| @@ -41,132 +41,368 @@ | ||
| 41 | 41 | return __CLASS__; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * Method init_menu() | |
| 45 | + * Get the registered Info subpages. | |
| 46 | 46 | * |
| 47 | - * Initiate Info subPage menu. | |
| 48 | - * | |
| 49 | - * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 50 | - * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software() | |
| 47 | + * @return array<int, array<string, mixed>> Info subpages. | |
| 51 | 48 | */ |
| 52 | - public static function init_menu() { // phpcs:ignore -- NOSONAR - complex. | |
| 49 | + private static function get_subpages() { | |
| 50 | + if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { | |
| 51 | + return static::$subPages; | |
| 52 | + } | |
| 53 | 53 | |
| 54 | - add_action( 'mainwp_pageheader_infor', array( static::get_class_name(), 'render_header' ) ); | |
| 55 | - add_action( 'mainwp_pagefooter_infor', array( static::get_class_name(), 'render_footer' ) ); | |
| 54 | + /** | |
| 55 | + * Filter mainwp_getsubpages_server | |
| 56 | + * | |
| 57 | + * Filters subpages for the Info page. | |
| 58 | + * | |
| 59 | + * @since Unknown | |
| 60 | + */ | |
| 61 | + $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-server', array( array() ), '4.0.7.2', 'mainwp_getsubpages_server' ); // NOSONAR - not IP. | |
| 62 | + static::$subPages = apply_filters( 'mainwp_getsubpages_server', $sub_pages ); | |
| 56 | 63 | |
| 57 | - add_submenu_page( | |
| 58 | - 'mainwp_tab', | |
| 59 | - __( 'Info', 'mainwp' ), | |
| 60 | - ' <span id="mainwp-ServerInformation">' . esc_html__( 'Info', 'mainwp' ) . '</span>', | |
| 61 | - 'read', | |
| 62 | - 'ServerInformation', | |
| 64 | + return is_array( static::$subPages ) ? static::$subPages : array(); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Get the built-in Info pages used across menu registration and navigation rendering. | |
| 69 | + * | |
| 70 | + * @return array<int, array<string, mixed>> Info page definitions. | |
| 71 | + */ | |
| 72 | + private static function get_core_pages() { | |
| 73 | + $pages = array( | |
| 63 | 74 | array( |
| 64 | - static::get_class_name(), | |
| 65 | - 'render', | |
| 66 | - ) | |
| 75 | + 'slug' => 'ServerInformation', | |
| 76 | + 'page_title' => __( 'Info', 'mainwp' ), | |
| 77 | + 'menu_title' => ' <span id="mainwp-ServerInformation">' . esc_html__( 'Info', 'mainwp' ) . '</span>', | |
| 78 | + 'nav_title' => esc_html__( 'Server', 'mainwp' ), | |
| 79 | + 'callback' => array( static::get_class_name(), 'render' ), | |
| 80 | + 'active_keys' => array( '', 'ServerInformation' ), | |
| 81 | + 'show_in_header_nav' => true, | |
| 82 | + 'show_in_subpages_menu' => true, | |
| 83 | + 'show_in_left_menu' => true, | |
| 84 | + 'show_in_palette' => true, | |
| 85 | + 'left_menu_parent' => 'ServerInformation', | |
| 86 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ) ), | |
| 87 | + ), | |
| 88 | + array( | |
| 89 | + 'slug' => 'ServerInformationCron', | |
| 90 | + 'page_title' => __( 'Cron Schedules', 'mainwp' ), | |
| 91 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'Cron Schedules', 'mainwp' ) . '</div>', | |
| 92 | + 'nav_title' => esc_html__( 'Cron Schedules', 'mainwp' ), | |
| 93 | + 'callback' => array( static::get_class_name(), 'render_cron' ), | |
| 94 | + 'active_keys' => array( 'ServerInformationCron' ), | |
| 95 | + 'show_in_header_nav' => true, | |
| 96 | + 'show_in_subpages_menu' => true, | |
| 97 | + 'show_in_left_menu' => true, | |
| 98 | + 'show_in_palette' => true, | |
| 99 | + 'left_menu_parent' => 'ServerInformation', | |
| 100 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), esc_html__( 'Cron Schedules', 'mainwp' ) ), | |
| 101 | + ), | |
| 102 | + array( | |
| 103 | + 'slug' => 'ErrorLog', | |
| 104 | + 'page_title' => __( 'Error Log', 'mainwp' ), | |
| 105 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'Error Log', 'mainwp' ) . '</div>', | |
| 106 | + 'nav_title' => esc_html__( 'Error Log', 'mainwp' ), | |
| 107 | + 'callback' => array( static::get_class_name(), 'render_error_log_page' ), | |
| 108 | + 'active_keys' => array( 'ErrorLog' ), | |
| 109 | + 'show_in_header_nav' => true, | |
| 110 | + 'show_in_subpages_menu' => true, | |
| 111 | + 'show_in_left_menu' => true, | |
| 112 | + 'show_in_palette' => true, | |
| 113 | + 'left_menu_parent' => 'ServerInformation', | |
| 114 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), esc_html__( 'Error Log', 'mainwp' ) ), | |
| 115 | + ), | |
| 116 | + array( | |
| 117 | + 'slug' => 'WPConfig', | |
| 118 | + 'page_title' => __( 'WP-Config File', 'mainwp' ), | |
| 119 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'WP-Config File', 'mainwp' ) . '</div>', | |
| 120 | + 'nav_title' => esc_html__( 'WP-Config File', 'mainwp' ), | |
| 121 | + 'callback' => array( static::get_class_name(), 'render_wp_config' ), | |
| 122 | + 'active_keys' => array( 'WPConfig' ), | |
| 123 | + 'show_in_header_nav' => false, | |
| 124 | + 'show_in_subpages_menu' => true, | |
| 125 | + 'show_in_left_menu' => false, | |
| 126 | + 'show_in_palette' => true, | |
| 127 | + 'left_menu_parent' => 'ServerInformation', | |
| 128 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), esc_html__( 'WP-Config File', 'mainwp' ) ), | |
| 129 | + ), | |
| 130 | + array( | |
| 131 | + 'slug' => '.htaccess', | |
| 132 | + 'page_title' => __( '.htaccess File', 'mainwp' ), | |
| 133 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( '.htaccess File', 'mainwp' ) . '</div>', | |
| 134 | + 'nav_title' => esc_html__( '.htaccess File', 'mainwp' ), | |
| 135 | + 'callback' => array( static::get_class_name(), 'render_htaccess' ), | |
| 136 | + 'active_keys' => array( '.htaccess' ), | |
| 137 | + 'show_in_header_nav' => false, | |
| 138 | + 'show_in_subpages_menu' => true, | |
| 139 | + 'show_in_left_menu' => false, | |
| 140 | + 'show_in_palette' => true, | |
| 141 | + 'left_menu_parent' => 'ServerInformation', | |
| 142 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), esc_html__( '.htaccess File', 'mainwp' ) ), | |
| 143 | + 'condition' => static function() { | |
| 144 | + return MainWP_Server_Information_Handler::is_apache_server_software(); | |
| 145 | + }, | |
| 146 | + ), | |
| 147 | + array( | |
| 148 | + 'slug' => 'ActionLogs', | |
| 149 | + 'page_title' => __( 'Custom Event Monitor', 'mainwp' ), | |
| 150 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'Custom Event Monitor', 'mainwp' ) . '</div>', | |
| 151 | + 'nav_title' => esc_html__( 'Custom Event Monitor', 'mainwp' ), | |
| 152 | + 'callback' => array( static::get_class_name(), 'render_action_logs' ), | |
| 153 | + 'active_keys' => array( 'ActionLogs' ), | |
| 154 | + 'show_in_header_nav' => true, | |
| 155 | + 'show_in_subpages_menu' => false, | |
| 156 | + 'show_in_left_menu' => true, | |
| 157 | + 'show_in_palette' => true, | |
| 158 | + 'left_menu_parent' => 'ServerInformation', | |
| 159 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), esc_html__( 'Custom Event Monitor', 'mainwp' ) ), | |
| 160 | + ), | |
| 161 | + array( | |
| 162 | + 'slug' => 'PluginPrivacy', | |
| 163 | + 'page_title' => __( 'Plugin Privacy', 'mainwp' ), | |
| 164 | + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'Plugin Privacy', 'mainwp' ) . '</div>', | |
| 165 | + 'nav_title' => esc_html__( 'Plugin Privacy', 'mainwp' ), | |
| 166 | + 'callback' => array( static::get_class_name(), 'render_plugin_privacy_page' ), | |
| 167 | + 'active_keys' => array( 'PluginPrivacy' ), | |
| 168 | + 'show_in_header_nav' => false, | |
| 169 | + 'show_in_subpages_menu' => false, | |
| 170 | + 'show_in_left_menu' => true, | |
| 171 | + 'show_in_palette' => true, | |
| 172 | + 'left_menu_parent' => 'mainwp_tab', | |
| 173 | + 'palette_titles' => array( esc_html__( 'Privacy Policy', 'mainwp' ) ), | |
| 174 | + ), | |
| 67 | 175 | ); |
| 68 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) { | |
| 69 | - add_submenu_page( | |
| 70 | - 'mainwp_tab', | |
| 71 | - __( 'Cron Schedules', 'mainwp' ), | |
| 72 | - '<div class="mainwp-hidden">' . esc_html__( 'Cron Schedules', 'mainwp' ) . '</div>', | |
| 73 | - 'read', | |
| 74 | - 'ServerInformationCron', | |
| 75 | - array( | |
| 76 | - static::get_class_name(), | |
| 77 | - 'render_cron', | |
| 78 | - ) | |
| 176 | + | |
| 177 | + $visible_pages = array(); | |
| 178 | + | |
| 179 | + foreach ( $pages as $page ) { | |
| 180 | + if ( 'ServerInformation' !== $page['slug'] && MainWP_Menu::is_disable_menu_item( 3, $page['slug'] ) ) { | |
| 181 | + continue; | |
| 182 | + } | |
| 183 | + | |
| 184 | + if ( isset( $page['condition'] ) && is_callable( $page['condition'] ) && ! call_user_func( $page['condition'] ) ) { | |
| 185 | + continue; | |
| 186 | + } | |
| 187 | + | |
| 188 | + $visible_pages[] = $page; | |
| 189 | + } | |
| 190 | + | |
| 191 | + return $visible_pages; | |
| 192 | + } | |
| 193 | + | |
| 194 | + /** | |
| 195 | + * Convert a navigation href into a usable URL. | |
| 196 | + * | |
| 197 | + * @param string $href Navigation href. | |
| 198 | + * | |
| 199 | + * @return string Navigation URL. | |
| 200 | + */ | |
| 201 | + private static function get_navigation_item_url( $href ) { | |
| 202 | + $href = trim( wp_specialchars_decode( (string) $href, ENT_QUOTES ) ); | |
| 203 | + | |
| 204 | + if ( empty( $href ) ) { | |
| 205 | + return ''; | |
| 206 | + } | |
| 207 | + | |
| 208 | + if ( preg_match( '/^https?:\/\//i', $href ) ) { | |
| 209 | + return $href; | |
| 210 | + } | |
| 211 | + | |
| 212 | + return admin_url( ltrim( $href, '/' ) ); | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Get dynamic Info subpage items using the legacy left-menu normalization path. | |
| 217 | + * | |
| 218 | + * @return array<int, array<string, mixed>> Info navigation items. | |
| 219 | + */ | |
| 220 | + private static function get_filtered_subpage_navigation_items() { | |
| 221 | + $menu_items = array(); | |
| 222 | + $core_slugs = array(); | |
| 223 | + | |
| 224 | + foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) { | |
| 225 | + if ( empty( $item['show_in_left_menu'] ) ) { | |
| 226 | + continue; | |
| 227 | + } | |
| 228 | + | |
| 229 | + $core_slugs[ $item['slug'] ] = true; | |
| 230 | + $menu_items[] = array( | |
| 231 | + 'title' => $item['title'], | |
| 232 | + 'parent_key' => $item['left_menu_parent'], | |
| 233 | + 'href' => $item['href'], | |
| 234 | + 'slug' => $item['slug'], | |
| 235 | + 'right' => '', | |
| 79 | 236 | ); |
| 80 | 237 | } |
| 81 | 238 | |
| 82 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) { | |
| 83 | - add_submenu_page( | |
| 84 | - 'mainwp_tab', | |
| 85 | - __( 'Error Log', 'mainwp' ), | |
| 86 | - '<div class="mainwp-hidden">' . esc_html__( 'Error Log', 'mainwp' ) . '</div>', | |
| 87 | - 'read', | |
| 88 | - 'ErrorLog', | |
| 89 | - array( | |
| 90 | - static::get_class_name(), | |
| 91 | - 'render_error_log_page', | |
| 92 | - ) | |
| 239 | + MainWP_Menu::init_subpages_left_menu( static::get_subpages(), $menu_items, 'ServerInformation', 'Server' ); | |
| 240 | + | |
| 241 | + $items = array(); | |
| 242 | + | |
| 243 | + foreach ( $menu_items as $menu_item ) { | |
| 244 | + if ( empty( $menu_item['slug'] ) || empty( $menu_item['title'] ) || empty( $menu_item['href'] ) ) { | |
| 245 | + continue; | |
| 246 | + } | |
| 247 | + | |
| 248 | + if ( isset( $core_slugs[ $menu_item['slug'] ] ) ) { | |
| 249 | + continue; | |
| 250 | + } | |
| 251 | + | |
| 252 | + if ( isset( $menu_item['item_slug'] ) ) { | |
| 253 | + if ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['item_slug'] ) ) { | |
| 254 | + continue; | |
| 255 | + } | |
| 256 | + } elseif ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['slug'] ) ) { | |
| 257 | + continue; | |
| 258 | + } | |
| 259 | + | |
| 260 | + $active_slug = 0 === strpos( $menu_item['slug'], 'Server' ) ? substr( $menu_item['slug'], strlen( 'Server' ) ) : $menu_item['slug']; | |
| 261 | + | |
| 262 | + $item = array( | |
| 263 | + 'slug' => $menu_item['slug'], | |
| 264 | + 'title' => $menu_item['title'], | |
| 265 | + 'href' => $menu_item['href'], | |
| 266 | + 'active_keys' => array( $active_slug, $menu_item['slug'] ), | |
| 267 | + 'show_in_header_nav' => false, | |
| 268 | + 'show_in_subpages_menu' => true, | |
| 269 | + 'show_in_left_menu' => true, | |
| 270 | + 'show_in_palette' => true, | |
| 271 | + 'left_menu_parent' => isset( $menu_item['parent_key'] ) ? $menu_item['parent_key'] : 'ServerInformation', | |
| 272 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), $menu_item['title'] ), | |
| 273 | + 'menu_hidden' => false, | |
| 93 | 274 | ); |
| 275 | + | |
| 276 | + if ( isset( $menu_item['item_slug'] ) ) { | |
| 277 | + $item['item_slug'] = $menu_item['item_slug']; | |
| 278 | + } | |
| 279 | + | |
| 280 | + if ( ! empty( $menu_item['before_title'] ) ) { | |
| 281 | + $item['before_title'] = $menu_item['before_title']; | |
| 282 | + $item['palette_titles'][1] = trim( wp_strip_all_tags( $menu_item['before_title'] ) . ' ' . $menu_item['title'] ); | |
| 283 | + } | |
| 284 | + | |
| 285 | + $items[] = $item; | |
| 94 | 286 | } |
| 95 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'WPConfig' ) ) { | |
| 96 | - add_submenu_page( | |
| 97 | - 'mainwp_tab', | |
| 98 | - __( 'WP-Config File', 'mainwp' ), | |
| 99 | - '<div class="mainwp-hidden">' . esc_html__( 'WP-Config File', 'mainwp' ) . '</div>', | |
| 100 | - 'read', | |
| 101 | - 'WPConfig', | |
| 102 | - array( | |
| 103 | - static::get_class_name(), | |
| 104 | - 'render_wp_config', | |
| 105 | - ) | |
| 287 | + | |
| 288 | + return $items; | |
| 289 | + } | |
| 290 | + | |
| 291 | + /** | |
| 292 | + * Get the Info navigation items. | |
| 293 | + * | |
| 294 | + * @return array<int, array<string, mixed>> Info navigation items. | |
| 295 | + */ | |
| 296 | + public static function get_navigation_items( $context = 'default' ) { | |
| 297 | + $items = array(); | |
| 298 | + | |
| 299 | + foreach ( static::get_core_pages() as $page ) { | |
| 300 | + $items[] = array( | |
| 301 | + 'slug' => $page['slug'], | |
| 302 | + 'title' => $page['nav_title'], | |
| 303 | + 'href' => 'admin.php?page=' . $page['slug'], | |
| 304 | + 'active_keys' => $page['active_keys'], | |
| 305 | + 'show_in_header_nav' => $page['show_in_header_nav'], | |
| 306 | + 'show_in_subpages_menu' => $page['show_in_subpages_menu'], | |
| 307 | + 'show_in_left_menu' => $page['show_in_left_menu'], | |
| 308 | + 'show_in_palette' => $page['show_in_palette'], | |
| 309 | + 'left_menu_parent' => $page['left_menu_parent'], | |
| 310 | + 'palette_titles' => $page['palette_titles'], | |
| 311 | + 'menu_hidden' => false, | |
| 106 | 312 | ); |
| 107 | 313 | } |
| 108 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, '.htaccess' ) && MainWP_Server_Information_Handler::is_apache_server_software() ) { | |
| 109 | - add_submenu_page( | |
| 110 | - 'mainwp_tab', | |
| 111 | - __( '.htaccess File', 'mainwp' ), | |
| 112 | - '<div class="mainwp-hidden">' . esc_html__( '.htaccess File', 'mainwp' ) . '</div>', | |
| 113 | - 'read', | |
| 114 | - '.htaccess', | |
| 115 | - array( | |
| 116 | - static::get_class_name(), | |
| 117 | - 'render_htaccess', | |
| 118 | - ) | |
| 314 | + | |
| 315 | + if ( 'left_menu_core' === $context ) { | |
| 316 | + return $items; | |
| 317 | + } | |
| 318 | + | |
| 319 | + if ( 'command_palette' === $context ) { | |
| 320 | + return array_merge( $items, static::get_filtered_subpage_navigation_items() ); | |
| 321 | + } | |
| 322 | + | |
| 323 | + foreach ( static::get_subpages() as $subPage ) { | |
| 324 | + if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) { | |
| 325 | + continue; | |
| 326 | + } | |
| 327 | + | |
| 328 | + $item = array( | |
| 329 | + 'slug' => 'Server' . $subPage['slug'], | |
| 330 | + 'title' => $subPage['title'], | |
| 331 | + 'href' => ! empty( $subPage['href'] ) ? $subPage['href'] : 'admin.php?page=Server' . $subPage['slug'], | |
| 332 | + 'active_keys' => array( $subPage['slug'], 'Server' . $subPage['slug'] ), | |
| 333 | + 'show_in_header_nav' => false, | |
| 334 | + 'show_in_subpages_menu' => empty( $subPage['menu_hidden'] ), | |
| 335 | + 'show_in_left_menu' => empty( $subPage['menu_hidden'] ), | |
| 336 | + 'show_in_palette' => empty( $subPage['menu_hidden'] ), | |
| 337 | + 'left_menu_parent' => 'ServerInformation', | |
| 338 | + 'palette_titles' => array( esc_html__( 'System Info', 'mainwp' ), $subPage['title'] ), | |
| 339 | + 'menu_hidden' => ! empty( $subPage['menu_hidden'] ), | |
| 119 | 340 | ); |
| 341 | + | |
| 342 | + if ( isset( $subPage['item_slug'] ) ) { | |
| 343 | + $item['item_slug'] = $subPage['item_slug']; | |
| 344 | + } | |
| 345 | + | |
| 346 | + $items[] = $item; | |
| 120 | 347 | } |
| 121 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ActionLogs' ) ) { | |
| 122 | - add_submenu_page( | |
| 123 | - 'mainwp_tab', | |
| 124 | - __( 'Custom Event Monitor', 'mainwp' ), | |
| 125 | - '<div class="mainwp-hidden">' . esc_html__( 'Custom Event Monitor', 'mainwp' ) . '</div>', | |
| 126 | - 'read', | |
| 127 | - 'ActionLogs', | |
| 128 | - array( | |
| 129 | - static::get_class_name(), | |
| 130 | - 'render_action_logs', | |
| 131 | - ) | |
| 348 | + | |
| 349 | + return $items; | |
| 350 | + } | |
| 351 | + | |
| 352 | + /** | |
| 353 | + * Get the Info command palette items. | |
| 354 | + * | |
| 355 | + * @return array<int, array<string, mixed>> Command palette item definitions. | |
| 356 | + */ | |
| 357 | + public static function get_command_palette_items() { | |
| 358 | + $items = array(); | |
| 359 | + | |
| 360 | + foreach ( static::get_navigation_items( 'command_palette' ) as $item ) { | |
| 361 | + if ( empty( $item['show_in_palette'] ) ) { | |
| 362 | + continue; | |
| 363 | + } | |
| 364 | + | |
| 365 | + $items[] = array( | |
| 366 | + 'slug' => $item['slug'], | |
| 367 | + 'href' => $item['href'], | |
| 368 | + 'path_titles' => $item['palette_titles'], | |
| 132 | 369 | ); |
| 133 | 370 | } |
| 134 | 371 | |
| 135 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'PluginPrivacy' ) ) { | |
| 372 | + return $items; | |
| 373 | + } | |
| 374 | + | |
| 375 | + /** | |
| 376 | + * Method init_menu() | |
| 377 | + * | |
| 378 | + * Initiate Info subPage menu. | |
| 379 | + * | |
| 380 | + * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item() | |
| 381 | + * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_apache_server_software() | |
| 382 | + */ | |
| 383 | + public static function init_menu() { // phpcs:ignore -- NOSONAR - complex. | |
| 384 | + | |
| 385 | + add_action( 'mainwp_pageheader_infor', array( static::get_class_name(), 'render_header' ) ); | |
| 386 | + add_action( 'mainwp_pagefooter_infor', array( static::get_class_name(), 'render_footer' ) ); | |
| 387 | + | |
| 388 | + foreach ( static::get_core_pages() as $page ) { | |
| 136 | 389 | add_submenu_page( |
| 137 | 390 | 'mainwp_tab', |
| 138 | - __( 'Plugin Privacy', 'mainwp' ), | |
| 139 | - '<div class="mainwp-hidden">' . esc_html__( 'Plugin Privacy', 'mainwp' ) . '</div>', | |
| 391 | + $page['page_title'], | |
| 392 | + $page['menu_title'], | |
| 140 | 393 | 'read', |
| 141 | - 'PluginPrivacy', | |
| 142 | - array( | |
| 143 | - static::get_class_name(), | |
| 144 | - 'render_plugin_privacy_page', | |
| 145 | - ) | |
| 394 | + $page['slug'], | |
| 395 | + $page['callback'] | |
| 146 | 396 | ); |
| 147 | 397 | } |
| 148 | 398 | |
| 149 | - /** | |
| 150 | - * Filter mainwp_getsubpages_server | |
| 151 | - * | |
| 152 | - * Filters subpages for the Info page. | |
| 153 | - * | |
| 154 | - * @since Unknown | |
| 155 | - */ | |
| 156 | - $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-server', array( array() ), '4.0.7.2', 'mainwp_getsubpages_server' ); // NOSONAR - not IP. | |
| 157 | - static::$subPages = apply_filters( 'mainwp_getsubpages_server', $sub_pages ); | |
| 399 | + foreach ( static::get_subpages() as $subPage ) { | |
| 400 | + if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) { | |
| 401 | + continue; | |
| 402 | + } | |
| 158 | 403 | |
| 159 | - if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { | |
| 160 | - foreach ( static::$subPages as $subPage ) { | |
| 161 | - if ( ! isset( $subPage['slug'] ) ) { | |
| 162 | - continue; | |
| 163 | - } | |
| 164 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) { | |
| 165 | - continue; | |
| 166 | - } | |
| 167 | - add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Server' . $subPage['slug'], $subPage['callback'] ); | |
| 168 | - } | |
| 404 | + add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Server' . $subPage['slug'], $subPage['callback'] ); | |
| 169 | 405 | } |
| 170 | 406 | } |
| 171 | 407 | |
| 172 | 408 | /** |
| @@ -180,39 +416,12 @@ | ||
| 180 | 416 | <div id="menu-mainwp-ServerInformation" class="mainwp-submenu-wrapper"> |
| 181 | 417 | <div class="wp-submenu sub-open"> |
| 182 | 418 | <div class="mainwp_boxout"> |
| 183 | 419 | <div class="mainwp_boxoutin"></div> |
| 184 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformation' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Server', 'mainwp' ); ?></a> | |
| 185 | - <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) { ?> | |
| 186 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=ServerInformationCron' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Cron Schedules', 'mainwp' ); ?></a> | |
| 420 | + <?php foreach ( static::get_navigation_items() as $item ) { ?> | |
| 421 | + <?php if ( empty( $item['show_in_subpages_menu'] ) ) { continue; } ?> | |
| 422 | + <a href="<?php echo esc_url( static::get_navigation_item_url( $item['href'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $item['title'] ); ?></a> | |
| 187 | 423 | <?php } ?> |
| 188 | - <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) { ?> | |
| 189 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=ErrorLog' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Error Log', 'mainwp' ); ?></a> | |
| 190 | - <?php } ?> | |
| 191 | - <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'WPConfig' ) ) { ?> | |
| 192 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=WPConfig' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'WP-Config File', 'mainwp' ); ?></a> | |
| 193 | - <?php } ?> | |
| 194 | - <?php | |
| 195 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, '.htaccess' ) && MainWP_Server_Information_Handler::is_apache_server_software() ) { | |
| 196 | - ?> | |
| 197 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=.htaccess' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( '.htaccess File', 'mainwp' ); ?></a> | |
| 198 | - <?php | |
| 199 | - } | |
| 200 | - ?> | |
| 201 | - <?php | |
| 202 | - if ( isset( static::$subPages ) && is_array( static::$subPages ) ) { | |
| 203 | - foreach ( static::$subPages as $subPage ) { | |
| 204 | - if ( ! isset( $subPage['menu_hidden'] ) || ( isset( $subPage['menu_hidden'] ) && true !== $subPage['menu_hidden'] ) ) { | |
| 205 | - if ( MainWP_Menu::is_disable_menu_item( 3, 'Server' . $subPage['slug'] ) ) { | |
| 206 | - continue; | |
| 207 | - } | |
| 208 | - ?> | |
| 209 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=Server' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo esc_html( $subPage['title'] ); ?></a> | |
| 210 | - <?php | |
| 211 | - } | |
| 212 | - } | |
| 213 | - } | |
| 214 | - ?> | |
| 215 | 424 | </div> |
| 216 | 425 | </div> |
| 217 | 426 | </div> |
| 218 | 427 | <?php |
| @@ -239,60 +448,39 @@ | ||
| 239 | 448 | ), |
| 240 | 449 | 0 |
| 241 | 450 | ); |
| 242 | 451 | |
| 243 | - /** | |
| 244 | - * MainWP active menu slugs array. | |
| 245 | - * | |
| 246 | - * @global object | |
| 247 | - */ | |
| 248 | - global $_mainwp_menu_active_slugs; | |
| 452 | + $init_sub_subleftmenu = array(); | |
| 249 | 453 | |
| 250 | - $_mainwp_menu_active_slugs['ActionLogs'] = 'ServerInformation'; | |
| 454 | + foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) { | |
| 455 | + if ( empty( $item['show_in_left_menu'] ) ) { | |
| 456 | + continue; | |
| 457 | + } | |
| 251 | 458 | |
| 252 | - $init_sub_subleftmenu = array( | |
| 253 | - array( | |
| 254 | - 'title' => esc_html__( 'Server', 'mainwp' ), | |
| 255 | - 'parent_key' => 'ServerInformation', | |
| 256 | - 'href' => 'admin.php?page=ServerInformation', | |
| 257 | - 'slug' => 'ServerInformation', | |
| 459 | + $init_sub_subleftmenu[] = array( | |
| 460 | + 'title' => $item['title'], | |
| 461 | + 'parent_key' => $item['left_menu_parent'], | |
| 462 | + 'href' => $item['href'], | |
| 463 | + 'slug' => $item['slug'], | |
| 258 | 464 | 'right' => '', |
| 259 | - ), | |
| 260 | - array( | |
| 261 | - 'title' => esc_html__( 'Cron Schedules', 'mainwp' ), | |
| 262 | - 'parent_key' => 'ServerInformation', | |
| 263 | - 'href' => 'admin.php?page=ServerInformationCron', | |
| 264 | - 'slug' => 'ServerInformationCron', | |
| 265 | - 'right' => '', | |
| 266 | - ), | |
| 267 | - array( | |
| 268 | - 'title' => esc_html__( 'Error Log', 'mainwp' ), | |
| 269 | - 'parent_key' => 'ServerInformation', | |
| 270 | - 'href' => 'admin.php?page=ErrorLog', | |
| 271 | - 'slug' => 'ErrorLog', | |
| 272 | - 'right' => '', | |
| 273 | - ), | |
| 274 | - array( | |
| 275 | - 'title' => esc_html__( 'Custom Event Monitor', 'mainwp' ), | |
| 276 | - 'parent_key' => 'ServerInformation', | |
| 277 | - 'href' => 'admin.php?page=ActionLogs', | |
| 278 | - 'slug' => 'ActionLogs', | |
| 279 | - 'right' => '', | |
| 280 | - ), | |
| 281 | - array( | |
| 282 | - 'title' => esc_html__( 'Plugin Privacy', 'mainwp' ), | |
| 283 | - 'parent_key' => 'mainwp_tab', | |
| 284 | - 'href' => 'admin.php?page=PluginPrivacy', | |
| 285 | - 'slug' => 'PluginPrivacy', | |
| 286 | - 'right' => '', | |
| 287 | - ), | |
| 288 | - ); | |
| 465 | + ); | |
| 466 | + } | |
| 289 | 467 | |
| 468 | + if ( empty( $subPages ) ) { | |
| 469 | + $subPages = static::get_subpages(); | |
| 470 | + } | |
| 471 | + | |
| 290 | 472 | MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'ServerInformation', 'Server' ); |
| 473 | + | |
| 291 | 474 | foreach ( $init_sub_subleftmenu as $item ) { |
| 292 | - if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { | |
| 475 | + if ( isset( $item['item_slug'] ) ) { | |
| 476 | + if ( MainWP_Menu::is_disable_menu_item( 3, $item['item_slug'] ) ) { | |
| 477 | + continue; | |
| 478 | + } | |
| 479 | + } elseif ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) { | |
| 293 | 480 | continue; |
| 294 | 481 | } |
| 482 | + | |
| 295 | 483 | MainWP_Menu::add_left_menu( $item, 2 ); |
| 296 | 484 | } |
| 297 | 485 | } |
| 298 | 486 | |
| @@ -314,38 +502,20 @@ | ||
| 314 | 502 | MainWP_UI::render_top_header( $params ); |
| 315 | 503 | |
| 316 | 504 | $renderItems = array(); |
| 317 | 505 | |
| 318 | - $renderItems[] = array( | |
| 319 | - 'title' => esc_html__( 'Server', 'mainwp' ), | |
| 320 | - 'href' => 'admin.php?page=ServerInformation', | |
| 321 | - 'active' => ( '' === $shownPage ) ? true : false, | |
| 322 | - ); | |
| 506 | + foreach ( static::get_navigation_items() as $item ) { | |
| 507 | + if ( empty( $item['show_in_header_nav'] ) ) { | |
| 508 | + continue; | |
| 509 | + } | |
| 323 | 510 | |
| 324 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ServerInformationCron' ) ) { | |
| 325 | 511 | $renderItems[] = array( |
| 326 | - 'title' => esc_html__( 'Cron Schedules', 'mainwp' ), | |
| 327 | - 'href' => 'admin.php?page=ServerInformationCron', | |
| 328 | - 'active' => ( 'ServerInformationCron' === $shownPage ) ? true : false, | |
| 512 | + 'title' => $item['title'], | |
| 513 | + 'href' => $item['href'], | |
| 514 | + 'active' => in_array( $shownPage, $item['active_keys'], true ), | |
| 329 | 515 | ); |
| 330 | 516 | } |
| 331 | 517 | |
| 332 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ErrorLog' ) ) { | |
| 333 | - $renderItems[] = array( | |
| 334 | - 'title' => esc_html__( 'Error Log', 'mainwp' ), | |
| 335 | - 'href' => 'admin.php?page=ErrorLog', | |
| 336 | - 'active' => ( 'ErrorLog' === $shownPage ) ? true : false, | |
| 337 | - ); | |
| 338 | - } | |
| 339 | - | |
| 340 | - if ( ! MainWP_Menu::is_disable_menu_item( 3, 'ActionLogs' ) ) { | |
| 341 | - $renderItems[] = array( | |
| 342 | - 'title' => esc_html__( 'Custom Event Monitor', 'mainwp' ), | |
| 343 | - 'href' => 'admin.php?page=ActionLogs', | |
| 344 | - 'active' => ( 'ActionLogs' === $shownPage ) ? true : false, | |
| 345 | - ); | |
| 346 | - } | |
| 347 | - | |
| 348 | 518 | if ( isset( $_GET['page'] ) && 'PluginPrivacy' !== $_GET['page'] ) { //phpcs:ignore -- monce safe. |
| 349 | 519 | MainWP_UI::render_page_navigation( $renderItems ); |
| 350 | 520 | } |
| 351 | 521 | |
| @@ -446,8 +616,12 @@ | ||
| 446 | 616 | if ( function_exists( 'curl_version' ) && ! MainWP_Server_Information_Handler::curlssl_compare( 'OpenSSL/1.1.0', '>=' ) ) { |
| 447 | 617 | /* translators: 1: line break tag, 2: opening anchor tag, 3: closing anchor tag */ |
| 448 | 618 | echo "<div class='ui yellow message'>" . sprintf( esc_html__( 'Your host needs to update OpenSSL to at least version 1.1.0 which is already over 4 years old and contains patches for over 60 vulnerabilities.%1$sThese range from Denial of Service to Remote Code Execution. %2$sClick here for more information.%3$s', 'mainwp' ), '<br/>', '<a href="https://community.letsencrypt.org/t/openssl-client-compatibility-changes-for-let-s-encrypt-certificates/143816" target="_blank">', '</a>' ) . '</div>'; |
| 449 | 619 | } |
| 620 | + | |
| 621 | + // Detect issues before rendering. | |
| 622 | + $datatable_rows = MainWP_Server_Information_Handler::get_database_report_rows(); | |
| 623 | + | |
| 450 | 624 | static::render_detected_issues_summary(); |
| 451 | 625 | ?> |
| 452 | 626 | <style type="text/css"> |
| 453 | 627 | #mainwp-system-report-page { |
| @@ -519,8 +693,10 @@ | ||
| 519 | 693 | <?php static::render_mysql_check_tbody(); ?> |
| 520 | 694 | </tbody> |
| 521 | 695 | </table> |
| 522 | 696 | |
| 697 | + <?php self::render_report_section_table( 'mainwp-system-report-mainwp-database-table', __( 'Database', 'mainwp' ), $datatable_rows, 'Database' ); ?> | |
| 698 | + | |
| 523 | 699 | <?php self::render_report_section_table( 'mainwp-system-report-connectivity-table', __( 'Connectivity & Authentication', 'mainwp' ), MainWP_Server_Information_Handler::get_connectivity_report_rows(), 'Connectivity & Authentication' ); ?> |
| 524 | 700 | |
| 525 | 701 | <?php self::render_report_section_table( 'mainwp-system-report-scheduler-table', __( 'Scheduler & Background Jobs', 'mainwp' ), MainWP_Server_Information_Handler::get_scheduler_report_rows(), 'Scheduler & Background Jobs' ); ?> |
| 526 | 702 | |
| @@ -1771,8 +1947,9 @@ | ||
| 1771 | 1947 | MainWP_Logger::CACHE_METRICS_LOG_PRIORITY => esc_html__( 'Cache Metrics', 'mainwp' ), |
| 1772 | 1948 | MainWP_Logger::DB_QUERIES_LOG_PRIORITY => esc_html__( 'DB Queries', 'mainwp' ), |
| 1773 | 1949 | MainWP_Logger::WARM_CACHE_LOG_PRIORITY => esc_html__( 'Warm Cache', 'mainwp' ), |
| 1774 | 1950 | MainWP_Logger::EXTENSION_UPDATES_CHECK_LOG_PRIORITY => esc_html__( 'Extension Updates Check', 'mainwp' ), |
| 1951 | + MainWP_Logger::AUTO_UPDATES_LOG_PRIORITY => esc_html__( 'Auto Updates', 'mainwp' ), | |
| 1775 | 1952 | ); |
| 1776 | 1953 | $specific_logs = apply_filters( 'mainwp_specific_action_logs', $specific_default ); // deprecated since 4.3.1, use 'mainwp_log_specific_actions' instead. |
| 1777 | 1954 | $specific_logs = apply_filters( 'mainwp_log_specific_actions', $specific_logs ); |
| 1778 | 1955 | |