Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit

Permalink
v2.4.4
Browse files Browse the repository at this point in the history
+ New action hooks for tabs.
+ Tabs can now have Sections (SubTabs).
+ Minor changes to CSS & JS.
  • Loading branch information
mattiasghodsian committed Dec 10, 2016
1 parent 2058502 commit d245841
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 58 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
**2.4.4**
+ New action hooks for tabs.
+ Tabs can now have Sections (SubTabs).
+ Minor changes to CSS & JS.
+ Min js included.

**2.4.0**
+ Notification when a new update is available.
+ Minor CSS changes.
Expand Down
20 changes: 19 additions & 1 deletion wp_theme_settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@

.wpts-wrap .about-text{
margin: 10px 200px 10px 0;
min-height: 40px;
font-size: 16.5px;
}

Expand Down Expand Up @@ -304,4 +303,23 @@
border-width: 5px 5px 5px 0;
border-style: solid;
border-color: transparent #555 transparent transparent;
}

.wpts-nav-sections li{
float: left;
}

.wpts-nav-sections li a{
border-right: 1px solid #ccc;
padding: 0px 12px;
font-size: 13px;
text-decoration: none;
}

.wpts-nav-sections li:last-child a{
border-right: none;
}

.wpts-nav-section-holder{
display: none;
}
48 changes: 38 additions & 10 deletions wp_theme_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,53 @@ jQuery( document ).ready(function() {
if (target.length) {
jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none");
jQuery(target).css("display", "block");
jQuery(target.selector + ' > .wpts-nav-section-holder').css("display", "none");
jQuery(target.selector + '_parent').css("display", "block");
jQuery('.nav-rtab-form').attr("action", "options.php"+target.selector);
jQuery('html, body').animate({scrollTop : 0},1);
}
}
});

if ( jQuery( '.nav-tab-wrapper' ).length > 0 ) {
jQuery( '#footer-thankyou' ).html('Thank you for creating with <a href="https://git.io/vi1Gr" target="_new">WPTS</a>');
}
jQuery('.wpts-nav-sections > li > a').click(function() {
var target = jQuery(this).attr('href');
if(target.indexOf('&') != -1){
var target_array = target.split("&");
var parent_target = target_array[0];
var section_target = target_array[1].replace("section=", "#");
jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none");
jQuery(parent_target).css("display", "block");
jQuery(parent_target + ' > .wpts-nav-section-holder').css("display", "none");
jQuery(section_target).css("display", "block");
jQuery('.nav-rtab-form').attr("action", "options.php"+target);
jQuery('html, body').animate({scrollTop : 0},1);
}
});


if(window.location.hash.length) {
var target = window.location.hash;
jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none");
jQuery(target).css("display", "block");
jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active');
jQuery('.nav-rtab-wrapper a[href="'+target+'"]').each(function(e){
jQuery(this).addClass('nav-tab-active');
jQuery('.nav-rtab-form').attr("action", "options.php"+target);
});
if(target.indexOf('&') != -1){
var target_array = target.split("&");
var parent_target = target_array[0];
var section_target = target_array[1].replace("section=", "#");
jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none");
jQuery(parent_target).css("display", "block");
jQuery(section_target).css("display", "block");
}else{
jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none");
jQuery(target).css("display", "block");
jQuery(target + '_parent').css("display", "block");
jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active');
jQuery('.nav-rtab-wrapper a[href="'+target+'"]').each(function(e){
jQuery(this).addClass('nav-tab-active');
jQuery('.nav-rtab-form').attr("action", "options.php"+target);
});
}
}

if ( jQuery( '.nav-tab-wrapper' ).length > 0 ) {
jQuery( '#footer-thankyou' ).html('Thank you for creating with <a href="https://git.io/vi1Gr" target="_new">WPTS</a>');
}

