diff --git a/ds-live-composer.php b/ds-live-composer.php index 07e8c801..82f3b276 100644 --- a/ds-live-composer.php +++ b/ds-live-composer.php @@ -4,7 +4,7 @@ * Plugin URI: https://www.livecomposerplugin.com * Description: Page builder for WordPress with drag and drop header/footer editing. * Author: Live Composer Team - * Version: 1.5.36 + * Version: 1.5.37 * Author URI: https://livecomposerplugin.com * License: GPL3 * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -41,7 +41,7 @@ * Constants */ - define( 'DS_LIVE_COMPOSER_VER', '1.5.36' ); + define( 'DS_LIVE_COMPOSER_VER', '1.5.37' ); define( 'DS_LIVE_COMPOSER_SHORTNAME', __( 'Live Composer', 'live-composer-page-builder' ) ); define( 'DS_LIVE_COMPOSER_BASENAME', plugin_basename( __FILE__ ) ); diff --git a/includes/ajax.php b/includes/ajax.php index 0c7d46e2..2ac4b0e5 100644 --- a/includes/ajax.php +++ b/includes/ajax.php @@ -31,7 +31,7 @@ function dslc_ajax_add_modules_section( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -75,7 +75,7 @@ function dslc_ajax_add_modules_section( $atts ) { function dslc_ajax_add_module( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -215,7 +215,7 @@ function dslc_ajax_add_module( $atts ) { function dslc_ajax_display_module_options( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -292,7 +292,7 @@ function dslc_ajax_display_module_options( $atts ) { function dslc_ajax_save_composer( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -381,7 +381,7 @@ function dslc_ajax_save_composer( $atts ) { function dslc_ajax_save_draft_composer( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -425,7 +425,7 @@ function dslc_ajax_save_draft_composer( $atts ) { function dslc_ajax_load_template( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array that holds active templates. $templates = dslc_get_templates(); @@ -464,7 +464,7 @@ function dslc_ajax_load_template( $atts ) { function dslc_ajax_import_template( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -501,7 +501,7 @@ function dslc_ajax_import_template( $atts ) { function dslc_ajax_save_template( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) ) { // Response to the AJAX call. $response = array(); @@ -563,7 +563,7 @@ function dslc_ajax_save_template( $atts ) { function dslc_ajax_delete_template( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) ) { $response = array(); $response['status'] = 'success'; @@ -605,7 +605,8 @@ function dslc_ajax_delete_template( $atts ) { function dslc_ajax_import_modules_section( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { + // The array we'll pass back to the AJAX call. $response = array(); @@ -639,7 +640,7 @@ function dslc_ajax_import_modules_section( $atts ) { */ function dslc_ajax_dm_module_defaults_code( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce')) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { $code = ''; @@ -713,7 +714,7 @@ function dslc_ajax_dm_module_defaults_code( $atts ) { function dslc_ajax_save_preset() { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -761,7 +762,7 @@ function dslc_ajax_save_preset() { function dslc_ajax_delete_preset() { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) { + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) ) { // The array we'll pass back to the AJAX call. $response = array(); @@ -836,7 +837,7 @@ function dslc_ajax_clear_cache() { function dslc_ajax_toggle_extension( $atts ) { // Allowed to do this? - if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['security']['nonce'], 'dslc-optionspanel-ajax' )): + if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) ): // The array we'll pass back to the AJAX call. $response = false; diff --git a/includes/scripts.php b/includes/scripts.php index 803a421e..d2a42aa9 100644 --- a/includes/scripts.php +++ b/includes/scripts.php @@ -244,7 +244,6 @@ public static function dslc_load_scripts_admin( $hook ) { wp_localize_script( 'dslc-editor-backend-js', 'DSLCAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), - '_wpnonce' => wp_create_nonce( 'dslc-ajax-wpnonce' ), ) ); wp_localize_script( 'dslc-editor-backend-js', 'DSLCSiteData', array( 'siteurl' => get_option( 'siteurl' ), diff --git a/js/builder.all.min.js b/js/builder.all.min.js index 8d966495..2b429ee6 100644 --- a/js/builder.all.min.js +++ b/js/builder.all.min.js @@ -1 +1 @@ -"use strict";function dslc_ui_animations(){if(dslcDebug)console.log("dslc_ui_animations");jQuery(document).on("mouseenter",".dslca-modules-area-manage",function(){jQuery(this).closest(".dslc-modules-area").addClass("dslca-options-hovered")}).on("mouseleave",".dslca-modules-area-manage",function(){jQuery(this).closest(".dslc-modules-area").removeClass("dslca-options-hovered")});jQuery(document).on("mouseenter",".dslca-drag-not-in-progress .dslc-module-front",function(e){if(!jQuery("body").hasClass("dslca-composer-hidden")){if(jQuery(this).height()<190)jQuery(".dslca-module-manage",this).addClass("dslca-horizontal");else jQuery(".dslca-module-manage",this).removeClass("dslca-horizontal")}}).on("mouseleave",".dslca-drag-not-in-progress .dslc-module-front",function(e){if(!jQuery("body").hasClass("dslca-composer-hidden")){}});jQuery(document).on("mouseenter",".dslca-drag-not-in-progress .dslc-modules-area",function(e){var o=jQuery(this);if(!jQuery("body").hasClass("dslca-composer-hidden")){if(jQuery(this).height()<130)jQuery(".dslca-modules-area-manage",this).addClass("dslca-horizontal");else jQuery(".dslca-modules-area-manage",this).removeClass("dslca-horizontal")}}).on("mouseleave",".dslca-drag-not-in-progress .dslc-modules-area",function(e){var o=jQuery(this);if(!jQuery("body").hasClass("dslca-composer-hidden")){}})}jQuery(document).ready(function(){dslc_ui_animations()});"use strict";function dslc_save_composer(){if(dslcDebug)console.log("dslc_save_composer");dslc_generate_code();dslca_gen_content_for_search();var e=jQuery("#dslca-code").val(),o=jQuery("#dslca-content-for-search").val(),s=jQuery(".dslca-container").data("post-id");jQuery("body").addClass("dslca-saving-in-progress");jQuery(".dslca-save-composer .dslca-icon").removeClass("dslc-icon-ok").addClass("dslc-icon-spin dslc-icon-spinner");jQuery.ajax({method:"POST",type:"POST",url:DSLCAjax.ajaxurl,data:{action:"dslc-ajax-save-composer",dslc:"active",_wpnonce : DSLCAjax._wpnonce,dslc_post_id:s,dslc_code:e,dslc_content_for_search:o},timeout:3e4}).done(function(e){if(e.status=="success"){jQuery(".dslca-save-composer").fadeOut(250);jQuery(".dslca-save-draft-composer").fadeOut(250);jQuery("body").append('');jQuery(".lbmn-cache-iframe").each(function(e,o){jQuery(o).load(function(){jQuery(o).remove()})})}else{alert("Something went wrong, please try to save again. Are you sure to make any changes? Error Code: "+e.status)}}).fail(function(e){if(e.statusText=="timeout"){alert("The request timed out after 30 seconds. Server do not respond in time. Please try again.")}else{alert("Something went wrong. Please try again. Error Code: "+e.statusText)}}).always(function(e){jQuery(".dslca-save-composer .dslca-icon").removeClass("dslc-icon-spin dslc-icon-spinner").addClass("dslc-icon-ok");jQuery("body").removeClass("dslca-saving-in-progress")})}function dslc_save_draft_composer(){if(dslcDebug)console.log("dslc_save_draft_composer");var e=jQuery("#dslca-code").val(),o=jQuery(".dslca-container").data("post-id");jQuery("body").addClass("dslca-saving-in-progress");jQuery(".dslca-save-draft-composer .dslca-icon").removeClass("dslc-icon-ok").addClass("dslc-icon-spin dslc-icon-spinner");jQuery.post(DSLCAjax.ajaxurl,{action:"dslc-ajax-save-draft-composer",dslc:"active",_wpnonce : DSLCAjax._wpnonce,dslc_post_id:o,dslc_code:e},function(e){jQuery(".dslca-save-draft-composer .dslca-icon").removeClass("dslc-icon-spin dslc-icon-spinner").addClass("dslc-icon-save");if(e.status=="success"){jQuery(".dslca-save-draft-composer").fadeOut(250)}else{alert("Something went wrong, please try to save again.")}jQuery("body").removeClass("dslca-saving-in-progress")})}function dslc_generate_code(){if(dslcDebug)console.log("dslc_generate_code");var e="",o,s="",d="",l=12,i=12,t=0,a=0,r,c,n,u,m,p="",f;jQuery("#dslc-main .dslc-modules-area",LiveComposer.Builder.PreviewAreaDocument).each(function(){if(jQuery(".dslc-module-front",this).length){jQuery(this).removeClass("dslc-modules-area-empty").addClass("dslc-modules-area-not-empty");jQuery(".dslca-no-content",this).hide()}else{jQuery(this).removeClass("dslc-modules-area-not-empty").addClass("dslc-modules-area-empty");jQuery(".dslca-no-content:not(:visible)",this).show().css({"-webkit-animation-name":"dslcBounceIn","-moz-animation-name":"dslcBounceIn","animation-name":"dslcBounceIn","animation-duration":"0.6s","-webkit-animation-duration":"0.6s",padding:0}).animate({padding:"35px 0"},300)}});jQuery("#dslc-main .dslc-modules-section",LiveComposer.Builder.PreviewAreaDocument).each(function(){m=jQuery(this);f=dslc_generate_section_code(m);m.find(".dslca-section-code").val(f);d=d+f+","});d=d.slice(0,-1);d="["+d+"]";jQuery("#dslca-code").val(d);jQuery("#dslca-export-code").val(d)}function dslc_generate_section_code(e){if(dslcDebug)console.log("dslc_generate_section_code");var i="",t,o="",s="",a=12,d=12,r=0,c=0,n,u,m,p,l,f="",v="",h;l=e;if(jQuery(".dslc-modules-area",l).length){l.removeClass("dslc-modules-section-empty").addClass("dslc-modules-section-not-empty")}else{l.removeClass("dslc-modules-section-not-empty").addClass("dslc-modules-section-empty")}jQuery(".dslc-modules-area.dslc-last-col, .dslc-modules-area.dslc-first-col",this).removeClass("dslc-last-col dslc-first-col");jQuery(".dslc-module-front.dslc-last-col, .dslc-module-front.dslc-first-col",this).removeClass("dslc-last-col dslc-first-col");c=0;v=l.find(".dslca-section-code").val();h=JSON.parse(v);f="";jQuery(".dslca-modules-section-settings input",l).each(function(){var e=jQuery(this);var o=e.data("id");var s=e.val();f=f+o+'="'+s+'" ';h[o]=s});if(undefined!==h["give_new_id"]){delete h["give_new_id"]}h["content"]=[];jQuery(".dslc-modules-area",l).each(function(){r=0;u=jQuery(this);n=parseInt(u.data("size"));m="no";p="no";c+=n;jQuery(this).removeClass("dslc-first-col");jQuery(this).removeClass("dslc-last-col");if(c==d){jQuery(this).addClass("dslc-last-col").next(".dslc-modules-area").addClass("dslc-first-col");c=0;m="yes"}else if(c>d){jQuery(this).removeClass("dslc-last-col").addClass("dslc-first-col");c=n;p="yes"}if(c==n){p="yes";jQuery(this).removeClass("dslc-last-col").addClass("dslc-first-col")}var l='{"element_type":"module_area","last":"'+m+'","first":"'+p+'","size":"'+n+'"}';l=JSON.parse(l);if(undefined!==l["give_new_id"]){delete l["give_new_id"]}l.content=[];jQuery(".dslc-module-front",u).each(function(){var o=jQuery(this);t=parseInt(o[0].getAttribute("data-dslc-module-size"));var e="no";var s="no";jQuery(this).removeClass("dslc-first-col");jQuery(this).removeClass("dslc-last-col");r+=t;if(r==a){jQuery(this).addClass("dslc-last-col");jQuery(this).next(".dslc-module-front").addClass("dslc-first-col");r=0;e="yes";s="yes"}else if(r>a){jQuery(this).removeClass("dslc-last-col").addClass("dslc-first-col");r=t;s="yes"}if(r==t){s="yes";jQuery(this).removeClass("dslc-last-col").addClass("dslc-first-col")}try{i=o[0].querySelector(".dslca-module-code").value}catch(e){console.info("No DSLC code found in module: "+o[0].getAttribute("id"))}if(""!==i){var d=JSON.parse(i);d.last=e;jQuery.each(d,function(e,o){if(false===o||""===o){delete d[e]}if("content"===e){d[e]=o.replace(/\\'/g,"'")}if("give_new_id"===e){delete d[e]}});o[0].querySelector(".dslca-module-code").value=JSON.stringify(d);l["content"].push(d)}i=""});h["content"].push(l)});var _=JSON.stringify(h);return _}jQuery(document).ready(function(o){o(document).on("click",".dslca-save-composer-hook",function(e){e.preventDefault();if(!o("body").hasClass("dslca-module-saving-in-progress")&&!o("body").hasClass("dslca-saving-in-progress")){dslc_save_composer()}});o(document).on("click",".dslca-save-draft-composer-hook",function(e){e.preventDefault();if(!o("body").hasClass("dslca-module-saving-in-progress")&&!o("body").hasClass("dslca-saving-in-progress")){dslc_save_draft_composer()}})});function dslca_gen_content_for_search(){if(dslcDebug)console.log("dslca_gen_content_for_search");var e=document.getElementById("dslca-content-for-search");if(null===e){return}var o=e.value;var l="";var s=LiveComposer.Builder.PreviewAreaWindow.document.querySelectorAll("#dslc-main .dslc-module-front [data-exportable-content]");if(undefined!==s){Array.prototype.forEach.call(s,function(e,o){var s;if(e.getAttribute("data-exportable-content")!==""){var d=e.getAttribute("data-exportable-content");s="<"+d+">"+e.innerHTML+""+d+">"}else{s=e.innerHTML}if(s!==null){l+=s.replace(/\s+/g," ").trim()+"\n"}})}e.value=l;if(o!==l){dslc_show_publish_button()}}var massagesTicker=jQuery("#editor-messages").newsTicker({row_height:40,max_rows:2,speed:900,direction:"up",duration:12e3,autostart:1,pauseOnHover:1,start:function(){jQuery("#editor-messages").css("opacity","1")}});jQuery(document).ready(function(s){s(document).on("click",".dslc-editor-messages-hide",function(e){var o=s(".dslc-editor-messages-hide").data("can-hide");if(o=="1"){jQuery.post(DSLCAjax.ajaxurl,{action:"dslc-ajax-hidden-panel"});s(".dslc-editor-messages-section-122017").css("display","none");s(".dslca-container").removeClass("active-message-panel")}else{s("#editor-messages").html('
')}});if(s("div.dslc-editor-messages-section-122017").length){s(".dslc-editor-messages-section-122017").css("display","block");s(".dslca-container").addClass("active-message-panel")}});"use strict";var dslcRegularFontsArray=DSLCFonts.regular;var dslcGoogleFontsArray=DSLCFonts.google;var dslcAllFontsArray=dslcRegularFontsArray.concat(dslcGoogleFontsArray);var dslcIconsCurrentSet=DSLCIcons.fontawesome;var dslcDebug=false;var LiveComposer={Builder:{Elements:{},UI:{},Actions:{},Flags:{},PreviewFrame:{},Helpers:{}},Production:{},Utils:{}};(function(){LiveComposer.Builder.Flags={windowScroller:false,panelOpened:false,generate_code_after_row_changed:true};LiveComposer.Builder.Actions={postponed_actions_queue:{},add_postponed_action:function(e){if(e===undefined){return}if(isNaN(this.postponed_actions_queue[e])){this.postponed_actions_queue[e]=0}this.postponed_actions_queue[e]+=1},release_postponed_actions:function(){var s=this;jQuery.each(this.postponed_actions_queue,function(e,o){if(1