public function output()
 {
     echo $this->element_before();
     $value_defaults = array('image' => '', 'repeat' => '', 'position' => '', 'attachment' => '', 'size' => '', 'color' => '');
     $this->value = wp_parse_args($this->element_value(), $value_defaults);
     if (isset($this->field['settings'])) {
         extract($this->field['settings']);
     }
     $upload_type = isset($upload_type) ? $upload_type : 'image';
     $button_title = isset($button_title) ? $button_title : __('Upload', 'cs-framework');
     $frame_title = isset($frame_title) ? $frame_title : __('Upload', 'cs-framework');
     $insert_title = isset($insert_title) ? $insert_title : __('Use Image', 'cs-framework');
     echo '<div class="cs-field-upload">';
     echo '<input type="text" name="' . $this->element_name('[image]') . '" value="' . $this->value['image'] . '"' . $this->element_class() . $this->element_attributes() . '/>';
     echo '<a href="#" class="button cs-add" data-frame-title="' . $frame_title . '" data-upload-type="' . $upload_type . '" data-insert-title="' . $insert_title . '">' . $button_title . '</a>';
     echo '</div>';
     // background attributes
     echo '<fieldset>';
     echo cs_add_element(array('pseudo' => true, 'type' => 'select', 'name' => $this->element_name('[repeat]'), 'options' => array('' => 'repeat', 'repeat-x' => 'repeat-x', 'repeat-y' => 'repeat-y', 'no-repeat' => 'no-repeat', 'inherit' => 'inherit'), 'attributes' => array('data-atts' => 'repeat'), 'value' => $this->value['repeat']));
     echo cs_add_element(array('pseudo' => true, 'type' => 'select', 'name' => $this->element_name('[position]'), 'options' => array('' => 'left top', 'left center' => 'left center', 'left bottom' => 'left bottom', 'right top' => 'right top', 'right center' => 'right center', 'right bottom' => 'right bottom', 'center top' => 'center top', 'center center' => 'center center', 'center bottom' => 'center bottom'), 'attributes' => array('data-atts' => 'position'), 'value' => $this->value['position']));
     echo cs_add_element(array('pseudo' => true, 'type' => 'select', 'name' => $this->element_name('[attachment]'), 'options' => array('' => 'scroll', 'fixed' => 'fixed'), 'attributes' => array('data-atts' => 'attachment'), 'value' => $this->value['attachment']));
     echo cs_add_element(array('pseudo' => true, 'type' => 'select', 'name' => $this->element_name('[size]'), 'options' => array('' => 'size', 'cover' => 'cover', 'contain' => 'contain', 'inherit' => 'inherit', 'initial' => 'initial'), 'attributes' => array('data-atts' => 'size'), 'value' => $this->value['size']));
     echo cs_add_element(array('pseudo' => true, 'id' => $this->field['id'] . '_color', 'type' => 'color_picker', 'name' => $this->element_name('[color]'), 'attributes' => array('data-atts' => 'bgcolor'), 'value' => $this->value['color'], 'default' => isset($this->field['default']['color']) ? $this->field['default']['color'] : '', 'rgba' => isset($this->field['rgba']) && $this->field['rgba'] === false ? false : ''));
     echo '</fieldset>';
     echo $this->element_after();
 }
