', 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 '
' . sprintf(
@@ -1358,7 +1409,10 @@
) . '';
echo '
';
echo '
' . sprintf(
@@ -1369,7 +1423,7 @@
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 `