init(); } return self::$instance; } private function __construct() {} private function init(): void { add_action( 'admin_menu', array( $this, 'register_menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); add_action( 'admin_post_ssc_real_seo_run_baseline', array( $this, 'handle_run_baseline' ) ); add_action( 'admin_post_ssc_real_seo_request_help', array( $this, 'handle_request_help' ) ); } public function register_menu(): void { add_menu_page( __( '7 Sided Cube Real SEO', '7-sided-cube-real-seo' ), __( '7 Sided Cube Real SEO', '7-sided-cube-real-seo' ), 'manage_options', $this->menu_slug, array( $this, 'render_main_page' ), 'dashicons-chart-area', 58 ); } public function enqueue_assets( string $hook ): void { // Enqueue styles on our plugin screen. Be resilient to different hook names. // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only screen routing. $page = isset( $_GET['page'] ) ? sanitize_key( (string) wp_unslash( $_GET['page'] ) ) : ''; $is_our_hook = ( false !== strpos( (string) $hook, $this->menu_slug ) ); $is_our_page = ( $this->menu_slug === $page ); if ( ! $is_our_hook && ! $is_our_page ) { return; } wp_enqueue_style( "ssc-real-seo-admin", SSC_REAL_SEO_PLUGIN_URL . "assets/css/admin.css", array(), SSC_REAL_SEO_VERSION ); } private function get_active_tab(): string { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only tab selection. $tab = isset( $_GET['tab'] ) ? sanitize_key( (string) wp_unslash( $_GET['tab'] ) ) : 'baseline'; $allowed = array( 'baseline', 'overview', 'request_help' ); return in_array( $tab, $allowed, true ) ? $tab : 'baseline'; } public function render_main_page(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to access this page.', '7-sided-cube-real-seo' ) ); } $tab = $this->get_active_tab(); $baseline_cache = SSC_Real_SEO_Baseline::get_cached_results(); $last_run = isset( $baseline_cache['ran_at'] ) ? (int) $baseline_cache['ran_at'] : 0; ?>
0 ) { echo esc_html( sprintf( /* translators: %s: time */ __( 'Last run: %s', '7-sided-cube-real-seo' ), date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $last_run ) ) ); } ?>