| 1081 | 1081 | $hookname = get_plugin_page_hookname( $menu_slug, '' ); |
| 1082 | 1082 | |
| 1083 | 1083 | if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) ) |
| 1084 | 1084 | add_action( $hookname, $function ); |
| 1085 | 1085 | |
| 1086 | 1086 | if ( empty($icon_url) ) { |
| 1087 | 1087 | $icon_url = 'dashicons-admin-generic'; |
| 1088 | 1088 | $icon_class = 'menu-icon-generic '; |
| 1089 | 1089 | } else { |
| 1090 | 1090 | $icon_url = set_url_scheme( $icon_url ); |
| 1091 | 1091 | $icon_class = ''; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url ); |
| 1095 | 1095 | |
| 1096 | 1101 | if ( null === $position ) { |
| 1097 | 1102 | $menu[] = $new_menu; |
| 1098 | 1103 | } elseif ( isset( $menu[ "$position" ] ) ) { |
| 1099 | 1104 | $position = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ) , -5 ) * 0.00001; |
| 1100 | 1105 | $menu[ "$position" ] = $new_menu; |
| 1101 | 1106 | } else { |
| 1102 | 1107 | $menu[ $position ] = $new_menu; |
| 1103 | 1108 | } |
| 1104 | 1109 | |
| 1105 | 1110 | $_registered_pages[$hookname] = true; |
| 1106 | 1111 | |
| 1107 | 1112 | // No parent as top level |
| 1108 | 1113 | $_parent_pages[$menu_slug] = false; |
| 1109 | 1114 | |
| 1110 | 1115 | return $hookname; |