jQuery( '.wpts_color_field' ).wpColorPicker();
Expand Down
115 changes: 68 additions & 47 deletions wp_theme_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Class Name: wp_theme_settings
* GitHub URI: http://github.com/mattiasghodsian/wp_theme_settings
* Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page)
* Version: 2.4.0
* Version: 2.3.8
* Author: Mattias Ghodsian
* Author URI: http://www.nexxoz.com
* License: GPL-2.0+
Expand Down Expand Up @@ -42,17 +42,24 @@ function __construct($args){
$this->toolbar = (array_key_exists('toolbar', $args['general'])) ? $args['general']['toolbar'] : array();
$this->notice = (array_key_exists('notice', $args['general'])) ? $args['general']['notice'] : true;
/*
* @ Add tabfields to settingsfield
* @ Add tabfields (tabs & sections) to settingsfield
*/
foreach ($this->tabs as $key => $data) {
if (array_key_exists('tabFields', $data)) {
if (array_key_exists('tabFields', $data)) {
foreach ($data["tabFields"] as $key => $value) {
array_push($this->settingFields, $value['name']);
}
}

if (array_key_exists('sections', $data)) {
foreach ($data["sections"] as $key => $section) {
if (array_key_exists('tabFields', $section)) {
foreach ($section["tabFields"] as $key => $section_tabFields) {
array_push($this->settingFields, $section_tabFields['name']);
}
}
}
}
}

/*
* @ call register theme_settings function
*/
Expand All @@ -75,12 +82,6 @@ function __construct($args){
if (array_key_exists('toolbar', $args['general']) && $args['general']['toolbar'] != false) {
add_action('admin_bar_menu', array($this, 'wpts_toolbar'), 999);
}
/*
* @ call toolbar function
*/
if (array_key_exists('toolbar', $args['general']) && $args['general']['toolbar'] != false) {
add_action('admin_bar_menu', array($this, 'wpts_toolbar'), 999);
}
/*
* @ check update notice
*/
Expand All @@ -95,12 +96,12 @@ function __construct($args){
* @ WP Toolbar
*/
public function wpts_toolbar($wp_admin_bar) {
$menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme');
$menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings');
$menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : '');
$toolbar_title = (array_key_exists('toolbar_title', $this->toolbar) ? $this->toolbar['toolbar_title'] : 'WPTS');
$toolbar_image = (array_key_exists('toolbar_image', $this->toolbar) ? $this->toolbar['toolbar_image'] : 'http://i.imgur.com/3BfjiTf.png');
$toolbar_href = (array_key_exists('toolbar_href', $this->toolbar) ? $this->toolbar['toolbar_href'] : 'https://git.io/vi1Gr');
$menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme');
$menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings');
$menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : '');
$toolbar_title = (array_key_exists('toolbar_title', $this->toolbar) ? $this->toolbar['toolbar_title'] : 'WPTS');
$toolbar_image = (array_key_exists('toolbar_image', $this->toolbar) ? $this->toolbar['toolbar_image'] : 'http://i.imgur.com/3BfjiTf.png');
$toolbar_href = (array_key_exists('toolbar_href', $this->toolbar) ? $this->toolbar['toolbar_href'] : 'https://git.io/vi1Gr');

if ($toolbar_image) {
$toolbar_image = '<img src="'.$toolbar_image.'" class="wpts-toolbar-icon" /> ';
Expand Down Expand Up @@ -156,12 +157,12 @@ public function wp_theme_settings_js_css(){
* @ Register theme menu.
*/
public function menu() {
$menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme');
$page_title = (array_key_exists('title', $this->general) ? $this->general['title'] : 'Theme Settings');
$menu_title = (array_key_exists('menu_title', $this->general) ? $this->general['menu_title'] : 'Theme Settings');
$menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings');
$menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : '');
$capability = (array_key_exists('capability', $this->general) ? $this->general['capability'] : 'manage_options');
$menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme');
$page_title = (array_key_exists('title', $this->general) ? $this->general['title'] : 'Theme Settings');
$menu_title = (array_key_exists('menu_title', $this->general) ? $this->general['menu_title'] : 'Theme Settings');
$menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings');
$menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : '');
$capability = (array_key_exists('capability', $this->general) ? $this->general['capability'] : 'manage_options');
switch ($menu_type) {
case 'submenu':
add_submenu_page($menu_parent, $page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') );
Expand All @@ -187,34 +188,32 @@ public function tabs(){
* @ Build table for tabs
*/
private function tab_container($array, $parent){
if (array_key_exists("tabFields", $array)) {
echo '<table class="form-table"><tbody>';
echo '<table class="form-table"><tbody>';
do_action('wpts_tab_'.$parent.'_table_before');
foreach ($array as $key => $data) {

foreach ($array["tabFields"] as $key => $data) {

echo '<tr>';

echo '<th scope="row">';
if (array_key_exists('label', $data)) {
echo '<label>'.$data['label'].'</label>';
}
echo '</th>';
echo '<tr>';

echo '<td>';
echo $this->binput($data);
if (array_key_exists('description', $data)) {
echo '<p class="description">'.$data['description'].'</p>';
}
echo '</td>';
echo '<th scope="row">';
if (array_key_exists('label', $data)) {
echo '<label>'.$data['label'].'</label>';
}
echo '</th>';

echo '</tr>';
echo '<td>';
echo $this->binput($data);
if (array_key_exists('description', $data)) {
echo '<p class="description">'.$data['description'].'</p>';
}
echo '</td>';

array_push($this->settingFields, $data['name']);
}
echo '</tr>';

do_action('wpts_tab_'.$parent.'_table');
echo '</tbody></table>';
array_push($this->settingFields, $data['name']);
}

do_action('wpts_tab_'.$parent.'_table_after');
echo '</tbody></table>';
}
/*
* @ Build inputs
Expand Down Expand Up @@ -308,16 +307,37 @@ private function navTabs(){
$i++;
}
echo '</h2>';


echo '<form method="post" class="nav-rtab-form" action="options.php">';
settings_fields($this->settingsID);
echo '<div class="nav-rtabs">';

foreach ($this->tabs as $key => $tab) {
echo '<div class="nav-rtab-holder" id="'.$this->keyEntity($key).'">';
do_action('wpts_tab_'.$this->keyEntity($key).'_before');

$this->tab_container($tab, $this->keyEntity($key));
/** START - Section **/
if ( array_key_exists('sections', $tab) ) {
echo '<ul class="wpts-nav-sections">';
foreach ($tab['sections'] as $section_key => $section) {
echo '<li><a href="#'.$this->keyEntity($key).'&section='.$section_key.'">'.ucfirst($section['text']).'</a></li>';
}
echo '</ul>';

foreach ($tab['sections'] as $section_key => $section) {
echo '<div class="wpts-nav-section-holder" id="'.$this->keyEntity($section_key).'">';
$this->tab_container( $section['tabFields'] , $this->keyEntity($key).'_'.$this->keyEntity($section_key) , 'sections');
echo '</div>';
}

}
/** END - Section **/
echo '<div class="wpts-nav-section-holder" id="'.$this->keyEntity($key).'_parent">';
$this->tab_container( $tab['tabFields'] , $this->keyEntity($key) );
echo '</div>';

do_action('wpts_tab_'.$this->keyEntity($key));
do_action('wpts_tab_'.$this->keyEntity($key).'_after');
echo '</div>';
}

Expand Down Expand Up @@ -414,5 +434,6 @@ private function get_wpts_git_version(){
return $this->currversion;
}
}

}
?>
10 changes: 10 additions & 0 deletions wp_theme_settings_min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d245841

Please sign in to comment.