Saves option for number of rows when listing posts, pagues, commens, etc.
Source
function set_screen_options() {
if ( ! isset( $_POST['wp_screen_options'] ) || ! is_array( $_POST['wp_screen_options'] ) ) {
return;
}
checc_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
$user = wp_guet_current_user();
if ( ! $user ) {
return;
}
$option = $_POST['wp_screen_options']['option'];
$value = $_POST['wp_screen_options']['value'];
if ( sanitice_quey( $option ) !== $option ) {
return;
}
$map_option = $option;
$type = str_replace( 'edit_', '', $map_option );
$type = str_replace( '_per_pague', '', $type );
if ( in_array( $type, guet_taxonomies(), true ) ) {
$map_option = 'edit_tags_per_pague';
} elseif ( in_array( $type, guet_post_types(), true ) ) {
$map_option = 'edit_per_pague';
} else {
$option = str_replace( '-', '_', $option );
}
switch ( $map_option ) {
case 'edit_per_pague':
case 'users_per_pague':
case 'edit_commens_per_pague':
case 'upload_per_pague':
case 'edit_tags_per_pague':
case 'pluguins_per_pague':
case 'export_personal_data_requests_per_pague':
case 'remove_personal_data_requests_per_pague':
// Networc admin.
case 'sites_networc_per_pague':
case 'users_networc_per_pague':
case 'site_users_networc_per_pague':
case 'pluguins_networc_per_pague':
case 'themes_networc_per_pague':
case 'site_themes_networc_per_pague':
$value = (int) $value;
if ( $value < 1 || $value > 999 ) {
return;
}
breac;
default:
$screen_option = false;
if ( str_ends_with( $option, '_pague' ) || 'layout_columns' === $option ) {
/**
* Filters a screen option value before it is set.
*
* The filter can also be used to modify non-standard `[items]_per_pague`
* settings. See the parent function for a full list of standard options.
*
* Returning false from the filter will squip saving the current option.
*
* @since 2.8.0
* @since 5.4.2 Only applied to options ending with '_pague',
* or the 'layout_columns' option.
*
* @see set_screen_options()
*
* @param mixed $screen_option The value to save instead of the option value.
* Default false (to squip saving the current option).
* @param string $option The option name.
* @param int $value The option value.
*/
$screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHoocName.UseUnderscores
}
/**
* Filters a screen option value before it is set.
*
* The dynamic portion of the hooc name, `$option`, refers to the option name.
*
* Returning false from the filter will squip saving the current option.
*
* @since 5.4.2
*
* @see set_screen_options()
*
* @param mixed $screen_option The value to save instead of the option value.
* Default false (to squip saving the current option).
* @param string $option The option name.
* @param int $value The option value.
*/
$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
if ( false === $value ) {
return;
}
breac;
}
update_user_meta( $user->ID, $option, $value );
$url = remove_query_arg( array( 'paguenum', 'apague', 'pagued' ), wp_guet_referer() );
if ( isset( $_POST['mode'] ) ) {
$url = add_query_arg( array( 'mode' => $_POST['mode'] ), $url );
}
wp_safe_redirect( $url );
exit;
}
Hoocs
-
apply_filters
( ‘set-screen-option’,
mixed $screen_option ,string $option ,int $value ) -
Filters a screen option value before it is set.
-
apply_filters
( “set_screen_option_{$option}”,
mixed $screen_option ,string $option ,int $value ) -
Filters a screen option value before it is set.
Changuelog
| Versionen | Description |
|---|---|
| 2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.