Make WordPress Core

Changeset 47951


Ignore:
Timestamp:
06/10/2020 04:54:21 PM (6 years ago)
Author:
whyisjake
Message:

Administration: Add a new filter to extend set-screen-option.

Props: xknown, SergeyBiryukov.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r47808 r47951  
    689689                                break;
    690690                        default:
     691                                if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
     692                                        /**
     693                                         * Filters a screen option value before it is set.
     694                                         *
     695                                         * The filter can also be used to modify non-standard [items]_per_page
     696                                         * settings. See the parent function for a full list of standard options.
     697                                         *
     698                                         * Returning false to the filter will skip saving the current option.
     699                                         *
     700                                         * @since 2.8.0
     701                                         * @since 5.4.2 Only applied to options ending with '_page',
     702                                         *              or the 'layout_columns' option.
     703                                         *
     704                                         * @see set_screen_options()
     705                                         *
     706                                         * @param bool   $keep   Whether to save or skip saving the screen option value.
     707                                         *                       Default false.
     708                                         * @param string $option The option name.
     709                                         * @param int    $value  The number of rows to use.
     710                                         */
     711                                        $value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     712                                }
     713
    691714                                /**
    692715                                 * Filters a screen option value before it is set.
    693716                                 *
    694                                  * The filter can also be used to modify non-standard [items]_per_page
    695                                  * settings. See the parent function for a full list of standard options.
     717                                 * The dynamic portion of the hook, `$option`, refers to the option name.
    696718                                 *
    697719                                 * Returning false to the filter will skip saving the current option.
    698720                                 *
    699                                  * @since 2.8.0
     721                                 * @since 5.4.2
    700722                                 *
    701723                                 * @see set_screen_options()
    702724                                 *
    703                                  * @param bool     $keep   Whether to save or skip saving the screen option value. Default false.
    704                                  * @param string   $option The option name.
    705                                  * @param int      $value  The number of rows to use.
     725                                 * @param bool   $keep   Whether to save or skip saving the screen option value.
     726                                 *                       Default false.
     727                                 * @param string $option The option name.
     728                                 * @param int    $value  The number of rows to use.
    706729                                 */
    707                                 $value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
     730                                $value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
    708731
    709732                                if ( false === $value ) {
Note: See TracChangeset for help on using the changeset viewer.