├── docs ├── readme.md └── _config.yml ├── .github └── FUNDING.yml ├── twentyseventeen-child ├── style.css ├── functions.php └── wpts │ ├── wp_theme_settings.min.js │ ├── wp_theme_settings.js │ ├── wp_theme_settings.css │ └── wp_theme_settings.php ├── changelog.md ├── README.md ├── wp_theme_settings.min.js ├── wp_theme_settings.js ├── wp_theme_settings.css └── wp_theme_settings.php /docs/readme.md: -------------------------------------------------------------------------------- 1 | docs 2 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | custom: ['https://www.paypal.me/MattiasG', 'https://en.cryptobadges.io/donate/0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5'] 4 | -------------------------------------------------------------------------------- /twentyseventeen-child/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | Theme Name: Twenty Seventeen Child 3 | Theme URI: http://example.com/twenty-seventeen-child/ 4 | Description: Twenty Seventeen Child Theme 5 | Author: John Doe 6 | Author URI: http://example.com 7 | Template: twentyseventeen 8 | Version: 1.0.0 9 | License: GNU General Public License v2 or later 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready 12 | Text Domain: twenty-seventeen-child 13 | */ -------------------------------------------------------------------------------- /twentyseventeen-child/functions.php: -------------------------------------------------------------------------------- 1 | 'text', 30 | 'label' => 'Example Input', 31 | 'name' => 'example_input' , 32 | 'description' => 'Example description', 33 | ], 34 | [ 35 | 'type' => 'fa', 36 | 'label' => 'Example Icons', 37 | 'name' => 'example_icons' , 38 | 'description' => 'Example description', 39 | ], 40 | ]; 41 | 42 | $wpts = new wp_theme_settings( 43 | array( 44 | 'general' => array('description' => 'A custom WordPress class for creating theme settings page'), 45 | 'settingsID' => 'wp_theme_settings', 46 | 'settingFields' => array('wp_theme_settings_title'), 47 | 'tabs' => array( 48 | 'general' => array('text' => 'General', 'dashicon' => 'dashicons-admin-generic' , 'tabFields' => $wpts_general_fields), 49 | 'buttons' => array('text' => 'Buttons') 50 | ), 51 | ) 52 | ); 53 | ?> -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | **2.4.5** 2 | + Fix for foreach() on line 339. 3 | 4 | **2.4.4** 5 | + New action hooks for tabs. 6 | + Tabs can now have Sections (SubTabs). 7 | + Minor changes to CSS & JS. 8 | + Min js included. 9 | 10 | **2.4.0** 11 | + Notification when a new update is available. 12 | + Minor CSS changes. 13 | + Tooltip for tabFields (Works only on input,toggle,select). 14 | 15 | **2.3.9** 16 | + tab_container error fix. 17 | + CSS on h1 title. 18 | 19 | **2.3.8** 20 | + WP Toolbar. 21 | 22 | **2.3.7** 23 | + wpts-file-field (media-upload | Choose image/upload image) for tabFields. 24 | + FontAwesome 4.7.0 25 | + js wpts version removed. 26 | 27 | **2.3.6** 28 | + Error row 118 fix. 29 | 30 | **2.3.5** 31 | + Option to use WPTS for plugins. 32 | + Js changes. 33 | 34 | **2.3.4** 35 | + Get option(s) with apply_filters('wpts_option', 'key-here') instead of esc_attr(get_option('key-here')) both work. 36 | + ABSPATH added. 37 | + Options replaced with wpts_option in binput(). 38 | 39 | **2.3.3** 40 | + FontAwesomeArray removed. 41 | + Fix line 166/173. 42 | + New FontAwesome Selector (add class name wpts_fa_field to a input) + option for tabFields. 43 | 44 | **2.3.2** 45 | + Toggle Switch for tabFields. 46 | 47 | **2.3.1** 48 | + color field class renamed from wp_theme_settings_color_field to wpts_color_field. 49 | + tabFields (Auto build fields). 50 | + Action hook added for table wpts_tab_NameHere_table 51 | 52 | **2.1.3** 53 | + scrollTop after tab clicked. 54 | 55 | **2.1.2** 56 | + wpColorPicker added (Add wp_theme_settings_color_field class to input text). 57 | + FontAwesomeArray 4.6.3 added. 58 | + FontAwesome 4.6.3 CSS (Back End). 59 | 60 | **2.1.0** 61 | + Style for input,select. 62 | + Return to selected tab after save. 63 | 64 | **2.0** 65 | + Class was completly re-written & more options added. 66 | 67 | **1.1** 68 | + checkTabs() function replaced with keyEntity(). 69 | + WP Dashicons added for tabs. 70 | + Reworked tab array. 71 | 72 | **1.0** 73 | + Release. 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wp_theme_settings (Discontinued) 2 | ## Checkout [Iroh The WordPress Starter Theme For Developers](https://github.com/mattiasghodsian/Iroh) 3 | 4 | **A custom WordPress class for creating theme settings page (Compatible Wordpress 4.5+, Tested on Wordpress 4.7.3)** 5 | 6 | ![Extras](http://i.imgur.com/UI3WnJk.png) 7 | 8 | 9 | NOTE 10 | ---- 11 | This is a utility class intended to create a theme settings page. Read full [docs](https://github.com/mattiasghodsian/wp_theme_settings/wiki) and [changelog](https://github.com/mattiasghodsian/wp_theme_settings/blob/master/changelog.md) 12 | 13 | Installation 14 | ------------ 15 | Place **wp_theme_settings.php**, **wp_theme_settings.js** and **wp_theme_settings.css** in your WordPress theme folder `/wp-content/your-theme/` 16 | 17 | Open your WordPress themes **functions.php** file `/wp-content/your-theme/functions.php` add the following code: 18 | 19 | ```php 20 | include 'wp_theme_settings.php'; 21 | ``` 22 | 23 | Add both CSS & JS file to Wordpress with **admin_enqueue_scripts** 24 | 25 | ```php 26 | add_action('admin_enqueue_scripts', 'wp_theme_settings_add_stylesheet'); 27 | function wp_theme_settings_add_stylesheet(){ 28 | wp_enqueue_style('wp_theme_settings', get_template_directory_uri().'/wp_theme_settings.css'); 29 | wp_register_script('wp_theme_settings',get_template_directory_uri() . '/wp_theme_settings.js', array( 'wp-color-picker' )); 30 | wp_enqueue_script('wp_theme_settings'); 31 | } 32 | ``` 33 | 34 | 35 | 36 | Example 37 | ------------ 38 | ```php 39 | include 'wp_theme_settings.php'; 40 | 41 | $wpts = new wp_theme_settings( 42 | array( 43 | 'general' => array('description' => 'A custom WordPress class for creating theme settings page'), 44 | 'settingsID' => 'wp_theme_settings', 45 | 'settingFields' => array('wp_theme_settings_title'), 46 | 'tabs' => array( 47 | 'general' => array('text' => 'General', 'dashicon' => 'dashicons-admin-generic' ), 48 | 'buttons' => array('text' => 'Buttons') 49 | ), 50 | ) 51 | ); 52 | 53 | add_action('wpts_tab_general' , 'general'); 54 | function general(){ 55 | ?> 56 |

