From d5b67d6a1db4acfe66a0a407ed34b8a87b97d8cc Mon Sep 17 00:00:00 2001 From: Sazedul Haque Date: Fri, 29 Jul 2022 15:09:34 +0600 Subject: [PATCH 01/43] FIX: Escape theme slug in template full with --- core/template-full-width.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/template-full-width.php b/core/template-full-width.php index ee2cc9e7..1d5d36f2 100644 --- a/core/template-full-width.php +++ b/core/template-full-width.php @@ -24,7 +24,7 @@ get( 'TextDomain' ); - echo do_blocks( '' ); + echo do_blocks( '' ); } else { get_header(); } @@ -36,7 +36,7 @@ if ( version_compare( $wp_version, '5.9', '>=' ) && function_exists( 'wp_is_block_theme' ) && true === wp_is_block_theme() ) { $theme = wp_get_theme(); $theme_slug = $theme->get( 'TextDomain' ); - echo do_blocks(''); + echo do_blocks(''); echo ''; wp_footer(); echo ''; From f804f44720d95dfdfb1c86a5f3c54a6bdefc9abe Mon Sep 17 00:00:00 2001 From: Sazedul Haque Date: Fri, 5 Aug 2022 12:19:46 +0600 Subject: [PATCH 02/43] FIX: Add deprecated to Tabs Block --- assets/reactjs/src/blocks/tabs/index.js | 155 ++++++++++++++++++++++-- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/assets/reactjs/src/blocks/tabs/index.js b/assets/reactjs/src/blocks/tabs/index.js index efa0d52d..354da9f6 100644 --- a/assets/reactjs/src/blocks/tabs/index.js +++ b/assets/reactjs/src/blocks/tabs/index.js @@ -2,8 +2,9 @@ import "./style.scss"; import Save from "./Save"; import Edit from "./Edit"; import attributes from "./attributes"; -const { Component } = wp.element; -const { InnerBlocks } = wp.blockEditor; +import classnames from "classnames"; +const { Fragment, Component } = wp.element; +const { InnerBlocks, RichText } = wp.blockEditor; const { HelperFunction: { animationAttr, IsInteraction }, } = wp.qubelyComponents; @@ -11,16 +12,18 @@ const { const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; +const supports = { + html: false, + className: false, + align: ["full", "wide", "center"], +}; + registerBlockType("qubely/tabs", { title: __("Tabs"), category: "qubely", icon: {__("Tabs, description: __("Showcase features in beautiful pre-designed tabs with Qubely Tabs."), - supports: { - html: false, - className: false, - align: ["full", "wide", "center"], - }, + supports: supports, example: { attributes: { tabTitles: [{ title: "Tab 1" }, { title: "Tab 2" }, { title: "Tab 3" }], @@ -43,4 +46,142 @@ registerBlockType("qubely/tabs", { attributes, edit: Edit, save: Save, + deprecated: [ + { + attributes, + supports, + save(props) { + const { + attributes: { + uniqueId, + className, + tabs, + navType, + autoSwithcing, + showProgressBar, + defaultDelay, + tabStyle, + tabTitles, + iconPosition, + navAlignment, + animation, + interaction, + navLayout, + enableImageNavTitle, + progressbarPosition, + imageNavTitleAlignment, + enableImageNavDesciption, + }, + } = props; + + const interactionClass = IsInteraction(interaction) ? "qubley-block-interaction" : ""; + + const renderTabTitles = () => { + return tabTitles.map((title, index) => ( + + {navType === "text" ? ( + + + {title.iconName && (iconPosition == "top" || iconPosition == "left") && ( + + )} + {title.title} + {title.iconName && iconPosition == "right" && ( + + )} + + + ) : ( +
+
+ {navLayout !== "three" && ( + + {typeof title.avatar !== "undefined" && title.avatar.url ? ( + {title.avatar.alt + ) : ( +
+ +
+ )} +
+ )} + + {(enableImageNavTitle || enableImageNavDesciption) && ( +
+ {enableImageNavTitle && ( + + )} + {enableImageNavDesciption && ( + + )} +
+ )} +
+
+ )} + + {autoSwithcing && showProgressBar && ( +
+ )} + + )); + }; + + const blockWrapperClasses = classnames( + { [`qubely-block-${uniqueId}`]: typeof uniqueId !== "undefined" }, + { "with-auto-swithing": autoSwithcing }, + { [className]: typeof className !== "undefined" } + ); + const blockClasses = classnames("qubely-block-tab", `${interactionClass}`, `qubely-tab-style-${tabStyle}`, { + "with-auto-swithing": autoSwithcing, + }); + + return ( +
+
+
{renderTabTitles()}
+
+ +
+
+
+ ); + } + } + ] }); From 2110bef88c051afe0986e3a6db5b537e0e994df4 Mon Sep 17 00:00:00 2001 From: sifat009 Date: Tue, 9 Aug 2022 10:36:32 +0600 Subject: [PATCH 03/43] Fix: re render issue in table of content --- .../reactjs/src/blocks/table-of-contents/components.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/assets/reactjs/src/blocks/table-of-contents/components.js b/assets/reactjs/src/blocks/table-of-contents/components.js index 50da667f..b5a2b2d3 100644 --- a/assets/reactjs/src/blocks/table-of-contents/components.js +++ b/assets/reactjs/src/blocks/table-of-contents/components.js @@ -80,15 +80,6 @@ class TableOfContents extends Component { this.setState({ unsubscribe }); } - componentDidUpdate(prevProps, prevState) { - if ( - JSON.stringify(prevProps.headers) !== JSON.stringify(prevState.headers) - ) { - this.props.blockProp.setAttributes({ - headerLinks: JSON.stringify(this.state.headers), - }); - } - } componentWillUnmount() { this.state.unsubscribe(); } From e621d971fd57e845cfe84b8851fbee5df007d584 Mon Sep 17 00:00:00 2001 From: Sazedul Haque Date: Tue, 9 Aug 2022 15:59:32 +0600 Subject: [PATCH 04/43] UPDATE: Latest version with change log --- qubely.php | 4 ++-- readme.txt | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qubely.php b/qubely.php index 6e6413c7..b5fdfd6d 100644 --- a/qubely.php +++ b/qubely.php @@ -3,7 +3,7 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.3 + * Version: 1.8.4 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely @@ -24,7 +24,7 @@ function qubely_language_load() } // Define Version -define('QUBELY_VERSION', '1.8.3'); +define('QUBELY_VERSION', '1.8.4'); // Define License define('QUBELY_LICENSE', 'free'); diff --git a/readme.txt b/readme.txt index e57bb72d..76dbcd37 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 Tested up to: 6.0.1 -Stable tag: 1.8.3 +Stable tag: 1.8.4 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt @@ -239,6 +239,10 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.4 = +Update: Implemented more security update for improved security +New: Introduced "Deprecation" in case of the "Block Recovery Issue" for Update + = 1.8.3 = Update: Email Sending Mechanism is improved in terms of Security and Performance Update: PHP version compatibility is improved From 1fa748af3b1e8bb35050292d3cc313f53a95677b Mon Sep 17 00:00:00 2001 From: sifat009 Date: Thu, 19 Jan 2023 17:18:36 +0600 Subject: [PATCH 05/43] Updated mail functionality to fix receiver email not working --- core/QUBELY.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index 4c4abf47..0ba9549c 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -1959,7 +1959,7 @@ public function sanitize_form_array( $input = array() ) { return $array; } - + /** * Ajax for sending form data * @@ -2016,7 +2016,9 @@ public function qubely_send_form_data() { } $fieldNames[ $key ] = $value; - $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); + // if ($key == 'email') { + // $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); + // } } if ( $validation || ( isset( $_POST['qubely-form-has-policy'] ) && empty( $_POST['qubely-form-has-policy'] ) ) ) { @@ -2066,7 +2068,7 @@ public function qubely_send_form_data() { // Send E-Mail Now or through error msg. try { - $isMail = wp_mail( $emailFrom, $emailSubject, $emailBody, $headers ); + $isMail = wp_mail( $emailReceiver, $emailSubject, $emailBody, $headers ); if ( $isMail ) { $responseData['status'] = 1; $responseData['msg'] = __( $formSuccessMessage, 'qubely' ); From 2a90ea79af1dd86d345afdd62d0d9465fa5a7528 Mon Sep 17 00:00:00 2001 From: sifat009 Date: Tue, 24 Jan 2023 13:24:55 +0600 Subject: [PATCH 06/43] Fixed xss issues from postgrid block --- core/blocks/postgrid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/blocks/postgrid.php b/core/blocks/postgrid.php index 932b4454..decc4cac 100644 --- a/core/blocks/postgrid.php +++ b/core/blocks/postgrid.php @@ -1419,7 +1419,7 @@ function qubely_excerpt_max_charlength($limit) $class .= ' align' . $att['align']; } if (isset($att['className'])) { - $class .= $att['className']; + $class .= esc_attr($att['className']); } if ($query->have_posts()) { From 3e27bc98ef63c07917d001cd688a143edf44d689 Mon Sep 17 00:00:00 2001 From: sifat009 Date: Fri, 27 Jan 2023 13:47:16 +0600 Subject: [PATCH 07/43] Fixed jetpack conflict with button and icon blocks --- assets/reactjs/src/blocks/button/Edit.js | 6 +++--- assets/reactjs/src/blocks/button/Save.js | 2 +- assets/reactjs/src/blocks/button/attributes.js | 2 +- assets/reactjs/src/blocks/icon/Edit.js | 4 ++-- assets/reactjs/src/blocks/icon/Save.js | 3 ++- assets/reactjs/src/blocks/icon/index.js | 2 +- qubely.php | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/assets/reactjs/src/blocks/button/Edit.js b/assets/reactjs/src/blocks/button/Edit.js index f7b3a4d0..abe8fe98 100644 --- a/assets/reactjs/src/blocks/button/Edit.js +++ b/assets/reactjs/src/blocks/button/Edit.js @@ -61,7 +61,7 @@ class Edit extends Component { // updateBlockAttributes, // buttonGroupAttributes, attributes: { - url, + qubelyButtonUrl, iconName, recreateStyles, fillType, @@ -154,8 +154,8 @@ class Edit extends Component { setAttributes({ url: value })} + value={qubelyButtonUrl} + onChange={(value) => setAttributes({ qubelyButtonUrl: value })} /> {enableAlignment && ( this.setState({ device: value })} /> )} - setAttributes({ url: val })} /> + setAttributes({ qubelyIconUrl: val })} /> diff --git a/assets/reactjs/src/blocks/icon/index.js b/assets/reactjs/src/blocks/icon/index.js index b9c0ecbb..59ec4c8f 100644 --- a/assets/reactjs/src/blocks/icon/index.js +++ b/assets/reactjs/src/blocks/icon/index.js @@ -31,7 +31,7 @@ registerBlockType("qubely/icon", { style: [{ selector: "{{QUBELY}}" }], }, name: { type: "string", default: "fas fa-rocket" }, - url: { type: "object", default: {} }, + qubelyIconUrl: { type: "object", default: {} }, alignment: { type: "object", default: { md: "center" }, diff --git a/qubely.php b/qubely.php index b5fdfd6d..fdf06550 100644 --- a/qubely.php +++ b/qubely.php @@ -3,7 +3,7 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.4 + * Version: 1.8.5 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely @@ -24,7 +24,7 @@ function qubely_language_load() } // Define Version -define('QUBELY_VERSION', '1.8.4'); +define('QUBELY_VERSION', '1.8.5'); // Define License define('QUBELY_LICENSE', 'free'); From 2bbfcc9250c626e330707a1f2e7fd1d98a5c2c4d Mon Sep 17 00:00:00 2001 From: sifat009 Date: Thu, 2 Feb 2023 22:39:47 +0600 Subject: [PATCH 08/43] Updated README.txt with the latest changes --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 76dbcd37..c1e35e16 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 Tested up to: 6.0.1 -Stable tag: 1.8.4 +Stable tag: 1.8.5 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt From d00cf5f45a53aa620b11148d7620f25fabab9a38 Mon Sep 17 00:00:00 2001 From: sifat009 Date: Mon, 6 Feb 2023 14:54:51 +0600 Subject: [PATCH 09/43] Updated README.txt --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index c1e35e16..fa82f37a 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: themeum Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 -Tested up to: 6.0.1 +Tested up to: 6.1.1 Stable tag: 1.8.5 Requires PHP: 7.0 License: GPL-2.0+ From 5cc8fbe94f6123e107a8e8892b92b5c8dced220f Mon Sep 17 00:00:00 2001 From: sifat009 Date: Wed, 8 Feb 2023 12:36:40 +0600 Subject: [PATCH 10/43] Added latest changelog --- readme.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.txt b/readme.txt index fa82f37a..cce818fa 100644 --- a/readme.txt +++ b/readme.txt @@ -239,6 +239,12 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.5 = +New: Jetpack compatibility is introduced +Update: All Stylesheet and Script libraries are updated to the latest version +Update: More security improvements is introduced +Fix: Form Builder had an issue with the Recipient Email input field + = 1.8.4 = Update: Implemented more security update for improved security New: Introduced "Deprecation" in case of the "Block Recovery Issue" for Update From 8daacf1dc0a7bf8528c8139b77182ac90058ac55 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 6 Jul 2023 15:53:20 +0600 Subject: [PATCH 11/43] contact form vulnerability issue fixed and b uild packege file updated --- assets/js/blocks/contactform.js | 1 + assets/reactjs/package.json | 2 +- assets/reactjs/src/blocks/contactform/Save.js | 1 + .../reactjs/src/blocks/contactform/index.js | 1 + core/QUBELY.php | 247 +++++++++------- package.json | 3 +- qubely.php | 275 +++++++++--------- 7 files changed, 281 insertions(+), 249 deletions(-) diff --git a/assets/js/blocks/contactform.js b/assets/js/blocks/contactform.js index 93c5edce..51342aaa 100644 --- a/assets/js/blocks/contactform.js +++ b/assets/js/blocks/contactform.js @@ -5,6 +5,7 @@ jQuery(function ($) { $('.qubely-block-contact-form form.qubely-form:not(.qubely-form-ready)').each(function () { + const $form = $(this); $form.addClass('qubely-form-ready'); $form.find('input.qubely-form-control').on('keydown', (e) => { diff --git a/assets/reactjs/package.json b/assets/reactjs/package.json index 5b59eba3..c10a4901 100755 --- a/assets/reactjs/package.json +++ b/assets/reactjs/package.json @@ -6,7 +6,7 @@ "scripts": { "start": "webpack --watch", "test": "echo \"Error: no test specified\" && exit 1", - "build": "NODE_ENV=production webpack --config ./webpack.production.config.js" + "build": "NODE_ENV=production webpack --config ./webpack.production.config.js && gulp sass" }, "author": "themeum", "license": "ISC", diff --git a/assets/reactjs/src/blocks/contactform/Save.js b/assets/reactjs/src/blocks/contactform/Save.js index d58e6605..7ab9442e 100644 --- a/assets/reactjs/src/blocks/contactform/Save.js +++ b/assets/reactjs/src/blocks/contactform/Save.js @@ -128,6 +128,7 @@ class Save extends Component { buttonTag={buttonTag} /> + + diff --git a/core/QUBELY.php b/core/QUBELY.php index 0ba9549c..ad938f83 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -63,9 +63,11 @@ public function __construct() { add_action( 'wp_ajax_qubely_get_saved_block', array( $this, 'qubely_get_saved_block' ) ); add_action( 'wp_ajax_qubely_delete_saved_block', array( $this, 'qubely_delete_saved_block' ) ); - - add_action( 'wp_ajax_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); - add_action( 'wp_ajax_nopriv_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); + + add_action( 'wp_ajax_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); + add_action( 'wp_ajax_nopriv_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); + + add_action( 'wp_ajax_qubely_add_to_cart', array( $this, 'qubely_add_to_cart' ) ); add_action( 'wp_ajax_nopriv_qubely_add_to_cart', array( $this, 'qubely_add_to_cart' ) ); @@ -740,6 +742,7 @@ public function qubely_enqueue_scripts() { } if ( has_block( 'qubely/contactform' ) || has_block( 'qubely/form' ) || $this->has_block_in_reusable( 'qubely/contactform' ) || $this->has_block_in_reusable( 'qubely/form' ) ) { wp_enqueue_script( 'qubely-block-contactform' ); + } if ( has_block( 'qubely/imagecomparison' ) || $this->has_block_in_reusable( 'qubely/imagecomparison' ) ) { wp_enqueue_script( 'qubely-block-image-comparison' ); @@ -1966,123 +1969,149 @@ public function sanitize_form_array( $input = array() ) { * @return boolean,void Return false if failure, echo json on success */ - public function qubely_send_form_data() { - - // Verify the authenticity of the request. - check_ajax_referer( 'qubely_nonce', 'security' ); - - // All good, let's proceed. - if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { - $captcha = $_POST['captcha']; - $secretKey = $_POST['recaptcha-secret-key']; - $verify = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captcha}" ); - - if ( ! is_array( $verify ) || ! isset( $verify['body'] ) ) { - wp_send_json( __( 'Cannot validate captcha', 'qubely' ), 400 ); - } - - $verified = json_decode( $verify['body'] ); - if ( ! $verified->success ) { - wp_send_json( __( 'Captcha validation error', 'qubely' ), 400 ); - } - } - - // setting from options. - $qubely_options = maybe_unserialize( get_option( 'qubely_options' ) ); - $emailFrom = isset( $qubely_options['form_from_email'] ) ? sanitize_email( $qubely_options['form_from_email'] ) : sanitize_email( get_option( 'admin_email' ) ); - $fromName = isset( $qubely_options['form_from_name'] ) ? sanitize_text_field( $qubely_options['form_from_name'] ) : sanitize_text_field( get_option( 'blogname' ) ); - - $default_receiver = sanitize_email( get_option( 'admin_email' ) ); - - // Settings data - $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; - $formSuccessMessage = ( $_POST['form-success-message'] ) ? sanitize_text_field( $_POST['form-success-message'] ) : ''; - $formErrorMessage = ( $_POST['form-error-message'] ) ? sanitize_text_field( $_POST['form-error-message'] ) : ''; - $emailReceiver = ( $_POST['email-receiver'] ) ? sanitize_email( $_POST['email-receiver'] ) : $default_receiver; - $emailHeaders = ( $_POST['email-headers'] ) ? sanitize_textarea_field( $_POST['email-headers'] ) : ''; - $emailSubject = ( $_POST['email-subject'] ) ? sanitize_text_field( $_POST['email-subject'] ) : ''; - $emailBody = ( $_POST['email-body'] ) ? wp_kses_post( $_POST['email-body'] ) : ''; + public function qubely_send_form_data() { + + $url = wp_get_referer(); + $post_id = url_to_postid( $url ); + + // Retrieve the post content + $post_content = get_post_field('post_content', $post_id); - $fieldNames = array(); - $validation = false; - $formInputArray = $this->sanitize_form_array( $_POST['qubely-form-input'] ); - - foreach ( $formInputArray as $key => $value ) { - if ( preg_match( '/[*]$/', $key ) ) { - if ( empty( $value ) ) { - $validation = true; + // Parse the content into blocks + $blocks = parse_blocks($post_content); + + // Check if the specific block exists + $block_exists = false; + foreach ($blocks as $block) { + if ($block['blockName'] === 'qubely/contactform' || 'qubely/form') { + $block_exists = true; + break; + } - $key = str_replace( '*', '', $key ); } - $fieldNames[ $key ] = $value; - - // if ($key == 'email') { - // $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); - // } - } - - if ( $validation || ( isset( $_POST['qubely-form-has-policy'] ) && empty( $_POST['qubely-form-has-policy'] ) ) ) { - wp_send_json( __( $formErrorMessage, 'qubely' ), 400 ); - } - - $replyToMail = $replyToName = $cc = $bcc = ''; - - $emailHeaders = explode( "\n", $emailHeaders ); - foreach ( $emailHeaders as $_header ) { - $_header = explode( ':', $_header ); - if ( count( $_header ) > 0 ) { - if ( strtolower( $_header[0] ) == 'reply-to' ) { - $replyToMail = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + if($block_exists == false){ + return ; + } + + // Verify the authenticity of the request. + check_ajax_referer( 'qubely_nonce', 'security'); + + // All good, let's proceed. + if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { + $captcha = $_POST['captcha']; + $secretKey = $_POST['recaptcha-secret-key']; + $verify = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captcha}" ); + + if ( ! is_array( $verify ) || ! isset( $verify['body'] ) ) { + wp_send_json( __( 'Cannot validate captcha', 'qubely' ), 400 ); } - if ( strtolower( $_header[0] ) == 'reply-name' ) { - $replyToName = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + + $verified = json_decode( $verify['body'] ); + if ( ! $verified->success ) { + wp_send_json( __( 'Captcha validation error', 'qubely' ), 400 ); } - if ( strtolower( $_header[0] ) == 'cc' ) { - $cc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + } + + // setting from options. + $qubely_options = maybe_unserialize( get_option( 'qubely_options' ) ); + $emailFrom = isset( $qubely_options['form_from_email'] ) ? sanitize_email( $qubely_options['form_from_email'] ) : sanitize_email( get_option( 'admin_email' ) ); + $fromName = isset( $qubely_options['form_from_name'] ) ? sanitize_text_field( $qubely_options['form_from_name'] ) : sanitize_text_field( get_option( 'blogname' ) ); + + $default_receiver = sanitize_email( get_option( 'admin_email' ) ); + + // Settings data + $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; + $formSuccessMessage = ( $_POST['form-success-message'] ) ? sanitize_text_field( $_POST['form-success-message'] ) : ''; + $formErrorMessage = ( $_POST['form-error-message'] ) ? sanitize_text_field( $_POST['form-error-message'] ) : ''; + $emailReceiver = ( $_POST['email-receiver'] ) ? sanitize_email( $_POST['email-receiver'] ) : $default_receiver; + $emailHeaders = ( $_POST['email-headers'] ) ? sanitize_textarea_field( $_POST['email-headers'] ) : ''; + $emailSubject = ( $_POST['email-subject'] ) ? sanitize_text_field( $_POST['email-subject'] ) : ''; + $emailBody = ( $_POST['email-body'] ) ? wp_kses_post( $_POST['email-body'] ) : ''; + + $fieldNames = array(); + $validation = false; + $formInputArray = $this->sanitize_form_array( $_POST['qubely-form-input'] ); + + foreach ( $formInputArray as $key => $value ) { + if ( preg_match( '/[*]$/', $key ) ) { + if ( empty( $value ) ) { + $validation = true; + } + $key = str_replace( '*', '', $key ); } - if ( strtolower( $_header[0] ) == 'bcc' ) { - $bcc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + $fieldNames[ $key ] = $value; + + // if ($key == 'email') { + // $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); + // } + } + + if ( $validation || ( isset( $_POST['qubely-form-has-policy'] ) && empty( $_POST['qubely-form-has-policy'] ) ) ) { + wp_send_json( __( $formErrorMessage, 'qubely' ), 400 ); + } + + $replyToMail = $replyToName = $cc = $bcc = ''; + + $emailHeaders = explode( "\n", $emailHeaders ); + foreach ( $emailHeaders as $_header ) { + $_header = explode( ':', $_header ); + if ( count( $_header ) > 0 ) { + if ( strtolower( $_header[0] ) == 'reply-to' ) { + $replyToMail = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + } + if ( strtolower( $_header[0] ) == 'reply-name' ) { + $replyToName = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + } + if ( strtolower( $_header[0] ) == 'cc' ) { + $cc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + } + if ( strtolower( $_header[0] ) == 'bcc' ) { + $bcc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; + } } } - } - - foreach ( $fieldNames as $name => $value ) { - $value = is_array( $fieldNames[ $name ] ) ? implode( ', ', $fieldNames[ $name ] ) : $value; - $emailBody = str_replace( '{{' . $name . '}}', sanitize_textarea_field( $value ), $emailBody ); - $emailSubject = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $emailSubject ); - $replyToName = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToName ); - $replyToMail = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToMail ); - $cc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $cc ); - $bcc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $bcc ); - } - - // Subject Structure - $siteName = isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( $_SERVER['SERVER_NAME'] ) : ''; - $emailSubject = str_replace( '{{site-name}}', $siteName, $emailSubject ); - - $headers[] = 'Content-Type: text/html; charset=UTF-8'; - $headers[] = 'From: ' . $fromName . ' <' . $emailFrom . '>'; - $headers[] = 'Reply-To: ' . $replyToName . ' <' . $replyToMail . '>'; - $headers[] = 'Cc: ' . $cc; - $headers[] = 'Bcc: ' . $bcc; - - // Send E-Mail Now or through error msg. - try { - $isMail = wp_mail( $emailReceiver, $emailSubject, $emailBody, $headers ); - if ( $isMail ) { - $responseData['status'] = 1; - $responseData['msg'] = __( $formSuccessMessage, 'qubely' ); - } else { + + foreach ( $fieldNames as $name => $value ) { + $value = is_array( $fieldNames[ $name ] ) ? implode( ', ', $fieldNames[ $name ] ) : $value; + $emailBody = str_replace( '{{' . $name . '}}', sanitize_textarea_field( $value ), $emailBody ); + $emailSubject = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $emailSubject ); + $replyToName = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToName ); + $replyToMail = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToMail ); + $cc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $cc ); + $bcc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $bcc ); + } + + // Subject Structure + $siteName = isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( $_SERVER['SERVER_NAME'] ) : ''; + $emailSubject = str_replace( '{{site-name}}', $siteName, $emailSubject ); + + $headers[] = 'Content-Type: text/html; charset=UTF-8'; + $headers[] = 'From: ' . $fromName . ' <' . $emailFrom . '>'; + $headers[] = 'Reply-To: ' . $replyToName . ' <' . $replyToMail . '>'; + $headers[] = 'Cc: ' . $cc; + $headers[] = 'Bcc: ' . $bcc; + + // Send E-Mail Now or through error msg. + try { + $isMail = wp_mail( $emailReceiver, $emailSubject, $emailBody, $headers ); + if ( $isMail ) { + $responseData['status'] = 1; + $responseData['msg'] = __( $formSuccessMessage, 'qubely' ); + } else { + $responseData['status'] = 0; + $responseData['msg'] = __( $formErrorMessage, 'qubely' ); + } + wp_send_json_success( $responseData ); + } catch ( \Exception $e ) { $responseData['status'] = 0; - $responseData['msg'] = __( $formErrorMessage, 'qubely' ); + $responseData['msg'] = $e->getMessage(); + wp_send_json_error( $responseData ); } - wp_send_json_success( $responseData ); - } catch ( \Exception $e ) { - $responseData['status'] = 0; - $responseData['msg'] = $e->getMessage(); - wp_send_json_error( $responseData ); + + } - } + + /** * Ajax add to cart button diff --git a/package.json b/package.json index 86b1d10f..4995c917 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "merge-stream": "^2.0.0" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "prebuild": "cd ./assets/reactjs && npm run build", + "build": "npm run prebuild && gulp" }, "repository": { "type": "git", diff --git a/qubely.php b/qubely.php index fdf06550..82acd7b8 100644 --- a/qubely.php +++ b/qubely.php @@ -3,37 +3,37 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.5 + * Version: 1.8.6 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely * Requires at least: 5.3 - * Tested up to: 6.0.1 + * Tested up to: 6.2 * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ -if (!defined('ABSPATH')) { - exit; // Exit if accessed directly +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly } // Language Load -add_action('init', 'qubely_language_load'); -function qubely_language_load() -{ - load_plugin_textdomain('qubely', false, basename(dirname(__FILE__)) . '/languages/'); +add_action( 'init', 'qubely_language_load' ); +function qubely_language_load() { + load_plugin_textdomain( 'qubely', false, basename( dirname( __FILE__ ) ) . '/languages/' ); } // Define Version -define('QUBELY_VERSION', '1.8.5'); +define( 'QUBELY_VERSION', '1.8.5' ); // Define License -define('QUBELY_LICENSE', 'free'); +define( 'QUBELY_LICENSE', 'free' ); // Define Dir URL -define('QUBELY_DIR_URL', plugin_dir_url(__FILE__)); +define( 'QUBELY_DIR_URL', plugin_dir_url( __FILE__ ) ); // Define Physical Path -define('QUBELY_DIR_PATH', plugin_dir_path(__FILE__)); +define( 'QUBELY_DIR_PATH', plugin_dir_path( __FILE__ ) ); + // Include Require File require_once QUBELY_DIR_PATH . 'core/initial-setup.php'; // Initial Setup Data @@ -44,19 +44,19 @@ function qubely_language_load() require_once QUBELY_DIR_PATH . 'core/Options.php'; // Loading QUBELY Blocks Main Files // Page Template Added -require_once QUBELY_DIR_PATH.'core/Template.php'; +require_once QUBELY_DIR_PATH . 'core/Template.php'; -if (class_exists('QUBELY_Options')){ - new QUBELY_Options(); +if ( class_exists( 'QUBELY_Options' ) ) { + new QUBELY_Options(); } // Version Check & Include Core -if (!version_compare(PHP_VERSION, '5.4', '>=')) { - add_action('admin_notices', array('QUBELY_Initial_Setup', 'php_error_notice')); // PHP Version Check -} elseif (!version_compare(get_bloginfo('version'), '4.7', '>=')) { - add_action('admin_notices', array('QUBELY_Initial_Setup', 'wordpress_error_notice')); // WordPress Version Check +if ( ! version_compare( PHP_VERSION, '5.4', '>=' ) ) { + add_action( 'admin_notices', array( 'QUBELY_Initial_Setup', 'php_error_notice' ) ); // PHP Version Check +} elseif ( ! version_compare( get_bloginfo( 'version' ), '4.7', '>=' ) ) { + add_action( 'admin_notices', array( 'QUBELY_Initial_Setup', 'wordpress_error_notice' ) ); // WordPress Version Check } else { - require_once QUBELY_DIR_PATH . 'core/QUBELY.php'; // Loading QUBELY Blocks Main Files + require_once QUBELY_DIR_PATH . 'core/QUBELY.php'; // Loading QUBELY Blocks Main Files } function qubely_blocks_add_orderby( $params ) { @@ -73,156 +73,155 @@ function qubely_blocks_add_orderby( $params ) { * @since 1.0.9 */ function qubely_register_rest_fields() { - $post_types = QUBELY_MAIN::get_post_types(); - - foreach ( $post_types as $key => $value ) { - - // Featured image. - register_rest_field( - $value['value'], - 'qubely_featured_image_url', - array( - 'get_callback' => 'qubely_get_featured_image_url', - 'update_callback' => null, - 'schema' => array( - 'description' => __('Different sized featured images'), - 'type' => 'array', - ), - ) - ); - // Author info. - register_rest_field( - $value['value'], - 'qubely_author', - array( - 'get_callback' => 'qubely_get_author_info', - 'update_callback' => null, - 'schema' => null, - ) - ); - - // Add comment info. - register_rest_field( - $value['value'], - 'qubely_comment', - array( - 'get_callback' => 'qubely_get_comment_info', - 'update_callback' => null, - 'schema' => null, - ) - ); - - // Category links. - register_rest_field( - $value['value'], - 'qubely_category', - array( - 'get_callback' => 'qubely_get_category_list', - 'update_callback' => null, - 'schema' => array( - 'description' => __('Category list links'), - 'type' => 'string', - ), - ) - ); - - // Excerpt. - register_rest_field( - $value['value'], - 'qubely_excerpt', - array( - 'get_callback' => 'qubely_get_excerpt', - 'update_callback' => null, - 'schema' => null, - ) - ); - } + $post_types = QUBELY_MAIN::get_post_types(); + + foreach ( $post_types as $key => $value ) { + + // Featured image. + register_rest_field( + $value['value'], + 'qubely_featured_image_url', + array( + 'get_callback' => 'qubely_get_featured_image_url', + 'update_callback' => null, + 'schema' => array( + 'description' => __( 'Different sized featured images' ), + 'type' => 'array', + ), + ) + ); + // Author info. + register_rest_field( + $value['value'], + 'qubely_author', + array( + 'get_callback' => 'qubely_get_author_info', + 'update_callback' => null, + 'schema' => null, + ) + ); + + // Add comment info. + register_rest_field( + $value['value'], + 'qubely_comment', + array( + 'get_callback' => 'qubely_get_comment_info', + 'update_callback' => null, + 'schema' => null, + ) + ); + + // Category links. + register_rest_field( + $value['value'], + 'qubely_category', + array( + 'get_callback' => 'qubely_get_category_list', + 'update_callback' => null, + 'schema' => array( + 'description' => __( 'Category list links' ), + 'type' => 'string', + ), + ) + ); + + // Excerpt. + register_rest_field( + $value['value'], + 'qubely_excerpt', + array( + 'get_callback' => 'qubely_get_excerpt', + 'update_callback' => null, + 'schema' => null, + ) + ); + } } // Author. function qubely_get_author_info( $object ) { - $author = ( isset( $object['author'] ) ) ? $object['author'] : ''; + $author = ( isset( $object['author'] ) ) ? $object['author'] : ''; + + $author_data['display_name'] = get_the_author_meta( 'display_name', $author ); + $author_data['author_link'] = get_author_posts_url( $author ); - $author_data['display_name'] = get_the_author_meta( 'display_name', $author ) ; - $author_data['author_link'] = get_author_posts_url( $author ); - - return $author_data; + return $author_data; } // Comment. function qubely_get_comment_info( $object ) { - $comments_count = wp_count_comments( $object['id'] ); - return $comments_count->total_comments; + $comments_count = wp_count_comments( $object['id'] ); + return $comments_count->total_comments; } // Category list. -if ( !function_exists( 'qubely_get_category_list' ) ) { - function qubely_get_category_list( $object ) { - $taxonomies = get_post_taxonomies( $object['id'] ); - if ( 'post' === get_post_type() ) { - return get_the_category_list( esc_html__(' '), '', $object['id'] ); - } else { - if ( ! empty( $taxonomies ) ) { - return get_the_term_list( $object['id'], $taxonomies[0], ' ' ); - } - } - } +if ( ! function_exists( 'qubely_get_category_list' ) ) { + function qubely_get_category_list( $object ) { + $taxonomies = get_post_taxonomies( $object['id'] ); + if ( 'post' === get_post_type() ) { + return get_the_category_list( esc_html__( ' ' ), '', $object['id'] ); + } else { + if ( ! empty( $taxonomies ) ) { + return get_the_term_list( $object['id'], $taxonomies[0], ' ' ); + } + } + } } // Feature image. function qubely_get_featured_image_url( $object ) { - $featured_images = array(); - if ( ! isset( $object['featured_media'] ) ) { - return $featured_images; - } else { - $image = wp_get_attachment_image_src( $object['featured_media'], 'full', false ); - if ( is_array( $image ) ) { - $featured_images['full'] = $image; - $featured_images['landscape'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_landscape', false ); - $featured_images['portraits'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_portrait', false ); - $featured_images['thumbnail'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_thumbnail', false ); - - $image_sizes = QUBELY_MAIN::get_all_image_sizes(); - foreach ( $image_sizes as $key => $value ) { - $size = $value['value']; - $featured_images[$size] = wp_get_attachment_image_src( - $object['featured_media'], - $size, - false - ); - } - return $featured_images; - } - } + $featured_images = array(); + if ( ! isset( $object['featured_media'] ) ) { + return $featured_images; + } else { + $image = wp_get_attachment_image_src( $object['featured_media'], 'full', false ); + if ( is_array( $image ) ) { + $featured_images['full'] = $image; + $featured_images['landscape'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_landscape', false ); + $featured_images['portraits'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_portrait', false ); + $featured_images['thumbnail'] = wp_get_attachment_image_src( $object['featured_media'], 'qubely_thumbnail', false ); + + $image_sizes = QUBELY_MAIN::get_all_image_sizes(); + foreach ( $image_sizes as $key => $value ) { + $size = $value['value']; + $featured_images[ $size ] = wp_get_attachment_image_src( + $object['featured_media'], + $size, + false + ); + } + return $featured_images; + } + } } // Excerpt. function qubely_get_excerpt( $object ) { - $excerpt = wp_trim_words( get_the_excerpt( $object['id'] ) ); - if ( ! $excerpt ) { - $excerpt = null; - } - return $excerpt; + $excerpt = wp_trim_words( get_the_excerpt( $object['id'] ) ); + if ( ! $excerpt ) { + $excerpt = null; + } + return $excerpt; } add_action( 'rest_api_init', 'qubely_register_rest_fields' ); /** - * Order by + * Order by */ function qubely_resigter_rest_order_by_fields() { - $post_types = QUBELY_MAIN::get_post_types(); + $post_types = QUBELY_MAIN::get_post_types(); - foreach ( $post_types as $key => $type ) { + foreach ( $post_types as $key => $type ) { add_filter( "rest_{$type['value']}_collection_params", 'qubely_blocks_add_orderby', 10, 1 ); } } add_action( 'init', 'qubely_resigter_rest_order_by_fields' ); -function qubely_blog_posts_image_sizes() -{ - add_image_size( 'qubely_landscape', 1200, 750, true ); - add_image_size( 'qubely_portrait', 540, 320, true ); - add_image_size( 'qubely_thumbnail', 140, 100, true ); +function qubely_blog_posts_image_sizes() { + add_image_size( 'qubely_landscape', 1200, 750, true ); + add_image_size( 'qubely_portrait', 540, 320, true ); + add_image_size( 'qubely_thumbnail', 140, 100, true ); } add_action( 'after_setup_theme', 'qubely_blog_posts_image_sizes' ); From c15653a2eb1b536c676bd22a72bb918bddc3cc13 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Mon, 10 Jul 2023 13:09:36 +0600 Subject: [PATCH 12/43] security updated and readme file updated --- core/QUBELY.php | 8 +++++++- readme.txt | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index ad938f83..26d8f0b1 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -1979,11 +1979,15 @@ public function qubely_send_form_data() { // Parse the content into blocks $blocks = parse_blocks($post_content); + + // Check if the specific block exists $block_exists = false; foreach ($blocks as $block) { + if ($block['blockName'] === 'qubely/contactform' || 'qubely/form') { + $get_reciveremail= $block['attrs']['emailReceiver']; $block_exists = true; break; @@ -2023,7 +2027,9 @@ public function qubely_send_form_data() { $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; $formSuccessMessage = ( $_POST['form-success-message'] ) ? sanitize_text_field( $_POST['form-success-message'] ) : ''; $formErrorMessage = ( $_POST['form-error-message'] ) ? sanitize_text_field( $_POST['form-error-message'] ) : ''; - $emailReceiver = ( $_POST['email-receiver'] ) ? sanitize_email( $_POST['email-receiver'] ) : $default_receiver; + + $emailReceiver = isset( $get_reciveremail) ? sanitize_email( $get_reciveremail ) : $default_receiver; + $emailHeaders = ( $_POST['email-headers'] ) ? sanitize_textarea_field( $_POST['email-headers'] ) : ''; $emailSubject = ( $_POST['email-subject'] ) ? sanitize_text_field( $_POST['email-subject'] ) : ''; $emailBody = ( $_POST['email-body'] ) ? wp_kses_post( $_POST['email-body'] ) : ''; diff --git a/readme.txt b/readme.txt index cce818fa..4d63af4f 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: themeum Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 -Tested up to: 6.1.1 -Stable tag: 1.8.5 +Tested up to: 6.2 +Stable tag: 1.8.6 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt @@ -239,6 +239,9 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.6 = +Update: Addressed security vulnerability issue + = 1.8.5 = New: Jetpack compatibility is introduced Update: All Stylesheet and Script libraries are updated to the latest version From 873f57c4eb6747bba03f5f0435f1fbea75773e42 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Mon, 10 Jul 2023 16:21:47 +0600 Subject: [PATCH 13/43] code formatted --- assets/js/blocks/contactform.js | 1 - assets/reactjs/src/blocks/contactform/Save.js | 3 +- .../reactjs/src/blocks/contactform/index.js | 1 - core/QUBELY.php | 543 +++++++++--------- 4 files changed, 272 insertions(+), 276 deletions(-) diff --git a/assets/js/blocks/contactform.js b/assets/js/blocks/contactform.js index 51342aaa..93c5edce 100644 --- a/assets/js/blocks/contactform.js +++ b/assets/js/blocks/contactform.js @@ -5,7 +5,6 @@ jQuery(function ($) { $('.qubely-block-contact-form form.qubely-form:not(.qubely-form-ready)').each(function () { - const $form = $(this); $form.addClass('qubely-form-ready'); $form.find('input.qubely-form-control').on('keydown', (e) => { diff --git a/assets/reactjs/src/blocks/contactform/Save.js b/assets/reactjs/src/blocks/contactform/Save.js index 7ab9442e..4f4f9f09 100644 --- a/assets/reactjs/src/blocks/contactform/Save.js +++ b/assets/reactjs/src/blocks/contactform/Save.js @@ -127,8 +127,7 @@ class Save extends Component { buttonIconPosition={buttonIconPosition} buttonTag={buttonTag} /> - - + - diff --git a/core/QUBELY.php b/core/QUBELY.php index 26d8f0b1..7897944d 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -32,7 +32,7 @@ public function __construct() { if ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) { add_filter( 'block_categories_all', array( $this, 'qubely_block_categories' ), 1, 2 ); } else { - add_filter( 'block_categories', array( $this, 'qubely_block_categories' ), 1, 2 ); + add_filter( 'block_categories', array( $this, 'qubely_block_categories' ), 1, 2 ); } // Add Styles and Scripts @@ -63,11 +63,9 @@ public function __construct() { add_action( 'wp_ajax_qubely_get_saved_block', array( $this, 'qubely_get_saved_block' ) ); add_action( 'wp_ajax_qubely_delete_saved_block', array( $this, 'qubely_delete_saved_block' ) ); - - add_action( 'wp_ajax_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); - add_action( 'wp_ajax_nopriv_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); - - + + add_action( 'wp_ajax_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); + add_action( 'wp_ajax_nopriv_qubely_send_form_data', array( $this, 'qubely_send_form_data' ) ); add_action( 'wp_ajax_qubely_add_to_cart', array( $this, 'qubely_add_to_cart' ) ); add_action( 'wp_ajax_nopriv_qubely_add_to_cart', array( $this, 'qubely_add_to_cart' ) ); @@ -116,9 +114,9 @@ public function qubely_global_container_width() { /** * Qubely editor body class - * + * * @param string|mixed $classes - * + * * @return string|mixed $classes */ public function qubely_editor_bodyclass( $classes ) { @@ -133,30 +131,30 @@ public function qubely_editor_bodyclass( $classes ) { /** * Add custom classes - * + * * @param array $classes - * + * * @return array $classes */ public function add_custom_class( $classes ) { return array_merge( $classes, array( 'qubely qubely-frontend' ) ); } - + /** * Create preview CSS */ public function create_preview_css() { - + global $wp_filesystem; if ( ! $wp_filesystem ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $upload_dir = wp_upload_dir(); WP_Filesystem( false, $upload_dir['basedir'], true ); - $dir = trailingslashit( $upload_dir['basedir'] ) . 'qubely/'; + $dir = trailingslashit( $upload_dir['basedir'] ) . 'qubely/'; - $filename = "qubely-preview.css"; - $jsonfilename = "qubely-preview.json"; + $filename = 'qubely-preview.css'; + $jsonfilename = 'qubely-preview.json'; if ( ! $wp_filesystem->is_dir( $dir ) ) { $wp_filesystem->mkdir( $dir ); @@ -173,14 +171,14 @@ public function create_preview_css() { } } } - + /** * Init dynamic blocks frontend */ public function init_dynamic_blocks() { require_once QUBELY_DIR_PATH . 'core/blocks/postgrid.php'; $this->create_preview_css(); - } + } /** * Load Editor Styles and Scripts @@ -268,8 +266,8 @@ public function getSvgDivider() { /** * Parse all blocks - * - * * @since 1.6.5 + * + * * @since 1.6.5 */ public function parse_all_blocks() { $blocks; @@ -291,14 +289,14 @@ public function parse_all_blocks() { /** * Load font-awesome CSS - * - * * @since 1.6.5 + * + * * @since 1.6.5 */ public function qubely_load_fontawesome() { - $option_data = get_option( 'qubely_options' ); + $option_data = get_option( 'qubely_options' ); $load_font_awesome = isset( $option_data['load_font_awesome_CSS'] ) ? sanitize_text_field( $option_data['load_font_awesome_CSS'] ) : 'yes'; if ( $load_font_awesome == 'yes' ) { - $blocks = $this->parse_all_blocks(); + $blocks = $this->parse_all_blocks(); $contains_qubely_blocks = $this->has_blocks_with_fontawesome( $blocks ); if ( $contains_qubely_blocks ) { } @@ -307,32 +305,37 @@ public function qubely_load_fontawesome() { } public function colsFromArray( array $array, $keys ) { - if ( ! is_array( $keys ) ) $keys = [ $keys ]; - return array_map( function ( $el ) use ( $keys ) { - $o = []; - foreach( $keys as $key ) { - // if(isset($el[$key]))$o[$key] = $el[$key]; //you can do it this way if you don't want to set a default for missing keys. - $o[ $key ] = isset( $el[ $key ] ) ? $el[ $key ] : false; - } - return $o; - }, $array ); + if ( ! is_array( $keys ) ) { + $keys = array( $keys ); + } + return array_map( + function ( $el ) use ( $keys ) { + $o = array(); + foreach ( $keys as $key ) { + // if(isset($el[$key]))$o[$key] = $el[$key]; //you can do it this way if you don't want to set a default for missing keys. + $o[ $key ] = isset( $el[ $key ] ) ? $el[ $key ] : false; + } + return $o; + }, + $array + ); } /** * Get block google fonts */ - public function gather_block_fonts( $blocks,$block_fonts ) { + public function gather_block_fonts( $blocks, $block_fonts ) { $google_fonts = $block_fonts; foreach ( $blocks as $key => $block ) { if ( strpos( $block['blockName'], 'qubely' ) !== false ) { - foreach ( $block['attrs'] as $key => $att ) { + foreach ( $block['attrs'] as $key => $att ) { if ( gettype( $att ) == 'array' && isset( $att['openTypography'] ) && isset( $att['family'] ) ) { if ( isset( $block['attrs'][ $key ]['activeSource'] ) ) { if ( $block['attrs'][ $key ]['activeSource'] == 'custom' ) { - array_push( $google_fonts,$block['attrs'][ $key ]['family'] ); + array_push( $google_fonts, $block['attrs'][ $key ]['family'] ); } } else { - array_push( $google_fonts,$block['attrs'][ $key ]['family'] ); + array_push( $google_fonts, $block['attrs'][ $key ]['family'] ); } } } @@ -340,7 +343,7 @@ public function gather_block_fonts( $blocks,$block_fonts ) { if ( isset( $block['innerBlocks'] ) && gettype( $block['innerBlocks'] ) == 'array' && count( $block['innerBlocks'] ) > 0 ) { $child_fonts = $this->gather_block_fonts( $block['innerBlocks'], $google_fonts ); if ( count( $child_fonts ) > 0 ) { - $google_fonts= array_merge( $google_fonts, $child_fonts ); + $google_fonts = array_merge( $google_fonts, $child_fonts ); } } } @@ -350,9 +353,9 @@ public function gather_block_fonts( $blocks,$block_fonts ) { /** * Check whether post contains * any qubely blocks - * + * * @param array $blocks - * + * * @return bool */ public function has_qubely_blocks( $blocks ) { @@ -371,14 +374,14 @@ public function has_qubely_blocks( $blocks ) { /** * Check whether post contains * any qubely blocks with Font-awesome - * + * * @param array $blocks - * + * * @return bool */ public function has_blocks_with_fontawesome( $blocks ) { $has_fontawesome_block = false; - $target_blocks = array( + $target_blocks = array( 'qubely/icon', 'qubely/accordion', 'qubely/advancedlist', @@ -387,14 +390,14 @@ public function has_blocks_with_fontawesome( $blocks ) { 'qubely/pricing', 'qubely/socialicons', 'qubely/tabs', - 'qubely/timeline', + 'qubely/timeline', 'qubely/testimonial', 'qubely/team', 'qubely/woocarousel', 'qubely/testimonialcarousel', 'qubely/teamcarousel', 'qubely/table', - 'qubely/postcarousel', + 'qubely/postcarousel', 'qubely/imagecarousel', 'qubely/verticaltabs', 'qubely/form', @@ -421,30 +424,30 @@ public function has_blocks_with_fontawesome( $blocks ) { /** * Load Google fonts - * + * * @since 1.6.5 */ public function qubely_load_googlefonts() { - //Global settings fonts + // Global settings fonts $blocks; $contains_qubely_blocks = false; - $block_fonts = []; - $option_data = get_option( 'qubely_options' ); - $load_google_fonts = isset( $option_data['load_google_fonts'] ) ? sanitize_text_field( $option_data['load_google_fonts'] ) : 'yes'; + $block_fonts = array(); + $option_data = get_option( 'qubely_options' ); + $load_google_fonts = isset( $option_data['load_google_fonts'] ) ? sanitize_text_field( $option_data['load_google_fonts'] ) : 'yes'; if ( $load_google_fonts == 'yes' ) { - $blocks = $this->parse_all_blocks(); + $blocks = $this->parse_all_blocks(); $contains_qubely_blocks = $this->has_qubely_blocks( $blocks ); if ( $contains_qubely_blocks ) { - $block_fonts = $this->gather_block_fonts( $blocks, $block_fonts ); - $global_settings = get_option( $this->option_keyword ); - $global_settings = $global_settings == false ? json_decode( '{}' ) : json_decode( $global_settings ); - $global_settings = json_decode( json_encode( $global_settings ), true ); - $gfonts = ''; + $block_fonts = $this->gather_block_fonts( $blocks, $block_fonts ); + $global_settings = get_option( $this->option_keyword ); + $global_settings = $global_settings == false ? json_decode( '{}' ) : json_decode( $global_settings ); + $global_settings = json_decode( json_encode( $global_settings ), true ); + $gfonts = ''; $all_global_fonts = array(); if ( isset( $global_settings['presets'] ) && isset( $global_settings['presets'][ $global_settings['activePreset'] ] ) && isset( $global_settings['presets'][ $global_settings['activePreset'] ]['typography'] ) ) { - $all_global_fonts = $this->colsFromArray( array_column( $global_settings['presets'][ $global_settings['activePreset'] ]['typography'], 'value' ), ['family', 'weight'] ); + $all_global_fonts = $this->colsFromArray( array_column( $global_settings['presets'][ $global_settings['activePreset'] ]['typography'], 'value' ), array( 'family', 'weight' ) ); } if ( count( $all_global_fonts ) > 0 ) { $global_fonts = array_column( $all_global_fonts, 'family' ); @@ -507,12 +510,12 @@ public function qubely_admin_assets() { ); wp_enqueue_script( 'qubely_local_script' ); - #START_REPLACE + // START_REPLACE wp_enqueue_style( 'qubley-animated-headline-style', QUBELY_DIR_URL . 'assets/css/qubely.animatedheadline.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-animation', QUBELY_DIR_URL . 'assets/css/animation.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-magnific-popup-style', QUBELY_DIR_URL . 'assets/css/magnific-popup.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-style-min', QUBELY_DIR_URL . 'assets/css/style.min.css', false, QUBELY_VERSION ); - #END_REPLACE + // END_REPLACE wp_enqueue_style( 'qubely-font-awesome', QUBELY_DIR_URL . 'assets/css/font-awesome.min.css', false, QUBELY_VERSION ); @@ -656,42 +659,41 @@ public function qubely_enqueue_style() { * @warning: Don't Remove `START_REPLACE` and `START_REPLACE` comments. These comments are required for gulp build */ - #START_REPLACE + // START_REPLACE wp_enqueue_style( 'qubley-animated-headline-style', QUBELY_DIR_URL . 'assets/css/qubely.animatedheadline.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-animation', QUBELY_DIR_URL . 'assets/css/animation.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-magnific-popup-style', QUBELY_DIR_URL . 'assets/css/magnific-popup.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-style-min', QUBELY_DIR_URL . 'assets/css/style.min.css', false, QUBELY_VERSION ); - #END_REPLACE + // END_REPLACE - - $this->qubely_load_fontawesome(); - $this->qubely_load_googlefonts(); + $this->qubely_load_fontawesome(); + $this->qubely_load_googlefonts(); } } // Check if a block is in reusable - public function has_block_in_reusable( $block_name, $id = false ){ - $id = (!$id) ? get_the_ID() : $id; - if( $id ){ - if ( has_block( 'block', $id ) ){ + public function has_block_in_reusable( $block_name, $id = false ) { + $id = ( ! $id ) ? get_the_ID() : $id; + if ( $id ) { + if ( has_block( 'block', $id ) ) { // Check reusable blocks $content = get_post_field( 'post_content', $id ); - $blocks = parse_blocks( $content ); - + $blocks = parse_blocks( $content ); + if ( ! is_array( $blocks ) || empty( $blocks ) ) { return false; } - + foreach ( $blocks as $block ) { if ( $block['blockName'] === 'core/block' && ! empty( $block['attrs']['ref'] ) ) { - if( has_block( $block_name, $block['attrs']['ref'] ) ){ - return true; + if ( has_block( $block_name, $block['attrs']['ref'] ) ) { + return true; } } } } } - + return false; } @@ -724,7 +726,6 @@ public function qubely_enqueue_scripts() { wp_register_script( 'qubely-block-common', QUBELY_DIR_URL . 'assets/js/common-script.js', array( 'jquery' ), QUBELY_VERSION, true ); wp_register_script( 'qubely-interaction', QUBELY_DIR_URL . 'assets/js/interaction.js', array( 'jquery' ), QUBELY_VERSION, true ); - if ( is_array( $blocks_meta_data ) && count( $blocks_meta_data ) ) { $available_blocks = $blocks_meta_data['available_blocks']; $has_interaction = $blocks_meta_data['interaction']; @@ -809,10 +810,10 @@ public function qubely_enqueue_scripts() { * * @since 1.3.0 */ - public function qubely_inline_footer_scripts() { - global $wp_query; + public function qubely_inline_footer_scripts() { + global $wp_query; $is_previewing = $wp_query->is_preview(); - $can_edit = current_user_can( 'edit_posts' ); + $can_edit = current_user_can( 'edit_posts' ); if ( $is_previewing || $can_edit ) { ?> '; } - } + } } else { $post_id = $this->is_qubely_single(); if ( $post_id ) { - $css_path = $upload_css_dir . "qubely/qubely-css-{$post_id}.css"; - $json_path = $upload_css_dir . "qubely/qubely-json-{$post_id}.json"; - + $css_path = $upload_css_dir . "qubely/qubely-css-{$post_id}.css"; + $json_path = $upload_css_dir . "qubely/qubely-json-{$post_id}.json"; + if ( file_exists( $css_path ) ) { $blockCss = file_get_contents( $css_path ); echo ''; } else { echo ''; } - + if ( ! file_exists( $json_path ) ) { $this->print_interaction_json_to_header(); } else { @@ -1587,7 +1588,7 @@ public function add_block_inline_css() { } $this->add_reusable_css(); } - + } /** @@ -1640,13 +1641,13 @@ public function qubely_get_sections() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1687,13 +1688,13 @@ public function qubely_get_layouts() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1734,13 +1735,13 @@ public function qubely_get_single_layout() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1765,13 +1766,13 @@ public function qubely_get_single_section() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1829,7 +1830,7 @@ public function load_and_cache_single_layout_from_server( $layout_id = 0 ) { $post_args = array( 'timeout' => 120 ); - $body_param = array_merge( + $body_param = array_merge( $this->qubely_api_request_body_default, array( 'request_for' => 'get_single_layout', @@ -1858,13 +1859,13 @@ public function qubely_get_saved_block() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1890,13 +1891,13 @@ public function qubely_delete_saved_block() { check_ajax_referer( 'qubely_nonce', 'security' ); // It's good let's do some capability check. - $user = wp_get_current_user(); + $user = wp_get_current_user(); $allowed_roles = array( 'editor', 'administrator', 'author' ); - + if ( ! array_intersect( $allowed_roles, $user->roles ) ) { wp_die( __( 'You don\'t have permission to perform this action', 'qubely' ) ); } - + // Cool, we're almost there, let's check the user authenticity a little bit, shall we! if ( ! is_user_logged_in() && $user->ID !== sanitize_text_field( $_REQUEST['user_id'] ) ) { wp_die( __( 'You don\'t have proper authorization to perform this action', 'qubely' ) ); @@ -1962,165 +1963,163 @@ public function sanitize_form_array( $input = array() ) { return $array; } - + /** * Ajax for sending form data * * @return boolean,void Return false if failure, echo json on success */ - public function qubely_send_form_data() { - - $url = wp_get_referer(); - $post_id = url_to_postid( $url ); - - // Retrieve the post content - $post_content = get_post_field('post_content', $post_id); - - // Parse the content into blocks - $blocks = parse_blocks($post_content); - - - - // Check if the specific block exists - $block_exists = false; - foreach ($blocks as $block) { - - if ($block['blockName'] === 'qubely/contactform' || 'qubely/form') { - $get_reciveremail= $block['attrs']['emailReceiver']; - $block_exists = true; - break; - + public function qubely_send_form_data() { + + $url = wp_get_referer(); + $post_id = url_to_postid( $url ); + + // Retrieve the post content + $post_content = get_post_field( 'post_content', $post_id ); + + // Parse the content into blocks + $blocks = parse_blocks( $post_content ); + + // Check if the specific block exists + $block_exists = false; + foreach ( $blocks as $block ) { + + if ( $block['blockName'] === 'qubely/contactform' || 'qubely/form' ) { + $get_reciveremail = $block['attrs']['emailReceiver']; + $block_exists = true; + break; + + } + } + if ( $block_exists == false ) { + wp_send_json( __( 'Invalid request', 'qubely' ), 400 ); + return; + } + + // Verify the authenticity of the request. + check_ajax_referer( 'qubely_nonce', 'security' ); + + // All good, let's proceed. + if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { + $captcha = $_POST['captcha']; + $secretKey = $_POST['recaptcha-secret-key']; + $verify = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captcha}" ); + + if ( ! is_array( $verify ) || ! isset( $verify['body'] ) ) { + wp_send_json( __( 'Cannot validate captcha', 'qubely' ), 400 ); + } + + $verified = json_decode( $verify['body'] ); + if ( ! $verified->success ) { + wp_send_json( __( 'Captcha validation error', 'qubely' ), 400 ); + } + } + + // setting from options. + $qubely_options = maybe_unserialize( get_option( 'qubely_options' ) ); + $emailFrom = isset( $qubely_options['form_from_email'] ) ? sanitize_email( $qubely_options['form_from_email'] ) : sanitize_email( get_option( 'admin_email' ) ); + $fromName = isset( $qubely_options['form_from_name'] ) ? sanitize_text_field( $qubely_options['form_from_name'] ) : sanitize_text_field( get_option( 'blogname' ) ); + + $default_receiver = sanitize_email( get_option( 'admin_email' ) ); + + // Settings data + $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; + $formSuccessMessage = ( $_POST['form-success-message'] ) ? sanitize_text_field( $_POST['form-success-message'] ) : ''; + $formErrorMessage = ( $_POST['form-error-message'] ) ? sanitize_text_field( $_POST['form-error-message'] ) : ''; + + $emailReceiver = isset( $get_reciveremail ) ? sanitize_email( $get_reciveremail ) : $default_receiver; + + $emailHeaders = ( $_POST['email-headers'] ) ? sanitize_textarea_field( $_POST['email-headers'] ) : ''; + $emailSubject = ( $_POST['email-subject'] ) ? sanitize_text_field( $_POST['email-subject'] ) : ''; + $emailBody = ( $_POST['email-body'] ) ? wp_kses_post( $_POST['email-body'] ) : ''; + + $fieldNames = array(); + $validation = false; + $formInputArray = $this->sanitize_form_array( $_POST['qubely-form-input'] ); + + foreach ( $formInputArray as $key => $value ) { + if ( preg_match( '/[*]$/', $key ) ) { + if ( empty( $value ) ) { + $validation = true; } + $key = str_replace( '*', '', $key ); } - if($block_exists == false){ - return ; - } - - // Verify the authenticity of the request. - check_ajax_referer( 'qubely_nonce', 'security'); - - // All good, let's proceed. - if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { - $captcha = $_POST['captcha']; - $secretKey = $_POST['recaptcha-secret-key']; - $verify = wp_remote_get( "https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$captcha}" ); - - if ( ! is_array( $verify ) || ! isset( $verify['body'] ) ) { - wp_send_json( __( 'Cannot validate captcha', 'qubely' ), 400 ); + $fieldNames[ $key ] = $value; + + // if ($key == 'email') { + // $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); + // } + } + + if ( $validation || ( isset( $_POST['qubely-form-has-policy'] ) && empty( $_POST['qubely-form-has-policy'] ) ) ) { + wp_send_json( __( $formErrorMessage, 'qubely' ), 400 ); + } + + $replyToMail = $replyToName = $cc = $bcc = ''; + + $emailHeaders = explode( "\n", $emailHeaders ); + foreach ( $emailHeaders as $_header ) { + $_header = explode( ':', $_header ); + if ( count( $_header ) > 0 ) { + if ( strtolower( $_header[0] ) == 'reply-to' ) { + $replyToMail = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; } - - $verified = json_decode( $verify['body'] ); - if ( ! $verified->success ) { - wp_send_json( __( 'Captcha validation error', 'qubely' ), 400 ); + if ( strtolower( $_header[0] ) == 'reply-name' ) { + $replyToName = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; } - } - - // setting from options. - $qubely_options = maybe_unserialize( get_option( 'qubely_options' ) ); - $emailFrom = isset( $qubely_options['form_from_email'] ) ? sanitize_email( $qubely_options['form_from_email'] ) : sanitize_email( get_option( 'admin_email' ) ); - $fromName = isset( $qubely_options['form_from_name'] ) ? sanitize_text_field( $qubely_options['form_from_name'] ) : sanitize_text_field( get_option( 'blogname' ) ); - - $default_receiver = sanitize_email( get_option( 'admin_email' ) ); - - // Settings data - $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; - $formSuccessMessage = ( $_POST['form-success-message'] ) ? sanitize_text_field( $_POST['form-success-message'] ) : ''; - $formErrorMessage = ( $_POST['form-error-message'] ) ? sanitize_text_field( $_POST['form-error-message'] ) : ''; - - $emailReceiver = isset( $get_reciveremail) ? sanitize_email( $get_reciveremail ) : $default_receiver; - - $emailHeaders = ( $_POST['email-headers'] ) ? sanitize_textarea_field( $_POST['email-headers'] ) : ''; - $emailSubject = ( $_POST['email-subject'] ) ? sanitize_text_field( $_POST['email-subject'] ) : ''; - $emailBody = ( $_POST['email-body'] ) ? wp_kses_post( $_POST['email-body'] ) : ''; - - $fieldNames = array(); - $validation = false; - $formInputArray = $this->sanitize_form_array( $_POST['qubely-form-input'] ); - - foreach ( $formInputArray as $key => $value ) { - if ( preg_match( '/[*]$/', $key ) ) { - if ( empty( $value ) ) { - $validation = true; - } - $key = str_replace( '*', '', $key ); + if ( strtolower( $_header[0] ) == 'cc' ) { + $cc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; } - $fieldNames[ $key ] = $value; - - // if ($key == 'email') { - // $emailReceiver = apply_filters( 'qubely_custom_email_receiver', $value, $emailReceiver ); - // } - } - - if ( $validation || ( isset( $_POST['qubely-form-has-policy'] ) && empty( $_POST['qubely-form-has-policy'] ) ) ) { - wp_send_json( __( $formErrorMessage, 'qubely' ), 400 ); - } - - $replyToMail = $replyToName = $cc = $bcc = ''; - - $emailHeaders = explode( "\n", $emailHeaders ); - foreach ( $emailHeaders as $_header ) { - $_header = explode( ':', $_header ); - if ( count( $_header ) > 0 ) { - if ( strtolower( $_header[0] ) == 'reply-to' ) { - $replyToMail = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; - } - if ( strtolower( $_header[0] ) == 'reply-name' ) { - $replyToName = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; - } - if ( strtolower( $_header[0] ) == 'cc' ) { - $cc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; - } - if ( strtolower( $_header[0] ) == 'bcc' ) { - $bcc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; - } + if ( strtolower( $_header[0] ) == 'bcc' ) { + $bcc = isset( $_header[1] ) ? sanitize_text_field( $_header[1] ) : ''; } } - - foreach ( $fieldNames as $name => $value ) { - $value = is_array( $fieldNames[ $name ] ) ? implode( ', ', $fieldNames[ $name ] ) : $value; - $emailBody = str_replace( '{{' . $name . '}}', sanitize_textarea_field( $value ), $emailBody ); - $emailSubject = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $emailSubject ); - $replyToName = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToName ); - $replyToMail = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToMail ); - $cc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $cc ); - $bcc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $bcc ); - } - - // Subject Structure - $siteName = isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( $_SERVER['SERVER_NAME'] ) : ''; - $emailSubject = str_replace( '{{site-name}}', $siteName, $emailSubject ); - - $headers[] = 'Content-Type: text/html; charset=UTF-8'; - $headers[] = 'From: ' . $fromName . ' <' . $emailFrom . '>'; - $headers[] = 'Reply-To: ' . $replyToName . ' <' . $replyToMail . '>'; - $headers[] = 'Cc: ' . $cc; - $headers[] = 'Bcc: ' . $bcc; - - // Send E-Mail Now or through error msg. - try { - $isMail = wp_mail( $emailReceiver, $emailSubject, $emailBody, $headers ); - if ( $isMail ) { - $responseData['status'] = 1; - $responseData['msg'] = __( $formSuccessMessage, 'qubely' ); - } else { - $responseData['status'] = 0; - $responseData['msg'] = __( $formErrorMessage, 'qubely' ); - } - wp_send_json_success( $responseData ); - } catch ( \Exception $e ) { + } + + foreach ( $fieldNames as $name => $value ) { + $value = is_array( $fieldNames[ $name ] ) ? implode( ', ', $fieldNames[ $name ] ) : $value; + $emailBody = str_replace( '{{' . $name . '}}', sanitize_textarea_field( $value ), $emailBody ); + $emailSubject = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $emailSubject ); + $replyToName = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToName ); + $replyToMail = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $replyToMail ); + $cc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $cc ); + $bcc = str_replace( '{{' . $name . '}}', sanitize_text_field( $value ), $bcc ); + } + + // Subject Structure + $siteName = isset( $_SERVER['SERVER_NAME'] ) ? sanitize_text_field( $_SERVER['SERVER_NAME'] ) : ''; + $emailSubject = str_replace( '{{site-name}}', $siteName, $emailSubject ); + + $headers[] = 'Content-Type: text/html; charset=UTF-8'; + $headers[] = 'From: ' . $fromName . ' <' . $emailFrom . '>'; + $headers[] = 'Reply-To: ' . $replyToName . ' <' . $replyToMail . '>'; + $headers[] = 'Cc: ' . $cc; + $headers[] = 'Bcc: ' . $bcc; + + // Send E-Mail Now or through error msg. + try { + $isMail = wp_mail( $emailReceiver, $emailSubject, $emailBody, $headers ); + if ( $isMail ) { + $responseData['status'] = 1; + $responseData['msg'] = __( $formSuccessMessage, 'qubely' ); + } else { $responseData['status'] = 0; - $responseData['msg'] = $e->getMessage(); - wp_send_json_error( $responseData ); + $responseData['msg'] = __( $formErrorMessage, 'qubely' ); } - - + wp_send_json_success( $responseData ); + } catch ( \Exception $e ) { + $responseData['status'] = 0; + $responseData['msg'] = $e->getMessage(); + wp_send_json_error( $responseData ); } - - + } + + + /** - * Ajax add to cart button + * Ajax add to cart button * * @return boolean,void Return false if failure, echo json on success */ From bbf6b7c8bdaf5dfeea146533294de0f69d3aa237 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Mon, 10 Jul 2023 16:56:34 +0600 Subject: [PATCH 14/43] some file updated --- core/QUBELY.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index 7897944d..be156ecf 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -1972,6 +1972,9 @@ public function sanitize_form_array( $input = array() ) { public function qubely_send_form_data() { + // Verify the authenticity of the request. + check_ajax_referer( 'qubely_nonce', 'security' ); + $url = wp_get_referer(); $post_id = url_to_postid( $url ); @@ -1997,8 +2000,6 @@ public function qubely_send_form_data() { return; } - // Verify the authenticity of the request. - check_ajax_referer( 'qubely_nonce', 'security' ); // All good, let's proceed. if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { From 4d2b363c06bebba5b6d082367642be3401282635 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Tue, 11 Jul 2023 11:46:24 +0600 Subject: [PATCH 15/43] conditional issue fixed --- core/QUBELY.php | 4 ++-- qubely.php | 4 ++-- readme.txt | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index be156ecf..02703949 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -1987,8 +1987,8 @@ public function qubely_send_form_data() { // Check if the specific block exists $block_exists = false; foreach ( $blocks as $block ) { - - if ( $block['blockName'] === 'qubely/contactform' || 'qubely/form' ) { + + if ( 'qubely/contactform' === $block['blockName'] || 'qubely/form' === $block['blockName'] ) { $get_reciveremail = $block['attrs']['emailReceiver']; $block_exists = true; break; diff --git a/qubely.php b/qubely.php index 82acd7b8..ff829a99 100644 --- a/qubely.php +++ b/qubely.php @@ -3,7 +3,7 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.6 + * Version: 1.8.7 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely @@ -23,7 +23,7 @@ function qubely_language_load() { } // Define Version -define( 'QUBELY_VERSION', '1.8.5' ); +define( 'QUBELY_VERSION', '1.8.7' ); // Define License define( 'QUBELY_LICENSE', 'free' ); diff --git a/readme.txt b/readme.txt index 4d63af4f..b7d6eca6 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 Tested up to: 6.2 -Stable tag: 1.8.6 +Stable tag: 1.8.7 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt @@ -238,6 +238,8 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.7 = +Update: One condition updated. = 1.8.6 = Update: Addressed security vulnerability issue From 8c851519db96674bcb6d1849afd96617808e1fd3 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Tue, 11 Jul 2023 15:43:49 +0600 Subject: [PATCH 16/43] changelog updated --- readme.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index b7d6eca6..f82f0b1e 100644 --- a/readme.txt +++ b/readme.txt @@ -238,8 +238,9 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == + = 1.8.7 = -Update: One condition updated. +Update: Improved security issue = 1.8.6 = Update: Addressed security vulnerability issue From d0d6001de759fca87a08d22e4fe8062a6ab3e6da Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Tue, 11 Jul 2023 15:48:33 +0600 Subject: [PATCH 17/43] changelog updated --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index f82f0b1e..3bb638aa 100644 --- a/readme.txt +++ b/readme.txt @@ -240,7 +240,7 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == = 1.8.7 = -Update: Improved security issue +Update: Improved security = 1.8.6 = Update: Addressed security vulnerability issue From 977d52e812a00fc706d23cd0c15db044e0c77e6b Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 13 Jul 2023 11:12:36 +0600 Subject: [PATCH 18/43] built file issue solved --- .gitignore | 1 + core/QUBELY.php | 12 ++++++------ gulpfile.js | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 86092346..bd324124 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ build/Release node_modules/ jspm_packages/ vendor/ +build/ # TypeScript v1 declaration files typings/ diff --git a/core/QUBELY.php b/core/QUBELY.php index 02703949..66b8ec93 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -510,12 +510,12 @@ public function qubely_admin_assets() { ); wp_enqueue_script( 'qubely_local_script' ); - // START_REPLACE + #START_REPLACE wp_enqueue_style( 'qubley-animated-headline-style', QUBELY_DIR_URL . 'assets/css/qubely.animatedheadline.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-animation', QUBELY_DIR_URL . 'assets/css/animation.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-magnific-popup-style', QUBELY_DIR_URL . 'assets/css/magnific-popup.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-style-min', QUBELY_DIR_URL . 'assets/css/style.min.css', false, QUBELY_VERSION ); - // END_REPLACE + #END_REPLACE wp_enqueue_style( 'qubely-font-awesome', QUBELY_DIR_URL . 'assets/css/font-awesome.min.css', false, QUBELY_VERSION ); @@ -659,12 +659,12 @@ public function qubely_enqueue_style() { * @warning: Don't Remove `START_REPLACE` and `START_REPLACE` comments. These comments are required for gulp build */ - // START_REPLACE + #START_REPLACE wp_enqueue_style( 'qubley-animated-headline-style', QUBELY_DIR_URL . 'assets/css/qubely.animatedheadline.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-animation', QUBELY_DIR_URL . 'assets/css/animation.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-magnific-popup-style', QUBELY_DIR_URL . 'assets/css/magnific-popup.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-style-min', QUBELY_DIR_URL . 'assets/css/style.min.css', false, QUBELY_VERSION ); - // END_REPLACE + #END_REPLACE $this->qubely_load_fontawesome(); $this->qubely_load_googlefonts(); @@ -1522,12 +1522,12 @@ public function add_reusable_css() { public function add_static_css() { // CSS - // START_REPLACE + #START_REPLACE wp_enqueue_style( 'qubley-animated-headline-style', QUBELY_DIR_URL . 'assets/css/qubely.animatedheadline.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-animation', QUBELY_DIR_URL . 'assets/css/animation.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-magnific-popup-style', QUBELY_DIR_URL . 'assets/css/magnific-popup.css', false, QUBELY_VERSION ); wp_enqueue_style( 'qubely-style-min', QUBELY_DIR_URL . 'assets/css/style.min.css', false, QUBELY_VERSION ); - // END_REPLACE + #END_REPLACE $this->qubely_load_fontawesome(); diff --git a/gulpfile.js b/gulpfile.js index 5fd8c450..ec5bd797 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -42,6 +42,7 @@ function makeBuild() { function productionMode() { const replacement_string = '\n\t\t\twp_enqueue_style(\'qubely-bundle\', QUBELY_DIR_URL . \'assets/css/qubely.bundle.min.css\', false, QUBELY_VERSION);\n\t\t\t'; + console.log(replacement_string); return src(['./build/qubely/core/QUBELY.php']) .pipe(replace(/(?<=#START_REPLACE)([^]*?)(?=#END_REPLACE)/g, replacement_string)) .pipe(replace(/qubely\.dev\.js/g, 'qubely.min.js')) @@ -52,7 +53,7 @@ function productionMode() { .pipe(replace(/image-comparison\.js/g, 'image-comparison.min.js')) .pipe(replace(/interaction\.js/g, 'interaction.min.js')) .pipe(replace(/common-script\.js/g, 'common-script.min.js')) - .pipe(dest('./build/qubely/core/')); + .pipe(dest('./build/qubely/core')); } function gulpConcatCss() { @@ -122,7 +123,7 @@ function removeCSSFiles() { function makeZip() { return src('./build/**/*.*') .pipe(zip('qubely.zip')) - .pipe(dest('./')) + .pipe(dest('./build/')) } exports.makeBuild = makeBuild; @@ -135,4 +136,4 @@ exports.cleanZip = cleanZip; exports.removeJsFiles = removeJsFiles; // exports.removeCSSFiles = removeCSSFiles; exports.makeZip = makeZip; -exports.default = series(cleanBuild, cleanZip, makeBuild, productionMode, gulpConcatCss, minify_css, minify_js, removeJsFiles, makeZip, cleanBuild); +exports.default = series(cleanBuild, cleanZip, makeBuild, productionMode, gulpConcatCss, minify_css, minify_js, makeZip); From cb73b5b5edf813c8abceb4849cb32b365603d569 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 13 Jul 2023 11:49:59 +0600 Subject: [PATCH 19/43] built process issue fixed --- gulpfile.js | 7 +++---- qubely.php | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ec5bd797..5fd8c450 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -42,7 +42,6 @@ function makeBuild() { function productionMode() { const replacement_string = '\n\t\t\twp_enqueue_style(\'qubely-bundle\', QUBELY_DIR_URL . \'assets/css/qubely.bundle.min.css\', false, QUBELY_VERSION);\n\t\t\t'; - console.log(replacement_string); return src(['./build/qubely/core/QUBELY.php']) .pipe(replace(/(?<=#START_REPLACE)([^]*?)(?=#END_REPLACE)/g, replacement_string)) .pipe(replace(/qubely\.dev\.js/g, 'qubely.min.js')) @@ -53,7 +52,7 @@ function productionMode() { .pipe(replace(/image-comparison\.js/g, 'image-comparison.min.js')) .pipe(replace(/interaction\.js/g, 'interaction.min.js')) .pipe(replace(/common-script\.js/g, 'common-script.min.js')) - .pipe(dest('./build/qubely/core')); + .pipe(dest('./build/qubely/core/')); } function gulpConcatCss() { @@ -123,7 +122,7 @@ function removeCSSFiles() { function makeZip() { return src('./build/**/*.*') .pipe(zip('qubely.zip')) - .pipe(dest('./build/')) + .pipe(dest('./')) } exports.makeBuild = makeBuild; @@ -136,4 +135,4 @@ exports.cleanZip = cleanZip; exports.removeJsFiles = removeJsFiles; // exports.removeCSSFiles = removeCSSFiles; exports.makeZip = makeZip; -exports.default = series(cleanBuild, cleanZip, makeBuild, productionMode, gulpConcatCss, minify_css, minify_js, makeZip); +exports.default = series(cleanBuild, cleanZip, makeBuild, productionMode, gulpConcatCss, minify_css, minify_js, removeJsFiles, makeZip, cleanBuild); diff --git a/qubely.php b/qubely.php index ff829a99..ae346aed 100644 --- a/qubely.php +++ b/qubely.php @@ -3,7 +3,7 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.7 + * Version: 1.8.8 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely @@ -23,7 +23,7 @@ function qubely_language_load() { } // Define Version -define( 'QUBELY_VERSION', '1.8.7' ); +define( 'QUBELY_VERSION', '1.8.8' ); // Define License define( 'QUBELY_LICENSE', 'free' ); From 647bb2223c12cd03f9b42422099127f9443728fb Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 13 Jul 2023 14:48:54 +0600 Subject: [PATCH 20/43] gitignore file updated --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index bd324124..86092346 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,6 @@ build/Release node_modules/ jspm_packages/ vendor/ -build/ # TypeScript v1 declaration files typings/ From 8857d515dbc2104e32f119ec7f305d1d8a2c3aa5 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Fri, 14 Jul 2023 13:57:48 +0600 Subject: [PATCH 21/43] readme file updated --- readme.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 3bb638aa..3156da81 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 Tested up to: 6.2 -Stable tag: 1.8.7 +Stable tag: 1.8.8 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt @@ -239,6 +239,9 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.8 = +Fix: Resolved some CSS issues + = 1.8.7 = Update: Improved security From bac52237f09522dca7b437e6aefb6e717181322d Mon Sep 17 00:00:00 2001 From: sifat009 Date: Thu, 20 Jul 2023 15:16:01 +0600 Subject: [PATCH 22/43] Added qubely block check in contact form --- core/QUBELY.php | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index 66b8ec93..3cbda321 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -1964,6 +1964,28 @@ public function sanitize_form_array( $input = array() ) { return $array; } + /** + * Get block by block name + * + * @param array $blocks Blocks. + * @param array $block_names Block names. + * @return mixed + */ + private function qubely_get_block( $blocks, $block_names ) { + foreach ( $blocks as $block ) { + if ( in_array( $block['blockName'], $block_names, true ) ) { + return $block; + } + if ( isset( $block['innerBlocks'] ) ) { + $found_block = $this->qubely_get_block( $block['innerBlocks'], $block_names ); + if ( $found_block ) { + return $found_block; + } + } + } + return false; + } + /** * Ajax for sending form data * @@ -1978,29 +2000,20 @@ public function qubely_send_form_data() { $url = wp_get_referer(); $post_id = url_to_postid( $url ); - // Retrieve the post content + // Retrieve the post content. $post_content = get_post_field( 'post_content', $post_id ); - // Parse the content into blocks + // Parse the content into blocks. $blocks = parse_blocks( $post_content ); - // Check if the specific block exists - $block_exists = false; - foreach ( $blocks as $block ) { - - if ( 'qubely/contactform' === $block['blockName'] || 'qubely/form' === $block['blockName'] ) { - $get_reciveremail = $block['attrs']['emailReceiver']; - $block_exists = true; - break; + // Check if the specific block exists. + $block = $this->qubely_get_block( $blocks, array( 'qubely/contactform', 'qubely/form' ) ); - } - } - if ( $block_exists == false ) { + if ( false === $block ) { wp_send_json( __( 'Invalid request', 'qubely' ), 400 ); return; } - // All good, let's proceed. if ( isset( $_POST['captcha'] ) && $_POST['recaptcha'] == 'true' ) { $captcha = $_POST['captcha']; @@ -2023,6 +2036,7 @@ public function qubely_send_form_data() { $fromName = isset( $qubely_options['form_from_name'] ) ? sanitize_text_field( $qubely_options['form_from_name'] ) : sanitize_text_field( get_option( 'blogname' ) ); $default_receiver = sanitize_email( get_option( 'admin_email' ) ); + $get_reciveremail = $block['attrs']['emailReceiver']; // Settings data $fieldErrorMessage = ( $_POST['field-error-message'] ) ? sanitize_text_field( $_POST['field-error-message'] ) : ''; From 1e56a4564a8e8231eebc5886030d4c60c1962009 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Wed, 22 Nov 2023 10:34:32 +0600 Subject: [PATCH 23/43] pro upgrade option removed --- .../src/components/fields/Interaction.js | 15 --- .../reactjs/src/components/fields/Styles.js | 13 --- assets/reactjs/src/helpers/PageListModal.js | 97 +++++++++---------- core/admin-views/Getting_Started.php | 11 --- 4 files changed, 45 insertions(+), 91 deletions(-) diff --git a/assets/reactjs/src/components/fields/Interaction.js b/assets/reactjs/src/components/fields/Interaction.js index a6455b55..2feb7979 100644 --- a/assets/reactjs/src/components/fields/Interaction.js +++ b/assets/reactjs/src/components/fields/Interaction.js @@ -149,21 +149,6 @@ class Interaction extends Component { alt={__("Qubely")} />
-
- {__("Upgrade to Pro")} - - {__( - "Get all features of post grid at your disposal by upgrading to pro version" - )} - -
- - {__("Upgrade Now")} - ) : ( diff --git a/assets/reactjs/src/components/fields/Styles.js b/assets/reactjs/src/components/fields/Styles.js index a52ae775..03e902e6 100644 --- a/assets/reactjs/src/components/fields/Styles.js +++ b/assets/reactjs/src/components/fields/Styles.js @@ -35,19 +35,6 @@ class Styles extends Component {
{__("Qubely")}
-
- {__("Upgrade to Pro")} - - {__("Get all features of post grid at your disposal by upgrading to pro version")} - -
- - {__("Upgrade Now")} - )} diff --git a/assets/reactjs/src/helpers/PageListModal.js b/assets/reactjs/src/helpers/PageListModal.js index c2bcea51..a240c8d0 100755 --- a/assets/reactjs/src/helpers/PageListModal.js +++ b/assets/reactjs/src/helpers/PageListModal.js @@ -32,7 +32,7 @@ class PageListModal extends Component { requestFailedMsg: "", spinner: false, lazyloadThrottleTimeout: 0, - priceFilter: "", + priceFilter: qubely_admin.pro_enable ? "pro" : '', isOpen: false, rememberChoice: false, }; @@ -81,7 +81,7 @@ class PageListModal extends Component { } } else { if (selectedCategory) { - pageData[selectedCategory].map((value) => { + pageData[selectedCategory].filter(item => priceFilter === 'pro' ? true : !item.pro).map((value) => { if (itemType == "block") { if (!(tempDataID.indexOf(value.ID) > -1)) { currentPageData.push(value); @@ -97,7 +97,7 @@ class PageListModal extends Component { } else { for (let key in pageData) { Array.isArray(pageData[key]) && - pageData[key].map((value) => { + pageData[key].filter(item => priceFilter === 'pro' ? true : !item.pro).map((value) => { if (itemType == "block") { if (!(tempDataID.indexOf(value.ID) > -1)) { currentPageData.push(value); @@ -118,7 +118,7 @@ class PageListModal extends Component { if (this.state.layer === "multiple") { if (selectedCategory) { let itemCount = 0; - pageData[selectedCategory].map((value) => { + pageData[selectedCategory].filter(item => priceFilter === 'pro' ? true : !item.pro).map((value) => { if (!value.parentID && !(tempDataID.indexOf(value.ID) > -1)) { let found = value.category.find((item) => item.slug == selectedCategory); if (found) { @@ -130,7 +130,7 @@ class PageListModal extends Component { } else { for (let key in pageData) { if (typeof pageData[key] === "object") { - pageData[key].map((value) => { + pageData[key].filter(item => priceFilter === 'pro' ? true : !item.pro).map((value) => { if (!value.parentID && !(tempDataID.indexOf(value.ID) > -1)) { tempDataID.push(value.ID); currentPageData.push(value); @@ -145,14 +145,14 @@ class PageListModal extends Component { currentPageData = this.state.savedBlocks; } - if (itemType != "saved_blocks") { - currentPageData = - priceFilter == "pro" - ? currentPageData.filter((item) => item.pro == true) - : priceFilter == "free" - ? currentPageData.filter((item) => item.pro == false) - : currentPageData; - } + // if (itemType != "saved_blocks") { + // currentPageData = + // priceFilter == "pro" + // ? currentPageData.filter((item) => item.pro == true) + // : priceFilter == "free" + // ? currentPageData.filter((item) => item.pro == false) + // : currentPageData; + // } if (this.state.isSearchEnable) { let filterData = currentPageData.filter( @@ -161,6 +161,7 @@ class PageListModal extends Component { return { pageCategories, selectedCategory, currentPageData: filterData }; } + return { pageCategories, selectedCategory, currentPageData }; } @@ -293,6 +294,7 @@ class PageListModal extends Component { } getSectionsList() { + let { priceFilter } = this.state; this.setState({ loading: true }); let requestFailedMsg = []; let security = qubely_urls.nonce; @@ -325,14 +327,25 @@ class PageListModal extends Component { blockData[cat.slug].push(item); } let index = -1; + blockCategories.forEach((change, i) => { if (cat.slug == change.slug) { index = i; - blockCategories[i].count = blockCategories[i].count + 1; + if (priceFilter !== 'pro') { + if (!item.pro) { + blockCategories[i].count = blockCategories[i].count + 1; + } + } else { + blockCategories[i].count = blockCategories[i].count + 1; + } } }); if (index === -1) { - blockCategories.push({ name: cat.name, slug: cat.slug, count: 1 }); + blockCategories.push({ + name: cat.name, + slug: cat.slug, + count: priceFilter !== 'pro' ? cat.name === 'Content' ? 1 : 0 : 1 + }); } }); } @@ -383,12 +396,12 @@ class PageListModal extends Component { layer: "single", parent_id: "", searchContext: "", - priceFilter: "", + // priceFilter: "", }); } _onlickLayoutsTab() { - let { layoutData, layoutCategoryItems } = this.state; + let { layoutData, layoutCategoryItems, priceFilter } = this.state; if (!layoutData) { this.setState({ loading: true }); @@ -434,7 +447,13 @@ class PageListModal extends Component { if (cat.slug == change.slug) { index = i; if (item.parentID == 0) { - layoutCategories[i].count = layoutCategories[i].count + 1; + if (priceFilter !== 'pro') { + if (!item.pro) { + layoutCategories[i].count = layoutCategories[i].count + 1; + } + } else { + layoutCategories[i].count = layoutCategories[i].count + 1; + } } } }); @@ -442,7 +461,7 @@ class PageListModal extends Component { layoutCategories.push({ name: cat.name, slug: cat.slug, - count: item.parentID == 0 ? 1 : 0, + count: 0, }); } }); @@ -480,7 +499,7 @@ class PageListModal extends Component { layer: "multiple", parent_id: "", searchContext: "", - priceFilter: "", + // priceFilter: "", }); } @@ -511,7 +530,7 @@ class PageListModal extends Component { itemType: "saved_blocks", savedBlocks: response.data, searchContext: "", - priceFilter: "", + // priceFilter: "", }); }) .catch((error) => { @@ -520,7 +539,7 @@ class PageListModal extends Component { loading: false, requestFailedMsg, searchContext: "", - priceFilter: "", + // priceFilter: "", }); }); } else { @@ -528,7 +547,7 @@ class PageListModal extends Component { layer: "block", itemType: "saved_blocks", searchContext: "", - priceFilter: "", + // priceFilter: "", }); } } @@ -630,7 +649,6 @@ class PageListModal extends Component { blockCategories, selectedLayoutCategory, itemType, - blockData, layoutCategories, } = this.state; let count = 0; @@ -666,8 +684,8 @@ class PageListModal extends Component { } } else { if (itemType == "block") { - Object.keys(blockData).forEach(function (key) { - count = count + blockData[key].length; + blockCategories.forEach(function (data) { + count = count + data.count; }); return count; } else { @@ -817,11 +835,7 @@ class PageListModal extends Component { > {data.name} - {itemType == "block" - ? blockData[data.slug] - ? blockData[data.slug].length - : 0 - : data.count} + {data.count} ))} @@ -855,27 +869,6 @@ class PageListModal extends Component { ? __("Layouts") : __("Starter Packs")} -
- - - -
)} diff --git a/core/admin-views/Getting_Started.php b/core/admin-views/Getting_Started.php index de5378b6..8a678573 100644 --- a/core/admin-views/Getting_Started.php +++ b/core/admin-views/Getting_Started.php @@ -8,11 +8,6 @@ class QUBELY_Getting_Started { public $posts; - public $hasPro; - - public function __construct() { - $this->hasPro = defined('QUBELY_PRO_FILE'); - } public function mini_cards() { @@ -135,12 +130,6 @@ public function markup() {
- hasPro ) {?> -
-

- -
-

From 40ccc861b3816a9374cd0f7bae4d1e2f1b946045 Mon Sep 17 00:00:00 2001 From: Sazedul Haque Date: Tue, 28 Nov 2023 12:43:00 +0600 Subject: [PATCH 24/43] Fix table of content not rendering in frontend --- .../reactjs/src/blocks/table-of-contents/components.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/reactjs/src/blocks/table-of-contents/components.js b/assets/reactjs/src/blocks/table-of-contents/components.js index b5a2b2d3..f8f47565 100644 --- a/assets/reactjs/src/blocks/table-of-contents/components.js +++ b/assets/reactjs/src/blocks/table-of-contents/components.js @@ -80,6 +80,16 @@ class TableOfContents extends Component { this.setState({ unsubscribe }); } + componentDidUpdate(prevProps, prevState) { + if ( + JSON.stringify(prevProps.headers) !== JSON.stringify(prevState.headers) + ) { + this.props.blockProp.setAttributes({ + headerLinks: JSON.stringify(this.state.headers), + }); + } + } + componentWillUnmount() { this.state.unsubscribe(); } From 4bfc580f88f2498a3b796b7b097dc61862bd5c1c Mon Sep 17 00:00:00 2001 From: Sazedul Haque Date: Tue, 28 Nov 2023 13:38:32 +0600 Subject: [PATCH 25/43] Fix preset changes not showing after reload --- .../src/plugins/global-settings/index.js | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/assets/reactjs/src/plugins/global-settings/index.js b/assets/reactjs/src/plugins/global-settings/index.js index 247b43ea..44d4c74c 100644 --- a/assets/reactjs/src/plugins/global-settings/index.js +++ b/assets/reactjs/src/plugins/global-settings/index.js @@ -79,7 +79,7 @@ class GlobalSettings extends Component { } }); } - // this.getGlobalSettings(); + this.getGlobalSettings(); let hasExistingValues = true; fetchFromApi().then((data) => { if (data.success) { @@ -235,46 +235,46 @@ class GlobalSettings extends Component { } } - // getGlobalSettings = () => { - // let hasExistingValues = true; - // return fetchFromApi().then(data => { - // if (qubely_admin.is_core_active && this.state.savedMeta && ( - // this.state.savedMeta.key !== data.settings.activePreset || - // Object.keys(diff({ 'colors': data.settings.presets[data.settings.activePreset].colors }, { 'colors': this.state.savedMeta.colors })).length > 0 || - // Object.keys(diff({ 'typography': data.settings.presets[data.settings.activePreset].typography }, { 'typography': this.state.savedMeta.typography })).length > 0 || - // Object.keys(diff({ 'breakingPoints': data.settings.breakingPoints }, { 'breakingPoints': this.state.savedMeta.breakingPoints })).length > 0 - // )) { - // console.log('preset changed'); - // this.setState({ isPresetChanged: true, showModal: true }); - // } else { - // console.log('same preset'); - // this.setState({ isPresetChanged: false }); - // } - // if (data.success) { - // if (Object.keys(data.settings).length === 0) { - // hasExistingValues = false - // this.updateGlobalSettings(); - // } - // if (data.settings.activePreset !== 'theme') { - // this.saveGlobalCSS(); - // } - // this.setState({ ...data.settings }); - // localStorage.setItem('qubely-global-settings', JSON.stringify({ - // ...DEFAULTPRESETS.presets[DEFAULTPRESETS.activePreset], - // breakingPoints: { - // ...this.state.breakingPoints, - // ...(typeof qubely_container_width !== undefined && qubely_container_width), - // ...((hasExistingValues && typeof data.settings.breakingPoints !== 'undefined') & data.settings.breakingPoints) - // }, - // ...((hasExistingValues && typeof data.settings.presets !== 'undefined' && typeof data.settings.activePreset !== 'undefined') & data.settings.presets[data.settings.activePreset]), + getGlobalSettings = () => { + let hasExistingValues = true; + return fetchFromApi().then(data => { + if (qubely_admin.is_core_active && this.state.savedMeta && ( + this.state.savedMeta.key !== data.settings.activePreset || + Object.keys(diff({ 'colors': data.settings.presets[data.settings.activePreset].colors }, { 'colors': this.state.savedMeta.colors })).length > 0 || + Object.keys(diff({ 'typography': data.settings.presets[data.settings.activePreset].typography }, { 'typography': this.state.savedMeta.typography })).length > 0 || + Object.keys(diff({ 'breakingPoints': data.settings.breakingPoints }, { 'breakingPoints': this.state.savedMeta.breakingPoints })).length > 0 + )) { + console.log('preset changed'); + this.setState({ isPresetChanged: true, showModal: true }); + } else { + console.log('same preset'); + this.setState({ isPresetChanged: false }); + } + if (data.success) { + if (Object.keys(data.settings).length === 0) { + hasExistingValues = false + this.updateGlobalSettings(); + } + if (data.settings.activePreset !== 'theme') { + this.saveGlobalCSS(); + } + this.setState({ ...data.settings }); + localStorage.setItem('qubely-global-settings', JSON.stringify({ + ...DEFAULTPRESETS.presets[DEFAULTPRESETS.activePreset], + breakingPoints: { + ...this.state.breakingPoints, + ...(typeof qubely_container_width !== undefined && qubely_container_width), + ...((hasExistingValues && typeof data.settings.breakingPoints !== 'undefined') & data.settings.breakingPoints) + }, + ...((hasExistingValues && typeof data.settings.presets !== 'undefined' && typeof data.settings.activePreset !== 'undefined') & data.settings.presets[data.settings.activePreset]), - // })) - // } else { - // this.setState({ ...DEFAULTPRESETS }); - // this.updateGlobalSettings() - // } - // }); - // } + })) + } else { + this.setState({ ...DEFAULTPRESETS }); + this.updateGlobalSettings() + } + }); + } restoreSavedpreset(savedMeta) { const { key, name, colors, typography, breakingPoints } = savedMeta; From 5539a0b3912021b958a49b0ba4b28a90bacddab5 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Wed, 13 Dec 2023 17:55:48 +0600 Subject: [PATCH 26/43] version updated --- qubely.php | 4 ++-- readme.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qubely.php b/qubely.php index ae346aed..f0efc5e4 100644 --- a/qubely.php +++ b/qubely.php @@ -3,12 +3,12 @@ * Plugin Name: Qubely - Advanced Gutenberg Blocks * Plugin URI: https://www.themeum.com/ * Description: The one and only Gutenberg block plugin you will ever need. - * Version: 1.8.8 + * Version: 1.8.9 * Author: Themeum * Author URI: https://www.themeum.com/ * Text Domain: qubely * Requires at least: 5.3 - * Tested up to: 6.2 + * Tested up to: 6.4.2 * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt */ diff --git a/readme.txt b/readme.txt index 3156da81..7f4ada23 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: themeum Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 -Tested up to: 6.2 -Stable tag: 1.8.8 +Tested up to: 6.4.2 +Stable tag: 1.8.9 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt From 13c7cc44c1b63235e789671741f7b9ea0d6b072d Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Mon, 18 Dec 2023 15:49:00 +0600 Subject: [PATCH 27/43] Updated changelog --- readme.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.txt b/readme.txt index 7f4ada23..81d1c382 100644 --- a/readme.txt +++ b/readme.txt @@ -238,6 +238,11 @@ You can report bugs on the [support forum here](https://wordpress.org/support/pl == Changelog == += 1.8.9 = +Fix: Resolved table of contents issue. +Fix: Fixed settings color preset issue. +Fix: Enhanced security measures. +Update: Unlocked all premium features. = 1.8.8 = Fix: Resolved some CSS issues From 49bf5aaafcd44674122b1a78a6bb57f8ab59566b Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 21 Dec 2023 16:02:46 +0600 Subject: [PATCH 28/43] PHP-8.X compatibility --- core/QUBELY.php | 4 ++-- readme.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index 1ffe0869..6a8c6f33 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -327,7 +327,7 @@ function ( $el ) use ( $keys ) { public function gather_block_fonts( $blocks, $block_fonts ) { $google_fonts = $block_fonts; foreach ( $blocks as $key => $block ) { - if ( strpos( $block['blockName'], 'qubely' ) !== false ) { + if ( strpos( $block['blockName'] ?? '', 'qubely' ) !== false ) { foreach ( $block['attrs'] as $key => $att ) { if ( gettype( $att ) == 'array' && isset( $att['openTypography'] ) && isset( $att['family'] ) ) { if ( isset( $block['attrs'][ $key ]['activeSource'] ) ) { @@ -361,7 +361,7 @@ public function gather_block_fonts( $blocks, $block_fonts ) { public function has_qubely_blocks( $blocks ) { $is_qubely_block = false; foreach ( $blocks as $key => $block ) { - if ( strpos( $block['blockName'], 'qubely' ) !== false ) { + if ( strpos( $block['blockName'] ?? '', 'qubely' ) !== false ) { $is_qubely_block = true; } if ( isset( $block['innerBlocks'] ) && gettype( $block['innerBlocks'] ) == 'array' && count( $block['innerBlocks'] ) > 0 ) { diff --git a/readme.txt b/readme.txt index 81d1c382..c1f8b73e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.themeum.com Tags: blocks, gutenberg, gutenberg blocks, editor, block, page builder Requires at least: 5.3 Tested up to: 6.4.2 -Stable tag: 1.8.9 +Stable tag: 1.8.10 Requires PHP: 7.0 License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt From f2715690e992f1ceeeb0c81292ab063a640375d6 Mon Sep 17 00:00:00 2001 From: Mohammad Ibrahim Date: Thu, 21 Dec 2023 17:08:36 +0600 Subject: [PATCH 29/43] depricated issue fixed --- core/QUBELY.php | 10 +++++----- qubely.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/QUBELY.php b/core/QUBELY.php index 6a8c6f33..4cbd8293 100644 --- a/core/QUBELY.php +++ b/core/QUBELY.php @@ -781,22 +781,22 @@ public function qubely_enqueue_scripts() { $post = $wp_post->post_content; } - if ( false !== strpos( $post, '