wp_filter_object_list example


function get_taxonomies( $args = array()$output = 'names', $operator = 'and' ) {
    global $wp_taxonomies;

    $field = ( 'names' === $output ) ? 'name' : false;

    return wp_filter_object_list( $wp_taxonomies$args$operator$field );
}

/** * Returns the names or objects of the taxonomies which are registered for the requested object or object type, * such as a post object or post type name. * * Example: * * $taxonomies = get_object_taxonomies( 'post' ); * * This results in: * * Array( 'category', 'post_tag' ) * * @since 2.3.0 * * @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies. * * @param string|string[]|WP_Post $object_type Name of the type of taxonomy object, or an object (row from posts). * @param string $output Optional. The type of output to return in the array. Accepts either * 'names' or 'objects'. Default 'names'. * @return string[]|WP_Taxonomy[] The names or objects of all taxonomies of `$object_type`. */

function get_post_stati( $args = array()$output = 'names', $operator = 'and' ) {
    global $wp_post_statuses;

    $field = ( 'names' === $output ) ? 'name' : false;

    return wp_filter_object_list( $wp_post_statuses$args$operator$field );
}

/** * Determines whether the post type is hierarchical. * * A false return value might also mean that the post type does not exist. * * @since 3.0.0 * * @see get_post_type_object() * * @param string $post_type Post type name * @return bool Whether post type is hierarchical. */
/** * @return string[] Array of column titles keyed by their column name. */
    public function get_columns() {
        $posts_columns       = array();
        $posts_columns['cb'] = '<input type="checkbox" />';
        /* translators: Column name. */
        $posts_columns['title']  = _x( 'File', 'column name' );
        $posts_columns['author'] = __( 'Author' );

        $taxonomies = get_taxonomies_for_attachments( 'objects' );
        $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );

        /** * Filters the taxonomy columns for attachments in the Media list table. * * @since 3.5.0 * * @param string[] $taxonomies An array of registered taxonomy names to show for attachments. * @param string $post_type The post type. Default 'attachment'. */
        $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' );
        $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );

        
if ( isset( $api->info['groups'] ) ) {
            $this->groups = $api->info['groups'];
        }

        if ( $installed_plugins ) {
            $js_plugins = array_fill_keys(
                array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ),
                array()
            );

            $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) );
            $upgrade_plugins   = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' );

            if ( $upgrade_plugins ) {
                $js_plugins['upgrade'] = array_values( $upgrade_plugins );
            }

            wp_localize_script(
                'updates',
                '_wpUpdatesItemCounts',
                array(
                    'plugins' => $js_plugins,
                    'totals'  => wp_get_update_data(),
                )

function wp_list_filter( $input_list$args = array()$operator = 'AND' ) {
    return wp_filter_object_list( $input_list$args$operator );
}

/** * Plucks a certain field out of each object or array in an array. * * This has the same functionality and prototype of * array_column() (PHP 5.5) but also supports objects. * * @since 3.1.0 * @since 4.0.0 $index_key parameter added. * @since 4.7.0 Uses `WP_List_Util` class. * * @param array $input_list List of objects or arrays. * @param int|string $field Field from the object to place instead of the entire object. * @param int|string $index_key Optional. Field from the object to use as keys for the new array. * Default null. * @return array Array of found values. If `$index_key` is set, an array of found values with keys * corresponding to `$index_key`. If `$index_key` is null, array keys from the original * `$input_list` will be preserved in the results. */
$posts_columns['cb'] = '<input type="checkbox" />';

        /* translators: Posts screen column name. */
        $posts_columns['title'] = _x( 'Title', 'column name' );

        if ( post_type_supports( $post_type, 'author' ) ) {
            $posts_columns['author'] = __( 'Author' );
        }

        $taxonomies = get_object_taxonomies( $post_type, 'objects' );
        $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );

        /** * Filters the taxonomy columns in the Posts list table. * * The dynamic portion of the hook name, `$post_type`, refers to the post * type slug. * * Possible hook names include: * * - `manage_taxonomies_for_post_columns` * - `manage_taxonomies_for_page_columns` * * @since 3.5.0 * * @param string[] $taxonomies Array of taxonomy names to show columns for. * @param string $post_type The post type. */
Home | Imprint | This part of the site doesn't use cookies.