Make WordPress Core


Ignore:
Timestamp:
09/18/2023 01:17:39 PM (18 months ago)
Author:
SergeyBiryukov
Message:

Quick Edit: Allow Quick Edit to be disabled for custom post types or taxonomies.

Some custom post types or taxonomies may not need the Quick Edit functionality, in which case adding hidden fields and rendering the form with the data to edit would be redundant.

This commit introduces two filters for more granular control:

  • quick_edit_enabled_for_post_type
  • quick_edit_enabled_for_taxonomy

Follow-up to [8857], [9083], [9098].

Props garyc40, sabernhardt, mukesh27, costdev, oglekler, wyrfel, peterwilsoncc, faguni22, robinwpdeveloper, webcommsat, johnbillion, azaozz, hellofromTonya, GunGeekATX, Jick, mikeschinkel, jane, nacin, helen, wonderboymusic, DrewAPicture, SergeyBiryukov.
Fixes #16502, #19343, #57596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r56586 r56611  
    11691169        }
    11701170
    1171         get_inline_data( $post );
     1171        /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
     1172        $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type );
     1173
     1174        if ( $quick_edit_enabled ) {
     1175            get_inline_data( $post );
     1176        }
    11721177    }
    11731178
     
    14761481            );
    14771482
    1478             if ( 'wp_block' !== $post->post_type ) {
     1483            /**
     1484             * Filters whether Quick Edit should be enabled for the given post type.
     1485             *
     1486             * @since 6.4.0
     1487             *
     1488             * @param bool   $enable    Whether to enable the Quick Edit functionality. Default true.
     1489             * @param string $post_type Post type name.
     1490             */
     1491            $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type );
     1492
     1493            if ( $quick_edit_enabled && 'wp_block' !== $post->post_type ) {
    14791494                $actions['inline hide-if-no-js'] = sprintf(
    14801495                    '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
Note: See TracChangeset for help on using the changeset viewer.