$data ) { $slug = dirname( $file ); if ( '.' === $slug ) { $slug = basename( $file, '.php' ); } if ( self::MANAGER_SLUG === $slug ) { return is_plugin_active( $file ); } } return false; } /** * Persists the dismissal of the plugins-screen notice, then redirects * back to a clean URL. * * @since 1.2.2 * * @return void */ public function handle_dismiss() { if ( ! isset( $_GET['ai_translator_dismiss_manager_notice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- verified below before any state change. return; } check_admin_referer( 'ai_translator_dismiss_manager_notice' ); if ( ! current_user_can( 'manage_options' ) ) { return; } update_option( self::DISMISSED_OPTION, '1', false ); wp_safe_redirect( remove_query_arg( array( 'ai_translator_dismiss_manager_notice', '_wpnonce' ) ) ); exit; } /** * Renders the dismissible notice on the Plugins list screens when * Manager is missing or inactive. * * @since 1.2.2 * * @return void */ public function render_plugins_screen_notice() { if ( ! current_user_can( 'manage_options' ) ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! is_object( $screen ) || ! in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) ) { return; } if ( $this->is_manager_active() ) { return; } if ( '1' === get_option( self::DISMISSED_OPTION, '' ) ) { return; } $dismiss_url = wp_nonce_url( add_query_arg( 'ai_translator_dismiss_manager_notice', '1' ), 'ai_translator_dismiss_manager_notice' ); printf( '

%1$s %3$s%5$s

', esc_html__( 'To get updates for the ROBOTSTXT plugins, the plugin below must be installed and active:', 'robotstxt-ai-translator' ), esc_url( self::MANAGER_URL ), esc_html__( 'Manager (by ROBOTSTXT)', 'robotstxt-ai-translator' ), esc_url( $dismiss_url ), esc_html__( 'Dismiss this notice', 'robotstxt-ai-translator' ) ); } /** * Renders the persistent (non-dismissible) warning for the settings * pages when Manager is missing or inactive. * * @since 1.2.2 * * @return void */ public function render_settings_notice() { if ( $this->is_manager_active() ) { return; } printf( '

%1$s %3$s

', esc_html__( 'To get updates for the ROBOTSTXT plugins, the plugin below must be installed and active:', 'robotstxt-ai-translator' ), esc_url( self::MANAGER_URL ), esc_html__( 'Manager (by ROBOTSTXT)', 'robotstxt-ai-translator' ) ); } } }