Changeset 3286504
- Timestamp:
- 05/02/2025 07:44:47 PM (10 months ago)
- Location:
- section-widget/trunk
- Files:
-
- 4 added
- 16 edited
-
Gruntfile.js (added)
-
composer.json (added)
-
css/section-widget-admin.min.css (modified) (1 diff)
-
css/section-widget.min.css (modified) (1 diff)
-
js/section-widget-admin.min.js (modified) (1 diff)
-
js/section-widget-tabs-gutenberg.js (added)
-
js/section-widget-tabs.js (modified) (3 diffs)
-
js/section-widget-tabs.min.js (modified) (1 diff)
-
js/section-widget.min.js (modified) (1 diff)
-
olt-checklist/loader.php (modified) (2 diffs)
-
olt-checklist/olt-checklist.css (modified) (1 diff)
-
olt-checklist/olt-checklist.dev.css (modified) (1 diff)
-
olt-checklist/olt-checklist.js (modified) (1 diff)
-
olt-checklist/olt-checklist.php (modified) (1 diff)
-
package.json (added)
-
readme.txt (modified) (1 diff)
-
section-widget-options-page.php (modified) (6 diffs)
-
section-widget-tabbed.php (modified) (25 diffs)
-
section-widget.php (modified) (3 diffs)
-
themes/theme-loader.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
section-widget/trunk/css/section-widget-admin.min.css
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/1 /*! Section Widget 18-10-2021 */ 2 2 3 3 div.olt-sw-body{clear:both;border-width:1px;border-style:solid;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;border-color:#dfdfdf}.olt-swt-designer .ui-tabs .ui-tabs-nav .olt-swt-designer-add-tab{position:absolute;right:0;top:-34px}.olt-swt-designer .ui-tabs{margin-top:30px}div.olt-sw-body p.olt-sw-body-help{padding:6px .9em;margin:0;font-size:11px;color:#333;background-color:#ededed;background-image:url(../olt-checklist/gray-grad.png);background-position:bottom;background-repeat:repeat-x}div.olt-sw-body code{background:transparent}div.olt-sw-body>textarea{width:100%;border:0;-moz-border-radius:0;-khtml-border-radius:0;-webkit-border-radius:0;border-radius:0;margin:0}.olt-swt-designer-top>*{float:left}.olt-swt-designer-top label{padding-top:4px;padding-right:4px}.olt-swt-designer-top .olt-swt-designer-tabs-controls{padding-top:4px!important;padding-left:8px!important}.olt-swt-designer-add-tab>a{padding:.5em!important}.olt-swt-designer-tab,.olt-swt-designer-tab a{cursor:move!important}.olt-swt-designer-add-tab,.olt-swt-designer-add-tab>a{cursor:pointer!important}.olt-swt-designer-main code{background:transparent!important}div#swt-theme-preview{width:400px;margin:10px 0}div#swt-scope-help{max-width:650px;background-color:#eee;padding:10px;margin-top:10px}div#swt-scope-help p{text-align:justify}div#swt-scope-detect-message div{border-width:1px;border-style:solid;border-radius:2px;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;margin:2px;padding:2px 6px}div#swt-scope-detect-message div.success{color:#3c6;border-color:#3c6;background-color:#cfc}div#swt-scope-detect-message div.message{color:#39c;border-color:#39c;background-color:#cff}div#swt-scope-detect-message div.warning{color:#990;border-color:#990;background-color:#ffc}div#swt-scope-detect-message div.error{color:red;border-color:red;background-color:#fcc} -
section-widget/trunk/css/section-widget.min.css
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/1 /*! Section Widget 18-10-2021 */ 2 2 3 3 .section-widget-tabs-container{margin:1em 0;padding:0}ul.section-widget-tabs{margin:12px 0 0;padding:0;list-style:none}ul.section-widget-tabs li.section-widget-tab{display:inline;padding:5px 8px;margin:0;border:0}ul.section-widget-tabs li.section-widget-tab a{text-decoration:none;line-height:12px}ul.section-widget-tabs li.section-widget-tab.ui-tabs-selected{-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;border-style:solid solid none;border-width:1px 1px 0;border-color:#dfdfdf;background-color:#f1f1f1}ul.section-widget-tabs li.section-widget-tab.ui-tabs-selected a{color:#000}.section-widget-tabs-container div.section-widget-tab-panel{height:150px;overflow:auto;margin:3px 0 0;padding:.5em .9em;border:1px solid #dfdfdf}.section-widget-tabs-container div.section-widget-tab-panel ul{margin:0;padding:0}.section-widget-tabs-container div.section-widget-tab-panel li{margin:0;list-style:none;line-height:19px}.section-widget-checklist-entry{width:100%}.section-widget-checklist-entry>p{font-size:80%;margin-left:2em!important}.section-widget-controls-container{font-size:75%;text-decoration:none;display:none} -
section-widget/trunk/js/section-widget-admin.min.js
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/1 /*! Section Widget 18-10-2021 */ 2 2 jQuery(document).ready(function(a){a("head").append('<link id="swt-preview-style" rel="stylesheet" href="" type="text/css" media="all" />');var b=a("#swt-preview-style");a("#swt-theme-preview-wrapper").tabs(),a("#swt-theme").change(function(){"none"==a(this).val()?b.attr("href",""):b.attr("href",stylesheet_url+"?theme="+a(this).val()+"&scope=%23swt-theme-preview")}).change(),a("#swt-theme-preview-link").click(function(){return a("#swt-theme-preview").slideDown(),!1}),a("#swt-theme-preview-hide-link").click(function(){return a("#swt-theme-preview").slideUp(),!1}),a("#swt-scope-help-link").click(function(){return a("#swt-scope-help").slideDown(),!1}),a("#swt-scope-help-hide-link").click(function(){return a("#swt-scope-help").slideUp(),!1}),a("#swt-scope-detect").click(function(){a(this).hide(),a("body").append('<iframe id="swt-scope-detect-iframe" style="display:none" />');var b,c,d=a("#swt-scope-detect-iframe"),e=a(this).siblings("#swt-scope-detect-message").empty().show(),f=function(){return e.append('<div class="message">Initializing scope detect...</div>'),"undefined"==typeof links||links.length<1?(e.append('<div class="error">Cannot find JavaScript variable "links"...</div>'),h(),!1):(b=[],c=links.slice(),d.unbind("load"),g(),void 0)},g=function(f){if("undefined"!=typeof f){var i=a(this).contents().find(".swt-wrapper"),j=!1;i.length<1?e.append('<div class="warning">No widget instances found, skipping...</div>'):(i.length<2&&(e.append('<div class="warning">Only one widget instance found, this might lead to inaccurate result...</div>'),j=!0),i.each(function(){var c=a(this).parents(),d=[];c.each(function(){var b=a(this).attr("id");""!=b&&d.push(b)}),j&&d.shift(),b.push(d)}))}c.length<1?h():(link=c.pop(),e.append('<div class="message">Trying '+link+" ...</div>"),d.attr("src",link).load(g))},h=function(){if(b.length<1)e.append('<div class="error">Scope detection has failed. Your settings are unchanged.</div>');else{for(var c=b.shift(),d=[],f=0;f<c.length;f++){for(var g=!0,h=c[f],i=0;i<b.length;i++)if(-1==a.inArray(h,b[i])){g=!1;break}g&&d.push("#"+h)}d.reverse().push(".swt-outter"),a("#swt-scope").val(d.join(" ")),e.append('<div class="success">Scope detection has completed. Your optimal CSS scope is <strong>"'+d.join(" ")+""</strong> and it has been filled in for you.<br /><strong>Don't forget to save your changes!</strong></div>")}a("#swt-scope-detect").show()};return f(d,e),!1})}); -
section-widget/trunk/js/section-widget-tabs.js
r762559 r3286504 20 20 init:function(){ 21 21 22 23 $( '#widgets-right')24 // add tabs 25 .delegate('.olt-swt-designer-add-tab a','click','', Section_Widget_Tabs.add_tab )26 // delete tabs27 .delegate('.olt-swt-designer-delete-tab a','click','', Section_Widget_Tabs.delete_tab ) 28 // update tab title29 .delegate('.olt-swt-designer-tab-title','focusout','', Section_Widget_Tabs.update_tab_title);22 // Add tabs 23 $(document).on('click', '.olt-swt-designer-add-tab a', Section_Widget_Tabs.add_tab); 24 25 // Delete tabs 26 $(document).on('click', '.olt-swt-designer-delete-tab a', Section_Widget_Tabs.delete_tab); 27 28 // Update tab title 29 $(document).on('focusout', '.olt-swt-designer-tab-title', Section_Widget_Tabs.update_tab_title); 30 30 31 31 Section_Widget_Tabs.create_tabs(); … … 48 48 49 49 if(typeof(tab.data('inc')) == 'undefined') { 50 var inc = tab. size();50 var inc = tab.length; 51 51 var counter = tab.find(".olt-swt-designer-tab").length; 52 52 … … 108 108 shell.remove(); 109 109 list_shell.remove(); 110 tabs.tabs( "refresh");110 tabs.tabs(); 111 111 } 112 112 e.preventDefault(); -
section-widget/trunk/js/section-widget-tabs.min.js
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/2 !function(a,b){b.OLTSWTInit=function(a){d.create_tabs(a)};var c={axis:"x",items:"li:not(.olt-swt-designer-tabs-controls)",update:function(){var a=jQuery,b=a(this).parents(".olt-swt-designer-wrapper:first").siblings(".olt-swt-order:first");b.val(a(this).sortable("serialize",{key:"order"}))}},d={tabs:!1,init:function(){a( "#widgets-right").delegate(".olt-swt-designer-add-tab a","click","",d.add_tab).delegate(".olt-swt-designer-delete-tab a","click","",d.delete_tab).delegate(".olt-swt-designer-tab-title","focusout","",d.update_tab_title),d.create_tabs()},create_tabs:function(){d.tabs=d.tab?d.tab:a(".olt-swt-designer-wrapper"),d.tabs.tabs().find(".ui-tabs-nav").sortable(c),d.tabs.each(function(b,c){var d=a(c);if("undefined"==typeof d.data("inc")){d.size();var e=d.find(".olt-swt-designer-tab").length;d.data("inc",e)}})},add_tab:function(b){var c=a(this).parents(".olt-swt-designer-wrapper");d.create_tabs(c);var e=c.find("ul"),f=c.data("inc");f++;var g=c.siblings("input[name=idprefix]:first").val(),h=c.siblings("input[name=nameprefix]:first").val(),i=g+"-id-"+f,j="You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.";a('<li class="olt-swt-designer-tab" id="'+i+'-list"><a href="#'+i+'" id="'+i+'-title-link">New Tab</a></li>').appendTo(e);var k='<div id="'+i+'" class="olt-swt-designer-panel">';k+='<div class="olt-swt-designer-top">',k+='<label for="">Title:</label> <input id="'+i+'-title" class="olt-swt-designer-tab-title" name="'+h+"["+f+'][title]" type="text" value="New Tab" />',k+='<p class="olt-swt-designer-tabs-controls olt-swt-designer-delete-tab" ><a href="#" id="'+i+'-delete"><span class="ui-icon ui-icon-trash" style="float:left;margin-right:.3em;margin-top: -2px;"></span>Delete this tab</a></p>',k+="</div>",k+='<div class="olt-sw-body">',k+='<p class="olt-sw-body-help"><strong>Formatting Help:</strong> '+j+"</p>",k+='<textarea rows="16" cols="20" name="'+h+"["+f+'][body]"></textarea>',k+="</div>",a(k).appendTo(c),c.tabs("refresh");var l=e.find("li").length;c.tabs("option","active",l-2),c.data("inc",f),b.preventDefault()},delete_tab:function(c){var d=b.confirm("Are you sure you want to delete this tab?");if(d){var e=a(this).attr("id").slice(0,-7),f=a("#"+e),g=a("#"+e+"-list"),h=f.parents(".olt-swt-designer-wrapper");f.remove(),g.remove(),h.tabs("refresh")}c.preventDefault()},update_tab_title:function(b){var c=a(this);a("#"+c.attr("id")+"-link").text(c.val()),b.preventDefault()}};a(function(){d.init()})}(jQuery,window);1 /*! Section Widget 18-10-2021 */ 2 !function(a,b){b.OLTSWTInit=function(a){d.create_tabs(a)};var c={axis:"x",items:"li:not(.olt-swt-designer-tabs-controls)",update:function(){var a=jQuery,b=a(this).parents(".olt-swt-designer-wrapper:first").siblings(".olt-swt-order:first");b.val(a(this).sortable("serialize",{key:"order"}))}},d={tabs:!1,init:function(){a(document).on("click",".olt-swt-designer-add-tab a",d.add_tab),a(document).on("click",".olt-swt-designer-delete-tab a",d.delete_tab),a(document).on("focusout",".olt-swt-designer-tab-title",d.update_tab_title),d.create_tabs()},create_tabs:function(){d.tabs=d.tab?d.tab:a(".olt-swt-designer-wrapper"),d.tabs.tabs().find(".ui-tabs-nav").sortable(c),d.tabs.each(function(b,c){var d=a(c);if("undefined"==typeof d.data("inc")){d.length;var e=d.find(".olt-swt-designer-tab").length;d.data("inc",e)}})},add_tab:function(b){var c=a(this).parents(".olt-swt-designer-wrapper");d.create_tabs(c);var e=c.find("ul"),f=c.data("inc");f++;var g=c.siblings("input[name=idprefix]:first").val(),h=c.siblings("input[name=nameprefix]:first").val(),i=g+"-id-"+f,j="You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.";a('<li class="olt-swt-designer-tab" id="'+i+'-list"><a href="#'+i+'" id="'+i+'-title-link">New Tab</a></li>').appendTo(e);var k='<div id="'+i+'" class="olt-swt-designer-panel">';k+='<div class="olt-swt-designer-top">',k+='<label for="">Title:</label> <input id="'+i+'-title" class="olt-swt-designer-tab-title" name="'+h+"["+f+'][title]" type="text" value="New Tab" />',k+='<p class="olt-swt-designer-tabs-controls olt-swt-designer-delete-tab" ><a href="#" id="'+i+'-delete"><span class="ui-icon ui-icon-trash" style="float:left;margin-right:.3em;margin-top: -2px;"></span>Delete this tab</a></p>',k+="</div>",k+='<div class="olt-sw-body">',k+='<p class="olt-sw-body-help"><strong>Formatting Help:</strong> '+j+"</p>",k+='<textarea rows="16" cols="20" name="'+h+"["+f+'][body]"></textarea>',k+="</div>",a(k).appendTo(c),c.tabs("refresh");var l=e.find("li").length;c.tabs("option","active",l-2),c.data("inc",f),b.preventDefault()},delete_tab:function(c){var d=b.confirm("Are you sure you want to delete this tab?");if(d){var e=a(this).attr("id").slice(0,-7),f=a("#"+e),g=a("#"+e+"-list"),h=f.parents(".olt-swt-designer-wrapper");f.remove(),g.remove(),h.tabs()}c.preventDefault()},update_tab_title:function(b){var c=a(this);a("#"+c.attr("id")+"-link").text(c.val()),b.preventDefault()}};a(function(){d.init()})}(jQuery,window); -
section-widget/trunk/js/section-widget.min.js
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/1 /*! Section Widget 18-10-2021 */ 2 2 jQuery(document).ready(function(a){a(".swt-wrapper").tabs(),a(".swt-height-fix").each(function(b,c){var d=a(c).css("display"),e=a(c).css("display","inline-block").height();a(c).css("display",d).height(e)})}); -
section-widget/trunk/olt-checklist/loader.php
r504574 r3286504 2 2 3 3 $olt_checklist_version = '1.1.4'; // Version number of this copy 4 $olt_checklist_callback = create_function('$base_url', // Version specific init callback 5 'include_once("'.addslashes(dirname(__FILE__)).'/olt-checklist.php");'. // addslashes to please the Windows god... 6 'if(is_admin()) {'. 7 'global $pagenow;'. 8 'if($pagenow == "widgets.php"):'. 9 '$js_url = $base_url . "/olt-checklist.js";'. 10 '$css_url = $base_url . "/olt-checklist.css";'. 11 ' wp_enqueue_script("olt-checklist",$js_url,array("jquery","jquery-ui-tabs"));'. 12 ' wp_enqueue_style("olt-checklist",$css_url);'. 13 'endif;'. 14 '}' 15 ); 4 5 $olt_checklist_callback = function( $base_url ) { 6 7 include_once( addslashes( dirname( __FILE__ ) ) . '/olt-checklist.php' ); 8 9 if ( is_admin() ) { 10 11 global $pagenow; 12 13 if ( 'widgets.php' === $pagenow ) { 14 $js_url = $base_url . '/olt-checklist.js'; 15 $css_url = $base_url . '/olt-checklist.css'; 16 wp_enqueue_script( 'olt-checklist', $js_url, array( 'jquery', 'jquery-ui-tabs' ) ); 17 wp_enqueue_style( 'olt-checklist', $css_url ); 18 } 19 } 20 21 }; 16 22 17 23 if(!function_exists('enqueue_olt_checklist_loader')){ 18 24 /** 19 * enqueue_olt_checklist_loader function.20 * 21 * @access public22 * @param mixed $base_url23 * @return void24 */25 function enqueue_olt_checklist_loader($base_url){26 global $olt_checklist, $olt_checklist_version, $olt_checklist_callback;27 28 if(!isset($olt_checklist))29 $olt_checklist = array();30 31 if(substr($base_url, -1) == '/')32 $base_url = substr($base_url, 0, -1);33 34 $olt_checklist[] = array(35 $olt_checklist_version,36 $olt_checklist_callback,37 $base_url38 );39 }25 * enqueue_olt_checklist_loader function. 26 * 27 * @access public 28 * @param mixed $base_url 29 * @return void 30 */ 31 function enqueue_olt_checklist_loader($base_url){ 32 global $olt_checklist, $olt_checklist_version, $olt_checklist_callback; 33 34 if(!isset($olt_checklist)) 35 $olt_checklist = array(); 36 37 if(substr($base_url, -1) == '/') 38 $base_url = substr($base_url, 0, -1); 39 40 $olt_checklist[] = array( 41 $olt_checklist_version, 42 $olt_checklist_callback, 43 $base_url 44 ); 45 } 40 46 } 41 47 42 48 if(!function_exists('load_olt_checklist')){ 43 49 /** 44 * load_olt_checklist function. 45 * 46 * @access public 47 * @return void 48 */ 49 function load_olt_checklist(){ 50 global $olt_checklist; 51 52 $version = $olt_checklist[0][0]; 53 $callback = $olt_checklist[0][1]; 54 $base_url = $olt_checklist[0][2]; 55 56 for($i=1;$i<count($olt_checklist);$i++){ 57 if(is_newer($olt_checklist[$i][0], $version)){ 58 $version = $olt_checklist[$i][0]; 59 $callback = $olt_checklist[$i][1]; 60 $base_url = $olt_checklist[$i][2]; 61 } 62 } 63 64 $callback($base_url); 65 } 66 50 * load_olt_checklist function. 51 * 52 * @access public 53 * @return void 54 */ 55 function load_olt_checklist(){ 56 global $olt_checklist; 57 58 $version = $olt_checklist[0][0]; 59 $callback = $olt_checklist[0][1]; 60 $base_url = $olt_checklist[0][2]; 61 62 for($i=1;$i<count($olt_checklist);$i++){ 63 if(is_newer($olt_checklist[$i][0], $version)){ 64 $version = $olt_checklist[$i][0]; 65 $callback = $olt_checklist[$i][1]; 66 $base_url = $olt_checklist[$i][2]; 67 } 68 } 69 if ( ! is_callable( $callback ) ) { 70 return; 71 } 72 73 $callback( $base_url ); 74 } 75 67 76 } 68 77 … … 71 80 if(!function_exists('is_newer')){ 72 81 /** 73 * is_newer function.74 * 75 * @access public76 * @param mixed $v1. (default: null)77 * @param mixed $v2. (default: null)78 * @return void79 */80 function is_newer($v1 = null, $v2 = null){81 // return true if v1 > v2, false otherwise82 83 if(!is_string($v1) || $v1 == '')84 return false;85 86 if(!is_string($v2) || $v2 == '')87 return true;88 89 $v1_e = explode('.', $v1);90 $v2_e = explode('.', $v2);91 92 for($i=0;;$i++){93 // same prefix, but v2 is longer (or they tied) => v1 <= v294 // e.g. 1.0 vs 1.0.195 if($i >= count($v1_e))96 return false;97 98 // same prefix, but v1 is longer (or they tied) => v1 >= v299 // e.g. 1.0.1 vs 1.0100 if($i >= count($v2_e))101 return true;102 103 $diff = intval($v1_e[$i]) - intval($v2_e[$i]);104 105 if($diff < 0){106 // v1 < v2107 // e.g. 1.1 vs 1.2108 return false;109 }elseif($diff > 0){110 // v1 > v2111 // e.g. 1.2 vs 1.1112 return true;113 }114 }115 }82 * is_newer function. 83 * 84 * @access public 85 * @param mixed $v1. (default: null) 86 * @param mixed $v2. (default: null) 87 * @return void 88 */ 89 function is_newer($v1 = null, $v2 = null){ 90 // return true if v1 > v2, false otherwise 91 92 if(!is_string($v1) || $v1 == '') 93 return false; 94 95 if(!is_string($v2) || $v2 == '') 96 return true; 97 98 $v1_e = explode('.', $v1); 99 $v2_e = explode('.', $v2); 100 101 for($i=0;;$i++){ 102 // same prefix, but v2 is longer (or they tied) => v1 <= v2 103 // e.g. 1.0 vs 1.0.1 104 if($i >= count($v1_e)) 105 return false; 106 107 // same prefix, but v1 is longer (or they tied) => v1 >= v2 108 // e.g. 1.0.1 vs 1.0 109 if($i >= count($v2_e)) 110 return true; 111 112 $diff = intval($v1_e[$i]) - intval($v2_e[$i]); 113 114 if($diff < 0){ 115 // v1 < v2 116 // e.g. 1.1 vs 1.2 117 return false; 118 }elseif($diff > 0){ 119 // v1 > v2 120 // e.g. 1.2 vs 1.1 121 return true; 122 } 123 } 124 } 116 125 } 117 126 -
section-widget/trunk/olt-checklist/olt-checklist.css
r762559 r3286504 1 div.olt-checklist-wrapper{margin:1em 0 1em 0;padding:0;}div.olt-checklist-wrapper>ul.ui-tabs-nav{margin:12px 0 0 0;padding:0;list-style:none;}div.olt-checklist-wrapper>ul.ui-tabs-nav>li{display:inline;padding:5px 8px 5px 8px;margin:0;border:0;}div.olt-checklist-wrapper>ul.ui-tabs-nav>li a{text-decoration:none;line-height:12px;}div.olt-checklist-wrapper>ul.ui-tabs-nav>li.ui-state-active{-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;border-style:solid solid none solid;border-width:1px 1px 0 1px;border-color:#dfdfdf;background-color:#ededed;}div.olt-checklist-wrapper>ul.ui-tabs-nav>li.ui-state-active a{color:#000;}div.olt-checklist-wrapper div.ui-tabs-panel{height:180px;overflow:auto;margin:3px 0 0 0;padding:0;border:1px solid #dfdfdf;}div.olt-checklist-wrapper div.ui-tabs-panel p.olt-checklist-tab-description{margin:0!important;padding:6px .9em 0 .9em!important;height:25px;background-image:url(gray-grad.png);font-size:11px;}ul.olt-checklist{padding:.5em .9em .5em .9em;margin:0;list-style:none;}ul.olt-checklist li{margin:0;list-style:none;line-height:19px;}ul.olt-checklist div.olt-checklist-entry>p{font-size:80%;margin-left:2em!important;}.olt-checklist-controls-wrapper{font-size:75%;text-decoration:none;display:none;}1 div.olt-checklist-wrapper{margin:1em 0;padding:0}div.olt-checklist-wrapper>ul.ui-tabs-nav{margin:12px 0 0;padding:0;list-style:none}div.olt-checklist-wrapper>ul.ui-tabs-nav>li{display:inline;float:none;padding:5px 8px;margin:0;border:0}div.olt-checklist-wrapper>ul.ui-tabs-nav>li a{text-decoration:none;line-height:12px}div.olt-checklist-wrapper>ul.ui-tabs-nav>li.ui-state-active{-moz-border-radius:3px 3px 0 0;-webkit-border-top-left-radius:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-left-radius:3px;-khtml-border-top-right-radius:3px;border-top-left-radius:3px;border-top-right-radius:3px;border-style:solid solid none;border-width:1px 1px 0;border-color:#dfdfdf;background-color:#ededed}div.olt-checklist-wrapper>ul.ui-tabs-nav>li.ui-state-active a{color:#000}div.olt-checklist-wrapper div.ui-tabs-panel{height:180px;overflow:auto;margin:3px 0 0;padding:0;border:1px solid #dfdfdf}div.olt-checklist-wrapper div.ui-tabs-panel p.olt-checklist-tab-description{margin:0!important;padding:6px .9em 0!important;height:25px;background-image:url(gray-grad.png);font-size:11px}ul.olt-checklist{padding:.5em .9em;margin:0;list-style:none}ul.olt-checklist li{margin:0;list-style:none;line-height:19px}ul.olt-checklist div.olt-checklist-entry>p{font-size:80%;margin-left:2em!important}.olt-checklist-controls-wrapper{font-size:75%;text-decoration:none;display:none} -
section-widget/trunk/olt-checklist/olt-checklist.dev.css
r762559 r3286504 22 22 div.olt-checklist-wrapper>ul.ui-tabs-nav>li { 23 23 display: inline; 24 float: none; 24 25 padding: 5px 8px 5px 8px; 25 26 margin: 0; -
section-widget/trunk/olt-checklist/olt-checklist.js
r762559 r3286504 1 /*! Section Widget 1 3-08-2013*/1 /*! Section Widget 18-10-2021 */ 2 2 function OLTChecklistPaneInit(a){console.log(a),a=a||jQuery("div.olt-checklist-wrapper"),jQuery(a).each(function(a,b){jQuery(b).tabs({selected:0}).data("olt-checklist-tabs-initialized",!0),OLTChecklistInit(b)})}function OLTChecklistInit(a){a=a||jQuery("div.olt-checklist-wrapper>ul.ui-tabs-nav"),jQuery("li:has(ul.children)>div.olt-checklist-entry",a).each(function(a,b){jQuery(b).not("*:has(span.olt-checklist-controls-wrapper)").append(' <span class="olt-checklist-controls-wrapper"><a href="#" class="olt-checklist-controls-collapse">Collapse</a> | <a href="#" class="olt-checklist-controls-select">Select All</a></span>')})}function sectionWidgetCreateTabs(){}jQuery(document).ready(function(a){function b(){return e=a(this),e.toggleClass("olt-checklist-controls-collapse").toggleClass("olt-checklist-controls-expand").parents(".olt-checklist-entry:first").siblings("ul.children").slideToggle("fast"),e.hasClass("olt-checklist-controls-collapse")?e.text("Collapse"):e.text("Expand"),!1}function c(){return e=a(this),e.toggleClass("olt-checklist-controls-select").toggleClass("olt-checklist-controls-deselect").parents("li:first").find("input:checkbox").each(function(){this.checked=e.hasClass("olt-checklist-controls-deselect")}),e.hasClass("olt-checklist-controls-select")?e.text("Select All"):e.text("Deselect All"),!1}OLTChecklistPaneInit(),OLTChecklistInit(document),a("#widgets-right ").delegate("div.olt-checklist-wrapper .ui-tabs-nav a","click","",function(b){b.preventDefault();var c=a(this).parents("div.olt-checklist-wrapper:first");1!=c.data("olt-checklist-tabs-initialized")&&(OLTChecklistPaneInit(c),b.stopPropagation(),a(b.target).click())}),a("#widgets-right ").delegate("div.olt-checklist-entry","mouseover","",function(){a(this).children("span.olt-checklist-controls-wrapper").show()}),a("#widgets-right").delegate("div.olt-checklist-entry","mouseout","",function(){a(this).children("span.olt-checklist-controls-wrapper").hide()}),a("#widgets-right").delegate("a.olt-checklist-controls-collapse","click","",b),a("#widgets-right").delegate("a.olt-checklist-controls-expand","click","",b),a("#widgets-right").delegate("a.olt-checklist-controls-select","click","",c),a("#widgets-right").delegate("a.olt-checklist-controls-deselect","click","",c)}); -
section-widget/trunk/olt-checklist/olt-checklist.php
r821249 r3286504 2 2 3 3 /* 4 OLT Checklist Helper Functions5 6 Version 1.1.44 OLT Checklist Helper Functions 5 6 Version 1.1.4 7 7 */ 8 8 9 if(!function_exists('olt_checklist')) { 10 11 /* 12 $args = array( 13 'echo' => true|false, echo out or just return a string 14 'id' => 'string', base id for elements 15 'name' => 'string', base name for form elements 16 'exclude' => array(), exclude certain tabs 17 'special-pages' => array(), options for the special pages tab 18 'pages' => array(), options for the pages tab 19 'categories' => array(), options for the categories tab 20 'tags' => array() options for the tags tab 21 ); 22 */ 23 /** 24 * olt_checklist_pane function. 25 * 26 * @access public 27 * @param array $args. (default: array()) 28 * @return void 29 */ 30 function olt_checklist_pane($args = array()) { 31 // Process top-level defaults first 32 $defaults = array( 33 'echo' => true, 34 'id' => 'olt-checklist', 35 'name' => 'olt-checklist', 36 'exclude' => array() 37 ); 38 39 $args = wp_parse_args( $args, $defaults ); 40 41 // Set default name/id for second-level... 42 43 // Special Pages (id and name only, set others in the actual function) 44 $defaults = array( 45 'id' => $args['id'].'-special-pages', 46 'name' => $args['name'].'[special-pages]' 47 ); 48 $args['special-pages'] = wp_parse_args( $args['special-pages'], $defaults ); 49 50 // Pages (id and name only, set others in the actual function) 51 $defaults = array( 52 'id' => $args['id'].'-pages', 53 'name' => $args['name'].'[pages]' 54 ); 55 $args['pages'] = wp_parse_args( $args['pages'], $defaults ); 56 57 // Categories (id and name only, set others in the actual function) 58 $defaults = array( 59 'id' => $args['id'].'-categories', 60 'name' => $args['name'].'[categories]' 61 ); 62 $args['categories'] = wp_parse_args( $args['categories'], $defaults ); 63 64 // Tags (id and name only, set others in the actual function) 65 $defaults = array( 66 'id' => $args['id'].'-tags', 67 'name' => $args['name'].'[tags]' 68 ); 69 $args['tags'] = wp_parse_args( $args['tags'], $defaults ); 70 71 // Supress output, we want to control the echo-ing here instead 72 $args['special-pages']['echo'] = false; 73 $args['pages']['echo'] = false; 74 $args['categories']['echo'] = false; 75 $args['tags']['echo'] = false; 76 77 extract( $args, EXTR_SKIP ); 78 79 $output = "<div id=\"{$id}-wrapper\" class=\"olt-checklist-wrapper\">\n"; 80 $output .= " <ul>\n"; 81 if(!in_array('special-pages', $exclude)) 82 $output .= " <li><a href=\"#{$id}-special-pages\">Special Pages</a></li>\n"; 83 if(!in_array('pages', $exclude)) 84 $output .= " <li><a href=\"#{$id}-pages\">Pages</a></li>\n"; 85 if(!in_array('categories', $exclude)) 86 $output .= " <li><a href=\"#{$id}-categories\">Categories</a></li>\n"; 87 if(!in_array('tags', $exclude)) 88 $output .= " <li><a href=\"#{$id}-tags\">Tags</a></li>\n"; 89 $output .= " </ul>\n"; 90 91 if(!in_array('special-pages', $exclude)) { 92 $output .= " <div id=\"{$id}-special-pages\">\n"; 93 $output .= olt_checklist('special-pages', $args['special-pages']); 94 $output .= " </div>\n"; 95 } 96 97 if(!in_array('pages', $exclude) ) { 98 $output .= " <div id=\"{$id}-pages\">\n"; 99 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on these pages.</p>\n"; 100 $output .= olt_checklist('pages', $args['pages']); 101 $output .= " </div>\n"; 102 } 103 104 if(!in_array('categories', $exclude)) { 105 $output .= " <div id=\"{$id}-categories\">\n"; 106 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on posts or pages filed under these categories.</p>\n"; 107 $output .= olt_checklist('categories', $args['categories']); 108 $output .= " </div>\n"; 109 } 110 111 if(!in_array('tags', $exclude)) { 112 $output .= " <div id=\"{$id}-tags\">\n"; 113 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on posts or pages with these tags.</p>\n"; 114 $output .= olt_checklist('tags', $args['tags']); 115 $output .= " </div>\n"; 116 } 117 118 $output .= "</div>\n"; 119 120 if ( $echo ) echo $output; 121 122 return $output; 123 } 124 /** 125 * olt_checklist function. 126 * 127 * @access public 128 * @param string $mode. (default: 'pages') 129 * @param string $args. (default: '') 130 * @return void 131 */ 132 function olt_checklist($mode = 'pages', $args = '') { 133 switch($mode) { 134 case 'special-pages': 135 $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'olt-checklist-special-pages', 'name' => 'olt-checklist-special-pages', 'exclude' => array()); 136 $data = array( 137 (object) array( 'parent' => 0,'id' => 'all', 'name' => __('Everywhere','section-widget'), 138 'description' => __('Display this widget everywhere on your site, i.e. behave like any other widgets.','section-widget')), 139 (object) array('parent' => 0, 'id' => 'front', 'name' => __('Front Page','section-widget'), 140 'description' => __('Display this widget on the front page, as determined by your site\'s <a href="'.admin_url('options-reading.php').'">Reading Settings</a>.','section-widget')), 141 (object) array('parent' => 0, 'id' => 'home', 'name' => __('Posts page','section-widget'), 142 'description' => __('Display this widget on the posts page (i.e. your blog). This is usually your front page, but it can be changed in the <a href="'.admin_url('options-reading.php').'">Reading Settings</a>.','section-widget')), 143 (object) array('parent' => 0, 'id' => 'category', 'name' => __('Selected Category Archive Pages','section-widget'), 144 'description' => __('Display this widget on a category archive page if the corresponding category is selected in the <strong>Categories</strong> tab.','section-widget')), 145 (object) array('parent' => 0, 'id' => 'tag', 'name' => __('Selected Tag Archive Pages','section-widget'), 146 'description' => __('Display this widget on a tag archive page if the corresponding tag is selected in the <strong>Tags</strong> tab.','section-widget')), 147 (object) array('parent' => 0, 'id' => 'allcategory', 'name' => __('All Category Archive Pages','section-widget'), 148 'description' => __('Display this widget on all category archive pages.','section-widget')), 149 (object) array('parent' => 0, 'id' => 'alltag', 'name' => __('All Tag Archive Pages','section-widget'), 150 'description' => __('Display this widget on all tag archive pages.','section-widget')), 151 (object) array('parent' => 0, 'id' => 'date', 'name' => __('All Date-Based Archive Pages','section-widget'), 152 'description' => __('Display this widget on all date-based archive pages (i.e. all monthly, yearly, daily or time-based archives).','section-widget')), 153 (object) array('parent' => 0, 'id' => 'page', 'name' => __('All Pages','section-widget'), 'description' => __('Display this widget on all pages.','section-widget')), 154 (object) array('parent' => 0, 'id' => 'post', 'name' => __('All Post','section-widget'), 'description' => __('Display this widget on all posts.','section-widget')), 155 (object) array('parent' => 0, 'id' => 'comment', 'name' => __('Commentable Pages/Posts','section-widget'), 'description' => __('Display this widget on all pages/posts where comments are allowed.','section-widget')), 156 (object) array('parent' => 0, 'id' => 'author', 'name' => __('Author Pages','section-widget'), 'description' => __('Display this widget on all author pages.','section-widget')), 157 (object) array('parent' => 0, 'id' => 'search', 'name' => __('Search Results','section-widget'), 'description' => __('Display this widget on all search result pages.','section-widget')), 158 (object) array('parent' => 0, 'id' => 'notfound', 'name' => __('"Not Found" Pages','section-widget'), 'description' => __('Display this widget when a requested page cannot be found.','section-widget')) 159 160 161 ); 162 9 if ( ! function_exists( 'olt_checklist' ) ) { 10 11 /* 12 $args = array( 13 'echo' => true|false, echo out or just return a string 14 'id' => 'string', base id for elements 15 'name' => 'string', base name for form elements 16 'exclude' => array(), exclude certain tabs 17 'special-pages' => array(), options for the special pages tab 18 'pages' => array(), options for the pages tab 19 'categories' => array(), options for the categories tab 20 'tags' => array() options for the tags tab 21 ); 22 */ 23 /** 24 * olt_checklist_pane function. 25 * 26 * @access public 27 * @param array $args. (default: array()) 28 * @return void 29 */ 30 function olt_checklist_pane( $args = array() ) { 31 // Process top-level defaults first 32 $defaults = array( 33 'echo' => true, 34 'id' => 'olt-checklist', 35 'name' => 'olt-checklist', 36 'exclude' => array(), 37 ); 38 39 $args = wp_parse_args( $args, $defaults ); 40 41 // Set default name/id for second-level... 42 43 // Special Pages (id and name only, set others in the actual function) 44 $defaults = array( 45 'id' => $args['id'] . '-special-pages', 46 'name' => $args['name'] . '[special-pages]', 47 ); 48 $args['special-pages'] = wp_parse_args( $args['special-pages'], $defaults ); 49 50 // Pages (id and name only, set others in the actual function) 51 $defaults = array( 52 'id' => $args['id'] . '-pages', 53 'name' => $args['name'] . '[pages]', 54 ); 55 $args['pages'] = wp_parse_args( $args['pages'], $defaults ); 56 57 // Categories (id and name only, set others in the actual function) 58 $defaults = array( 59 'id' => $args['id'] . '-categories', 60 'name' => $args['name'] . '[categories]', 61 ); 62 $args['categories'] = wp_parse_args( $args['categories'], $defaults ); 63 64 // Tags (id and name only, set others in the actual function) 65 $defaults = array( 66 'id' => $args['id'] . '-tags', 67 'name' => $args['name'] . '[tags]', 68 ); 69 $args['tags'] = wp_parse_args( $args['tags'], $defaults ); 70 71 // Supress output, we want to control the echo-ing here instead 72 $args['special-pages']['echo'] = false; 73 $args['pages']['echo'] = false; 74 $args['categories']['echo'] = false; 75 $args['tags']['echo'] = false; 76 77 extract( $args, EXTR_SKIP ); 78 79 $output = "<div id=\"{$id}-wrapper\" class=\"olt-checklist-wrapper\">\n"; 80 $output .= " <ul>\n"; 81 if ( ! in_array( 'special-pages', $exclude ) ) { 82 $output .= " <li><a href=\"#{$id}-special-pages\">Special Pages</a></li>\n"; 83 } 84 if ( ! in_array( 'pages', $exclude ) ) { 85 $output .= " <li><a href=\"#{$id}-pages\">Pages</a></li>\n"; 86 } 87 if ( ! in_array( 'categories', $exclude ) ) { 88 $output .= " <li><a href=\"#{$id}-categories\">Categories</a></li>\n"; 89 } 90 if ( ! in_array( 'tags', $exclude ) ) { 91 $output .= " <li><a href=\"#{$id}-tags\">Tags</a></li>\n"; 92 } 93 $output .= " </ul>\n"; 94 95 if ( ! in_array( 'special-pages', $exclude ) ) { 96 $output .= " <div id=\"{$id}-special-pages\">\n"; 97 $output .= olt_checklist( 'special-pages', $args['special-pages'] ); 98 $output .= " </div>\n"; 99 } 100 101 if ( ! in_array( 'pages', $exclude ) ) { 102 $output .= " <div id=\"{$id}-pages\">\n"; 103 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on these pages.</p>\n"; 104 $output .= olt_checklist( 'pages', $args['pages'] ); 105 $output .= " </div>\n"; 106 } 107 108 if ( ! in_array( 'categories', $exclude ) ) { 109 $output .= " <div id=\"{$id}-categories\">\n"; 110 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on posts or pages filed under these categories.</p>\n"; 111 $output .= olt_checklist( 'categories', $args['categories'] ); 112 $output .= " </div>\n"; 113 } 114 115 if ( ! in_array( 'tags', $exclude ) ) { 116 $output .= " <div id=\"{$id}-tags\">\n"; 117 $output .= " <p class=\"olt-checklist-tab-description\">Display this widget on posts or pages with these tags.</p>\n"; 118 $output .= olt_checklist( 'tags', $args['tags'] ); 119 $output .= " </div>\n"; 120 } 121 122 $output .= "</div>\n"; 123 124 if ( $echo ) { 125 $allowed_html = array( 126 'div' => array( 127 'id' => true, 128 'class' => true, 129 ), 130 'ul' => array( 131 'class' => true, 132 'id' => true, 133 ), 134 'li' => array(), 135 'input' => array( 136 'type' => true, 137 'class' => true, 138 'id' => true, 139 'name' => true, 140 'value' => true, 141 'checked' => true, 142 ), 143 'label' => array( 144 'for' => true, 145 ), 146 'p' => array( 147 'class' => true, 148 ), 149 'a' => array( 150 'href' => true, 151 ), 152 'strong' => array(), 153 // add more as needed 154 ); 155 156 echo wp_kses( $output, $allowed_html ); 157 } 158 159 return $output; 160 } 161 /** 162 * olt_checklist function. 163 * 164 * @access public 165 * @param string $mode. (default: 'pages') 166 * @param string $args. (default: '') 167 * @return void 168 */ 169 function olt_checklist( $mode = 'pages', $args = '' ) { 170 switch ( $mode ) { 171 case 'special-pages': 172 $defaults = array( 173 'selected' => array(), 174 'echo' => 1, 175 'id' => 'olt-checklist-special-pages', 176 'name' => 'olt-checklist-special-pages', 177 'exclude' => array(), 178 ); 179 $data = array( 180 (object) array( 181 'parent' => 0, 182 'id' => 'all', 183 'name' => __( 'Everywhere', 'section-widget' ), 184 'description' => __( 'Display this widget everywhere on your site, i.e. behave like any other widgets.', 'section-widget' ), 185 ), 186 (object) array( 187 'parent' => 0, 188 'id' => 'front', 189 'name' => __( 'Front Page', 'section-widget' ), 190 'description' => __( 'Display this widget on the front page, as determined by your site\'s <a href="' . admin_url( 'options-reading.php' ) . '">Reading Settings</a>.', 'section-widget' ), 191 ), 192 (object) array( 193 'parent' => 0, 194 'id' => 'home', 195 'name' => __( 'Posts page', 'section-widget' ), 196 'description' => __( 'Display this widget on the posts page (i.e. your blog). This is usually your front page, but it can be changed in the <a href="' . admin_url( 'options-reading.php' ) . '">Reading Settings</a>.', 'section-widget' ), 197 ), 198 (object) array( 199 'parent' => 0, 200 'id' => 'category', 201 'name' => __( 'Selected Category Archive Pages', 'section-widget' ), 202 'description' => __( 'Display this widget on a category archive page if the corresponding category is selected in the <strong>Categories</strong> tab.', 'section-widget' ), 203 ), 204 (object) array( 205 'parent' => 0, 206 'id' => 'tag', 207 'name' => __( 'Selected Tag Archive Pages', 'section-widget' ), 208 'description' => __( 'Display this widget on a tag archive page if the corresponding tag is selected in the <strong>Tags</strong> tab.', 'section-widget' ), 209 ), 210 (object) array( 211 'parent' => 0, 212 'id' => 'allcategory', 213 'name' => __( 'All Category Archive Pages', 'section-widget' ), 214 'description' => __( 'Display this widget on all category archive pages.', 'section-widget' ), 215 ), 216 (object) array( 217 'parent' => 0, 218 'id' => 'alltag', 219 'name' => __( 'All Tag Archive Pages', 'section-widget' ), 220 'description' => __( 'Display this widget on all tag archive pages.', 'section-widget' ), 221 ), 222 (object) array( 223 'parent' => 0, 224 'id' => 'date', 225 'name' => __( 'All Date-Based Archive Pages', 'section-widget' ), 226 'description' => __( 'Display this widget on all date-based archive pages (i.e. all monthly, yearly, daily or time-based archives).', 'section-widget' ), 227 ), 228 (object) array( 229 'parent' => 0, 230 'id' => 'page', 231 'name' => __( 'All Pages', 'section-widget' ), 232 'description' => __( 'Display this widget on all pages.', 'section-widget' ), 233 ), 234 (object) array( 235 'parent' => 0, 236 'id' => 'post', 237 'name' => __( 'All Post', 'section-widget' ), 238 'description' => __( 'Display this widget on all posts.', 'section-widget' ), 239 ), 240 (object) array( 241 'parent' => 0, 242 'id' => 'comment', 243 'name' => __( 'Commentable Pages/Posts', 'section-widget' ), 244 'description' => __( 'Display this widget on all pages/posts where comments are allowed.', 'section-widget' ), 245 ), 246 (object) array( 247 'parent' => 0, 248 'id' => 'author', 249 'name' => __( 'Author Pages', 'section-widget' ), 250 'description' => __( 'Display this widget on all author pages.', 'section-widget' ), 251 ), 252 (object) array( 253 'parent' => 0, 254 'id' => 'search', 255 'name' => __( 'Search Results', 'section-widget' ), 256 'description' => __( 'Display this widget on all search result pages.', 'section-widget' ), 257 ), 258 (object) array( 259 'parent' => 0, 260 'id' => 'notfound', 261 'name' => __( '"Not Found" Pages', 'section-widget' ), 262 'description' => __( 'Display this widget when a requested page cannot be found.', 'section-widget' ), 263 ), 264 265 ); 266 163 267 $post_types = olt_checklist_post_types(); 164 165 foreach ($post_types as $post_type): 166 $type = get_post_type_object($post_type); 167 168 if($type->publicly_queryable): 169 array_push($data, (object) array('parent' => 0, 'id' => 'cpts-'.$post_type, 'name' => __('All ','section-widget').$type->labels->name, 'description' => __('Display this widget on all ','section-widget').$type->labels->name.__(' single pages','section-widget'))); 170 if($type->has_archive): 171 array_push($data, (object) array('parent' => 0, 'id' => 'cpta-'.$post_type, 'name' => $type->labels->name. __(" Archive Pages",'section-widget'), 'description' => __('Display this widget on all ','section-widget').$type->labels->name.__(' archive pages','section-widget'))); 172 endif; 173 endif; 174 268 269 foreach ( $post_types as $post_type ) : 270 $type = get_post_type_object( $post_type ); 271 272 if ( $type->publicly_queryable ) : 273 array_push( 274 $data, 275 (object) array( 276 'parent' => 0, 277 'id' => 'cpts-' . $post_type, 278 'name' => __( 'All ', 'section-widget' ) . $type->labels->name, 279 'description' => __( 'Display this widget on all ', 'section-widget' ) . $type->labels->name . __( ' single pages', 'section-widget' ), 280 ) 281 ); 282 if ( $type->has_archive ) : 283 array_push( 284 $data, 285 (object) array( 286 'parent' => 0, 287 'id' => 'cpta-' . $post_type, 288 'name' => $type->labels->name . __( ' Archive Pages', 'section-widget' ), 289 'description' => __( 'Display this widget on all ', 'section-widget' ) . $type->labels->name . __( ' archive pages', 'section-widget' ), 290 ) 291 ); 292 endif; 293 endif; 294 175 295 endforeach; 176 296 177 297 $taxonomies = olt_checklist_taxonomies(); 178 179 foreach ($taxonomies as $taxonomie): 180 $tax = get_taxonomy($taxonomie); 181 182 array_push($data, (object) array('parent' => 0, 'id' => 'cta--'.$taxonomie, 'name' => __("All ",'section-widget').$tax->labels->name. __(" Archive Pages",'section-widget'), 'description' => __('Display this widget on all ','section-widget').$type->labels->name.__(' taxonomy archive pages','section-widget'))); 298 299 foreach ( $taxonomies as $taxonomie ) : 300 $tax = get_taxonomy( $taxonomie ); 301 302 array_push( 303 $data, 304 (object) array( 305 'parent' => 0, 306 'id' => 'cta--' . $taxonomie, 307 'name' => __( 'All ', 'section-widget' ) . $tax->labels->name . __( ' Archive Pages', 'section-widget' ), 308 'description' => __( 'Display this widget on all ', 'section-widget' ) . $type->labels->name . __( ' taxonomy archive pages', 'section-widget' ), 309 ) 310 ); 183 311 184 312 endforeach; 185 186 $walker = new OLTSpecialPagesChecklistWalker; 187 break; 188 189 case 'categories': 190 $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'olt-checklist-categories', 'name' => 'olt-checklist-categories' ); 191 $data = get_categories('get=all'); 192 $walker = new OLTCategoryChecklistWalker; 193 break; 194 195 case 'tags': 196 $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'olt-checklist-tags', 'name' => 'olt-checklist-tags' ); 197 $data = get_tags('get=all'); 198 $walker = new OLTTagChecklistWalker; 199 break; 200 201 case 'pages': 202 default: 203 $defaults = array( 'selected' => array(), 'echo' => 1, 'id' => 'olt-checklist-pages', 'name' => 'olt-checklist-pages' ); 204 $data = get_pages('get=all'); 205 $walker = new OLTPageChecklistWalker; 206 break; 207 } 208 209 $args = wp_parse_args( $args, $defaults ); 210 extract( $args, EXTR_SKIP ); 211 212 if ( !empty($data) ) { 213 $output = "<ul class=\"olt-checklist\" id=\"$id\">\n"; 214 $output .= $walker->walk($data, 0, $args); 215 $output .= "</ul>\n"; 216 } else { 217 $output = __("No $mode found.",'section-widget'); 218 } 219 220 if ( $echo ) echo $output; 221 222 return $output; 223 } 224 /** 225 * olt_checklist_conditions_check function. 226 * 227 * @access public 228 * @param mixed $conditions 229 * @return void 230 */ 231 function olt_checklist_conditions_check($conditions) { 232 wp_reset_query(); // Just in case 233 234 // Most of the conditional tags will always return true when passed an empty array. So we need to pad them will some junk. 235 $conditions['special-pages'][] = -1; 236 $conditions['pages'][] = -1; 237 $conditions['categories'][] = -1; 238 $conditions['tags'][] = -1; 239 240 foreach($conditions['special-pages'] as $key) { 241 switch($key){ 242 case "all": 243 return true; 244 break; 245 case "front": 246 if(is_front_page()) 247 return true; 248 break; 249 case "home": 250 if(is_home()) 251 return true; 252 break; 253 case "category": 254 if(is_category($conditions['categories'])) 255 return true; 256 break; 257 case "tag": 258 $ts = get_tags(array('hide_empty'=>false,'include' => implode(',',$conditions['tags']))); 259 if(is_tag(array_map(create_function('$t', 'return $t->slug;'),$ts))) 260 return true; 261 break; 262 case "allcategory": 263 if(is_category()) 264 return true; 265 break; 266 case "alltag": 267 if(is_tag()) 268 return true; 269 break; 270 case "date": 271 if(is_date()) 272 return true; 273 break; 274 case "page": 275 // Exclude the front page to avoid confusion 276 if(!is_front_page() && is_page()) 277 return true; 278 break; 279 case "post": 280 if(is_single()) 281 return true; 282 break; 283 case "comment": 284 // Exclude the front page to avoid confusion 285 if(!is_front_page() && is_singular() && comments_open()) 286 return true; 287 break; 288 case "author": 289 if(is_author()) 290 return true; 291 break; 292 case "search": 293 if(is_search()) 294 return true; 295 break; 296 case "notfound": 297 if(is_404()) 298 return true; 299 break; 300 default: 301 // lets check if we have any custom post types 302 $sub = substr($key, 0, 4); 303 $rest = substr($key, 5); 304 switch($sub){ 305 case 'cpts': // single custom post type 306 if( is_singular( $rest ) ) 307 return true; 308 break; 309 310 case 'cpta' : // archive custom post type 311 if( is_post_type_archive( array( $rest ) ) ) 312 return true; 313 break; 314 315 case 'cta-': // archive custom taxonomy 316 if( is_tax( $rest ) ) 317 return true; 318 break; 319 320 } 321 322 break; 323 } 324 } 325 326 if(is_page($conditions['pages'])) 327 return true; 328 329 if(is_singular() && in_category($conditions['categories'])) 330 return true; 331 332 if(is_singular() && has_tag($conditions['tags'])) 333 return true; 334 335 return false; 336 } 337 338 /** 339 * olt_checklist_post_types function. 340 * 341 * @access public 342 * @return void 343 */ 344 function olt_checklist_post_types() { 345 $args = $args= array( 346 'public' => true, 347 '_builtin' => false 348 ); 349 $output = 'names'; // names or objects, note names is the default 313 314 $walker = new OLTSpecialPagesChecklistWalker(); 315 break; 316 317 case 'categories': 318 $defaults = array( 319 'selected' => array(), 320 'echo' => 1, 321 'id' => 'olt-checklist-categories', 322 'name' => 'olt-checklist-categories', 323 ); 324 $data = get_categories( 'get=all' ); 325 $walker = new OLTCategoryChecklistWalker(); 326 break; 327 328 case 'tags': 329 $defaults = array( 330 'selected' => array(), 331 'echo' => 1, 332 'id' => 'olt-checklist-tags', 333 'name' => 'olt-checklist-tags', 334 ); 335 $data = get_tags( 'get=all' ); 336 $walker = new OLTTagChecklistWalker(); 337 break; 338 339 case 'pages': 340 default: 341 $defaults = array( 342 'selected' => array(), 343 'echo' => 1, 344 'id' => 'olt-checklist-pages', 345 'name' => 'olt-checklist-pages', 346 ); 347 $data = get_pages( 'get=all' ); 348 $walker = new OLTPageChecklistWalker(); 349 break; 350 } 351 352 $args = wp_parse_args( $args, $defaults ); 353 extract( $args, EXTR_SKIP ); 354 355 if ( ! empty( $data ) ) { 356 $output = "<ul class=\"olt-checklist\" id=\"$id\">\n"; 357 $output .= $walker->walk( $data, 0, $args ); 358 $output .= "</ul>\n"; 359 } else { 360 $output = __( "No $mode found.", 'section-widget' ); 361 } 362 363 if ( $echo ) { 364 $allowed_html = array( 365 'div' => array( 366 'id' => true, 367 'class' => true, 368 ), 369 'ul' => array( 370 'class' => true, 371 'id' => true, 372 ), 373 'li' => array(), 374 'input' => array( 375 'type' => true, 376 'class' => true, 377 'id' => true, 378 'name' => true, 379 'value' => true, 380 'checked' => true, 381 ), 382 'label' => array( 383 'for' => true, 384 ), 385 'p' => array( 386 'class' => true, 387 ), 388 'a' => array( 389 'href' => true, 390 ), 391 'strong' => array(), 392 // add more as needed 393 ); 394 395 echo wp_kses($output, $allowed_html); 396 } 397 398 return $output; 399 } 400 /** 401 * olt_checklist_conditions_check function. 402 * 403 * @access public 404 * @param mixed $conditions 405 * @return void 406 */ 407 function olt_checklist_conditions_check( $conditions ) { 408 wp_reset_query(); // Just in case 409 410 // Most of the conditional tags will always return true when passed an empty array. So we need to pad them will some junk. 411 $conditions['special-pages'][] = -1; 412 $conditions['pages'][] = -1; 413 $conditions['categories'][] = -1; 414 $conditions['tags'][] = -1; 415 416 foreach ( $conditions['special-pages'] as $key ) { 417 switch ( $key ) { 418 case 'all': 419 return true; 420 break; 421 case 'front': 422 if ( is_front_page() ) { 423 return true; 424 } 425 break; 426 case 'home': 427 if ( is_home() ) { 428 return true; 429 } 430 break; 431 case 'category': 432 if ( is_category( $conditions['categories'] ) ) { 433 return true; 434 } 435 break; 436 case 'tag': 437 $ts = get_tags( 438 array( 439 'hide_empty' => false, 440 'include' => implode( ',', $conditions['tags'] ), 441 ) 442 ); 443 if ( is_tag( 444 array_map( 445 function ( $t ) { 446 return $t->slug; }, 447 $ts 448 ) 449 ) ) { 450 return true; 451 } 452 break; 453 454 case 'allcategory': 455 if ( is_category() ) { 456 return true; 457 } 458 break; 459 case 'alltag': 460 if ( is_tag() ) { 461 return true; 462 } 463 break; 464 case 'date': 465 if ( is_date() ) { 466 return true; 467 } 468 break; 469 case 'page': 470 // Exclude the front page to avoid confusion 471 if ( ! is_front_page() && is_page() ) { 472 return true; 473 } 474 break; 475 case 'post': 476 if ( is_single() ) { 477 return true; 478 } 479 break; 480 case 'comment': 481 // Exclude the front page to avoid confusion 482 if ( ! is_front_page() && is_singular() && comments_open() ) { 483 return true; 484 } 485 break; 486 case 'author': 487 if ( is_author() ) { 488 return true; 489 } 490 break; 491 case 'search': 492 if ( is_search() ) { 493 return true; 494 } 495 break; 496 case 'notfound': 497 if ( is_404() ) { 498 return true; 499 } 500 break; 501 default: 502 // lets check if we have any custom post types 503 $sub = substr( $key, 0, 4 ); 504 $rest = substr( $key, 5 ); 505 switch ( $sub ) { 506 case 'cpts': // single custom post type 507 if ( is_singular( $rest ) ) { 508 return true; 509 } 510 break; 511 512 case 'cpta': // archive custom post type 513 if ( is_post_type_archive( array( $rest ) ) ) { 514 return true; 515 } 516 break; 517 518 case 'cta-': // archive custom taxonomy 519 if ( is_tax( $rest ) ) { 520 return true; 521 } 522 break; 523 524 } 525 526 break; 527 } 528 } 529 530 if ( is_page( $conditions['pages'] ) ) { 531 return true; 532 } 533 534 if ( is_singular() && in_category( $conditions['categories'] ) ) { 535 return true; 536 } 537 538 if ( is_singular() && has_tag( $conditions['tags'] ) ) { 539 return true; 540 } 541 542 return false; 543 } 544 545 /** 546 * olt_checklist_post_types function. 547 * 548 * @access public 549 * @return void 550 */ 551 function olt_checklist_post_types() { 552 $args = $args = array( 553 'public' => true, 554 '_builtin' => false, 555 ); 556 $output = 'names'; // names or objects, note names is the default 350 557 $operator = 'and'; // 'and' or 'or' 351 return get_post_types( $args, $output, $operator);352 }353 /**354 * olt_checklist_taxonomies function.355 * 356 * @access public357 * @return void358 */359 function olt_checklist_taxonomies(){360 $args= array(361 'public' => true,362 '_builtin' => false 363 ); 364 $output = 'names'; // or objects558 return get_post_types( $args, $output, $operator ); 559 } 560 /** 561 * olt_checklist_taxonomies function. 562 * 563 * @access public 564 * @return void 565 */ 566 function olt_checklist_taxonomies() { 567 $args = array( 568 'public' => true, 569 '_builtin' => false, 570 ); 571 $output = 'names'; // or objects 365 572 $operator = 'and'; // 'and' or 'or' 366 return get_taxonomies($args,$output,$operator); 367 } 368 369 370 /** 371 * OLTSpecialPagesChecklistWalker class. 372 * 373 * @extends Walker 374 */ 375 class OLTSpecialPagesChecklistWalker extends Walker { 376 377 var $tree_type = 'special'; 378 var $db_fields = array ( 'parent' => 'parent', 'id' => 'id'); 379 380 function start_el(&$output, $special_page, $depth = 0, $args = array(), $current_object_id = 0) { 381 extract($args); 382 383 if(in_array($special_page->id, $exclude)) return; 384 385 $id = "{$id}-{$special_page->id}"; 386 $name .= '[]'; 387 $title = esc_html($special_page->name); 388 $desc = $special_page->description; // Don't escape HTML here.. 389 390 $output .= "<li><div class=\"olt-checklist-entry\"><input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$special_page->id\""; 391 if ( in_array($special_page->id, $selected) ) 392 $output .= ' checked="checked"'; 393 $output .= " /> <label for=\"$id\">$title</label><p>$desc</p></div>\n"; 394 } 395 } 396 /** 397 * OLTChecklistWalker class. 398 * 399 * @extends Walker 400 */ 401 class OLTChecklistWalker extends Walker { 402 403 function start_lvl(&$output, $depth=0, $args=array()) { 404 $indent = str_repeat("\t", $depth); 405 $output .= "$indent<ul class='children'>\n"; 406 } 407 408 function end_lvl(&$output, $depth=0, $args=array()) { 409 $indent = str_repeat("\t", $depth); 410 $output .= "$indent</ul>\n"; 411 } 412 413 function end_el(&$output, $page, $depth=0, $args=array()) { 414 $output .= "</li>\n"; 415 } 416 } 417 /** 418 * OLTPageChecklistWalker class. 419 * 420 * @extends OLTChecklistWalker 421 */ 422 class OLTPageChecklistWalker extends OLTChecklistWalker { 423 424 var $tree_type = 'page'; 425 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); 426 427 function start_el(&$output, $page, $depth=0, $args=array(), $current_object_id=0) { 428 extract($args); 429 430 $pad = str_repeat(' ', $depth * 4); 431 $id = "{$id}-{$page->ID}"; 432 $name .= '[]'; 433 $title = esc_html($page->post_title); 434 435 $output .= "<li><div class=\"olt-checklist-entry\">$pad<input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$page->ID\""; 436 if ( in_array($page->ID, $selected) ) 437 $output .= ' checked="checked"'; 438 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 439 } 440 } 441 /** 442 * OLtCategoryChecklistWalker class. 443 * 444 * @extends OLTChecklistWalker 445 */ 446 class OLtCategoryChecklistWalker extends OLTChecklistWalker { 447 448 var $tree_type = 'category'; 449 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 450 function start_el(&$output, $category, $depth=0, $args=array(), $current_object_id=0) { 451 extract($args); 452 453 $pad = str_repeat(' ', $depth * 4); 454 $id = "{$id}-{$category->term_id}"; 455 $name .= '[]'; 456 $title = esc_html($category->name); 457 458 $output .= "<li><div class=\"olt-checklist-entry\">$pad<input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$category->term_id\""; 459 if ( in_array($category->term_id, $selected) ) 460 $output .= ' checked="checked"'; 461 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 462 } 463 } 464 /** 465 * OLTTagChecklistWalker class. 466 * 467 * @extends Walker 468 */ 469 class OLTTagChecklistWalker extends Walker { 470 471 var $tree_type = 'tag'; 472 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 473 474 function start_el(&$output, $tag, $depth=0, $args=array(), $current_object_id=0) { 475 extract($args); 476 477 $id = "{$id}-{$tag->term_id}"; 478 $name .= '[]'; 479 $title = esc_html($tag->name); 480 481 $output .= "<li><div class=\"olt-checklist-entry\"><input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$tag->term_id\""; 482 if ( in_array($tag->term_id, $selected) ) 483 $output .= ' checked="checked"'; 484 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 485 } 486 } 573 return get_taxonomies( $args, $output, $operator ); 574 } 575 576 577 /** 578 * OLTSpecialPagesChecklistWalker class. 579 * 580 * @extends Walker 581 */ 582 class OLTSpecialPagesChecklistWalker extends Walker { 583 584 var $tree_type = 'special'; 585 var $db_fields = array( 586 'parent' => 'parent', 587 'id' => 'id', 588 ); 589 590 function start_el( &$output, $special_page, $depth = 0, $args = array(), $current_object_id = 0 ) { 591 extract( $args ); 592 593 if ( in_array( $special_page->id, $exclude ) ) { 594 return; 595 } 596 597 $id = "{$id}-{$special_page->id}"; 598 $name .= '[]'; 599 $title = esc_html( $special_page->name ); 600 $desc = $special_page->description; // Don't escape HTML here.. 601 602 $output .= "<li><div class=\"olt-checklist-entry\"><input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$special_page->id\""; 603 if ( in_array( $special_page->id, $selected ) ) { 604 $output .= ' checked="checked"'; 605 } 606 $output .= " /> <label for=\"$id\">$title</label><p>$desc</p></div>\n"; 607 } 608 } 609 /** 610 * OLTChecklistWalker class. 611 * 612 * @extends Walker 613 */ 614 class OLTChecklistWalker extends Walker { 615 616 function start_lvl( &$output, $depth = 0, $args = array() ) { 617 $indent = str_repeat( "\t", $depth ); 618 $output .= "$indent<ul class='children'>\n"; 619 } 620 621 function end_lvl( &$output, $depth = 0, $args = array() ) { 622 $indent = str_repeat( "\t", $depth ); 623 $output .= "$indent</ul>\n"; 624 } 625 626 function end_el( &$output, $page, $depth = 0, $args = array() ) { 627 $output .= "</li>\n"; 628 } 629 } 630 /** 631 * OLTPageChecklistWalker class. 632 * 633 * @extends OLTChecklistWalker 634 */ 635 class OLTPageChecklistWalker extends OLTChecklistWalker { 636 637 var $tree_type = 'page'; 638 var $db_fields = array( 639 'parent' => 'post_parent', 640 'id' => 'ID', 641 ); 642 643 function start_el( &$output, $page, $depth = 0, $args = array(), $current_object_id = 0 ) { 644 extract( $args ); 645 646 $pad = str_repeat( ' ', $depth * 4 ); 647 $id = "{$id}-{$page->ID}"; 648 $name .= '[]'; 649 $title = esc_html( $page->post_title ); 650 651 $output .= "<li><div class=\"olt-checklist-entry\">$pad<input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$page->ID\""; 652 if ( in_array( $page->ID, $selected ) ) { 653 $output .= ' checked="checked"'; 654 } 655 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 656 } 657 } 658 /** 659 * OLtCategoryChecklistWalker class. 660 * 661 * @extends OLTChecklistWalker 662 */ 663 class OLtCategoryChecklistWalker extends OLTChecklistWalker { 664 665 var $tree_type = 'category'; 666 var $db_fields = array( 667 'parent' => 'parent', 668 'id' => 'term_id', 669 ); 670 function start_el( &$output, $category, $depth = 0, $args = array(), $current_object_id = 0 ) { 671 extract( $args ); 672 673 $pad = str_repeat( ' ', $depth * 4 ); 674 $id = "{$id}-{$category->term_id}"; 675 $name .= '[]'; 676 $title = esc_html( $category->name ); 677 678 $output .= "<li><div class=\"olt-checklist-entry\">$pad<input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$category->term_id\""; 679 if ( in_array( $category->term_id, $selected ) ) { 680 $output .= ' checked="checked"'; 681 } 682 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 683 } 684 } 685 /** 686 * OLTTagChecklistWalker class. 687 * 688 * @extends Walker 689 */ 690 class OLTTagChecklistWalker extends Walker { 691 692 var $tree_type = 'tag'; 693 var $db_fields = array( 694 'parent' => 'parent', 695 'id' => 'term_id', 696 ); 697 698 function start_el( &$output, $tag, $depth = 0, $args = array(), $current_object_id = 0 ) { 699 extract( $args ); 700 701 $id = "{$id}-{$tag->term_id}"; 702 $name .= '[]'; 703 $title = esc_html( $tag->name ); 704 705 $output .= "<li><div class=\"olt-checklist-entry\"><input type=\"checkbox\" class=\"level-$depth\" id=\"$id\" name=\"$name\" value=\"$tag->term_id\""; 706 if ( in_array( $tag->term_id, $selected ) ) { 707 $output .= ' checked="checked"'; 708 } 709 $output .= " /> <label for=\"$id\">$title</label></div>\n"; 710 } 711 } 487 712 } 488 ?> -
section-widget/trunk/readme.txt
r821249 r3286504 1 1 === Section Widget === 2 Contributors: oltdev, godfreykfc, enej, ubcdev, loongchan, ctlt-dev, ctlt-dev2 Contributors: oltdev, godfreykfc, enej, ubcdev, ctlt-dev, ctlt-dev 3 3 Tags: text, html, shortcode, tabs, tabbed, widget, conditional, section, per page, post type, taxonomies 4 4 Requires at least: 3.6 -
section-widget/trunk/section-widget-options-page.php
r821249 r3286504 103 103 ?> 104 104 <script type="text/javascript"> 105 var stylesheet_url = '<?php echo plugins_url("section-widget/themes/theme-loader.php"); ?>';106 var links = [<?php echo $links_text; ?>];105 var stylesheet_url = '<?php echo esc_url( plugins_url("section-widget/themes/theme-loader.php") ); ?>'; 106 var links = [<?php echo esc_html( $links_text ); ?>]; 107 107 </script> 108 108 109 109 <div class="wrap"> 110 <h2><?php _e('Section Widget Settings','section-widget'); ?></h2>110 <h2><?php esc_html_e('Section Widget Settings','section-widget'); ?></h2> 111 111 <?php if($updated): ?> 112 <div class="updated"><p><strong><?php _e('Settings updated.','section-widget'); ?></strong></p></div>112 <div class="updated"><p><strong><?php esc_html_e('Settings updated.','section-widget'); ?></strong></p></div> 113 113 <?php endif; ?> 114 114 <form method="post"> 115 <h3><?php _e('Tabbed Section Widget','section-widget'); ?></h3>115 <h3><?php esc_html_e('Tabbed Section Widget','section-widget'); ?></h3> 116 116 <p> 117 <?php _e('Section Widget ships with 25 default <a href="http://jqueryui.com/" target="_blank">jQuery UI</a> themes. You can specify a CSS selector which will be prepended to all CSS rules provided by the theme. Click on the help link below if you are not sure what to do.','section-widget'); ?>117 <?php esc_html_e('Section Widget ships with 25 default <a href="http://jqueryui.com/" target="_blank">jQuery UI</a> themes. You can specify a CSS selector which will be prepended to all CSS rules provided by the theme. Click on the help link below if you are not sure what to do.','section-widget'); ?> 118 118 </p> 119 119 <p> 120 <?php _e('You may also roll your own theme by selecteing <strong>Bring My Own Stylesheet</strong> in theme menu. If you choose to do this, no extra stylesheet will be loaded and the CSS Scope option will be <strong>ignored</strong>. In this case the <strong>Base</strong> theme will be used in the widget designer. Refer to the <a href="http://jqueryui.com/docs/Theming" target="_blank">theming guide</a> for more information.','section-widget'); ?>120 <?php esc_html_e('You may also roll your own theme by selecteing <strong>Bring My Own Stylesheet</strong> in theme menu. If you choose to do this, no extra stylesheet will be loaded and the CSS Scope option will be <strong>ignored</strong>. In this case the <strong>Base</strong> theme will be used in the widget designer. Refer to the <a href="http://jqueryui.com/docs/Theming" target="_blank">theming guide</a> for more information.','section-widget'); ?> 121 121 </p> 122 122 <table class="form-table"> 123 123 <tr valign="top"> 124 124 <th scope="row"> 125 <label for="swt-theme"><?php _e('Theme','section-widget'); ?></label>125 <label for="swt-theme"><?php esc_html_e('Theme','section-widget'); ?></label> 126 126 </th> 127 127 <td> 128 128 <select name="swt_theme" id="swt-theme"> 129 129 <option value="none" <?php if($theme == 'none') echo 'selected="selected"'; ?>> 130 <?php _e('Bring My Own Stylesheet','section-widget'); ?>130 <?php esc_html_e('Bring My Own Stylesheet','section-widget'); ?> 131 131 </option> 132 132 <?php foreach($themes as $t): ?> 133 <option value="<?php echo $t; ?>" <?php if($theme == $t) echo 'selected="selected"'; ?>>134 <?php echo theme_display_name($t); ?>133 <option value="<?php echo esc_attr($t); ?>" <?php if($theme == $t) echo 'selected="selected"'; ?>> 134 <?php echo esc_html(theme_display_name($t)); ?> 135 135 </option> 136 136 <?php endforeach; ?> 137 137 </select> 138 <span class="description">(<a id="swt-theme-preview-link" href="#"><?php _e('Preview','section-widget'); ?></a>)</span>138 <span class="description">(<a id="swt-theme-preview-link" href="#"><?php esc_html_e('Preview','section-widget'); ?></a>)</span> 139 139 <div id="swt-theme-preview" style="display:none"> 140 140 <div id="swt-theme-preview-wrapper"> … … 155 155 </div> 156 156 <p> 157 <a id="swt-theme-preview-hide-link" href="#"><?php _e('Hide preview','section-widget'); ?></a>157 <a id="swt-theme-preview-hide-link" href="#"><?php esc_html_e('Hide preview','section-widget'); ?></a> 158 158 </p> 159 159 </div> … … 162 162 <tr valign="top"> 163 163 <th scope="row"> 164 <label for="swt-scope"><?php _e('CSS Scope','section-widget'); ?></label>164 <label for="swt-scope"><?php esc_html_e('CSS Scope','section-widget'); ?></label> 165 165 </th> 166 166 <td> 167 <input name="swt_scope" type="text" id="swt-scope" value="<?php echo $scope?>" class="regular-text code" />168 <span class="description"><?php _e('Enter a CSS selector to limit the theme\'s scope (<a id="swt-scope-help-link" href="#">Help is here</a>)','section-widget'); ?></span>167 <input name="swt_scope" type="text" id="swt-scope" value="<?php echo esc_attr($scope) ?>" class="regular-text code" /> 168 <span class="description"><?php esc_html_e('Enter a CSS selector to limit the theme\'s scope (<a id="swt-scope-help-link" href="#">Help is here</a>)','section-widget'); ?></span> 169 169 <div id="swt-scope-help" style="display:none"> 170 170 <p> 171 <?php _e('This is to ensure the theme you have chosen here will not affect other areas of your site. Generally speaking, you would want to narrow down the scope as much as possible. This would help to override rules defined by your WordPress theme too.','section-widget'); ?>172 </p> 173 <p> 174 <?php _e('If you have no idea what this is all about, we can detect the optimal settings for you. To do this, you would need to have <strong>at least two Tabbed Section Widget</strong> added to your sidebar. You can do that in the','section-widget') ?> <a href="<?php echo admin_url('widgets.php'); ?>"><?php _e('Widgets','section-widget'); ?></a> <?php_e('control panel. You may choose to leave out the content fields so that they would be invisible to your visitors.','section-widget'); ?>175 </p> 176 <p> 177 <?php _e('Once you\'ve done that, come back to this page and click the button below.','section-widget'); ?>171 <?php esc_html_e('This is to ensure the theme you have chosen here will not affect other areas of your site. Generally speaking, you would want to narrow down the scope as much as possible. This would help to override rules defined by your WordPress theme too.','section-widget'); ?> 172 </p> 173 <p> 174 <?php esc_html_e('If you have no idea what this is all about, we can detect the optimal settings for you. To do this, you would need to have <strong>at least two Tabbed Section Widget</strong> added to your sidebar. You can do that in the','section-widget') ?> <a href="<?php echo esc_url(admin_url('widgets.php')); ?>"><?php esc_html_e('Widgets','section-widget'); ?></a> <?php esc_html_e('control panel. You may choose to leave out the content fields so that they would be invisible to your visitors.','section-widget'); ?> 175 </p> 176 <p> 177 <?php esc_html_e('Once you\'ve done that, come back to this page and click the button below.','section-widget'); ?> 178 178 </p> 179 179 <div> … … 182 182 </div> 183 183 <p> 184 <a id="swt-scope-help-hide-link" href="#"><?php _e('Hide this help message','section-widget'); ?></a>184 <a id="swt-scope-help-hide-link" href="#"><?php esc_html_e('Hide this help message','section-widget'); ?></a> 185 185 </p> 186 186 </div> … … 189 189 <tr valign="top"> 190 190 <th scope="row"> 191 <?php _e('Height Fix','section-widget'); ?>191 <?php esc_html_e('Height Fix','section-widget'); ?> 192 192 </th> 193 193 <td> 194 194 <label for="swt_heightfix"> 195 <input name="swt_heightfix" type="checkbox" id="swt_heightfix" value="true" class="regular-text code"<?php echo $heightFix?> />196 <?php _e('Turn this on if the widget looks stretched out on your theme','section-widget'); ?>195 <input name="swt_heightfix" type="checkbox" id="swt_heightfix" value="true" class="regular-text code"<?php echo esc_attr($heightFix) ?> /> 196 <?php esc_html_e('Turn this on if the widget looks stretched out on your theme','section-widget'); ?> 197 197 </label> 198 198 </td> … … 200 200 </table> 201 201 <p class="submit"> 202 <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes','section-widget'); ?>" />202 <input type="submit" name="Submit" class="button-primary" value="<?php esc_html_e('Save Changes','section-widget'); ?>" /> 203 203 </p> 204 204 </form> -
section-widget/trunk/section-widget-tabbed.php
r910718 r3286504 11 11 /** 12 12 * OLT_Tabbed_Section_Widget class. 13 * 13 * 14 14 * @extends WP_Widget 15 15 */ … … 21 21 /** 22 22 * OLT_Tabbed_Section_Widget function. 23 * 23 * 24 24 * @access public 25 25 * @return void 26 26 */ 27 function OLT_Tabbed_Section_Widget() {27 function __construct() { 28 28 $widget_ops = array('classname' => 'section-widget-tabbed', 'description' => __('Display section-specific content in tabs.')); 29 29 $control_ops = array('width' => 400); 30 $this->WP_Widget('section-tabbed', __('Section (Tabbed)'), $widget_ops, $control_ops);31 32 33 } 34 35 36 30 parent::__construct('section-tabbed', __('Section (Tabbed)'), $widget_ops, $control_ops); 31 32 33 } 34 35 36 37 37 /** 38 38 * widget function. 39 * 39 * 40 40 * @access public 41 41 * @param mixed $args … … 45 45 function widget( $args, $instance ) { 46 46 extract($args); 47 47 48 48 extract(wp_parse_args((array) get_option('section-widget-settings'), array( 49 49 'heightfix' => false // This is all I care about 50 50 ))); 51 51 52 52 if(isset($_GET['swt-scope-test'])) { 53 echo $before_widget . '<div class="swt-wrapper">Section Widget Scope Test</div>' . $after_widget;53 echo wp_kses_post($before_widget) . '<div class="swt-wrapper">Section Widget Scope Test</div>' . wp_kses_post($after_widget); 54 54 return; 55 55 } 56 56 57 57 // olt_checklist_conditions_check is the replacement for $should_display 58 58 if(olt_checklist_conditions_check($instance['section_conditions'])) { 59 59 if(count($instance['tabs']) == 0) 60 60 return; 61 61 62 62 $list = ''; 63 63 $content = ''; 64 64 65 65 if( is_array( get_theme_support('tabs') ) ) { 66 66 $current_tabs_theme_support = reset( get_theme_support('tabs') ); … … 68 68 $current_tabs_theme_support = false; 69 69 } 70 71 70 71 72 72 if ( $current_tabs_theme_support == 'twitter-bootstrap' ) { 73 73 foreach($instance['tabs'] as $id => $tab) { 74 74 75 75 if ( $id == 0 ): 76 76 $list .= "<li class=\"active\">"; … … 79 79 endif; 80 80 $list .= "<a href=\"#{$widget_id}-tab-{$id}\">{$tab['title']}</a></li>"; 81 82 81 82 83 83 if ( $id == 0 ): 84 84 $content .= "<div class=\"tab-pane active\" "; … … 86 86 $content .= "<div class=\"tab-pane\" "; 87 87 endif; 88 88 89 89 $content .= "id=\"{$widget_id}-tab-{$id}\">".do_shortcode($tab['body']).'</div>'; 90 90 } … … 96 96 } 97 97 $heightFixClass = ($heightfix)? ' class="swt-height-fix"' : ''; 98 if ( $current_tabs_theme_support == 'twitter-bootstrap' ) { 98 if ( $current_tabs_theme_support == 'twitter-bootstrap' ) { 99 99 $html = '<ul class="nav nav-tabs" id="'.$widget_id.'">'; 100 #$html .= 100 #$html .= 101 101 $html .= $list; 102 102 $html .= '</ul>'; … … 107 107 108 108 $html = "<ul{$heightFixClass}>".$list.'</ul>'.$content; 109 110 } 111 112 echo $before_widget;113 109 110 } 111 $before_widget = str_replace( 'class="', 'class="section-widget-tabbed ', $before_widget ); 112 echo wp_kses_post($before_widget); 113 114 114 if($instance['display-title']){ 115 echo $before_title;116 echo apply_filters('widget_title', $instance['title']);117 echo $after_title;118 } 119 115 echo wp_kses_post($before_title); 116 echo esc_html( apply_filters('widget_title', $instance['title']) ); 117 echo wp_kses_post($after_title); 118 } 119 120 120 if ( $current_tabs_theme_support == 'twitter-bootstrap' ) { 121 122 123 121 122 123 124 124 echo apply_filters('widget_text', $html); 125 125 126 126 if ( is_null(self::$widget_ids) ) { 127 127 self::$widget_ids = array ( $widget_id ); … … 131 131 132 132 ?> 133 133 134 134 <?php 135 } else { 135 } else { 136 136 echo '<div class="swt-outter"><div class="swt-wrapper">'; 137 137 echo apply_filters('widget_text', $html); 138 138 echo '</div></div>'; 139 139 } 140 echo $after_widget;140 echo wp_kses_post($after_widget); 141 141 } 142 142 } 143 143 /** 144 144 * update function. 145 * 145 * 146 146 * @access public 147 147 * @param mixed $new_instance … … 152 152 // Mostly borrowed from text widget 153 153 $instance = $old_instance; 154 154 155 155 // For backwards compatibility: 156 156 if(!is_array($instance['section_conditions']) && is_array($instance['conditions'])) { … … 159 159 $instance['title'] = strip_tags($new_instance['title']); 160 160 $instance['display-title'] = (bool) $new_instance['display-title']; 161 161 162 162 $instance['section_conditions'] = is_array($new_instance['section_conditions'])? 163 163 $new_instance['section_conditions'] : array(); 164 164 165 165 $instance['section_conditions']['special-pages'] = 166 166 is_array($new_instance['section_conditions']['special-pages'])? 167 167 $new_instance['section_conditions']['special-pages'] : array(); 168 168 169 169 $instance['section_conditions']['pages'] = 170 170 is_array($new_instance['section_conditions']['pages'])? 171 171 $new_instance['section_conditions']['pages'] : array(); 172 172 173 173 $instance['section_conditions']['categories'] = 174 174 is_array($new_instance['section_conditions']['categories'])? 175 175 $new_instance['section_conditions']['categories'] : array(); 176 176 177 177 $instance['section_conditions']['tags'] = 178 178 is_array($new_instance['section_conditions']['tags'])? 179 179 $new_instance['section_conditions']['tags'] : array(); 180 180 181 181 $instance['tabs'] = array(); 182 182 183 183 if(is_array($new_instance['tabs'])) { 184 184 $tabs = array(); 185 185 186 186 if(isset($new_instance['order']) && $new_instance['order'] != '') { 187 187 // order=1&order=0&order=2... 188 188 $order = explode('&', str_replace('order=', '', $new_instance['order'])); 189 189 190 190 foreach($order as $i) { 191 191 if(isset($new_instance['tabs'][intval($i)])) { … … 195 195 } 196 196 } 197 197 198 198 $tabs = array_merge($tabs, $new_instance['tabs']); 199 199 200 200 foreach($tabs as $tab){ 201 201 $title = strip_tags($tab['title']); … … 204 204 else 205 205 $body = wp_filter_post_kses( $tab['body'] ); 206 206 207 207 $instance['tabs'][] = array( 208 208 'title' => $title, … … 211 211 } 212 212 } 213 213 214 214 // Processing tabs below 215 215 return $instance; … … 217 217 /** 218 218 * form function. 219 * 219 * 220 220 * @access public 221 221 * @param mixed $instance … … 235 235 ) 236 236 )); 237 237 238 238 // Make sure second level options are actually arrays 239 239 foreach($instance['tabs'] as $i => $v) 240 240 if(!is_array($v)) 241 241 $instance['tabs'][$i] = array(); 242 242 243 243 foreach($instance['section_conditions'] as $i => $v) 244 244 if(!is_array($v)) 245 245 $instance['section_conditions'][$i] = array(); 246 247 246 247 248 248 $title = strip_tags($instance['title']); 249 249 $display_title = (bool) $instance['display-title']; … … 252 252 $categories = $instance['section_conditions']['categories']; 253 253 $tags = $instance['section_conditions']['tags']; 254 254 255 255 $tabs = is_array($instance['tabs'])? $instance['tabs'] : array(); 256 256 257 257 foreach($tabs as $i => $tab) { 258 258 $tabs[$i]['title'] = strip_tags($tab['title']); … … 261 261 ?> 262 262 <p> 263 <label for="<?php echo $this->get_field_id('title'); ?>"><?php_e('Title:','section-widget'); ?></label>264 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />265 <input id="<?php echo $this->get_field_id('display-title'); ?>" name="<?php echo $this->get_field_name('display-title'); ?>" type="checkbox" <?php checked($display_title); ?> />266 <label for="<?php echo $this->get_field_id('display-title'); ?>"><?php_e('Display title','section-widget'); ?></label>263 <label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php esc_html_e('Title:','section-widget'); ?></label> 264 <input class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> 265 <input id="<?php echo esc_attr( $this->get_field_id('display-title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('display-title') ); ?>" type="checkbox" <?php checked($display_title); ?> /> 266 <label for="<?php echo esc_attr( $this->get_field_id('display-title') ); ?>"><?php esc_html_e('Display title','section-widget'); ?></label> 267 267 </p> 268 <?php 268 <?php 269 269 olt_checklist_pane(array( 270 270 'id' => $this->get_field_id('section_conditions'), … … 277 277 ?> 278 278 <div class="olt-swt-designer"> 279 <input type="hidden" name="idprefix" value="<?php echo $this->get_field_id('tab')?>" />280 <input type="hidden" name="nameprefix" value="<?php echo $this->get_field_name('tabs')?>" />281 <input type="hidden" name="<?php echo $this->get_field_name('order')?>" class="olt-swt-order" />282 <div class="olt-swt-designer-wrapper" id="<?php echo $this->get_field_id('designer-wrapper')?>">283 <div id="<?php echo $this->get_field_id('designer-main')?>" class="olt-swt-designer-main">279 <input type="hidden" name="idprefix" value="<?php echo esc_attr( $this->get_field_id('tab') ); ?>" /> 280 <input type="hidden" name="nameprefix" value="<?php echo esc_attr( $this->get_field_name('tabs') ); ?>" /> 281 <input type="hidden" name="<?php echo esc_attr( $this->get_field_name('order') ); ?>" class="olt-swt-order" /> 282 <div class="olt-swt-designer-wrapper" id="<?php echo esc_attr( $this->get_field_id('designer-wrapper') ); ?>"> 283 <div id="<?php echo esc_attr( $this->get_field_id('designer-main') ); ?>" class="olt-swt-designer-main"> 284 284 <ul> 285 285 <?php foreach($tabs as $id => $tab): ?> 286 <li class="olt-swt-designer-tab" id="<?php echo $this->get_field_id('tab-'.$id); ?>-list">287 <a href="#<?php echo $this->get_field_id('tab-'.$id); ?>" id="<?php echo $this->get_field_id('tab-'.$id.'-title-link'); ?>">286 <li class="olt-swt-designer-tab" id="<?php echo esc_attr( $this->get_field_id('tab-'.$id) ); ?>-list"> 287 <a href="#<?php echo esc_attr( $this->get_field_id('tab-'.$id) ); ?>" id="<?php echo esc_attr( $this->get_field_id('tab-'.$id.'-title-link') ); ?>"> 288 288 <?php echo esc_html($tab['title']); ?> 289 289 </a> … … 291 291 <?php endforeach; ?> 292 292 <li class="olt-swt-designer-tabs-controls olt-swt-designer-add-tab"> 293 <a><span class="ui-icon ui-icon-plusthick" style="float:left;margin-right:.3em;margin-top: -1px;"></span><?php _e('Add a new tab','section-widget'); ?></a>293 <a><span class="ui-icon ui-icon-plusthick" style="float:left;margin-right:.3em;margin-top: -1px;"></span><?php esc_html_e('Add a new tab','section-widget'); ?></a> 294 294 </li> 295 295 </ul> 296 296 <?php foreach($tabs as $id => $tab): ?> 297 <div id="<?php echo $this->get_field_id('tab-'.$id)?>" class="olt-swt-designer-panel">297 <div id="<?php echo esc_attr( $this->get_field_id('tab-'.$id) ); ?>" class="olt-swt-designer-panel"> 298 298 <div class="olt-swt-designer-top"> 299 <label for="<?php echo $this->get_field_id('tab-'.$id.'-title'); ?>"><?php_e('Title:','section-widget'); ?></label>300 <input id="<?php echo $this->get_field_id('tab-'.$id.'-title'); ?>" class="olt-swt-designer-tab-title" name="<?php echo $this->get_field_name('tabs')."[$id][title]"; ?>" type="text" value="<?php echo esc_attr($tab['title']); ?>" />299 <label for="<?php echo esc_attr( $this->get_field_id('tab-'.$id.'-title') ); ?>"><?php esc_html_e('Title:','section-widget'); ?></label> 300 <input id="<?php echo esc_attr( $this->get_field_id('tab-'.$id.'-title') ); ?>" class="olt-swt-designer-tab-title" name="<?php echo esc_attr( $this->get_field_name('tabs') )."[".esc_attr($id)."][title]"; ?>" type="text" value="<?php echo esc_attr($tab['title']); ?>" /> 301 301 <p class="olt-swt-designer-tabs-controls olt-swt-designer-delete-tab"> 302 <a href="#" id="<?php echo $this->get_field_id('tab-'.$id) ?>-delete"><span class="ui-icon ui-icon-trash" style="float:left;margin-right:.3em;margin-top: -2px;"></span><?php_e('Delete this tab','section-widget');?></a>302 <a href="#" id="<?php echo esc_attr( $this->get_field_id('tab-'.$id) ); ?>-delete"><span class="ui-icon ui-icon-trash" style="float:left;margin-right:.3em;margin-top: -2px;"></span><?php esc_html_e('Delete this tab','section-widget');?></a> 303 303 </p> 304 304 </div> 305 305 <div class="olt-sw-body"> 306 306 <p class="olt-sw-body-help"> 307 <?php _e('<strong>Formatting Help:</strong> You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.','section-widget');?></p>308 <textarea rows="16" cols="20" name="<?php echo $this->get_field_name('tabs')."[$id][body]"; ?>"><?php echo esc_html($tab['body']); ?></textarea>307 <?php esc_html_e('<strong>Formatting Help:</strong> You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.','section-widget');?></p> 308 <textarea rows="16" cols="20" name="<?php echo esc_attr( $this->get_field_name('tabs') )."[".esc_attr($id)."][body]"; ?>"><?php echo esc_html($tab['body']); ?></textarea> 309 309 </div> 310 310 </div> … … 314 314 </div> 315 315 <script type="text/javascript"> 316 //console.log('<?php echo $this->get_field_id('designer-main'); ?>', '<?php echo $this->get_field_id('conditions-wrapper'); ?>');316 //console.log('<?php echo esc_attr( $this->get_field_id('designer-main') ); ?>', '<?php echo esc_attr( $this->get_field_id('conditions-wrapper') ); ?>'); 317 317 if(typeof OLTChecklistPaneInit == 'function') 318 OLTChecklistPaneInit(jQuery('#<?php echo $this->get_field_id('conditions-wrapper'); ?>'));318 OLTChecklistPaneInit(jQuery('#<?php echo esc_attr( $this->get_field_id('conditions-wrapper') ); ?>')); 319 319 if(typeof OLTSWTInit == 'function') 320 OLTSWTInit(jQuery('#<?php echo $this->get_field_id('designer-wrapper')?>'));320 OLTSWTInit(jQuery('#<?php echo esc_attr( $this->get_field_id('designer-wrapper') ); ?>')); 321 321 </script> 322 322 <?php … … 325 325 /** 326 326 * tabbed_section_widget_init function. 327 * 327 * 328 328 * @access public 329 329 * @return void … … 334 334 /** 335 335 * tabbed_section_widget_load_scripts function. 336 * 336 * 337 337 * @access public 338 338 * @return void 339 339 */ 340 340 function tabbed_section_widget_load_scripts() { 341 341 342 342 extract(wp_parse_args((array) get_option('section-widget-settings'), array( 343 343 'theme' => 'redmond', … … 345 345 'heightfix' => false 346 346 ))); 347 347 348 348 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 349 349 350 350 if(is_admin() ): 351 351 global $pagenow; 352 352 353 353 if( $pagenow == 'widgets.php' ): 354 354 355 355 if($theme == 'none') $theme = 'base'; 356 356 357 357 wp_enqueue_style( 'section-widget-admin', plugins_url('section-widget/js/section-widget-admin'. $suffix.'.css') ); 358 358 wp_enqueue_style( "section-widget-theme-{$theme}", plugins_url("section-widget/themes/theme-loader.php?theme={$theme}&scope=.olt-swt-designer")); 359 wp_enqueue_script('section-widget-admin', plugins_url('section-widget/js/section-widget-tabs'. $suffix.'.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable') );360 361 elseif( $pagenow == 'themes.php' && $_GET['page'] == 'section-widget' ):362 wp_enqueue_script('section-widget-admin', plugins_url('section-widget/js/section-widget-admin'. $suffix.'.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable') );363 359 wp_enqueue_script('section-widget-admin', plugins_url('section-widget/js/section-widget-tabs'. $suffix.'.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable'), '3.3.1'); 360 361 elseif( $pagenow == 'themes.php' && isset( $_GET['page'] ) && $_GET['page'] == 'section-widget' ): 362 wp_enqueue_script('section-widget-admin', plugins_url('section-widget/js/section-widget-admin'. $suffix.'.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable'), '3.3.1'); 363 364 364 endif; 365 365 else: 366 366 // Only load script and css if there is at least one active tabbed widget 367 if( is_active_widget( false, false, 'section-tabbed' ) ): 367 if( is_active_widget( false, false, 'section-tabbed' ) ): 368 368 if($theme != 'none'): 369 wp_enqueue_style("section-widget-theme-{$theme}", 369 wp_enqueue_style("section-widget-theme-{$theme}", 370 370 plugins_url("section-widget/themes/theme-loader.php?theme={$theme}&scope=").urlencode($scope)); 371 371 endif; 372 372 373 373 $current_tabs_theme_support = false; 374 374 if( is_array( get_theme_support('tabs') ) ) 375 375 $current_tabs_theme_support = reset( get_theme_support('tabs') ); 376 376 377 377 if ( $current_tabs_theme_support != 'twitter-bootstrap' ): 378 wp_enqueue_script('section-widget', 379 plugins_url('section-widget/js/section-widget'. $suffix.'.js'), array('jquery','jquery-ui-tabs') );380 378 wp_enqueue_script('section-widget', 379 plugins_url('section-widget/js/section-widget'. $suffix.'.js'), array('jquery','jquery-ui-tabs'), '3.3.1' ); 380 381 381 endif; // uses_twitter_bootstrap ? 382 382 383 383 endif; 384 384 endif; // is_admin 385 } 386 387 function enqueue_assets_for_widget_page() { 388 $current_screen = get_current_screen(); 389 390 if( $current_screen->id !== "widgets" ) { 391 return; 392 } 393 394 if ( version_compare( $GLOBALS['wp_version'], '5.8', '<' ) ) { 395 return; 396 } 397 398 if( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('classic-widgets/classic-widgets.php') ) { 399 return; 400 } 401 402 if( function_exists('is_plugin_active') && is_plugin_active('classic-widgets/classic-widgets.php') ) { 403 return; 404 } 405 406 wp_enqueue_script('section-widget-admin-gutenberg', plugins_url('section-widget/js/section-widget-tabs-gutenberg.js'), array('jquery','jquery-ui-tabs','jquery-ui-sortable'), '3.3.1'); 385 407 } 386 408 … … 389 411 add_action('init', 'tabbed_section_widget_load_scripts'); 390 412 add_action('wp_footer', 'print_script'); 413 add_action( 'current_screen', 'enqueue_assets_for_widget_page' ); 414 391 415 392 416 function print_script() { 393 417 echo '<script type="text/javascript">'; 394 418 #foreach ( OLT_Tabbed_Section_Widget::$widget_ids as $widget_id ) { ?> 395 jQuery(function () { jQuery('. nav-tabs a').click(function (e) { e.preventDefault();419 jQuery(function () { jQuery('.section-widget-tabbed .nav-tabs a, widget-inside .nav-tabs a').click(function (e) { e.preventDefault(); 396 420 jQuery(this).tab('show'); }) }); 397 421 398 <?php 422 <?php 399 423 echo '</script>'; 400 424 } -
section-widget/trunk/section-widget.php
r910774 r3286504 5 5 Plugin URI: http://blogs.ubc.ca/support/plugins/section-widget/ 6 6 Description: Display arbitrary text or HTML on certain sections of your site. 7 Author: Godfrey Chan (UBC CTLT), Enej, 8 Version: 3. 2.57 Author: Godfrey Chan (UBC CTLT), Enej, 8 Version: 3.3.1 9 9 Author URI: http://www.chancancode.com/ 10 10 */ 11 11 12 define( 'SECTION_WIDGET_DIR_PATH', plugin_dir_path( __FILE__ ) ); 13 12 14 include_once('olt-checklist/loader.php'); 13 15 enqueue_olt_checklist_loader(plugins_url('section-widget/olt-checklist')); … … 18 20 /** 19 21 * section_widget_text_init function. 20 * 22 * 21 23 * @access public 22 24 * @return void 23 25 */ 24 26 function section_widget_text_init() { 25 26 load_plugin_textdomain( 'section-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );27 28 load_plugin_textdomain( 'section-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 27 29 } 28 30 … … 32 34 /** 33 35 * OLT_Section_Widget class. 34 * 36 * 35 37 * @extends WP_Widget 36 38 */ 37 39 class OLT_Section_Widget extends WP_Widget { 38 /**39 * OLT_Section_Widget function.40 * 41 * @access public42 * @return void43 */44 function OLT_Section_Widget() {45 $widget_ops = array('classname' => 'section-widget', 'description' => __('Display section-specific content.','section-widget'));46 $control_ops = array('width' => 400);47 $this->WP_Widget('section', __('Section','section-widget'), $widget_ops, $control_ops);48 }49 /**50 * widget function.51 * 52 * @access public53 * @param mixed $args54 * @param mixed $instance55 * @return void56 */57 function widget( $args, $instance ) {58 extract($args);59 60 // $instance['conditions'] had to be renamed to $instance['section_conditions'] to resolve conflict with the Jetpack plugin61 // For backwards compatibility:62 if(!is_array($instance['section_conditions']) && is_array($instance['conditions'])) {63 $instance['section_conditions'] = $instance['conditions'];64 }65 // For backwards compatibility:66 if(!is_array($instance['section_conditions'])) {67 $instance['section_conditions'] = array(68 'special-pages' => $instance['special-pages'],69 'pages' => $instance['pages'],70 'categories' => $instance['categories'],71 'tags' => $instance['tags'] 72 );73 }74 75 // olt_checklist_conditions_check is the replacement for $should_display76 if(olt_checklist_conditions_check($instance['section_conditions'])) {77 echo $before_widget;78 79 if($instance['display-title']){80 echo $before_title;81 echo apply_filters('widget_title', $instance['title']);82 echo $after_title;83 }84 85 echo apply_filters('widget_text', do_shortcode($instance['body']));86 echo $after_widget;87 }88 }89 /**90 * update function.91 * 92 * @access public93 * @param mixed $new_instance94 * @param mixed $old_instance95 * @return void96 */97 function update( $new_instance, $old_instance ) {98 // Mostly borrowed from text widget99 $instance = $old_instance;100 101 // For backwards compatibility:102 if(!is_array($instance['section_conditions'])) {103 $instance['section_conditions'] = array(104 'special-pages' => $instance['special-pages'],105 'pages' => $instance['pages'],106 'categories' => $instance['categories'],107 'tags' => $instance['tags'] 108 );109 110 unset($instance['special-pages']);111 unset($instance['pages']);112 unset($instance['categories']);113 unset($instance['tags']);114 }115 116 $instance['title'] = strip_tags($new_instance['title']);117 $instance['display-title'] = (bool) $new_instance['display-title'];118 119 $instance['section_conditions']['special-pages'] =120 is_array($new_instance['section_conditions']['special-pages'])?121 $new_instance['section_conditions']['special-pages'] : array();122 123 $instance['section_conditions']['special-pages'] =124 is_array($new_instance['section_conditions']['special-pages'])?125 $new_instance['section_conditions']['special-pages'] : array();126 127 $instance['section_conditions']['pages'] =128 is_array($new_instance['section_conditions']['pages'])?129 $new_instance['section_conditions']['pages'] : array();130 131 $instance['section_conditions']['categories'] =132 is_array($new_instance['section_conditions']['categories'])?133 $new_instance['section_conditions']['categories'] : array();134 135 $instance['section_conditions']['tags'] =136 is_array($new_instance['section_conditions']['tags'])?137 $new_instance['section_conditions']['tags'] : array();138 139 $instance['body'] = current_user_can('unfiltered_html')?140 $new_instance['body'] : wp_filter_post_kses( $new_instance['body'] );141 142 return $instance;143 }144 /**145 * form function.146 * 147 * @access public148 * @param mixed $instance149 * @return void150 */151 function form( $instance ) {152 153 // For backwards compatibility:154 if(!is_array($instance['section_conditions']) && is_array($instance['conditions'])) {155 $instance['section_conditions'] = $instance['conditions'];156 }157 if(is_array($instance) && isset($instance['section_conditions']) && !is_array($instance['section_conditions'])) {158 $instance['section_conditions'] = array(159 'special-pages' => $instance['special-pages'],160 'pages' => $instance['pages'],161 'categories' => $instance['categories'],162 'tags' => $instance['tags'] 163 );164 }165 166 // Provide the defaults here167 $instance = wp_parse_args((array) $instance, array(168 'title' => '',169 'display-title' => true,170 'body' => '',171 'section_conditions' => array(172 'special-pages' => array(),173 'pages' => array(),174 'categories' => array(),175 'tags' => array()176 )177 ));178 179 // Make sure second level options are actually arrays180 foreach($instance['section_conditions'] as $i => $v)181 if(!is_array($v))182 $instance['section_conditions'][$i] = array();183 184 $title = strip_tags($instance['title']);185 $display_title = (bool) $instance['display-title'];186 $special_pages = $instance['section_conditions']['special-pages'];187 $pages = $instance['section_conditions']['pages'];188 $categories = $instance['section_conditions']['categories'];189 $tags = $instance['section_conditions']['tags'];190 $body = format_to_edit($instance['body']);40 /** 41 * OLT_Section_Widget function. 42 * 43 * @access public 44 * @return void 45 */ 46 function __construct() { 47 $widget_ops = array('classname' => 'section-widget', 'description' => __('Display section-specific content.','section-widget')); 48 $control_ops = array('width' => 400); 49 parent::__construct( 'section', __( 'Section','section-widget' ), $widget_ops, $control_ops ); 50 } 51 /** 52 * widget function. 53 * 54 * @access public 55 * @param mixed $args 56 * @param mixed $instance 57 * @return void 58 */ 59 function widget( $args, $instance ) { 60 extract($args); 61 62 // $instance['conditions'] had to be renamed to $instance['section_conditions'] to resolve conflict with the Jetpack plugin 63 // For backwards compatibility: 64 if(!is_array($instance['section_conditions']) && is_array($instance['conditions'])) { 65 $instance['section_conditions'] = $instance['conditions']; 66 } 67 // For backwards compatibility: 68 if(!is_array($instance['section_conditions'])) { 69 $instance['section_conditions'] = array( 70 'special-pages' => $instance['special-pages'], 71 'pages' => $instance['pages'], 72 'categories' => $instance['categories'], 73 'tags' => $instance['tags'] 74 ); 75 } 76 77 // olt_checklist_conditions_check is the replacement for $should_display 78 if(olt_checklist_conditions_check($instance['section_conditions'])) { 79 echo wp_kses_post($before_widget); 80 81 if($instance['display-title']){ 82 echo wp_kses_post($before_title); 83 echo esc_html( apply_filters('widget_title', $instance['title']) ); 84 echo wp_kses_post($after_title); 85 } 86 87 echo apply_filters('widget_text', do_shortcode($instance['body'])); 88 echo wp_kses_post($after_widget); 89 } 90 } 91 /** 92 * update function. 93 * 94 * @access public 95 * @param mixed $new_instance 96 * @param mixed $old_instance 97 * @return void 98 */ 99 function update( $new_instance, $old_instance ) { 100 // Mostly borrowed from text widget 101 $instance = $old_instance; 102 103 // For backwards compatibility: 104 if(!is_array($instance['section_conditions'])) { 105 $instance['section_conditions'] = array( 106 'special-pages' => $instance['special-pages'], 107 'pages' => $instance['pages'], 108 'categories' => $instance['categories'], 109 'tags' => $instance['tags'] 110 ); 111 112 unset($instance['special-pages']); 113 unset($instance['pages']); 114 unset($instance['categories']); 115 unset($instance['tags']); 116 } 117 118 $instance['title'] = strip_tags($new_instance['title']); 119 $instance['display-title'] = (bool) $new_instance['display-title']; 120 121 $instance['section_conditions']['special-pages'] = 122 is_array($new_instance['section_conditions']['special-pages'])? 123 $new_instance['section_conditions']['special-pages'] : array(); 124 125 $instance['section_conditions']['special-pages'] = 126 is_array($new_instance['section_conditions']['special-pages'])? 127 $new_instance['section_conditions']['special-pages'] : array(); 128 129 $instance['section_conditions']['pages'] = 130 is_array($new_instance['section_conditions']['pages'])? 131 $new_instance['section_conditions']['pages'] : array(); 132 133 $instance['section_conditions']['categories'] = 134 is_array($new_instance['section_conditions']['categories'])? 135 $new_instance['section_conditions']['categories'] : array(); 136 137 $instance['section_conditions']['tags'] = 138 is_array($new_instance['section_conditions']['tags'])? 139 $new_instance['section_conditions']['tags'] : array(); 140 141 $instance['body'] = current_user_can('unfiltered_html')? 142 $new_instance['body'] : wp_filter_post_kses( $new_instance['body'] ); 143 144 return $instance; 145 } 146 /** 147 * form function. 148 * 149 * @access public 150 * @param mixed $instance 151 * @return void 152 */ 153 function form( $instance ) { 154 155 // For backwards compatibility: 156 if( isset( $instance['section_conditions'] ) && ! is_array( $instance['section_conditions'] ) && isset( $instance['conditions'] ) && is_array( $instance['conditions'] ) ) { 157 $instance['section_conditions'] = $instance['conditions']; 158 } 159 if(is_array($instance) && isset($instance['section_conditions']) && !is_array($instance['section_conditions'])) { 160 $instance['section_conditions'] = array( 161 'special-pages' => $instance['special-pages'], 162 'pages' => $instance['pages'], 163 'categories' => $instance['categories'], 164 'tags' => $instance['tags'] 165 ); 166 } 167 168 // Provide the defaults here 169 $instance = wp_parse_args((array) $instance, array( 170 'title' => '', 171 'display-title' => true, 172 'body' => '', 173 'section_conditions' => array( 174 'special-pages' => array(), 175 'pages' => array(), 176 'categories' => array(), 177 'tags' => array() 178 ) 179 )); 180 181 // Make sure second level options are actually arrays 182 foreach($instance['section_conditions'] as $i => $v) 183 if(!is_array($v)) 184 $instance['section_conditions'][$i] = array(); 185 186 $title = strip_tags($instance['title']); 187 $display_title = (bool) $instance['display-title']; 188 $special_pages = $instance['section_conditions']['special-pages']; 189 $pages = $instance['section_conditions']['pages']; 190 $categories = $instance['section_conditions']['categories']; 191 $tags = $instance['section_conditions']['tags']; 192 $body = format_to_edit($instance['body']); 191 193 ?> 192 <p>193 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php_e('Title:','section-widget'); ?></label>194 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr($title); ?>" />195 <input id="<?php echo $this->get_field_id('display-title'); ?>" name="<?php echo $this->get_field_name('display-title'); ?>" type="checkbox" <?php checked($display_title); ?> />196 <label for="<?php echo esc_attr($this->get_field_id('display-title')); ?>"><?php_e('Display title','section-widget'); ?></label>197 </p>198 <?php 199 olt_checklist_pane(array(200 'id' => $this->get_field_id('section_conditions'),201 'name' => $this->get_field_name('section_conditions'),202 'special-pages' => array('selected' => $special_pages),203 'pages' => array('selected' => $pages),204 'categories' => array('selected' => $categories),205 'tags' => array('selected' => $tags)206 ));194 <p> 195 <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:','section-widget'); ?></label> 196 <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title') ); ?>" type="text" value="<?php echo esc_attr($title); ?>" /> 197 <input id="<?php echo esc_attr($this->get_field_id('display-title')); ?>" name="<?php echo esc_attr($this->get_field_name('display-title')); ?>" type="checkbox" <?php checked($display_title); ?> /> 198 <label for="<?php echo esc_attr($this->get_field_id('display-title')); ?>"><?php esc_html_e('Display title','section-widget'); ?></label> 199 </p> 200 <?php 201 olt_checklist_pane(array( 202 'id' => $this->get_field_id('section_conditions'), 203 'name' => $this->get_field_name('section_conditions'), 204 'special-pages' => array('selected' => $special_pages), 205 'pages' => array('selected' => $pages), 206 'categories' => array('selected' => $categories), 207 'tags' => array('selected' => $tags) 208 )); 207 209 ?> 208 <div class="olt-sw-body">209 <p class="olt-sw-body-help">210 <?php_e('<strong>Formatting Help:</strong> You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.','section-widget'); ?>211 </p>212 <textarea rows="16" cols="20" id="<?php echo esc_attr($this->get_field_id('body')); ?>" name="<?php echo esc_attr($this->get_field_name('body')); ?>"><?php echo $body; ?></textarea>213 </div>214 <script type="text/javascript">215 if(typeof OLTChecklistPaneInit == 'function')216 OLTChecklistPaneInit(jQuery('#<?php echo $this->get_field_id('section_conditions-wrapper'); ?>'));217 </script>210 <div class="olt-sw-body"> 211 <p class="olt-sw-body-help"> 212 <?php esc_html_e('<strong>Formatting Help:</strong> You may use HTML in this widget, and it is probably a good idea to wrap the content in your own <code><div></code> to aid styling. Shortcodes are also allowed, but please beware not all of them will function properly on archive pages.','section-widget'); ?> 213 </p> 214 <textarea rows="16" cols="20" id="<?php echo esc_attr($this->get_field_id('body')); ?>" name="<?php echo esc_attr($this->get_field_name('body')); ?>"><?php echo wp_kses_post($body); ?></textarea> 215 </div> 216 <script type="text/javascript"> 217 if(typeof OLTChecklistPaneInit == 'function') 218 OLTChecklistPaneInit(jQuery('#<?php echo esc_attr($this->get_field_id('section_conditions-wrapper')); ?>')); 219 </script> 218 220 <?php 219 }221 } 220 222 } 221 223 /** 222 224 * section_widget_init function. 223 * 225 * 224 226 * @access public 225 227 * @return void 226 228 */ 227 229 function section_widget_init() { 228 register_widget('OLT_Section_Widget'); 229 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 230 if(is_admin()){ 231 global $pagenow; 232 if( $pagenow == 'widgets.php' ): 233 wp_enqueue_style('section-widget-admin', plugins_url('section-widget/css/section-widget-admin'.$suffix.'.css')); 234 endif; 235 } 230 $olt_section_widget = new OLT_Section_Widget(); 231 register_widget( $olt_section_widget ); 232 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 233 if(is_admin()){ 234 global $pagenow; 235 if( $pagenow == 'widgets.php' ): 236 wp_enqueue_style('section-widget-admin', plugins_url('section-widget/css/section-widget-admin'.$suffix.'.css')); 237 endif; 238 } 236 239 } 237 240 -
section-widget/trunk/themes/theme-loader.php
r140858 r3286504 4 4 $scope = isset($_GET['scope'])? trim($_GET['scope']) : ''; 5 5 6 $content = @file_get_contents( "./{$theme}/sw-theme.css");6 $content = @file_get_contents(SECTION_WIDGET_DIR_PATH . "themes/{$theme}/sw-theme.css"); 7 7 8 8 if(!$content) { 9 9 // Try again with the default theme 10 $content = @file_get_contents( "./base/sw-theme.css");10 $content = @file_get_contents(SECTION_WIDGET_DIR_PATH . "/themes/base/sw-theme.css"); 11 11 } 12 12 … … 15 15 $content = str_replace('url(images', "url({$theme}/images", $content); 16 16 header('Content-Type: text/css'); 17 echo $content;17 echo wp_kses_post($content); 18 18 } 19 19
Note: See TracChangeset
for help on using the changeset viewer.