Changeset 2234
- Timestamp:
- 02/07/2005 01:15:06 AM (21 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
- admin-functions.php (modified) (3 diffs)
- admin.php (modified) (1 diff)
- menu-header.php (modified) (1 diff)
- menu.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2186 r2234 774 774 775 775 function add_menu_page($page_title, $menu_title, $access_level, $file) { 776 global $menu ;776 global $menu, $admin_page_hooks; 777 777 778 778 $file = plugin_basename($file); 779 779 780 780 $menu[] = array($menu_title, $access_level, $file, $page_title); 781 } 782 783 function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file) { 781 782 $admin_page_hooks[$file] = sanitize_title($menu_title); 783 } 784 785 function add_submenu_page($parent, $page_title, $menu_title, $access_level, $file, $function = '') { 784 786 global $submenu; 785 787 global $menu; … … 801 803 802 804 $submenu[$parent][] = array($menu_title, $access_level, $file, $page_title); 803 } 804 805 function add_options_page($page_title, $menu_title, $access_level, $file) { 806 add_submenu_page('options-general.php', $page_title, $menu_title, $access_level, $file); 807 } 808 809 function add_management_page($page_title, $menu_title, $access_level, $file) { 810 add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file); 805 806 $hookname = get_plugin_page_hookname($file, $parent); 807 if ( !empty($function) && !empty($hookname) ) 808 add_action($hookname, $function); 809 810 return $hookname; 811 } 812 813 function add_options_page($page_title, $menu_title, $access_level, $file, $function = '') { 814 return add_submenu_page('options-general.php', $page_title, $menu_title, $access_level, $file, $function); 815 } 816 817 function add_management_page($page_title, $menu_title, $access_level, $file, $function = '') { 818 return add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file, $function); 811 819 } 812 820 … … 1000 1008 } 1001 1009 1010 function get_plugin_page_hookname($plugin_page, $parent_page) { 1011 global $admin_page_hooks; 1012 1013 if ( isset($admin_page_hooks[$parent_page]) ) 1014 $page_type = $admin_page_hooks[$parent_page]; 1015 else 1016 $page_type = 'admin'; 1017 1018 $plugin_name = preg_replace('!\.php!', '', $plugin_page); 1019 1020 return $page_type . '_page_' . $plugin_name; 1021 } 1022 1023 function get_plugin_page_hook($plugin_page, $parent_page) { 1024 global $wp_filter; 1025 1026 $hook = get_plugin_page_hookname($plugin_page, $parent_page); 1027 1028 if ( isset($wp_filter[$hook]) ) 1029 return $hook; 1030 else 1031 return ''; 1032 } 1033 1002 1034 ?> -
trunk/wp-admin/admin.php
r2157 r2234 42 42 if (isset($_GET['page'])) { 43 43 $plugin_page = plugin_basename($_GET['page']); 44 if ( validate_file($plugin_page) ) { 45 die(__('Invalid plugin page')); 44 $page_hook = get_plugin_page_hook($plugin_page, $pagenow); 45 46 if ( $page_hook ) { 47 if (! isset($_GET['noheader'])) 48 require_once(ABSPATH . '/wp-admin/admin-header.php'); 49 50 do_action($page_hook); 51 } else { 52 if ( validate_file($plugin_page) ) { 53 die(__('Invalid plugin page')); 54 } 55 56 if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) 57 die(sprintf(__('Cannot load %s.'), $plugin_page)); 58 59 if (! isset($_GET['noheader'])) 60 require_once(ABSPATH . '/wp-admin/admin-header.php'); 61 62 include(ABSPATH . "wp-content/plugins/$plugin_page"); 46 63 } 64 65 include(ABSPATH . 'wp-admin/admin-footer.php'); 47 66 48 if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) 49 die(sprintf(__('Cannot load %s.'), $plugin_page)); 50 51 if (! isset($_GET['noheader'])) 52 require_once(ABSPATH . '/wp-admin/admin-header.php'); 53 54 include(ABSPATH . "wp-content/plugins/$plugin_page"); 55 56 include(ABSPATH . 'wp-admin/admin-footer.php'); 67 exit(); 57 68 } 58 69 -
trunk/wp-admin/menu-header.php
r1998 r2234 36 36 } 37 37 38 if ( ( substr($self, -10) == substr($item[2], -10)) || (isset($plugin_page) && $plugin_page == $item[2]) ) $class = ' class="current"';38 if ( (isset($plugin_page) && $plugin_page == $item[2]) || (!isset($plugin_page) && substr($self, -10) == substr($item[2], -10)) ) $class = ' class="current"'; 39 39 else if (isset($submenu_file) && $submenu_file == substr($item[2], -10)) $class = ' class="current"'; 40 40 else $class = ''; 41 41 42 if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}")) 43 echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 44 else 42 if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}")) { 43 $page_hook = get_plugin_page_hook($item[2], $parent_file); 44 if ( $page_hook ) 45 echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>"; 46 else 47 echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>"; 48 } else { 45 49 echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>"; 50 } 46 51 endforeach; 47 52 ?> -
trunk/wp-admin/menu.php
r2218 r2234 49 49 $submenu['themes.php'][10] = array(__('Theme Editor'), 8, 'theme-editor.php'); 50 50 51 // Create list of page plugin hook names. 52 foreach ($menu as $menu_page) { 53 $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]); 54 } 55 51 56 do_action('admin_menu', ''); 52 57 ksort($menu); // make it all pretty
Note: See TracChangeset for help on using the changeset viewer.