'boolean', 'sanitize_callback' => guard_sanitizer( $option, 'rest_sanitize_boolean' ), 'default' => false, ) ); } register_setting( 'ajaco_settings', 'ajaco_indexnow_key', array( 'type' => 'string', 'sanitize_callback' => guard_sanitizer( 'ajaco_indexnow_key', __NAMESPACE__ . '\\sanitize_indexnow_key' ), 'default' => '', ) ); // Array options in the `ajaco_settings` group are safe to register ONLY // because the settings page ALWAYS renders their fields (options.php // force-updates every registered option of a submitted group — an option // without form fields would be wiped on each Save). register_setting( 'ajaco_settings', 'ajaco_ai_bot_policy', array( 'type' => 'array', 'sanitize_callback' => guard_sanitizer( 'ajaco_ai_bot_policy', __NAMESPACE__ . '\\sanitize_ai_bot_policy' ), 'default' => array(), ) ); register_setting( 'ajaco_settings', 'ajaco_org_schema', array( 'type' => 'array', 'sanitize_callback' => guard_sanitizer( 'ajaco_org_schema', __NAMESPACE__ . '\\sanitize_org_schema' ), 'default' => array(), ) ); register_setting( 'ajaco_settings', 'ajaco_content_signal_prefs', array( 'type' => 'array', 'sanitize_callback' => guard_sanitizer( 'ajaco_content_signal_prefs', __NAMESPACE__ . '\\sanitize_content_signal_prefs' ), 'default' => array(), ) ); // The llms.txt curation config lives in its OWN group, saved from its own // screen. It must NOT join `ajaco_settings`: options.php force-updates every // registered option in a submitted group, so a shared group would let the // Settings screen (which renders no curation fields) wipe the whole config // on every save — and vice versa. register_setting( 'ajaco_llms_settings', 'ajaco_llms_config', array( 'type' => 'array', 'sanitize_callback' => guard_sanitizer( 'ajaco_llms_config', __NAMESPACE__ . '\\sanitize_llms_config' ), 'default' => array(), ) ); } /** * Sanitize the Organization schema details (`ajaco_org_schema`). * * @param mixed $value Raw option value. * @return array */ function sanitize_org_schema( $value ): array { if ( ! is_array( $value ) ) { return array(); } $text = static function ( string $key ) use ( $value ): string { return isset( $value[ $key ] ) ? sanitize_text_field( (string) $value[ $key ] ) : ''; }; $same_as = array(); $raw = isset( $value['same_as'] ) ? $value['same_as'] : ''; $lines = is_array( $raw ) ? $raw : preg_split( '/[\r\n,]+/', (string) $raw ); foreach ( (array) $lines as $line ) { $url = esc_url_raw( trim( (string) $line ), array( 'http', 'https' ) ); if ( '' !== $url && ! in_array( $url, $same_as, true ) ) { $same_as[] = $url; } } return array( 'same_as' => array_slice( $same_as, 0, 20 ), 'email' => isset( $value['email'] ) ? sanitize_email( (string) $value['email'] ) : '', 'phone' => $text( 'phone' ), 'contact_type' => $text( 'contact_type' ), 'street' => $text( 'street' ), 'locality' => $text( 'locality' ), 'region' => $text( 'region' ), 'postal' => $text( 'postal' ), 'country' => $text( 'country' ), ); } /** * Stored Organization details, normalised. * * @return array */ function org_schema_settings(): array { return sanitize_org_schema( get_option( 'ajaco_org_schema', array() ) ); }