is_plugin_screen(); if ( ! $is_plugin_screen && 'index.php' !== $hook_suffix ) { return; } wp_enqueue_style( self::HANDLE, AIBLACKOUT_URL . 'assets/admin.css', array(), AIBLACKOUT_VERSION ); if ( ! $is_plugin_screen ) { // Nothing on the Dashboard for the interactive script to act on. return; } wp_enqueue_script( self::SCRIPT_HANDLE, AIBLACKOUT_URL . 'assets/admin.js', array(), AIBLACKOUT_VERSION, true ); wp_localize_script( self::SCRIPT_HANDLE, 'aiblackoutGroupLabels', array( /* translators: %s: Number of crawlers. */ 'block' => __( '%s blocked', 'ai-blackout' ), /* translators: %s: Number of crawlers. */ 'signal' => __( '%s asking', 'ai-blackout' ), /* translators: %s: Number of crawlers. */ 'allow' => __( '%s allowed', 'ai-blackout' ), ) ); } /** * Whether the screen being rendered is one of this plugin's. * * @return bool True on an AI Blackout screen. */ private function is_plugin_screen(): bool { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading which admin screen is being rendered; nothing is acted on. if ( ! isset( $_GET['page'] ) ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- As above. $page = sanitize_key( wp_unslash( $_GET['page'] ) ); return 0 === strpos( $page, MainScreen::SLUG ); } }