コード例 #1
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            extract($vals);
        }
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            } else {
                if (!is_array($this->field->value) && is_string($this->field->value)) {
                    $tmp_arr = array();
                    $tmp_arr[] = $this->field->value;
                    $this->field->value = $tmp_arr;
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
			<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
			<?php 
            for ($key = 0; $key < $count; $key++) {
                ?>
				<input id="upload_image-<?php 
                echo esc_attr($this->field->alias);
                ?>
_<?php 
                echo esc_attr($key);
                ?>
" class="custom-file-upload custom-data-type" <?php 
                echo $section;
                // escaped above
                ?>
 
					data-type="fileupload-type" type="text" size="36" name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]" 
					value="<?php 
                echo @stripslashes(isset($this->field->value[$key]) ? $this->field->value[$key] : '');
                ?>
" <?php 
                $this->link();
                ?>
 />

					<span class="field_label">
						<button id="upload_image_button-<?php 
                echo esc_attr($this->field->alias . '_' . $key);
                ?>
" class="custom-file-upload-button button"><?php 
                _e('Select File', 'framework');
                ?>
</button>
					</span>
					<a href="#" class="delete_fileupload_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
			<?php 
            }
            $field = array('field_name' => $this->field->alias, 'type' => 'text', 'class' => 'custom-file-upload custom-data-type', 'size' => '36', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'fileupload-type', 'after_field' => __('Select File', 'framework'), 'value' => '#');
            $this->enable_repeating($field);
            ?>
		<script type='text/javascript'>
                    var file_frame;
			var current_button;
			var attached_input;
			                    
			(function($){
				$('body').on('click', '.custom-file-upload-button', function(e){
					e.preventDefault();
					e.stopPropagation();
					current_button = $(this);
					attached_input = current_button.parent().prev();

					if ( file_frame ) {
						file_frame.open();
						return;
					}

					file_frame = wp.media.frames.file_frame = wp.media({
						multiple: false
					});

					file_frame.on( 'select', function() {
						attachment = file_frame.state().get('selection').first().toJSON();
						attached_input.val(attachment.url);
						attached_input.focus();

						if ( wp.customize ) {
							var api = wp.customize;
							var values_array = [];
							var name = attached_input.attr('name').replace(/\[\d*\]$/, "");
							$('input[name="'+attached_input.attr('name')+'"]').each(function(){
								values_array.push($(this).val());
							});
							api.instance(name).set(values_array);
						}

						var e = jQuery.Event("keypress");
						e.which = 13; //choose the one you want
						e.keyCode = 13;
						attached_input.trigger(e);
					});

					file_frame.open();
				});
			})(jQuery);
		</script>
	<?php 
        } else {
            $input_value = $vals != null ? $this->field->saved : $this->get_value();
            if (!is_string($input_value) && !is_numeric($input_value)) {
                if (is_array($input_value) && isset($input_value[0])) {
                    $input_value = $input_value[0];
                } else {
                    $input_value = "";
                }
            }
            ?>
		<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
		<input id="upload_image-<?php 
            echo esc_attr($this->field->alias);
            ?>
" class="custom-data-type" <?php 
            echo $section;
            // escaped above
            ?>
 data-type="fileupload-type" <?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
 type="text" size="36" name="<?php 
            echo esc_attr($this->field->alias);
            ?>
" value="<?php 
            echo esc_attr(@stripslashes($input_value));
            ?>
" <?php 
            $this->link();
            ?>
 />

		<span class="field_label">
			<button id="upload_image_button-<?php 
            echo esc_attr($this->field->alias);
            ?>
" class="button"><?php 
            _e('Select File', 'framework');
            ?>
</button>
		</span>
		
		<script type="text/javascript">
			var file_frame;
			var current_button;
			var attached_input;

			(function($){

				$("#upload_image-<?php 
            echo esc_js($this->field->alias);
            ?>
").keydown(function(e){
					console.log('Yes keydown triggered. ' + e.which)
				});	

				
					$("#upload_image_button-<?php 
            echo esc_js($this->field->alias);
            ?>
").click(function(e) {
						e.preventDefault();
						current_button = $(this);
						attached_input = current_button.parent().prev();

						if ( file_frame ) {
							file_frame.open();
							return;
						}

						file_frame = wp.media.frames.file_frame = wp.media({
							multiple: false
						});

						file_frame.on( 'select', function() {
							attachment = file_frame.state().get('selection').first().toJSON();
							attached_input.val(attachment.url);
							attached_input.trigger('change');
							
							if ( wp.customize ) {
								var api = wp.customize;
								var mysetting = api.instance(attached_input.attr('name'));
								api.instance(attached_input.attr('name')).set(attachment.url);
							}

							var e = jQuery.Event("keypress");
							e.which = 13; //choose the one you want
							e.keyCode = 13;
							attached_input.trigger(e);
						});

						file_frame.open();
					});
				
			})(jQuery);
		</script><?php 
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #2
0
    public function render_content($vals = null)
    {
        $input_value = $vals != null ? $this->field->saved : $this->get_value();
        $font_family = isset($this->field->family) ? $this->field->family : 'Open Sans';
        $font_weight = $this->field->weight != '' ? $this->field->weight : 'normal';
        $font_size = $this->field->size != '' ? $this->field->size : '20px';
        $font_style = isset($this->field->style) && $this->field->style != '' ? $this->field->style : 'normal';
        $font_color = isset($this->field->color) && $this->field->color != '' ? $this->field->color : '#000000';
        $previewText = isset($this->field->previewText) ? $this->field->previewText : '';
        global $developer_tools;
        $current_theme = rw_get_theme_data();
        $t = runway_admin_themes_list_prepare($current_theme);
        $options = $developer_tools->load_settings($t['folder']);
        $google_fonts = $this->wp_get_google_webfonts_list(isset($options['WebFontAPIKey']) ? $options['WebFontAPIKey'] : '');
        if (is_array($input_value)) {
            if (isset($input_value['family'])) {
                $font_family = $input_value['family'];
            }
            if (isset($input_value['style'])) {
                $font_style = $input_value['style'];
            }
            if (isset($input_value['weight'])) {
                $font_weight = $input_value['weight'];
            }
            if (isset($input_value['size'])) {
                $font_size = $input_value['size'];
            }
            if (isset($input_value['color'])) {
                $font_color = $input_value['color'];
            }
            if (isset($input_value['previewText'])) {
                $previewText = $input_value['previewText'];
            }
        }
        ?>

		<div class="<?php 
        echo esc_attr($this->field->alias);
        ?>
 custom-data-type">

			<div style="font-family: 
					<?php 
        echo esc_attr($font_family);
        ?>
; 
					<?php 
        if (isset($font_style) && !empty($font_style)) {
            ?>
						font-style: <?php 
            echo esc_attr($font_style);
            ?>
; 
					<?php 
        }
        ?>
					font-weight: <?php 
        echo esc_attr($font_weight);
        ?>
;
					font-size: <?php 
        echo esc_attr($font_size);
        ?>
; 
					<?php 
        if (isset($font_color) && !empty($font_color)) {
            ?>
						color: <?php 
            echo esc_attr($font_color);
            ?>
					<?php 
        }
        ?>
">
					<?php 
        echo $previewText != '' ? $previewText : ucwords(str_replace('-', ' ', $font_family));
        ?>
			</div>

			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[previewText]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[previewText]" value="<?php 
        echo esc_attr($previewText);
        ?>
" type="hidden"/>
			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[family]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[family]" value="<?php 
        echo esc_attr($font_family);
        ?>
" type="hidden"/>
			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[style]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[style]" value="<?php 
        echo esc_attr($font_style);
        ?>
" type="hidden"/>
			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[weight]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[weight]" value="<?php 
        echo esc_attr($font_weight);
        ?>
" type="hidden"/>
			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[size]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[size]" value="<?php 
        echo esc_attr($font_size);
        ?>
" type="hidden"/>
			<input class="custom-data-type" <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[color]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[color]" value="<?php 
        echo esc_attr($font_color);
        ?>
" type="hidden"/>

			<div class="<?php 
        echo esc_attr($this->field->alias);
        ?>
">
				<a href="#" onclick="return false" class="edit-font-options-a button"><?php 
        echo __('Edit Font Options', 'framework');
        ?>
</a>
				<div class="font-options-container pop" style="display:none">
				<div class="settings-font-options-dialog">
					<div class="toogle-font-select-container">

						<div class="settings-container preview-text-input">
							<label class="settings-title">
								<?php 
        echo __('Preview text', 'framework');
        ?>
:
							</label>
							<div class="settings-in">
								<input data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_previewText]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_previewText]" value="<?php 
        echo esc_attr($previewText);
        ?>
