enter center' => esc_html__( 'Center Center', 'kirki' ), 'center bottom' => esc_html__( 'Center Bottom', 'kirki' ), 'right top' => esc_html__( 'Right Top', 'kirki' ), 'right center' => esc_html__( 'Right Center', 'kirki' ), 'right bottom' => esc_html__( 'Right Bottom', 'kirki' ), ], 'required' => array_merge( $args['required'], [ [ 'setting' => $args['settings'], 'operator' => '!=', 'value' => '', 'choice' => 'background-image', ], ] ), ], $args ) ); /** * Background size. */ new Kirki\Field\Radio_Buttonset( wp_parse_args( [ 'settings' => $args['settings'] . '[background-size]', 'label' => '', 'description' => esc_html__( 'Background Size', 'kirki' ), 'default' => isset( $args['default']['background-size'] ) ? $args['default']['background-size'] : '', 'section' => $args['section'], 'choices' => [ 'cover' => esc_html__( 'Cover', 'kirki' ), 'contain' => esc_html__( 'Contain', 'kirki' ), 'auto' => esc_html__( 'Auto', 'kirki' ), ], 'required' => array_merge( $args['required'], [ [ 'setting' => $args['settings'], 'operator' => '!=', 'value' => '', 'choice' => 'background-image', ], ] ), ], $args ) ); /** * Background attachment. */ new Kirki\Field\Radio_Buttonset( wp_parse_args( [ 'type' => 'kirki-radio-buttonset', 'settings' => $args['settings'] . '[background-attachment]', 'description' => esc_html__( 'Background Attachment', 'kirki' ), 'label' => '', 'default' => isset( $args['default']['background-attachment'] ) ? $args['default']['background-attachment'] : '', 'section' => $args['section'], 'choices' => [ 'scroll' => esc_html__( 'Scroll', 'kirki' ), 'fixed' => esc_html__( 'Fixed', 'kirki' ), ], 'required' => array_merge( $args['required'], [ [ 'setting' => $args['settings'], 'operator' => '!=', 'value' => '', 'choice' => 'background-image', ], ] ), ], $args ) ); add_action( 'customize_preview_init', [ $this, 'enqueue_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Sets the $sanitize_callback * * @access protected * @since 1.0 * @return void */ protected function set_sanitize_callback() { // If a custom sanitize_callback has been defined, // then we don't need to proceed any further. if ( ! empty( $this->sanitize_callback ) ) { return; } $this->sanitize_callback = [ '\Kirki\Field\Background', 'sanitize' ]; } /** * Sanitizes background controls * * @static * @access public * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } $sanitized_value = [ 'background-color' => '', 'background-image' => '', 'background-repeat' => '', 'background-position' => '', 'background-size' => '', 'background-attachment' => '', ]; if ( isset( $value['background-color'] ) ) { $sanitized_value['background-color'] = \Kirki\Field\Color::sanitize( $value['background-color'] ); } if ( isset( $value['background-image'] ) ) { $sanitized_value['background-image'] = esc_url_raw( $value['background-image'] ); } if ( isset( $value['background-repeat'] ) ) { $sanitized_value['background-repeat'] = in_array( $value['background-repeat'], [ 'no-repeat', 'repeat', 'repeat-x', 'repeat-y', ], true ) ? $value['background-repeat'] : ''; } if ( isset( $value['background-position'] ) ) { $sanitized_value['background-position'] = in_array( $value['background-position'], [ 'left top', 'left center', 'left bottom', 'center top', 'center center', 'center bottom', 'right top', 'right center', 'right bottom', ], true ) ? $value['background-position'] : ''; } if ( isset( $value['background-size'] ) ) { $sanitized_value['background-size'] = in_array( $value['background-size'], [ 'cover', 'contain', 'auto', ], true ) ? $value['background-size'] : ''; } if ( isset( $value['background-attachment'] ) ) { $sanitized_value['background-attachment'] = in_array( $value['background-attachment'], [ 'scroll', 'fixed', ], true ) ? $value['background-attachment'] : ''; } return $sanitized_value; } /** * Sets the $js_vars * * @access protected * @since 1.0 * @return void */ protected function set_js_vars() { // Typecast to array. $this->js_vars = (array) $this->js_vars; // Check if transport is set to auto. // If not, then skip the auto-calculations and exit early. if ( 'auto' !== $this->transport ) { return; } // Set transport to refresh initially. // Serves as a fallback in case we failt to auto-calculate js_vars. $this->transport = 'refresh'; $js_vars = []; // Try to auto-generate js_vars. // First we need to check if js_vars are empty, and that output is not empty. if ( empty( $this->js_vars ) && ! empty( $this->output ) ) { // Start going through each item in the $output array. foreach ( $this->output as $output ) { // If 'element' is not defined, skip this. if ( ! isset( $output['element'] ) ) { continue; } if ( is_array( $output['element'] ) ) { $output['element'] = implode( ',', $output['element'] ); } // If there's a sanitize_callback defined, skip this. if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) { continue; } // If we got this far, it's safe to add this. $js_vars[] = $output; } // Did we manage to get all the items from 'output'? // If not, then we're missing something so don't add this. if ( count( $js_vars ) !== count( $this->output ) ) { return; } $this->js_vars = $js_vars; $this->transport = 'postMessage'; } } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_scripts() { wp_enqueue_script( 'kirki-typography', URL::get_from_path( __DIR__ ) . '/script.js', [ 'wp-hooks' ], '1.0', true ); } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-background'] = '\Kirki\Field\CSS\Background'; return $classnames; } }
Warning: session_start(): Session cannot be started after headers have already been sent in /htdocs/wp-content/plugins/shipping-rate-by-cities/shipping_rate_by_cities.php on line 106
Archives des En vedette - SOUTRAMARKET