/** * Render html UI_Background. * * @since 4.0.0 */ public function render() { $html = ''; $background_options = array('repeat' => array('no-repeat' => __('No repeat', 'cherry'), 'repeat' => __('Repeat All', 'cherry'), 'repeat-x' => __('Repeat Horizontally', 'cherry'), 'repeat-y' => __('Repeat Vertically', 'cherry')), 'position' => array('top-left' => __('Top Left', 'cherry'), 'top' => __('Top Center', 'cherry'), 'right-top' => __('Top Right', 'cherry'), 'left' => __('Middle Left', 'cherry'), 'center' => __('Middle Center', 'cherry'), 'right' => __('Middle Right', 'cherry'), 'bottom-left' => __('Bottom Left', 'cherry'), 'bottom' => __('Bottom Center', 'cherry'), 'bottom-right' => __('Bottom Right', 'cherry')), 'attachment' => array('notdefined' => __('Not defined', 'cherry'), 'scroll' => __('Scroll Normally', 'cherry'), 'fixed' => __('Fixed in Place', 'cherry')), 'clip' => array('notdefined' => __('Not defined', 'cherry'), 'padding-box' => __('Padding box', 'cherry'), 'border-box' => __('Border box', 'cherry'), 'content-box' => __('Content box', 'cherry')), 'size' => array('notdefined' => __('Not defined', 'cherry'), 'auto' => __('Auto', 'cherry'), 'cover' => __('Cover', 'cherry'), 'contain' => __('Contain', 'cherry')), 'origin' => array('notdefined' => __('Not defined', 'cherry'), 'padding-box' => __('Padding box', 'cherry'), 'border-box' => __('Border box', 'cherry'), 'content-box' => __('Content box', 'cherry'))); $ui_media = new UI_Media(array('id' => $this->settings['id'] . '-image', 'name' => $this->settings['name'] . '[image]', 'value' => $this->settings['value']['image'], 'multi_upload' => $this->settings['multi_upload'], 'library_type' => $this->settings['library_type'])); $ui_colorpicker = new UI_Colorpicker(array('id' => $this->settings['id'] . '-color', 'name' => $this->settings['name'] . '[color]', 'value' => $this->settings['value']['color'])); $html .= '<div class="cherry-ui-background-wrap">'; $html .= '<div class="cherry-ui-background-media">'; $html .= $ui_media->render(); $html .= '</div>'; $html .= '<div class="cherry-ui-background-settings">'; $html .= '<label for="' . $this->settings['id'] . '-settings">' . __('Background Settings', 'cherry') . '</label> '; $html .= '<div class="cherry-ui-background-color">'; $html .= '<label for="' . $this->settings['id'] . '-color">' . __('Background Color', 'cherry') . '</label> '; $html .= $ui_colorpicker->render(); $html .= '</div>'; foreach ($background_options as $options_key => $options_settings) { if (isset($this->settings['value'][$options_key])) { $html .= '<div class="cherry-background-setting-item">'; $ui_select = new UI_Select(array('id' => $this->settings['id'] . '[' . $options_key . ']', 'name' => $this->settings['name'] . '[' . $options_key . ']', 'value' => $this->settings['value'][$options_key], 'options' => $options_settings)); $label = sprintf(__('Background %s', 'cherry'), $options_key); $html .= '<label for="' . $this->settings['id'] . '[$options_key]">' . $label . '</label> '; $html .= $ui_select->render(); $html .= '</div>'; } } $html .= '<div class="clear"></div>'; $html .= '</div>'; $html .= '</div>'; return $html; }
/** * Add form item. Returns form item with selected arguments. * * @since 4.0.0 * @param array $args Input argument name => argument value */ public function add_form_item($args = array()) { $default = array('class' => '', 'inline_style' => '', 'type' => '', 'value' => '', 'multiple' => false, 'max_value' => '100', 'min_value' => '0', 'step_value' => '1', 'default_value' => '', 'options' => '', 'placeholder' => '', 'upload_button_text' => __('Choose Media', 'cherry'), 'remove_button_text' => __('Remove Media', 'cherry'), 'return_data_type' => 'id', 'multi_upload' => true, 'display_image' => true, 'display_input' => true, 'library_type' => '', 'label' => '', 'title' => '', 'description' => '', 'hint' => '', 'toggle' => array('true_toggle' => __('On', 'cherry'), 'false_toggle' => __('Off', 'cherry'))); extract(array_merge($default, $args)); $value = $value == '' || $value == false && $value != 0 ? $default_value : $value; $item_id = $id; $name = $this->generate_field_name($id); $id = $this->generate_field_id($id); $item_inline_style = $inline_style ? 'style="' . $inline_style . '"' : ''; $output = ''; if (is_array($this->options['hidden_items']) && in_array($item_id, $this->options['hidden_items'])) { return; } switch ($type) { case 'submit': // $output .= '<input ' . $item_inline_style . ' class="' . $class . ' '.$this->options['class']['submit'].'" id="' . $id . '" name="' . $name . '" type="'.$type.'" value="' . esc_html( $value ) . '" >'; $type .= ' ' . $class; $item_inline_style .= ' id=' . $id; $output .= get_submit_button($value, $type, $name, false, $item_inline_style); break; case 'reset': $output .= '<input ' . $item_inline_style . ' class="' . $class . ' ' . $this->options['class']['submit'] . '" id="' . $id . '" name="' . $name . '" type="reset" value="' . esc_html($value) . '" >'; break; case 'text': $ui_text = new UI_Text(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class)); $output .= $ui_text->render(); break; case 'textarea': $ui_textarea = new UI_Textarea(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class)); $output .= $ui_textarea->render(); break; case 'select': $ui_select = new UI_Select(array('id' => $id, 'name' => $name, 'multiple' => $multiple, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_select->render(); break; case 'checkbox': $ui_checkbox = new UI_Checkbox(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_checkbox->render(); break; case 'radio': $ui_radio = new UI_Radio(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_radio->render(); break; case 'switcher': $ui_switcher = new UI_Switcher(array('id' => $id, 'name' => $name, 'value' => $value, 'toggle' => $toggle, 'class' => $class)); $output .= $ui_switcher->render(); break; case 'stepper': $ui_stepper = new UI_Stepper(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_stepper->render(); break; case 'slider': $ui_slider = new UI_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_slider->render(); break; case 'rangeslider': $ui_range_slider = new UI_Range_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class)); $output .= $ui_range_slider->render(); break; case 'colorpicker': $ui_colorpicker = new UI_Colorpicker(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_colorpicker->render(); break; case 'media': $ui_media = new UI_Media(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class)); $output .= $ui_media->render(); break; case 'background': $ui_background = new UI_Background(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class)); $output .= $ui_background->render(); break; case 'typography': $ui_typography = new UI_Typography(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_typography->render(); break; case 'ace-editor': $ui_ace_editor = new UI_Ace_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_ace_editor->render(); break; case 'repeater': $ui_repeater = new UI_Repeater(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_repeater->render(); break; case 'static_area_editor': $ui_statics = new UI_Static_Area_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class)); $output .= $ui_statics->render(); break; case 'layouteditor': $ui_layout_editor = new UI_Layout_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class)); $output .= $ui_layout_editor->render(); break; case 'editor': //$wrap = false; ob_start(); $settings = array('textarea_name' => $name, 'media_buttons' => 1, 'teeny' => 0, 'textarea_rows' => 10, 'tinymce' => array('setup' => 'function(ed) { ed.onChange.add(function(ed) { tinyMCE.triggerSave(); }); }')); wp_editor($value, $id, $settings); $output .= ob_get_clean(); _WP_Editors::editor_js(); _WP_Editors::enqueue_scripts(); break; } return $this->wrap_item($output, $id, 'cherry-section cherry-' . $type . ' ' . $this->options['class']['section'], $title, $label, $description, $hint); }