" type="text" placeholder="<?php 
        echo __('Preview Test', 'framework');
        ?>
"/>
								<p class="settings-field-caption description"><?php 
        echo __('Preview text.', 'framework');
        ?>
</p>
							</div>
							<div class="clear"></div>
						</div>

						<div class="ui-dialog-content">

							<div class="settings-container">
								<label class="settings-title">
									<?php 
        echo __('Family', 'framework');
        ?>
:
								</label>
								<div class="settings-in">
									<select data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_family]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_family]" data-type="font-select" class="settings-select">
										<?php 
        if (is_array($google_fonts) && !empty($google_fonts)) {
            ?>
										<?php 
            foreach ($google_fonts as $font) {
                ?>
										<option <?php 
                if ($font_family == $font) {
                    echo "selected='true'";
                }
                ?>
value="<?php 
                echo esc_attr($font);
                ?>
"><?php 
                echo esc_attr($font);
                ?>
</option>
										<?php 
            }
            ?>
										<?php 
        } else {
            ?>
										<option selected="true" value="open sans"><?php 
            echo __('Open Sans', 'framework');
            ?>
</option>
										<?php 
        }
        ?>
									</select>
								</div>
								<div class="clear"></div>
							</div>

							<div class="settings-container">
								<label class="settings-title">
									<?php 
        echo __('Style', 'framework');
        ?>
:
								</label>
								<div class="settings-in">
									<select data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_style]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_style]" data-type="font-select" class="settings-select">
										<option <?php 
        if ($font_style == '' || $font_style == 'normal') {
            ?>
selected="true" <?php 
        }
        ?>
value="normal"><?php 
        echo __('Normal', 'framework');
        ?>
</option>
										<option <?php 
        if ($font_style == 'italic') {
            ?>
 selected="true" <?php 
        }
        ?>
 value="italic"><?php 
        echo __('Italic', 'framework');
        ?>
</option>
									</select>
								</div>
								<div class="clear"></div>
							</div>

							<div class="settings-container">
								<label class="settings-title">
									<?php 
        echo __('Weight', 'framework');
        ?>
:
								</label>
								<div class="settings-in">
									<input data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_weight]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_weight]" value="<?php 
        if ($this->field->weight == '') {
            ?>
bold<?php 
        } else {
            echo esc_attr($font_weight);
        }
        ?>
" type="text" data-type="font-select"  />
									<p class="settings-field-caption description"><?php 
        echo __('normal, bold, 300, 600, 800', 'framework');
        ?>
</p>
								</div>
								<div class="clear"></div>
							</div>

							<div class="settings-container">
								<label class="settings-title">
									<?php 
        echo __('Size', 'framework');
        ?>
:
								</label>
								<div class="settings-in">
									<input data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_size]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_size]" value="<?php 
        if ($this->field->size == '') {
            ?>
32px<?php 
        } else {
            echo esc_attr($font_size);
        }
        ?>
" type="text" data-type="font-select" />
									<p class="settings-field-caption description"><?php 
        echo __('12, 24px, 1em, 1.75', 'framework');
        ?>
</p>
								</div>
								<div class="clear"></div>
							</div>

							<div class="settings-container">
								<label class="settings-title">
									<?php 
        echo __('Color', 'framework');
        ?>
:
								</label>
								<div class="settings-in">
									<input data-set="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_color]" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
[_color]" value="<?php 
        echo $font_color != '' ? $font_color : '#000000';
        ?>
" type="text" class="color-picker-hex" data-type="font-select" />
								</div>
								<div class="clear"></div>
							</div>

						</div>

						<input class="button" type="button" value="<?php 
        _e('Close', 'framework');
        ?>
" name="<?php 
        echo esc_attr($this->field->alias);
        ?>
_save"/>
						<!-- <a href="#" class="<?php 
        echo esc_attr($this->field->alias);
        ?>
_cancel"><?php 
        _e('Cancel', 'framework');
        ?>
</a> -->

					</div>
					<script type="text/javascript">
						var alias = '<?php 
        echo esc_js($this->field->alias);
        ?>
';
						jQuery(document).ready(function($){

							function deselect(e) {
							  $('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .pop').slideFadeToggle(function() {
							    e.removeClass('font-edit');
							  });    
							}

							$.fn.slideFadeToggle = function(easing, callback) {
							  return this.animate({ opacity: 'toggle', height: 'toggle' }, 'fast', easing, callback);
							};

							jQuery('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').wpColorPicker({ change: function () {
									var hexcolor = jQuery( this ).wpColorPicker( 'color' );
									
									//setTimeout(function () {
										$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').attr('value', hexcolor).val(hexcolor).trigger('change');
									//}, 50);

								}});
							//);

							$('input[name=<?php 
        echo esc_js($this->field->alias);
        ?>
_save]').on('click', function(e){
								e.preventDefault();
								e.stopPropagation();

								var alias = "<?php 
        echo esc_js($this->field->alias);
        ?>
";

								$('input[name="'+alias+'[previewText]"]').val($('input[name="'+alias+'[_previewText]"]').val());
								$('input[name="'+alias+'[family]"]').val($('select[name="'+alias+'[_family]"]').val());
								$('input[name="'+alias+'[style]"]').val($('select[name="'+alias+'[_style]"]').val());
								$('input[name="'+alias+'[weight]"]').val($('input[name="'+alias+'[_weight]"]').val());
								$('input[name="'+alias+'[size]"]').val($('input[name="'+alias+'[_size]"]').val());
								$('input[name="'+alias+'[color]"]').val($('input[name="'+alias+'[_color]"]').val());

								if ( wp.customize ) {
									var api = wp.customize;
									var values_array = {};
									
									$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .settings-font-options-dialog .toogle-font-select-container input[type=text]').each(function(){
										var name = $(this).attr('name').replace(alias, '').replace("[", "").replace("]", "");
										
										values_array[name] = $(this).val();

										//api.instance($(this).attr('name')).set($(this).val());
									});
									$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container select option:selected').each(function(){
										var name = $(this).parent('select').attr('name').replace(alias, '').replace("[", "").replace("]", "");
										values_array[name] = $(this).attr('value');

										//api.instance($(this).parent('select').attr('name')).set($(this).attr('value'));
									});
									var name = $('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').attr('name').replace(alias, '').replace("[", "").replace("]", "");
									values_array[name] = $('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').val();

									api.instance(alias).set(values_array);
									//api.instance($('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .edit-font-options-inner .color-picker-hex').attr('name')).set($('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .edit-font-options-inner .color-picker-hex').val());
								}
								deselect($(this));
							});

							$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').wpColorPicker({ change: function () {
								var hexcolor = jQuery( this ).wpColorPicker( 'color' );
						
									//setTimeout(function () {
										$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .toogle-font-select-container .color-picker-hex').attr('value', hexcolor).val(hexcolor).trigger('change');
									//}, 50);

							}});


							$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 a.edit-font-options-a').on('click', function(e){console.log('11111');
								e.preventDefault();
								e.stopPropagation();
 	
    							if($(this).hasClass('font-edit')) {
      								deselect($(this));               
    							} else {
      								$(this).addClass('font-edit');
      								$('.<?php 
        echo esc_js($this->field->alias);
        ?>
 .pop').slideFadeToggle();
    							}
  							});

						    /*$('.<?php 
        echo esc_js($this->field->alias);
        ?>
_cancel').on('click', function(e) {
						    	e.preventDefault();
								e.stopPropagation();
						    	deselect($(this));
						    //return false;
						  	});*/
						});
					</script>					
				</div>
			</div>
			</div>	

		</div>

		<?php 
    }
