'auto', 'styleSource' => 'inherit', 'resourceSelector' => 'hidden', 'layout' => 'list', ); $value = get_option( self::OPTION, array() ); return is_array( $value ) ? array_intersect_key( $value, $base ) + $base : $base; } public static function store( array $input ): bool|WP_Error { if ( ! current_user_can( 'manage_options' ) ) { return Services::error( 'rest_forbidden', 403 ); } $allowed = array( 'locale' => array( 'auto', 'hu', 'en', 'de' ), 'styleSource' => array( 'inherit', 'service' ), 'resourceSelector' => array( 'hidden', 'optional' ), 'layout' => array( 'list', 'grid' ), ); if ( array_keys( $input ) !== array_keys( $allowed ) && ( array_diff_key( $input, $allowed ) || array_diff_key( $allowed, $input ) ) ) { return Services::error( 'embed_parameters', 400 ); } foreach ( $allowed as $key => $values ) { if ( ! in_array( $input[ $key ], $values, true ) ) { return Services::error( 'embed_parameters', 400 ); } } update_option( self::OPTION, $input, false ); return true; } public function save(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Administrator permission is required.', 'waitlistize' ), '', array( 'response' => 403 ) ); } check_admin_referer( 'waitlistize_defaults' ); $input = wp_unslash( $_POST ); unset( $input['action'], $input['_wpnonce'], $input['_wp_http_referer'], $input['submit'] ); $result = self::store( $input ); if ( is_wp_error( $result ) ) { wp_die( esc_html( $result->get_error_message() ), '', array( 'response' => 400 ) ); } wp_safe_redirect( admin_url( 'admin.php?page=waitlistize-settings&saved=1' ) ); exit; } public function render(): void { $value = self::values(); ?>

array( __( 'Language', 'waitlistize' ), array( 'auto' => __( 'Account default', 'waitlistize' ), 'hu' => 'Magyar', 'en' => 'English', 'de' => 'Deutsch', ), ), 'styleSource' => array( __( 'Appearance', 'waitlistize' ), array( 'inherit' => __( 'WordPress theme', 'waitlistize' ), 'service' => __( 'Service accent color', 'waitlistize' ), ), ), 'resourceSelector' => array( __( 'Resource selector (display only)', 'waitlistize' ), array( 'hidden' => __( 'Hidden (backend default resource)', 'waitlistize' ), 'optional' => __( 'Optional', 'waitlistize' ), ), ), 'layout' => array( __( 'Layout', 'waitlistize' ), array( 'list' => __( 'List', 'waitlistize' ), 'grid' => __( 'Grid', 'waitlistize' ), ), ), ) as $key => $field ) { echo '

'; } submit_button( __( 'Save display defaults', 'waitlistize' ) ); ?>