403 ) ); } check_admin_referer( 'ajaco_reset' ); $options = array( 'ajaco_markdown_enabled', 'ajaco_content_signals_enabled', 'ajaco_api_catalog_enabled', 'ajaco_mcp_server_card_enabled', 'ajaco_agent_skills_index_enabled', 'ajaco_webmcp_enabled', 'ajaco_json_ld_enabled', 'ajaco_openapi_enabled', 'ajaco_indexnow_enabled', 'ajaco_llms_txt_enabled', 'ajaco_ai_bot_rules_enabled', 'ajaco_auth_md_enabled', 'ajaco_ai_bot_policy', 'ajaco_content_signal_prefs', 'ajaco_indexnow_key', // The stored self-scan — reset must not leave a stale score behind. 'ajaco_last_scan', // The llms.txt curation config — sections, intro, custom markdown. 'ajaco_llms_config', ); foreach ( $options as $option ) { delete_option( $option ); } // Deliberately NOT deleted here: the per-post `_ajaco_llms_exclude` and // `_ajaco_llms_summary` meta. Those are content an author wrote on their // own posts, not plugin settings — Reset clears settings, and only // uninstall.php removes user content. Wiping summaries from a whole site // because someone clicked "Reset to Defaults" would be unrecoverable. // Flush cached endpoint outputs so the next request reflects the reset state. delete_transient( 'ajaco_openapi_cache' ); delete_transient( 'ajaco_llms_txt_cache' ); delete_transient( 'ajaco_llms_full_txt_cache' ); // One-shot notice flag — consumed on the next settings page render so a // browser refresh doesn't show the notice repeatedly. set_transient( 'ajaco_reset_notice', 1, 60 ); wp_safe_redirect( settings_page_url() ); exit; } /** * Show a success notice after a reset. Uses the `settings-error` class so the * existing JS notice-mover relocates it to below the Save button, matching * the standard "Settings saved." treatment. Consumed once via transient so a * page refresh doesn't keep showing it. * * @return void */ function maybe_show_reset_notice(): void { $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; // Screen id depends on the parent menu — match the page slug instead of // hardcoding the pre-2.0 'settings_page_' prefix. if ( ! $screen || false === strpos( (string) $screen->id, 'aj-agent-crawl-optimizer' ) ) { return; } if ( ! get_transient( 'ajaco_reset_notice' ) ) { return; } delete_transient( 'ajaco_reset_notice' ); ?>