placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; $this->extras = isset( $args['extras'] ) ? $args['extras'] : array(); $this->required = isset( $args['required'] ) ? $args['required'] : array(); $this->input_attrs = wp_parse_args( isset( $args['input_attrs'] ) ? $args['input_attrs'] : array(), array( 'min' => 0, 'max' => 100, 'step' => 0.1 ) ); if ( ! isset( $this->extras['id'] ) ) { $this->extras['id'] = $id; } } public function to_json() { parent::to_json(); $this->json['placeholder'] = $this->placeholder; $this->json['extras'] = $this->extras; $this->json['required'] = $this->required; } public function enqueue() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'customize-unit-control', esc_url( get_theme_file_uri( "/assets/js/customize-unit-control{$suffix}.js" ) ), array( 'jquery' ), beetan_assets_version( get_theme_file_uri( "/assets/js/customize-unit-control{$suffix}.js" ) ), true ); wp_enqueue_style( 'customize-unit-control', esc_url( get_theme_file_uri( "/assets/css/customize-unit-control{$suffix}.css" ) ), array(), beetan_assets_version( get_theme_file_uri( "/assets/css/customize-unit-control{$suffix}.css" ) ) ); } private function parse_value( $value ) { $expression = '/(?P[0-9\.]+)(?P%|r?em|px)\b/i'; preg_match( $expression, $value, $matches ); return $matches; } protected function render_content() { $values = $this->parse_value( $this->value() ); $unit = $values['unit']; $type = $values['type']; ?>