field, array( 'lg_desktop_icon' => '', 'desktop_icon' => '', 'tablet_icon' => '', 'mobile_landscape_icon' => '', 'mobile_icon' => '', 'all_icon' => '', 'lg_desktop_placeholder' => esc_html__( 'Large Desktop', 'smart-post-show' ), 'desktop_placeholder' => esc_html__( 'Desktop', 'smart-post-show' ), 'tablet_placeholder' => esc_html__( 'Tablet', 'smart-post-show' ), 'mobile_landscape_placeholder' => esc_html__( 'Mobile Landscape', 'smart-post-show' ), 'mobile_placeholder' => esc_html__( 'Mobile', 'smart-post-show' ), 'all_placeholder' => esc_html__( 'all', 'smart-post-show' ), 'lg_desktop' => true, 'desktop' => true, 'tablet' => true, 'mobile_landscape' => true, 'mobile' => true, 'min' => '0', 'unit' => false, 'all' => false, 'units' => array( 'px', '%', 'em' ), ) ); $default_values = array( 'lg_desktop' => '5', 'desktop' => '4', 'tablet' => '3', 'mobile_landscape' => '2', 'mobile' => '1', 'min' => '', 'all' => '', 'unit' => 'px', ); // $value = wp_parse_args( $this->value, $default_values ); $value = wp_parse_args( $this->value, $default_values ); $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : ''; $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : ''; echo $this->field_before(); echo '
'; $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : ''; if ( ! empty( $args['all'] ) ) { $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : ''; echo '
'; echo ( ! empty( $args['all_icon'] ) ) ? '' . $args['all_icon'] . '' : ''; echo ''; echo ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? '' . $args['units'][0] . '' : ''; echo '
'; } else { $properties = array(); foreach ( array( 'lg_desktop', 'desktop', 'tablet', 'mobile_landscape', 'mobile' ) as $prop ) { if ( ! empty( $args[ $prop ] ) ) { $properties[] = $prop; } } $properties = ( $properties === array( 'tablet', 'mobile' ) ) ? array_reverse( $properties ) : $properties; foreach ( $properties as $property ) { $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : ''; echo '
'; echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '' . $args[ $property . '_icon' ] . '' : ''; echo ''; echo ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? '' . $args['units'][0] . '' : ''; echo '
'; } } if ( ! empty( $args['unit'] ) && count( $args['units'] ) > 1 ) { echo '
'; echo ''; echo '
'; } echo '
'; echo $this->field_after(); } /** * The output function. * * @return void */ public function output() { $output = ''; $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output']; $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : ''; $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px'; $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding'; $mode = ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) ? '' : $mode; $mode = ( ! empty( $mode ) ) ? $mode . '-' : ''; if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) { $output = $element . '{'; $output .= $mode . 'lg_desktop:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'desktop:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'tablet:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'mobile_landscape:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'mobile:' . $this->value['all'] . $unit . $important . ';'; $output .= '}'; } else { $lg_desktop = ( isset( $this->value['lg_desktop'] ) && $this->value['lg_desktop'] !== '' ) ? $mode . 'lg_desktop:' . $this->value['lg_desktop'] . $unit . $important . ';' : ''; $desktop = ( isset( $this->value['desktop'] ) && $this->value['desktop'] !== '' ) ? $mode . 'desktop:' . $this->value['desktop'] . $unit . $important . ';' : ''; $tablet = ( isset( $this->value['tablet'] ) && $this->value['tablet'] !== '' ) ? $mode . 'tablet:' . $this->value['tablet'] . $unit . $important . ';' : ''; $mobile_landscape = ( isset( $this->value['mobile_landscape'] ) && $this->value['mobile_landscape'] !== '' ) ? $mode . 'mobile_landscape:' . $this->value['mobile_landscape'] . $unit . $important . ';' : ''; $mobile = ( isset( $this->value['mobile'] ) && $this->value['mobile'] !== '' ) ? $mode . 'mobile:' . $this->value['mobile'] . $unit . $important . ';' : ''; if ( $lg_desktop !== '' || $desktop !== '' || $tablet !== '' || $mobile_landscape !== '' || $mobile !== '' ) { $output = $element . '{' . $lg_desktop . $desktop . $tablet . $mobile_landscape . $mobile . '}'; } } $this->parent->output_css .= $output; return $output; } } }