Esempio n. 2
0
 public function render_content()
 {
     $this->options['id'] = $this->id;
     $this->options['default'] = $this->setting->default;
     $this->options['attributes']['data-customize-setting-link'] = $this->settings['default']->id;
     echo cs_add_element($this->options, $this->value(), $this->unique);
 }
 public function output()
 {
     echo $this->element_before();
     $last_id = is_array($this->value) ? max(array_keys($this->value)) : 0;
     $acc_title = isset($this->field['accordion_title']) ? $this->field['accordion_title'] : __('Adding', 'cs-framework');
     $field_title = isset($this->field['fields'][0]['title']) ? $this->field['fields'][0]['title'] : $this->field['fields'][1]['title'];
     $field_id = isset($this->field['fields'][0]['id']) ? $this->field['fields'][0]['id'] : $this->field['fields'][1]['id'];
     $search_id = cs_array_search($this->field['fields'], 'id', $acc_title);
     if (!empty($search_id)) {
         $acc_title = isset($search_id[0]['title']) ? $search_id[0]['title'] : $acc_title;
         $field_id = isset($search_id[0]['id']) ? $search_id[0]['id'] : $field_id;
     }
     echo '<div class="cs-group hidden">';
     echo '<h4 class="cs-group-title">' . $acc_title . '</h4>';
     echo '<div class="cs-group-content">';
     foreach ($this->field['fields'] as $field_key => $field) {
         $field['sub'] = true;
         $unique = $this->unique . '[_nonce][' . $this->field['id'] . '][' . $last_id . ']';
         $field_default = isset($field['default']) ? $field['default'] : '';
         echo cs_add_element($field, $field_default, $unique);
     }
     echo '<div class="cs-element cs-text-right"><a href="#" class="button cs-warning-primary cs-remove-group">' . __('Remove', 'cs-framework') . '</a></div>';
     echo '</div>';
     echo '</div>';
     echo '<div class="cs-groups cs-accordion">';
     if (!empty($this->value)) {
         foreach ($this->value as $key => $value) {
             $title = isset($this->value[$key][$field_id]) ? $this->value[$key][$field_id] : '';
             if (is_array($title) && isset($this->multilang)) {
                 $lang = cs_language_defaults();
                 $title = $title[$lang['current']];
                 $title = is_array($title) ? $title[0] : $title;
             }
             $field_title = !empty($search_id) ? $acc_title : $field_title;
             echo '<div class="cs-group">';
             echo '<h4 class="cs-group-title">' . $field_title . ': ' . $title . '</h4>';
             echo '<div class="cs-group-content">';
             foreach ($this->field['fields'] as $field_key => $field) {
                 $field['sub'] = true;
                 $unique = $this->unique . '[' . $this->field['id'] . '][' . $key . ']';
                 $value = isset($field['id']) && isset($this->value[$key][$field['id']]) ? $this->value[$key][$field['id']] : '';
                 echo cs_add_element($field, $value, $unique);
             }
             echo '<div class="cs-element cs-text-right"><a href="#" class="button cs-warning-primary cs-remove-group">' . __('Remove', 'cs-framework') . '</a></div>';
             echo '</div>';
             echo '</div>';
         }
     }
     echo '</div>';
     echo '<a href="#" class="button button-primary cs-add-group">' . $this->field['button_title'] . '</a>';
     echo $this->element_after();
 }
