| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | use YayMail\Models\TemplateModel; |
| 8 | 8 | use YayMail\Models\RevisionModel; |
| 9 | 9 | use YayMail\Migrations\MainMigration; |
| 10 | 10 | use YayMail\Utils\Helpers; |
| 11 | +use YayMail\Migrations\AbstractMigration; | |
| 11 | 12 | |
| 12 | 13 | /** |
| 13 | 14 | * I18n Logic |
| 14 | 15 | * |
| @@ -60,12 +61,9 @@ | ||
| 60 | 61 | |
| 61 | 62 | $state_data = null; |
| 62 | 63 | for ( $i = 0; $i < $zip->numFiles; $i++ ) { |
| 63 | 64 | $filename = $zip->getNameIndex( $i ); |
| 64 | - // Matches both "yaymail_backup.json" (YayMail) and "email_builder_backup.json" | |
| 65 | - // (Email Builder) -- the zip always holds exactly this one entry, named per | |
| 66 | - // getBrandName() in backup/index.tsx. | |
| 67 | - if ( 1 === preg_match( '/_backup\.json$/', (string) $filename ) ) { | |
| 65 | + if ( $filename === 'yaymail_backup.json' ) { | |
| 68 | 66 | $state_data = $zip->getFromIndex( $i ); |
| 69 | 67 | break; |
| 70 | 68 | } |
| 71 | 69 | } |
| @@ -72,9 +70,9 @@ | ||
| 72 | 70 | |
| 73 | 71 | $zip->close(); |
| 74 | 72 | |
| 75 | 73 | if ( ! $state_data ) { |
| 76 | - return wp_send_json_error( [ 'mess' => __( 'Cannot find the backup JSON file in the ZIP file.', 'yaymail' ) ] ); | |
| 74 | + return wp_send_json_error( [ 'mess' => __( 'Cannot find yaymail_backup.json in the ZIP file.', 'yaymail' ) ] ); | |
| 77 | 75 | } |
| 78 | 76 | |
| 79 | 77 | $imported_data = json_decode( $state_data ); |
| 80 | 78 | if ( json_last_error() !== JSON_ERROR_NONE ) { |
| @@ -88,53 +86,12 @@ | ||
| 88 | 86 | $migration_model = \YayMail\Models\MigrationModel::get_instance(); |
| 89 | 87 | |
| 90 | 88 | $source_version = $imported_data->version; |
| 91 | 89 | |
| 92 | - $imported_posts = array_values( | |
| 93 | - array_filter( | |
| 94 | - $imported_data->posts, | |
| 95 | - function( $post ) { | |
| 96 | - return isset( $post->post_type ) && 'yaymail_template' === $post->post_type; | |
| 97 | - } | |
| 98 | - ) | |
| 99 | - ); | |
| 100 | - | |
| 101 | - $imported_postmeta = array_values( | |
| 102 | - array_filter( | |
| 103 | - $imported_data->postmeta, | |
| 104 | - function( $postmeta ) use ( $imported_posts ) { | |
| 105 | - if ( empty( $imported_posts ) ) { | |
| 106 | - return false; | |
| 107 | - } | |
| 108 | - if ( ! isset( $postmeta->post_id ) || ! isset( $postmeta->meta_key ) ) { | |
| 109 | - return false; | |
| 110 | - } | |
| 111 | - if ( strpos( (string) $postmeta->meta_key, 'yaymail' ) === false ) { | |
| 112 | - return false; | |
| 113 | - } | |
| 114 | - foreach ( $imported_posts as $post ) { | |
| 115 | - if ( isset( $post->ID ) && (int) $post->ID === (int) $postmeta->post_id ) { | |
| 116 | - return true; | |
| 117 | - } | |
| 118 | - } | |
| 119 | - return false; | |
| 120 | - } | |
| 121 | - ) | |
| 122 | - ); | |
| 123 | - | |
| 124 | - $imported_options = array_values( | |
| 125 | - array_filter( | |
| 126 | - $imported_data->options, | |
| 127 | - function( $option ) { | |
| 128 | - return isset( $option->option_name ) && strpos( (string) $option->option_name, 'yaymail' ) !== false; | |
| 129 | - } | |
| 130 | - ) | |
| 131 | - ); | |
| 132 | - | |
| 133 | 90 | $backup_data = [ |
| 134 | - 'posts' => $imported_posts, | |
| 135 | - 'postmeta' => $imported_postmeta, | |
| 136 | - 'options' => $imported_options, | |
| 91 | + 'posts' => $imported_data->posts, | |
| 92 | + 'postmeta' => $imported_data->postmeta, | |
| 93 | + 'options' => $imported_data->options, | |
| 137 | 94 | 'created_date' => $imported_data->created_date ?? current_datetime()->format( 'Y-m-d H:i:s' ), |
| 138 | 95 | 'name' => '_yaymail_import_backup_' . $source_version, |
| 139 | 96 | 'version' => $source_version, |
| 140 | 97 | ]; |
| @@ -198,23 +155,10 @@ | ||
| 198 | 155 | $yaymail_options = $wpdb->get_results( $query_options ); // phpcs:ignore |
| 199 | 156 | $backup_data['options'] = $yaymail_options; |
| 200 | 157 | |
| 201 | 158 | $backup_data['created_date'] = current_datetime()->format( 'Y-m-d H:i:s' ); |
| 159 | + $backup_data['version'] = get_option( 'yaymail_version_backup' ); | |
| 202 | 160 | |
| 203 | - // Fall back through running version / YAYWP_VERSION / '1.0' when the | |
| 204 | - // backup option hasn't been set yet (e.g. init_modules() hasn't | |
| 205 | - // recorded it), otherwise a falsy 'version' gets baked into the | |
| 206 | - // exported ZIP and MigrationModel::reset() rejects it on import with | |
| 207 | - // "Back up does not exist". | |
| 208 | - $version_backup = get_option( 'yaymail_version_backup' ); | |
| 209 | - if ( ! empty( $version_backup ) ) { | |
| 210 | - $backup_data['version'] = $version_backup; | |
| 211 | - } elseif ( ! empty( yaymail_version() ) ) { | |
| 212 | - $backup_data['version'] = yaymail_version(); | |
| 213 | - } else { | |
| 214 | - $backup_data['version'] = defined( 'YAYWP_VERSION' ) ? YAYWP_VERSION : '1.0'; | |
| 215 | - } | |
| 216 | - | |
| 217 | 161 | $backup_data = apply_filters( 'yaymail_backup_state_data', $backup_data ); |
| 218 | 162 | |
| 219 | 163 | wp_send_json_success( |
| 220 | 164 | [ |
| @@ -219,18 +163,16 @@ | ||
| 219 | 163 | wp_send_json_success( |
| 220 | 164 | [ |
| 221 | 165 | 'message' => 'success', |
| 222 | 166 | 'data' => $backup_data, |
| 223 | - 'file_name' => $this->export_file_name_prefix() . '_export_backup_' . gmdate( 'm-d-Y' ), | |
| 167 | + 'file_name' => 'yaymail_export_backup_' . gmdate( 'm-d-Y' ), | |
| 224 | 168 | ] |
| 225 | 169 | ); |
| 226 | 170 | |
| 227 | 171 | } catch ( \Error $error ) { |
| 228 | 172 | yaymail_get_logger( $error ); |
| 229 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 230 | 173 | } catch ( \Exception $exception ) { |
| 231 | 174 | yaymail_get_logger( $exception ); |
| 232 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 233 | 175 | }//end try |
| 234 | 176 | } |
| 235 | 177 | |
| 236 | 178 | public function sanitize( $array ) { |
| @@ -237,20 +179,8 @@ | ||
| 237 | 179 | |
| 238 | 180 | return wp_kses_post_deep( $array ); |
| 239 | 181 | } |
| 240 | 182 | |
| 241 | - /** | |
| 242 | - * File name prefix for exported/backup downloads, matching the frontend's | |
| 243 | - * brand name per platform (constants/theme.ts WP_COLORS vs the free "yaymail" | |
| 244 | - * default). Reads the "platform" the frontend sends alongside these AJAX | |
| 245 | - * requests (see common/ajax's getPlatform() calls) since these admin-ajax.php | |
| 246 | - * requests don't reliably expose the calling screen via get_current_screen(). | |
| 247 | - */ | |
| 248 | - private function export_file_name_prefix() { | |
| 249 | - $platform = isset( $_POST['platform'] ) ? sanitize_text_field( wp_unslash( $_POST['platform'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 250 | - return 'email-builder' === $platform ? 'email_builder' : 'yaymail'; | |
| 251 | - } | |
| 252 | - | |
| 253 | 183 | public function process_plugin_installer( $slug ) { |
| 254 | 184 | require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 255 | 185 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 256 | 186 | require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; |
| @@ -326,12 +256,10 @@ | ||
| 326 | 256 | ); |
| 327 | 257 | |
| 328 | 258 | } catch ( \Error $error ) { |
| 329 | 259 | yaymail_get_logger( $error ); |
| 330 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 331 | 260 | } catch ( \Exception $exception ) { |
| 332 | 261 | yaymail_get_logger( $exception ); |
| 333 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 334 | 262 | }//end try |
| 335 | 263 | } |
| 336 | 264 | |
| 337 | 265 | public function send_test_mail() { |
| @@ -342,15 +270,14 @@ | ||
| 342 | 270 | try { |
| 343 | 271 | $template_name = isset( $_POST['template_name'] ) ? sanitize_text_field( wp_unslash( $_POST['template_name'] ) ) : ''; |
| 344 | 272 | $order_id = isset( $_POST['order_id'] ) ? sanitize_text_field( wp_unslash( $_POST['order_id'] ) ) : 'sample_order'; |
| 345 | 273 | $email = isset( $_POST['email'] ) ? sanitize_text_field( $_POST['email'] ) : ''; |
| 346 | - $is_wc_email = strpos( $template_name, 'wp-core-' ) !== 0; | |
| 347 | 274 | |
| 348 | 275 | if ( empty( $template_name ) ) { |
| 349 | 276 | return wp_send_json_error( [ 'mess' => __( 'Can\'t find template', 'yaymail' ) ] ); |
| 350 | 277 | } |
| 351 | 278 | |
| 352 | - if ( empty( $order_id ) && $is_wc_email ) { | |
| 279 | + if ( empty( $order_id ) ) { | |
| 353 | 280 | return wp_send_json_error( [ 'mess' => __( 'Can\'t find order', 'yaymail' ) ] ); |
| 354 | 281 | } |
| 355 | 282 | |
| 356 | 283 | if ( empty( $email ) ) { |
| @@ -373,25 +300,13 @@ | ||
| 373 | 300 | update_option( 'yaymail_default_email_test', $email ); |
| 374 | 301 | |
| 375 | 302 | $html = $template->get_content( $render_data ); |
| 376 | 303 | |
| 377 | - $headers = "Content-Type: text/html\r\n"; | |
| 378 | - $subject = __( 'Email Test', 'yaymail' ); | |
| 304 | + $headers = "Content-Type: text/html\r\n"; | |
| 305 | + $class_wc_email = \WC_Emails::instance(); | |
| 306 | + $subject = __( 'Email Test', 'yaymail' ); | |
| 307 | + $send_mail = $class_wc_email->send( $email, $subject, $html, $headers, [] ); | |
| 379 | 308 | |
| 380 | - if ( $is_wc_email ) { | |
| 381 | - $class_wc_email = \WC_Emails::instance(); | |
| 382 | - $send_mail = $class_wc_email->send( $email, $subject, $html, $headers, [] ); | |
| 383 | - } else { | |
| 384 | - // $html is already the fully-rendered wp-core-mail template output. | |
| 385 | - // Without this marker, WpMail::custom_wp_mail_body() (hooked on the | |
| 386 | - // 'wp_mail' filter, meant to wrap *raw* WP core messages like a | |
| 387 | - // password-reset email) can't tell it apart from unrendered content | |
| 388 | - // and wraps it in the template a second time -- the same marker | |
| 389 | - // AddonWpMailController::woocommerce_mail_content() uses for real | |
| 390 | - // WooCommerce sends. | |
| 391 | - $html = '<!-- yaymail:wp-has-template-email-content -->' . $html; | |
| 392 | - $send_mail = wp_mail( $email, $subject, $html, $headers, [] ); | |
| 393 | - } | |
| 394 | 309 | if ( ! $send_mail ) { |
| 395 | 310 | return wp_send_json_error( [ 'mess' => __( 'Can\'t send email', 'yaymail' ) ] ); |
| 396 | 311 | } |
| 397 | 312 | |
| @@ -402,12 +317,10 @@ | ||
| 402 | 317 | ] |
| 403 | 318 | ); |
| 404 | 319 | } catch ( \Error $error ) { |
| 405 | 320 | yaymail_get_logger( $error ); |
| 406 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 407 | 321 | } catch ( \Exception $exception ) { |
| 408 | 322 | yaymail_get_logger( $exception ); |
| 409 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 410 | 323 | }//end try |
| 411 | 324 | } |
| 412 | 325 | |
| 413 | 326 | public function preview_mail() { |
| @@ -415,10 +328,10 @@ | ||
| 415 | 328 | if ( ! wp_verify_nonce( $nonce, 'yaymail_frontend_nonce' ) ) { |
| 416 | 329 | return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] ); |
| 417 | 330 | } |
| 418 | 331 | try { |
| 419 | - $order_id = ! empty( $_POST['order_id'] ) ? sanitize_text_field( wp_unslash( $_POST['order_id'] ) ) : 'sample_order'; | |
| 420 | - $template_data = isset( $_POST['template_data'] ) ? $this->sanitize( json_decode( wp_unslash( $_POST['template_data'] ), true ) ) : []; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 332 | + $order_id = isset( $_POST['order_id'] ) ? sanitize_text_field( wp_unslash( $_POST['order_id'] ) ) : 'sample_order'; | |
| 333 | + $template_data = isset( $_POST['template_data'] ) ? $this->sanitize( wp_unslash( $_POST['template_data'] ) ) : []; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 421 | 334 | $unsaved_settings = isset( $_POST['unsaved_settings'] ) ? $this->sanitize( wp_unslash( $_POST['unsaved_settings'] ) ) : []; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 422 | 335 | |
| 423 | 336 | if ( empty( $template_data ) ) { |
| 424 | 337 | return wp_send_json_error( [ 'mess' => __( 'Can\'t find template', 'yaymail' ) ] ); |
| @@ -453,25 +366,23 @@ | ||
| 453 | 366 | // check if email template on preview and send test mail |
| 454 | 367 | |
| 455 | 368 | $html = $template->get_content( $render_data ); |
| 456 | 369 | |
| 457 | - if ( strpos( $template->get_name(), 'wp-core-' ) !== 0 ) { | |
| 458 | - // TODO: render with passing settings | |
| 459 | - $current_email = null; | |
| 460 | - $subject = 'Sample Subject'; | |
| 461 | - $emails = wc()->mailer()->emails; | |
| 462 | - foreach ( $emails as $email ) { | |
| 463 | - if ( $email->id === $template_data['name'] ) { | |
| 464 | - $current_email = $email; | |
| 465 | - if ( method_exists( $current_email, 'set_object' ) ) { | |
| 466 | - if ( ! empty( $render_data['order'] ) && is_a( $render_data['order'], '\WC_Order' ) ) { | |
| 467 | - $current_email->set_object( $render_data['order'] ); | |
| 468 | - } else { | |
| 469 | - $current_email->set_object( Helpers::get_dummy_order() ); | |
| 470 | - } | |
| 370 | + // TODO: render with passing settings | |
| 371 | + $current_email = null; | |
| 372 | + $subject = 'Sample Subject'; | |
| 373 | + $emails = wc()->mailer()->emails; | |
| 374 | + foreach ( $emails as $email ) { | |
| 375 | + if ( $email->id === $template_data['name'] ) { | |
| 376 | + $current_email = $email; | |
| 377 | + if ( method_exists( $current_email, 'set_object' ) ) { | |
| 378 | + if ( ! empty( $render_data['order'] ) && is_a( $render_data['order'], '\WC_Order' ) ) { | |
| 379 | + $current_email->set_object( $render_data['order'] ); | |
| 380 | + } else { | |
| 381 | + $current_email->set_object( Helpers::get_dummy_order() ); | |
| 471 | 382 | } |
| 472 | - break; | |
| 473 | 383 | } |
| 384 | + break; | |
| 474 | 385 | } |
| 475 | 386 | } |
| 476 | 387 | |
| 477 | 388 | if ( ! empty( $current_email ) ) { |
| @@ -487,12 +398,10 @@ | ||
| 487 | 398 | ] |
| 488 | 399 | ); |
| 489 | 400 | } catch ( \Error $error ) { |
| 490 | 401 | yaymail_get_logger( $error ); |
| 491 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 492 | 402 | } catch ( \Exception $exception ) { |
| 493 | 403 | yaymail_get_logger( $exception ); |
| 494 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 495 | 404 | }//end try |
| 496 | 405 | } |
| 497 | 406 | |
| 498 | 407 | public function preview_mail_for_woo() { |
| @@ -530,12 +439,10 @@ | ||
| 530 | 439 | ] |
| 531 | 440 | ); |
| 532 | 441 | } catch ( \Error $error ) { |
| 533 | 442 | yaymail_get_logger( $error ); |
| 534 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 535 | 443 | } catch ( \Exception $exception ) { |
| 536 | 444 | yaymail_get_logger( $exception ); |
| 537 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 538 | 445 | }//end try |
| 539 | 446 | } |
| 540 | 447 | |
| 541 | 448 | public function export_templates() { |
| @@ -569,29 +476,24 @@ | ||
| 569 | 476 | $text_link_color = get_post_meta( $post->ID, YayMailTemplate::META_KEYS['text_link_color'], true ); |
| 570 | 477 | $background_color = get_post_meta( $post->ID, YayMailTemplate::META_KEYS['background_color'], true ); |
| 571 | 478 | $content_background_color = get_post_meta( $post->ID, YayMailTemplate::META_KEYS['content_background_color'], true ); |
| 572 | 479 | $content_text_color = get_post_meta( $post->ID, YayMailTemplate::META_KEYS['content_text_color'], true ); |
| 573 | - $title_color = get_post_meta( $post->ID, YayMailTemplate::META_KEYS['title_color'], true ); | |
| 574 | 480 | $file_name = "{$template_name}.json"; |
| 575 | - // Every WP-core template (e.g. wp-core-mail) is saved with a | |
| 576 | - // non-empty language meta (the site locale), unlike WooCommerce | |
| 577 | - // templates -- gating on "no language" here used to silently | |
| 578 | - // drop every WP-core template from the export with no error. | |
| 579 | - // find_by_name() below only ever looks templates up by name, so | |
| 580 | - // there's no separate per-language row to disambiguate against. | |
| 581 | - $export_data[] = [ | |
| 582 | - 'file_name' => $file_name, | |
| 583 | - 'templates_data' => [ | |
| 584 | - 'template' => $template_name, | |
| 585 | - 'elements' => $elements, | |
| 586 | - 'language' => $language, | |
| 587 | - 'text_link_color' => $text_link_color, | |
| 588 | - 'background_color' => $background_color, | |
| 589 | - 'content_background_color' => $content_background_color, | |
| 590 | - 'content_text_color' => $content_text_color, | |
| 591 | - 'title_color' => $title_color, | |
| 592 | - ], | |
| 593 | - ]; | |
| 481 | + if ( empty( $language ) ) { | |
| 482 | + $export_data[] = [ | |
| 483 | + 'file_name' => $file_name, | |
| 484 | + 'templates_data' => [ | |
| 485 | + 'template' => $template_name, | |
| 486 | + 'elements' => $elements, | |
| 487 | + 'language' => '', | |
| 488 | + 'text_link_color' => $text_link_color, | |
| 489 | + 'background_color' => $background_color, | |
| 490 | + 'content_background_color' => $content_background_color, | |
| 491 | + 'content_text_color' => $content_text_color, | |
| 492 | + 'title_color' => $title_color, | |
| 493 | + ], | |
| 494 | + ]; | |
| 495 | + } | |
| 594 | 496 | }//end foreach |
| 595 | 497 | }//end if |
| 596 | 498 | wp_reset_postdata(); |
| 597 | 499 | wp_send_json_success( |
| @@ -597,17 +499,15 @@ | ||
| 597 | 499 | wp_send_json_success( |
| 598 | 500 | [ |
| 599 | 501 | 'message' => __( 'Export successfully', 'yaymail' ), |
| 600 | 502 | 'data' => $export_data, |
| 601 | - 'file_name' => $this->export_file_name_prefix() . '_customizer_templates_' . gmdate( 'm-d-Y' ), | |
| 503 | + 'file_name' => 'yaymail_customizer_templates_' . gmdate( 'm-d-Y' ), | |
| 602 | 504 | ] |
| 603 | 505 | ); |
| 604 | 506 | } catch ( \Error $error ) { |
| 605 | 507 | yaymail_get_logger( $error ); |
| 606 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 607 | 508 | } catch ( \Exception $exception ) { |
| 608 | 509 | yaymail_get_logger( $exception ); |
| 609 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 610 | 510 | }//end try |
| 611 | 511 | } |
| 612 | 512 | |
| 613 | 513 | public function import_templates() { |
| @@ -627,12 +527,10 @@ | ||
| 627 | 527 | wp_send_json_error( [ 'message' => __( 'Can\'t find import files.', 'yaymail' ) ] ); |
| 628 | 528 | } |
| 629 | 529 | } catch ( \Error $error ) { |
| 630 | 530 | yaymail_get_logger( $error ); |
| 631 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 632 | 531 | } catch ( \Exception $exception ) { |
| 633 | 532 | yaymail_get_logger( $exception ); |
| 634 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 635 | 533 | } |
| 636 | 534 | } |
| 637 | 535 | |
| 638 | 536 | public function process_import( $files ) { |
| @@ -690,15 +588,13 @@ | ||
| 690 | 588 | return $updated_templates; |
| 691 | 589 | } |
| 692 | 590 | |
| 693 | 591 | public function processing_import_update_data( $data, $is_legacy = false ) { |
| 694 | - $template_name = $data['template'] ?? null; | |
| 695 | - $elements = $data['elements'] ?? null; | |
| 696 | - $text_link_color = $data['text_link_color'] ?? null; | |
| 697 | - $background_color = $data['background_color'] ?? null; | |
| 698 | - $title_color = $data['title_color'] ?? null; | |
| 699 | - $content_background_color = $data['content_background_color'] ?? null; | |
| 700 | - $content_text_color = $data['content_text_color'] ?? null; | |
| 592 | + $template_name = $data['template'] ?? null; | |
| 593 | + $elements = $data['elements'] ?? null; | |
| 594 | + $text_link_color = $data['text_link_color'] ?? null; | |
| 595 | + $background_color = $data['background_color'] ?? null; | |
| 596 | + $title_color = $data['title_color'] ?? null; | |
| 701 | 597 | |
| 702 | 598 | if ( empty( $template_name ) ) { |
| 703 | 599 | return null; |
| 704 | 600 | } |
| @@ -781,12 +677,10 @@ | ||
| 781 | 677 | ] |
| 782 | 678 | ); |
| 783 | 679 | } catch ( \Error $error ) { |
| 784 | 680 | yaymail_get_logger( $error ); |
| 785 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 786 | 681 | } catch ( \Exception $exception ) { |
| 787 | 682 | yaymail_get_logger( $exception ); |
| 788 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 789 | 683 | }//end try |
| 790 | 684 | } |
| 791 | 685 | |
| 792 | 686 | /** |
| @@ -800,10 +694,10 @@ | ||
| 800 | 694 | try { |
| 801 | 695 | $setting_model = SettingModel::get_instance(); |
| 802 | 696 | $settings_data = $setting_model->find_all(); |
| 803 | 697 | |
| 804 | - $template_name = isset( $_POST['data']['template_name'] ) ? sanitize_text_field( wp_unslash( $_POST['data']['template_name'] ) ) : 'new_order'; | |
| 805 | - $order_id = isset( $_POST['data']['order_id'] ) ? sanitize_text_field( wp_unslash( $_POST['data']['order_id'] ) ) : 'sample_order'; | |
| 698 | + $template_name = isset( $_POST['data']['template_name'] ) ? sanitize_text_field( $_POST['data']['template_name'] ) : 'new_order'; | |
| 699 | + $order_id = isset( $_POST['data']['order_id'] ) ? sanitize_text_field( $_POST['data']['order_id'] ) : 'sample_order'; | |
| 806 | 700 | |
| 807 | 701 | $template_model = TemplateModel::get_instance(); |
| 808 | 702 | |
| 809 | 703 | $shortcodes_data = $template_model->get_shortcodes_by_template_name_and_order_id( $template_name, $order_id ); |
| @@ -855,12 +749,10 @@ | ||
| 855 | 749 | ); |
| 856 | 750 | |
| 857 | 751 | } catch ( \Error $error ) { |
| 858 | 752 | yaymail_get_logger( $error ); |
| 859 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 860 | 753 | } catch ( \Exception $exception ) { |
| 861 | 754 | yaymail_get_logger( $exception ); |
| 862 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 863 | 755 | } |
| 864 | 756 | } |
| 865 | 757 | |
| 866 | 758 | public function change_ghf_tour() { |
| @@ -879,12 +771,10 @@ | ||
| 879 | 771 | ] |
| 880 | 772 | ); |
| 881 | 773 | } catch ( \Error $error ) { |
| 882 | 774 | yaymail_get_logger( $error ); |
| 883 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 884 | 775 | } catch ( \Exception $exception ) { |
| 885 | 776 | yaymail_get_logger( $exception ); |
| 886 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 887 | 777 | } |
| 888 | 778 | } |
| 889 | 779 | |
| 890 | 780 | public function dismiss_multi_select_notice() { |
| @@ -902,12 +792,10 @@ | ||
| 902 | 792 | ] |
| 903 | 793 | ); |
| 904 | 794 | } catch ( \Error $error ) { |
| 905 | 795 | yaymail_get_logger( $error ); |
| 906 | - wp_send_json_error( [ 'mess' => $error->getMessage() ] ); | |
| 907 | 796 | } catch ( \Exception $exception ) { |
| 908 | 797 | yaymail_get_logger( $exception ); |
| 909 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 910 | 798 | } |
| 911 | 799 | } |
| 912 | 800 | |
| 913 | 801 | public function dismiss_new_element_notification() { |
| @@ -932,8 +820,7 @@ | ||
| 932 | 820 | } catch ( \Error $error ) { |
| 933 | 821 | wp_send_json_error( [ 'mess' => $error->getMessage() ] ); |
| 934 | 822 | } catch ( \Exception $exception ) { |
| 935 | 823 | yaymail_get_logger( $exception ); |
| 936 | - wp_send_json_error( [ 'mess' => $exception->getMessage() ] ); | |
| 937 | 824 | } |
| 938 | 825 | } |
| 939 | 826 | } |