Ejemplo n.º 1
0
 public function output()
 {
     echo $this->element_before();
     $last_id = is_array($this->value) ? count($this->value) : 0;
     $acc_title = isset($this->field['accordion_title']) ? $this->field['accordion_title'] : __('Adding', SK_TEXTDOMAIN);
     $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 = sk_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="sk-group hidden">';
     echo '<h4 class="sk-group-title">' . $acc_title . '</h4>';
     echo '<div class="sk-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 sk_add_element($field, $field_default, $unique);
     }
     echo '<div class="sk-element sk-text-right"><a href="#" class="button sk-warning-primary sk-remove-group">' . __('Remove', SK_TEXTDOMAIN) . '</a></div>';
     echo '</div>';
     echo '</div>';
     echo '<div class="sk-groups sk-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 = sk_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="sk-group">';
             echo '<h4 class="sk-group-title">' . $field_title . ': ' . $title . '</h4>';
             echo '<div class="sk-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 sk_add_element($field, $value, $unique);
             }
             echo '<div class="sk-element sk-text-right"><a href="#" class="button sk-warning-primary sk-remove-group">' . __('Remove', SK_TEXTDOMAIN) . '</a></div>';
             echo '</div>';
             echo '</div>';
         }
     }
     echo '</div>';
     echo '<a href="#" class="button button-primary sk-add-group">' . $this->field['button_title'] . '</a>';
     echo $this->element_after();
 }
Ejemplo n.º 2
0
 function sk_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, sk_array_search($sub_array, $key, $value));
         }
     }
     return $results;
 }
Ejemplo n.º 3
0
 public function admin_page()
 {
     $transient = get_transient('sk-framework-transient');
     $has_nav = count($this->options) <= 1 ? ' sk-show-all' : '';
     $section_id = !empty($transient['section_id']) ? $transient['section_id'] : $this->sections[0]['name'];
     $section_id = isset($_GET['sk-section']) ? esc_attr($_GET['sk-section']) : $section_id;
     echo '<div class="sk-framework sk-option-framework">';
     echo '<form method="post" action="options.php" enctype="multipart/form-data" id="csframework_form">';
     echo '<input type="hidden" class="sk-reset" name="sk_section_id" value="' . $section_id . '" />';
     if ($this->settings['ajax_save'] !== true && !empty($transient['errors'])) {
         global $sk_errors;
         $sk_errors = $transient['errors'];
         if (!empty($sk_errors)) {
             foreach ($sk_errors as $error) {
                 if (in_array($error['setting'], array('general', 'sk-errors'))) {
                     echo '<div class="sk-settings-error ' . $error['type'] . '">';
                     echo '<p><strong>' . $error['message'] . '</strong></p>';
                     echo '</div>';
                 }
             }
         }
     }
     settings_fields($this->unique . '_group');
     echo '<header class="sk-header">';
     echo '<h1>';
     echo sprintf('%s', isset($this->settings['header_title']) ? $this->settings['header_title'] : "Skelet Framework");
     echo '</h1>';
     echo '<p class="feedback"><a target="_blank" href="http://www.maginoo.co/feedback/">Feedback</a></p>';
     echo '<fieldset>';
     echo $this->settings['ajax_save'] === true ? '<span id="sk-save-ajax">' . __('Settings saved.', SK_TEXTDOMAIN) . '</span>' : '';
     submit_button(__('Save Changes', SK_TEXTDOMAIN), 'sk-save', 'save', false, array('data-ajax' => $this->settings['ajax_save'], 'data-save' => __('Saving...', SK_TEXTDOMAIN)));
     submit_button(__('Restore', SK_TEXTDOMAIN), 'secondary sk-restore sk-reset-confirm', $this->unique . '[reset]', false);
     echo '</fieldset>';
     //echo ( empty( $has_nav ) ) ? '<a href="#" class="sk-expand-all"><i class="fa fa-eye-slash"></i> '. __( 'show all options', SK_TEXTDOMAIN ) .'</a>' : '';
     echo '<div class="clear"></div>';
     echo '</header>';
     // end .sk-header
     echo '<div class="sk-body' . $has_nav . '">';
     echo '<div class="sk-nav">';
     echo '<ul>';
     foreach ($this->options as $key => $tab) {
         if (isset($tab['sections'])) {
             $tab_active = sk_array_search($tab['sections'], 'name', $section_id);
             $active_style = !empty($tab_active) ? ' style="display: block;"' : '';
             $active_list = !empty($tab_active) ? ' sk-tab-active' : '';
             $tab_icon = !empty($tab['icon']) ? '<i class="sk-icon ' . $tab['icon'] . '"></i>' : '';
             echo '<li class="sk-sub' . $active_list . '">';
             echo '<a href="#/section/' . $tab['name'] . '" class="sk-arrow">' . $tab_icon . $tab['title'] . '</a>';
             echo '<ul' . $active_style . '>';
             foreach ($tab['sections'] as $tab_section) {
                 $active_tab = $section_id == $tab_section['name'] ? ' class="sk-section-active"' : '';
                 $icon = !empty($tab_section['icon']) ? '<i class="sk-icon ' . $tab_section['icon'] . '"></i>' : '';
                 echo '<li><a href="#/section/sub/' . $tab_section['name'] . '"' . $active_tab . ' data-section="' . $tab_section['name'] . '">' . $icon . $tab_section['title'] . '</a></li>';
             }
             echo '</ul>';
             echo '</li>';
         } else {
             $icon = !empty($tab['icon']) ? '<i class="sk-icon ' . $tab['icon'] . '"></i>' : '';
             if (isset($tab['fields'])) {
                 $active_list = $section_id == $tab['name'] ? ' class="sk-section-active"' : '';
                 echo '<li><a href="#/section/' . $tab['name'] . '"' . $active_list . ' data-section="' . $tab['name'] . '">' . $icon . $tab['title'] . '</a></li>';
             } else {
                 echo '<li><div class="sk-seperator">' . $icon . $tab['title'] . '</div></li>';
             }
         }
     }
     echo '</ul>';
     echo '</div>';
     // end .sk-nav
     echo '<div class="sk-content">';
     echo '<div class="sk-sections">';
     foreach ($this->sections as $section) {
         if (isset($section['fields'])) {
             $active_content = $section_id == $section['name'] ? ' style="display: block;"' : '';
             echo '<div id="sk-tab-' . $section['name'] . '" class="sk-section"' . $active_content . '>';
             echo isset($section['title']) && empty($has_nav) ? '<div class="sk-section-title"><h3>' . $section['title'] . '</h3></div>' : '';
             $this->do_settings_sections($section['name'] . '_section_group');
             echo '</div>';
         }
     }
     echo '</div>';
     // end .sk-sections
     echo '<div class="clear"></div>';
     echo '</div>';
     // end .sk-content
     echo '<div class="sk-nav-background"></div>';
     echo '</div>';
     // end .sk-body
     echo '</form>';
     // end form
     echo '<div class="clear"></div>';
     echo '</div>';
     // end .sk-framework
     global $skelet_path;
     echo '<footer class="sk-footer">';
     echo '<img src="' . $skelet_path["uri"] . '/assets/images/madeby.png">';
     echo '<a target="_blank" href="http://pressapps.co/"><img src="' . $skelet_path["uri"] . '/assets/images/pressapps.png"></a>';
     echo '</footer>';
     // end .sk-footer
 }