4079 | | if ( 'background_repeat' === $setting->id ) { |
4080 | | if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ) ) ) { |
4081 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background repeat.' ) ); |
4082 | | } |
4083 | | } elseif ( 'background_attachment' === $setting->id ) { |
4084 | | if ( ! in_array( $value, array( 'fixed', 'scroll' ) ) ) { |
4085 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background attachment.' ) ); |
4086 | | } |
4087 | | } elseif ( 'background_position_x' === $setting->id ) { |
4088 | | if ( ! in_array( $value, array( 'left', 'center', 'right' ), true ) ) { |
4089 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background position X.' ) ); |
4090 | | } |
4091 | | } elseif ( 'background_position_y' === $setting->id ) { |
4092 | | if ( ! in_array( $value, array( 'top', 'center', 'bottom' ), true ) ) { |
4093 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background position Y.' ) ); |
4094 | | } |
4095 | | } elseif ( 'background_size' === $setting->id ) { |
4096 | | if ( ! in_array( $value, array( 'auto', 'contain', 'cover' ), true ) ) { |
4097 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); |
4098 | | } |
4099 | | } elseif ( 'background_preset' === $setting->id ) { |
4100 | | if ( ! in_array( $value, array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) { |
4101 | | return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); |
4102 | | } |
4103 | | } elseif ( 'background_image' === $setting->id || 'background_image_thumb' === $setting->id ) { |
4104 | | $value = empty( $value ) ? '' : esc_url_raw( $value ); |
4105 | | } else { |
4106 | | return new WP_Error( 'unrecognized_setting', __( 'Unrecognized background setting.' ) ); |
| 4079 | switch( $setting->id ) { |
| 4080 | case 'background_repeat': |
| 4081 | if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ) ) ) { |
| 4082 | return new WP_Error( 'invalid_value', __( 'Invalid value for background repeat.' ) ); |
| 4083 | } |
| 4084 | break; |
| 4085 | case 'background_attachment': |
| 4086 | if ( ! in_array( $value, array( 'fixed', 'scroll' ) ) ) { |
| 4087 | return new WP_Error( 'invalid_value', __( 'Invalid value for background attachment.' ) ); |
| 4088 | } |
| 4089 | break; |
| 4090 | case 'background_position_x': |
| 4091 | if ( ! in_array( $value, array( 'left', 'center', 'right' ), true ) ) { |
| 4092 | return new WP_Error( 'invalid_value', __( 'Invalid value for background position X.' ) ); |
| 4093 | } |
| 4094 | break; |
| 4095 | case 'background_position_y': |
| 4096 | if ( ! in_array( $value, array( 'top', 'center', 'bottom' ), true ) ) { |
| 4097 | return new WP_Error( 'invalid_value', __( 'Invalid value for background position Y.' ) ); |
| 4098 | } |
| 4099 | break; |
| 4100 | case 'background_size': |
| 4101 | if ( ! in_array( $value, array( 'auto', 'contain', 'cover' ), true ) ) { |
| 4102 | return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); |
| 4103 | } |
| 4104 | break; |
| 4105 | case 'background_preset': |
| 4106 | if ( ! in_array( $value, array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) { |
| 4107 | return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) ); |
| 4108 | } |
| 4109 | break; |
| 4110 | case 'background_image': |
| 4111 | case 'background_image_thumb': |
| 4112 | $value = empty( $value ) ? '' : esc_url_raw( $value ); |
| 4113 | break; |
| 4114 | default: |
| 4115 | return new WP_Error( 'unrecognized_setting', __( 'Unrecognized background setting.' ) ); |
| 4116 | break; |