fields = $fields;
$this->attr = $attr;
$this->label = $args['label'];
parent::__construct( $manager, $id, $args );
}
/**
* enqueue css and scrpts
*
* @since 1.2.8
*/
public function enqueue() {
wp_enqueue_style('appzend-cssbox', get_template_directory_uri() . '/inc/custom-controller/cssbox/css/cssbox.css', array());
wp_enqueue_script('appzend-cssbox', get_template_directory_uri().'/inc/custom-controller/cssbox/js/cssbox.js', array( 'jquery', 'customize-controls' ), '', true);
}
/**
* Renders the control wrapper and calls $this->render_content() for the internals.
*
* @see WP_Customize_Control::render()
*/
protected function render() {
$id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
$class = 'customize-control has-switchers customize-control-' . $this->type;
?>
render_content(); ?>
value() ) && ! empty( $this->value() ) ) {
$values = json_encode( $this->value() );
} else {
$values = $this->value();
}
?>
link(); ?> class="cssbox-collection-value" value=""/>
array(
'icon' => 'dashicons-laptop',
),
'tablet' => array(
'icon' => 'dashicons-tablet',
),
'mobile' => array(
'icon' => 'dashicons-smartphone ',
),
);
$default_fields = array(
'top' => true,
'right' => true,
'bottom' => true,
'left' => true,
);
$box_fields_attr = ! empty( $this->fields ) ? $this->fields : $default_fields;
$attr = $this->attr;
if ( is_array( $this->value() ) && ! empty( $this->value() ) ) {
$values = $this->value();
} else {
$values = json_decode( $this->value(), true );
}
$min = isset( $attr['min'] ) ? $attr['min'] : 0;
$max = isset( $attr['max'] ) ? $attr['max'] : 1000;
$step = isset( $attr['step'] ) ? $attr['step'] : 1;
$link = isset( $attr['link'] ) ? $attr['link'] : 1;
$devices = isset( $attr['devices'] ) ? $attr['devices'] : $devices;
$link_text = isset( $attr['link_text'] ) ? $attr['link_text'] : esc_html__( 'Link', 'appzend' );
?>
" . esc_html( $this->label ) . '';
?>
description ) {
?>
description ); ?>
1 ) {
?>
$device_details ) {
if ( $i == 1 ) {
$active = ' active';
} else {
$active = '';
}
?>
-
$device_details ) {
if ( $i == 1 ) {
$active = ' active';
} else {
$active = '';
}
echo '
register_control_type('AppZend_Cssbox');
}
if ( ! function_exists( 'appzend_sanitize_field_default_css_box' ) ) :
/**
* Sanitize Default Css Box
*
* @since appzend 1.0.0
*
* @param $input
* @return array
*
*/
function appzend_sanitize_field_default_css_box( $input, $AppZend_setting ) {
$input_decoded = json_decode( $input, true );
$output = array();
if ( ! empty( $input_decoded ) ) {
foreach ( $input_decoded as $device_id => $device_details ) {
foreach ( $device_details as $key => $value ) {
if ( $key == 'cssbox_link' ) {
$output[ $device_id ][ $key ] =( ( isset( $value ) && true === $value ) ? true : false );
} else {
$output[ $device_id ][ $key ] = !empty( $value ) ? intval( $value ) : '';
}
}
}
return json_encode( $output );
}
return $input;
}
endif;
if ( ! function_exists( 'appzend_not_empty' ) ) {
/**
* appzend_not_empty
* @param $var
* @return bool
*/
function appzend_not_empty( $var ) {
if ( trim( $var ) === '' ) {
return false;
}
return true;
}
}
if ( ! function_exists( 'appzend_cssbox_values_inline' ) ) {
/**
* appzend_cssbox_values_inline description
* @param array $position_collection
* @param string $device
* @return string
*/
function appzend_cssbox_values_inline( $position_collection, $device ) {
$inline_css = '';
if ( ! is_array( $position_collection ) ) {
return false;
}
foreach ( $position_collection as $device_data => $value ) {
switch ( $device_data ) {
case 'desktop':
if ( 'desktop' == $device ) {
$top = ( isset( $value['top'] ) && appzend_not_empty( $value['top'] ) ) ? $value['top'] : '';
$right = ( isset( $value['right'] ) && appzend_not_empty( $value['right'] ) ) ? $value['right'] : '';
$bottom = ( isset( $value['bottom'] ) && appzend_not_empty( $value['bottom'] ) ) ? $value['bottom'] : '';
$left = ( isset( $value['left'] ) && appzend_not_empty( $value['left'] ) ) ? $value['left'] : '';
if ( appzend_not_empty( $top ) || appzend_not_empty( $right ) || appzend_not_empty( $bottom ) || appzend_not_empty( $left ) ) {
$top = ( appzend_not_empty( $top ) ) ? $top . 'px' : 0;
$right = ( appzend_not_empty( $right ) ) ? $right . 'px' : 0;
$bottom = ( appzend_not_empty( $bottom ) ) ? $bottom . 'px' : 0;
$left = ( appzend_not_empty( $left ) ) ? $left . 'px' : 0;
$inline_css = $top . ' ' . $right . ' ' . $bottom . ' ' . $left;
} else {
$inline_css = '0';
}
}
break;
case 'tablet':
if ( 'tablet' == $device ) {
$top = ( isset( $value['top'] ) && appzend_not_empty( $value['top'] ) ) ? $value['top'] : '';
$right = ( isset( $value['right'] ) && appzend_not_empty( $value['right'] ) ) ? $value['right'] : '';
$bottom = ( isset( $value['bottom'] ) && appzend_not_empty( $value['bottom'] ) ) ? $value['bottom'] : '';
$left = ( isset( $value['left'] ) && appzend_not_empty( $value['left'] ) ) ? $value['left'] : '';
if ( appzend_not_empty( $top ) || appzend_not_empty( $right ) || appzend_not_empty( $bottom ) || appzend_not_empty( $left ) ) {
$top = ( appzend_not_empty( $top ) ) ? $top . 'px' : 0;
$right = ( appzend_not_empty( $right ) ) ? $right . 'px' : 0;
$bottom = ( appzend_not_empty( $bottom ) ) ? $bottom . 'px' : 0;
$left = ( appzend_not_empty( $left ) ) ? $left . 'px' : 0;
$inline_css = $top . ' ' . $right . ' ' . $bottom . ' ' . $left;
} else {
$inline_css = '0';
}
}
break;
case 'mobile':
if ( 'mobile' == $device ) {
$top = ( isset( $value['top'] ) && appzend_not_empty( $value['top'] ) ) ? $value['top'] : '';
$right = ( isset( $value['right'] ) && appzend_not_empty( $value['right'] ) ) ? $value['right'] : '';
$bottom = ( isset( $value['bottom'] ) && appzend_not_empty( $value['bottom'] ) ) ? $value['bottom'] : '';
$left = ( isset( $value['left'] ) && appzend_not_empty( $value['left'] ) ) ? $value['left'] : '';
if ( appzend_not_empty( $top ) || appzend_not_empty( $right ) || appzend_not_empty( $bottom ) || appzend_not_empty( $left ) ) {
$top = ( appzend_not_empty( $top ) ) ? $top . 'px' : 0;
$right = ( appzend_not_empty( $right ) ) ? $right . 'px' : 0;
$bottom = ( appzend_not_empty( $bottom ) ) ? $bottom . 'px' : 0;
$left = ( appzend_not_empty( $left ) ) ? $left . 'px' : 0;
$inline_css = $top . ' ' . $right . ' ' . $bottom . ' ' . $left;
} else {
$inline_css = '0';
}
}
break;
default:
break;
}
}
return $inline_css;
}
}