first commit
This commit is contained in:
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/**
|
||||
* Add controls to customizer
|
||||
*
|
||||
*/
|
||||
if ( ! class_exists( 'HU_controls' ) ) :
|
||||
class HU_controls extends WP_Customize_Control {
|
||||
public $type;
|
||||
public $link;
|
||||
public $title;
|
||||
public $label;
|
||||
public $buttontext;
|
||||
public $settings;
|
||||
public $hr_after;
|
||||
public $notice;
|
||||
//number vars
|
||||
public $step;
|
||||
public $min;
|
||||
public $icon;
|
||||
|
||||
public $ubq_section;
|
||||
|
||||
static $enqueued_resources;
|
||||
|
||||
public function render_content() {
|
||||
do_action( '__before_setting_control' , $this -> id );
|
||||
|
||||
switch ( $this -> type) {
|
||||
case 'hr':
|
||||
echo '<hr class="czr-customizer-separator" />';
|
||||
break;
|
||||
|
||||
|
||||
case 'title' :
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<?php if (isset( $this->notice)) : ?>
|
||||
<i class="czr-notice"><?php echo $this -> notice ?></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
if ( empty( $this->choices ) )
|
||||
return;
|
||||
?>
|
||||
<?php if (!empty( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php $this -> hu_print_select_control( '' ) ?>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this -> notice ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'number':
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<span class="czr-number-label customize-control-title"><?php echo $this->label ?></span>
|
||||
<input <?php $this->link() ?> type="number" step="<?php echo $this-> step ?>" min="<?php echo $this-> min ?>" id="posts_per_page" value="<?php echo $this->value() ?>" class="czr-number-input small-text">
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this-> notice ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
case 'nimblecheck':
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( 'checkbox' === $this->type ) : ?>
|
||||
<?php
|
||||
printf('<div class="czr-check-label"><label><span class="customize-control-title">%1$s</span></label></div>',
|
||||
$this->label
|
||||
);
|
||||
?>
|
||||
<input <?php $this->link(); ?> type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php checked( $this->value() ); ?> />
|
||||
<?php elseif ( 'nimblecheck' === $this->type ) : ?>
|
||||
<div class="czr-control-nimblecheck">
|
||||
<?php
|
||||
printf('<div class="czr-check-label"><label><span class="customize-control-title">%1$s</span></label></div>',
|
||||
$this->label
|
||||
);
|
||||
?>
|
||||
<div class="nimblecheck-wrap">
|
||||
<input id="nimblecheck-<?php echo $this -> id; ?>" <?php $this->link(); ?> type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php checked( $this->value() ); ?> class="nimblecheck-input">
|
||||
<label for="nimblecheck-<?php echo $this -> id; ?>" class="nimblecheck-label">Switch</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this-> notice ?></span>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this-> notice; ?></span>
|
||||
<?php endif; ?>
|
||||
<textarea class="widefat" rows="3" cols="10" <?php $this->link(); ?>><?php echo esc_html( $this->value() ); ?></textarea>
|
||||
</label>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
case 'email':
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
printf('<label><span class="customize-control-title %1$s">%2$s</span><input type="text" value="%3$s" %4$s /></label>',
|
||||
! empty( $this -> icon) ? $this -> icon : '',
|
||||
$this->label,
|
||||
call_user_func( array( HU_utils_settings_map::$instance, 'hu_sanitize_' . $this -> type), $this->value() ),
|
||||
call_user_func( array( $this, 'get'.'_'.'link' ) )
|
||||
);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
global $wp_version;
|
||||
?>
|
||||
<?php if (isset( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<?php if ( ! empty( $this->label ) ) : ?>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $this->description ) ) : ?>
|
||||
<span class="description customize-control-description"><?php echo $this->description; ?></span>;;;
|
||||
<?php endif; ?>
|
||||
<?php if ( ! version_compare( $wp_version, '4.0', '>=' ) ) : ?>
|
||||
<input type="<?php echo esc_attr( $this->type ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />
|
||||
<?php else : ?>
|
||||
<input type="<?php echo esc_attr( $this->type ); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> />
|
||||
<?php endif; ?>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this-> notice; ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
break;
|
||||
}//end switch
|
||||
do_action( '__after_setting_control' , $this -> id );
|
||||
}//end function
|
||||
|
||||
|
||||
|
||||
|
||||
private function hu_print_select_control($class) {
|
||||
printf('<select %1$s class="%2$s">%3$s</select>',
|
||||
call_user_func( array( $this, 'get'.'_'.'link' ) ),
|
||||
$class,
|
||||
$this -> hu_get_select_options()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function hu_get_select_options() {
|
||||
$_options_html = '';
|
||||
switch ( $this -> id ) {
|
||||
default:
|
||||
foreach ( $this->choices as $value => $label ) {
|
||||
$_options_html .= sprintf('<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( $value ),
|
||||
selected( $this->value(), $value, false ),
|
||||
$label
|
||||
);
|
||||
}
|
||||
break;
|
||||
}//end switch
|
||||
return $_options_html;
|
||||
}//end of fn
|
||||
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles
|
||||
* fired by the parent Control class constructor
|
||||
*
|
||||
*/
|
||||
// public function enqueue() {
|
||||
// if ( ! empty( self::$enqueued_resources ) )
|
||||
// return;
|
||||
|
||||
// self::$enqueued_resources = true;
|
||||
|
||||
// wp_enqueue_script( 'wp-color-picker' );
|
||||
// wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
// wp_enqueue_style(
|
||||
// 'font-awesome',
|
||||
// sprintf('%1$s/assets/front/css/font-awesome.min.css', get_template_directory_uri() ),
|
||||
// array(),
|
||||
// HUEMAN_VER,
|
||||
// $media = 'all'
|
||||
// );
|
||||
|
||||
// //select2 stylesheet
|
||||
// //overriden by some specific style in theme-customzer-control.css
|
||||
// wp_enqueue_style(
|
||||
// 'select2-css',
|
||||
// sprintf('%1$s/assets/czr/css/lib/select2.min.css', get_template_directory_uri() ),
|
||||
// array( 'customize-controls' ),
|
||||
// HUEMAN_VER,
|
||||
// $media = 'all'
|
||||
// );
|
||||
// }
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
*
|
||||
* @Override
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
if ( is_array( $this->ubq_section ) && array_key_exists( 'section', $this->ubq_section ) )
|
||||
$this->json['ubq_section'] = $this->ubq_section;
|
||||
}
|
||||
}//end of class
|
||||
endif;
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
*/
|
||||
if ( class_exists('WP_Customize_Code_Editor_Control') && ! class_exists( 'HU_Customize_Code_Editor_Control' ) ) :
|
||||
class HU_Customize_Code_Editor_Control extends WP_Customize_Code_Editor_Control {
|
||||
|
||||
public $type = 'czr_code_editor';
|
||||
public $title;
|
||||
public $notice;
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::json()
|
||||
*
|
||||
* @return array Array of parameters passed to the JavaScript.
|
||||
*/
|
||||
public function json() {
|
||||
$json = parent::json();
|
||||
if ( is_array( $json ) ) {
|
||||
$json['title'] = !empty( $this -> title ) ? esc_html( $this -> title ) : '';
|
||||
$json['notice'] = !empty( $this -> notice ) ? $this -> notice : '';
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render a JS template for the content of the media control.
|
||||
*
|
||||
* @since 3.4.19
|
||||
* @package Customizr
|
||||
*
|
||||
* @Override
|
||||
* @see WP_Customize_Control::content_template()
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( data.title ) { #>
|
||||
<h3 class="czr-customizr-title">{{{ data.title }}}</h3>
|
||||
<# } #>
|
||||
<?php parent::content_template(); ?>
|
||||
<# if ( data.notice ) { #>
|
||||
<span class="czr-notice">{{{ data.notice }}}</span>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}//end class
|
||||
endif;
|
||||
?>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*
|
||||
*/
|
||||
if ( ! class_exists( 'HU_Customize_Color_Alpha_Control' ) ) :
|
||||
class HU_Customize_Color_Alpha_Control extends HU_controls {
|
||||
|
||||
public $type = 'wp_color_alpha';
|
||||
public $title;
|
||||
public $notice;
|
||||
|
||||
public $statuses;
|
||||
|
||||
public $mode = 'full';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::__construct()
|
||||
*
|
||||
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
|
||||
* @param string $id Control ID.
|
||||
* @param array $args Optional. Arguments to override class property defaults.
|
||||
*/
|
||||
public function __construct( $manager, $id, $args = array() ) {
|
||||
$this->statuses = array( '' => __('Default', 'hueman') );
|
||||
parent::__construct( $manager, $id, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @see WP_Customize_Control::json()
|
||||
*
|
||||
* @return array Array of parameters passed to the JavaScript.
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['statuses'] = $this->statuses;
|
||||
$this->json['defaultValue'] = $this->setting->default;
|
||||
$this->json['mode'] = $this->mode;
|
||||
$this->json['title'] = !empty( $this -> title ) ? esc_html( $this -> title ) : '';
|
||||
$this->json['notice'] = !empty( $this -> notice ) ? $this -> notice : '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<# var defaultValue = '#RRGGBB', defaultValueAttr = '',
|
||||
isHueSlider = data.mode === 'hue';
|
||||
if ( data.defaultValue && _.isString( data.defaultValue ) && ! isHueSlider ) {
|
||||
if ( '#' !== data.defaultValue.substring( 0, 1 ) ) {
|
||||
defaultValue = '#' + data.defaultValue;
|
||||
} else {
|
||||
defaultValue = data.defaultValue;
|
||||
}
|
||||
defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically.
|
||||
} #>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="customize-control-title">{{{ data.label }}}</span>
|
||||
<# } #>
|
||||
<# if ( data.description ) { #>
|
||||
<span class="description customize-control-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
<div class="customize-control-content">
|
||||
<label><span class="screen-reader-text">{{{ data.label }}}</span>
|
||||
<# if ( isHueSlider ) { #>
|
||||
<input data-alpha="true" class="color-picker-hue" type="text" data-type="hue" />
|
||||
<# } else { #>
|
||||
<input data-alpha="true" class="color-picker-hex" type="text" maxlength="7" placeholder="{{ defaultValue }}" {{ defaultValueAttr }} />
|
||||
<# } #>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}//end class
|
||||
endif;
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/*
|
||||
*/
|
||||
if ( class_exists('WP_Customize_Cropped_Image_Control') && ! class_exists( 'HU_Customize_Cropped_Image_Control' ) ) :
|
||||
class HU_Customize_Cropped_Image_Control extends WP_Customize_Cropped_Image_Control {
|
||||
public $type = 'czr_cropped_image';
|
||||
public $title;
|
||||
public $notice;
|
||||
public $dst_width;
|
||||
public $dst_height;
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
*
|
||||
* @Override
|
||||
* @see WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['title'] = !empty( $this -> title ) ? esc_html( $this -> title ) : '';
|
||||
$this->json['notice'] = !empty( $this -> notice ) ? $this -> notice : '';
|
||||
|
||||
$this->json['dst_width'] = isset( $this -> dst_width ) ? $this -> dst_width : $this -> width;
|
||||
$this->json['dst_height'] = isset( $this -> dst_height ) ? $this -> dst_height : $this -> height;
|
||||
//overload WP_Customize_Upload_Control
|
||||
//we need to re-build the absolute url of the logo src set in old Customizr
|
||||
$value = $this->value();
|
||||
if ( $value ) {
|
||||
//re-build the absolute url if the value isn't an attachment id before retrieving the id
|
||||
if ( (int) esc_attr( $value ) < 1 ) {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$value = false !== strpos( $value , '/wp-content/' ) ? $value : $upload_dir['baseurl'] . $value;
|
||||
}
|
||||
// Get the attachment model for the existing file.
|
||||
$attachment_id = attachment_url_to_postid( $value );
|
||||
if ( $attachment_id ) {
|
||||
$this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id );
|
||||
}
|
||||
}//end overload
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a JS template for the content of the media control.
|
||||
*
|
||||
* @since 3.4.19
|
||||
* @package Customizr
|
||||
*
|
||||
* @Override
|
||||
* @see WP_Customize_Control::content_template()
|
||||
*/
|
||||
public function content_template() {
|
||||
?>
|
||||
<# if ( data.title ) { #>
|
||||
<h3 class="czr-customizr-title">{{{ data.title }}}</h3>
|
||||
<# } #>
|
||||
<?php parent::content_template(); ?>
|
||||
<# if ( data.notice ) { #>
|
||||
<span class="czr-notice">{{{ data.notice }}}</span>
|
||||
<# } #>
|
||||
<?php
|
||||
}
|
||||
}//end class
|
||||
endif;
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**************************************************************************************************
|
||||
* LAYOUT SELECT
|
||||
***************************************************************************************************/
|
||||
if ( ! class_exists( 'HU_Customize_Layout_Control' ) ) :
|
||||
/**
|
||||
* Customize Multi-picker Control Class
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 3.4.10
|
||||
*/
|
||||
class HU_Customize_Layout_Control extends HU_controls {
|
||||
|
||||
public function render_content() {
|
||||
if ( empty( $this->choices ) )
|
||||
return;
|
||||
|
||||
?>
|
||||
<?php if (!empty( $this->title)) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php $this -> hu_print_select_control( 'no-selecter-js' ); //no-selecter-js : we don't want the default selecter $ plugin fired for this control ?>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this -> notice ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
private function hu_print_select_control($class) {
|
||||
printf('<select %1$s class="%2$s">%3$s</select>',
|
||||
call_user_func( array( $this, 'get'.'_'.'link' ) ),
|
||||
$class,
|
||||
$this -> hu_get_select_options()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function hu_get_select_options() {
|
||||
$_options_html = '';
|
||||
switch ( $this -> id ) {
|
||||
default:
|
||||
foreach ( $this->choices as $value => $data ) {
|
||||
$_options_html .= sprintf('<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_attr( $value ),
|
||||
selected( $this->value(), $value, false ),
|
||||
$data['label']
|
||||
);
|
||||
}
|
||||
break;
|
||||
}//end switch
|
||||
return $_options_html;
|
||||
}//end of fn
|
||||
|
||||
//the layouts are turned into a js object
|
||||
//{ 'col-1c' : { src: ..., label : ... }, ... }
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['layouts'] = $this->choices;
|
||||
}
|
||||
}//end class
|
||||
endif;
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
* @since 4.0
|
||||
*/
|
||||
if ( ! class_exists( 'HU_Customize_Modules' ) ) :
|
||||
class HU_Customize_Modules extends HU_controls {
|
||||
public $module_type;
|
||||
public $syncCollection;
|
||||
public $syncSektion;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public function __construct($manager, $id, $args = array()) {
|
||||
//let the parent do what it has to
|
||||
parent::__construct($manager, $id, $args );
|
||||
}
|
||||
|
||||
public function render_content(){}
|
||||
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
$this->json['syncCollection'] = $this->syncCollection;
|
||||
$this->json['syncSektion'] = $this->syncSektion;
|
||||
$this->json['module_type'] = $this->module_type;
|
||||
}
|
||||
|
||||
}
|
||||
endif;
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**************************************************************************************************
|
||||
* MULTIPICKER CLASSES
|
||||
***************************************************************************************************/
|
||||
if ( ! class_exists( 'HU_Customize_Multipicker_Control' ) ) :
|
||||
/**
|
||||
* Customize Multi-picker Control Class
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 3.4.10
|
||||
*/
|
||||
abstract class HU_Customize_Multipicker_Control extends HU_controls {
|
||||
|
||||
public function render_content() {
|
||||
|
||||
if ( ! $this -> type ) return;
|
||||
do_action( '__before_setting_control' , $this -> id );
|
||||
|
||||
$dropdown = $this -> hu_get_dropdown_multipicker();
|
||||
|
||||
if ( empty( $dropdown ) ) return;
|
||||
|
||||
$dropdown = str_replace( '<select', '<select multiple="multiple"' . $this->get_link(), $dropdown );
|
||||
//start rendering
|
||||
if (!empty( $this->title)) :
|
||||
?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<label>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php echo $dropdown; ?>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this -> notice ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
do_action( '__after_setting_control' , $this -> id );
|
||||
}
|
||||
|
||||
//to define in the extended classes
|
||||
abstract public function hu_get_dropdown_multipicker();
|
||||
}//end class
|
||||
endif;
|
||||
|
||||
if ( ! class_exists( 'HU_Customize_Multipicker_Categories_Control' ) ) :
|
||||
class HU_Customize_Multipicker_Categories_Control extends HU_Customize_Multipicker_Control {
|
||||
|
||||
public function hu_get_dropdown_multipicker() {
|
||||
$cats_dropdown = wp_dropdown_categories(
|
||||
array(
|
||||
'name' => '_customize-'.$this->type,
|
||||
'id' => $this -> id,
|
||||
//hide empty, set it to false to avoid complains
|
||||
'hide_empty' => 0 ,
|
||||
'echo' => 0 ,
|
||||
'walker' => new HU_Walker_CategoryDropdown_Multipicker(),
|
||||
'hierarchical' => 1,
|
||||
'class' => 'czrSelect2 no-selecter-js '.$this->type,
|
||||
'selected' => implode(',', $this->value() )
|
||||
)
|
||||
);
|
||||
|
||||
return $cats_dropdown;
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* @ dropdown multi-select walker
|
||||
* Create HTML dropdown list of Categories.
|
||||
*
|
||||
* @package WordPress
|
||||
* @since 2.1.0
|
||||
* @uses Walker
|
||||
*
|
||||
* we need to allow more than one "selected" attribute
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'HU_Walker_CategoryDropdown_Multipicker' ) ) :
|
||||
class HU_Walker_CategoryDropdown_Multipicker extends Walker_CategoryDropdown {
|
||||
/**
|
||||
* Start the element output.
|
||||
*
|
||||
* @Override
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $category Category data object.
|
||||
* @param int $depth Depth of category. Used for padding.
|
||||
* @param array $args Uses 'selected', 'show_count', and 'value_field' keys, if they exist.
|
||||
* See {@see wp_dropdown_categories()}.
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
$pad = str_repeat('—', $depth );
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$cat_name = apply_filters( 'list_cats', $category->name, $category );
|
||||
|
||||
$value_field = 'term_id';
|
||||
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $category->{$value_field} ) . "\"";
|
||||
//Treat selected arg as array
|
||||
if ( in_array( (string) $category->{$value_field}, explode( ',', $args['selected'] ) ) )
|
||||
$output .= ' selected="selected"';
|
||||
|
||||
$output .= '>';
|
||||
$output .= $pad.$cat_name;
|
||||
if ( $args['show_count'] )
|
||||
$output .= ' ('. number_format_i18n( $category->count ) .')';
|
||||
$output .= "</option>\n";
|
||||
}
|
||||
}
|
||||
endif;
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* Old upload control used until v3.4.18, still used if current version of WP is < 4.3
|
||||
**********************************************************************************/
|
||||
if ( ! class_exists( 'HU_Customize_Upload_Control' ) ) :
|
||||
/**
|
||||
* Customize Upload Control Class
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Customize
|
||||
* @since 3.4.0
|
||||
*/
|
||||
class HU_Customize_Upload_Control extends WP_Customize_Control {
|
||||
public $type = 'czr_upload';
|
||||
public $removed = '';
|
||||
public $context;
|
||||
public $extensions = array();
|
||||
public $title;
|
||||
public $notice;
|
||||
|
||||
/**
|
||||
* Enqueue control related scripts/styles.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public function enqueue() {
|
||||
wp_enqueue_script( 'wp-plupload' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameters passed to the JavaScript via JSON.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @uses WP_Customize_Control::to_json()
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['removed'] = $this->removed;
|
||||
|
||||
if ( $this->context )
|
||||
$this->json['context'] = $this->context;
|
||||
|
||||
if ( $this->extensions )
|
||||
$this->json['extensions'] = implode( ',', $this->extensions );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the control's content.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public function render_content() {
|
||||
do_action( '__before_setting_control' , $this -> id );
|
||||
?>
|
||||
<?php if ( isset( $this->title) ) : ?>
|
||||
<h3 class="czr-customizr-title"><?php echo esc_html( $this->title); ?></h3>
|
||||
<?php endif; ?>
|
||||
<label>
|
||||
<?php if ( ! empty( $this->label ) ) : ?>
|
||||
<span class="customize-control-title"><?php echo $this->label; ?></span>
|
||||
<?php endif;
|
||||
if ( ! empty( $this->description ) ) : ?>
|
||||
<span class="description customize-control-description"><?php echo $this->description; ?></span>
|
||||
<?php endif; ?>
|
||||
<div>
|
||||
<a href="#" class="button-secondary czr-upload"><?php _e( 'Upload' , 'hueman' ); ?></a>
|
||||
<a href="#" class="remove"><?php _e( 'Remove' , 'hueman' ); ?></a>
|
||||
</div>
|
||||
<?php if(!empty( $this -> notice)) : ?>
|
||||
<span class="czr-notice"><?php echo $this -> notice; ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php
|
||||
do_action( '__after_setting_control' , $this -> id );
|
||||
}
|
||||
}
|
||||
endif;
|
||||
Reference in New Issue
Block a user