/** * 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); }
/** * * @since 4.0.0 */ public static function cherry_options_page_build() { global $cherry_options_framework; $option_inteface_builder = new Cherry_Interface_Builder(); $option_inteface_builder->enqueue_builder_scripts(); $option_inteface_builder->enqueue_builder_styles(); $section_index = 0; $cherry_options = $cherry_options_framework->get_current_settings(); $cherry_options = self::child_priority_sorting($cherry_options); $cherry_options = self::priority_sorting($cherry_options); ?> <?php settings_errors('cherry-options'); ?> <form id="cherry-options" class="cherry-ui-core" method="post"> <?php settings_fields('cherry-options'); ?> <input class="active-section-field" type="hidden" name="active_section" value=""> <div class="cherry-sections-wrapper"> <ul class="cherry-option-section-tab vertical-tabs_ vertical-tabs_width_mid_"> <?php foreach ($cherry_options as $section_key => $section_value) { $parent = !empty($section_value['parent']) ? $section_value['parent'] : ''; $parent !== '' ? $subClass = 'subitem' : ($subClass = ''); $priority_value = $section_value['priority']; ?> <li class="tabitem-<?php echo $section_index; ?> <?php echo $subClass; ?> <?php echo $parent; ?> " data-section-name="<?php echo $section_key; ?> "><a href="javascript:void(0)"><i class="<?php echo $section_value["icon"]; ?> "></i><span><?php echo $section_value["name"]; ?> </span></a></li> <?php $section_index++; } ?> </ul> <div class="cherry-option-group-list"></div> <div class="clear"></div> </div> <div class="cherry-submit-wrapper"> <div class="cherry-options-export-import"> <div class="wrap-cherry-import-options"> <a href="javascript:void(0)" id="cherry-export-import-options" class="button button-default_"> <?php _e('Export/Import', 'cherry'); ?> </a> </div> <div class="wrap-cherry-default-options-backup"> <a href="#" id="cherry-default-options-backup" class="button button-primary_"> <?php _e('Default options', 'cherry'); ?> <div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div> </a> </div> </div> <div id="wrap-cherry-save-options"> <a href="javascript:void(0)" id="cherry-save-options" class="button button-secondary_"> <?php echo __('Save options', 'cherry'); ?> <div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div> </a> </div> <div id="wrap-cherry-restore-section"> <a href="javascript:void(0)" id="cherry-restore-section" class="button button-primary_"> <?php echo __('Restore section', 'cherry'); ?> </a> </div> <div id="wrap-cherry-restore-options"> <a href="javascript:void(0)" id="cherry-restore-options" class="button button-primary_"> <?php echo __('Restore options', 'cherry'); ?> </a> </div> </div> </form> <div class="export-import-wrapper cherry-ui-core"> <div class="export-control"> <h4><?php _e('Export', 'cherry'); ?> </h4> <a href="<?php echo esc_url(self::$options_export_url); ?> " id="cherry-export-options" class="button button-default_"><?php _e('Export', 'cherry'); ?> </a> <?php wp_nonce_field('cherry_partial_export', 'partial-export-nonce', false); ?> <a href="javascript:void(0)" id="cherry-partial-export-options" class="button button-default_"><?php _e('Partial export', 'cherry'); ?> <div class="cherry-spinner-wordpress spinner-wordpress-type-3"><span class="cherry-inner-circle"></span></div></a> <div class="use-statics-wrap"> <?php $ui_checkbox = new UI_Checkbox(array('id' => 'cherry-export-use-static-setting', 'name' => 'cherry-export-use-static-setting', 'value' => array(), 'options' => array('use-statics' => __('Attach statics settings', 'cherry')), 'class' => 'cherry-export-use-static-setting')); echo $ui_checkbox->render(); ?> </div> </div> <div class="import-control"> <h4><?php _e('Import', 'cherry'); ?> </h4> <?php wp_nonce_field('cherry_import_options', 'import-options-nonce', false); ?> <input type="hidden" autocomplete="off" id="cherry-import-options-file-id" value=""> <input type="hidden" autocomplete="off" id="cherry-import-options-file-type" value=""> <a href="#" id="cherry-import-options-file" class="button button-default_"><?php _e('Select file', 'cherry'); ?> </a> <a href="#" id="cherry-import-options-start" class="button button-primary_"><?php _e('Start import', 'cherry'); ?> <div class="cherry-spinner-wordpress spinner-wordpress-type-2"><span class="cherry-inner-circle"></span></div></a> <div class="cherry-import-file-name"></div> </div> <div class="clear"></div> </div> <div id="restore-options-confirm" class="confirm-message" title="<?php echo __('Are you sure?', 'cherry'); ?> "> <span class="dashicons dashicons-info"></span> <p><?php echo __('Current options will be reset to the defaults, page will be refreshed.', 'cherry'); ?> </p> </div> <div id="restore-section-confirm" class="confirm-message" title="<?php echo __('Are you sure?', 'cherry'); ?> "> <span class="dashicons dashicons-info"></span> <p><?php echo __('Active section will be reset to the defaults, page will be refreshed.', 'cherry'); ?> </p> </div> <?php }