コード例 #3
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            $this->field->values = preg_replace("/\\r\\n|\\n|\\r/", '\\n\\r', $this->field->values);
        }
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $key_values = array();
        $key_values = array();
        if (isset($this->field->values) && !empty($this->field->values)) {
            if (strstr($this->field->values, "\r\n")) {
                $rows = explode("\r\n", $this->field->values);
            } else {
                $rows = explode("\\r\\n", $this->field->values);
            }
            foreach ($rows as $v) {
                if ($v != '') {
                    $v = htmlspecialchars_decode($v);
                    $this->field->values = explode('=>', $v);
                    if (count($this->field->values) == 1) {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[0];
                    } else {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[1];
                    }
                }
            }
        }
        $name = isset($alias) ? $alias : $this->field->alias;
        $vars = $key_values;
        $checked = 1;
        ?>
		<legend class="customize-control-title"><span><?php 
        echo stripslashes($this->field->title);
        ?>
</span></legend>
		<?php 
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            } else {
                if (!is_array($this->field->value) && is_string($this->field->value)) {
                    $tmp_arr = array();
                    $tmp_arr[] = $this->field->value;
                    $this->field->value = $tmp_arr;
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            $len = count($vars);
            $vars = apply_filters($this->field->alias . '_data_options', $vars);
            for ($key_val = 0; $key_val < $count; $key_val++) {
                $cnt = 0;
                $html = "<div class='radio_group'>";
                foreach ($vars as $key => $val) {
                    $cnt++;
                    $checked = isset($this->field->value[$key_val]) && $key == trim($this->field->value[$key_val]) ? 'checked="checked"' : '';
                    $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
                    $html .= '<label><input ' . $this->return_link() . ' class="input-radio custom-data-type" ' . $section . ' data-type="radio-buttons" type="radio" name="' . $this->field->alias . '[' . $key_val . ']" value="' . $key . '" ' . $checked . ' />' . stripslashes($val) . '</label>';
                    if ($cnt < $len) {
                        $html .= '<br>';
                    }
                }
                echo $html . "</div>";
                ?>
					<a href="#" class="delete__radio_buttons_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br><br>
				<?php 
            }
            $field = array('field_name' => $this->field->alias, 'start_number' => $count, 'type' => 'radio', 'class' => 'input-radio custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'radio-buttons', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field, $key_values);
            $this->wp_customize_js();
        } else {
            $html = '';
            $set = $value;
            if (!isset($set) || empty($set)) {
                $set = $value;
            }
            $len = count($vars);
            $count = 0;
            $vars = apply_filters($this->field->alias . '_data_options', $vars);
            // allow filters to alter values
            foreach ($vars as $key => $val) {
                $count++;
                $checked = is_string($set) && $key == trim($set) ? 'checked="checked"' : '';
                $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
                $html .= '<label><input ' . $this->get_link() . ' class="input-radio custom-data-type" ' . parent::add_data_conditional_display($this->field) . ' ' . $section . ' data-type="radio-buttons" type="radio" name="' . $this->field->alias . '" value="' . $key . '" ' . $checked . ' />' . stripslashes($val) . '</label>';
                if ($count < $len) {
                    $html .= '<br>';
                }
            }
            // Add the fieldset container
            $html = '<fieldset><legend class="screen-reader-text"><span>' . stripslashes($this->field->title) . '</span></legend>' . stripslashes($html) . '</fieldset>';
            echo $html;
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #4
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        $customize_title = stripslashes($this->field->title);
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $start = "0";
        $double = false;
        if ($this->field->startFirstEntry != '' && $this->field->startSecondEntry != '') {
            $double = true;
        }
        if ($double) {
            $start = "[" . $this->field->startFirstEntry . ", " . $this->field->startSecondEntry . "]";
        } else {
            if ($this->field->startFirstEntry != '') {
                $start = "[" . $this->field->startFirstEntry . "]";
            }
        }
        if ($value !== null && $value !== false && $value !== "") {
            $start = $value;
            if ($double) {
                $values_string = $start;
                $values_string = preg_replace("/[\\[\\]\\s]*/", "", $values_string);
                $values_array = explode(",", $values_string);
                $this->field->startFirstEntry = $values_array[0];
                $this->field->startSecondEntry = $values_array[1];
            } else {
                $this->field->startFirstEntry = preg_replace("/\\[\\]\\s/", "", $start);
            }
        }
        $connect = 'false';
        if ($this->field->connect == 'false' || $this->field->connect == 'true') {
            $connect = $this->field->connect;
        } else {
            $connect = '"' . $this->field->connect . '"';
        }
        ?>

		<legend class='customize-control-title'><span><?php 
        echo $customize_title;
        ?>
</span></legend>
		
		<div id="<?php 
        echo esc_attr($this->field->alias);
        ?>
" class="range-slider">
			<div id="slider-<?php 
        echo esc_attr($this->field->alias);
        ?>
" <?php 
        if ($this->field->orientation == 'vertical') {
            ?>
style="height: 250px;"<?php 
        }
        ?>
></div>
			<div class="slider-values">
				Slider values: <?php 
        if ($double) {
            ?>
					<span class="slider-start-<?php 
            echo esc_attr($this->field->alias);
            ?>
 slider-value"><?php 
            echo $this->field->startFirstEntry;
            ?>
</span>
					<span class="slider-end-<?php 
            echo esc_attr($this->field->alias);
            ?>
 slider-value"><?php 
            echo $this->field->startSecondEntry;
            ?>
</span>
					<?php 
        } else {
            ?>
					<span class="slider-start-<?php 
            echo esc_attr($this->field->alias);
            ?>
 slider-value"><?php 
            echo $this->field->startFirstEntry;
            ?>
</span>
					<?php 
        }
        ?>
					
					<input type="hidden" 
					       class="custom-data-type" 
					       <?php 
        echo parent::add_data_conditional_display($this->field);
        ?>
 
					       name="<?php 
        echo esc_attr($this->field->alias);
        ?>
" 
					       value="<?php 
        echo esc_attr($value);
        ?>
" 
					       <?php 
        $this->link();
        ?>
					       <?php 
        echo $section;
        // escaped above
        ?>
					       id="hidden-<?php 
        echo esc_attr($this->field->alias);
        ?>
"
					       data-type="range-slider"/>
			</div>
			<script type="text/javascript">
				jQuery(document).ready(function($) {
					$('#slider-<?php 
        echo esc_js($this->field->alias);
        ?>
').noUiSlider({
						start: <?php 
        echo esc_js($start);
        ?>
, 
						range: {
							'min': [<?php 
        echo $this->field->rangeMin != "" ? esc_js($this->field->rangeMin) : 0;
        ?>
],
							'max': [<?php 
        echo $this->field->rangeMax != "" ? esc_js($this->field->rangeMax) : 100;
        ?>
]
						}, 
						connect: <?php 
        echo esc_js($connect);
        if ($this->field->margin != "") {
            ?>
,
						margin: <?php 
            echo esc_js($this->field->margin);
        }
        if ($this->field->step != "") {
            ?>
, 
						step: <?php 
            echo esc_js($this->field->step);
        }
        ?>
, 
						orientation: "<?php 
        echo esc_js($this->field->orientation);
        ?>
", 
						direction: "<?php 
        echo esc_js($this->field->direction);
        ?>
",
						serialization: {
							lower: [
								$.Link({
									target: $(".slider-start-<?php 
        echo esc_js($this->field->alias);
        ?>
"),
									method: "html"
								})
							],
							upper: [
								$.Link({
									target: $(".slider-end-<?php 
        echo esc_js($this->field->alias);
        ?>
"),
									method: "html"
								})
							]
						}
					});
				});
			</script>
			
		</div>
		
		<?php 
        $this->wp_customize_js($double);
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #5
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
        }
        $this->get_value();
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            ?>
			<label>
				<span class="customize-control-title"><?php 
            echo $this->field->title;
            ?>
</span>
				<div class="customize-control-content">				
			<?php 
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            for ($key = 0; $key < $count; $key++) {
                if (isset($this->field->value) && is_array($this->field->value)) {
                    $repeat_value = isset($this->field->value[$key]) ? $this->field->value[$key] : '';
                } else {
                    $repeat_value = '';
                }
                ?>
				<input 
					type="text" 
					class="input-text custom-data-type" 
					<?php 
                echo $section;
                // escaped above
                ?>
 
					data-type="input-text" 
					<?php 
                echo parent::add_data_conditional_display($this->field);
                ?>
 
					<?php 
                $this->link();
                ?>
 
					name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]" 
					accept=""value="<?php 
                echo isset($repeat_value) && $repeat_value != '' ? esc_attr($repeat_value) : '';
                ?>
"
				/>
					<a href="#" class="delete_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
				<?php 
            }
            if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
                $field = array('field_name' => $this->field->alias, 'type' => 'text', 'class' => 'input-text custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'input-text', 'after_field' => '', 'value' => 'aaa');
                $field = parent::add_data_conditional_display_repeating($field, $this->field);
                $this->enable_repeating($field);
            }
            ?>
				</div>
			</label>
			<?php 
            $this->wp_customize_js();
        } else {
            ?>
			<label>
				<span class="customize-control-title"><?php 
            echo $this->field->title;
            ?>
</span>
				<?php 
            $input_value = $vals != null ? $this->field->saved : $this->get_value();
            if (!is_string($input_value) && !is_numeric($input_value)) {
                if (is_array($input_value) && isset($input_value[0])) {
                    $input_value = $input_value[0];
                } else {
                    $input_value = "";
                }
            }
            ?>
                            
				<div class="customize-control-content">
					<input type="text" 
						class="input-text custom-data-type" <?php 
            echo $section;
            // escaped above
            ?>
 data-type="input-text" <?php 
            echo parent::add_data_conditional_display($this->field);
            // escaped above
            ?>
 <?php 
            $this->link();
            ?>
 name="<?php 
            echo esc_attr($this->field->alias);
            ?>
" value="<?php 
            echo esc_attr($input_value);
            ?>
"/>
				</div>
			</label>
			<?php 
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #6
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        ?>

		<?php 
        if ($vals != null) {
            $this->field = (object) $vals;
            extract($vals);
            $value = $vals['saved'];
        } else {
            $value = $this->get_value();
        }
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        ?>
		<?php 
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
			<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
			<?php 
            for ($key = 0; $key < $count; $key++) {
                if (isset($this->field->value) && is_array($this->field->value)) {
                    $repeat_value = isset($this->field->value[$key]) ? $this->field->value[$key] : '';
                } else {
                    $repeat_value = "";
                }
                ?>
				<input <?php 
                $this->link();
                ?>
 type="text" class="datepicker custom-data-type"
					name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]"
					value="<?php 
                echo esc_attr($repeat_value);
                ?>
"
					<?php 
                echo $section;
                // escaped above
                ?>
					data-format="<?php 
                echo esc_attr(stripslashes($this->field->format));
                ?>
"
					data-changeMonth="<?php 
                echo esc_attr(stripslashes($this->field->changeMonth));
                ?>
"
					data-changeYear="<?php 
                echo esc_attr(stripslashes($this->field->changeYear));
                ?>
"
					data-type="datepicker-type" />
				<a href="#" class="delete_datepicker_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
			<?php 
            }
            $field = array('field_name' => $this->field->alias, 'type' => 'text', 'class' => 'datepicker custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'datepicker-type', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field);
            $this->wp_customize_js();
            ?>
			<script type="text/javascript">
				(function ($) {
					$(function () {
						$(".datepicker").datepicker({
							autoSize: false,
							dateFormat: "<?php 
            echo stripslashes(str_replace('"', "'", $this->field->format));
            ?>
",
							changeMonth: $(this).data('changemonth'),
							changeYear: $(this).data('changeyear'),

							onSelect: function(date) {
								if(typeof reinitialize_customize_instance == 'function') {
									reinitialize_customize_instance('<?php 
            echo esc_js($this->field->alias);
            ?>
');
								}
							}
						});
					});
				})(jQuery);
			</script>
		<?php 
        } else {
            $input_value = isset($value) && is_string($value) ? stripslashes($value) : '';
            //$input_value_unformatted =date_format(date_create($input_value), 'm/d/Y') );
            if (!is_string($input_value) && !is_numeric($input_value)) {
                if (is_array($input_value) && isset($input_value[0])) {
                    $input_value = $input_value[0];
                } else {
                    $input_value = "";
                }
            }
            ?>
			<script type="text/javascript">
				(function ($) {
					$(function () {
						$("[name='<?php 
            echo esc_js($this->field->alias);
            ?>
']").datepicker({
							autoSize: false,
							dateFormat: "<?php 
            echo stripslashes(str_replace('"', "'", $this->field->format));
            ?>
",
							changeMonth: $(this).data('changemonth'),
							changeYear: $(this).data('changeyear'),

							onSelect: function(date) {
								$("[name='<?php 
            echo esc_js($this->field->alias);
            ?>
']").attr('value', date).val(date);
								if ( wp.customize ) {
									var api = wp.customize;
									console.log(api);
									api.instance('<?php 
            echo esc_js($this->field->alias);
            ?>
').set(date);
								}
							}
						});
					});
				})(jQuery);
			</script>
			
			<legend class="customize-control-title"><span><?php 
            echo esc_attr(stripslashes($this->field->title));
            ?>
</span></legend>
			<input <?php 
            $this->link();
            ?>
 type="text" class="datepicker custom-data-type"
				name="<?php 
            echo esc_attr($this->field->alias);
            ?>
"
				value="<?php 
            echo esc_attr($input_value);
            ?>
"
				<?php 
            echo $section;
            // escaped above
            ?>
				data-format="<?php 
            echo esc_attr(stripslashes($this->field->format));
            ?>
"
				<?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
				data-changeMonth="<?php 
            echo esc_attr(stripslashes($this->field->changeMonth));
            ?>
"
				data-changeYear="<?php 
            echo esc_attr(stripslashes($this->field->changeYear));
            ?>
"
				data-type="datepicker-type" />
			<div id="datapicker-dialog" name="<?php 
            echo isset($alias) ? esc_attr($alias) : '';
            ?>
" title="<?php 
            echo isset($title) ? esc_attr(stripslashes($title)) : '';
            ?>
" style="display:none;"></div>
                    
		<?php 
        }
        ?>
                
		<?php 
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #7
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            $this->field->values = preg_replace("/\\r\\n|\\n|\\r/", "\r\n", $this->field->values);
        }
        $key_values = array();
        if (isset($this->field->values) && !empty($this->field->values)) {
            if (strstr($this->field->values, "\r\n")) {
                $rows = explode("\r\n", $this->field->values);
            } else {
                $rows = explode("\\r\\n", $this->field->values);
            }
            foreach ($rows as $v) {
                if ($v != '') {
                    $v = htmlspecialchars_decode($v);
                    $this->field->values = explode('=>', $v);
                    if (count($this->field->values) == 1) {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[0];
                    } else {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[1];
                    }
                }
            }
        }
        $options = array();
        $checked_list = array();
        $this->field->values = $vals != null ? $this->field->saved : (array) $this->get_value();
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
        if (isset($this->field->value[$this->field->alias]) && isset($this->field->value) && in_array('field_types', (array) $this->field->value)) {
            $this->field->value = $this->field->value[$this->field->alias];
        }
        if (empty($this->field->values[0])) {
            $this->field->values = $checked_list;
        }
        if (isset($this->field->values[0]) && $this->field->values[0] == 'Array') {
            $this->field->values = array(0 => $options['values']);
        }
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            ?>
		<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
		<?php 
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key) || !is_array($tmp_value)) {
                        unset($this->field->value[$key]);
                    }
                }
            } else {
                if (!is_array($this->field->value) && is_string($this->field->value)) {
                    $tmp_arr = array();
                    $tmp_arr[] = $this->field->value;
                    $this->field->value = $tmp_arr;
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            $key_values = apply_filters($this->field->alias . '_data_options', $key_values);
            $len = count($key_values);
            for ($key_val = 0; $key_val < $count; $key_val++) {
                $cnt = 0;
                $html = "<div class='checkbox_group'>";
                foreach ($key_values as $key => $val) {
                    $cnt++;
                    if (!isset($options[$key])) {
                        $options[$key] = array('class' => '', 'disabled' => '');
                    }
                    $class = ($a = $options[$key]['class']) ? 'class="' . $a . '"' : '';
                    $readonly = $options[$key]['disabled'] ? ' disabled="disabled"' : '';
                    if (isset($this->field->values[$key_val]) && is_array($this->field->values[$key_val])) {
                        $checked = in_array($key, $this->field->values[$key_val]) ? ' checked="checked"' : '';
                    } else {
                        $checked = "";
                    }
                    $html .= '<label>
							<input
							class="input-check custom-data-type"
							' . $section . '
							type="checkbox"
							data-type="checkbox-type"
							value="' . $key . '"
							name="' . $this->field->alias . '[' . $key_val . '][]" ' . (isset($this->field->class) ? $this->field->class : "") . ' ' . $readonly . ' ' . $checked . '/>' . stripslashes($val) . '</label>';
                }
                echo $html . "</div>";
                ?>
					<a href="#" class="delete__checkbox_group_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br><br>
				<?php 
            }
            $field = array('field_name' => $this->field->alias, 'start_number' => $count, 'type' => 'checkbox', 'class' => 'input-check custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'checkbox-type', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field, $key_values);
            $this->wp_customize_js();
        } else {
            $html = '';
            $len = count($key_values);
            $count = 0;
            $key_values = apply_filters($this->field->alias . '_data_options', $key_values);
            // allow filters to alter values
            foreach ($key_values as $key => $val) {
                $count++;
                // Options will over-ride values
                if (!isset($options[$key])) {
                    $options[$key] = array('class' => '', 'disabled' => '');
                }
                $class = ($a = $options[$key]['class']) ? 'class="' . $a . '"' : '';
                $readonly = $options[$key]['disabled'] ? ' disabled="disabled"' : '';
                if (array_key_exists('value', (array) $options[$key])) {
                    $checked = $options[$key]['value'] ? ' checked="checked" ' : '';
                } elseif (is_array($this->field->values)) {
                    $checked = in_array($key, $this->field->values) ? ' checked="checked"' : '';
                }
                if (!isset($this->field->class)) {
                    $this->field->class = '';
                }
                $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
                $html .= '<label>
						<input
						class="input-check custom-data-type" ' . parent::add_data_conditional_display($this->field) . ' ' . $section . '
						type="checkbox"
						data-type="checkbox-type"
						value="' . $key . '"
						name="' . $this->field->alias . '[]" ' . (isset($this->field->class) ? $this->field->class : "") . ' ' . $readonly . ' ' . $checked . '/>' . stripslashes($val) . '</label>';
                if (isset($options[$key]['text'])) {
                    if ($t = $options[$key]['text']) {
                        $html .= '<em>' . $t . '</em>';
                    }
                }
                if ($count < $len) {
                    $html .= '<br>';
                }
            }
            // Add the fieldset container
            $html = '<legend class="customize-control-title"><span>' . $this->field->title . '</span></legend><fieldset><legend class="screen-reader-text"><span>' . $this->field->title . '</span></legend>' . $html . '</fieldset>';
            echo $html;
            /* dirty hack to make multiple elms on customize.php page */
            if ($this->is_customize_theme_page) {
                ?>
				<input type="hidden" <?php 
                $this->link();
                ?>
 name="<?php 
                echo esc_attr($this->field->alias);
                ?>
" value="" />

				<script type="text/javascript">

					jQuery('input[name="<?php 
                echo esc_js($this->field->alias);
                ?>
[]"]').on('click', function () {
						var value = [];

						jQuery('[name="<?php 
                echo esc_js($this->field->alias);
                ?>
[]"]:checked').each(function () {
							value.push(jQuery(this).val());
						});

						jQuery('[name="<?php 
                echo esc_js($this->field->alias);
                ?>
"]').val(value).trigger('change');

					});

				</script>
			<?php 
            }
            /* dirty hack to make multiple elms on customize.php page */
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #8
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            $this->field->values = preg_replace("/\\r\\n|\\n|\\r/", '\\n\\r', $this->field->values);
        }
        $key_values = array();
        if (isset($this->field->values) && !empty($this->field->values)) {
            if (strstr($this->field->values, "\r\n")) {
                $rows = explode("\r\n", $this->field->values);
            } else {
                $rows = explode("\\r\\n", $this->field->values);
            }
            foreach ($rows as $v) {
                if ($v != '') {
                    $v = htmlspecialchars_decode($v);
                    $this->field->values = explode('=>', $v);
                    if (count($this->field->values) == 1) {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[0];
                    } else {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[1];
                    }
                }
            }
        }
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        $customize_title = stripslashes($this->field->title);
        ?>
		<?php 
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $vals = $vals != null ? $this->field->saved : $this->get_value();
            if (isset($vals) && is_array($vals)) {
                foreach ($vals as $key => $tmp_value) {
                    if (!is_array($tmp_value) || is_string($key)) {
                        unset($vals[$key]);
                    }
                }
            }
            $count = isset($vals) ? count((array) $vals) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
		<legend class='customize-control-title'><span><?php 
            echo $customize_title;
            ?>
</span></legend>
		<?php 
            for ($key = 0; $key < $count; $key++) {
                ?>
			<select multiple class="input-select custom-data-type" <?php 
                echo $section;
                // escaped above
                ?>
 data-type="multi-select-type" 
				name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[<?php 
                echo esc_attr($key);
                ?>
][]" size="5" style="height: 103px;" <?php 
                $this->link();
                ?>
>
                    
				<option value="no" <?php 
                if (isset($vals[$key][0]) && $vals[$key][0] == 'no') {
                    ?>
 selected="selected" <?php 
                }
                ?>
><?php 
                echo __('No value', 'framework');
                ?>
</option>
				<?php 
                foreach ($key_values as $select_value_key => $val) {
                    if (is_array($vals[$key])) {
                        $checked = in_array($select_value_key, $vals[$key]) ? ' selected="selected" checked="checked"' : '';
                    } else {
                        $checked = '';
                    }
                    ?>
				<option value='<?php 
                    echo esc_attr($select_value_key);
                    ?>
' <?php 
                    echo esc_attr($checked);
                    ?>
><?php 
                    echo stripslashes($val);
                    ?>
</option>
				<?php 
                }
                ?>
			</select>
		<a href="#" class="delete_multiselect_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
		<?php 
            }
            $field = array('field_name' => $this->field->alias, 'start_number' => $count, 'type' => 'select', 'class' => 'input-select custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'multi-select-type', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field, $key_values);
            $this->wp_customize_js();
        } else {
            $html = '<legend class="customize-control-title"><span>' . stripslashes($this->field->title) . '</span></legend>';
            $html .= '<select multiple class="input-select custom-data-type" ' . $section . ' data-type="multi-select-type" ' . parent::add_data_conditional_display($this->field) . ' name="' . $this->field->alias . '[]" size="5" style="height: 103px;">';
            $value = $vals != null ? $this->field->saved : $this->get_value();
            if (isset($this->field->value[$this->field->alias]) && isset($this->field->value[$this->field->alias]) && isset($this->field->value) && array_key_exists('field_types', $this->field->value)) {
                $value = $this->field->value[$this->field->alias];
            }
            $key_values = apply_filters($this->field->alias . '_data_options', $key_values);
            // allow filters to alter values
            $html .= '<option value="no">' . __('No value', 'framework') . '</option>';
            foreach ($key_values as $key => $val) {
                if (is_array($value)) {
                    $checked = in_array($key, $value) ? ' selected="selected"' : '';
                } else {
                    $checked = '';
                }
                if ($val != '') {
                    $html .= '<option value="' . $key . '"' . $checked . '>' . stripslashes($val) . '</option>';
                }
            }
            $html .= '</select>';
            echo $html;
            /* dirty hack to make multiple elms on customize.php page */
            if ($this->is_customize_theme_page) {
                ?>

			<script type="text/javascript">

				(function($){
					$('body').on('click', 'select[name^="<?php 
                echo esc_js($this->field->alias);
                ?>
"] option', function(){
						var values_array = [];
						$(this).parent().children("option:selected").each(function(){
							values_array.push($(this).val());
						});
						
						var api = wp.customize;
						api.instance('<?php 
                echo esc_js($this->field->alias);
                ?>
').set(values_array);
					});
				})(jQuery);

			</script>
		<?php 
            }
            /* dirty hack to make multiple elms on customize.php page */
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #9
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
        }
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
        $customize_title = stripslashes($this->field->title);
        ?>
		
		<legend class='customize-control-title'><span><?php 
        echo $customize_title;
        ?>
</span></legend>
		
		<?php 
        if (isset($this->field->editorType) && $this->field->editorType === 'ace') {
            ?>
		
		<div id="<?php 
            echo $this->field->alias;
            ?>
" class="code-editor" 
		     style="<?php 
            echo isset($this->field->editorWidth) ? 'width: ' . $this->field->editorWidth . 'px; ' : ' ';
            ?>
 
			    <?php 
            echo isset($this->field->editorHeight) ? 'height: ' . $this->field->editorHeight . 'px; ' : '';
            ?>
"><?php 
            echo is_string($value) ? $value : '';
            ?>
</div>
		<input  type="hidden" 
			class="code-editor<?php 
            echo " " . $this->field->cssClass;
            ?>
 custom-data-type ace_editor"
			name="<?php 
            echo $this->field->alias;
            ?>
" 
			<?php 
            $this->link();
            ?>
			id="hidden-<?php 
            echo $this->field->alias;
            ?>
"
			<?php 
            echo $section;
            ?>
			value="<?php 
            echo is_string($value) ? $value : '';
            ?>
"
			data-type='code-editor'/>
			<script>
				jQuery(document).ready(function() {
					var editor = ace.edit("<?php 
            echo $this->field->alias;
            ?>
");
					
					<?php 
            if (isset($this->field->enableVim) && ($this->field->enableVim === 'true' || $this->field->enableVim === true)) {
                ?>
					ace.require("ace/lib/net").loadScript("https://rawgithub.com/ajaxorg/ace-builds/master/src-min-noconflict/keybinding-vim.js", 
					function() { 
					    e = document.querySelector("#<?php 
                echo $this->field->alias;
                ?>
").env.editor; 
					    e.setKeyboardHandler(ace.require("ace/keyboard/vim").handler); 
					});
					<?php 
            }
            ?>
					
					editor.setTheme("ace/theme/chrome");
					editor.getSession().setMode("ace/mode/<?php 
            echo isset($this->field->editorLanguage) ? strtolower($this->field->editorLanguage) : 'javascript';
            ?>
");
					editor.getSession().on('change', function(e) {
						var editor = ace.edit("<?php 
            echo $this->field->alias;
            ?>
");
						var code = editor.getSession().getValue();
						jQuery('#hidden-<?php 
            echo $this->field->alias;
            ?>
').val(code);
					}); 
				});
			</script>
		<?php 
            $this->wp_customize_js();
        } else {
            ?>
			<textarea id="<?php 
            echo $this->field->alias;
            ?>
" class="code-editor<?php 
            echo " " . $this->field->cssClass;
            ?>
 custom-data-type"
			<?php 
            $this->link();
            ?>
			name="<?php 
            echo $this->field->alias;
            ?>
"
			<?php 
            echo $section;
            ?>
			data-type='code-editor' <?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
 ><?php 
            echo is_string($value) ? $value : '';
            ?>
</textarea>
		<?php 
        }
        ?>
		<?php 
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #10
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            $this->field->values = preg_replace("/\\r\\n|\\n|\\r/", '\\n\\r', $this->field->values);
        }
        ?>

		<script type="text/javascript">
			(function($) {
				$('body').on('click', '.radio-image', function(){
					$(this).siblings('div').removeClass('checked');
					$(this).addClass('checked');
				});
			})(jQuery);
		</script>
		<?php 
        $value = $vals != null ? $this->field->saved : $this->get_value();
        if (is_array($value) && isset($value[0])) {
            $value = $value[0];
        }
        $key_values = array();
        $comments = array();
        if (isset($this->field->values) && !empty($this->field->values)) {
            if (strstr($this->field->values, "\r\n")) {
                $rows = explode("\r\n", $this->field->values);
            } else {
                $rows = explode("\\r\\n", $this->field->values);
            }
            foreach ($rows as $v) {
                if ($v != '') {
                    $v = htmlspecialchars_decode($v);
                    $this->field->values = explode('=>', $v);
                    if (count($this->field->values) == 1) {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[0];
                    } else {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[1];
                    }
                }
            }
        }
        $name = $this->field->alias;
        $vars = $key_values;
        $checked = 1;
        $customize_title = stripslashes($this->field->title);
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            ?>
			<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
			<?php 
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            } else {
                if (!is_array($this->field->value) && is_string($this->field->value)) {
                    $tmp_arr = array();
                    $tmp_arr[] = $this->field->value;
                    $this->field->value = $tmp_arr;
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            $len = count($vars);
            $vars = apply_filters($this->field->alias . '_data_options', $vars);
            for ($key_val = 0; $key_val < $count; $key_val++) {
                $cnt = 0;
                $html = "<div class='radio_group_image'>";
                foreach ($vars as $key => $val) {
                    $cnt++;
                    $checked = isset($this->field->value[$key_val]) && $key == trim($this->field->value[$key_val]) ? 'checked="checked"' : '';
                    $class = 'radio-image';
                    if ($checked != '') {
                        $class .= ' checked';
                    }
                    $image_size = isset($this->field->image_size) ? $this->field->image_size : '';
                    $comment = isset($comments[$key]) ? $comments[$key] : '';
                    $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
                    $html .= "\n\t\t\t\t\t\t<div style='width: {$image_size}px; vertical-align: middle; display: inline-block; text-align: center; vertical-align: top;' class='" . stripslashes($class) . "'>\n\t\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t\t<dt class='wp-caption-dt'>\n\t\t\t\t\t\t\t\t\t<img src='" . stripslashes($val) . "' width='{$image_size}' height='" . $image_size . "'>\n\t\t\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t\t\t<p>" . stripslashes($comment) . "</p>\n\t\t\t\t\t\t\t\t<input " . $this->get_link() . " class='input-radio custom-data-type' " . $section . " data-type='radio-buttons-image' type='radio' name='" . $this->field->alias . "[" . $key_val . "]' value='{$key}' {$checked} style='display: none;'/>\n\t\t\t\t\t\t\t</label>\n\t\t\t\t\t\t</div>";
                }
                echo $html . "</div>";
                ?>
					<a href="#" class="delete_radio_image_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br><br>
				<?php 
            }
            $field = array('field_name' => $this->field->alias, 'start_number' => $count, 'type' => 'radio', 'class' => 'input-radio custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'radio-buttons', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field, $key_values);
            $this->wp_customize_js();
        } else {
            $html = "";
            $set = $value;
            if (!isset($set) || empty($set)) {
                $set = $checked;
            }
            $vars = apply_filters($this->field->alias . '_data_options', $vars);
            // allow filters to alter values
            foreach ($vars as $key => $val) {
                $checked = $key == $set ? ' checked="checked"' : '';
                $class = 'radio-image';
                if ($checked != '') {
                    $class .= ' checked';
                }
                $image_size = isset($this->field->image_size) ? $this->field->image_size : '';
                $comment = isset($comments[$key]) ? $comments[$key] : '';
                $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . $this->page->section . '"' : '';
                $html .= "\n\t\t\t\t\t<div style='width: {$image_size}px; vertical-align: middle; display: inline-block; text-align: center; vertical-align: top;' class='" . stripslashes($class) . "'>\n\t\t\t\t\t\t<label>\n\t\t\t\t\t\t\t<dt class='wp-caption-dt'>\n\t\t\t\t\t\t\t\t<img src='" . stripslashes($val) . "' width='{$image_size}' height='" . $image_size . "'>\n\t\t\t\t\t\t\t</dt>\n\t\t\t\t\t\t\t<p>" . stripslashes($comment) . "</p>\n\t\t\t\t\t\t\t<input " . $this->get_link() . " class='input-radio custom-data-type' " . parent::add_data_conditional_display($this->field) . ' ' . $section . " data-type='radio-buttons-image' type='radio' name='" . $this->field->alias . "' value='{$key}' {$checked} style='display: none;'/>\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</div>";
            }
            $title = isset($title) ? $title : '';
            $html = '<fieldset><legend class="screen-reader-text"><span>' . stripslashes($title) . '</span></legend><legend class="customize-control-title"><span>' . $customize_title . '</span></legend>' . stripslashes($html) . '</fieldset>';
            echo $html;
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #11
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            extract($vals);
        }
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        ?>

	<label>
		<div class="customize-control-content">
		<?php 
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
				<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
			<?php 
            for ($key = 0; $key < $count; $key++) {
                if (isset($this->field->value) && is_array($this->field->value)) {
                    $repeat_value = isset($this->field->value[$key]) ? $this->field->value[$key] : '';
                } else {
                    $repeat_value = "";
                }
                ?>
				<input class="color-picker-hex custom-data-type" <?php 
                echo $section;
                // escaped above
                ?>
 
					data-type="colorpicker-type" type="text" maxlength="7" <?php 
                $this->link();
                ?>
 
					name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]" 
					value="<?php 
                echo isset($repeat_value) && $repeat_value != '' ? esc_attr($repeat_value) : '';
                ?>
" />
				<a href="#" class="delete_colorpicker_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
				<?php 
            }
            $field = array('field_name' => $this->field->alias, 'type' => 'text', 'class' => 'color-picker-hex custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'colorpicker-type', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field);
            $this->wp_customize_js();
            ?>
			<script type="text/javascript">
				(function () {

					var name = '<?php 
            echo esc_js($this->field->alias);
            ?>
';

					jQuery(function () {

						jQuery('.color-picker-hex.custom-data-type').wpColorPicker({ change: function () {

							setTimeout(function () {

								jQuery('.color-picker-hex.custom-data-type').trigger('change');

							}, 50);

						}});

					});

				})();
			</script>
		<?php 
        } else {
            $input_value = $vals != null ? $this->field->saved : $this->get_value();
            if (!is_string($input_value) && !is_numeric($input_value)) {
                if (is_array($input_value) && isset($input_value[0])) {
                    $input_value = $input_value[0];
                } else {
                    $input_value = "";
                }
            }
            ?>
			<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
			<input class="color-picker-hex custom-data-type" <?php 
            echo $section;
            // escaped above
            ?>
 data-type="colorpicker-type" <?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
 type="text" maxlength="7" <?php 
            $this->link();
            ?>
 name="<?php 
            echo esc_attr($this->field->alias);
            ?>
" value="<?php 
            echo esc_attr($input_value);
            ?>
" />
			<script type="text/javascript">
				(function () {

					var name = '<?php 
            echo esc_js($this->field->alias);
            ?>
';
 					var default_val = '<?php 
            echo esc_js($this->field->values);
            ?>
';

					jQuery(document).ready(function($) {
                        default_val = (default_val) ? default_val : false;
						$('input.color-picker-hex[name="'+name+'"]').keydown(function (e) {
						    if (e.keyCode == 13) {
						    	e.preventDefault();
						    }
						});                        
                        $('input[name="'+name+'"]').wpColorPicker({ 
                            change: function (event, ui) {
                                var hexcolor = $(this).wpColorPicker( 'color' );
                                $('[name="'+name+'"]').attr('value', hexcolor).trigger('change');
                            },
                            clear: function() { 
                              $('[name="'+name+'"]').attr('value', '');
                              if ( wp.customize ) {
                                var alias = name.replace(/\[\d*\]$/, "");
                                var api = wp.customize;
                                api.instance(alias).set($('input[name="'+alias+'"]').val());
                              }
                            },
                            defaultColor: default_val
                        });
                    });

				})();
			</script>
		<?php 
        }
        ?>
		</div>
	</label> <?php 
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #12
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
        }
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        $customize_title = stripslashes($this->field->title);
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            } else {
                if (!is_array($this->field->value) && is_string($this->field->value)) {
                    $tmp_arr = array();
                    $tmp_arr[] = $this->field->value;
                    $this->field->value = $tmp_arr;
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
			<legend class='customize-control-title'><span><?php 
            echo $customize_title;
            ?>
</span></legend>
			<?php 
            for ($key = 0; $key < $count; $key++) {
                ?>
				<textarea
					class="input-textarea<?php 
                echo " " . $this->field->cssClass;
                ?>
 custom-data-type"
					<?php 
                $this->link();
                ?>
					name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]"
					<?php 
                echo $section;
                // escaped above
                ?>
					data-type='textarea-image'><?php 
                echo isset($this->field->value[$key]) && is_string($this->field->value[$key]) ? $this->field->value[$key] : '';
                ?>
</textarea>
				<a href="#" class="delete_textarea_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
			<?php 
            }
            $field = array('field_name' => $this->field->alias, 'class' => 'input-textarea ' . $this->field->cssClass . ' custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'textarea-image', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field);
            $this->wp_customize_js();
        } else {
            ?>
			<legend class='customize-control-title'><span><?php 
            echo $customize_title;
            ?>
</span></legend>
				<textarea
					class="input-textarea<?php 
            echo " " . $this->field->cssClass;
            ?>
 custom-data-type"
					<?php 
            $this->link();
            ?>
 
					<?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
					name="<?php 
            echo esc_attr($this->field->alias);
            ?>
"
					<?php 
            echo $section;
            // escaped above
            ?>
					data-type='textarea-image'><?php 
            echo is_string($value) ? html_entity_decode(esc_textarea($value)) : '';
            ?>
</textarea><?php 
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #13
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
        }
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $this->get_value();
            if (isset($this->field->value) && is_array($this->field->value)) {
                foreach ($this->field->value as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($this->field->value[$key]);
                    }
                }
            }
            $count = isset($this->field->value) ? count((array) $this->field->value) : 1;
            if ($count == 0) {
                $count = 1;
            }
            ?>
		<fieldset>
			<legend class="customize-control-title"><span><?php 
            echo stripslashes($this->field->title);
            ?>
</span></legend>
                        
		<?php 
            for ($key = 0; $key < $count; $key++) {
                ?>
			<input <?php 
                $this->link();
                ?>
 class="input-check custom-data-type" <?php 
                echo $section;
                // escaped above
                ?>
 data-type="checkbox-bool-type" type="checkbox" value="true" name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]" <?php 
                if (isset($this->field->value[$key]) && $this->field->value[$key] == 'true') {
                    echo 'checked ';
                }
                ?>
 /> 
			<span class="field_label"><?php 
                _e('Yes', 'framework');
                ?>
</span>
                                
			<a href="#" class="delete_checkbox_bool_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
		<?php 
            }
            ?>
        
		<?php 
            $field = array('field_name' => $this->field->alias, 'type' => 'checkbox', 'class' => 'input-check custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'checkbox-bool-type', 'after_field' => __('Yes', 'framework'));
            $this->enable_repeating($field);
            $this->wp_customize_js();
            ?>
		</fieldset>
		<?php 
        } else {
            ?>
			<fieldset>
				<legend class="customize-control-title"><span><?php 
            echo __(stripslashes($this->field->title), 'framework');
            ?>
</span></legend>
				<input type="hidden" value="false" name="<?php 
            echo esc_attr($this->field->alias);
            ?>
"  />
				<label>
					<input <?php 
            $this->link();
            ?>
 class="input-check custom-data-type" <?php 
            echo $section;
            // escaped above
            ?>
 data-type="checkbox-bool-type" <?php 
            echo parent::add_data_conditional_display($this->field);
            ?>
 type="checkbox" value="true" name="<?php 
            echo esc_attr($this->field->alias);
            ?>
" <?php 
            if ($this->get_value() == 'true' || $this->get_value() === true || $this->get_value() === '1') {
                echo 'checked ';
            }
            ?>
 /> <?php 
            _e('Yes', 'framework');
            ?>
				</label>
			</fieldset> 
		<?php 
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }
コード例 #14
0
    public function render_content($vals = null)
    {
        do_action(self::$type_slug . '_before_render_content', $this);
        if ($vals != null) {
            $this->field = (object) $vals;
            $this->field->values = preg_replace("/\\r\\n|\\n|\\r/", '\\n\\r', $this->field->values);
        }
        $value = $vals != null ? $this->field->saved : $this->get_value();
        $key_values = array();
        if (isset($this->field->values) && !empty($this->field->values)) {
            if (is_array($this->field->values)) {
                $this->field->values = "";
            }
            if (strstr($this->field->values, "\r\n")) {
                $rows = explode("\r\n", $this->field->values);
            } else {
                $rows = explode("\\r\\n", $this->field->values);
            }
            foreach ($rows as $v) {
                if ($v != '') {
                    $v = htmlspecialchars_decode($v);
                    $this->field->values = explode('=>', $v);
                    if (count($this->field->values) == 1) {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[0];
                    } else {
                        $key = str_replace(' ', '-', trim(strtolower($this->field->values[0])));
                        $key_values[$key] = $this->field->values[1];
                    }
                }
            }
        }
        $vals = $value;
        $key_values = apply_filters($this->field->alias . '_data_options', $key_values);
        // allow filters to alter values
        $section = isset($this->page->section) && $this->page->section != '' ? 'data-section="' . esc_attr($this->page->section) . '"' : '';
        $customize_title = stripslashes($this->field->title);
        ?>
		<legend class='customize-control-title'><span><?php 
        echo $customize_title;
        ?>
</span></legend>
                <?php 
        if (isset($this->field->repeating) && $this->field->repeating == 'Yes') {
            $vals = isset($this->field->value) ? $this->field->value : array();
            if (isset($vals) && is_array($vals)) {
                foreach ($vals as $key => $tmp_value) {
                    if (is_string($key)) {
                        unset($vals[$key]);
                    }
                }
            }
            $count = isset($vals) ? count((array) $vals) : 1;
            if ($count == 0) {
                $count = 1;
            }
            for ($key = 0; $key < $count; $key++) {
                ?>
			<select <?php 
                $this->link();
                ?>
				class='input-select custom-data-type'
				<?php 
                echo $section;
                // escaped above
                ?>
				data-type='select-type'
				name="<?php 
                echo esc_attr($this->field->alias);
                ?>
[]">
			<?php 
                foreach ($key_values as $select_value_key => $val) {
                    $html = "";
                    if ($val == 'OPTION_GROUP_START' || $val == 'OPTION_GROUP_END') {
                        $html .= $val == 'OPTION_GROUP_START' ? '<optgroup label="' . $select_value_key . '">' : '</optgroup>';
                    } else {
                        if ($vals[$key] == trim($select_value_key)) {
                            $checked = ' selected="selected"';
                        } else {
                            $checked = '';
                        }
                        $html .= '<option value="' . $select_value_key . '" ' . $checked . '>' . stripslashes($val) . '</option>';
                    }
                    echo $html;
                }
                ?>
			</select>
			<a href="#" class="delete_select_field"><?php 
                echo __('Delete', 'framework');
                ?>
</a><br>
			<?php 
            }
            $field = array('field_name' => $this->field->alias, 'type' => 'select', 'class' => 'input-select custom-data-type', 'data_section' => isset($this->page->section) ? $this->page->section : '', 'data_type' => 'select-type', 'after_field' => '', 'value' => '#');
            $this->enable_repeating($field, $key_values);
            $this->wp_customize_js();
        } else {
            $html = "<select " . $this->get_link() . " class='input-select custom-data-type' " . parent::add_data_conditional_display($this->field) . " {$section} data-type='select-type' name='{$this->field->alias}'>";
            foreach ($key_values as $key => $val) {
                if ($val == 'OPTION_GROUP_START' || $val == 'OPTION_GROUP_END') {
                    $html .= $val == 'OPTION_GROUP_START' ? '<optgroup label="' . $key . '">' : '</optgroup>';
                } else {
                    $checked = is_string($vals) && $key == trim($vals) ? ' selected="selected"' : '';
                    $html .= '<option value="' . $key . '" ' . $checked . '>' . stripslashes($val) . '</option>';
                }
            }
            $html .= '</select>';
            echo $html;
        }
        do_action(self::$type_slug . '_after_render_content', $this);
    }