Changeset 2381 for trunk/wp-admin/admin-functions.php
- Timestamp:
- 02/25/2005 04:11:27 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r2346 r2381 745 745 function get_admin_page_parent() { 746 746 global $parent_file; 747 global $menu; 747 748 global $submenu; 748 749 global $pagenow; … … 753 754 } 754 755 756 if ($pagenow == 'admin.php' && isset($plugin_page)) { 757 foreach ($menu as $parent_menu) { 758 if ($parent_menu[2] == $plugin_page) { 759 $parent_file = $plugin_page; 760 return $plugin_page; 761 } 762 } 763 } 764 755 765 foreach (array_keys($submenu) as $parent) { 756 766 foreach ($submenu[$parent] as $submenu_array) { … … 770 780 771 781 function plugin_basename($file) { 772 return preg_replace(' #^.*wp-content/plugins/#', '', $file);773 } 774 775 function add_menu_page($page_title, $menu_title, $access_level, $file ) {782 return preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file); 783 } 784 785 function add_menu_page($page_title, $menu_title, $access_level, $file, $function = '') { 776 786 global $menu, $admin_page_hooks; 777 787 … … 781 791 782 792 $admin_page_hooks[$file] = sanitize_title($menu_title); 793 794 $hookname = get_plugin_page_hookname($file, ''); 795 if ( !empty($function) && !empty($hookname) ) 796 add_action($hookname, $function); 797 798 return $hookname; 783 799 } 784 800 … … 1015 1031 global $admin_page_hooks; 1016 1032 1017 if ( isset($admin_page_hooks[$parent_page]) ) 1033 $parent = get_admin_page_parent(); 1034 1035 if ( empty($parent_page) || 'admin.php' == $parent_page ) { 1036 if ( isset($admin_page_hooks[$plugin_page]) ) 1037 $page_type = 'toplevel'; 1038 else if ( isset($admin_page_hooks[$parent]) ) 1039 $page_type = $admin_page_hooks[$parent]; 1040 } else if ( isset($admin_page_hooks[$parent_page]) ) { 1018 1041 $page_type = $admin_page_hooks[$parent_page]; 1019 else1042 } else { 1020 1043 $page_type = 'admin'; 1044 } 1021 1045 1022 1046 $plugin_name = preg_replace('!\.php!', '', $plugin_page); … … 1027 1051 function get_plugin_page_hook($plugin_page, $parent_page) { 1028 1052 global $wp_filter; 1029 1053 1030 1054 $hook = get_plugin_page_hookname($plugin_page, $parent_page); 1031 1032 1055 if ( isset($wp_filter[$hook]) ) 1033 1056 return $hook;
Note: See TracChangeset
for help on using the changeset viewer.