Changeset 3463814
- Timestamp:
- 02/17/2026 08:29:36 PM (6 weeks ago)
- Location:
- conditional-menus
- Files:
-
- 16 added
- 5 edited
-
tags/1.2.7 (added)
-
tags/1.2.7/assets (added)
-
tags/1.2.7/assets/admin.css (added)
-
tags/1.2.7/assets/admin.css.gz (added)
-
tags/1.2.7/assets/admin.js (added)
-
tags/1.2.7/assets/admin.js.gz (added)
-
tags/1.2.7/docs (added)
-
tags/1.2.7/docs/images (added)
-
tags/1.2.7/docs/images/conditional-menus.png (added)
-
tags/1.2.7/docs/index.html (added)
-
tags/1.2.7/init.php (added)
-
tags/1.2.7/languages (added)
-
tags/1.2.7/languages/readme.txt (added)
-
tags/1.2.7/readme.txt (added)
-
tags/1.2.7/templates (added)
-
tags/1.2.7/templates/conditions.php (added)
-
trunk/assets/admin.js (modified) (1 diff)
-
trunk/assets/admin.js.gz (modified) (previous)
-
trunk/init.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/templates/conditions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
conditional-menus/trunk/assets/admin.js
r3100859 r3463814 1 !function($,t,i){"use strict";var e,n,c,o=[],a="";function s(i=t.body){let e=i.getElementsByClassName("themify_cm_loader")[0];e||(e=t.createElement("div"),e.className="themify_cm_loader",i.prepend(e)),e.classList.add("busy")}function m(i=t.body){const e=i.getElementsByClassName("themify_cm_loader")[0];e&&e.classList.remove("busy")}function l(t){t||(t=n);const i=t.querySelectorAll('input[type="checkbox"]');for(let t=0;t<i.length;t++)i[t].checked=a.includes(i[t].name+"=on")}function r(){var i=t;return Math.max(Math.max(i.body.scrollHeight,i.documentElement.scrollHeight),Math.max(i.body.offsetHeight,i.documentElement.offsetHeight),Math.max(i.body.clientHeight,i.documentElement.clientHeight))}function y(t,e,n,c){var a=t.clone().removeClass("cm-location");a.find(".menu-location-title").empty();var s=a.find("select").attr("name").match(/menu-locations\[(.*)\]/)[1];null==e&&(void 0===o[s]&&(o[s]=parseInt($(function(t){var i=[];for(var e in t)t.hasOwnProperty(e)&&i.push(e);return i}(i.options[s])).last()[0]),$.isNumeric(o[s])||(o[s]=1)),e=o[s]++),a.find("select").find('option[value="0"]').text(i.lang.disable_menu).before('<option value=""></option>').end().val(n).attr("name","themify_cm["+s+"]["+e+"][menu]"),(a=function(t,e,n,c){return c=c||"",t.find(".locations-row-links").empty().html('<input type="hidden" data-id="'+n+'" name="'+e+"\" value='"+c+'\' /><a href="#" class="themify-cm-conditions">'+i.lang.conditions+'</a> <a class="themify-cm-remove" href="#">x</a>'),t}(a,"themify_cm["+s+"]["+e+"][condition]",e,c)).insertBefore(jQuery('.menu-locations tr[data-menu="'+s+'"]'));var m=$(".menu-location-menus select").length,l=$(".cm-replacement-button").length+1;a.find(".menu-location-menus").attr("data-item",s+e),m===l&&$(".themify-cm-conditions-container:first").addClass("themify-cm-conditions-container-"+s+e).data("item",s+e),m>l&&$(".themify-cm-conditions-container:first").clone().removeClass().addClass("themify-cm-conditions-container themify-admin-lightbox tf_clearfix themify-cm-conditions-container-"+s+e).data("item",s+e).insertAfter(".themify-cm-conditions-container:last")}$(".menu-locations .locations-row-links").empty(),$("body").on("click",".themify-cm-conditions",(function(o){o.preventDefault(),a=decodeURI((e=this.previousElementSibling).value);var y=$(t).scrollTop()+80;return n||(s(),$.ajax({type:"POST",url:ajaxurl,async:!1,data:{action:"themify_cm_get_conditions",nonce:i.nonce},success(i){m();const e=t.createElement("template");e.innerHTML=i,t.body.appendChild(e.content)}}),n=t.getElementById("themify-cm-conditions"),c=t.getElementById("themify-cm-overlay")),l(),c.style.display="block",$(n).show().css("top",r()).animate({top:y},800),$("#visibility-tabs",n).tabs(),$("#visibility-tabs .themify-visibility-inner-tabs",n).tabs(),!1})).on("click","#visibility-tabs .themify_cm_load_ajax, #visibility-tabs .inline-tabs a",(function(t){let e=this.dataset.type,c=n.querySelector(this.getAttribute("href"));e?c.getElementsByClassName("themify-visibility-items-page-1")[0]||$.ajax({url:ajaxurl,type:"post",data:{action:"themify_cm_create_inner_page",nonce:i.nonce,type:e},beforeSend(){s()},success(t){m(),c.firstElementChild.innerHTML=t,l(c)}}):c.querySelector(".inline-tabs .ui-tabs-active a").click()})).on("click",".themify-visibility-pagination a.page-numbers",(function(e){e.preventDefault();const c=parseInt(this.getAttribute("href")),o=this.closest(".themify-visibility-items-inner"),a=o.getElementsByClassName("themify-visibility-items-page");o.getElementsByClassName("themify-visibility-items-page-"+c)[0]||$.ajax({url:ajaxurl,async:!1,type:"post",data:{action:"themify_cm_create_inner_page",type:(this.closest(".themify-visibility-inner-tab")?this.closest(".themify-visibility-inner-tabs"):n).querySelector(".ui-tabs-active a").dataset.type,paged:c,nonce:i.nonce},beforeSend(){s()},success(i){m();const e=t.createElement("template");e.innerHTML=i,l(e.content),o.appendChild(e.content)}});for(let t=0;t<a.length;t++)a[t].style.display=a[t].classList.contains("themify-visibility-items-page-"+c)?"block":"none"})).on("change",'.themify-cm-conditions-container input[type="checkbox"]',(function(){this.checked?a+="&"+this.name+"=on":a=a.replace(this.name+"=on","")})).on("click",".themify-cm-close, #themify-cm-overlay",(t=>(t.preventDefault(),$(n).animate({top:r()},800,(()=>{c.style.display="none",n.style.display="none",a="",l()})),!1))).on("click",".themify-mc-add-assignment",(function(){return y($("#locations-"+$(this).closest("tr").attr("data-menu")).closest("tr")),!1})).on("click",".themify-cm-save",(()=>(e.value=a,$(".menu-location-menus[data-item="+e.dataset.id+"]").val(a),c.click(),!1))).on("click",".themify-cm-remove",(function(){return $(this).closest("tr").fadeOut((function(){$(this).remove()})),!1})).on("click",".themify-cm-conditions-container .uncheck-all",(t=>{t.preventDefault(),a="",l()})).on("click",".themify-cm-conditions-container .themify_apply_all_conditions",(()=>{})),window.addEventListener("load",(()=>{$.each(i.nav_menus,((t,e)=>{$("#locations-"+e).closest("tr").after('<tr class="cm-replacement-button" data-menu="'+e+'"><td> </td><td><a href="#" class="themify-mc-add-assignment">'+i.lang.add_assignment+"</a></td></tr>")})),$.each(i.options,((t,i)=>{"object"==typeof i&&$.each(i,((i,e)=>{y($("#locations-"+t).closest("tr"),i,e.menu,e.condition),o[t]=++i}))}))}))}(jQuery,document,themify_cm);1 !function($,t,i){"use strict";var n,e,c,o=[],a="";function m(i=t.body){let n=i.getElementsByClassName("themify_cm_loader")[0];n||(n=t.createElement("div"),n.className="themify_cm_loader",i.prepend(n)),n.classList.add("busy")}function s(i=t.body){const n=i.getElementsByClassName("themify_cm_loader")[0];n&&n.classList.remove("busy")}function l(t){t||(t=e);const i=t.querySelectorAll('input[type="checkbox"]');for(let t=0;t<i.length;t++)i[t].checked=a.includes(i[t].name+"=on")}function r(){var i=t;return Math.max(Math.max(i.body.scrollHeight,i.documentElement.scrollHeight),Math.max(i.body.offsetHeight,i.documentElement.offsetHeight),Math.max(i.body.clientHeight,i.documentElement.clientHeight))}function y(t,n,e,c){var a=t.clone().removeClass("cm-location");a.find(".menu-location-title").empty();var m=a.find("select").attr("name").match(/menu-locations\[(.*)\]/)[1];null==n&&(void 0===o[m]&&(o[m]=parseInt($(function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);return i}(i.options[m])).last()[0]),$.isNumeric(o[m])||(o[m]=1)),n=o[m]++),a.find("select").find('option[value="0"]').text(i.lang.disable_menu).before('<option value=""></option>').end().val(e).attr("name","themify_cm["+m+"]["+n+"][menu]"),(a=function(t,n,e,c){return c=c||"",t.find(".locations-row-links").empty().html('<input type="hidden" data-id="'+e+'" name="'+n+"\" value='"+c+'\' /><a href="#" class="themify-cm-conditions">'+i.lang.conditions+'</a> <a class="themify-cm-remove" href="#">x</a>'),t}(a,"themify_cm["+m+"]["+n+"][condition]",n,c)).insertBefore(jQuery('.menu-locations tr[data-menu="'+m+'"]'));var s=$(".menu-location-menus select").length,l=$(".cm-replacement-button").length+1;a.find(".menu-location-menus").attr("data-item",m+n),s===l&&$(".themify-cm-conditions-container:first").addClass("themify-cm-conditions-container-"+m+n).data("item",m+n),s>l&&$(".themify-cm-conditions-container:first").clone().removeClass().addClass("themify-cm-conditions-container themify-admin-lightbox tf_clearfix themify-cm-conditions-container-"+m+n).data("item",m+n).insertAfter(".themify-cm-conditions-container:last")}$(".menu-locations .locations-row-links").empty(),$("body").on("click",".themify-cm-conditions",(function(o){o.preventDefault(),a=decodeURI((n=this.previousElementSibling).value);var y=$(t).scrollTop()+80;return e||(m(),$.ajax({type:"POST",url:ajaxurl,async:!1,data:{action:"themify_cm_get_conditions",nonce:i.nonce},success(i){s();const n=t.createElement("template");n.innerHTML=i,t.body.appendChild(n.content)}}),e=t.getElementById("themify-cm-conditions"),c=t.getElementById("themify-cm-overlay")),l(),c.style.display="block",$(e).show().css("top",r()).animate({top:y},800),$("#visibility-tabs",e).tabs(),$("#visibility-tabs .themify-visibility-inner-tabs",e).tabs(),!1})).on("click","#visibility-tabs .themify_cm_load_ajax, #visibility-tabs .inline-tabs a",(function(t){let n=this.dataset.type,c=e.querySelector(this.getAttribute("href"));n?c.getElementsByClassName("themify-visibility-items-page-1")[0]||$.ajax({url:ajaxurl,type:"post",data:{action:"themify_cm_create_inner_page",nonce:i.nonce,type:n},beforeSend(){m()},success(t){s(),c.firstElementChild.innerHTML=t,l(c)}}):c.querySelector(".inline-tabs .ui-tabs-active a").click()})).on("click",".themify-visibility-pagination a.page-numbers",(function(n){n.preventDefault();const c=parseInt(this.getAttribute("href")),o=this.closest(".themify-visibility-items-inner"),a=o.getElementsByClassName("themify-visibility-items-page");o.getElementsByClassName("themify-visibility-items-page-"+c)[0]||$.ajax({url:ajaxurl,async:!1,type:"post",data:{action:"themify_cm_create_inner_page",type:(this.closest(".themify-visibility-inner-tab")?this.closest(".themify-visibility-inner-tabs"):e).querySelector(".ui-tabs-active a").dataset.type,paged:c,nonce:i.nonce},beforeSend(){m()},success(i){s();const n=t.createElement("template");n.innerHTML=i,l(n.content),o.appendChild(n.content)}});for(let t=0;t<a.length;t++)a[t].style.display=a[t].classList.contains("themify-visibility-items-page-"+c)?"block":"none"})).on("change",'.themify-cm-conditions-container input[type="checkbox"]',(function(){this.checked?a+="&"+this.name+"=on":a=a.replace(this.name+"=on","")})).on("click",".themify-cm-close, #themify-cm-overlay",(t=>(t.preventDefault(),$(e).animate({top:r()},800,(()=>{c.style.display="none",e.style.display="none",a="",l()})),!1))).on("click",".themify-mc-add-assignment",(function(){return y($("#locations-"+$(this).closest("tr").attr("data-menu")).closest("tr")),!1})).on("click",".themify-cm-save",(()=>(n.value=a,$(".menu-location-menus[data-item="+n.dataset.id+"]").val(a),c.click(),!1))).on("click",".themify-cm-remove",(function(){return $(this).closest("tr").fadeOut((function(){$(this).remove()})),!1})).on("click",".themify-cm-conditions-container .uncheck-all",(t=>{t.preventDefault(),a="",l()})).on("click",".themify-cm-conditions-container .themify_apply_all_conditions",(()=>{})),window.addEventListener("load",(()=>{$.each(i.nav_menus,((t,n)=>{$("#locations-"+n).closest("tr").after('<tr class="cm-replacement-button" data-menu="'+n+'"><td> </td><td><a href="#" class="themify-mc-add-assignment">'+i.lang.add_assignment+"</a></td></tr>")})),$.each(i.options,((t,i)=>{"object"==typeof i&&$.each(i,((i,n)=>{y($("#locations-"+t).closest("tr"),i,n.menu,n.condition),o[t]=++i}))})),$("#themify_cm_nonce").appendTo($(".menu-locations").closest("form"))}))}(jQuery,document,themify_cm); -
conditional-menus/trunk/init.php
r3246086 r3463814 3 3 Plugin Name: Conditional Menus 4 4 Plugin URI: https://themify.me/conditional-menus 5 Version: 1.2. 65 Version: 1.2.7 6 6 Author: Themify 7 7 Author URI: https://themify.me/ … … 182 182 183 183 public function init() { 184 if( isset( $_GET['action'] ) && 'locations' === $_GET['action']) {184 if( ( isset( $_GET['action'] ) && 'locations' === $_GET['action'] ) || isset( $_POST['menu-locations'] ) ) { 185 185 $this->save_options(); 186 186 add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue' ) ); 187 add_action( 'admin_footer', array( $this, 'output_nonce' ) ); 187 188 } 188 189 } … … 190 191 public function save_options() { 191 192 if( isset( $_POST['menu-locations'] ) ) { 193 if ( ! isset( $_POST['themify_cm_nonce'] ) || ! wp_verify_nonce( $_POST['themify_cm_nonce'], 'themify_cm_nonce' ) ) { 194 return; 195 } 192 196 $themify_cm = isset( $_POST['themify_cm'] ) ? $_POST['themify_cm'] : array(); 193 197 set_theme_mod( 'themify_conditional_menus', $themify_cm ); … … 201 205 } 202 206 207 public function output_nonce() { 208 wp_nonce_field( 'themify_cm_nonce', 'themify_cm_nonce' ); 209 } 210 203 211 public function admin_enqueue() { 204 212 global $_wp_registered_nav_menus; 205 $version='1.2. 3';213 $version='1.2.7'; 206 214 self::themify_enque_style( 'themify-conditional-menus', THEMIFY_CM_URI . 'assets/admin.css', null, $version ); 207 215 wp_enqueue_script( 'themify-conditional-menus', self::themify_enque(THEMIFY_CM_URI . 'assets/admin.js'), array( 'jquery', 'jquery-ui-tabs' ), $version, true ); -
conditional-menus/trunk/readme.txt
r3246086 r3463814 2 2 Contributors: themifyme 3 3 Tags: menu, conditional-tags, context, menu-items, admin 4 Requires at least: 5.05 Tested up to: 6. 7.26 Stable tag: 1.2. 64 Requires at least: 4.0 5 Tested up to: 6.9.1 6 Stable tag: 1.2.7 7 7 License: GPL v2 8 8 License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -
conditional-menus/trunk/templates/conditions.php
r3020806 r3463814 11 11 <div id="themify-cm-conditions" class="themify-cm-conditions-container themify-admin-lightbox tf_clearfix" style="display: none;"> 12 12 <h3 class="themify-cm-title"><?php _e( 'Condition', 'themify-cm' ) ?></h3> 13 <a href="#" class="themify-cm-close"> x</a>13 <a href="#" class="themify-cm-close"><span class="screen-reader-text">Close</span></a> 14 14 <div class="lightbox_container"> 15 15 <form id="visibility-tabs" class="ui-tabs">
Note: See TracChangeset
for help on using the changeset viewer.