get_taxonomies_for_attachments example

/** * @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' );
        
'posts_per_page',
        'paged',
        'post_mime_type',
        'post_parent',
        'author',
        'post__in',
        'post__not_in',
        'year',
        'monthnum',
    );

    foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) {
        if ( $t->query_var && isset( $query[ $t->query_var ] ) ) {
            $keys[] = $t->query_var;
        }
    }

    $query              = array_intersect_key( $queryarray_flip( $keys ) );
    $query['post_type'] = 'attachment';

    if (
        MEDIA_TRASH &&
        ! empty( $_REQUEST['query']['post_status'] ) &&
        


$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );

// $menu[5] = Posts.
$menu[10]                     = array( __( 'Media' ), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' );
    $submenu['upload.php'][5] = array( __( 'Library' ), 'upload_files', 'upload.php' );
    /* translators: Add new file. */
    $submenu['upload.php'][10] = array( _x( 'Add New', 'file' ), 'upload_files', 'media-new.php' );
    $i                         = 15;
foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
    if ( ! $tax->show_ui || ! $tax->show_in_menu ) {
        continue;
    }

    $submenu['upload.php'][ $i++ ] = array( esc_attr( $tax->labels->menu_name )$tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&amp;post_type=attachment' );
}
    unset( $tax$i );

$menu[15]                           = array( __( 'Links' ), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'dashicons-admin-links' );
    $submenu['link-manager.php'][5] = array( _x( 'All Links', 'admin menu' ), 'manage_links', 'link-manager.php' );
    /* translators: Add new links. */
    
$join  .= $clauses['join'];
            $where .= $clauses['where'];
        }

        if ( $this->is_tax ) {
            if ( empty( $post_type ) ) {
                // Do a fully inclusive search for currently registered post types of queried taxonomies.                 $post_type  = array();
                $taxonomies = array_keys( $this->tax_query->queried_terms );
                foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
                    $object_taxonomies = 'attachment' === $pt ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt );
                    if ( array_intersect( $taxonomies$object_taxonomies ) ) {
                        $post_type[] = $pt;
                    }
                }
                if ( ! $post_type ) {
                    $post_type = 'any';
                } elseif ( count( $post_type ) === 1 ) {
                    $post_type = $post_type[0];
                }

                $post_status_join = true;
            }
Home | Imprint | This part of the site doesn't use cookies.