'yes', 'llms_txt_enabled' => 'yes', 'allow_ai_bots' => 'yes', 'verify_any' => 'no', 'block_impostor_checkout' => 'yes', ); } /** Non-checkbox settings. */ public static function text_defaults() { return array( 'mode' => 'monitor', // monitor | enforce. 'operators' => '', // Extra operators, one per line: https://origin | Name. ); } public static function all() { $saved = get_option( self::OPTION, array() ); return wp_parse_args( is_array( $saved ) ? $saved : array(), array_merge( self::defaults(), self::text_defaults() ) ); } public static function get( $key ) { $all = self::all(); return isset( $all[ $key ] ) ? $all[ $key ] : null; } public static function get_text( $key ) { return (string) self::get( $key ); } public static function on( $key ) { return 'yes' === self::get( $key ); } public static function save( array $values ) { $clean = array(); foreach ( self::defaults() as $key => $default ) { $clean[ $key ] = ( isset( $values[ $key ] ) && 'yes' === $values[ $key ] ) ? 'yes' : 'no'; } $clean['mode'] = ( isset( $values['mode'] ) && 'enforce' === $values['mode'] ) ? 'enforce' : 'monitor'; $lines = array(); foreach ( preg_split( '/[\r\n]+/', isset( $values['operators'] ) ? (string) $values['operators'] : '' ) as $line ) { $line = sanitize_text_field( $line ); if ( '' !== $line ) { $lines[] = $line; } } $clean['operators'] = implode( "\n", array_slice( $lines, 0, 50 ) ); update_option( self::OPTION, $clean ); } }