options = get_option( 'ast_robots_txt_options' ); } public function add_robots_txt_menu() { add_submenu_page( 'advanced-seo-toolkit', esc_html__( 'Robots.txt Editor', 'advanced-seo-toolkit' ), esc_html__( 'Robots.txt', 'advanced-seo-toolkit' ), 'manage_options', 'ast-robots-txt', array( $this, 'render_robots_txt_page' ) ); } public function register_robots_txt_settings() { register_setting( 'ast_robots_txt_options', 'ast_robots_txt_options', array( $this, 'sanitize_robots_txt_options' ) ); add_settings_section( 'ast_robots_txt_main', esc_html__( 'Robots.txt Settings', 'advanced-seo-toolkit' ), array( $this, 'robots_txt_section_callback' ), 'ast-robots-txt' ); add_settings_field( 'ast_robots_txt_content', esc_html__( 'Robots.txt Content', 'advanced-seo-toolkit' ), array( $this, 'robots_txt_content_callback' ), 'ast-robots-txt', 'ast_robots_txt_main' ); } public function sanitize_robots_txt_options( $input ) { $sanitized_input = array(); if ( isset( $input['content'] ) ) { $sanitized_input['content'] = wp_kses_post( $input['content'] ); } return $sanitized_input; } public function robots_txt_section_callback() { echo '
' . esc_html__( 'Customize your robots.txt file content here. Be careful as incorrect settings can affect your site\'s search engine visibility.', 'advanced-seo-toolkit' ) . '
'; } public function robots_txt_content_callback() { $content = isset( $this->options['content'] ) ? $this->options['content'] : $this->get_default_robots_txt(); echo ''; } public function render_robots_txt_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } ?>