ui = $ui; $this->global_settings = $global_settings; } public function slug(): string { return 'settings'; } public function label(): string { return __( 'Settings', 'acez-seo' ); } public function icon(): string { return 'settings'; } public function enqueue(): void { } public function handles_form_key( string $raw_tab ): bool { return in_array( sanitize_key( $raw_tab ), array( 'visibility', 'url_settings', 'plugin_language', 'conflict_override' ), true ); } /** @return array */ public function save( string $raw_tab ): array { // Defence in depth: SettingsPage::handle_save() verifies this nonce // before dispatch; re-checking keeps every entry point independently safe. check_admin_referer( FormControls::NONCE_ACTION ); $tab_key = sanitize_key( $raw_tab ); if ( 'visibility' === $tab_key ) { $this->global_settings->update( array( 'hide_from_search' => isset( $_POST['hide_from_search'] ), ) ); } elseif ( 'url_settings' === $tab_key ) { $this->global_settings->update( array( 'no_category_base' => isset( $_POST['no_category_base'] ), ) ); } elseif ( 'plugin_language' === $tab_key ) { $this->global_settings->update( array( 'force_locale' => isset( $_POST['force_locale'] ) ? sanitize_text_field( wp_unslash( $_POST['force_locale'] ) ) : '', ) ); } elseif ( 'conflict_override' === $tab_key ) { $this->global_settings->update( array( 'override_seo_conflict' => isset( $_POST['override_seo_conflict'] ), ) ); } return array( 'tab' => 'settings' ); } public function render(): void { $settings = $this->global_settings->get(); echo '

' . esc_html__( 'Module settings: the plugin\'s interface language, URL structure and the site\'s visibility to search engines.', 'acez-seo' ) . '

'; $this->render_language_card( $settings ); $this->ui->card_open( __( 'URLs', 'acez-seo' ), 'settings', '', 'url-settings' ); $this->ui->form_open( 'url_settings' ); echo ''; $this->ui->checkbox_field( 'no_category_base', __( 'Remove "/category/" from category URLs (old URLs automatically 301-redirect)', 'acez-seo' ), (bool) $settings['no_category_base'], 'no_category_base' ); echo '
'; submit_button(); $this->ui->form_close(); $this->ui->card_close(); $this->render_conflict_override_card( $settings ); // Deliberately LAST and visually flagged — this switch can deindex // the whole site. $this->render_visibility_card( $settings ); } /** * Only rendered when another SEO plugin is actually detected AND a * verified override exists for it (ConflictOverrideRegistry) — no dead * toggle for plugins we haven't researched/built support for yet. * * @param array $settings */ private function render_conflict_override_card( array $settings ): void { $override = ConflictOverrideRegistry::for_active_conflict(); if ( null === $override ) { return; } $this->ui->card_open( __( 'SEO plugin conflict — risk zone', 'acez-seo' ), 'settings', 'acez-seo-card--danger', 'conflict-override' ); printf( '

%s

', esc_html( sprintf( /* translators: %1$s: name of the detected SEO plugin. */ __( '⚠ Active plugin “%1$s” detected. By default, Acez SEO AI disables ALL of its own meta tags to avoid duplicating them. This switch forces our own Open Graph/Twitter Cards and disables the corresponding tags in that plugin (without changing its settings) — the title, meta description and canonical still come from “%1$s”.', 'acez-seo' ), $override->plugin_name() ) ) ); $this->ui->form_open( 'conflict_override' ); echo ''; $this->ui->checkbox_field( 'override_seo_conflict', __( 'Force Acez SEO AI Open Graph/Twitter Cards', 'acez-seo' ), (bool) $settings['override_seo_conflict'], 'conflict_override' ); echo '
'; submit_button(); $this->ui->form_close(); $this->ui->card_close(); } /** * @param array $settings */ private function render_visibility_card( array $settings ): void { $this->ui->card_open( __( 'Search engine visibility — danger zone', 'acez-seo' ), 'robots', 'acez-seo-card--danger', 'visibility' ); echo '

' . esc_html__( '⚠ Warning: enabling this lock disables indexing of the ENTIRE site by search engines (noindex, nofollow on every page + XML sitemap disabled). Left on in production, it will make the site disappear from search results.', 'acez-seo' ) . '

'; if ( (bool) $settings['hide_from_search'] ) { echo '

' . esc_html__( 'The site is currently HIDDEN from search engines — every page has noindex, nofollow, and the XML sitemap is disabled.', 'acez-seo' ) . '

'; } // Read-only detection of WordPress's own "Search engine visibility" // setting (blog_public) — the two switches are independent, so warn // whenever the WP one hides the site (same doctrine as the other // conflict detectors: never modify foreign settings, only inform). if ( '0' === (string) get_option( 'blog_public', '1' ) ) { $message = (bool) $settings['hide_from_search'] ? __( 'The site is also hidden by WordPress\'s own "Search engine visibility" setting — turning the lock off here will NOT restore indexing.', 'acez-seo' ) : __( 'Even though the plugin\'s lock is off, the site is STILL invisible to search engines — it is hidden by WordPress\'s own "Search engine visibility" setting.', 'acez-seo' ); printf( '

%1$s %3$s

', esc_html( $message ), esc_url( admin_url( 'options-reading.php' ) ), esc_html__( 'Go to Settings → Reading', 'acez-seo' ) ); } $this->ui->form_open( 'visibility' ); echo ''; $this->ui->checkbox_field( 'hide_from_search', __( 'Hide the entire site from search engines (noindex, nofollow on every page + sitemap disabled)', 'acez-seo' ), (bool) $settings['hide_from_search'], 'hide_from_search' ); echo '
'; echo '

' . esc_html__( 'Overrides all per-post and per-content-type robots settings. Useful for development/staging sites — remember to turn it off before going live. Works independently of WordPress\'s own "Search engine visibility" setting (Settings → Reading) — turning one off does not turn off the other.', 'acez-seo' ) . '

'; submit_button(); $this->ui->form_close(); $this->ui->card_close(); } /** * @param array $settings */ private function render_language_card( array $settings ): void { $this->ui->card_open( __( 'Plugin language', 'acez-seo' ), 'global', '', 'plugin-language' ); echo '

' . esc_html__( 'Forces the language of the Acez SEO AI panel (settings, editor, Gutenberg sidebar) independently of WordPress\'s own language. Leave "Automatically" for the plugin to follow the site\'s language.', 'acez-seo' ) . '

'; $this->ui->form_open( 'plugin_language' ); echo ''; echo '
' . esc_html__( 'Force language', 'acez-seo' ) . ''; // The option stays selectable on purpose: a disabled
'; submit_button(); $this->ui->form_close(); $this->ui->card_close(); } }