Code Modernization: Rename parameters that use reserved keywords in `wp-admin/includes/plugin.php`.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit: * Renames the `$function` parameter to `$callback` in: * `add_menu_page()` * `add_submenu_page()` * `add_management_page()` * `add_options_page()` * `add_theme_page()` * `add_plugins_page()` * `add_users_page()` * `add_dashboard_page()` * `add_posts_page()` * `add_media_page()` * `add_links_page()` * `add_pages_page()` * `add_comments_page()` * Renames the `$echo` parameter to `$display` in `menu_page_url()`. * Renames the `$parent` parameter to `$parent_page` in `get_admin_page_parent()`. Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #55327. Built from https://develop.svn.wordpress.org/trunk@53215 git-svn-id: http://core.svn.wordpress.org/trunk@52804 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ec0574144a
commit
90cbd98c6b
|
@ -1292,7 +1292,7 @@ function uninstall_plugin( $plugin ) {
|
|||
* @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu page and only
|
||||
* include lowercase alphanumeric, dashes, and underscores characters to be compatible
|
||||
* with sanitize_key().
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param string $icon_url Optional. The URL to the icon to be used for this menu.
|
||||
* * Pass a base64-encoded SVG using a data URI, which will be colored to match
|
||||
* the color scheme. This should begin with 'data:image/svg+xml;base64,'.
|
||||
|
@ -1302,7 +1302,7 @@ function uninstall_plugin( $plugin ) {
|
|||
* @param int|float $position Optional. The position in the menu order this item should appear.
|
||||
* @return string The resulting page's hook_suffix.
|
||||
*/
|
||||
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
|
||||
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) {
|
||||
global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
|
||||
|
||||
$menu_slug = plugin_basename( $menu_slug );
|
||||
|
@ -1311,8 +1311,8 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func
|
|||
|
||||
$hookname = get_plugin_page_hookname( $menu_slug, '' );
|
||||
|
||||
if ( ! empty( $function ) && ! empty( $hookname ) && current_user_can( $capability ) ) {
|
||||
add_action( $hookname, $function );
|
||||
if ( ! empty( $callback ) && ! empty( $hookname ) && current_user_can( $capability ) ) {
|
||||
add_action( $hookname, $callback );
|
||||
}
|
||||
|
||||
if ( empty( $icon_url ) ) {
|
||||
|
@ -1380,11 +1380,11 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func
|
|||
* @param string $menu_slug The slug name to refer to this menu by. Should be unique for this menu
|
||||
* and only include lowercase alphanumeric, dashes, and underscores characters
|
||||
* to be compatible with sanitize_key().
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int|float $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
|
||||
$_registered_pages, $_parent_pages;
|
||||
|
||||
|
@ -1456,8 +1456,8 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
|||
ksort( $submenu[ $parent_slug ] );
|
||||
|
||||
$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
|
||||
if ( ! empty( $function ) && ! empty( $hookname ) ) {
|
||||
add_action( $hookname, $function );
|
||||
if ( ! empty( $callback ) && ! empty( $hookname ) ) {
|
||||
add_action( $hookname, $callback );
|
||||
}
|
||||
|
||||
$_registered_pages[ $hookname ] = true;
|
||||
|
@ -1492,12 +1492,12 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1516,12 +1516,12 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug,
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1540,12 +1540,12 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $f
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1564,12 +1564,12 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1588,17 +1588,17 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
if ( current_user_can( 'edit_users' ) ) {
|
||||
$parent = 'users.php';
|
||||
} else {
|
||||
$parent = 'profile.php';
|
||||
}
|
||||
return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1617,12 +1617,12 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1641,12 +1641,12 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug,
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1665,12 +1665,12 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1689,12 +1689,12 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1713,12 +1713,12 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1737,12 +1737,12 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $fun
|
|||
* @param string $menu_title The text to be used for the menu.
|
||||
* @param string $capability The capability required for this menu to be displayed to the user.
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param callable $function Optional. The function to be called to output the content for this page.
|
||||
* @param callable $callback Optional. The function to be called to output the content for this page.
|
||||
* @param int $position Optional. The position in the menu order this item should appear.
|
||||
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
|
||||
*/
|
||||
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
|
||||
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function, $position );
|
||||
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
|
||||
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1817,10 +1817,10 @@ function remove_submenu_page( $menu_slug, $submenu_slug ) {
|
|||
* @global array $_parent_pages
|
||||
*
|
||||
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
|
||||
* @param bool $echo Whether or not to echo the URL. Default true.
|
||||
* @param bool $display Optional. Whether or not to display the URL. Default true.
|
||||
* @return string The menu page URL.
|
||||
*/
|
||||
function menu_page_url( $menu_slug, $echo = true ) {
|
||||
function menu_page_url( $menu_slug, $display = true ) {
|
||||
global $_parent_pages;
|
||||
|
||||
if ( isset( $_parent_pages[ $menu_slug ] ) ) {
|
||||
|
@ -1837,7 +1837,7 @@ function menu_page_url( $menu_slug, $echo = true ) {
|
|||
|
||||
$url = esc_url( $url );
|
||||
|
||||
if ( $echo ) {
|
||||
if ( $display ) {
|
||||
echo $url;
|
||||
}
|
||||
|
||||
|
@ -1862,20 +1862,20 @@ function menu_page_url( $menu_slug, $echo = true ) {
|
|||
* @global array $_wp_menu_nopriv
|
||||
* @global array $_wp_submenu_nopriv
|
||||
*
|
||||
* @param string $parent The slug name for the parent menu (or the file name of a standard
|
||||
* WordPress admin page). Default empty string.
|
||||
* @param string $parent_page Optional. The slug name for the parent menu (or the file name
|
||||
* of a standard WordPress admin page). Default empty string.
|
||||
* @return string The parent file of the current admin page.
|
||||
*/
|
||||
function get_admin_page_parent( $parent = '' ) {
|
||||
function get_admin_page_parent( $parent_page = '' ) {
|
||||
global $parent_file, $menu, $submenu, $pagenow, $typenow,
|
||||
$plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv;
|
||||
|
||||
if ( ! empty( $parent ) && 'admin.php' !== $parent ) {
|
||||
if ( isset( $_wp_real_parent_file[ $parent ] ) ) {
|
||||
$parent = $_wp_real_parent_file[ $parent ];
|
||||
if ( ! empty( $parent_page ) && 'admin.php' !== $parent_page ) {
|
||||
if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
|
||||
$parent_page = $_wp_real_parent_file[ $parent_page ];
|
||||
}
|
||||
|
||||
return $parent;
|
||||
return $parent_page;
|
||||
}
|
||||
|
||||
if ( 'admin.php' === $pagenow && isset( $plugin_page ) ) {
|
||||
|
@ -1911,23 +1911,23 @@ function get_admin_page_parent( $parent = '' ) {
|
|||
return $parent_file;
|
||||
}
|
||||
|
||||
foreach ( array_keys( (array) $submenu ) as $parent ) {
|
||||
foreach ( $submenu[ $parent ] as $submenu_array ) {
|
||||
if ( isset( $_wp_real_parent_file[ $parent ] ) ) {
|
||||
$parent = $_wp_real_parent_file[ $parent ];
|
||||
foreach ( array_keys( (array) $submenu ) as $parent_page ) {
|
||||
foreach ( $submenu[ $parent_page ] as $submenu_array ) {
|
||||
if ( isset( $_wp_real_parent_file[ $parent_page ] ) ) {
|
||||
$parent_page = $_wp_real_parent_file[ $parent_page ];
|
||||
}
|
||||
|
||||
if ( ! empty( $typenow ) && "$pagenow?post_type=$typenow" === $submenu_array[2] ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
$parent_file = $parent_page;
|
||||
return $parent_page;
|
||||
} elseif ( empty( $typenow ) && $pagenow === $submenu_array[2]
|
||||
&& ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) )
|
||||
) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
$parent_file = $parent_page;
|
||||
return $parent_page;
|
||||
} elseif ( isset( $plugin_page ) && $plugin_page === $submenu_array[2] ) {
|
||||
$parent_file = $parent;
|
||||
return $parent;
|
||||
$parent_file = $parent_page;
|
||||
return $parent_page;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-beta1-53214';
|
||||
$wp_version = '6.0-beta1-53215';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue