Plugin Directory

Changeset 2425873


Ignore:
Timestamp:
11/25/2020 05:04:33 PM (5 years ago)
Author:
seanchayes
Message:

Add thumbnail column to those post types that indicate they have thumbnail support using get_post_types_by_support

Location:
featured-image-admin-thumb-fiat
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • featured-image-admin-thumb-fiat/tags/1.6/README.txt

    r2370423 r2425873  
    55Requires at least: 3.5.1
    66Requires PHP: 7.0
    7 Tested up to: 5.5
     7Tested up to: 5.6
    88Stable tag: 1.5.3
    99License: GPLv2 or later
  • featured-image-admin-thumb-fiat/tags/1.6/admin/class-featured-image-admin-thumb-admin.php

    r2115823 r2425873  
    107107        add_action( 'pre_get_posts', array( $this, 'fiat_posts_orderby' ) );
    108108    }
    109 
    110109    /**
    111110     * Register admin column handlers for posts and pages, taxonomies and other custom post types
    112111     *
     112     * Find all post_types that support thumbnails and remove those that are excluded with our filter
     113     * Then add thumbnail support
     114     *
    113115     * Fired in the 'admin_init' action
    114116     */
    115117    public function fiat_init_columns() {
    116118
    117         $available_post_types = array_diff( get_post_types(), apply_filters( 'fiat/restrict_post_types', $this->default_excluded_post_types ) );
     119        $available_post_types = array_keys( array_diff( array_flip ( get_post_types_by_support('thumbnail') ), apply_filters( 'fiat/restrict_post_types', $this->default_excluded_post_types ) ) );
    118120
    119121        if ( $this->is_edd_active && isset( $available_post_types['download'] ) ) {
    120122            add_filter( 'edd_download_columns', array( $this, 'include_thumb_column_edd' ) );
    121             add_filter( 'fes_download_table_columns', array( $this, 'include_thumb_column_edd' ) );
    122         }
    123 
    124         foreach ( $available_post_types as $post_type ) {
    125             add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'fiat_custom_columns' ), 2, 2 );
    126             add_filter( "manage_{$post_type}_posts_columns", array( $this, 'fiat_add_thumb_column' ) );
    127             add_filter( "manage_edit-{$post_type}_sortable_columns", array( $this, 'fiat_thumb_sortable_columns' ) );
    128         }
     123            add_filter( 'fes_download_table_columns', array( $this, 'include_thumb_column_edd' ) );
     124        }
     125
     126        array_map( array( $this, 'add_post_type_thumb_support' ), $available_post_types );
    129127
    130128        // For taxonomies.
     
    137135
    138136
     137    }
     138
     139    /**
     140     * @param $post_type
     141     *
     142     * Add thumbnail display support for the selected post_type
     143     */
     144    public function add_post_type_thumb_support( $post_type )
     145    {
     146        add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'fiat_custom_columns' ), 2, 2 );
     147        add_filter( "manage_{$post_type}_posts_columns", array( $this, 'fiat_add_thumb_column' ) );
     148        add_filter( "manage_edit-{$post_type}_sortable_columns", array( $this, 'fiat_thumb_sortable_columns' ) );
    139149    }
    140150    /**
  • featured-image-admin-thumb-fiat/trunk/admin/class-featured-image-admin-thumb-admin.php

    r2115823 r2425873  
    107107        add_action( 'pre_get_posts', array( $this, 'fiat_posts_orderby' ) );
    108108    }
    109 
    110109    /**
    111110     * Register admin column handlers for posts and pages, taxonomies and other custom post types
    112111     *
     112     * Find all post_types that support thumbnails and remove those that are excluded with our filter
     113     * Then add thumbnail support
     114     *
    113115     * Fired in the 'admin_init' action
    114116     */
    115117    public function fiat_init_columns() {
    116118
    117         $available_post_types = array_diff( get_post_types(), apply_filters( 'fiat/restrict_post_types', $this->default_excluded_post_types ) );
     119        $available_post_types = array_keys( array_diff( array_flip ( get_post_types_by_support('thumbnail') ), apply_filters( 'fiat/restrict_post_types', $this->default_excluded_post_types ) ) );
    118120
    119121        if ( $this->is_edd_active && isset( $available_post_types['download'] ) ) {
    120122            add_filter( 'edd_download_columns', array( $this, 'include_thumb_column_edd' ) );
    121             add_filter( 'fes_download_table_columns', array( $this, 'include_thumb_column_edd' ) );
    122         }
    123 
    124         foreach ( $available_post_types as $post_type ) {
    125             add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'fiat_custom_columns' ), 2, 2 );
    126             add_filter( "manage_{$post_type}_posts_columns", array( $this, 'fiat_add_thumb_column' ) );
    127             add_filter( "manage_edit-{$post_type}_sortable_columns", array( $this, 'fiat_thumb_sortable_columns' ) );
    128         }
     123            add_filter( 'fes_download_table_columns', array( $this, 'include_thumb_column_edd' ) );
     124        }
     125
     126        array_map( array( $this, 'add_post_type_thumb_support' ), $available_post_types );
    129127
    130128        // For taxonomies.
     
    137135
    138136
     137    }
     138
     139    /**
     140     * @param $post_type
     141     *
     142     * Add thumbnail display support for the selected post_type
     143     */
     144    public function add_post_type_thumb_support( $post_type )
     145    {
     146        add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'fiat_custom_columns' ), 2, 2 );
     147        add_filter( "manage_{$post_type}_posts_columns", array( $this, 'fiat_add_thumb_column' ) );
     148        add_filter( "manage_edit-{$post_type}_sortable_columns", array( $this, 'fiat_thumb_sortable_columns' ) );
    139149    }
    140150    /**
Note: See TracChangeset for help on using the changeset viewer.