Esempio n. 4
0
 public function output()
 {
     echo $this->element_before();
     echo '<div class="cs-inner">';
     foreach ($this->field['fields'] as $field) {
         $field_id = isset($field['id']) ? $field['id'] : '';
         $field_value = isset($this->value[$field_id]) ? $this->value[$field_id] : '';
         $unique_id = $this->unique . '[' . $this->field['id'] . ']';
         echo cs_add_element($field, $field_value, $unique_id);
     }
     echo '</div>';
     echo $this->element_after();
 }
 public function render_taxonomy_form_fields($term)
 {
     global $cs_errors;
     $form_edit = is_object($term) && isset($term->taxonomy) ? true : false;
     $taxonomy = $form_edit ? $term->taxonomy : $term;
     $classname = $form_edit ? 'edit' : 'add';
     $cs_errors = get_transient('cs-taxonomy-transient');
     wp_nonce_field('cs-taxonomy', 'cs-taxonomy-nonce');
     echo '<div class="cs-framework cs-taxonomy cs-taxonomy-' . $classname . '-fields">';
     foreach ($this->options as $option) {
         if ($taxonomy == $option['taxonomy']) {
             $tax_value = $form_edit ? get_term_meta($term->term_id, $option['id'], true) : '';
             foreach ($option['fields'] as $field) {
                 $default = isset($field['default']) ? $field['default'] : '';
                 $elem_id = isset($field['id']) ? $field['id'] : '';
                 $elem_value = is_array($tax_value) && isset($tax_value[$elem_id]) ? $tax_value[$elem_id] : $default;
                 echo cs_add_element($field, $elem_value, $option['id']);
             }
         }
     }
     echo '</div>';
 }
 public function field_callback($field)
 {
     $value = isset($field['id']) && isset($this->get_option[$field['id']]) ? $this->get_option[$field['id']] : '';
     echo cs_add_element($field, $value, $this->unique);
 }
 public function shortcode_generator()
 {
     if (!isset($_REQUEST['shortcode'])) {
         die;
     }
     $request = $_REQUEST['shortcode'];
     $shortcode = $this->shortcodes[$request];
     if (isset($shortcode['fields'])) {
         foreach ($shortcode['fields'] as $key => $field) {
             if (isset($field['id'])) {
                 $field['attributes'] = isset($field['attributes']) ? wp_parse_args(array('data-atts' => $field['id']), $field['attributes']) : array('data-atts' => $field['id']);
             }
             $field_default = isset($field['default']) ? $field['default'] : '';
             if (in_array($field['type'], array('image_select', 'checkbox')) && isset($field['options'])) {
                 $field['attributes']['data-check'] = true;
             }
             echo cs_add_element($field, $field_default, 'shortcode');
         }
     }
     if (isset($shortcode['clone_fields'])) {
         $clone_id = isset($shortcode['clone_id']) ? $shortcode['clone_id'] : $shortcode['name'];
         echo '<div class="cs-shortcode-clone" data-clone-id="' . $clone_id . '">';
         echo '<a href="#" class="cs-remove-clone"><i class="fa fa-trash"></i></a>';
         foreach ($shortcode['clone_fields'] as $key => $field) {
             $field['sub'] = true;
             $field['attributes'] = isset($field['attributes']) ? wp_parse_args(array('data-clone-atts' => $field['id']), $field['attributes']) : array('data-clone-atts' => $field['id']);
             $field_default = isset($field['default']) ? $field['default'] : '';
             if (in_array($field['type'], array('image_select', 'checkbox')) && isset($field['options'])) {
                 $field['attributes']['data-check'] = true;
             }
             echo cs_add_element($field, $field_default, 'shortcode');
         }
         echo '</div>';
         echo '<div class="cs-clone-button"><a id="shortcode-clone-button" class="button" href="#"><i class="fa fa-plus-circle"></i> ' . $shortcode['clone_title'] . '</a></div>';
     }
     die;
 }
 function form($instance)
 {
     //
     // 设置默认值
     // -------------------------------------------------
     $instance = wp_parse_args($instance, array('title' => '支付宝', 'accounts' => '', 'money' => '', 'caption' => '', 'remark' => '', 'background' => ''));
     //
     // 标题
     // -------------------------------------------------
     $text_value = esc_attr($instance['title']);
     $text_field = array('id' => $this->get_field_name('title'), 'name' => $this->get_field_name('title'), 'type' => 'text', 'title' => '标题');
     echo cs_add_element($text_field, $text_value);
     //
     // 账户
     // -------------------------------------------------
     $text_value = esc_attr($instance['accounts']);
     $text_field = array('id' => $this->get_field_name('accounts'), 'name' => $this->get_field_name('accounts'), 'type' => 'text', 'title' => '账户');
     echo cs_add_element($text_field, $text_value);
     //
     // 金额
     // -------------------------------------------------
     $number_value = esc_attr($instance['money']);
     $number_field = array('id' => $this->get_field_name('money'), 'name' => $this->get_field_name('money'), 'type' => 'number', 'title' => '金额');
     echo cs_add_element($number_field, $number_value);
     //
     // 说明
     // -------------------------------------------------
     $text_value = esc_attr($instance['caption']);
     $text_field = array('id' => $this->get_field_name('caption'), 'name' => $this->get_field_name('caption'), 'type' => 'text', 'title' => '说明');
     echo cs_add_element($text_field, $text_value);
     //
     // 备注
     // -------------------------------------------------
     $textarea_value = esc_attr($instance['remark']);
     $textarea_field = array('id' => $this->get_field_name('remark'), 'name' => $this->get_field_name('remark'), 'type' => 'textarea', 'title' => '备注');
     echo cs_add_element($textarea_field, $textarea_value);
     //
     // 按钮图片
     // -------------------------------------------------
     $upload_value = esc_attr($instance['background']);
     $upload_field = array('id' => $this->get_field_name('background'), 'name' => $this->get_field_name('background'), 'type' => 'upload', 'title' => '按钮图片');
     echo cs_add_element($upload_field, $upload_value);
 }
