get_abilities(); $risk_counts = $scanner->get_risk_counts( $abilities ); $ability_table = new Ability_Guard_Ability_Table( $abilities ); $ability_table->prepare_items(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only detail selection. $selected_name = isset( $_GET['ability_name'] ) ? sanitize_text_field( rawurldecode( wp_unslash( $_GET['ability_name'] ) ) ) : ''; $selected_item = '' !== $selected_name ? $scanner->get_ability( $selected_name ) : null; require ABILITY_GUARD_PATH . 'templates/admin/page-ability-inventory.php'; } /** * Render the execution log page. */ public function render_log_viewer(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to view this page.', 'ability-guard' ) ); } $repository = new Ability_Guard_Log_Repository(); $log_table = new Ability_Guard_Log_Table( $repository ); $log_table->prepare_items(); $selected_log = null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only detail selection. $log_id = isset( $_GET['log_id'] ) ? absint( wp_unslash( $_GET['log_id'] ) ) : 0; if ( $log_id > 0 ) { $selected_log = $repository->get_log( $log_id ); } require ABILITY_GUARD_PATH . 'templates/admin/page-log-viewer.php'; } /** * Render the settings page. */ public function render_settings(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to view this page.', 'ability-guard' ) ); } require ABILITY_GUARD_PATH . 'templates/admin/page-settings.php'; } /** * Render multisite network dashboard. */ public function render_network_dashboard(): void { if ( ! current_user_can( 'manage_network_options' ) ) { wp_die( esc_html__( 'You do not have permission to view this page.', 'ability-guard' ) ); } $sites = is_multisite() ? get_sites( array( 'number' => 100 ) ) : array(); require ABILITY_GUARD_PATH . 'templates/admin/page-network-dashboard.php'; } /** * Enqueue admin assets. * * @param string $hook_suffix Current admin hook suffix. */ public function enqueue_assets( string $hook_suffix ): void { $pages = array( 'toplevel_page_ability-guard', 'abilityguard_page_ability-guard-logs', 'abilityguard_page_ability-guard-settings', 'toplevel_page_ability-guard-network', ); if ( ! in_array( $hook_suffix, $pages, true ) ) { return; } wp_enqueue_style( 'ability-guard-admin', ABILITY_GUARD_URL . 'assets/css/admin.css', array(), ABILITY_GUARD_VERSION ); $script_dependencies = array(); if ( 'abilityguard_page_ability-guard-logs' === $hook_suffix || 'toplevel_page_ability-guard' === $hook_suffix ) { add_thickbox(); $script_dependencies[] = 'thickbox'; } wp_enqueue_script( 'ability-guard-admin', ABILITY_GUARD_URL . 'assets/js/admin.js', $script_dependencies, ABILITY_GUARD_VERSION, true ); } }