Changeset 13579
- Timestamp:
- 03/04/2010 12:15:55 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin.php
r12982 r13579 73 73 $editing = false; 74 74 75 if ( isset($_GET['page'])) {75 if ( isset($_GET['page']) ) { 76 76 $plugin_page = stripslashes($_GET['page']); 77 77 $plugin_page = plugin_basename($plugin_page); 78 78 } 79 80 if ( isset($_GET['post_type']) ) 81 $typenow = sanitize_user($_GET['post_type'], true); 82 else 83 $typenow = ''; 79 84 80 85 require(ABSPATH . 'wp-admin/menu.php'); … … 82 87 do_action('admin_init'); 83 88 84 if (isset($plugin_page) ) { 85 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) { 89 if ( isset($plugin_page) ) { 90 if ( !empty($typenow) ) 91 $the_parent = $pagenow . '?post_type=' . $typenow; 92 else 93 $the_parent = $pagenow; 94 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { 86 95 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); 87 96 // backwards compatibility for plugins using add_management_page … … 96 105 } 97 106 } 107 unset($the_parent); 98 108 } 99 109 … … 105 115 else if ( isset($pagenow) ) 106 116 $hook_suffix = $pagenow; 107 108 if ( isset($_GET['post_type']) )109 $typenow = $_GET['post_type'];110 else111 $typenow = '';112 // @todo validate typenow against post types.113 117 114 118 set_current_screen(); -
trunk/wp-admin/includes/plugin.php
r13256 r13579 818 818 819 819 $hookname = get_plugin_page_hookname( $menu_slug, '' ); 820 820 821 if (!empty ( $function ) && !empty ( $hookname ) && current_user_can( $capability ) ) 821 822 add_action( $hookname, $function ); … … 1168 1169 global $submenu; 1169 1170 global $pagenow; 1171 global $typenow; 1170 1172 global $plugin_page; 1171 1173 global $_wp_real_parent_file; … … 1216 1218 if ( isset( $_wp_real_parent_file[$parent] ) ) 1217 1219 $parent = $_wp_real_parent_file[$parent]; 1218 if ( $submenu_array[2] == $pagenow && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { 1220 if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) { 1221 $parent_file = $parent; 1222 return $parent; 1223 } elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) { 1219 1224 $parent_file = $parent; 1220 1225 return $parent; … … 1327 1332 } 1328 1333 1334 1329 1335 $plugin_name = preg_replace( '!\.php!', '', $plugin_page ); 1330 1336 … … 1351 1357 1352 1358 $hookname = get_plugin_page_hookname($plugin_page, $parent); 1359 1353 1360 if ( !isset($_registered_pages[$hookname]) ) 1354 1361 return false; -
trunk/wp-admin/includes/template.php
r13576 r13579 3948 3948 $current_screen->id = $typenow; 3949 3949 $current_screen->post_type = $typenow; 3950 } else {3951 $typenow = '';3952 3950 } 3953 3951 -
trunk/wp-admin/menu-header.php
r12733 r13579 34 34 */ 35 35 function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { 36 global $self, $parent_file, $submenu_file, $plugin_page, $pagenow ;36 global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; 37 37 38 38 $first = true; … … 48 48 $class[] = 'wp-has-submenu'; 49 49 50 if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && strcmp($self, $item[2]) == 0) ) {50 if ( ( $parent_file && $item[2] == $parent_file ) || ( false === strpos($parent_file, '?') && $self == $item[2] ) ) { 51 51 if ( !empty($submenu[$item[2]]) ) 52 52 $class[] = 'wp-has-current-submenu wp-menu-open'; … … 113 113 114 114 $menu_file = $item[2]; 115 115 116 if ( false !== $pos = strpos($menu_file, '?') ) 116 117 $menu_file = substr($menu_file, 0, $pos); 118 119 // Handle current for post_type=post|page|foo pages, which won't match $self. 120 if ( !empty($typenow) ) 121 $self_type = $self . '?post_type=' . $typenow; 122 else 123 $self_type = 'nothing'; 117 124 118 125 if ( isset($submenu_file) ) { … … 121 128 // If plugin_page is set the parent must either match the current page or not physically exist. 122 129 // This allows plugin pages with the same hook to exist under different parents. 123 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self) )) || (!isset($plugin_page) && $self == $sub_item[2]) ) {130 } else if ( (isset($plugin_page) && $plugin_page == $sub_item[2] && (!file_exists($menu_file) || ($item[2] == $self) || ($item[2] == $self_type))) || (!isset($plugin_page) && $self == $sub_item[2]) ) { 124 131 $class[] = 'current'; 125 132 } … … 134 141 if ( ( ('index.php' != $sub_item[2]) && file_exists(WP_PLUGIN_DIR . "/$sub_file") ) || ! empty($menu_hook) ) { 135 142 // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir 136 137 $parent_exists = (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}") ) || file_exists($menu_file); 138 if ( $parent_exists ) 139 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 140 elseif ( 'admin.php' == $pagenow || !$parent_exists ) 141 echo "<li$class><a href='admin.php?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 143 if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) ) 144 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] ); 142 145 else 143 echo "<li$class><a href='{$item[2]}?page={$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; 146 $sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' ); 147 echo "<li$class><a href='$sub_item_url'$class$tabindex>{$sub_item[0]}</a></li>"; 144 148 } else { 145 149 echo "<li$class><a href='{$sub_item[2]}'$class$tabindex>{$sub_item[0]}</a></li>"; -
trunk/wp-admin/menu.php
r13533 r13579 178 178 // Create list of page plugin hook names. 179 179 foreach ($menu as $menu_page) { 180 $hook_name = sanitize_title(basename($menu_page[2], '.php')); 180 if ( false !== $pos = strpos($menu_page[2], '?') ) { 181 // Handle post_type=post|page|foo pages. 182 $hook_name = substr($menu_page[2], 0, $pos); 183 $hook_args = substr($menu_page[2], $pos + 1); 184 wp_parse_str($hook_args, $hook_args); 185 // Set the hook name to be the post type. 186 if ( isset($hook_args['post_type']) ) 187 $hook_name = $hook_args['post_type']; 188 else 189 $hook_name = basename($hook_name, '.php'); 190 unset($hook_args); 191 } else { 192 $hook_name = basename($menu_page[2], '.php'); 193 } 194 $hook_name = sanitize_title($hook_name); 181 195 182 196 // ensure we're backwards compatible … … 184 198 'index' => 'dashboard', 185 199 'edit' => 'posts', 200 'post' => 'posts', 186 201 'upload' => 'media', 187 202 'link-manager' => 'links', 188 203 'edit-pages' => 'pages', 204 'page' => 'pages', 189 205 'edit-comments' => 'comments', 190 206 'options-general' => 'settings',
Note: See TracChangeset
for help on using the changeset viewer.