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', ZELS_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 = zels_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="zels-group hidden">'; echo '<h4 class="zels-group-title">' . $acc_title . '</h4>'; echo '<div class="zels-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 zels_add_element($field, $field_default, $unique); } echo '<div class="zels-element zels-text-right"><a href="#" class="button zels-warning-primary zels-remove-group">' . __('Remove', ZELS_TEXTDOMAIN) . '</a></div>'; echo '</div>'; echo '</div>'; echo '<div class="zels-groups zels-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 = zels_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="zels-group">'; echo '<h4 class="zels-group-title">' . $field_title . ': ' . $title . '</h4>'; echo '<div class="zels-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 zels_add_element($field, $value, $unique); } echo '<div class="zels-element zels-text-right"><a href="#" class="button zels-warning-primary zels-remove-group">' . __('Remove', ZELS_TEXTDOMAIN) . '</a></div>'; echo '</div>'; echo '</div>'; } } echo '</div>'; echo '<a href="#" class="button button-primary zels-add-group">' . $this->field['button_title'] . '</a>'; echo $this->element_after(); }
function zels_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, zels_array_search($sub_array, $key, $value)); } } return $results; }
public function admin_page() { $has_nav = count($this->options) <= 1 ? ' zels-show-all' : ''; $section_id = get_transient('zels_section_id') ? get_transient('zels_section_id') : $this->sections[0]['name']; $section_id = isset($_GET['zels-section']) ? esc_attr($_GET['zels-section']) : $section_id; echo '<div class="zels-framework zels-option-framework">'; echo '<form method="post" action="options.php" enctype="multipart/form-data" id="zels_framework_form">'; echo '<input type="hidden" class="zels-reset" name="zels_section_id" value="' . $section_id . '" />'; if ($this->settings['ajax_save'] !== true) { $errors = get_settings_errors(); if (!empty($errors)) { foreach ($errors as $error) { if (in_array($error['setting'], array('general', 'zels-framework-errors'))) { echo '<div class="zels-settings-error ' . $error['type'] . '">'; echo '<p><strong>' . $error['message'] . '</strong></p>'; echo '</div>'; } } } } settings_fields($this->unique . '_group'); echo '<header class="zels-header">'; echo '<div class="zels-logo">'; //if (ZELS_THEME_LOGO == true) { echo '<img src="' . esc_url(get_template_directory_uri() . '/assets/images/logo.png') . '" alt="' . ZELS_THEME_NAME . '"/>'; //} echo '</div>'; // echo '<div class="zels-info">'; // echo '<h1 class="zels-heading">' . esc_attr( ZELS_THEME_NAME ) . '<small class="zels-name">' . esc_attr( ZELS_THEME_VERSION ) . '</small></h1>'; // echo '</div>'; echo '<fieldset class="zels-action-field">'; echo $this->settings['ajax_save'] === true ? '<span id="zels-save-ajax">' . __('Settings saved.', ZELS_TEXTDOMAIN) . '</span>' : ''; submit_button(__('Save Changes', ZELS_TEXTDOMAIN), 'primary', 'save', false, array('data-ajax' => $this->settings['ajax_save'], 'data-save' => __('Saving...', ZELS_TEXTDOMAIN))); submit_button(__('Restore Settings', ZELS_TEXTDOMAIN), 'secondary zels-restore zels-reset-confirm', $this->unique . '[reset]', false); echo '</fieldset>'; echo empty($has_nav) ? '<a href="#" class="zels-expand-all"><i class="fa fa-eye-slash"></i> ' . __('show all options', ZELS_TEXTDOMAIN) . '</a>' : ''; echo '<div class="clear"></div>'; echo '</header>'; // end .zels-header echo '<div class="zels-body' . $has_nav . '">'; echo '<div class="zels-nav">'; echo '<ul>'; foreach ($this->options as $key => $tab) { if (isset($tab['sections'])) { $tab_active = zels_array_search($tab['sections'], 'name', $section_id); $active_style = !empty($tab_active) ? ' style="display: block;"' : ''; $active_list = !empty($tab_active) ? ' zels-tab-active' : ''; $tab_icon = !empty($tab['icon']) ? '<i class="zels-icon ' . $tab['icon'] . '"></i>' : ''; echo '<li class="zels-sub' . $active_list . '">'; echo '<a href="#" class="zels-arrow">' . $tab_icon . $tab['title'] . '</a>'; echo '<ul' . $active_style . '>'; foreach ($tab['sections'] as $tab_section) { $active_tab = $section_id == $tab_section['name'] ? ' class="zels-section-active"' : ''; $icon = !empty($tab_section['icon']) ? '<i class="zels-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="zels-icon ' . $tab['icon'] . '"></i>' : ''; if (isset($tab['fields'])) { $active_list = $section_id == $tab['name'] ? ' class="zels-section-active"' : ''; echo '<li><a href="#"' . $active_list . ' data-section="' . $tab['name'] . '">' . $icon . $tab['title'] . '</a></li>'; } else { echo '<li><div class="zels-seperator">' . $icon . $tab['title'] . '</div></li>'; } } } echo '</ul>'; echo '</div>'; // end .zels-nav echo '<div class="zels-content">'; echo '<div class="zels-sections">'; foreach ($this->sections as $section) { if (isset($section['fields'])) { $active_content = $section_id == $section['name'] ? ' style="display: block;"' : ''; echo '<div id="zels-tab-' . $section['name'] . '" class="zels-section"' . $active_content . '>'; echo isset($section['title']) && empty($has_nav) ? '<div class="zels-section-title"><h3>' . $section['title'] . '</h3></div>' : ''; $this->do_settings_sections($section['name'] . '_section_group'); echo '</div>'; } } echo '</div>'; // end .zels-sections echo '<div class="clear"></div>'; echo '</div>'; // end .zels-content echo '<div class="zels-nav-background"></div>'; echo '</div>'; // end .zels-body echo '<footer class="zels-footer">'; echo 'Zels Framework <strong>v' . ZELS_VERSION . ' adapted from <a href="' . esc_url('github.com/Codestar/codestar-framework') . '">codestar</a> by CodexCoder</strong>'; echo '</footer>'; // end .zels-footer echo '</form>'; // end form echo '<div class="clear"></div>'; echo '</div>'; // end .zels-framework }