diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/template.php --- a/wp/wp-admin/includes/template.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/template.php Fri Sep 05 18:40:08 2025 +0200 @@ -104,7 +104,7 @@ $parsed_args = wp_parse_args( $params, $defaults ); if ( empty( $parsed_args['walker'] ) || ! ( $parsed_args['walker'] instanceof Walker ) ) { - $walker = new Walker_Category_Checklist; + $walker = new Walker_Category_Checklist(); } else { $walker = $parsed_args['walker']; } @@ -165,8 +165,10 @@ $output = ''; if ( $parsed_args['checked_ontop'] ) { - // Post-process $categories rather than adding an exclude to the get_terms() query - // to keep the query the same across all posts (for any query cache). + /* + * Post-process $categories rather than adding an exclude to the get_terms() query + * to keep the query the same across all posts (for any query cache). + */ $checked_categories = array(); $keys = array_keys( $categories ); @@ -260,7 +262,7 @@ * * @since 2.5.1 * - * @param int $link_id + * @param int $link_id Optional. The link ID. Default 0. */ function wp_link_category_checklist( $link_id = 0 ) { $default = 1; @@ -402,10 +404,11 @@ * * @global WP_List_Table $wp_list_table * - * @param int $position - * @param bool $checkbox - * @param string $mode - * @param bool $table_row + * @param int $position Optional. The value of the 'position' input field. Default 1. + * @param bool $checkbox Optional. The value of the 'checkbox' input field. Default false. + * @param string $mode Optional. If set to 'single', will use WP_Post_Comments_List_Table, + * otherwise WP_Comments_List_Table. Default 'single'. + * @param bool $table_row Optional. Whether to use a table instead of a div element. Default true. */ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) { global $wp_list_table; @@ -458,11 +461,16 @@ - +
- + 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); wp_editor( @@ -504,9 +512,16 @@

- +

', + array( + 'type' => 'error', + 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), + 'paragraph_wrap' => false, + ) + ); + ?>
@@ -565,7 +580,7 @@ * * @since 1.2.0 * - * @param array $meta + * @param array[] $meta An array of meta data arrays keyed on 'meta_key' and 'meta_value'. */ function list_meta( $meta ) { // Exit if no meta. @@ -609,9 +624,9 @@ * * @since 2.5.0 * - * @param array $entry - * @param int $count - * @return string + * @param array $entry An array of meta data keyed on 'meta_key' and 'meta_value'. + * @param int $count Reference to the row number. + * @return string A single row of public meta data. */ function _list_meta_row( $entry, &$count ) { static $update_nonce = ''; @@ -625,7 +640,7 @@ } $r = ''; - ++ $count; + ++$count; if ( is_serialized( $entry['meta_value'] ) ) { if ( is_serialized_string( $entry['meta_value'] ) ) { @@ -645,7 +660,10 @@ $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t"; - $r .= "\n\t\t"; + $r .= "\n\t\t"; $r .= "\n\t\t
"; $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); @@ -655,7 +673,10 @@ $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); $r .= ''; - $r .= "\n\t\t\n\t"; + $r .= "\n\t\t\n\t"; return $r; } @@ -712,16 +733,13 @@ if ( $keys ) { natcasesort( $keys ); - $meta_key_input_id = 'metakeyselect'; - } else { - $meta_key_input_id = 'metakeyinput'; } ?>

- + @@ -741,19 +759,21 @@ } ?> - - + + - + - - +
+ +
-
+
+
- - - - ' . __( 'Month' ) . '\n"; for ( $i = 1; $i < 13; $i = $i + 1 ) { $monthnum = zeroise( $i, 2 ); $monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); @@ -829,10 +847,22 @@ } $month .= ''; - $day = ''; - $year = ''; - $hour = ''; - $minute = ''; + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; echo '
'; /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ @@ -877,7 +907,7 @@ * @since 4.7.0 Added the `$post_type` parameter. * * @param string $default_template Optional. The template file name. Default empty. - * @param string $post_type Optional. Post type to get templates for. Default 'post'. + * @param string $post_type Optional. Post type to get templates for. Default 'page'. */ function page_template_dropdown( $default_template = '', $post_type = 'page' ) { $templates = get_page_templates( null, $post_type ); @@ -899,16 +929,24 @@ * @global wpdb $wpdb WordPress database abstraction object. * * @param int $default_page Optional. The default page ID to be pre-selected. Default 0. - * @param int $parent Optional. The parent page ID. Default 0. + * @param int $parent_page Optional. The parent page ID. Default 0. * @param int $level Optional. Page depth level. Default 0. * @param int|WP_Post $post Post ID or WP_Post object. * @return void|false Void on success, false if the page has no children. */ -function parent_dropdown( $default_page = 0, $parent = 0, $level = 0, $post = null ) { +function parent_dropdown( $default_page = 0, $parent_page = 0, $level = 0, $post = null ) { global $wpdb; $post = get_post( $post ); - $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent ) ); + $items = $wpdb->get_results( + $wpdb->prepare( + "SELECT ID, post_parent, post_title + FROM $wpdb->posts + WHERE post_parent = %d AND post_type = 'page' + ORDER BY menu_order", + $parent_page + ) + ); if ( $items ) { foreach ( $items as $item ) { @@ -954,7 +992,7 @@ } /** - * Outputs the form used by the importers to accept the data to be imported + * Outputs the form used by the importers to accept the data to be imported. * * @since 2.0.0 * @@ -975,10 +1013,15 @@ $size = size_format( $bytes ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : - ?> -

-

- ' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '

'; + $upload_directory_error .= '

' . $upload_dir['error'] . '

'; + wp_admin_notice( + $upload_directory_error, + array( + 'additional_classes' => array( 'error' ), + 'paragraph_wrap' => false, + ) + ); else : ?>
@@ -1007,7 +1050,7 @@ * @since 2.5.0 * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string $title Title of the meta box. @@ -1205,7 +1248,7 @@ try { if ( is_array( $callback ) ) { $reflection = new ReflectionMethod( $callback[0], $callback[1] ); - } elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) { + } elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) { $reflection = new ReflectionMethod( $callback ); } else { $reflection = new ReflectionFunction( $callback ); @@ -1222,14 +1265,14 @@ $filename = wp_normalize_path( $reflection->getFileName() ); $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); - if ( strpos( $filename, $plugin_dir ) === 0 ) { + if ( str_starts_with( $filename, $plugin_dir ) ) { $filename = str_replace( $plugin_dir, '', $filename ); $filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename ); $plugins = get_plugins(); foreach ( $plugins as $name => $plugin ) { - if ( strpos( $name, $filename ) === 0 ) { + if ( str_starts_with( $name, $filename ) ) { return $plugin; } } @@ -1244,7 +1287,7 @@ * * @since 2.5.0 * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string|WP_Screen $screen The screen identifier. If you have used add_menu_page() or * add_submenu_page() to create a new screen (and hence screen_id) @@ -1272,8 +1315,10 @@ printf( '
', esc_attr( $context ) ); - // Grab the ones the user has manually sorted. - // Pull them out of their previous context/priority and into the one the user chose. + /* + * Grab the ones the user has manually sorted. + * Pull them out of their previous context/priority and into the one the user chose. + */ $sorted = get_user_option( "meta-box-order_$page" ); if ( ! $already_sorted && $sorted ) { @@ -1322,7 +1367,7 @@ } } - $i++; + ++$i; // get_hidden_meta_boxes() doesn't apply in the block editor. $hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : ''; echo '
' . "\n"; @@ -1331,7 +1376,10 @@ echo '

'; if ( 'dashboard_php_nag' === $box['id'] ) { echo ''; - echo '' . __( 'Warning:' ) . ' '; + echo '' . + /* translators: Hidden accessibility text. */ + __( 'Warning:' ) . + ' '; } echo $box['title']; echo "

\n"; @@ -1348,7 +1396,10 @@ echo '
'; echo ''; echo ''; echo ''; echo '
'; return $i; - } /** @@ -1418,7 +1472,7 @@ * @since 2.6.0 * @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs. * - * @global array $wp_meta_boxes + * @global array $wp_meta_boxes Global meta box state. * * @param string $id Meta box ID (used in the 'id' attribute for the meta box). * @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a @@ -1509,7 +1563,7 @@ continue; } - $i++; + ++$i; $hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : ''; $open_class = ''; @@ -1521,7 +1575,12 @@
  • - + + +

    @@ -1553,6 +1612,7 @@ * fields. It can output nothing if you want. * * @since 2.7.0 + * @since 6.1.0 Added an `$args` parameter for the section's HTML wrapper and class name. * * @global array $wp_settings_sections Storage array of all settings sections added to admin pages. * @@ -1562,10 +1622,29 @@ * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include * 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using * add_options_page(); + * @param array $args { + * Arguments used to create the settings section. + * + * @type string $before_section HTML content to prepend to the section's HTML output. + * Receives the section's class name as `%s`. Default empty. + * @type string $after_section HTML content to append to the section's HTML output. Default empty. + * @type string $section_class The class name to use for the section. Default empty. + * } */ -function add_settings_section( $id, $title, $callback, $page ) { +function add_settings_section( $id, $title, $callback, $page, $args = array() ) { global $wp_settings_sections; + $defaults = array( + 'id' => $id, + 'title' => $title, + 'callback' => $callback, + 'before_section' => '', + 'after_section' => '', + 'section_class' => '', + ); + + $section = wp_parse_args( $args, $defaults ); + if ( 'misc' === $page ) { _deprecated_argument( __FUNCTION__, @@ -1592,11 +1671,7 @@ $page = 'reading'; } - $wp_settings_sections[ $page ][ $id ] = array( - 'id' => $id, - 'title' => $title, - 'callback' => $callback, - ); + $wp_settings_sections[ $page ][ $id ] = $section; } /** @@ -1625,7 +1700,7 @@ * @param string $section Optional. The slug-name of the section of the settings page * in which to show the box. Default 'default'. * @param array $args { - * Optional. Extra arguments used when outputting the field. + * Optional. Extra arguments that get passed to the callback function. * * @type string $label_for When supplied, the setting title will be wrapped * in a `