Skip to content

Commit

Permalink
wpnonce token added
Browse files Browse the repository at this point in the history
  • Loading branch information
jagveer-blueastral committed Mar 9, 2024
1 parent 3f235b5 commit 5ac7c06
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
24 changes: 12 additions & 12 deletions includes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' ) ) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array that holds active templates.
$templates = dslc_get_templates();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// Response to the AJAX call.
$response = array();
Expand Down Expand Up @@ -639,7 +639,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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce')) {

$code = '';

Expand Down Expand Up @@ -713,7 +713,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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -761,7 +761,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 ) ) {
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )) {

// The array we'll pass back to the AJAX call.
$response = array();
Expand Down Expand Up @@ -836,7 +836,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 ) ):
if ( is_user_logged_in() && current_user_can( DS_LIVE_COMPOSER_CAPABILITY_SAVE ) && wp_verify_nonce($_REQUEST['_wpnonce'], 'dslc-ajax-wpnonce' )):

// The array we'll pass back to the AJAX call.
$response = false;
Expand Down
2 changes: 1 addition & 1 deletion js/builder.all.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/dist/editor_backend.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/editor_backend.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/src/editor/backend/codegeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function dslc_save_composer() {
url: DSLCAjax.ajaxurl,
data: {
action : 'dslc-ajax-save-composer',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_post_id : postID,
dslc_code : composerCode,
Expand Down Expand Up @@ -111,6 +112,7 @@ function dslc_save_draft_composer() {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-save-draft-composer',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_post_id : postID,
dslc_code : composerCode,
Expand Down Expand Up @@ -599,4 +601,4 @@ export const editableContentCodeGeneration = ( dslcField ) => {

export const codeGenerationInitJS = () => {
setEventListeners();
}
}
5 changes: 4 additions & 1 deletion js/src/editor/backend/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ window.dslc_module_options_show = function( moduleID ) {
// Settings array for the Ajax call
var dslcSettings = {};
dslcSettings['action'] = 'dslc-ajax-display-module-options';
_wpnonce : DSLCAjax._wpnonce,
dslcSettings['dslc'] = 'active';
dslcSettings['dslc_module_id'] = moduleID;
dslcSettings['dslc_post_id'] = jQuery('.dslca-container').data('data-post-id');
Expand Down Expand Up @@ -744,6 +745,7 @@ export const moduleOutputDefault = ( dslc_module_id, callback ) => {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-add-module',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_module_id : dslc_module_id, // ex. DSLC_Button
dslc_post_id : jQuery('.dslca-container').data('post-id'),
Expand Down Expand Up @@ -935,6 +937,7 @@ function dslc_dm_get_defaults( module ) {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-dm-module-defaults',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_modules_options : optionsCode
},
Expand All @@ -957,4 +960,4 @@ function dslc_reload_module( moduleID, callback ) { window.dslc_module_output_re
export const moduleInitJS = () => {
adjustZindex();
editableContentTextEvents();
}
}
4 changes: 3 additions & 1 deletion js/src/editor/backend/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const updatePreset = () => {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-save-preset',
_wpnonce : DSLCAjax._wpnonce,
dslc_preset_name : presetName,
dslc_preset_code : presetCode,
dslc_module_id : moduleID
Expand Down Expand Up @@ -107,6 +108,7 @@ jQuery(document).ready(function($){
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-delete-preset',
_wpnonce : DSLCAjax._wpnonce,
dslc_preset_name : presetName,
dslc_module_id : moduleID
},
Expand All @@ -122,4 +124,4 @@ jQuery(document).ready(function($){

export const presetsInit = () => {

}
}
3 changes: 2 additions & 1 deletion js/src/editor/backend/sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export const addSection = ( callback ) => {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-add-modules-section',
_wpnonce : DSLCAjax._wpnonce,s
dslc : 'active'
},
function( response ) {
Expand Down Expand Up @@ -738,4 +739,4 @@ export const sectionsInit = () => {
jQuery('.dslca-row-options-filter-hook.dslca-active').removeClass('dslca-active');
LiveComposer.Builder.PreviewAreaWindow.dslc_responsive_classes( true );
});
}
}
3 changes: 3 additions & 0 deletions js/src/editor/backend/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const loadTemplateById = ( template ) => {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-load-template',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_template_id : template
},
Expand Down Expand Up @@ -82,6 +83,7 @@ function dslc_template_import() {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-import-template',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_template_code : jQuery('#dslca-import-code').val()
},
Expand Down Expand Up @@ -142,6 +144,7 @@ function dslc_template_delete( template ) {
DSLCAjax.ajaxurl,
{
action : 'dslc-ajax-delete-template',
_wpnonce : DSLCAjax._wpnonce,
dslc : 'active',
dslc_template_id : template
},
Expand Down

0 comments on commit 5ac7c06

Please sign in to comment.