field,
array(
'top_icon' => '',
'left_icon' => '',
'bottom_icon' => '',
'right_icon' => '',
'all_icon' => '',
'top_placeholder' => esc_html__( 'top', 'darkify' ),
'right_placeholder' => esc_html__( 'right', 'darkify' ),
'bottom_placeholder' => esc_html__( 'bottom', 'darkify' ),
'left_placeholder' => esc_html__( 'left', 'darkify' ),
'all_placeholder' => esc_html__( 'all', 'darkify' ),
'top' => true,
'left' => true,
'bottom' => true,
'right' => true,
'unit' => true,
'show_units' => true,
'all' => false,
'units' => array( 'px', '%', 'em' ),
)
);
$default_values = array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
'all' => '',
'unit' => 'px',
);
$value = wp_parse_args( $this->value, $default_values );
$unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : '';
$is_unit = ( ! empty( $unit ) ) ? ' darkify--is-unit' : '';
echo wp_kses_post( $this->field_before() );
echo '
';
echo wp_kses_post( $this->field_after() );
}
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';
if ( $mode === 'border-radius' || $mode === 'radius' ) {
$top = 'border-top-left-radius';
$right = 'border-top-right-radius';
$bottom = 'border-bottom-right-radius';
$left = 'border-bottom-left-radius';
} elseif ( $mode === 'relative' || $mode === 'absolute' || $mode === 'none' ) {
$top = 'top';
$right = 'right';
$bottom = 'bottom';
$left = 'left';
} else {
$top = $mode . '-top';
$right = $mode . '-right';
$bottom = $mode . '-bottom';
$left = $mode . '-left';
}
if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && $this->value['all'] !== '' ) {
$output = $element . '{';
$output .= $top . ':' . $this->value['all'] . $unit . $important . ';';
$output .= $right . ':' . $this->value['all'] . $unit . $important . ';';
$output .= $bottom . ':' . $this->value['all'] . $unit . $important . ';';
$output .= $left . ':' . $this->value['all'] . $unit . $important . ';';
$output .= '}';
} else {
$top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $top . ':' . $this->value['top'] . $unit . $important . ';' : '';
$right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $right . ':' . $this->value['right'] . $unit . $important . ';' : '';
$bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $bottom . ':' . $this->value['bottom'] . $unit . $important . ';' : '';
$left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $left . ':' . $this->value['left'] . $unit . $important . ';' : '';
if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' ) {
$output = $element . '{' . $top . $right . $bottom . $left . '}';
}
}
$this->parent->output_css .= $output;
return $output;
}
}
}