Changeset 3252030
- Timestamp:
- 03/07/2025 08:40:16 AM (13 months ago)
- Location:
- sidebar-navigation-for-wpbakery/trunk
- Files:
-
- 6 edited
-
assets/css/sidebar-for-wpb.css (modified) (3 diffs)
-
assets/css/sidebar-for-wpb.min.css (modified) (1 diff)
-
assets/js/sidebar-for-wpb.js (modified) (1 diff)
-
assets/js/sidebar-for-wpb.min.js (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
sidebar-navigation-for-wpbakery.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sidebar-navigation-for-wpbakery/trunk/assets/css/sidebar-for-wpb.css
r3238119 r3252030 1 1 @media screen and (min-width: 961px) { 2 2 3 :root { 3 4 --vc-navbar-width: 50px; 5 --vc-min-panel-width: 440px; 4 6 } 5 7 … … 84 86 top: 0 !important; 85 87 width: auto !important; 88 height: 100vh !important; 86 89 } 87 90 88 91 #vc_inline-frame { 89 height: 100 vh!important;92 height: 100% !important; 90 93 } 91 94 92 .vc_ui-panel -window {95 .vc_ui-panel.vc_ui-panel-window { 93 96 top: 0 !important; 94 97 bottom: 0 !important; 95 98 left: var(--vc-navbar-width) !important; 96 width: 440px!important;99 width: var(--vc-min-panel-width) !important; 97 100 max-height: 100% !important; 98 101 margin: 0 !important; … … 130 133 background-color: #00447F; 131 134 } 135 136 .ui-resizable-handle { 137 display: none !important; 138 } 139 140 .vc_hide-description .vc_element-description { 141 display: none !important; 142 } 143 144 .vc_compact-view .wpb-content-layouts-container h4 { 145 margin: 0 0 10px !important; 146 } 147 148 .vc_compact-view .wpb-content-layouts { 149 margin: 0 !important; 150 grid-template-columns: repeat(auto-fit, 96px) !important; 151 } 152 153 .vc_compact-view .vc_element-description { 154 font-size: 12px !important; 155 } 156 157 .vc_compact-view .vc_shortcode-link { 158 font-size: 13px; 159 } 160 161 .vc_compact-view .vc_element-icon { 162 margin-bottom: 10px; 163 } 132 164 } 133 165 -
sidebar-navigation-for-wpbakery/trunk/assets/css/sidebar-for-wpb.min.css
r3238119 r3252030 1 @media screen and (min-width:961px){:root{--vc-navbar-width:50px }#wpbody,#wpcontent{padding:0;height:0}#vc_navbar{position:fixed;top:0;left:0;right:initial;bottom:0;width:var(--vc-navbar-width);box-shadow:1px 1px 4px rgba(0,0,0,.25);z-index:99999}#vc_navbar .vc_navbar-header,#vc_navbar li{float:none!important;height:auto}#vc_navbar .vc_navbar-brand{padding:25px}#vc_navbar .vc_save-buttons{flex-direction:column;gap:4px;margin:0 2px}#vc_navbar .vc_save-buttons .vc_btn{margin:2px;width:70%}#vc_navbar .vc_save-buttons .vc_btn p{font-size:10px}#vc_navbar a.vc_icon-btn{width:var(--vc-navbar-width);height:45px;padding:24px;font-size:20px}#vc_navbar .vc_navbar-nav{display:flex;flex-direction:column;align-items:center;position:absolute;top:56px;left:0;bottom:0;width:100%}#vc_navbar .vc_navbar-nav>li:not(.vc_save-buttons){height:48px}#vc_navbar .vc_dropdown-list{left:100%;right:initial;top:-75px;z-index:999999}#vc_navbar #vc_screen-size-control .vc_dropdown-list{top:-145px}#vc_inline-frame-wrapper{left:var(--vc-navbar-width);right:0;top:0!important;width:auto!important}#vc_inline-frame{height:100vh!important}.vc_ui-panel-window{top:0!important;bottom:0!important;left:var(--vc-navbar-width)!important;width:440px!important;max-height:100%!important;margin:0!important;padding:0!important;height:100%!important}.vc_ui-minimize-button{display:none!important}.vc_ui-panel-header-actions,.vc_ui-search-box{width:100%}.vc_message{top:0!important;z-index:99999!important}.vc_add-element-container .wpb-content-layouts{gap:1px}.vc_ui-panel-content{margin-top:0!important}.vc_ui-panel-content.vc_properties-list-init{margin:auto!important}#vc_navbar .vc_icon-btn.vc_active{background-color:#00447f}}1 @media screen and (min-width:961px){:root{--vc-navbar-width:50px;--vc-min-panel-width:440px}#wpbody,#wpcontent{padding:0;height:0}#vc_navbar{position:fixed;top:0;left:0;right:initial;bottom:0;width:var(--vc-navbar-width);box-shadow:1px 1px 4px rgba(0,0,0,.25);z-index:99999}#vc_navbar .vc_navbar-header,#vc_navbar li{float:none!important;height:auto}#vc_navbar .vc_navbar-brand{padding:25px}#vc_navbar .vc_save-buttons{flex-direction:column;gap:4px;margin:0 2px}#vc_navbar .vc_save-buttons .vc_btn{margin:2px;width:70%}#vc_navbar .vc_save-buttons .vc_btn p{font-size:10px}#vc_navbar a.vc_icon-btn{width:var(--vc-navbar-width);height:45px;padding:24px;font-size:20px}#vc_navbar .vc_navbar-nav{display:flex;flex-direction:column;align-items:center;position:absolute;top:56px;left:0;bottom:0;width:100%}#vc_navbar .vc_navbar-nav>li:not(.vc_save-buttons){height:48px}#vc_navbar .vc_dropdown-list{left:100%;right:initial;top:-75px;z-index:999999}#vc_navbar #vc_screen-size-control .vc_dropdown-list{top:-145px}#vc_inline-frame-wrapper{left:var(--vc-navbar-width);right:0;top:0!important;width:auto!important;height:100vh!important}#vc_inline-frame{height:100%!important}.vc_ui-panel.vc_ui-panel-window{top:0!important;bottom:0!important;left:var(--vc-navbar-width)!important;width:var(--vc-min-panel-width)!important;max-height:100%!important;margin:0!important;padding:0!important;height:100%!important}.vc_ui-minimize-button{display:none!important}.vc_ui-panel-header-actions,.vc_ui-search-box{width:100%}.vc_message{top:0!important;z-index:99999!important}.vc_add-element-container .wpb-content-layouts{gap:1px}.vc_ui-panel-content{margin-top:0!important}.vc_ui-panel-content.vc_properties-list-init{margin:auto!important}#vc_navbar .vc_icon-btn.vc_active{background-color:#00447f}.ui-resizable-handle{display:none!important}.vc_hide-description .vc_element-description{display:none!important}.vc_compact-view .wpb-content-layouts-container h4{margin:0 0 10px!important}.vc_compact-view .wpb-content-layouts{margin:0!important;grid-template-columns:repeat(auto-fit,96px)!important}.vc_compact-view .vc_element-description{font-size:12px!important}.vc_compact-view .vc_shortcode-link{font-size:13px}.vc_compact-view .vc_element-icon{margin-bottom:10px}} -
sidebar-navigation-for-wpbakery/trunk/assets/js/sidebar-for-wpb.js
r3238119 r3252030 1 1 (function ($) { 2 $(document).ready(function () { 3 var $window = $(window); 4 $window.on('vc_build', function () { 5 var pluginUrl = window.sidebar_for_wpb_js.plugin_url; 6 var $navbar = $('#vc_navbar'); 7 var $frameWrapper = $('#vc_inline-frame-wrapper'); 8 var $navbarItems = $navbar.find('.vc_navbar-nav li'); 9 var $panelWindow = $('.vc_ui-panel-window'); 10 var $navbarBtns = $navbar.find('.vc_icon-btn'); 11 var panelsSettings = [ 12 { 13 panelId: 'panel-add-element', 14 navbarBtnId: 'vc_add-new-element' 15 }, 16 { 17 panelId: 'panel-templates', 18 navbarBtnId: 'vc_templates-editor-button' 19 }, 20 { 21 panelId: 'panel-post-seo', 22 navbarBtnId: 'vc_seo-button' 23 }, 24 { 25 panelId: 'panel-post-settings', 26 navbarBtnId: 'vc_post-settings-button' 27 } 28 ] 2 $(document).ready(() => { 3 const $window = $(window) 4 $window.on('vc_build', () => { 5 const pluginUrl = window.sidebar_for_wpb_js.pluginUrl 6 const disableDescription = window.sidebar_for_wpb_js.disableDescription 7 const compactView = window.sidebar_for_wpb_js.compactView 8 const responsiveView = window.sidebar_for_wpb_js.responsiveView 9 const $screenSizeControls = $('#vc_screen-size-control .vc_screen-width') 10 const $addElementPanel = $('#vc_ui-panel-add-element') 11 const $navbar = $('#vc_navbar') 12 const $frameWrapper = $('#vc_inline-frame-wrapper') 13 const $iframe = $('#vc_inline-frame') 14 const $navbarItems = $navbar.find('.vc_navbar-nav li') 15 const $panelWindow = $('.vc_ui-panel-window') 16 const $navbarBtns = $navbar.find('.vc_icon-btn') 17 const panelsSettings = [ 18 { 19 panelId: 'panel-add-element', 20 navbarBtnId: 'vc_add-new-element' 21 }, 22 { 23 panelId: 'panel-templates', 24 navbarBtnId: 'vc_templates-editor-button' 25 }, 26 { 27 panelId: 'panel-post-seo', 28 navbarBtnId: 'vc_seo-button' 29 }, 30 { 31 panelId: 'panel-post-settings', 32 navbarBtnId: 'vc_post-settings-button' 33 } 34 ] 29 35 30 $.each($navbarItems, function (index, item) { 31 var $item = $(item); 32 var $child = $item.children(); 33 if ($child.hasClass('vc_back-button')) { 34 $item.css('order', '10'); 35 } else if ($child.hasClass('vc_dropdown-more')) { 36 $item.css({ 37 'order': '9' 38 }); 39 } else if ($child.hasClass('vc_btn-save')) { 40 $item.css({ 41 'order': '8' 42 }); 43 } else if ($child.attr('id') === 'vc_screen-size-control') { 44 $item.css('order', '7'); 45 } else if ($child.hasClass('vc_post-settings')) { 46 $item.css('order', '6'); 47 } else if ($child.hasClass('vc_seo-button')) { 48 $item.css({ 49 'order':'5', 50 'margin-top': 'auto' 51 }); 52 } 53 }); 36 $.each($navbarItems, setNavbarItems) 54 37 55 $('body').append('<link rel="stylesheet" href="' + pluginUrl + '/assets/css/sidebar-for-wpb.min.css" type="text/css" />'); 38 $('body').append('<link rel="stylesheet" href="' + pluginUrl + '/assets/css/sidebar-for-wpb.min.css" type="text/css" />') 56 39 57 var myObserver = new MutationObserver(mutationHandler); 58 varobsConfig = {59 attributes: true60 }; 40 const myObserver = new MutationObserver(mutationHandler) 41 const obsConfig = { 42 attributes: true 43 } 61 44 62 $panelWindow.each(function() {63 myObserver.observe(this, obsConfig); 64 }); 45 $panelWindow.each(function() { 46 myObserver.observe(this, obsConfig) 47 }) 65 48 66 function mutationHandler(mutationRecords) {67 mutationRecords.forEach(function(mutation){68 if (window.innerWidth > 960 && mutation.type === 'attributes' && mutation.attributeName === 'class') {69 setFrameWrapperPosition($(mutation.target)); 70 setActiveBtn($(mutation.target)); 71 }72 }); 73 }49 function mutationHandler(mutationRecords) { 50 mutationRecords.forEach((mutation) => { 51 if (window.innerWidth > 960 && mutation.type === 'attributes' && mutation.attributeName === 'class') { 52 setFrameWrapperPosition() 53 setActiveBtn($(mutation.target)) 54 } 55 }) 56 } 74 57 75 function handleWindowResize() {76 setFrameWrapperPosition($panelWindow); 77 }58 function handleWindowResize() { 59 setFrameWrapperPosition() 60 } 78 61 79 function setFrameWrapperPosition($panelWindow) { 80 if (window.innerWidth > 960) { 81 if ($panelWindow.hasClass('vc_active')) { 82 $frameWrapper.css('left', '490px'); // sidebar 440px + navbar 50px 83 } else { 84 $frameWrapper.css('left', '50px'); // navbar 50px 85 } 86 } else { 87 $frameWrapper.css('left', '0'); 88 } 89 } 62 function setFrameWrapperPosition() { 63 const currentView = getCurrentView() 64 if (window.innerWidth > 960) { 65 const $activePanel = $panelWindow.filter('.vc_active') 66 if ($activePanel.length) { 67 $frameWrapper.css('left', '490px') // sidebar 440px + navbar 50px 68 setIframeWidth(currentView, window.innerWidth + 'px', 'auto') 69 if ($activePanel.is('#vc_ui-panel-templates') && $activePanel.hasClass('vc_media-xs')) { 70 $activePanel.removeClass('vc_media-xs') 71 $activePanel.addClass('vc_media-sm') 72 } 73 } else { 74 $frameWrapper.css('left', '50px') // navbar 50px 75 setIframeWidth(currentView, '100%', 'none') 76 } 77 } else { 78 $frameWrapper.css('left', '0') 79 setIframeWidth(currentView, '100%', 'none') 80 } 81 } 90 82 91 function setActiveBtn ($target) { 92 $navbarBtns.removeClass('vc_active'); 93 if ($target.hasClass('vc_active')) { 94 var panelType = $target.attr('data-vc-ui-element'); 95 var activePanel = panelsSettings.find(function (setting) { 96 return setting.panelId === panelType; 97 }); 98 if (activePanel) { 99 var activeBtn = activePanel.navbarBtnId; 100 $navbar.find('.vc_navbar-nav > li > #' + activeBtn).addClass('vc_active'); 101 } 102 } 103 } 83 function setIframeWidth (currentView, iframeWidth, overflow) { 84 if (responsiveView === '0') { 85 if (currentView === 100) { 86 $frameWrapper.css('overflow-x', overflow) 87 $iframe.css('width', iframeWidth) 88 } else { 89 $frameWrapper.css('overflow-x', 'auto') 90 $iframe.css('width', currentView + 'px') 91 } 92 } 93 } 104 94 105 setActiveBtn($panelWindow.filter('.vc_active')); 106 handleWindowResize(); 95 function getCurrentView () { 96 return parseInt($screenSizeControls.filter('.active').attr('data-size')) 97 } 107 98 108 $window.on('resize', handleWindowResize); 99 function setActiveBtn ($target) { 100 $navbarBtns.removeClass('vc_active') 101 if ($target.hasClass('vc_active')) { 102 const panelType = $target.attr('data-vc-ui-element') 103 const activePanel = panelsSettings.find((setting) => setting.panelId === panelType) 104 if (activePanel) { 105 const activeBtn = activePanel.navbarBtnId 106 $navbar.find('.vc_navbar-nav > li > #' + activeBtn).addClass('vc_active') 107 } 108 } 109 } 109 110 110 }); 111 }); 112 })(jQuery); 111 function setSettings () { 112 if (disableDescription === '1') { 113 $addElementPanel.find('.wpb-elements-list').addClass('vc_hide-description') 114 } 115 if (compactView === '1') { 116 $addElementPanel.find('.wpb-elements-list').addClass('vc_compact-view') 117 } 118 } 119 120 function setNavbarItems (index, item) { 121 const $item = $(item) 122 const $child = $item.children() 123 if ($child.hasClass('vc_back-button')) { 124 $item.css('order', '10') 125 } else if ($child.hasClass('vc_dropdown-more')) { 126 $item.css({ 127 'order': '9' 128 }) 129 } else if ($child.hasClass('vc_btn-save')) { 130 $item.css({ 131 'order': '8' 132 }) 133 } else if ($child.attr('id') === 'vc_screen-size-control') { 134 $item.css('order', '7') 135 } else if ($child.hasClass('vc_post-settings')) { 136 $item.css('order', '6') 137 } else if ($child.hasClass('vc_seo-button')) { 138 $item.css({ 139 'order':'5', 140 'margin-top': 'auto' 141 }) 142 } 143 } 144 145 setActiveBtn($panelWindow.filter('.vc_active')) 146 handleWindowResize() 147 setSettings() 148 149 $window.on('resize', handleWindowResize) 150 }) 151 }) 152 })(jQuery) -
sidebar-navigation-for-wpbakery/trunk/assets/js/sidebar-for-wpb.min.js
r3238119 r3252030 1 ( u=>{u(document).ready(function(){var p=u(window);p.on("vc_build",function(){var e=window.sidebar_for_wpb_js.plugin_url,t=u("#vc_navbar"),n=u("#vc_inline-frame-wrapper"),a=t.find(".vc_navbar-nav li"),s=u(".vc_ui-panel-window"),r=t.find(".vc_icon-btn"),c=[{panelId:"panel-add-element",navbarBtnId:"vc_add-new-element"},{panelId:"panel-templates",navbarBtnId:"vc_templates-editor-button"},{panelId:"panel-post-seo",navbarBtnId:"vc_seo-button"},{panelId:"panel-post-settings",navbarBtnId:"vc_post-settings-button"}],i=(u.each(a,function(e,n){var n=u(n),t=n.children();t.hasClass("vc_back-button")?n.css("order","10"):t.hasClass("vc_dropdown-more")?n.css({order:"9"}):t.hasClass("vc_btn-save")?n.css({order:"8"}):"vc_screen-size-control"===t.attr("id")?n.css("order","7"):t.hasClass("vc_post-settings")?n.css("order","6"):t.hasClass("vc_seo-button")&&n.css({order:"5","margin-top":"auto"})}),u("body").append('<link rel="stylesheet" href="'+e+'/assets/css/sidebar-for-wpb.min.css" type="text/css" />'),new MutationObserver(function(e){e.forEach(function(e){960<window.innerWidth&&"attributes"===e.type&&"class"===e.attributeName&&(v(u(e.target)),l(u(e.target)))})})),o={attributes:!0};function d(){v(s)}function v(e){960<window.innerWidth?e.hasClass("vc_active")?n.css("left","490px"):n.css("left","50px"):n.css("left","0")}function l(e){var n;r.removeClass("vc_active"),e.hasClass("vc_active")&&(n=e.attr("data-vc-ui-element"),e=c.find(function(e){return e.panelId===n}))&&(e=e.navbarBtnId,t.find(".vc_navbar-nav > li > #"+e).addClass("vc_active"))}s.each(function(){i.observe(this,o)}),l(s.filter(".vc_active")),d(),p.on("resize",d)})})})(jQuery);1 (C=>{C(document).ready(()=>{let h=C(window);h.on("vc_build",()=>{var e=window.sidebar_for_wpb_js.pluginUrl;let s=window.sidebar_for_wpb_js.disableDescription,t=window.sidebar_for_wpb_js.compactView,a=window.sidebar_for_wpb_js.responsiveView,n=C("#vc_screen-size-control .vc_screen-width"),i=C("#vc_ui-panel-add-element"),c=C("#vc_navbar"),r=C("#vc_inline-frame-wrapper"),d=C("#vc_inline-frame");var o=c.find(".vc_navbar-nav li");let l=C(".vc_ui-panel-window"),v=c.find(".vc_icon-btn"),p=[{panelId:"panel-add-element",navbarBtnId:"vc_add-new-element"},{panelId:"panel-templates",navbarBtnId:"vc_templates-editor-button"},{panelId:"panel-post-seo",navbarBtnId:"vc_seo-button"},{panelId:"panel-post-settings",navbarBtnId:"vc_post-settings-button"}],_=(C.each(o,function(e,s){var s=C(s),t=s.children();t.hasClass("vc_back-button")?s.css("order","10"):t.hasClass("vc_dropdown-more")?s.css({order:"9"}):t.hasClass("vc_btn-save")?s.css({order:"8"}):"vc_screen-size-control"===t.attr("id")?s.css("order","7"):t.hasClass("vc_post-settings")?s.css("order","6"):t.hasClass("vc_seo-button")&&s.css({order:"5","margin-top":"auto"})}),C("body").append('<link rel="stylesheet" href="'+e+'/assets/css/sidebar-for-wpb.min.css" type="text/css" />'),new MutationObserver(function(e){e.forEach(e=>{960<window.innerWidth&&"attributes"===e.type&&"class"===e.attributeName&&(f(),m(C(e.target)))})})),w={attributes:!0};function b(){f()}function f(){var e,s=parseInt(n.filter(".active").attr("data-size"));960<window.innerWidth?(e=l.filter(".vc_active")).length?(r.css("left","490px"),u(s,window.innerWidth+"px","auto"),e.is("#vc_ui-panel-templates")&&e.hasClass("vc_media-xs")&&(e.removeClass("vc_media-xs"),e.addClass("vc_media-sm"))):(r.css("left","50px"),u(s,"100%","none")):(r.css("left","0"),u(s,"100%","none"))}function u(e,s,t){"0"===a&&(100===e?(r.css("overflow-x",t),d.css("width",s)):(r.css("overflow-x","auto"),d.css("width",e+"px")))}function m(e){if(v.removeClass("vc_active"),e.hasClass("vc_active")){let s=e.attr("data-vc-ui-element");var e=p.find(e=>e.panelId===s);e&&(e=e.navbarBtnId,c.find(".vc_navbar-nav > li > #"+e).addClass("vc_active"))}}l.each(function(){_.observe(this,w)}),m(l.filter(".vc_active")),b(),"1"===s&&i.find(".wpb-elements-list").addClass("vc_hide-description"),"1"===t&&i.find(".wpb-elements-list").addClass("vc_compact-view"),h.on("resize",b)})})})(jQuery); -
sidebar-navigation-for-wpbakery/trunk/readme.txt
r3238119 r3252030 2 2 3 3 Contributors: nikitahl, mrdollar4444 4 Tags: wpbakery 4 Tags: wpbakery, wpbakery-extension, wpbakery-addon, sidebar, navigation, extension 5 5 Requires at least: 6.4 6 Tested up to: 6.7. 17 Stable tag: 1.16 Tested up to: 6.7.2 7 Stable tag: 2.0 8 8 Requires PHP: 7.0 9 9 License: GPLv3 or later … … 14 14 == Description == 15 15 16 This simple plugin adds a navigation bar and panels as a sidebar in the WPBakery Page Builder.16 This simple and lightweight plugin adds a navigation bar and panels as a sidebar in the WPBakery Page Builder. 17 17 18 18 If you want to keep your content visible at all times without constantly dragging or resizing panels, while still having quick access to them, this plugin is perfect for you. 19 19 20 20 It makes navigating the WPBakery Page Builder's Frontend Editor effortless. The navigation bar and panels appear as a sidebar on the left side of the screen, enhancing usability and efficiency. 21 22 Additionally, the plugin provides a settings page where you can customize some of the sidebar's appearance and behavior. 23 24 = Features = 25 26 * Sidebar navigation bar for quick access to panels. 27 * Panels as a sidebar for easy access to settings. 28 * Settings page for customizing the sidebar's appearance and behavior. 29 * Hide the description under elements in the Add Element panel. 30 * Reduce spacing between elements in the Add Element panel for a more compact view. 31 * Make the page view area shrink or stay the same width when the sidebar is opened. 32 33 = Requirements = 34 35 * WPBakery Page Builder 8.0 or later 36 * PHP 7.0 or later 37 * WordPress 6.4 or later 21 38 22 39 == Installation == … … 32 49 4. Edit Form panel 33 50 5. Page Settings panel 51 6. Plugin's settings page 34 52 35 53 == Frequently Asked Questions == … … 49 67 == Changelog == 50 68 69 = 2.0 = 70 * Update: Added the ability to hide the description under elements in the Add Element panel. 71 * Update: Added the ability to reduces spacing between elements in the Add Element panel for a more compact view. 72 * Update: Added the option to make the page view area shrink or stay the same width when the sidebar is opened. 73 * Fix: Fixed the issue with template preview in the Templates panel 74 51 75 = 1.1 = 52 76 * Update: Added active state for the icons in the navigation bar. -
sidebar-navigation-for-wpbakery/trunk/sidebar-navigation-for-wpbakery.php
r3238123 r3252030 3 3 * Plugin Name: Sidebar for WPBakery 4 4 * Description: Enhanced UI for WPBakery Page Builder with a sidebar navigation and panels. 5 * Version: 1.15 * Version: 2.0 6 6 * Author: Nikita Hlopov 7 7 * Author URI: https://nikitahl.com … … 16 16 } 17 17 18 require_once plugin_dir_path(__FILE__) . 'includes/settings.php'; 19 20 add_action( 'vc_frontend_editor_enqueue_js_css', 'sidebar_for_wpb_enqueue_frontend', 999 ); 21 add_action( 'plugins_loaded', 'sidebar_nav_for_wpbakery_load_textdomain' ); 22 23 // Add "Settings" link on the Plugins page 24 add_filter('plugin_action_links_sidebar-navigation-for-wpbakery/sidebar-navigation-for-wpbakery.php', 'sidebar_nav_for_wpbakery_settings_link'); 25 26 /** 27 * Enqueue the plugin's styles and scripts. 28 */ 18 29 function sidebar_for_wpb_enqueue_frontend() { 19 // check if we are in inline editor mode 20 // and only then load the script 30 // Check if we are in inline editor mode and only then load the script 21 31 if ( vc_is_inline() ) { 22 32 wp_register_script( 'sidebar-for-wpb-js', plugins_url( '/assets/js/sidebar-for-wpb.min.js', __FILE__ ), array(), WPB_VC_VERSION, true ); 23 33 wp_enqueue_script( 'sidebar-for-wpb-js' ); 24 34 35 // Get saved options 36 $settings = array( 37 'pluginUrl' => plugins_url( '', __FILE__ ), 38 'disableDescription' => get_option( 'sidebar_nav_for_wpbakery_disable_description', '0' ), 39 'compactView' => get_option( 'sidebar_nav_for_wpbakery_compact_view', '0' ), 40 'responsiveView' => get_option( 'sidebar_nav_for_wpbakery_responsive_view', '0' ), 41 ); 42 25 43 // Provide plugin URL for JS 26 wp_localize_script( 'sidebar-for-wpb-js', 'sidebar_for_wpb_js', array( 27 'plugin_url' => plugins_url( '', __FILE__ ) 28 ) ); 44 wp_localize_script( 'sidebar-for-wpb-js', 'sidebar_for_wpb_js', $settings ); 29 45 } 30 46 } 31 add_action( 'vc_frontend_editor_enqueue_js_css', 'sidebar_for_wpb_enqueue_frontend', 999 ); 47 48 /** 49 * Adds a settings link to the plugin's actions array. 50 * 51 * @param array $links The plugin action links. 52 * @return array The modified links array with the settings link added. 53 * @since 2.0 54 */ 55 function sidebar_nav_for_wpbakery_settings_link( $links ) { 56 // Generate the settings link and escape the URL for security 57 $settings_link = '<a href="' . esc_url( admin_url( 'options-general.php?page=sidebar-navigation-for-wpbakery' ) ) . '">' . esc_html__( 'Settings', 'sidebar-navigation-for-wpbakery' ) . '</a>'; 58 59 // Add the settings link to the beginning of the array 60 array_unshift( $links, $settings_link ); 61 62 return $links; 63 } 64 65 /** 66 * Load the plugin's text domain for localization. 67 */ 68 function sidebar_nav_for_wpbakery_load_textdomain() { 69 load_plugin_textdomain( 'sidebar-navigation-for-wpbakery', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 70 }
Note: See TracChangeset
for help on using the changeset viewer.