sections, $parent->args, $parent->extra_tabs);
$this->field = $field;
$this->value = $value;
//$this->render();
}//function
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 1.0.0
*/
function render(){
// No errors please
$defaults = array(
'units' => '',
'mode' => 'padding',
'top' => true,
'bottom' => true,
'left' => true,
'right' => true,
'units_extended' => false,
);
$this->field = wp_parse_args( $this->field, $defaults );
$defaults = array(
'top'=>'',
'right'=>'',
'bottom'=>'',
'left'=>'',
'mode'=>'padding',
'units'=>'px',
);
$this->value = wp_parse_args( $this->value, $defaults );
if ( !empty( $this->field['units'] ) ) {
$this->value['units'] = $this->field['units'];
}
if ( !in_array($this->value['units'], array( '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px' ) ) ) {
if ( !empty( $this->field['units'] ) && in_array($this->value['units'], array( '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px' ) ) ) {
$this->value['units'] = $this->field['units'];
}
}
if ( $this->field['mode'] !== "margin" && $this->field['mode'] !== "padding" ) {
$mode = "";
}
if ( !empty( $this->field['mode'] ) ) {
$this->field['mode'] = $this->field['mode']."-";
}
$oldval = $this->value;
$this->value = array();
foreach ($oldval as $k=>$v) {
if ($k == "units") {
continue;
}
if (strpos($k, $this->field['mode']) === false) {
$this->value[$k] = str_replace($oldval['units'], "", $v);
} else {
$this->value[str_replace($this->field['mode'].'-', "", $k)] = str_replace($oldval['units'], "", $v);
}
}
$defaults = array(
'top'=>'',
'right'=>'',
'bottom'=>'',
'left'=>'',
'units'=>'',
);
$this->value = wp_parse_args( $this->value, $defaults );
/**
Top
**/
if ($this->field['top'] === true):
if ( !empty( $this->value['top'] ) ) {
$this->value['top'] = filter_var($this->value['top'], FILTER_SANITIZE_NUMBER_INT);
$this->value['top'] = $this->value['top'].$this->value['units'];
}
echo '
';
endif;
/**
Right
**/
if ($this->field['right'] === true):
if ( !empty( $this->value['right'] ) ) {
$this->value['right'] = filter_var($this->value['right'], FILTER_SANITIZE_NUMBER_INT);
$this->value['right'] = $this->value['right'].$this->value['units'];
}
echo '
';
endif;
/**
Bottom
**/
if ($this->field['bottom'] === true):
if ( !empty( $this->value['bottom'] ) ) {
$this->value['bottom'] = filter_var($this->value['bottom'], FILTER_SANITIZE_NUMBER_INT);
if ($this->field['units'] !== false ) {
$this->value['bottom'] .= $this->value['units'];
}
$this->value['bottom'] = $this->value['bottom'].$this->value['units'];
}
echo '
';
endif;
/**
Left
**/
if ($this->field['left'] === true):
if ( !empty( $this->value['left'] ) ) {
$this->value['left'] = filter_var($this->value['left'], FILTER_SANITIZE_NUMBER_INT);
$this->value['left'] = $this->value['left'].$this->value['units'];
}
echo '
';
endif;
/**
Units
**/
if ( $this->field['units'] !== false ):
echo '';
echo '
';
endif;
}//function
/**
* Enqueue Function.
*
* If this field requires any scripts, or css define this function and register/enqueue the scripts/css
*
* @since ReduxFramework 1.0.0
*/
function enqueue(){
wp_enqueue_script( 'select2-js' );
wp_enqueue_style( 'select2-css' );
wp_enqueue_script(
'redux-field-spacing-js',
ReduxFramework::$_url.'inc/fields/spacing/field_spacing.min.js',
array('jquery', 'select2-js', 'jquery-numeric'),
time(),
true
);
wp_enqueue_style(
'redux-field-spacing-css',
ReduxFramework::$_url.'inc/fields/spacing/field_spacing.css',
time(),
true
);
}//function
public function output() {
if ( !isset($this->field['output']) || empty( $this->field['output'] ) ) {
return;
}
if ( !empty( $this->field['mode'] ) && !in_array($this->field['mode'], array( 'padding', 'absolute', 'margin', '' ) ) ) {
unset( $this->field['mode'] );
}
if ( !isset( $this->field['mode'] ) ) {
$this->field['mode'] = "padding";
}
if ( $this->field['mode'] == "absolute" ) {
unset( $this->field['mode'] );
}
//absolute, padding, margin
$keys = implode(",", $this->field['output']);
$style = '';
echo $style;
}
}//class