57 | 58 | a").removeClass("nav-tab-active"),jQuery(this).addClass("nav-tab-active"),location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var a=jQuery(this.hash);a.length&&(jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(a).css("display","block"),jQuery(a.selector+" > .wpts-nav-section-holder").css("display","none"),jQuery(a.selector+"_parent").css("display","block"),jQuery(".nav-rtab-form").attr("action","options.php"+a.selector),jQuery("html, body").animate({scrollTop:0},1))}}),jQuery(".wpts-nav-sections > li > a").click(function(){var a=jQuery(this).attr("href");if(a.indexOf("&")!=-1){var b=a.split("&"),c=b[0],d=b[1].replace("section=","#");jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(c).css("display","block"),jQuery(c+" > .wpts-nav-section-holder").css("display","none"),jQuery(d).css("display","block"),jQuery(".nav-rtab-form").attr("action","options.php"+a),jQuery("html, body").animate({scrollTop:0},1)}}),window.location.hash.length){var a=window.location.hash;if(a.indexOf("&")!=-1){var b=a.split("&"),c=b[0],d=b[1].replace("section=","#");jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(c).css("display","block"),jQuery(d).css("display","block")}else jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(a).css("display","block"),jQuery(a+"_parent").css("display","block"),jQuery(".nav-rtab-wrapper > a").removeClass("nav-tab-active"),jQuery('.nav-rtab-wrapper a[href="'+a+'"]').each(function(b){jQuery(this).addClass("nav-tab-active"),jQuery(".nav-rtab-form").attr("action","options.php"+a)})}else{var a=jQuery(".nav-rtab-wrapper > a").first().attr("href");jQuery(a).css("display","block"),jQuery(a+"_parent").css("display","block")}jQuery(".nav-tab-wrapper").length>0&&jQuery("#footer-thankyou").html('Thank you for creating with WPTS'),jQuery(".wpts_color_field").wpColorPicker(),jQuery(".wpts_fa_field").wptsFa();var e;jQuery(".wpts-file-field").click(function(){return jQuery("html").addClass("Image"),e=jQuery(this).prev().attr("id"),tb_show("Upload File","media-upload.php?type=image&TB_iframe=true"),!1}),window.original_send_to_editor=window.send_to_editor,window.send_to_editor=function(a){e?(re=/\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i,res=a.match(re),src=res[1]||res[2]||res[3],jQuery("#"+e).val(src),jQuery(".wpts-file-field-preview").before("#"+e).attr("src",src),tb_remove(),jQuery("html").removeClass("Image")):window.original_send_to_editor(a)}}),function(a){a.fn.wptsFa=function(){return this.each(function(){var b=a(this),c=a(b).attr("name");a(b).hide(),a('
Select icon
').insertBefore(b),a.get("https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml",function(b){var d=jsyaml.load(b);jQuery.each(d.icons,function(b,d){a("#"+c+" .wptsFA-icons").append('')})}),a(this).length>0&&a("#"+c+" .wptsFA-icon").html(''),a("#"+c).click(function(){a(this).toggleClass("active")}),a(document).on("click","#"+c+" .wptsFA-icons > i",function(){var d=a(this).attr("class").replace("fa","");a(b).val(d),a("#"+c+" .wptsFA-icon").html('')})})}}(jQuery); -------------------------------------------------------------------------------- /twentyseventeen-child/wpts/wp_theme_settings.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Name: wp_theme_settings 3 | * GitHub URI: http://www.github.com/mattiasghodsian/wp_theme_settings 4 | * Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page) 5 | * Author: Mattias Ghodsian 6 | * Author URI: http://www.nexxoz.com 7 | * License: GPL-2.0+ 8 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 9 | */ 10 | jQuery(document).ready(function(){if(jQuery('.nav-rtab-wrapper a[href*="#"]:not([href="#"])').click(function(){if(jQuery(".nav-rtab-wrapper > a").removeClass("nav-tab-active"),jQuery(this).addClass("nav-tab-active"),location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname){var a=jQuery(this.hash);a.length&&(jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(a).css("display","block"),jQuery(a.selector+" > .wpts-nav-section-holder").css("display","none"),jQuery(a.selector+"_parent").css("display","block"),jQuery(".nav-rtab-form").attr("action","options.php"+a.selector),jQuery("html, body").animate({scrollTop:0},1))}}),jQuery(".wpts-nav-sections > li > a").click(function(){var a=jQuery(this).attr("href");if(a.indexOf("&")!=-1){var b=a.split("&"),c=b[0],d=b[1].replace("section=","#");jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(c).css("display","block"),jQuery(c+" > .wpts-nav-section-holder").css("display","none"),jQuery(d).css("display","block"),jQuery(".nav-rtab-form").attr("action","options.php"+a),jQuery("html, body").animate({scrollTop:0},1)}}),window.location.hash.length){var a=window.location.hash;if(a.indexOf("&")!=-1){var b=a.split("&"),c=b[0],d=b[1].replace("section=","#");jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(c).css("display","block"),jQuery(d).css("display","block")}else jQuery(".nav-rtabs .nav-rtab-holder").css("display","none"),jQuery(a).css("display","block"),jQuery(a+"_parent").css("display","block"),jQuery(".nav-rtab-wrapper > a").removeClass("nav-tab-active"),jQuery('.nav-rtab-wrapper a[href="'+a+'"]').each(function(b){jQuery(this).addClass("nav-tab-active"),jQuery(".nav-rtab-form").attr("action","options.php"+a)})}else{var a=jQuery(".nav-rtab-wrapper > a").first().attr("href");jQuery(a).css("display","block"),jQuery(a+"_parent").css("display","block")}jQuery(".nav-tab-wrapper").length>0&&jQuery("#footer-thankyou").html('Thank you for creating with WPTS'),jQuery(".wpts_color_field").wpColorPicker(),jQuery(".wpts_fa_field").wptsFa();var e;jQuery(".wpts-file-field").click(function(){return jQuery("html").addClass("Image"),e=jQuery(this).prev().attr("id"),tb_show("Upload File","media-upload.php?type=image&TB_iframe=true"),!1}),window.original_send_to_editor=window.send_to_editor,window.send_to_editor=function(a){e?(re=/\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i,res=a.match(re),src=res[1]||res[2]||res[3],jQuery("#"+e).val(src),jQuery(".wpts-file-field-preview").before("#"+e).attr("src",src),tb_remove(),jQuery("html").removeClass("Image")):window.original_send_to_editor(a)}}),function(a){a.fn.wptsFa=function(){return this.each(function(){var b=a(this),c=a(b).attr("name");a(b).hide(),a('
Select icon
').insertBefore(b),a.get("https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml",function(b){var d=jsyaml.load(b);jQuery.each(d.icons,function(b,d){a("#"+c+" .wptsFA-icons").append('')})}),a(this).length>0&&a("#"+c+" .wptsFA-icon").html(''),a("#"+c).click(function(){a(this).toggleClass("active")}),a(document).on("click","#"+c+" .wptsFA-icons > i",function(){var d=a(this).attr("class").replace("fa","");a(b).val(d),a("#"+c+" .wptsFA-icon").html('')})})}}(jQuery); -------------------------------------------------------------------------------- /wp_theme_settings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Name: wp_theme_settings 3 | * GitHub URI: http://www.github.com/mattiasghodsian/wp_theme_settings 4 | * Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page) 5 | * Author: Mattias Ghodsian 6 | * Author URI: http://www.nexxoz.com 7 | * License: GPL-2.0+ 8 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 9 | */ 10 | jQuery( document ).ready(function() { 11 | 12 | jQuery('.nav-rtab-wrapper a[href*="#"]:not([href="#"])').click(function() { 13 | jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active'); 14 | jQuery(this).addClass('nav-tab-active'); 15 | if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 16 | var target = jQuery(this.hash); 17 | if (target.length) { 18 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 19 | jQuery(target).css("display", "block"); 20 | jQuery(target.selector + ' > .wpts-nav-section-holder').css("display", "none"); 21 | jQuery(target.selector + '_parent').css("display", "block"); 22 | jQuery('.nav-rtab-form').attr("action", "options.php"+target.selector); 23 | jQuery('html, body').animate({scrollTop : 0},1); 24 | } 25 | } 26 | }); 27 | 28 | jQuery('.wpts-nav-sections > li > a').click(function() { 29 | var target = jQuery(this).attr('href'); 30 | if(target.indexOf('&') != -1){ 31 | var target_array = target.split("&"); 32 | var parent_target = target_array[0]; 33 | var section_target = target_array[1].replace("section=", "#"); 34 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 35 | jQuery(parent_target).css("display", "block"); 36 | jQuery(parent_target + ' > .wpts-nav-section-holder').css("display", "none"); 37 | jQuery(section_target).css("display", "block"); 38 | jQuery('.nav-rtab-form').attr("action", "options.php"+target); 39 | jQuery('html, body').animate({scrollTop : 0},1); 40 | } 41 | }); 42 | 43 | if(window.location.hash.length) { 44 | var target = window.location.hash; 45 | if(target.indexOf('&') != -1){ 46 | var target_array = target.split("&"); 47 | var parent_target = target_array[0]; 48 | var section_target = target_array[1].replace("section=", "#"); 49 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 50 | jQuery(parent_target).css("display", "block"); 51 | jQuery(section_target).css("display", "block"); 52 | }else{ 53 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 54 | jQuery(target).css("display", "block"); 55 | jQuery(target + '_parent').css("display", "block"); 56 | jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active'); 57 | jQuery('.nav-rtab-wrapper a[href="'+target+'"]').each(function(e){ 58 | jQuery(this).addClass('nav-tab-active'); 59 | jQuery('.nav-rtab-form').attr("action", "options.php"+target); 60 | }); 61 | } 62 | }else{ 63 | var target = jQuery('.nav-rtab-wrapper > a').first().attr('href'); 64 | jQuery(target).css("display", "block"); 65 | jQuery(target + '_parent').css("display", "block"); 66 | } 67 | 68 | if ( jQuery( '.nav-tab-wrapper' ).length > 0 ) { 69 | jQuery( '#footer-thankyou' ).html('Thank you for creating with WPTS'); 70 | } 71 | 72 | jQuery( '.wpts_color_field' ).wpColorPicker(); 73 | jQuery( '.wpts_fa_field' ).wptsFa(); 74 | 75 | var formfield; 76 | jQuery('.wpts-file-field').click(function() { 77 | jQuery('html').addClass('Image'); 78 | formfield = jQuery(this).prev().attr('id'); 79 | tb_show('Upload File', 'media-upload.php?type=image&TB_iframe=true'); 80 | return false; 81 | }); 82 | 83 | window.original_send_to_editor = window.send_to_editor; 84 | 85 | window.send_to_editor = function(html){ 86 | if (formfield) { 87 | re = /\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i, 88 | res = html.match(re), 89 | src = res[1]||res[2]||res[3]; 90 | jQuery('#'+formfield).val(src); 91 | jQuery( ".wpts-file-field-preview" ).before('#'+formfield).attr('src', src); 92 | tb_remove(); 93 | jQuery('html').removeClass('Image'); 94 | } else { 95 | window.original_send_to_editor(html); 96 | } 97 | }; 98 | 99 | 100 | 101 | }); 102 | 103 | (function( $ ){ 104 | $.fn.wptsFa = function() { 105 | return this.each(function() { 106 | var mainE = $(this); 107 | var mainName = $(mainE).attr('name'); 108 | $(mainE).hide(); 109 | 110 | $( '
Select icon
').insertBefore(mainE); 111 | 112 | $.get( 'https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml', function( data ) { 113 | var obj = jsyaml.load( data ); 114 | jQuery.each( obj['icons'], function( i, val ) { 115 | $('#' + mainName + ' .wptsFA-icons').append(''); 116 | }); 117 | }); 118 | 119 | if ($(this).length > 0) { 120 | $('#' + mainName + ' .wptsFA-icon').html(''); 121 | } 122 | 123 | $('#' + mainName).click(function(){ 124 | $(this).toggleClass('active'); 125 | }); 126 | 127 | $(document).on("click",'#' + mainName + ' .wptsFA-icons > i',function() { 128 | var id = $(this).attr('class').replace('fa',''); 129 | $(mainE).val(id); 130 | $('#' + mainName + ' .wptsFA-icon').html(''); 131 | }); 132 | 133 | }); 134 | }; 135 | })( jQuery ); -------------------------------------------------------------------------------- /twentyseventeen-child/wpts/wp_theme_settings.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Name: wp_theme_settings 3 | * GitHub URI: http://www.github.com/mattiasghodsian/wp_theme_settings 4 | * Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page) 5 | * Author: Mattias Ghodsian 6 | * Author URI: http://www.nexxoz.com 7 | * License: GPL-2.0+ 8 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 9 | */ 10 | jQuery( document ).ready(function() { 11 | 12 | jQuery('.nav-rtab-wrapper a[href*="#"]:not([href="#"])').click(function() { 13 | jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active'); 14 | jQuery(this).addClass('nav-tab-active'); 15 | if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 16 | var target = jQuery(this.hash); 17 | if (target.length) { 18 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 19 | jQuery(target).css("display", "block"); 20 | jQuery(target.selector + ' > .wpts-nav-section-holder').css("display", "none"); 21 | jQuery(target.selector + '_parent').css("display", "block"); 22 | jQuery('.nav-rtab-form').attr("action", "options.php"+target.selector); 23 | jQuery('html, body').animate({scrollTop : 0},1); 24 | } 25 | } 26 | }); 27 | 28 | jQuery('.wpts-nav-sections > li > a').click(function() { 29 | var target = jQuery(this).attr('href'); 30 | if(target.indexOf('&') != -1){ 31 | var target_array = target.split("&"); 32 | var parent_target = target_array[0]; 33 | var section_target = target_array[1].replace("section=", "#"); 34 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 35 | jQuery(parent_target).css("display", "block"); 36 | jQuery(parent_target + ' > .wpts-nav-section-holder').css("display", "none"); 37 | jQuery(section_target).css("display", "block"); 38 | jQuery('.nav-rtab-form').attr("action", "options.php"+target); 39 | jQuery('html, body').animate({scrollTop : 0},1); 40 | } 41 | }); 42 | 43 | if(window.location.hash.length) { 44 | var target = window.location.hash; 45 | if(target.indexOf('&') != -1){ 46 | var target_array = target.split("&"); 47 | var parent_target = target_array[0]; 48 | var section_target = target_array[1].replace("section=", "#"); 49 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 50 | jQuery(parent_target).css("display", "block"); 51 | jQuery(section_target).css("display", "block"); 52 | }else{ 53 | jQuery('.nav-rtabs .nav-rtab-holder').css("display", "none"); 54 | jQuery(target).css("display", "block"); 55 | jQuery(target + '_parent').css("display", "block"); 56 | jQuery('.nav-rtab-wrapper > a').removeClass('nav-tab-active'); 57 | jQuery('.nav-rtab-wrapper a[href="'+target+'"]').each(function(e){ 58 | jQuery(this).addClass('nav-tab-active'); 59 | jQuery('.nav-rtab-form').attr("action", "options.php"+target); 60 | }); 61 | } 62 | }else{ 63 | var target = jQuery('.nav-rtab-wrapper > a').first().attr('href'); 64 | jQuery(target).css("display", "block"); 65 | jQuery(target + '_parent').css("display", "block"); 66 | } 67 | 68 | if ( jQuery( '.nav-tab-wrapper' ).length > 0 ) { 69 | jQuery( '#footer-thankyou' ).html('Thank you for creating with WPTS'); 70 | } 71 | 72 | jQuery( '.wpts_color_field' ).wpColorPicker(); 73 | jQuery( '.wpts_fa_field' ).wptsFa(); 74 | 75 | var formfield; 76 | jQuery('.wpts-file-field').click(function() { 77 | jQuery('html').addClass('Image'); 78 | formfield = jQuery(this).prev().attr('id'); 79 | tb_show('Upload File', 'media-upload.php?type=image&TB_iframe=true'); 80 | return false; 81 | }); 82 | 83 | window.original_send_to_editor = window.send_to_editor; 84 | 85 | window.send_to_editor = function(html){ 86 | if (formfield) { 87 | re = /\ssrc=(?:(?:'([^']*)')|(?:"([^"]*)")|([^\s]*))/i, 88 | res = html.match(re), 89 | src = res[1]||res[2]||res[3]; 90 | jQuery('#'+formfield).val(src); 91 | jQuery( ".wpts-file-field-preview" ).before('#'+formfield).attr('src', src); 92 | tb_remove(); 93 | jQuery('html').removeClass('Image'); 94 | } else { 95 | window.original_send_to_editor(html); 96 | } 97 | }; 98 | 99 | 100 | 101 | }); 102 | 103 | (function( $ ){ 104 | $.fn.wptsFa = function() { 105 | return this.each(function() { 106 | var mainE = $(this); 107 | var mainName = $(mainE).attr('name'); 108 | $(mainE).hide(); 109 | 110 | $( '
Select icon
').insertBefore(mainE); 111 | 112 | $.get( 'https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml', function( data ) { 113 | var obj = jsyaml.load( data ); 114 | jQuery.each( obj['icons'], function( i, val ) { 115 | $('#' + mainName + ' .wptsFA-icons').append(''); 116 | }); 117 | }); 118 | 119 | if ($(this).length > 0) { 120 | $('#' + mainName + ' .wptsFA-icon').html(''); 121 | } 122 | 123 | $('#' + mainName).click(function(){ 124 | $(this).toggleClass('active'); 125 | }); 126 | 127 | $(document).on("click",'#' + mainName + ' .wptsFA-icons > i',function() { 128 | var id = $(this).attr('class').replace('fa',''); 129 | $(mainE).val(id); 130 | $('#' + mainName + ' .wptsFA-icon').html(''); 131 | }); 132 | 133 | }); 134 | }; 135 | })( jQuery ); -------------------------------------------------------------------------------- /wp_theme_settings.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Name: wp_theme_settings 3 | * GitHub URI: http://www.github.com/mattiasghodsian/wp_theme_settings 4 | * Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page) 5 | * Author: Mattias Ghodsian 6 | * Author URI: http://www.nexxoz.com 7 | * License: GPL-2.0+ 8 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 9 | */ 10 | .nav-rtabs .nav-rtab-holder:first-child{ 11 | display: block; 12 | } 13 | 14 | .nav-rtabs .nav-rtab-holder{ 15 | display: none; 16 | } 17 | 18 | .nav-rtabs .nav-rtab-holder input[type=text], 19 | .nav-rtabs .nav-rtab-holder select, 20 | .nav-rtabs .nav-rtab-holder input[type=number]{ 21 | display: inline-block; 22 | min-width: 300px; 23 | height: 34px; 24 | padding: 6px 12px; 25 | font-size: 14px; 26 | line-height: 1.42857143; 27 | color: #555; 28 | background-color: #fff; 29 | background-image: none; 30 | border: 1px solid #ccc; 31 | border-radius: 4px; 32 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 33 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 34 | } 35 | 36 | .nav-rtabs .nav-rtab-holder input[type=number]::-webkit-inner-spin-button, 37 | .nav-rtabs .nav-rtab-holder input[type=number]::-webkit-outer-spin-button { 38 | opacity: 1; 39 | } 40 | 41 | .nav-rtab-wrapper > .nav-tab{ 42 | font-size: 15px; 43 | } 44 | 45 | .wp-rbadge{ 46 | background-size: 90px 90px; 47 | } 48 | 49 | .nav-rtab-wrapper > .nav-tab span{ 50 | padding-right: 5px; 51 | width: 17px; 52 | height: 17px; 53 | font-size: 17px; 54 | line-height: 25px; 55 | } 56 | 57 | .nav-rtab-holder tr td label { 58 | display: block; 59 | padding-bottom: 8px; 60 | } 61 | 62 | .nav-rtab-holder .switch { 63 | position: relative; 64 | display: inline-block; 65 | width: 54px; 66 | height: 20px; 67 | } 68 | 69 | .nav-rtab-holder .switch input { 70 | display:none; 71 | } 72 | 73 | .nav-rtab-holder .slider { 74 | position: absolute; 75 | cursor: pointer; 76 | top: 0; 77 | left: 0; 78 | right: 0; 79 | bottom: 0; 80 | background-color: #ccc; 81 | -webkit-transition: .4s; 82 | transition: .4s; 83 | } 84 | 85 | .nav-rtab-holder .slider:before { 86 | position: absolute; 87 | content: ""; 88 | height: 20px; 89 | width: 20px; 90 | left: 4px; 91 | bottom: 4px; 92 | background-color: white; 93 | -webkit-transition: .4s; 94 | transition: .4s; 95 | } 96 | 97 | .nav-rtab-holder input:checked + .slider { 98 | background-color: #5cb85c; 99 | } 100 | 101 | .nav-rtab-holder input:focus + .slider { 102 | box-shadow: 0 0 1px #5cb85c; 103 | } 104 | 105 | .nav-rtab-holder input:checked + .slider:before { 106 | -webkit-transform: translateX(25px); 107 | -ms-transform: translateX(25px); 108 | transform: translateX(25px); 109 | } 110 | 111 | .nav-rtab-holder .slider.round { 112 | border-radius: 34px; 113 | } 114 | 115 | .nav-rtab-holder .slider.round:before { 116 | border-radius: 50%; 117 | } 118 | 119 | .wptsFA-container{ 120 | height: 34px; 121 | min-width: 300px; 122 | border: 1px solid #ccc; 123 | border-bottom: 2px solid #ccc; 124 | display: inline-block; 125 | border-radius: 4px; 126 | cursor: pointer; 127 | background: #F7F7F7; 128 | position: relative; 129 | -webkit-touch-callout: none; 130 | -webkit-user-select: none; 131 | -khtml-user-select: none; 132 | -moz-user-select: none; 133 | -ms-user-select: none; 134 | user-select: none; 135 | } 136 | 137 | 138 | .wptsFA-container .wptsFA-icon{ 139 | height: 34px; 140 | min-width: 45px; 141 | background: #c1bdbd; 142 | display: inline-table; 143 | color: #000; 144 | text-align: center; 145 | position: absolute; 146 | } 147 | 148 | .wptsFA-container .wptsFA-icon .fa{ 149 | font-size: 1.5em; 150 | line-height: 34px; 151 | display: block; 152 | } 153 | 154 | .wptsFA-container .wptsFA-button{ 155 | height: 34px; 156 | min-width: 255px; 157 | position: absolute; 158 | right: 0; 159 | display: inline-table; 160 | color: #000; 161 | text-align: center; 162 | line-height: 34px; 163 | } 164 | 165 | .wptsFA-container.active .wptsFA-icons{ 166 | display: block; 167 | } 168 | 169 | .wptsFA-container .wptsFA-icons{ 170 | position: absolute; 171 | top: 100%; 172 | left: 0; 173 | z-index: 1000; 174 | display: none; 175 | float: left; 176 | min-width: 300px; 177 | height: 100px; 178 | overflow-y: auto; 179 | padding: 0px 0; 180 | margin: -1px 0 0 -1px; 181 | font-size: 14px; 182 | text-align: left; 183 | list-style: none; 184 | background-color: #fff; 185 | -webkit-background-clip: padding-box; 186 | background-clip: padding-box; 187 | border: 1px solid #ccc; 188 | border: 1px solid rgba(0,0,0,.15); 189 | border-bottom-right-radius: 4px; 190 | border-bottom-left-radius: 4px; 191 | text-align: center; 192 | } 193 | 194 | .wptsFA-container .wptsFA-icons > i{ 195 | padding: 11.48px; 196 | font-size: 1.5em; 197 | color: #847272; 198 | } 199 | 200 | .wptsFA-container .wptsFA-icons > i:hover{ 201 | color: #000000; 202 | } 203 | 204 | .wpts-wrap { 205 | max-width: 90%!important; 206 | } 207 | 208 | .wpts-file-field{ 209 | display: inline-block!important; 210 | height: 33px!important; 211 | margin-top: 1px!important; 212 | } 213 | 214 | .wpts-file-field-preview{ 215 | max-width: 300px!important; 216 | display: block; 217 | border-radius: 5px; 218 | margin-bottom: 3px!important; 219 | } 220 | 221 | .wpts-toolbar-icon{ 222 | max-width: 18px; 223 | margin-right: 6px!important; 224 | padding-top: 7px!important; 225 | float: left; 226 | } 227 | 228 | .wpts-wrap h1{ 229 | padding-bottom: 10px; 230 | } 231 | 232 | .wpts-wrap .notice { 233 | display: block!important; 234 | width: 82%; 235 | } 236 | 237 | .wpts-wrap .about-text{ 238 | margin: 10px 200px 10px 0; 239 | font-size: 16.5px; 240 | } 241 | 242 | .wpts-tooltip { 243 | position: relative; 244 | display: inline-block; 245 | border-radius: 50%; 246 | width: 20px; 247 | height: 20px; 248 | color: #fff; 249 | background: #555; 250 | cursor: pointer; 251 | text-align: center; 252 | margin-left: 5px; 253 | } 254 | 255 | .wpts-tooltip .wpts-tooltiptext { 256 | visibility: hidden; 257 | text-align: center; 258 | width: 130px; 259 | background: #555; 260 | color: #fff; 261 | font-size: 13px; 262 | padding: 3px 5px; 263 | border-radius: 3px; 264 | position: absolute; 265 | z-index: 1; 266 | opacity: 0; 267 | transition: opacity 1s; 268 | } 269 | .wpts-tooltip:hover .wpts-tooltiptext { 270 | visibility: visible; 271 | opacity: 1; 272 | transition: opacity 1s; 273 | } 274 | 275 | .wpts-tooltip .wpts-tooltiptext.wpts-tooltip-top { 276 | bottom: 125%; 277 | left: 50%; 278 | margin-left: -60px; 279 | } 280 | 281 | .wpts-tooltip-top::after { 282 | content: ""; 283 | position: absolute; 284 | top: 100%; 285 | left: 50%; 286 | margin-left: -5px; 287 | border-width: 5px; 288 | border-style: solid; 289 | border-color: #555 transparent transparent transparent; 290 | } 291 | 292 | .wpts-tooltip .wpts-tooltiptext.wpts-tooltip-right { 293 | top: -2px; 294 | left: 130%; 295 | } 296 | 297 | .wpts-tooltip-right::after { 298 | content: ""; 299 | position: absolute; 300 | top: 6px; 301 | left:0%; 302 | margin-left: -5px; 303 | border-width: 5px 5px 5px 0; 304 | border-style: solid; 305 | border-color: transparent #555 transparent transparent; 306 | } 307 | 308 | .wpts-nav-sections li{ 309 | float: left; 310 | } 311 | 312 | .wpts-nav-sections li a{ 313 | border-right: 1px solid #ccc; 314 | padding: 0px 12px; 315 | font-size: 13px; 316 | text-decoration: none; 317 | } 318 | 319 | .wpts-nav-sections li:last-child a{ 320 | border-right: none; 321 | } 322 | 323 | .wpts-nav-section-holder{ 324 | display: none; 325 | } -------------------------------------------------------------------------------- /twentyseventeen-child/wpts/wp_theme_settings.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Class Name: wp_theme_settings 3 | * GitHub URI: http://www.github.com/mattiasghodsian/wp_theme_settings 4 | * Description: A custom WordPress class for creating theme settings page (Design looks identical to WP About page) 5 | * Author: Mattias Ghodsian 6 | * Author URI: http://www.nexxoz.com 7 | * License: GPL-2.0+ 8 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 9 | */ 10 | .nav-rtabs .nav-rtab-holder:first-child{ 11 | display: block; 12 | } 13 | 14 | .nav-rtabs .nav-rtab-holder{ 15 | display: none; 16 | } 17 | 18 | .nav-rtabs .nav-rtab-holder input[type=text], 19 | .nav-rtabs .nav-rtab-holder select, 20 | .nav-rtabs .nav-rtab-holder input[type=number]{ 21 | display: inline-block; 22 | min-width: 300px; 23 | height: 34px; 24 | padding: 6px 12px; 25 | font-size: 14px; 26 | line-height: 1.42857143; 27 | color: #555; 28 | background-color: #fff; 29 | background-image: none; 30 | border: 1px solid #ccc; 31 | border-radius: 4px; 32 | -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 33 | box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 34 | } 35 | 36 | .nav-rtabs .nav-rtab-holder input[type=number]::-webkit-inner-spin-button, 37 | .nav-rtabs .nav-rtab-holder input[type=number]::-webkit-outer-spin-button { 38 | opacity: 1; 39 | } 40 | 41 | .nav-rtab-wrapper > .nav-tab{ 42 | font-size: 15px; 43 | } 44 | 45 | .wp-rbadge{ 46 | background-size: 90px 90px; 47 | } 48 | 49 | .nav-rtab-wrapper > .nav-tab span{ 50 | padding-right: 5px; 51 | width: 17px; 52 | height: 17px; 53 | font-size: 17px; 54 | line-height: 25px; 55 | } 56 | 57 | .nav-rtab-holder tr td label { 58 | display: block; 59 | padding-bottom: 8px; 60 | } 61 | 62 | .nav-rtab-holder .switch { 63 | position: relative; 64 | display: inline-block; 65 | width: 54px; 66 | height: 20px; 67 | } 68 | 69 | .nav-rtab-holder .switch input { 70 | display:none; 71 | } 72 | 73 | .nav-rtab-holder .slider { 74 | position: absolute; 75 | cursor: pointer; 76 | top: 0; 77 | left: 0; 78 | right: 0; 79 | bottom: 0; 80 | background-color: #ccc; 81 | -webkit-transition: .4s; 82 | transition: .4s; 83 | } 84 | 85 | .nav-rtab-holder .slider:before { 86 | position: absolute; 87 | content: ""; 88 | height: 20px; 89 | width: 20px; 90 | left: 4px; 91 | bottom: 4px; 92 | background-color: white; 93 | -webkit-transition: .4s; 94 | transition: .4s; 95 | } 96 | 97 | .nav-rtab-holder input:checked + .slider { 98 | background-color: #5cb85c; 99 | } 100 | 101 | .nav-rtab-holder input:focus + .slider { 102 | box-shadow: 0 0 1px #5cb85c; 103 | } 104 | 105 | .nav-rtab-holder input:checked + .slider:before { 106 | -webkit-transform: translateX(25px); 107 | -ms-transform: translateX(25px); 108 | transform: translateX(25px); 109 | } 110 | 111 | .nav-rtab-holder .slider.round { 112 | border-radius: 34px; 113 | } 114 | 115 | .nav-rtab-holder .slider.round:before { 116 | border-radius: 50%; 117 | } 118 | 119 | .wptsFA-container{ 120 | height: 34px; 121 | min-width: 300px; 122 | border: 1px solid #ccc; 123 | border-bottom: 2px solid #ccc; 124 | display: inline-block; 125 | border-radius: 4px; 126 | cursor: pointer; 127 | background: #F7F7F7; 128 | position: relative; 129 | -webkit-touch-callout: none; 130 | -webkit-user-select: none; 131 | -khtml-user-select: none; 132 | -moz-user-select: none; 133 | -ms-user-select: none; 134 | user-select: none; 135 | } 136 | 137 | 138 | .wptsFA-container .wptsFA-icon{ 139 | height: 34px; 140 | min-width: 45px; 141 | background: #c1bdbd; 142 | display: inline-table; 143 | color: #000; 144 | text-align: center; 145 | position: absolute; 146 | } 147 | 148 | .wptsFA-container .wptsFA-icon .fa{ 149 | font-size: 1.5em; 150 | line-height: 34px; 151 | display: block; 152 | } 153 | 154 | .wptsFA-container .wptsFA-button{ 155 | height: 34px; 156 | min-width: 255px; 157 | position: absolute; 158 | right: 0; 159 | display: inline-table; 160 | color: #000; 161 | text-align: center; 162 | line-height: 34px; 163 | } 164 | 165 | .wptsFA-container.active .wptsFA-icons{ 166 | display: block; 167 | } 168 | 169 | .wptsFA-container .wptsFA-icons{ 170 | position: absolute; 171 | top: 100%; 172 | left: 0; 173 | z-index: 1000; 174 | display: none; 175 | float: left; 176 | min-width: 300px; 177 | height: 100px; 178 | overflow-y: auto; 179 | padding: 0px 0; 180 | margin: -1px 0 0 -1px; 181 | font-size: 14px; 182 | text-align: left; 183 | list-style: none; 184 | background-color: #fff; 185 | -webkit-background-clip: padding-box; 186 | background-clip: padding-box; 187 | border: 1px solid #ccc; 188 | border: 1px solid rgba(0,0,0,.15); 189 | border-bottom-right-radius: 4px; 190 | border-bottom-left-radius: 4px; 191 | text-align: center; 192 | } 193 | 194 | .wptsFA-container .wptsFA-icons > i{ 195 | padding: 11.48px; 196 | font-size: 1.5em; 197 | color: #847272; 198 | } 199 | 200 | .wptsFA-container .wptsFA-icons > i:hover{ 201 | color: #000000; 202 | } 203 | 204 | .wpts-wrap { 205 | max-width: 90%!important; 206 | } 207 | 208 | .wpts-file-field{ 209 | display: inline-block!important; 210 | height: 33px!important; 211 | margin-top: 1px!important; 212 | } 213 | 214 | .wpts-file-field-preview{ 215 | max-width: 300px!important; 216 | display: block; 217 | border-radius: 5px; 218 | margin-bottom: 3px!important; 219 | } 220 | 221 | .wpts-toolbar-icon{ 222 | max-width: 18px; 223 | margin-right: 6px!important; 224 | padding-top: 7px!important; 225 | float: left; 226 | } 227 | 228 | .wpts-wrap h1{ 229 | padding-bottom: 10px; 230 | } 231 | 232 | .wpts-wrap .notice { 233 | display: block!important; 234 | width: 82%; 235 | } 236 | 237 | .wpts-wrap .about-text{ 238 | margin: 10px 200px 10px 0; 239 | font-size: 16.5px; 240 | } 241 | 242 | .wpts-tooltip { 243 | position: relative; 244 | display: inline-block; 245 | border-radius: 50%; 246 | width: 20px; 247 | height: 20px; 248 | color: #fff; 249 | background: #555; 250 | cursor: pointer; 251 | text-align: center; 252 | margin-left: 5px; 253 | } 254 | 255 | .wpts-tooltip .wpts-tooltiptext { 256 | visibility: hidden; 257 | text-align: center; 258 | width: 130px; 259 | background: #555; 260 | color: #fff; 261 | font-size: 13px; 262 | padding: 3px 5px; 263 | border-radius: 3px; 264 | position: absolute; 265 | z-index: 1; 266 | opacity: 0; 267 | transition: opacity 1s; 268 | } 269 | .wpts-tooltip:hover .wpts-tooltiptext { 270 | visibility: visible; 271 | opacity: 1; 272 | transition: opacity 1s; 273 | } 274 | 275 | .wpts-tooltip .wpts-tooltiptext.wpts-tooltip-top { 276 | bottom: 125%; 277 | left: 50%; 278 | margin-left: -60px; 279 | } 280 | 281 | .wpts-tooltip-top::after { 282 | content: ""; 283 | position: absolute; 284 | top: 100%; 285 | left: 50%; 286 | margin-left: -5px; 287 | border-width: 5px; 288 | border-style: solid; 289 | border-color: #555 transparent transparent transparent; 290 | } 291 | 292 | .wpts-tooltip .wpts-tooltiptext.wpts-tooltip-right { 293 | top: -2px; 294 | left: 130%; 295 | } 296 | 297 | .wpts-tooltip-right::after { 298 | content: ""; 299 | position: absolute; 300 | top: 6px; 301 | left:0%; 302 | margin-left: -5px; 303 | border-width: 5px 5px 5px 0; 304 | border-style: solid; 305 | border-color: transparent #555 transparent transparent; 306 | } 307 | 308 | .wpts-nav-sections li{ 309 | float: left; 310 | } 311 | 312 | .wpts-nav-sections li a{ 313 | border-right: 1px solid #ccc; 314 | padding: 0px 12px; 315 | font-size: 13px; 316 | text-decoration: none; 317 | } 318 | 319 | .wpts-nav-sections li:last-child a{ 320 | border-right: none; 321 | } 322 | 323 | .wpts-nav-section-holder{ 324 | display: none; 325 | } -------------------------------------------------------------------------------- /wp_theme_settings.php: -------------------------------------------------------------------------------- 1 | tabs = (array_key_exists('tabs', $args)) ? $args['tabs'] : array(); 37 | $this->theme = wp_get_theme(); 38 | $this->general = (array_key_exists('general', $args)) ? $args['general'] : array(); 39 | $this->badge = (array_key_exists('badge', $args)) ? $args['badge'] : ''; 40 | $this->settingsID = (array_key_exists('settingsID', $args)) ? $this->keyEntity($args['settingsID']).'-settings-group' : ''; 41 | $this->settingFields = (array_key_exists('settingFields', $args)) ? $args['settingFields'] : array(); 42 | $this->toolbar = (array_key_exists('toolbar', $args['general'])) ? $args['general']['toolbar'] : array(); 43 | $this->notice = (array_key_exists('notice', $args['general'])) ? $args['general']['notice'] : true; 44 | /* 45 | * @ Add tabfields (tabs & sections) to settingsfield 46 | */ 47 | foreach ($this->tabs as $key => $data) { 48 | if (array_key_exists('tabFields', $data)) { 49 | foreach ($data["tabFields"] as $key => $value) { 50 | array_push($this->settingFields, $value['name']); 51 | } 52 | } 53 | if (array_key_exists('sections', $data)) { 54 | foreach ($data["sections"] as $key => $section) { 55 | if (array_key_exists('tabFields', $section)) { 56 | foreach ($section["tabFields"] as $key => $section_tabFields) { 57 | array_push($this->settingFields, $section_tabFields['name']); 58 | } 59 | } 60 | } 61 | } 62 | } 63 | /* 64 | * @ call register theme_settings function 65 | */ 66 | add_action('admin_init', array($this,'theme_settings')); 67 | /* 68 | * @ call register menu 69 | */ 70 | add_action('admin_menu', array($this,'menu')); 71 | /* 72 | * @ call js & css 73 | */ 74 | add_action('admin_enqueue_scripts', array($this, 'wp_theme_settings_js_css')); 75 | /* 76 | * @ call option function 77 | */ 78 | add_filter( 'wpts_option', array($this, 'wpts_option')); 79 | /* 80 | * @ call toolbar function 81 | */ 82 | if (array_key_exists('toolbar', $args['general']) && $args['general']['toolbar'] != false) { 83 | add_action('admin_bar_menu', array($this, 'wpts_toolbar'), 999); 84 | } 85 | /* 86 | * @ check update notice 87 | if ($this->notice !== false ) { 88 | if ( $this->get_wpts_git_version() > $this->currversion ) { 89 | add_action( 'admin_notices', array($this, 'wpts_update_admin_notice') ); 90 | } 91 | } 92 | */ 93 | } 94 | 95 | /* 96 | * @ WP Toolbar 97 | */ 98 | public function wpts_toolbar($wp_admin_bar) { 99 | $menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme'); 100 | $menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings'); 101 | $menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : ''); 102 | $toolbar_title = (array_key_exists('toolbar_title', $this->toolbar) ? $this->toolbar['toolbar_title'] : 'WPTS'); 103 | $toolbar_image = (array_key_exists('toolbar_image', $this->toolbar) ? $this->toolbar['toolbar_image'] : 'http://i.imgur.com/3BfjiTf.png'); 104 | $toolbar_href = (array_key_exists('toolbar_href', $this->toolbar) ? $this->toolbar['toolbar_href'] : 'https://git.io/vi1Gr'); 105 | 106 | if ($toolbar_image) { 107 | $toolbar_image = ' '; 108 | } 109 | 110 | $args = array( 111 | 'id' => 'wpts', 112 | 'title' => $toolbar_image.$toolbar_title, 113 | 'href' => $toolbar_href, 114 | 'meta' => array('class' => 'wpts-toolbar'), 115 | ); 116 | 117 | $wp_admin_bar->add_node($args); 118 | 119 | switch ($menu_type) { 120 | case 'submenu': 121 | $href = home_url().'/wp-admin/'.$menu_parent.'&page='.$menu_slug.'#%%key%%'; 122 | break; 123 | case 'options': 124 | $href = home_url().'/wp-admin/options-general.php?page='.$menu_slug.'#%%key%%'; 125 | break; 126 | default: 127 | $href = home_url().'/wp-admin/themes.php?page='.$menu_slug.'#%%key%%'; 128 | break; 129 | } 130 | 131 | foreach ($this->tabs as $key => $tab) { 132 | $args = array( 133 | 'id' => 'wpts-'.$this->keyEntity($key), 134 | 'title' => $tab['text'], 135 | 'href' => str_replace( '%%key%%', $this->keyEntity($key), $href ), 136 | 'parent' => 'wpts', 137 | ); 138 | $wp_admin_bar->add_node($args); 139 | } 140 | } 141 | 142 | 143 | /* 144 | * @ jQuery & Css 145 | */ 146 | public function wp_theme_settings_js_css(){ 147 | wp_enqueue_style( 'wp-color-picker' ); 148 | wp_enqueue_script( 'wp-color-picker'); 149 | wp_enqueue_style('fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); 150 | wp_register_script('js-yaml','https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.6.1/js-yaml.js', array('jquery')); 151 | wp_enqueue_script('js-yaml'); 152 | wp_enqueue_script('media-upload'); 153 | wp_enqueue_script('thickbox'); 154 | wp_enqueue_style('thickbox'); 155 | } 156 | /* 157 | * @ Register theme menu. 158 | */ 159 | public function menu() { 160 | $menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme'); 161 | $page_title = (array_key_exists('title', $this->general) ? $this->general['title'] : 'Theme Settings'); 162 | $menu_title = (array_key_exists('menu_title', $this->general) ? $this->general['menu_title'] : 'Theme Settings'); 163 | $menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings'); 164 | $menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : ''); 165 | $capability = (array_key_exists('capability', $this->general) ? $this->general['capability'] : 'manage_options'); 166 | switch ($menu_type) { 167 | case 'submenu': 168 | add_submenu_page($menu_parent, $page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 169 | break; 170 | case 'options': 171 | add_options_page( $page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 172 | break; 173 | default: 174 | add_theme_page($page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 175 | break; 176 | } 177 | } 178 | /* 179 | * @ Generate Display. 180 | */ 181 | public function tabs(){ 182 | echo '
'; 183 | $this->navHeader(); 184 | $this->navTabs(); 185 | echo '
'; 186 | } 187 | /* 188 | * @ Build table for tabs 189 | */ 190 | private function tab_container($array, $parent){ 191 | echo ''; 192 | do_action('wpts_tab_'.$parent.'_table_before'); 193 | foreach ($array as $key => $data) { 194 | 195 | echo ''; 196 | 197 | echo ''; 202 | 203 | echo ''; 209 | 210 | echo ''; 211 | 212 | array_push($this->settingFields, $data['name']); 213 | } 214 | 215 | do_action('wpts_tab_'.$parent.'_table_after'); 216 | echo '
'; 198 | if (array_key_exists('label', $data)) { 199 | echo ''; 200 | } 201 | echo ''; 204 | echo $this->binput($data); 205 | if (array_key_exists('description', $data)) { 206 | echo '

'.$data['description'].'

'; 207 | } 208 | echo '
'; 217 | } 218 | /* 219 | * @ Build inputs 220 | */ 221 | private function binput($array){ 222 | if (array_key_exists('class', $array)) { 223 | $html_class = $array['class']; 224 | }else{ 225 | $html_class = ''; 226 | } 227 | 228 | switch ($array['type']) { 229 | 230 | // Build text 231 | case 'text': 232 | echo ''; 233 | if (array_key_exists('tooltip', $array)) { 234 | echo '
!'.$array['tooltip'].'
'; 235 | } 236 | break; 237 | // Build file 238 | case 'file': 239 | if (array_key_exists('preview', $array) && $array['preview'] == true) { 240 | echo ''; 241 | } 242 | echo ''; 243 | break; 244 | // Build fontawesome selector 245 | case 'fa': 246 | echo ''; 247 | break; 248 | // Build Color 249 | case 'color': 250 | echo ''; 251 | break; 252 | // Build Select 253 | case 'select': 254 | echo ''; 260 | if (array_key_exists('tooltip', $array)) { 261 | echo '
!'.$array['tooltip'].'
'; 262 | } 263 | break; 264 | // Build Radio 265 | case 'radio': 266 | foreach ($array['options'] as $key => $value) { 267 | echo ' 268 | '; 272 | } 273 | 274 | break; 275 | // Build Checkbox 276 | case 'checkbox': 277 | echo ' 278 |
279 |
'; 280 | break; 281 | // Build Toggle Switch 282 | case 'toggle': 283 | echo ' 284 | 288 | '; 289 | if (array_key_exists('tooltip', $array)) { 290 | echo '
!'.$array['tooltip'].'
'; 291 | } 292 | break; 293 | // default return false 294 | default: 295 | return false; 296 | break; 297 | } 298 | } 299 | /* 300 | * @ Generate tabs 301 | */ 302 | private function navTabs(){ 303 | $i = 0; 304 | echo ''; 310 | 311 | 312 | echo ''; 349 | } 350 | /* 351 | * @ Tab Head 352 | */ 353 | private function navHeader(){ 354 | 355 | if (array_key_exists('title', $this->general)) { 356 | echo '

'.ucfirst($this->general['title']).'

'; 357 | }else{ 358 | echo '

'.ucfirst($this->theme->get( 'Name' )).' Theme Settings

359 | '; 360 | } 361 | 362 | 363 | if (array_key_exists('description', $this->general)) { 364 | echo '
'.$this->general['description'].'
'; 365 | } 366 | 367 | 368 | if (!empty($this->badge)) { 369 | 370 | if (array_key_exists('bg-image', $this->badge)) { 371 | echo '
'; 372 | }else{ 373 | echo '
'; 374 | } 375 | 376 | if (array_key_exists('version', $this->badge) && $this->badge['version'] == false) { 377 | // do nothing 378 | }else{ 379 | echo 'Version '.$this->theme->get('Version'); 380 | } 381 | echo '
'; 382 | } 383 | } 384 | /* 385 | * @ Remove special chars 386 | */ 387 | private function keyEntity($key){ 388 | $key = preg_replace( '/[^a-zA-Z0-9\']/', '_', $key ); 389 | return rtrim( $key, '_' ); 390 | } 391 | /* 392 | * @ Register Settings 393 | */ 394 | public function theme_settings(){ 395 | foreach ( $this->settingFields as $value ) { 396 | register_setting( $this->settingsID, $value, array($this, 'sanitize') ); 397 | } 398 | } 399 | /* 400 | * @ Sanitize inputs 401 | */ 402 | public function sanitize($input){ 403 | return sanitize_text_field($input); 404 | } 405 | /* 406 | * @ Get Option value 407 | */ 408 | public function wpts_option($key){ 409 | return esc_attr( get_option($key) ); 410 | } 411 | 412 | /* 413 | * @ Update notice 414 | */ 415 | public function wpts_update_admin_notice() { 416 | $class = 'notice notice-info is-dismissible'; 417 | $message = __( 'New version of WPTS is available ('.$this->get_wpts_git_version().'), click here to learn more about it.'); 418 | printf( '

%2$s

', $class, $message ); 419 | } 420 | 421 | /* 422 | * @ Get wpts github version 423 | */ 424 | private function get_wpts_git_version(){ 425 | try { 426 | $url = "http://wpts.nexxoz.com/changelog.txt"; 427 | $data = file_get_contents($url); 428 | $t = preg_split("#\n\s*\n#Uis", $data); 429 | foreach ($t as $key => $value) { 430 | $lines = explode('+', $value); 431 | $version = str_replace("**", "", $lines[0]); 432 | unset($lines[0]); 433 | $new_data[] = array('version' => $version, 'data' => $lines); 434 | } 435 | return trim($new_data[0]['version']); 436 | } catch (Exception $e) { 437 | return $this->currversion; 438 | } 439 | } 440 | 441 | } 442 | ?> 443 | -------------------------------------------------------------------------------- /twentyseventeen-child/wpts/wp_theme_settings.php: -------------------------------------------------------------------------------- 1 | tabs = (array_key_exists('tabs', $args)) ? $args['tabs'] : array(); 37 | $this->theme = wp_get_theme(); 38 | $this->general = (array_key_exists('general', $args)) ? $args['general'] : array(); 39 | $this->badge = (array_key_exists('badge', $args)) ? $args['badge'] : ''; 40 | $this->settingsID = (array_key_exists('settingsID', $args)) ? $this->keyEntity($args['settingsID']).'-settings-group' : ''; 41 | $this->settingFields = (array_key_exists('settingFields', $args)) ? $args['settingFields'] : array(); 42 | $this->toolbar = (array_key_exists('toolbar', $args['general'])) ? $args['general']['toolbar'] : array(); 43 | $this->notice = (array_key_exists('notice', $args['general'])) ? $args['general']['notice'] : true; 44 | /* 45 | * @ Add tabfields (tabs & sections) to settingsfield 46 | */ 47 | foreach ($this->tabs as $key => $data) { 48 | if (array_key_exists('tabFields', $data)) { 49 | foreach ($data["tabFields"] as $key => $value) { 50 | array_push($this->settingFields, $value['name']); 51 | } 52 | } 53 | if (array_key_exists('sections', $data)) { 54 | foreach ($data["sections"] as $key => $section) { 55 | if (array_key_exists('tabFields', $section)) { 56 | foreach ($section["tabFields"] as $key => $section_tabFields) { 57 | array_push($this->settingFields, $section_tabFields['name']); 58 | } 59 | } 60 | } 61 | } 62 | } 63 | /* 64 | * @ call register theme_settings function 65 | */ 66 | add_action('admin_init', array($this,'theme_settings')); 67 | /* 68 | * @ call register menu 69 | */ 70 | add_action('admin_menu', array($this,'menu')); 71 | /* 72 | * @ call js & css 73 | */ 74 | add_action('admin_enqueue_scripts', array($this, 'wp_theme_settings_js_css')); 75 | /* 76 | * @ call option function 77 | */ 78 | add_filter( 'wpts_option', array($this, 'wpts_option')); 79 | /* 80 | * @ call toolbar function 81 | */ 82 | if (array_key_exists('toolbar', $args['general']) && $args['general']['toolbar'] != false) { 83 | add_action('admin_bar_menu', array($this, 'wpts_toolbar'), 999); 84 | } 85 | /* 86 | * @ check update notice 87 | */ 88 | if ($this->notice !== false ) { 89 | if ( $this->get_wpts_git_version() > $this->currversion ) { 90 | add_action( 'admin_notices', array($this, 'wpts_update_admin_notice') ); 91 | } 92 | } 93 | } 94 | 95 | /* 96 | * @ WP Toolbar 97 | */ 98 | public function wpts_toolbar($wp_admin_bar) { 99 | $menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme'); 100 | $menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings'); 101 | $menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : ''); 102 | $toolbar_title = (array_key_exists('toolbar_title', $this->toolbar) ? $this->toolbar['toolbar_title'] : 'WPTS'); 103 | $toolbar_image = (array_key_exists('toolbar_image', $this->toolbar) ? $this->toolbar['toolbar_image'] : 'http://i.imgur.com/3BfjiTf.png'); 104 | $toolbar_href = (array_key_exists('toolbar_href', $this->toolbar) ? $this->toolbar['toolbar_href'] : 'https://git.io/vi1Gr'); 105 | 106 | if ($toolbar_image) { 107 | $toolbar_image = ' '; 108 | } 109 | 110 | $args = array( 111 | 'id' => 'wpts', 112 | 'title' => $toolbar_image.$toolbar_title, 113 | 'href' => $toolbar_href, 114 | 'meta' => array('class' => 'wpts-toolbar'), 115 | ); 116 | 117 | $wp_admin_bar->add_node($args); 118 | 119 | switch ($menu_type) { 120 | case 'submenu': 121 | $href = home_url().'/wp-admin/'.$menu_parent.'&page='.$menu_slug.'#%%key%%'; 122 | break; 123 | case 'options': 124 | $href = home_url().'/wp-admin/options-general.php?page='.$menu_slug.'#%%key%%'; 125 | break; 126 | default: 127 | $href = home_url().'/wp-admin/themes.php?page='.$menu_slug.'#%%key%%'; 128 | break; 129 | } 130 | 131 | foreach ($this->tabs as $key => $tab) { 132 | $args = array( 133 | 'id' => 'wpts-'.$this->keyEntity($key), 134 | 'title' => $tab['text'], 135 | 'href' => str_replace( '%%key%%', $this->keyEntity($key), $href ), 136 | 'parent' => 'wpts', 137 | ); 138 | $wp_admin_bar->add_node($args); 139 | } 140 | } 141 | 142 | 143 | /* 144 | * @ jQuery & Css 145 | */ 146 | public function wp_theme_settings_js_css(){ 147 | wp_enqueue_style( 'wp-color-picker' ); 148 | wp_enqueue_script( 'wp-color-picker'); 149 | wp_enqueue_style('fontawesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'); 150 | wp_register_script('js-yaml','https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.6.1/js-yaml.js', array('jquery')); 151 | wp_enqueue_script('js-yaml'); 152 | wp_enqueue_script('media-upload'); 153 | wp_enqueue_script('thickbox'); 154 | wp_enqueue_style('thickbox'); 155 | } 156 | /* 157 | * @ Register theme menu. 158 | */ 159 | public function menu() { 160 | $menu_type = (array_key_exists('menu_type', $this->general) ? $this->general['menu_type'] : 'theme'); 161 | $page_title = (array_key_exists('title', $this->general) ? $this->general['title'] : 'Theme Settings'); 162 | $menu_title = (array_key_exists('menu_title', $this->general) ? $this->general['menu_title'] : 'Theme Settings'); 163 | $menu_slug = (array_key_exists('menu_slug', $this->general) ? $this->general['menu_slug'] : 'wp-theme-settings'); 164 | $menu_parent = (array_key_exists('menu_parent', $this->general) ? $this->general['menu_parent'] : ''); 165 | $capability = (array_key_exists('capability', $this->general) ? $this->general['capability'] : 'manage_options'); 166 | switch ($menu_type) { 167 | case 'submenu': 168 | add_submenu_page($menu_parent, $page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 169 | break; 170 | case 'options': 171 | add_options_page( $page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 172 | break; 173 | default: 174 | add_theme_page($page_title, $menu_title, $capability, $menu_slug, array($this, 'tabs') ); 175 | break; 176 | } 177 | } 178 | /* 179 | * @ Generate Display. 180 | */ 181 | public function tabs(){ 182 | echo '
'; 183 | $this->navHeader(); 184 | $this->navTabs(); 185 | echo '
'; 186 | } 187 | /* 188 | * @ Build table for tabs 189 | */ 190 | private function tab_container($array, $parent){ 191 | echo ''; 192 | do_action('wpts_tab_'.$parent.'_table_before'); 193 | foreach ($array as $key => $data) { 194 | 195 | echo ''; 196 | 197 | echo ''; 202 | 203 | echo ''; 209 | 210 | echo ''; 211 | 212 | array_push($this->settingFields, $data['name']); 213 | } 214 | 215 | do_action('wpts_tab_'.$parent.'_table_after'); 216 | echo '
'; 198 | if (array_key_exists('label', $data)) { 199 | echo ''; 200 | } 201 | echo ''; 204 | echo $this->binput($data); 205 | if (array_key_exists('description', $data)) { 206 | echo '

'.$data['description'].'

'; 207 | } 208 | echo '
'; 217 | } 218 | /* 219 | * @ Build inputs 220 | */ 221 | private function binput($array){ 222 | if (array_key_exists('class', $array)) { 223 | $html_class = $array['class']; 224 | }else{ 225 | $html_class = ''; 226 | } 227 | 228 | switch ($array['type']) { 229 | 230 | // Build text 231 | case 'text': 232 | echo ''; 233 | if (array_key_exists('tooltip', $array)) { 234 | echo '
!'.$array['tooltip'].'
'; 235 | } 236 | break; 237 | // Build file 238 | case 'file': 239 | if (array_key_exists('preview', $array) && $array['preview'] == true) { 240 | echo ''; 241 | } 242 | echo ''; 243 | break; 244 | // Build fontawesome selector 245 | case 'fa': 246 | echo ''; 247 | break; 248 | // Build Color 249 | case 'color': 250 | echo ''; 251 | break; 252 | // Build Select 253 | case 'select': 254 | echo ''; 260 | if (array_key_exists('tooltip', $array)) { 261 | echo '
!'.$array['tooltip'].'
'; 262 | } 263 | break; 264 | // Build Radio 265 | case 'radio': 266 | foreach ($array['options'] as $key => $value) { 267 | echo ' 268 | '; 272 | } 273 | 274 | break; 275 | // Build Checkbox 276 | case 'checkbox': 277 | echo ' 278 |
279 |
'; 280 | break; 281 | // Build Toggle Switch 282 | case 'toggle': 283 | echo ' 284 | 288 | '; 289 | if (array_key_exists('tooltip', $array)) { 290 | echo '
!'.$array['tooltip'].'
'; 291 | } 292 | break; 293 | // default return false 294 | default: 295 | return false; 296 | break; 297 | } 298 | } 299 | /* 300 | * @ Generate tabs 301 | */ 302 | private function navTabs(){ 303 | $i = 0; 304 | echo ''; 310 | 311 | 312 | echo ''; 349 | } 350 | /* 351 | * @ Tab Head 352 | */ 353 | private function navHeader(){ 354 | 355 | if (array_key_exists('title', $this->general)) { 356 | echo '

'.ucfirst($this->general['title']).'

'; 357 | }else{ 358 | echo '

'.ucfirst($this->theme->get( 'Name' )).' Theme Settings

359 | '; 360 | } 361 | 362 | 363 | if (array_key_exists('description', $this->general)) { 364 | echo '
'.$this->general['description'].'
'; 365 | } 366 | 367 | 368 | if (!empty($this->badge)) { 369 | 370 | if (array_key_exists('bg-image', $this->badge)) { 371 | echo '
'; 372 | }else{ 373 | echo '
'; 374 | } 375 | 376 | if (array_key_exists('version', $this->badge) && $this->badge['version'] == false) { 377 | // do nothing 378 | }else{ 379 | echo 'Version '.$this->theme->get('Version'); 380 | } 381 | echo '
'; 382 | } 383 | } 384 | /* 385 | * @ Remove special chars 386 | */ 387 | private function keyEntity($key){ 388 | $key = preg_replace( '/[^a-zA-Z0-9\']/', '_', $key ); 389 | return rtrim( $key, '_' ); 390 | } 391 | /* 392 | * @ Register Settings 393 | */ 394 | public function theme_settings(){ 395 | foreach ( $this->settingFields as $value ) { 396 | register_setting( $this->settingsID, $value, array($this, 'sanitize') ); 397 | } 398 | } 399 | /* 400 | * @ Sanitize inputs 401 | */ 402 | public function sanitize($input){ 403 | return sanitize_text_field($input); 404 | } 405 | /* 406 | * @ Get Option value 407 | */ 408 | public function wpts_option($key){ 409 | return esc_attr( get_option($key) ); 410 | } 411 | 412 | /* 413 | * @ Update notice 414 | */ 415 | public function wpts_update_admin_notice() { 416 | $class = 'notice notice-info is-dismissible'; 417 | $message = __( 'New version of WPTS is available ('.$this->get_wpts_git_version().'), click here to learn more about it.'); 418 | printf( '

%2$s

', $class, $message ); 419 | } 420 | 421 | /* 422 | * @ Get wpts github version 423 | */ 424 | private function get_wpts_git_version(){ 425 | try { 426 | $url = "http://wpts.nexxoz.com/changelog.txt"; 427 | $data = file_get_contents($url); 428 | $t = preg_split("#\n\s*\n#Uis", $data); 429 | foreach ($t as $key => $value) { 430 | $lines = explode('+', $value); 431 | $version = str_replace("**", "", $lines[0]); 432 | unset($lines[0]); 433 | $new_data[] = array('version' => $version, 'data' => $lines); 434 | } 435 | return trim($new_data[0]['version']); 436 | } catch (Exception $e) { 437 | return $this->currversion; 438 | } 439 | } 440 | 441 | } 442 | ?> 443 | --------------------------------------------------------------------------------