| @@ -67,9 +67,9 @@ | ||
| 67 | 67 | * |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | 70 | public function response() { |
| 71 | - $page_type = isset( $_POST['page_type'] ) ? sanitize_text_field( wp_unslash( $_POST['page_type'] ) ) : null; //rtsb_tb_template_type - it represent to template type | |
| 71 | + $page_type = isset( $_POST['page_type'] ) ? sanitize_text_field( wp_unslash( $_POST['page_type'] ) ) : null; // rtsb_tb_template_type - it represent to template type | |
| 72 | 72 | $page_id = isset( $_POST['page_id'] ) ? absint( wp_unslash( $_POST['page_id'] ) ) : null; |
| 73 | 73 | $page_name = isset( $_POST['page_name'] ) ? sanitize_text_field( wp_unslash( $_POST['page_name'] ) ) : null; |
| 74 | 74 | $hasPro = isset( $_POST['hasPro'] ) ? sanitize_text_field( wp_unslash( $_POST['hasPro'] ) ) : null; |
| 75 | 75 | $edit_with = isset( $_POST['template_edit_with'] ) ? sanitize_text_field( wp_unslash( $_POST['template_edit_with'] ) ) : null; |
| @@ -78,9 +78,9 @@ | ||
| 78 | 78 | $product_id = isset( $_POST['preview_product_id'] ) ? absint( $_POST['preview_product_id'] ) : null; |
| 79 | 79 | |
| 80 | 80 | $url = '#'; |
| 81 | 81 | |
| 82 | - if ( ! Fns::verify_nonce() || ! $page_type ) { | |
| 82 | + if ( ! wp_verify_nonce( Fns::get_nonce(), rtsb()->nonceText ) || ! $page_type ) { | |
| 83 | 83 | $return = [ |
| 84 | 84 | 'success' => false, |
| 85 | 85 | 'post_id' => $page_id, |
| 86 | 86 | ]; |
| @@ -86,9 +86,9 @@ | ||
| 86 | 86 | ]; |
| 87 | 87 | wp_send_json( $return ); |
| 88 | 88 | |
| 89 | 89 | } |
| 90 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 90 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 91 | 91 | $return = [ |
| 92 | 92 | 'success' => false, |
| 93 | 93 | 'post_id' => $page_id, |
| 94 | 94 | ]; |
| @@ -94,21 +94,25 @@ | ||
| 94 | 94 | ]; |
| 95 | 95 | wp_send_json( $return ); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - add_filter( 'pre_option_elementor_unfiltered_files_upload', function () { | |
| 99 | - return '1'; | |
| 100 | - }, 99 ); | |
| 98 | + add_filter( | |
| 99 | + 'pre_option_elementor_unfiltered_files_upload', | |
| 100 | + function () { | |
| 101 | + return '1'; | |
| 102 | + }, | |
| 103 | + 99 | |
| 104 | + ); | |
| 101 | 105 | |
| 102 | 106 | Plugin::$instance->files_manager->clear_cache(); |
| 103 | 107 | add_filter( 'rtsb_import_status', '__return_true' ); |
| 104 | 108 | |
| 105 | - $status = $_REQUEST['status'] ?? ''; | |
| 109 | + $status = sanitize_text_field( wp_unslash( $_REQUEST['status'] ?? '' ) ); | |
| 106 | 110 | $post_args = [ 'timeout' => 120 ]; |
| 107 | 111 | $post_args['body'] = [ |
| 108 | 112 | 'status' => $status, |
| 109 | 113 | 'layout_id' => $import_layout, |
| 110 | - 'has_pro' => $hasPro | |
| 114 | + 'has_pro' => $hasPro, | |
| 111 | 115 | ]; |
| 112 | 116 | $layoutRequest = wp_remote_post( rtsb()->BASE_API, $post_args ); |
| 113 | 117 | |
| 114 | 118 | $layoutJson = []; |
| @@ -155,15 +159,12 @@ | ||
| 155 | 159 | $category_archive = array_unique( isset( $_POST['category_archive'] ) && is_array( $_POST['category_archive'] ) ? array_map( 'sanitize_text_field', $_POST['category_archive'] ) : [] ); |
| 156 | 160 | $the_products = array_unique( isset( $_POST['the_products'] ) && is_array( $_POST['the_products'] ) ? array_map( 'absint', $_POST['the_products'] ) : [] ); |
| 157 | 161 | if ( ! count( $the_products ) && ! count( $category_archive ) ) { |
| 158 | 162 | if ( 'default_template' === $default_template ) { |
| 159 | - // update_option( $option_name, $page_id ); | |
| 160 | 163 | TemplateSettings::instance()->set_option( $option_name, $page_id ); |
| 161 | 164 | } else { |
| 162 | - // $has_default = get_option( $option_name ); | |
| 163 | 165 | $has_default = TemplateSettings::instance()->get_option( $option_name ); |
| 164 | 166 | if ( ! $has_default ) { |
| 165 | - // update_option( $option_name, '' ); | |
| 166 | 167 | TemplateSettings::instance()->set_option( $option_name, '' ); |
| 167 | 168 | } |
| 168 | 169 | } |
| 169 | 170 | } |
| @@ -182,9 +183,9 @@ | ||
| 182 | 183 | |
| 183 | 184 | if ( ! empty( $layoutJson['data'] ) ) { |
| 184 | 185 | $data = json_decode( $layoutJson['data'], true ); |
| 185 | 186 | $content = $this->process_export_import_content( $data, 'on_import' ); |
| 186 | - $content = json_encode( $content ); | |
| 187 | + $content = wp_json_encode( $content ); | |
| 187 | 188 | update_post_meta( $page_id, '_elementor_data', $content ); |
| 188 | 189 | update_post_meta( $page_id, '_rtsb_import_id', $import_layout ); |
| 189 | 190 | } |
| 190 | 191 | } |
| @@ -198,9 +199,13 @@ | ||
| 198 | 199 | 'new_page' => $new_page, |
| 199 | 200 | |
| 200 | 201 | ]; |
| 201 | 202 | if ( $edit_by ) { |
| 202 | - $return['edit_btn_text'] = esc_html__( sprintf( 'Edit with %s', $edit_by ), 'shopbuilder' ); | |
| 203 | + $return['edit_btn_text'] = sprintf( | |
| 204 | + /* translators: %s: Edit */ | |
| 205 | + esc_html__( 'Edit with %s', 'shopbuilder' ), | |
| 206 | + esc_html( $edit_by ) | |
| 207 | + ); | |
| 203 | 208 | } |
| 204 | 209 | wp_send_json( $return ); |
| 205 | 210 | wp_die(); |
| 206 | 211 | } |