| 8 | | 'index.php' => array( 'base' => 'dashboard', 'id' => 'dashboard' ), |
| 9 | | 'edit.php' => array( 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post' ), |
| 10 | | 'post-new.php'=> array( 'action' => 'add', 'base' => 'post', 'id' => 'post', 'post_type' => 'post' ), |
| 11 | | 'edit-tags.php' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ), |
| 12 | | 'edit-tags.php?taxonomy=post_tag' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ), |
| 13 | | 'edit-tags.php?taxonomy=category' => array( 'base' => 'edit-tags', 'id' => 'edit-category', 'post_type' => 'post', 'taxonomy' => 'category' ), |
| 14 | | 'upload.php' => array( 'base' => 'upload', 'id' => 'upload' ), |
| 15 | | 'media-new.php' => array( 'action' => 'add', 'base' => 'media', 'id' => 'media' ), |
| 16 | | 'edit.php?post_type=page' => array( 'base' => 'edit', 'id' => 'edit-page', 'post_type' => 'page' ), |
| 17 | | 'link-manager.php' => array( 'base' => 'link-manager', 'id' => 'link-manager' ), |
| 18 | | 'link-add.php' => array( 'action' => 'add', 'base' => 'link', 'id' => 'link' ), |
| 19 | | 'edit-tags.php?taxonomy=link_category' => array( 'base' => 'edit-tags', 'id' => 'edit-link_category', 'taxonomy' => 'link_category' ), |
| 20 | | 'edit-comments.php' => array( 'base' => 'edit-comments', 'id' => 'edit-comments' ), |
| 21 | | 'themes.php' => array( 'base' => 'themes', 'id' => 'themes' ), |
| 22 | | 'widgets.php' => array( 'base' => 'widgets', 'id' => 'widgets' ), |
| 23 | | 'nav-menus.php' => array( 'base' => 'nav-menus', 'id' => 'nav-menus' ), |
| 24 | | 'plugins.php' => array( 'base' => 'plugins', 'id' => 'plugins' ), |
| 25 | | 'users.php' => array( 'base' => 'users', 'id' => 'users' ), |
| 26 | | 'user-new.php' => array( 'action' => 'add', 'base' => 'user', 'id' => 'user' ), |
| 27 | | 'profile.php' => array( 'base' => 'profile', 'id' => 'profile' ), |
| 28 | | 'tools.php' => array( 'base' => 'tools', 'id' => 'tools' ), |
| 29 | | 'import.php' => array( 'base' => 'import', 'id' => 'import' ), |
| 30 | | 'export.php' => array( 'base' => 'export', 'id' => 'export' ), |
| 31 | | 'options-general.php' => array( 'base' => 'options-general', 'id' => 'options-general' ), |
| 32 | | 'options-writing.php' => array( 'base' => 'options-writing', 'id' => 'options-writing' ), |
| | 8 | 'index.php' => array( 'base' => 'dashboard', 'id' => 'dashboard', 'guid' => 'site:dashboard' ), |
| | 9 | 'edit.php' => array( 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post', 'guid' => 'site:edit:post' ), |
| | 10 | 'post-new.php'=> array( 'action' => 'add', 'base' => 'post', 'id' => 'post', 'post_type' => 'post', 'guid' => 'site:post:post' ), |
| | 11 | 'edit-tags.php' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag', 'guid' => 'site:edit-tags:post_tag:post' ), |
| | 12 | 'edit-tags.php?taxonomy=post_tag' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag', 'guid' => 'site:edit-tags:post_tag:post' ), |
| | 13 | 'edit-tags.php?taxonomy=category' => array( 'base' => 'edit-tags', 'id' => 'edit-category', 'post_type' => 'post', 'taxonomy' => 'category', 'guid' => 'site:edit-tags:category:post' ), |
| | 14 | 'upload.php' => array( 'base' => 'upload', 'id' => 'upload', 'guid' => 'site:upload' ), |
| | 15 | 'media-new.php' => array( 'action' => 'add', 'base' => 'media', 'id' => 'media', 'guid' => 'site:media' ), |
| | 16 | 'edit.php?post_type=page' => array( 'base' => 'edit', 'id' => 'edit-page', 'post_type' => 'page', 'guid' => 'site:edit:page' ), |
| | 17 | 'link-manager.php' => array( 'base' => 'link-manager', 'id' => 'link-manager', 'guid' => 'site:link-manager' ), |
| | 18 | 'link-add.php' => array( 'action' => 'add', 'base' => 'link', 'id' => 'link', 'guid' => 'site:link' ), |
| | 19 | 'edit-tags.php?taxonomy=link_category' => array( 'base' => 'edit-tags', 'id' => 'edit-link_category', 'taxonomy' => 'link_category', 'guid' => 'site:edit-tags:link_category' ), |
| | 20 | 'edit-comments.php' => array( 'base' => 'edit-comments', 'id' => 'edit-comments', 'guid' => 'site:edit-comments' ), |
| | 21 | 'themes.php' => array( 'base' => 'themes', 'id' => 'themes', 'guid' => 'site:themes' ), |
| | 22 | 'widgets.php' => array( 'base' => 'widgets', 'id' => 'widgets', 'guid' => 'site:widgets' ), |
| | 23 | 'nav-menus.php' => array( 'base' => 'nav-menus', 'id' => 'nav-menus', 'guid' => 'site:nav-menus' ), |
| | 24 | 'plugins.php' => array( 'base' => 'plugins', 'id' => 'plugins', 'guid' => 'site:plugins' ), |
| | 25 | 'users.php' => array( 'base' => 'users', 'id' => 'users', 'guid' => 'site:users' ), |
| | 26 | 'user-new.php' => array( 'action' => 'add', 'base' => 'user', 'id' => 'user', 'guid' => 'site:user' ), |
| | 27 | 'profile.php' => array( 'base' => 'profile', 'id' => 'profile', 'guid' => 'site:profile' ), |
| | 28 | 'tools.php' => array( 'base' => 'tools', 'id' => 'tools', 'guid' => 'site:tools' ), |
| | 29 | 'import.php' => array( 'base' => 'import', 'id' => 'import', 'guid' => 'site:import' ), |
| | 30 | 'export.php' => array( 'base' => 'export', 'id' => 'export', 'guid' => 'site:export' ), |
| | 31 | 'options-general.php' => array( 'base' => 'options-general', 'id' => 'options-general', 'guid' => 'site:options-general' ), |
| | 32 | 'options-writing.php' => array( 'base' => 'options-writing', 'id' => 'options-writing', 'guid' => 'site:options-writing' ), |
| | 35 | var $core_screens_guid = array( |
| | 36 | 'site:dashboard' => array( 'base' => 'dashboard', 'id' => 'dashboard' ), |
| | 37 | 'site:edit:post' => array( 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post' ), |
| | 38 | 'site:post:post'=> array( 'action' => 'add', 'base' => 'post', 'id' => 'post', 'post_type' => 'post' ), |
| | 39 | 'site:edit-tags:post_tag:post' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ), |
| | 40 | 'site:edit-tags:category:post' => array( 'base' => 'edit-tags', 'id' => 'edit-category', 'post_type' => 'post', 'taxonomy' => 'category' ), |
| | 41 | 'site:upload' => array( 'base' => 'upload', 'id' => 'upload' ), |
| | 42 | 'site:media' => array( 'action' => 'add', 'base' => 'media', 'id' => 'media' ), |
| | 43 | 'site:edit:page' => array( 'base' => 'edit', 'id' => 'edit-page', 'post_type' => 'page' ), |
| | 44 | 'site:link-manager' => array( 'base' => 'link-manager', 'id' => 'link-manager' ), |
| | 45 | 'site:link' => array( 'action' => 'add', 'base' => 'link', 'id' => 'link' ), |
| | 46 | 'site:edit-tags:link_category' => array( 'base' => 'edit-tags', 'id' => 'edit-link_category', 'taxonomy' => 'link_category' ), |
| | 47 | 'site:edit-comments' => array( 'base' => 'edit-comments', 'id' => 'edit-comments' ), |
| | 48 | 'site:themes' => array( 'base' => 'themes', 'id' => 'themes' ), |
| | 49 | 'site:widgets' => array( 'base' => 'widgets', 'id' => 'widgets' ), |
| | 50 | 'site:nav-menus' => array( 'base' => 'nav-menus', 'id' => 'nav-menus' ), |
| | 51 | 'site:plugins' => array( 'base' => 'plugins', 'id' => 'plugins' ), |
| | 52 | 'site:users' => array( 'base' => 'users', 'id' => 'users' ), |
| | 53 | 'site:user' => array( 'action' => 'add', 'base' => 'user', 'id' => 'user' ), |
| | 54 | 'site:profile' => array( 'base' => 'profile', 'id' => 'profile' ), |
| | 55 | 'site:tools' => array( 'base' => 'tools', 'id' => 'tools' ), |
| | 56 | 'site:import' => array( 'base' => 'import', 'id' => 'import' ), |
| | 57 | 'site:export' => array( 'base' => 'export', 'id' => 'export' ), |
| | 58 | 'site:options-general' => array( 'base' => 'options-general', 'id' => 'options-general' ), |
| | 59 | 'site:options-writing' => array( 'base' => 'options-writing', 'id' => 'options-writing' ), |
| | 60 | ); |
| | 61 | |
| | 123 | function test_set_current_screen_with_guid() { |
| | 124 | global $current_screen; |
| | 125 | |
| | 126 | foreach ( $this->core_screens_guid as $guid => $screen ) { |
| | 127 | $screen = (object) $screen; |
| | 128 | set_current_screen( $guid ); |
| | 129 | $this->assertEquals( $screen->id, $current_screen->id, $guid ); |
| | 130 | $this->assertEquals( $screen->base, $current_screen->base, $guid ); |
| | 131 | if ( isset( $screen->action ) ) |
| | 132 | $this->assertEquals( $screen->action, $current_screen->action, $guid ); |
| | 133 | if ( isset( $screen->post_type ) ) |
| | 134 | $this->assertEquals( $screen->post_type, $current_screen->post_type, $guid ); |
| | 135 | else |
| | 136 | $this->assertEmpty( $current_screen->post_type, $guid ); |
| | 137 | if ( isset( $screen->taxonomy ) ) |
| | 138 | $this->assertEquals( $screen->taxonomy, $current_screen->taxonomy, $guid ); |
| | 139 | |
| | 140 | $this->assertTrue( $current_screen->in_admin() ); |
| | 141 | $this->assertTrue( $current_screen->in_admin( 'site' ) ); |
| | 142 | $this->assertFalse( $current_screen->in_admin( 'network' ) ); |
| | 143 | $this->assertFalse( $current_screen->in_admin( 'user' ) ); |
| | 144 | $this->assertFalse( $current_screen->in_admin( 'garbage' ) ); |
| | 145 | |
| | 146 | // With convert_to_screen(), the same ID should return the exact $current_screen. |
| | 147 | $this->assertSame( $current_screen, convert_to_screen( $screen->id ), $guid ); |
| | 148 | } |
| | 149 | } |
| | 150 | |