Skip to content

Commit 6103aaa

Browse files
committed
Docs: Address review feedback on callback types.
Allow null and an empty string for the $admin_header_callback parameter of Custom_Image_Header::__construct(), since the Customizer and the theme-support defaults pass them. Also type the admin page callbacks as callable(): mixed, matching Custom_Image_Header and Custom_Background, since the page hook is fired without arguments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015BuoHZQvJMvPEYp4Sfjgvd
1 parent bffd9e1 commit 6103aaa

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

‎src/wp-admin/includes/class-custom-image-header.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Custom_Image_Header {
5959
* @param callable $admin_image_div_callback Optional. Custom image div output callback.
6060
* Default empty string.
6161
*
62+
* @phpstan-param ''|(callable(): mixed)|null $admin_header_callback
6263
* @phpstan-param ''|(callable(): mixed)|null $admin_image_div_callback
6364
*/
6465
public function __construct( $admin_header_callback, $admin_image_div_callback = '' ) {

‎src/wp-admin/includes/plugin.php‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ function uninstall_plugin( $plugin ) {
13991399
* @param int|float $position Optional. The position in the menu order this item should appear.
14001400
* @return string The resulting page's hook_suffix.
14011401
*
1402-
* @phpstan-param ''|callable|null $callback
1402+
* @phpstan-param ''|(callable(): mixed)|null $callback
14031403
*/
14041404
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $icon_url = '', $position = null ) {
14051405
global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
@@ -1496,7 +1496,7 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $call
14961496
* @param int|float $position Optional. The position in the menu order this item should appear.
14971497
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
14981498
*
1499-
* @phpstan-param ''|callable|null $callback
1499+
* @phpstan-param ''|(callable(): mixed)|null $callback
15001500
*/
15011501
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
15021502
global $submenu, $menu, $_wp_real_parent_file, $_wp_submenu_nopriv,
@@ -1611,7 +1611,7 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
16111611
* @param int $position Optional. The position in the menu order this item should appear.
16121612
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
16131613
*
1614-
* @phpstan-param ''|callable|null $callback
1614+
* @phpstan-param ''|(callable(): mixed)|null $callback
16151615
*/
16161616
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
16171617
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1637,7 +1637,7 @@ function add_management_page( $page_title, $menu_title, $capability, $menu_slug,
16371637
* @param int $position Optional. The position in the menu order this item should appear.
16381638
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
16391639
*
1640-
* @phpstan-param ''|callable|null $callback
1640+
* @phpstan-param ''|(callable(): mixed)|null $callback
16411641
*/
16421642
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
16431643
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1663,7 +1663,7 @@ function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $c
16631663
* @param int $position Optional. The position in the menu order this item should appear.
16641664
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
16651665
*
1666-
* @phpstan-param ''|callable|null $callback
1666+
* @phpstan-param ''|(callable(): mixed)|null $callback
16671667
*/
16681668
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
16691669
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1689,7 +1689,7 @@ function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $cal
16891689
* @param int $position Optional. The position in the menu order this item should appear.
16901690
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
16911691
*
1692-
* @phpstan-param ''|callable|null $callback
1692+
* @phpstan-param ''|(callable(): mixed)|null $callback
16931693
*/
16941694
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
16951695
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1715,7 +1715,7 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $c
17151715
* @param int $position Optional. The position in the menu order this item should appear.
17161716
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
17171717
*
1718-
* @phpstan-param ''|callable|null $callback
1718+
* @phpstan-param ''|(callable(): mixed)|null $callback
17191719
*/
17201720
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
17211721
if ( current_user_can( 'edit_users' ) ) {
@@ -1746,7 +1746,7 @@ function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $cal
17461746
* @param int $position Optional. The position in the menu order this item should appear.
17471747
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
17481748
*
1749-
* @phpstan-param ''|callable|null $callback
1749+
* @phpstan-param ''|(callable(): mixed)|null $callback
17501750
*/
17511751
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
17521752
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1772,7 +1772,7 @@ function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug,
17721772
* @param int $position Optional. The position in the menu order this item should appear.
17731773
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
17741774
*
1775-
* @phpstan-param ''|callable|null $callback
1775+
* @phpstan-param ''|(callable(): mixed)|null $callback
17761776
*/
17771777
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
17781778
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1798,7 +1798,7 @@ function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $cal
17981798
* @param int $position Optional. The position in the menu order this item should appear.
17991799
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
18001800
*
1801-
* @phpstan-param ''|callable|null $callback
1801+
* @phpstan-param ''|(callable(): mixed)|null $callback
18021802
*/
18031803
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
18041804
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1824,7 +1824,7 @@ function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $cal
18241824
* @param int $position Optional. The position in the menu order this item should appear.
18251825
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
18261826
*
1827-
* @phpstan-param ''|callable|null $callback
1827+
* @phpstan-param ''|(callable(): mixed)|null $callback
18281828
*/
18291829
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
18301830
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1850,7 +1850,7 @@ function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $cal
18501850
* @param int $position Optional. The position in the menu order this item should appear.
18511851
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
18521852
*
1853-
* @phpstan-param ''|callable|null $callback
1853+
* @phpstan-param ''|(callable(): mixed)|null $callback
18541854
*/
18551855
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
18561856
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );
@@ -1876,7 +1876,7 @@ function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $cal
18761876
* @param int $position Optional. The position in the menu order this item should appear.
18771877
* @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
18781878
*
1879-
* @phpstan-param ''|callable|null $callback
1879+
* @phpstan-param ''|(callable(): mixed)|null $callback
18801880
*/
18811881
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $callback = '', $position = null ) {
18821882
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $callback, $position );

0 commit comments

Comments
 (0)