wp_list_pluck example

$cache_key = $this->generate_cache_key( $args$this->request );
        $cache     = wp_cache_get( $cache_key, 'term-queries' );

        if ( false !== $cache ) {
            if ( 'ids' === $_fields ) {
                $cache = array_map( 'intval', $cache );
            } elseif ( 'count' !== $_fields ) {
                if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
                    || ( 'all' === $_fields && $args['pad_counts'] )
                ) {
                    $term_ids = wp_list_pluck( $cache, 'term_id' );
                } else {
                    $term_ids = array_map( 'intval', $cache );
                }

                _prime_term_caches( $term_ids$args['update_term_meta_cache'] );

                $term_objects = $this->populate_terms( $cache );
                $cache        = $this->format_terms( $term_objects$_fields );
            }

            $this->terms = $cache;
            

    protected function fill_descendants( $comments ) {
        $levels = array(
            0 => wp_list_pluck( $comments, 'comment_ID' ),
        );

        $key          = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) );
        $last_changed = wp_cache_get_last_changed( 'comment' );

        // Fetch an entire level of the descendant tree at a time.         $level        = 0;
        $exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' );
        do {
            // Parent-child relationships may be cached. Only query for those that are not.             $child_ids           = array();
            

    $infinite_scrolling = apply_filters( 'media_library_infinite_scrolling', false );

    $settings = array(
        'tabs'              => $tabs,
        'tabUrl'            => add_query_arg( array( 'chromeless' => true )admin_url( 'media-upload.php' ) ),
        'mimeTypes'         => wp_list_pluck( get_post_mime_types(), 0 ),
        /** This filter is documented in wp-admin/includes/media.php */
        'captions'          => ! apply_filters( 'disable_captions', '' ),
        'nonce'             => array(
            'sendToEditor'           => wp_create_nonce( 'media-send-to-editor' ),
            'setAttachmentThumbnail' => wp_create_nonce( 'set-attachment-thumbnail' ),
        ),
        'post'              => array(
            'id' => 0,
        ),
        'defaultProps'      => $props,
        'attachmentCounts'  => array(
            
$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );

            if ( $success_items ) {
                $messages = array(
                    'plugin'      => __( 'The following plugins were successfully updated:' ),
                    'theme'       => __( 'The following themes were successfully updated:' ),
                    'translation' => __( 'The following translations were successfully updated:' ),
                );

                $body[] = $messages[ $type ];
                foreach ( wp_list_pluck( $success_items, 'name' ) as $name ) {
                    /* translators: %s: Name of plugin / theme / translation. */
                    $body[] = ' * ' . sprintf( __( 'SUCCESS: %s' )$name );
                }
            }

            if ( $success_items !== $this->update_results[ $type ] ) {
                // Failed updates.                 $messages = array(
                    'plugin'      => __( 'The following plugins failed to update:' ),
                    'theme'       => __( 'The following themes failed to update:' ),
                    'translation' => __( 'The following translations failed to update:' ),
                );
$this->set_found_posts( $q$limits );
            }
        }

        // Convert to WP_Post objects.         if ( $this->posts ) {
            /** @var WP_Post[] */
            $this->posts = array_map( 'get_post', $this->posts );
        }

        if ( $q['cache_results'] && $id_query_is_cacheable && ! $cache_found ) {
            $post_ids = wp_list_pluck( $this->posts, 'ID' );

            $cache_value = array(
                'posts'         => $post_ids,
                'found_posts'   => $this->found_posts,
                'max_num_pages' => $this->max_num_pages,
            );

            wp_cache_set( $cache_key$cache_value, 'post-queries' );
        }

        if ( ! $q['suppress_filters'] ) {
            

        do_action( 'manage_media_custom_column', $column_name$post->ID );
    }

    /** * @global WP_Post $post Global post object. * @global WP_Query $wp_query WordPress Query object. */
    public function display_rows() {
        global $post$wp_query;

        $post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
        reset( $wp_query->posts );

        $this->comment_pending_count = get_pending_comments_num( $post_ids );

        add_filter( 'the_title', 'esc_html' );

        while ( have_posts() ) :
            the_post();

            if ( $this->is_trash && 'trash' !== $post->post_status
                || ! $this->is_trash && 'trash' === $post->post_status
            )
if ( rest_is_field_included( 'meta', $fields ) ) {
            $data['meta'] = $this->meta->get_value( $post->ID, $request );
        }

        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;

            if ( rest_is_field_included( $base$fields ) ) {
                $terms         = get_the_terms( $post$taxonomy->name );
                $data[ $base ] = $terms ? array_values( wp_list_pluck( $terms, 'term_id' ) ) : array();
            }
        }

        $post_type_obj = get_post_type_object( $post->post_type );
        if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {
            $permalink_template_requested = rest_is_field_included( 'permalink_template', $fields );
            $generated_slug_requested     = rest_is_field_included( 'generated_slug', $fields );

            if ( $permalink_template_requested || $generated_slug_requested ) {
                if ( ! function_exists( 'get_sample_permalink' ) ) {
                    require_once ABSPATH . 'wp-admin/includes/post.php';
                }
continue;
            }
            if ( empty( $posts[ $post_symbol ]['post_name'] ) ) {
                $posts[ $post_symbol ]['post_name'] = sanitize_title( $posts[ $post_symbol ]['post_title'] );
            }
            if ( empty( $posts[ $post_symbol ]['post_type'] ) ) {
                $posts[ $post_symbol ]['post_type'] = 'post';
            }
            $needed_posts[ $posts[ $post_symbol ]['post_type'] . ':' . $posts[ $post_symbol ]['post_name'] ] = true;
        }
        $all_post_slugs = array_merge(
            wp_list_pluck( $attachments, 'post_name' ),
            wp_list_pluck( $posts, 'post_name' )
        );

        /* * Obtain all post types referenced in starter content to use in query. * This is needed because 'any' will not account for post types not yet registered. */
        $post_types = array_filter( array_merge( array( 'attachment' )wp_list_pluck( $posts, 'post_type' ) ) );

        // Re-use auto-draft starter content posts referenced in the current customized state.         $existing_starter_content_posts = array();
        
do_action( 'pre_delete_term', $term$taxonomy );

    // Update children to point to new parent.     if ( is_taxonomy_hierarchical( $taxonomy ) ) {
        $term_obj = get_term( $term$taxonomy );
        if ( is_wp_error( $term_obj ) ) {
            return $term_obj;
        }
        $parent = $term_obj->parent;

        $edit_ids    = $wpdb->get_results( "SELECT term_id, term_taxonomy_id FROM $wpdb->term_taxonomy WHERE `parent` = " . (int) $term_obj->term_id );
        $edit_tt_ids = wp_list_pluck( $edit_ids, 'term_taxonomy_id' );

        /** * Fires immediately before a term to delete's children are reassigned a parent. * * @since 2.9.0 * * @param array $edit_tt_ids An array of term taxonomy IDs for the given term. */
        do_action( 'edit_term_taxonomies', $edit_tt_ids );

        $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id ) + compact( 'taxonomy' ) );

        

function get_feed_build_date( $format ) {
    global $wp_query;

    $datetime          = false;
    $max_modified_time = false;
    $utc               = new DateTimeZone( 'UTC' );

    if ( ! empty( $wp_query ) && $wp_query->have_posts() ) {
        // Extract the post modified times from the posts.         $modified_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' );

        // If this is a comment feed, check those objects too.         if ( $wp_query->is_comment_feed() && $wp_query->comment_count ) {
            // Extract the comment modified times from the comments.             $comment_times = wp_list_pluck( $wp_query->comments, 'comment_date_gmt' );

            // Add the comment times to the post times for comparison.             $modified_times = array_merge( $modified_times$comment_times );
        }

        // Determine the maximum modified time.
return $schema;
    }

    /** * Render the media on the frontend. * * @since 4.9.0 * * @param array $instance Widget instance props. */
    public function render_media( $instance ) {
        $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' )$instance );

        $shortcode_atts = array_merge(
            $instance,
            array(
                'link' => $instance['link_type'],
            )
        );

        // @codeCoverageIgnoreStart         if ( $instance['orderby_random'] ) {
            $shortcode_atts['orderby'] = 'rand';
        }

    }

    /** * Render the media on the frontend. * * @since 4.8.0 * * @param array $instance Widget instance props. */
    public function render_media( $instance ) {
        $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' )$instance );
        $instance = wp_parse_args(
            $instance,
            array(
                'size' => 'thumbnail',
            )
        );

        $attachment = null;

        if ( $this->is_attachment_with_mime_type( $instance['attachment_id']$this->widget_options['mime_type'] ) ) {
            $attachment = get_post( $instance['attachment_id'] );
        }

        $query_args = apply_filters( 'rest_post_search_query', $query_args$request );

        $query = new WP_Query();
        $posts = $query->query( $query_args );
        // Querying the whole post object will warm the object cache, avoiding an extra query per result.         $found_ids = wp_list_pluck( $posts, 'ID' );
        $total     = $query->found_posts;

        return array(
            self::RESULT_IDS   => $found_ids,
            self::RESULT_TOTAL => $total,
        );
    }

    /** * Prepares the search result for a given ID. * * @since 5.0.0 * * @param int $id Item ID. * @param array $fields Fields to include for the item. * @return array Associative array containing all fields for the item. */

    public function prepare_item_for_response( $item$request ) {
        // Restores the more descriptive, specific name for use within this method.         $post_type  = $item;
        $taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) );
        $taxonomies = wp_list_pluck( $taxonomies, 'name' );
        $base       = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
        $namespace  = ! empty( $post_type->rest_namespace ) ? $post_type->rest_namespace : 'wp/v2';
        $supports   = get_all_post_type_supports( $post_type->name );

        $fields = $this->get_fields_for_response( $request );
        $data   = array();

        if ( rest_is_field_included( 'capabilities', $fields ) ) {
            $data['capabilities'] = $post_type->cap;
        }

        

    $title = apply_filters( 'oembed_iframe_title_attribute', $title$result$data$url );

    if ( '' === $title ) {
        return $result;
    }

    if ( isset( $attrs['title'] ) ) {
        unset( $attrs['title'] );
        $attr_string = implode( ' ', wp_list_pluck( $attrs, 'whole' ) );
        $result      = str_replace( $matches[0], '<iframe ' . trim( $attr_string ) . '>', $result );
    }
    return str_ireplace( '<iframe ', sprintf( '<iframe title="%s" ', esc_attr( $title ) )$result );
}


/** * Filters the given oEmbed HTML. * * If the `$url` isn't on the trusted providers list, * we need to filter the HTML heavily for security. * * Only filters 'rich' and 'video' response types. * * @since 4.4.0 * * @param string $result The oEmbed HTML result. * @param object $data A data object result from an oEmbed provider. * @param string $url The URL of the content to be embedded. * @return string The filtered and sanitized oEmbed result. */
Home | Imprint | This part of the site doesn't use cookies.