Skip to content

Commit

Permalink
Merge pull request #1117 from live-composer/release_1_5_33
Browse files Browse the repository at this point in the history
Release 1 5 33
  • Loading branch information
nitin-blueastral committed Feb 5, 2024
2 parents cf412fa + 9fa9fc2 commit dbdbe77
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 65 deletions.
4 changes: 2 additions & 2 deletions ds-live-composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.32
* Version: 1.5.33
* Author URI: https://livecomposerplugin.com
* License: GPL3
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -41,7 +41,7 @@
* Constants
*/

define( 'DS_LIVE_COMPOSER_VER', '1.5.32' );
define( 'DS_LIVE_COMPOSER_VER', '1.5.33' );

define( 'DS_LIVE_COMPOSER_SHORTNAME', __( 'Live Composer', 'live-composer-page-builder' ) );
define( 'DS_LIVE_COMPOSER_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
22 changes: 15 additions & 7 deletions includes/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
header( 'HTTP/1.0 403 Forbidden' );
exit;
}


/**
* Add/display a new module section
*
Expand Down Expand Up @@ -473,7 +471,11 @@ function dslc_ajax_import_template( $atts ) {

// The code of the template.
$template_code = stripslashes( $_POST['dslc_template_code'] );
$template_code = maybe_serialize($template_code);

if (!dslc_is_json( $template_code ) ) {
return 0;
exit;
}

$response['output'] = dslc_render_content( $template_code, true );

Expand Down Expand Up @@ -512,6 +514,11 @@ function dslc_ajax_save_template( $atts ) {
$template_id = strtolower( str_replace( ' ', '-', $template_title ) );
$template_code = stripslashes( $_POST['dslc_template_code'] );

if (!dslc_is_json($template_code) ) {
return 0;
exit;
}

// Get current templates.
$templates = get_option( 'dslc_templates' );

Expand All @@ -526,7 +533,7 @@ function dslc_ajax_save_template( $atts ) {
$templates[ $template_id ] = array(
'title' => $template_title,
'id' => $template_id,
'code' => maybe_serialize($template_code),
'code' => $template_code,
'section' => 'user',
);

Expand Down Expand Up @@ -605,9 +612,10 @@ function dslc_ajax_import_modules_section( $atts ) {

// The code of the modules section.
$code_to_import = stripslashes( $_POST['dslc_modules_section_code'] );

$code_to_import = maybe_serialize($code_to_import);

if (!dslc_is_json($code_to_import) ) {
return 0;
exit;
}
$response['output'] = dslc_render_content( $code_to_import, true );
$response['output'] = do_shortcode( $response['output'] );

Expand Down
117 changes: 63 additions & 54 deletions includes/display-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,9 @@ function dslc_filter_content( $content ) {
$rendered_page = $dslc_content_before . $composer_wrapper_before . do_action( 'dslc_output_prepend' ) . $composer_header . '<div id="dslc-main">' . $composer_prepend . $composer_content . '</div>' . $composer_append . $composer_footer . do_action( 'dslc_output_append' ) . $composer_wrapper_after . $dslc_content_after;

if ( ! dslc_is_editor_active() && ! is_singular( 'dslc_hf' ) ) {
global $wpdb;

$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->prefix}posts SET post_content = %s WHERE ID = %d AND post_type = 'page'",
$rendered_page,
$cache_id
)
);

$cache->set_cache( $rendered_page, $cache_id );

}

// We need double do_shortcode as our module shortcodes can contain encoded 3-rd party shortcodes.
Expand All @@ -797,6 +790,7 @@ function dslc_filter_content( $content ) {
} add_filter( 'the_content', 'dslc_filter_content', 101 );



/**
* Check if provided id is template for the custom 404 page.
*
Expand Down Expand Up @@ -942,7 +936,13 @@ function dslc_editor_code() {
* @return Bool True if JSON, false otherwise.
*/
function dslc_is_json( $string ) {
json_decode( $string );

try {
json_decode( $string );
} catch (\Throwable $th) {
return false;
}

return ( function_exists( 'json_last_error' ) && json_last_error() == JSON_ERROR_NONE );
}

