option_name, [ $this, 'sanitize_settings' ] ); add_settings_section( 'agentmark_main_section', __( 'General Settings', 'agentmark' ), null, 'agentmark' ); add_settings_field( 'enabled_post_types', __( 'Enabled Post Types', 'agentmark' ), [ $this, 'render_post_types_field' ], 'agentmark', 'agentmark_main_section' ); add_settings_field( 'enable_front_matter', __( 'Enable YAML Front Matter', 'agentmark' ), [ $this, 'render_checkbox_field' ], 'agentmark', 'agentmark_main_section', [ 'label_for' => 'enable_front_matter' ] ); add_settings_field( 'enable_llms_txt', __( 'Enable llms.txt', 'agentmark' ), [ $this, 'render_checkbox_field' ], 'agentmark', 'agentmark_main_section', [ 'label_for' => 'enable_llms_txt' ] ); add_settings_field( 'site_description', __( 'Site Description (for llms.txt)', 'agentmark' ), [ $this, 'render_text_field' ], 'agentmark', 'agentmark_main_section', [ 'label_for' => 'site_description' ] ); add_settings_field( 'ai_guidelines', __( 'AI Guidelines (for llms.txt)', 'agentmark' ), [ $this, 'render_text_field' ], 'agentmark', 'agentmark_main_section', [ 'label_for' => 'ai_guidelines' ] ); } public function render_post_types_field() { $options = $this->get_options(); $enabled = isset( $options['enabled_post_types'] ) ? $options['enabled_post_types'] : [ 'post', 'page' ]; $post_types = get_post_types( [ 'public' => true ], 'objects' ); foreach ( $post_types as $type ) { if ( in_array( $type->name, [ 'attachment' ] ) ) continue; printf( '
', esc_attr( $this->option_name ), esc_attr( $type->name ), checked( in_array( $type->name, $enabled ), true, false ), esc_html( $type->label ) ); } } public function render_checkbox_field( $args ) { $options = $this->get_options(); $id = $args['label_for']; $value = isset( $options[$id] ) ? $options[$id] : false; printf( '', esc_attr( $id ), esc_attr( $this->option_name ), esc_attr( $id ), checked( $value, 1, false ) ); } public function render_text_field( $args ) { $options = $this->get_options(); $id = $args['label_for']; $value = isset( $options[$id] ) ? $options[$id] : ''; printf( '', esc_attr( $id ), esc_attr( $this->option_name ), esc_attr( $id ), esc_textarea( $value ) ); } public function render_main_page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'agentmark' ) ); } $active_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'settings'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reading tab for UI display only. ?>

render_stats_content(); } else { $this->render_settings_content(); } ?>
get_stats(); ?>

$count ) : ?>

option_name, [] ); } public function get_allowed_post_types() { $options = $this->get_options(); $allowed_types = isset( $options['enabled_post_types'] ) ? $options['enabled_post_types'] : [ 'post', 'page' ]; return apply_filters( 'agentmark_allowed_post_types', $allowed_types ); } public function is_front_matter_enabled() { $options = $this->get_options(); return ! empty( $options['enable_front_matter'] ); } public function is_llms_txt_enabled() { $options = $this->get_options(); return ! empty( $options['enable_llms_txt'] ); } public function get_site_description() { $options = $this->get_options(); return ( isset( $options['site_description'] ) && ! empty( $options['site_description'] ) ) ? $options['site_description'] : get_bloginfo( 'description' ); } public function get_ai_guidelines() { $options = $this->get_options(); if ( isset( $options['ai_guidelines'] ) && ! empty( $options['ai_guidelines'] ) ) { return $options['ai_guidelines']; } return "- Prefer Markdown versions of pages\n- Use canonical URLs for citation\n- Ignore comment sections"; } }