Esempio n. 9
0
 public function render_meta_box_content($post, $callback)
 {
     global $post, $cs_errors;
     wp_nonce_field('cs-framework-metabox', 'cs-framework-metabox-nonce');
     $unique = $callback['args']['id'];
     $sections = $callback['args']['sections'];
     $meta_value = get_post_meta($post->ID, $unique, true);
     $transient = get_transient('cs-metabox-transient');
     $cs_errors = $transient['errors'];
     $has_nav = count($sections) >= 2 && $callback['args']['context'] != 'side' ? true : false;
     $show_all = !$has_nav ? ' cs-show-all' : '';
     $section_name = !empty($sections[0]['fields']) ? $sections[0]['name'] : $sections[1]['name'];
     $section_id = !empty($transient['ids'][$unique]) ? $transient['ids'][$unique] : $section_name;
     $section_id = !empty($_GET['cs-section']) ? esc_attr($_GET['cs-section']) : $section_id;
     $type_box = $callback['args']['type_box'];
     $type_box_string = "";
     if (!empty($type_box)) {
         foreach ($type_box as $key => $sub_type_box) {
             switch ($sub_type_box['type']) {
                 case 'checkbox':
                     $type_box_string .= '<label for="' . esc_attr($sub_type_box['id']) . '" class="' . esc_attr($sub_type_box['wrapper_class']) . ' tips">' . esc_html($sub_type_box['title']) . ': <input type="checkbox" name="' . esc_attr($sub_type_box['id']) . '" id="' . esc_attr($sub_type_box['id']) . '" /></label>';
                     break;
                 case 'select':
                     $type_box_string .= '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . $sub_type_box['optgroup'] . '">';
                     foreach ($sub_type_box['select_options'] as $value => $label) {
                         $type_box_string .= '<option value="' . esc_attr($value) . '" >' . esc_html($label) . '</option>';
                     }
                     $type_box_string .= '</optgroup></select></label>';
                     break;
                 default:
                     break;
             }
         }
         echo '  <span class="type_box"> &mdash; ' . $type_box_string . '</span>';
     }
     echo '<div class="cs-framework cs-metabox-framework">';
     echo '<input type="hidden" name="cs_section_id[' . $unique . ']" class="cs-reset" value="' . $section_id . '">';
     echo '<div class="cs-body' . $show_all . '">';
     if ($has_nav) {
         echo '<div class="cs-nav">';
         echo '<ul>';
         foreach ($sections as $value) {
             $tab_icon = !empty($value['icon']) ? '<i class="cs-icon ' . $value['icon'] . '"></i>' : '';
             if (isset($value['fields'])) {
                 $active_section = $section_id == $value['name'] ? ' class="cs-section-active"' : '';
                 echo '<li><a href="#"' . $active_section . ' data-section="' . $value['name'] . '">' . $tab_icon . $value['title'] . '</a></li>';
             } else {
                 echo '<li><div class="cs-seperator">' . $tab_icon . $value['title'] . '</div></li>';
             }
         }
         echo '</ul>';
         echo '</div>';
     }
     echo '<div class="cs-content">';
     echo '<div class="cs-sections">';
     foreach ($sections as $val) {
         if (isset($val['fields'])) {
             $active_content = $section_id == $val['name'] ? ' style="display: block;"' : '';
             echo '<div id="cs-tab-' . $val['name'] . '" class="cs-section"' . $active_content . '>';
             echo isset($val['title']) ? '<div class="cs-section-title"><h3>' . $val['title'] . '</h3></div>' : '';
             foreach ($val['fields'] as $field_key => $field) {
                 $default = isset($field['default']) ? $field['default'] : '';
                 $elem_id = isset($field['id']) ? $field['id'] : '';
                 $elem_value = is_array($meta_value) && isset($meta_value[$elem_id]) ? $meta_value[$elem_id] : $default;
                 echo cs_add_element($field, $elem_value, $unique);
             }
             echo '</div>';
         }
     }
     echo '</div>';
     echo '<div class="clear"></div>';
     echo '</div>';
     echo $has_nav ? '<div class="cs-nav-background"></div>' : '';
     echo '<div class="clear"></div>';
     echo '</div>';
     echo '</div>';
 }
 public function render_meta_box_content($post, $callback)
 {
     global $post, $cs_errors;
     wp_nonce_field('cs-framework-metabox', 'cs-framework-metabox-nonce');
     $unique = $callback['args']['id'];
     $sections = $callback['args']['sections'];
     $meta_value = get_post_meta($post->ID, $unique, true);
     $transient = get_transient('cs-metabox-transient');
     $cs_errors = $transient['errors'];
     $has_nav = count($sections) >= 2 && $callback['args']['context'] != 'side' ? true : false;
     $show_all = !$has_nav ? ' cs-show-all' : '';
     $section_name = !empty($sections[0]['fields']) ? $sections[0]['name'] : $sections[1]['name'];
     $section_id = !empty($transient['ids'][$unique]) ? $transient['ids'][$unique] : $section_name;
     $section_id = cs_get_var('cs-section', $section_id);
     echo '<div class="cs-framework cs-metabox-framework">';
     echo '<input type="hidden" name="cs_section_id[' . $unique . ']" class="cs-reset" value="' . $section_id . '">';
     echo '<div class="cs-body' . $show_all . '">';
     if ($has_nav) {
         echo '<div class="cs-nav">';
         echo '<ul>';
         foreach ($sections as $value) {
             $tab_icon = !empty($value['icon']) ? '<i class="cs-icon ' . $value['icon'] . '"></i>' : '';
             if (isset($value['fields'])) {
                 $active_section = $section_id == $value['name'] ? ' class="cs-section-active"' : '';
                 echo '<li><a href="#"' . $active_section . ' data-section="' . $value['name'] . '">' . $tab_icon . $value['title'] . '</a></li>';
             } else {
                 echo '<li><div class="cs-seperator">' . $tab_icon . $value['title'] . '</div></li>';
             }
         }
         echo '</ul>';
         echo '</div>';
     }
     echo '<div class="cs-content">';
     echo '<div class="cs-sections">';
     foreach ($sections as $val) {
         if (isset($val['fields'])) {
             $active_content = $section_id == $val['name'] ? ' style="display: block;"' : '';
             echo '<div id="cs-tab-' . $val['name'] . '" class="cs-section"' . $active_content . '>';
             echo isset($val['title']) ? '<div class="cs-section-title"><h3>' . $val['title'] . '</h3></div>' : '';
             foreach ($val['fields'] as $field_key => $field) {
                 $default = isset($field['default']) ? $field['default'] : '';
                 $elem_id = isset($field['id']) ? $field['id'] : '';
                 $elem_value = is_array($meta_value) && isset($meta_value[$elem_id]) ? $meta_value[$elem_id] : $default;
                 echo cs_add_element($field, $elem_value, $unique);
             }
             echo '</div>';
         }
     }
     echo '</div>';
     echo '<div class="clear"></div>';
     echo '</div>';
     echo $has_nav ? '<div class="cs-nav-background"></div>' : '';
     echo '<div class="clear"></div>';
     echo '</div>';
     echo '</div>';
 }
 public function render_meta_box_content($term, $taxonomy)
 {
     wp_nonce_field('cs-framework-taxonomy', 'cs-framework-taxonomy-nonce');
     foreach ($this->options as $value) {
         $thisTax = isset($value['taxonomy']) ? $value['taxonomy'] : '';
         //Check if current taxonomy match with loop taxonomy
         if ($thisTax !== $taxonomy) {
             continue;
         }
         $sections = $value['sections'];
         $unique = $value['id'];
         $meta_value = get_term_meta($term->term_id, $unique, true);
         echo '<tr class="form-field term-description-wrap">';
         echo '<td colspan="2">';
         echo '<div class="cs-framework cs-metabox-framework">';
         echo '<div class="cs-body">';
         echo '<div class="cs-content" style="margin-left:0">';
         echo isset($value['title']) ? '<div class="cs-main-section-title" style="display:block;margin-bottom:20px;"><h3>' . $value['title'] . '</h3></div>' : '';
         echo '<div class="cs-sections">';
         foreach ($sections as $val) {
             if (isset($val['fields'])) {
                 $icon = isset($val['icon']) ? '<i class="' . $val['icon'] . '"></i> ' : '';
                 echo isset($val['title']) ? '<div class="cs-section-title" style="display:block;"><h3>' . $icon . $val['title'] . '</h3></div>' : '';
                 foreach ($val['fields'] as $field_key => $field) {
                     $default = isset($field['default']) ? $field['default'] : '';
                     $elem_id = isset($field['id']) ? $field['id'] : '';
                     $elem_value = is_array($meta_value) && isset($meta_value[$elem_id]) ? $meta_value[$elem_id] : $default;
                     echo cs_add_element($field, $elem_value, $unique);
                 }
                 //echo '</div>';
             }
         }
         echo '</div>';
         echo '<div class="clear"></div>';
         echo '</div>';
         echo '</div>';
         echo '</div>';
         echo '</td>';
         echo '</tr>';
     }
 }