Expand All @@ -955,56 +955,65 @@ function dslc_is_json( $string ) {
*/
function dslc_json_decode( $raw_code, $ignore_migration = false ) {
$decoded = false;

if (!is_array($raw_code) && dslc_is_json( $raw_code ) ) {
$decoded = json_decode( $raw_code, true );

}
else{

// $raw_code = maybe_unserialize( stripslashes($raw_code) );
$raw_code = maybe_unserialize( $raw_code );

// Array already provided. Do nothing.
if ( is_array( $raw_code ) ) {
return $raw_code;
}

// $raw_code = maybe_unserialize( stripslashes($raw_code) );
$raw_code = maybe_unserialize( $raw_code );

// Array already provided. Do nothing.
if ( is_array( $raw_code ) ) {
return $raw_code;
}

// Is it JSON?
if ( ! dslc_is_json( $raw_code ) ) {
// If it's not JSON then:
// 1. it's old code of the module settings serialized + base64.
// 2. it's old code containing both shortocodes + base64.
/**
* Is it's valid base64?
*
* Function base64_decode returns FALSE if input contains
* character from outside the base64 alphabet.
*/

$decoded_base64 = base64_decode( $raw_code );

// Base64 successfull?
if ( ! $decoded_base64 ) {
// 2. it's old code containing both shortocodes + base64
// We can do nothing with it, so return FALSE.
return false;
} else {
// Is it JSON?
if ( ! dslc_is_json( $raw_code ) ) {
// If it's not JSON then:
// 1. it's old code of the module settings serialized + base64.
// Get array out of it.
$decoded = maybe_unserialize( $decoded_base64 );
// 2. it's old code containing both shortocodes + base64.
/**
* Is it's valid base64?
*
* Function base64_decode returns FALSE if input contains
* character from outside the base64 alphabet.
*/

$decoded_base64 = base64_decode( $raw_code );

// Base64 successfull?
if ( ! $decoded_base64 ) {
// 2. it's old code containing both shortocodes + base64
// We can do nothing with it, so return FALSE.
return false;
} else {
// 1. it's old code of the module settings serialized + base64.
// Get array out of it.
$decoded = maybe_unserialize( $decoded_base64 );

// Add a marker indicating that this module
// was imported from shortcode format.
if ( is_array( $decoded ) ) {
$decoded['code_version'] = 1;
}

// Add a marker indicating that this module
// was imported from shortcode format.
if ( is_array( $decoded ) ) {
$decoded['code_version'] = 1;
// Preset is always being stored in base64 format,
// so we need to ignore code version parameter as it's not relevant.
if ( $ignore_migration ) {
unset( $decoded['code_version'] );
}
}
} else {
// Decode JSON.
$decoded = json_decode( $raw_code, true );
} // End if().

// Preset is always being stored in base64 format,
// so we need to ignore code version parameter as it's not relevant.
if ( $ignore_migration ) {
unset( $decoded['code_version'] );
}
}
} else {
// Decode JSON.
$decoded = json_decode( $raw_code, true );
} // End if().
}


return $decoded;
}

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

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: LiveComposer
Tags: page builder, landing page builder, frontend page builder, drag and drop page builder, website builder
Requires at least: 4.7
Tested up to: 6.4.2
Stable tag: 1.5.32
Stable tag: 1.5.33
License: GPLv3

Page builder for WordPress with drag and drop header/footer editing, responsive settings, and animations. Compatible with Gutenberg block editor.
Expand Down Expand Up @@ -58,6 +58,9 @@ In most of the cases, this is because the homepage is not a real WordPress page,
* 🦊 [Check out our WooCommerce Page Builder Extension](https://livecomposerplugin.com/downloads/woocommerce-page-builder/?utm_source=wp-admin&utm_medium=changelog&utm_campaign=woo-integration)
* 👀 [We keep updating and improving our extensions pack](https://livecomposerplugin.com/downloads/extensions/?utm_source=wp-admin&utm_medium=changelog&utm_campaign=add-ons) ACF + CPT + MegaMenu + 9 more add-ons.

= 1.5.33 - Feb 05 2024 =
* Security improvement

= 1.5.32 - Jan 25 2024 =
* Reverted changes from Release 1.5.30 and 1.5.31

Expand Down

0 comments on commit dbdbe77

Please sign in to comment.