Make WordPress Core

Ticket #33521: 33521.diff

File 33521.diff, 2.2 KB (added by Cybr, 9 years ago)
  • wp-admin/includes/class-wp-terms-list-table.php

     
    164164         * @return array
    165165         */
    166166        public function get_columns() {
     167                $taxonomy = $this->screen->taxonomy;
     168
    167169                $columns = array(
    168170                        'cb'          => '<input type="checkbox" />',
    169171                        'name'        => _x( 'Name', 'term name' ),
     
    177179                        $columns['posts'] = _x( 'Count', 'Number/count of items' );
    178180                }
    179181
    180                 return $columns;
     182                /**
     183                 * Filter the columns displayed in the Terms list table.
     184                 *
     185                 * @since 4.3.1
     186                 *
     187                 * @param array  $columns An array of column names.
     188                 */
     189                $columns = apply_filters( "manage_{$taxonomy}_columns", $columns );
     190
     191                /**
     192                 * Filter the columns displayed in the Terms list table for a specific term id.
     193                 *
     194                 * The dynamic portion of the hook name, `$taxonomy`, refers to the term id slug.
     195                 *
     196                 * @since 4.3.1
     197                 *
     198                 * @param array $columns An array of column names.
     199                 */
     200                return apply_filters( "manage_{$taxonomy}_posts_columns", $columns );
    181201        }
    182202
    183203        /**
     
    506526         * @return string
    507527         */
    508528        public function column_default( $tag, $column_name ) {
     529                $taxonomy = $this->screen->taxonomy;
     530
    509531                /**
    510532                 * Filter the displayed columns in the terms list table.
    511533                 *
     
    518540                 * @param string $column_name Name of the column.
    519541                 * @param int    $term_id     Term ID.
    520542                 */
    521                 return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
     543                $column = apply_filters( "manage_{$taxonomy}_custom_column", $string = '', $column_name, $tag->term_id );
     544
     545                /**
     546                 * If the filter isn't used, return action as per default.
     547                 * Else, return the filter output.
     548                 *
     549                 * Fires for each custom column of a specific term id in the Term list table.
     550                 *
     551                 * @param string $column_name The name of the column to display.
     552                 * @param int    $term_id     Term ID.
     553                 *
     554                 * @since 4.3.1
     555                 */
     556                if ( empty( $column ) ) {
     557                        do_action( "manage_{$taxonomy}_custom_column", $column_name, $tag->term_id );
     558                } else {
     559                        return $column;
     560                }
    522561        }
    523562
    524563        /**