コード例 #1
0
 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();
 }
コード例 #2
0
 public function admin_page()
 {
     $transient = get_transient('cs-framework-transient');
     $has_nav = count($this->options) <= 1 ? ' cs-show-all' : '';
     $section_id = !empty($transient['section_id']) ? $transient['section_id'] : $this->sections[0]['name'];
     $section_id = isset($_GET['cs-section']) ? esc_attr($_GET['cs-section']) : $section_id;
     echo '<div class="cs-framework cs-option-framework">';
     echo '<form method="post" action="options.php" enctype="multipart/form-data" id="csframework_form">';
     echo '<input type="hidden" class="cs-reset" name="cs_section_id" value="' . $section_id . '" />';
     if ($this->settings['ajax_save'] !== true && !empty($transient['errors'])) {
         global $cs_errors;
         $cs_errors = $transient['errors'];
         if (!empty($cs_errors)) {
             foreach ($cs_errors as $error) {
                 if (in_array($error['setting'], array('general', 'cs-errors'))) {
                     echo '<div class="cs-settings-error ' . $error['type'] . '">';
                     echo '<p><strong>' . $error['message'] . '</strong></p>';
                     echo '</div>';
                 }
             }
         }
     }
     settings_fields($this->unique . '_group');
     echo '<header class="cs-header">';
     echo '<h1>优品微商城选项 <small>by YOUPZT</small></h1>';
     echo '<fieldset>';
     echo $this->settings['ajax_save'] === true ? '<span id="cs-save-ajax">' . __('设置已保存', 'cs-framework') . '</span>' : '';
     submit_button(__('保存', 'cs-framework'), 'primary', 'save', false, array('data-ajax' => $this->settings['ajax_save'], 'data-save' => __('正在保存...', 'cs-framework')));
     submit_button(__('恢复默认', 'cs-framework'), 'secondary cs-restore cs-reset-confirm', $this->unique . '[reset]', false);
     echo '</fieldset>';
     echo empty($has_nav) ? '<a href="#" class="cs-expand-all"><i class="fa fa-eye-slash"></i> ' . __('显示所有选项', 'cs-framework') . '</a>' : '';
     echo '<div class="clear"></div>';
     echo '</header>';
     // end .cs-header
     echo '<div class="cs-body' . $has_nav . '">';
     echo '<div class="cs-nav">';
     echo '<ul>';
     foreach ($this->options as $key => $tab) {
         if (isset($tab['sections'])) {
             $tab_active = cs_array_search($tab['sections'], 'name', $section_id);
             $active_style = !empty($tab_active) ? ' style="display: block;"' : '';
             $active_list = !empty($tab_active) ? ' cs-tab-active' : '';
             $tab_icon = !empty($tab['icon']) ? '<i class="cs-icon ' . $tab['icon'] . '"></i>' : '';
             echo '<li class="cs-sub' . $active_list . '">';
             echo '<a href="#" class="cs-arrow">' . $tab_icon . $tab['title'] . '</a>';
             echo '<ul' . $active_style . '>';
             foreach ($tab['sections'] as $tab_section) {
                 $active_tab = $section_id == $tab_section['name'] ? ' class="cs-section-active"' : '';
                 $icon = !empty($tab_section['icon']) ? '<i class="cs-icon ' . $tab_section['icon'] . '"></i>' : '';
                 echo '<li><a href="#"' . $active_tab . ' data-section="' . $tab_section['name'] . '">' . $icon . $tab_section['title'] . '</a></li>';
             }
             echo '</ul>';
             echo '</li>';
         } else {
             $icon = !empty($tab['icon']) ? '<i class="cs-icon ' . $tab['icon'] . '"></i>' : '';
             if (isset($tab['fields'])) {
                 $active_list = $section_id == $tab['name'] ? ' class="cs-section-active"' : '';
                 echo '<li><a href="#"' . $active_list . ' data-section="' . $tab['name'] . '">' . $icon . $tab['title'] . '</a></li>';
             } else {
                 echo '<li><div class="cs-seperator">' . $icon . $tab['title'] . '</div></li>';
             }
         }
     }
     echo '</ul>';
     echo '</div>';
     // end .cs-nav
     echo '<div class="cs-content">';
     echo '<div class="cs-sections">';
     foreach ($this->sections as $section) {
         if (isset($section['fields'])) {
             $active_content = $section_id == $section['name'] ? ' style="display: block;"' : '';
             echo '<div id="cs-tab-' . $section['name'] . '" class="cs-section"' . $active_content . '>';
             echo isset($section['title']) && empty($has_nav) ? '<div class="cs-section-title"><h3>' . $section['title'] . '</h3></div>' : '';
             $this->do_settings_sections($section['name'] . '_section_group');
             echo '</div>';
         }
     }
     echo '</div>';
     // end .cs-sections
     echo '<div class="clear"></div>';
     echo '</div>';
     // end .cs-content
     echo '<div class="cs-nav-background"></div>';
     echo '</div>';
     // end .cs-body
     echo '<footer class="cs-footer">';
     echo '<a href="http://www.youpzt.com" target="_blank">优品主题</a><strong>v' . CS_VERSION . ' </strong>';
     echo '</footer>';
     // end .cs-footer
     echo '</form>';
     // end form
     echo '<div class="clear"></div>';
     echo '</div>';
     // end .cs-framework
 }
コード例 #3
0
 function cs_array_search($array, $key, $value)
 {
     $results = array();
     if (is_array($array)) {
         if (isset($array[$key]) && $array[$key] == $value) {
             $results[] = $array;
         }
         foreach ($array as $sub_array) {
             $results = array_merge($results, cs_array_search($sub_array, $key, $value));
         }
     }
     return $results;
 }