Making WordPress.org

Changeset 12885


Ignore:
Timestamp:
09/14/2023 09:12:32 PM (17 months ago)
Author:
coffee2code
Message:

Photo Directory, Rejection: Hide custom taxonomies, 'stats', and 'likes' columns in listings of rejected submissions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/rejection.php

    r12840 r12885  
    158158        add_filter( 'manage_posts_columns',                    [ __CLASS__, 'posts_columns' ], 8, 2 );
    159159        add_action( "manage_{$post_type}_posts_custom_column", [ __CLASS__, 'custom_rejection_columns' ], 10, 2 );
     160
     161        // Remove columns.
     162        add_filter( "manage_edit-{$post_type}_columns",        [ __CLASS__, 'remove_columns' ] );
    160163
    161164        // Log the user and datetime when a photo gets rejected.
     
    10391042
    10401043    /**
     1044     * Removes certain columns from the listing of rejected photos.
     1045     *
     1046     * Removes these columns:
     1047     * - The custom taxonomy columns (Categories, Colors, Tags) since those
     1048     *   get removed upon rejection.
     1049     * - The number of likes, as provided by Jetpack.
     1050     * - Stats
     1051     *
     1052     * @param  array $columns Array of post column titles.
     1053     * @return array
     1054     */
     1055    public static function remove_columns( $columns ) {
     1056        if (
     1057            filter_input( INPUT_GET, 'post_type' ) === Registrations::get_post_type()
     1058        &&
     1059            filter_input( INPUT_GET, 'post_status' ) === self::get_post_status()
     1060        ) {
     1061            foreach ( Registrations::get_taxonomy( 'all' ) as $tax ) {
     1062                unset( $columns[ "taxonomy-{$tax}" ] );
     1063            }
     1064            unset( $columns['likes'] );
     1065            unset( $columns['stats'] );
     1066        }
     1067
     1068        return $columns;
     1069    }
     1070
     1071    /**
    10411072     * Hides 'Restore' (aka untrash) bulk action for deleted photo posts.
    10421073     *
Note: See TracChangeset for help on using the changeset viewer.