| @@ -28,9 +28,9 @@ | ||
| 28 | 28 | - 'modification' |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | |
| 32 | -require_once( WPBC_PLUGIN_DIR . '/core/any/api-emails.php' ); // API | |
| 32 | +require_once WPBC_PLUGIN_DIR . '/core/any/api-emails.php'; // API | |
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | // <editor-fold defaultstate="collapsed" desc=" Import Old Data " > |
| @@ -280,9 +280,9 @@ | ||
| 280 | 280 | , 'html' => ' </fieldset> |
| 281 | 281 | </td> |
| 282 | 282 | </tr>' |
| 283 | 283 | ); |
| 284 | - //FixIn: 9.7.3.17 | |
| 284 | + // FixIn: 9.7.3.17. | |
| 285 | 285 | $this->fields['enable_replyto'] = array( |
| 286 | 286 | 'type' => 'checkbox' |
| 287 | 287 | , 'default' => 'Off' |
| 288 | 288 | , 'title' => __( 'Enable Reply-To', 'booking' ) |
| @@ -314,9 +314,10 @@ | ||
| 314 | 314 | , 'only_field' => true |
| 315 | 315 | ); |
| 316 | 316 | $this->fields['subject_after'] = array( 'type' => 'pure_html', 'group' => 'general_content', |
| 317 | 317 | 'html' => '<p style="text-align: right;font-size:12px;">' |
| 318 | - . sprintf( __( 'Type your email %ssubject%s for the booking confirmation message.', 'booking' ), '<b>', '</b>' ) . ' ' . __( 'Required', 'booking' ) | |
| 318 | + /* translators: 1: ... */ | |
| 319 | + . sprintf( __( 'Type your email %1$ssubject%2$s for the booking confirmation message.', 'booking' ), '<b>', '</b>' ) . ' ' . __( 'Required', 'booking' ) | |
| 319 | 320 | . '.</p>' . '</td></tr>' ); |
| 320 | 321 | |
| 321 | 322 | $this->fields['content_before'] = array( |
| 322 | 323 | 'type' => 'pure_html', |
| @@ -330,9 +331,10 @@ | ||
| 330 | 331 | $blg_title = get_option( 'blogname' ); |
| 331 | 332 | $blg_title = str_replace( array( '"', "'" ), '', $blg_title ); |
| 332 | 333 | $this->fields['content'] = array( |
| 333 | 334 | 'type' => 'wp_textarea' |
| 334 | - , 'default' => sprintf( __( 'You need to approve a new booking %s for: %s Person detail information:%s Currently a new booking is waiting for approval. Please visit the moderation panel%sThank you, %s', 'booking' ), '[bookingtype]', '[dates]<br/><br/>', '<br/> [content]<br/><br/>', ' [moderatelink]<br/><br/>', $blg_title . '<br/>[siteurl]' ) | |
| 335 | + /* translators: 1: ... */ | |
| 336 | + , 'default' => sprintf( __( 'You need to approve a new booking %1$s for: %2$s Person detail information:%3$s Currently a new booking is waiting for approval. Please visit the moderation panel%4$sThank you, %5$s', 'booking' ), '[bookingtype]', '[dates]<br/><br/>', '<br/> [content]<br/><br/>', ' [moderatelink]<br/><br/>', $blg_title . '<br/>[siteurl]' ) | |
| 335 | 337 | //, 'placeholder' => '' |
| 336 | 338 | , 'title' => __('Content', 'booking') |
| 337 | 339 | , 'description' => ''//__('Type your email message content. ', 'booking') |
| 338 | 340 | , 'description_tag' => '' |
| @@ -391,9 +393,10 @@ | ||
| 391 | 393 | ); |
| 392 | 394 | |
| 393 | 395 | $this->fields['template_file_help'] = array( |
| 394 | 396 | 'type' => 'help' |
| 395 | - , 'value' => array( sprintf( __('You can override this email template in this folder %s', 'booking') | |
| 397 | + /* translators: 1: ... */ | |
| 398 | + , 'value' => array( sprintf( __( 'You can override this email template in this folder %s', 'booking') | |
| 396 | 399 | , '<code>' . realpath( dirname(__FILE__) . '/../any/emails_tpl/' ) . '</code>' ) |
| 397 | 400 | ) |
| 398 | 401 | , 'cols' => 2 |
| 399 | 402 | , 'group' => 'style' |
| @@ -485,9 +488,10 @@ | ||
| 485 | 488 | , 'visitorbookingslisting' //FixIn: 8.1.3.5.1 |
| 486 | 489 | , 'visitorbookingcancelurl' |
| 487 | 490 | , 'visitorbookingpayurl' |
| 488 | 491 | ); |
| 489 | - $email_example = sprintf(__('For example: "You have a new reservation %s on the following date(s): %s Contact information: %s You can approve or cancel this booking at: %s Thank you, Reservation service."' ,'booking'),'','[dates]<br/><br/>','<br/> [content]<br/><br/>', htmlentities( ' <a href="[moderatelink]">'.__('here' ,'booking').'</a> ') . '<br/><br/> '); | |
| 492 | + /* translators: 1: ... */ | |
| 493 | + $email_example = sprintf( __( 'For example: "You have a new reservation %1$s on the following date(s): %2$s Contact information: %3$s You can approve or cancel this booking at: %4$s Thank you, Reservation service."', 'booking' ),'','[dates]<br/><br/>','<br/> [content]<br/><br/>', htmlentities( ' <a href="[moderatelink]">'.__('here' ,'booking').'</a> ') . '<br/><br/> '); | |
| 490 | 494 | |
| 491 | 495 | $help_fields = wpbc_get_email_help_shortcodes( $skip_shortcodes, $email_example ); |
| 492 | 496 | |
| 493 | 497 | foreach ( $help_fields as $help_fields_key => $help_fields_value ) { |
| @@ -527,9 +531,9 @@ | ||
| 527 | 531 | // if ( |
| 528 | 532 | // ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) ) |
| 529 | 533 | // && ( ! wpbc_is_current_user_have_this_role('contributor') ) |
| 530 | 534 | // ){ // If this User not "super admin", then do not load this page at all |
| 531 | -// return (string) rand(100000, 1000000); | |
| 535 | +// return (string) wp_rand(100000, 1000000); | |
| 532 | 536 | // } |
| 533 | 537 | |
| 534 | 538 | return 'wpbc-settings'; |
| 535 | 539 | } |
| @@ -541,14 +545,14 @@ | ||
| 541 | 545 | |
| 542 | 546 | $tabs[ 'email' ] = array( |
| 543 | 547 | 'title' => __( 'Emails', 'booking') // Title of TAB |
| 544 | 548 | , 'page_title'=> __( 'Emails Settings', 'booking') // Title of Page |
| 545 | - , 'hint' => __( 'Emails Settings', 'booking') // Hint | |
| 549 | + , 'hint' => __( 'Set up automatic email notifications for different booking actions.', 'booking') // Hint | |
| 546 | 550 | //, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link |
| 547 | 551 | //, 'position' => '' // 'left' || 'right' || '' |
| 548 | 552 | //, 'css_classes'=> '' // CSS class(es) |
| 549 | 553 | //, 'icon' => '' // Icon - link to the real PNG img |
| 550 | - , 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of forn Icon | |
| 554 | + , 'font_icon' => 'wpbc-bi-envelope-at 0wpbc_icn_mail_outline' // CSS definition of forn Icon | |
| 551 | 555 | //, 'default' => false // Is this tab activated by default or not: true || false. |
| 552 | 556 | //, 'disabled' => false // Is this tab disbaled: true || false. |
| 553 | 557 | //, 'hided' => false // Is this tab hided: true || false. |
| 554 | 558 | , 'subtabs' => array() |
| @@ -561,20 +565,20 @@ | ||
| 561 | 565 | |
| 562 | 566 | $subtabs['new-admin'] = array( |
| 563 | 567 | 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html' |
| 564 | 568 | , 'title' => __('New Booking' ,'booking') . ' (' . __('admin' ,'booking') . ')' // Title of TAB |
| 565 | - , 'page_title' => __('Emails Settings', 'booking') // Title of Page | |
| 569 | + , 'page_title' => __('Emails Settings', 'booking') . ' - <span>' . esc_html( __('New Booking' ,'booking') . ' - ' . ucfirst( __('admin' ,'booking') ) ) . '</span>' // Title of Page. | |
| 570 | + , 'hint' => __( 'Set up automatic email notification about new booking for Administrator', 'booking') // Hint | |
| 566 | 571 | , 'link' => '' // link |
| 567 | 572 | , 'position' => '' // 'left' || 'right' || '' |
| 568 | 573 | , 'css_classes' => '' // CSS class(es) |
| 569 | 574 | //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img |
| 570 | 575 | //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon |
| 571 | - , 'header_font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon //FixIn: 9.6.1.4 | |
| 572 | - , 'default' => true // Is this sub tab activated by default or not: true || false. | |
| 576 | + , 'default' => true // Is this sub tab activated by default or not: true || false. | |
| 573 | 577 | , 'disabled' => false // Is this sub tab deactivated: true || false. |
| 574 | 578 | , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' ) |
| 575 | 579 | , 'content' => 'content' // Function to load as conten of this TAB |
| 576 | - , 'is_use_left_navigation' => true | |
| 580 | + , 'font_icon' => 'wpbc-bi-envelope-paper 0wpbc_icn_mark_email_unread' | |
| 577 | 581 | , 'show_checked_icon' => true |
| 578 | 582 | , 'checked_data' => WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_NEW_ADMIN_ID // This is where we get content |
| 579 | 583 | //, 'hint' => array( 'title' => __('Customization of email template, which is sending to Admin after new booking' ,'booking') , 'position' => 'right' ) |
| 580 | 584 | ); |
| @@ -623,13 +627,13 @@ | ||
| 623 | 627 | <div class="clear"></div> |
| 624 | 628 | |
| 625 | 629 | <span class="metabox-holder"> |
| 626 | 630 | |
| 627 | - <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" autocomplete="off"> | |
| 631 | + <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" autocomplete="off"> | |
| 628 | 632 | <?php |
| 629 | 633 | // N o n c e field, and key for checking S u b m i t |
| 630 | 634 | wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name ); |
| 631 | - ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /> | |
| 635 | + ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /> | |
| 632 | 636 | |
| 633 | 637 | <div class="clear"></div> |
| 634 | 638 | <?php |
| 635 | 639 | |
| @@ -713,9 +717,9 @@ | ||
| 713 | 717 | |
| 714 | 718 | $init_fields_values = wpbc_import6_email__new_admin__get_fields_array_for_activation(); |
| 715 | 719 | |
| 716 | 720 | // Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table |
| 717 | - $init_fields_values_temp = array_values( $init_fields_values ); //FixIn: 7.0.1.32 | |
| 721 | + $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32. | |
| 718 | 722 | $init_fields_values = array_shift( $init_fields_values_temp ); |
| 719 | 723 | |
| 720 | 724 | |
| 721 | 725 | $this->mail_api( WPBC_EMAIL_NEW_ADMIN_ID, $init_fields_values ); |
| @@ -727,8 +731,9 @@ | ||
| 727 | 731 | $submit_form_name = 'wpbc_emails_template'; // Define form name |
| 728 | 732 | |
| 729 | 733 | $this->mail_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields before submit. |
| 730 | 734 | |
| 735 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 731 | 736 | if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { |
| 732 | 737 | |
| 733 | 738 | // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. } |
| 734 | 739 | $nonce_gen_time = check_admin_referer( 'wpbc_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page |
| @@ -825,10 +830,11 @@ | ||
| 825 | 830 | $replace = array(); |
| 826 | 831 | |
| 827 | 832 | // Resources /////////////////////////////////////////////////////////////// |
| 828 | 833 | $bk_title = wpbc_get_resource_title( $bktype ); |
| 834 | + $parent_resource_title = wpbc_get_parent_resource_title( $bktype ); // FixIn: 10.9.2.4. | |
| 829 | 835 | |
| 830 | - //FixIn: 9.6.3.10 | |
| 836 | + // FixIn: 9.6.3.10. | |
| 831 | 837 | if ( class_exists( 'wpdev_bk_biz_l' ) ) { |
| 832 | 838 | $booking_data_arr = wpbc_api_get_booking_by_id( $booking_id ); |
| 833 | 839 | |
| 834 | 840 | $child_resource_id = (int) $booking_data_arr['booking_type']; |
| @@ -837,45 +843,61 @@ | ||
| 837 | 843 | } |
| 838 | 844 | |
| 839 | 845 | // Dates /////////////////////////////////////////////////////////////////// |
| 840 | 846 | $my_dates4emeil = wpbc_db__get_sql_dates__in_booking__as_str( $booking_id ); |
| 841 | - if ( get_bk_option( 'booking_date_view_type' ) == 'short' ) | |
| 842 | - $my_dates_4_send = wpbc_get_dates_short_format( $my_dates4emeil ); | |
| 843 | - else | |
| 844 | - $my_dates_4_send = wpbc_get_dates_comma_string_localized( $my_dates4emeil ); | |
| 845 | - | |
| 846 | - $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil ); | |
| 847 | 847 | |
| 848 | - $my_check_in_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[0] ); | |
| 849 | - $my_check_out_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); | |
| 850 | - //FixIn: 8.7.2.5 | |
| 851 | - $my_check_in_onlydate = wpbc_date_localized( date( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[0] ) ), 'Y-m-d' ); | |
| 852 | - $my_check_out_onlydate = wpbc_date_localized( date( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ) ), 'Y-m-d' ); | |
| 848 | + $my_dates_4_send = ( 'short' === get_bk_option( 'booking_date_view_type' ) ) | |
| 849 | + ? wpbc_get_dates_short_format( $my_dates4emeil ) | |
| 850 | + : wpbc_get_dates_comma_string_localized( $my_dates4emeil ); | |
| 851 | + $my_dates4emeil_check_in_out = explode( ',', $my_dates4emeil ); | |
| 853 | 852 | |
| 854 | - $my_check_out_plus1day = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( date( 'Y-m-d H:i:s', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] . " +1 day" ) ), 'Y-m-d H:i:s' ) ); | |
| 853 | + $my_check_in_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[0] ); | |
| 854 | + $my_check_out_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); | |
| 855 | + $my_check_in_onlydate_ymd = wpbc_date_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[0] ) ), 'Y-m-d' ); // FixIn: 8.7.2.5. | |
| 856 | + $my_check_out_onlydate_ymd = wpbc_date_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ) ), 'Y-m-d' ); | |
| 857 | + $my_check_in_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[0] ) ), 'Y-m-d 00:00:00' ) ); // FixIn: 8.7.2.5. | |
| 858 | + $my_check_out_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ) ), 'Y-m-d 00:00:00' ) ); | |
| 859 | + $my_check_out_plus1day = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( gmdate( 'Y-m-d H:i:s', strtotime( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] . " +1 day" ) ), 'Y-m-d H:i:s' ) ); | |
| 855 | 860 | |
| 861 | + // FixIn: 10.1.5.6. | |
| 862 | + $dates_only_arr = wpbc_get_only_dates__from_dates_ymd_his_csv__as_arr( $my_dates4emeil ); // -> '2023-10-09, 2023-10-09' | |
| 863 | + $dates_only_str = implode( ',', $dates_only_arr ); | |
| 864 | + $dates_only_str_formatted = ( 'short' === get_bk_option( 'booking_date_view_type' ) ) | |
| 865 | + ? wpbc_get_dates_short_format( $dates_only_str ) | |
| 866 | + : wpbc_get_dates_comma_string_localized( $dates_only_str ); | |
| 867 | + | |
| 856 | 868 | // Cost //////////////////////////////////////////////////////////////////// |
| 857 | - $booking_cost_digits_only = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id ); //FixIn: 9.2.3.1 | |
| 869 | + $booking_cost_digits_only = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id ); // FixIn: 9.2.3.1. | |
| 858 | 870 | $booking_cost = wpbc_get_cost_with_currency_for_user( $booking_cost_digits_only ); |
| 859 | 871 | // Other /////////////////////////////////////////////////////////////////// |
| 860 | 872 | $replace[ 'booking_id' ] = $booking_id; |
| 861 | 873 | $replace[ 'id' ] = $replace[ 'booking_id' ]; |
| 862 | 874 | $replace[ 'dates' ] = $my_dates_4_send; |
| 875 | + $replace[ 'only_dates' ] = $dates_only_str_formatted; | |
| 876 | + $replace[ 'dates_only' ] = $dates_only_str_formatted; | |
| 863 | 877 | $replace[ 'check_in_date' ] = $my_check_in_date; |
| 864 | - $replace[ 'check_out_date' ] = $my_check_out_date; | |
| 865 | - //FixIn: 8.7.2.5 | |
| 878 | + $replace[ 'check_out_date' ] = $my_check_out_date; | |
| 879 | + // FixIn: 8.7.2.5. | |
| 866 | 880 | $replace[ 'check_in_only_date' ] = $my_check_in_onlydate; |
| 867 | 881 | $replace[ 'check_out_only_date' ] = $my_check_out_onlydate; |
| 868 | - $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; //FixIn: 6.0.1.11 | |
| 869 | - $replace[ 'dates_count' ] = count( $my_dates4emeil_check_in_out ); | |
| 882 | + $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; // FixIn: 6.0.1.11. | |
| 883 | + | |
| 884 | + $replace['dates_count'] = count( $my_dates4emeil_check_in_out ); | |
| 885 | + $replace['days_count'] = intval( $replace['dates_count'] ); // FixIn: 10.15.1.3. | |
| 886 | + $replace['nights_count'] = ( $replace['days_count'] > 1 ) ? intval( $replace['days_count'] - 1 ) : 1; | |
| 887 | + $replace['days_count_plus1day'] = intval( $replace['days_count'] + 1 ); | |
| 888 | + | |
| 870 | 889 | $replace['cost'] = $booking_cost; |
| 871 | 890 | $replace['cost_digits_only'] = $booking_cost_digits_only; |
| 872 | - $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . home_url() . '">' . home_url() . '</a>' ); | |
| 891 | + $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . esc_url( home_url() ) . '">' . home_url() . '</a>' ); | |
| 873 | 892 | $replace[ 'resource_title'] = wpbc_lang( $bk_title ); |
| 893 | + $replace[ 'parent_resource_title'] = wpbc_lang( $parent_resource_title ); // FixIn: 10.9.2.4. | |
| 874 | 894 | $replace[ 'bookingtype' ] = $replace[ 'resource_title']; |
| 875 | - $replace[ 'remote_ip' ] = wpbc_get_user_ip(); //FixIn:7.1.2.4 // The IP address from which the user is viewing the current page. | |
| 876 | - $replace[ 'user_agent' ] = $_SERVER['HTTP_USER_AGENT']; // Contents of the User-Agent: header from the current request, if there is one. | |
| 877 | - $replace[ 'request_url' ] = ( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '' ); // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP | |
| 895 | + $replace[ 'remote_ip' ] = wpbc_get_user_ip(); //FixIn:7.1.2.4 // The IP address from which the user is viewing the current page. | |
| 896 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 897 | + $replace[ 'user_agent' ] = ( ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ) : '' ); // Contents of the User-Agent: header from the current request, if there is one. | |
| 898 | + $server_http_referer_uri = ( ( isset( $_SERVER['HTTP_REFERER'] ) ) ? sanitize_text_field( $_SERVER['HTTP_REFERER'] ) : '' ); /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.MissingUnslash */ /* FixIn: sanitize_unslash */ | |
| 899 | + $replace['request_url'] = $server_http_referer_uri; // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP | |
| 878 | 900 | $replace[ 'current_date' ] = date_i18n( get_bk_option( 'booking_date_format' ) ); |
| 879 | 901 | $replace[ 'current_time' ] = date_i18n( get_bk_option( 'booking_time_format' ) ); |
| 880 | 902 | |
| 881 | 903 | // Form Fields ///////////////////////////////////////////////////////////// |
| @@ -890,16 +912,16 @@ | ||
| 890 | 912 | |
| 891 | 913 | // Links /////////////////////////////////////////////////////////////////// |
| 892 | 914 | $replace[ 'moderatelink' ] = htmlspecialchars_decode( |
| 893 | 915 | // '<a href="' . |
| 894 | - esc_url( wpbc_get_bookings_url() . '&view_mode=vm_listing&tab=actions&wh_booking_id=' . $booking_id ) | |
| 895 | - // . '">' . __('here', 'booking') . '</a>' | |
| 916 | + esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing&wh_booking_id=' . $booking_id ) | |
| 917 | + // . '">' . esc_html__('here', 'booking') . '</a>' | |
| 896 | 918 | ); |
| 897 | 919 | |
| 898 | 920 | if ( function_exists( 'wpbc_get_url_click2approve' ) ) { |
| 899 | - $replace['click2approve'] = wpbc_get_url_click2approve( $booking_id ); //FixIn: 8.4.7.25 | |
| 900 | - $replace['click2decline'] = wpbc_get_url_click2decline( $booking_id ); //FixIn: 8.4.7.25 | |
| 901 | - $replace['click2trash'] = wpbc_get_url_click2trash( $booking_id ); //FixIn: 8.4.7.25 | |
| 921 | + $replace['click2approve'] = wpbc_get_url_click2approve( $booking_id ); // FixIn: 8.4.7.25. | |
| 922 | + $replace['click2decline'] = wpbc_get_url_click2decline( $booking_id ); // FixIn: 8.4.7.25. | |
| 923 | + $replace['click2trash'] = wpbc_get_url_click2trash( $booking_id ); // FixIn: 8.4.7.25. | |
| 902 | 924 | } |
| 903 | 925 | |
| 904 | 926 | $replace[ 'visitorbookingediturl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $booking_id ); |
| 905 | 927 | $replace[ 'visitorbookingslisting' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingslisting]', $booking_id ); //FixIn: 8.1.3.5.1 |
| @@ -907,18 +929,18 @@ | ||
| 907 | 929 | $replace[ 'visitorbookingpayurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $booking_id ); |
| 908 | 930 | $replace[ 'bookinghash' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[bookinghash]', $booking_id ); |
| 909 | 931 | |
| 910 | 932 | |
| 911 | - //FixIn: 7.1.2.5 | |
| 933 | + // FixIn: 7.1.2.5. | |
| 912 | 934 | // $booking_data = array( 'form_data' => $booking_form_show_array ); |
| 913 | 935 | // $booking_data[ 'dates_short' ] = array( $my_dates4emeil_check_in_out[ 0 ], '-', $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); |
| 914 | 936 | // $replace[ 'add_to_google_cal_url' ] = htmlspecialchars_decode( esc_url( |
| 915 | 937 | // wpbc_btn_add_booking_to_google_calendar( $booking_data , array( 'is_only_url' => true ), false ) |
| 916 | 938 | // ) ); |
| 917 | - //FixIn: 9.6.3.8 | |
| 939 | + // FixIn: 9.6.3.8. | |
| 918 | 940 | $google_calendar_link = wpbc_booking_do_action__get_google_calendar_link( array( |
| 919 | 941 | 'form_data' => $booking_form_show_array['_all_fields_'], |
| 920 | - 'form_show' => $booking_form_show_array['content'], //strip_tags( $parsed_form_show ), | |
| 942 | + 'form_show' => $booking_form_show_array['content'], //wp_strip_all_tags( $parsed_form_show ), | |
| 921 | 943 | 'dates_short' => array( |
| 922 | 944 | $my_dates4emeil_check_in_out[0] |
| 923 | 945 | , '-' |
| 924 | 946 | , $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] |
| @@ -924,16 +946,15 @@ | ||
| 924 | 946 | , $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] |
| 925 | 947 | ) |
| 926 | 948 | ) ); |
| 927 | 949 | $replace['add_to_google_cal_url'] = htmlspecialchars_decode( esc_url( $google_calendar_link ) ); |
| 928 | - $replace['add_to_google_cal_button'] = '<a href="' . esc_attr( $replace['add_to_google_cal_url'] ) . '" target="_blank" rel="nofollow">Add to Google Calendar</a>'; | |
| 950 | + $replace['add_to_google_cal_button'] = '<a href="' . esc_attr( $replace['add_to_google_cal_url'] ) . '" target="_blank" rel="nofollow">' . esc_attr__( 'Add to Google Calendar', 'booking' ) . '</a>'; | |
| 929 | 951 | |
| 930 | 952 | |
| 931 | 953 | // Get additional replace paramaters to the email shortcodes |
| 932 | - $replace = apply_filters( 'wpbc_replace_params_for_booking', $replace, $booking_id, $bktype, $formdata ); //FixIn: 8.0.1.7 | |
| 954 | + $replace = apply_filters( 'wpbc_replace_params_for_booking', $replace, $booking_id, $bktype, $formdata ); // FixIn: 8.0.1.7. | |
| 933 | 955 | |
| 934 | - //////////////////////////////////////////////////////////////////////////// | |
| 935 | - | |
| 956 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 936 | 957 | return $replace; |
| 937 | 958 | |
| 938 | 959 | |
| 939 | 960 | } |
| @@ -968,16 +989,15 @@ | ||
| 968 | 989 | |
| 969 | 990 | $init_fields_values = wpbc_import6_email__new_admin__get_fields_array_for_activation(); |
| 970 | 991 | |
| 971 | 992 | // Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table |
| 972 | - $init_fields_values_temp = array_values( $init_fields_values ); //FixIn: 7.0.1.32 | |
| 993 | + $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32. | |
| 973 | 994 | $init_fields_values = array_shift( $init_fields_values_temp ); |
| 974 | 995 | |
| 975 | 996 | |
| 976 | 997 | $mail_api = new WPBC_Emails_API_NewAdmin( WPBC_EMAIL_NEW_ADMIN_ID, $init_fields_values ); |
| 977 | 998 | |
| 978 | - //////////////////////////////////////////////////////////////////////////// | |
| 979 | - | |
| 999 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 980 | 1000 | if ( $mail_api->fields_values['enabled'] == 'Off' ) return false; // Email template deactivated - exit. |
| 981 | 1001 | |
| 982 | 1002 | |
| 983 | 1003 | $replace = wpbc__get_replace_shortcodes__email_new_admin( $booking_id, $bktype, $formdata ); |
| @@ -995,15 +1015,15 @@ | ||
| 995 | 1015 | $pos = $shortcode_params['end']; |
| 996 | 1016 | |
| 997 | 1017 | $exist_replace = substr( $mail_api->fields_values['content'], $shortcode_params['start'], ( $shortcode_params['end'] - $shortcode_params['start'] ) ); |
| 998 | 1018 | |
| 999 | - $new_replace = $url_shortcode . rand(1000,9000); | |
| 1019 | + $new_replace = $url_shortcode . wp_rand(1000,9000); | |
| 1000 | 1020 | |
| 1001 | 1021 | $pos = $shortcode_params['start'] + strlen( $new_replace ); //FixIn: 9.7.3.5.1 |
| 1002 | 1022 | $mail_api->fields_values['content'] = str_replace( $exist_replace, $new_replace ,$mail_api->fields_values['content'] ); |
| 1003 | 1023 | |
| 1004 | 1024 | $replace[ $new_replace ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '['.$exist_replace.']', $booking_id ); |
| 1005 | - } else if ( //FixIn: 8.1.1.8 | |
| 1025 | + } else if ( // FixIn: 8.1.1.8. | |
| 1006 | 1026 | ( ! empty( $shortcode_params ) ) |
| 1007 | 1027 | && ( isset( $shortcode_params['end'] ) ) |
| 1008 | 1028 | && ( $shortcode_params['end'] < strlen( $mail_api->fields_values['content'] ) ) |
| 1009 | 1029 | ) { |
| @@ -1011,50 +1031,172 @@ | ||
| 1011 | 1031 | } else { |
| 1012 | 1032 | $shortcode_params = false; //FixIn: 7.0.1.58 |
| 1013 | 1033 | } |
| 1014 | 1034 | |
| 1015 | - } while ( ! empty( $shortcode_params ) ); //FixIn: 7.0.1.52 | |
| 1035 | + } while ( ! empty( $shortcode_params ) ); // FixIn: 7.0.1.52. | |
| 1016 | 1036 | |
| 1017 | 1037 | } |
| 1018 | 1038 | |
| 1019 | 1039 | $mail_api->set_replace( $replace ); |
| 1020 | - $mail_api->fields_values['from_name'] = $mail_api->replace_shortcodes( $mail_api->fields_values['from_name'] ); //FixIn: 7.0.1.29 | |
| 1040 | + $mail_api->fields_values['from_name'] = $mail_api->replace_shortcodes( $mail_api->fields_values['from_name'] ); // FixIn: 7.0.1.29. | |
| 1021 | 1041 | |
| 1022 | - if ( ( strpos( $mail_api->fields_values['to'], ',') === false ) && ( strpos( $mail_api->fields_values['to'], ';') === false ) ) { | |
| 1023 | - | |
| 1024 | - $valid_email = sanitize_email( $mail_api->fields_values['to'] ); | |
| 1025 | - if ( ! empty( $valid_email ) ) | |
| 1026 | - $to = trim( wp_specialchars_decode( esc_html( stripslashes( $mail_api->fields_values['to_name'] ) ), ENT_QUOTES ) ) | |
| 1027 | - . ' <' . $valid_email . '> '; | |
| 1042 | + $email_result = false; | |
| 1043 | + | |
| 1044 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1045 | + // Case #1. Semicolon => send SEPARATE emails. | |
| 1046 | + // Example: | |
| 1047 | + // to = admin1@example.com;admin2@example.com | |
| 1048 | + // to_name = Admin One;Admin Two | |
| 1049 | + // | |
| 1050 | + // Also supported: | |
| 1051 | + // to = admin1@example.com,sales@example.com;support@example.com | |
| 1052 | + // to_name = Admin One,Sales Team;Support Team | |
| 1053 | + // => first email sent to 2 recipients, second email sent separately. | |
| 1054 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1055 | + if ( strpos( $mail_api->fields_values['to'], ';' ) !== false ) { | |
| 1056 | + | |
| 1057 | + $to_groups = explode( ';', $mail_api->fields_values['to'] ); | |
| 1058 | + $to_name_groups = explode( ';', $mail_api->fields_values['to_name'] ); | |
| 1059 | + | |
| 1060 | + $email_result = true; | |
| 1061 | + $sent_emails = 0; | |
| 1062 | + | |
| 1063 | + foreach ( $to_groups as $group_ind => $to_group ) { | |
| 1064 | + | |
| 1065 | + $to_group = trim( $to_group ); | |
| 1066 | + if ( '' === $to_group ) { | |
| 1067 | + continue; | |
| 1068 | + } | |
| 1069 | + | |
| 1070 | + $to_name_group = ''; | |
| 1071 | + if ( ! empty( $to_name_groups ) ) { | |
| 1072 | + $to_name_group = $to_name_groups[ count( $to_name_groups ) - 1 ]; | |
| 1073 | + if ( isset( $to_name_groups[ $group_ind ] ) ) { | |
| 1074 | + $to_name_group = $to_name_groups[ $group_ind ]; | |
| 1075 | + } | |
| 1076 | + } | |
| 1077 | + | |
| 1078 | + // One recipient in this group. | |
| 1079 | + if ( strpos( $to_group, ',' ) === false ) { | |
| 1080 | + | |
| 1081 | + $valid_email = sanitize_email( $to_group ); | |
| 1082 | + | |
| 1083 | + if ( empty( $valid_email ) ) { | |
| 1084 | + continue; | |
| 1085 | + } | |
| 1086 | + | |
| 1087 | + $to = trim( | |
| 1088 | + wp_specialchars_decode( | |
| 1089 | + esc_html( stripslashes( $to_name_group ) ), | |
| 1090 | + ENT_QUOTES | |
| 1091 | + ) | |
| 1092 | + ) . ' <' . $valid_email . '> '; | |
| 1093 | + | |
| 1094 | + // Several recipients in this group => send one email to this comma-separated group. | |
| 1095 | + } else { | |
| 1096 | + | |
| 1097 | + $to_array = explode( ',', $to_group ); | |
| 1098 | + $to_name = explode( ',', $to_name_group ); | |
| 1099 | + | |
| 1100 | + $to = array(); | |
| 1101 | + | |
| 1102 | + foreach ( $to_array as $to_ind => $to_email ) { | |
| 1103 | + | |
| 1104 | + $to_name_str = ''; | |
| 1105 | + if ( ! empty( $to_name ) ) { | |
| 1106 | + $to_name_str = $to_name[ count( $to_name ) - 1 ]; | |
| 1107 | + if ( isset( $to_name[ $to_ind ] ) ) { | |
| 1108 | + $to_name_str = $to_name[ $to_ind ]; | |
| 1109 | + } | |
| 1110 | + } | |
| 1111 | + | |
| 1112 | + $valid_email = sanitize_email( $to_email ); | |
| 1113 | + if ( ! empty( $valid_email ) ) { | |
| 1114 | + $to[] = trim( | |
| 1115 | + wp_specialchars_decode( | |
| 1116 | + esc_html( stripslashes( $to_name_str ) ), | |
| 1117 | + ENT_QUOTES | |
| 1118 | + ) | |
| 1119 | + ) . ' <' . $valid_email . '> '; | |
| 1120 | + } | |
| 1121 | + } | |
| 1122 | + | |
| 1123 | + $to = implode( ',', $to ); | |
| 1124 | + } | |
| 1125 | + | |
| 1126 | + if ( wpbc_is_not_blank_email( $to, $replace['content'] ) ) { | |
| 1127 | + $single_result = $mail_api->send( $to, $replace ); | |
| 1128 | + $email_result = ( $email_result && (bool) $single_result ); | |
| 1129 | + $sent_emails++; | |
| 1130 | + } | |
| 1131 | + } | |
| 1132 | + | |
| 1133 | + if ( 0 === $sent_emails ) { | |
| 1134 | + $email_result = false; | |
| 1135 | + } | |
| 1136 | + | |
| 1137 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1138 | + // Case #2. No semicolon => keep old behavior. | |
| 1139 | + // Single email OR one email to several comma-separated recipients. | |
| 1140 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1028 | 1141 | } else { |
| 1029 | - | |
| 1030 | - // Comma separated several emails - validate all these emails in Email API class | |
| 1031 | - $to_array = $mail_api->fields_values['to']; | |
| 1032 | - | |
| 1033 | - $to_array = str_replace(';', ',', $to_array); | |
| 1034 | - if ( !is_array( $to_array ) ) $to_array = explode( ',', $to_array ); | |
| 1035 | 1142 | |
| 1036 | - $to_name = str_replace(';', ',', $mail_api->fields_values['to_name']); | |
| 1037 | - if ( !is_array( $to_name ) ) $to_name = explode( ',', $to_name ); | |
| 1143 | + if ( strpos( $mail_api->fields_values['to'], ',' ) === false ) { | |
| 1038 | 1144 | |
| 1039 | - $to = array(); | |
| 1040 | - foreach ( $to_array as $to_ind => $to_email) { | |
| 1041 | - | |
| 1042 | - $to_name_str = $to_name[ ( count( $to_name ) - 1 ) ]; | |
| 1043 | - | |
| 1044 | - if ( isset( $to_name[ $to_ind ] ) ) | |
| 1045 | - $to_name_str = $to_name[ $to_ind ]; | |
| 1145 | + $valid_email = sanitize_email( $mail_api->fields_values['to'] ); | |
| 1046 | 1146 | |
| 1047 | - $valid_email = sanitize_email( $to_email ); | |
| 1048 | - if ( ! empty( $valid_email ) ) | |
| 1049 | - $to[] = trim( wp_specialchars_decode( esc_html( stripslashes( $to_name_str ) ), ENT_QUOTES ) ) . ' <' . $valid_email . '> '; | |
| 1147 | + if ( ! empty( $valid_email ) ) { | |
| 1148 | + $to = trim( | |
| 1149 | + wp_specialchars_decode( | |
| 1150 | + esc_html( stripslashes( $mail_api->fields_values['to_name'] ) ), | |
| 1151 | + ENT_QUOTES | |
| 1152 | + ) | |
| 1153 | + ) . ' <' . $valid_email . '> '; | |
| 1154 | + } else { | |
| 1155 | + $to = ''; | |
| 1156 | + } | |
| 1157 | + | |
| 1158 | + } else { | |
| 1159 | + | |
| 1160 | + $to_array = $mail_api->fields_values['to']; | |
| 1161 | + if ( ! is_array( $to_array ) ) { | |
| 1162 | + $to_array = explode( ',', $to_array ); | |
| 1163 | + } | |
| 1164 | + | |
| 1165 | + $to_name = $mail_api->fields_values['to_name']; | |
| 1166 | + if ( ! is_array( $to_name ) ) { | |
| 1167 | + $to_name = explode( ',', $to_name ); | |
| 1168 | + } | |
| 1169 | + | |
| 1170 | + $to = array(); | |
| 1171 | + | |
| 1172 | + foreach ( $to_array as $to_ind => $to_email ) { | |
| 1173 | + | |
| 1174 | + $to_name_str = ''; | |
| 1175 | + if ( ! empty( $to_name ) ) { | |
| 1176 | + $to_name_str = $to_name[ count( $to_name ) - 1 ]; | |
| 1177 | + if ( isset( $to_name[ $to_ind ] ) ) { | |
| 1178 | + $to_name_str = $to_name[ $to_ind ]; | |
| 1179 | + } | |
| 1180 | + } | |
| 1181 | + | |
| 1182 | + $valid_email = sanitize_email( $to_email ); | |
| 1183 | + if ( ! empty( $valid_email ) ) { | |
| 1184 | + $to[] = trim( | |
| 1185 | + wp_specialchars_decode( | |
| 1186 | + esc_html( stripslashes( $to_name_str ) ), | |
| 1187 | + ENT_QUOTES | |
| 1188 | + ) | |
| 1189 | + ) . ' <' . $valid_email . '> '; | |
| 1190 | + } | |
| 1191 | + } | |
| 1192 | + | |
| 1193 | + $to = implode( ',', $to ); | |
| 1050 | 1194 | } |
| 1051 | - $to = implode(',', $to); | |
| 1052 | - | |
| 1053 | - } | |
| 1054 | 1195 | |
| 1055 | - if ( wpbc_is_not_blank_email( $to, $replace['content'] ) ) { | |
| 1056 | - $email_result = $mail_api->send( $to , $replace ); | |
| 1196 | + if ( wpbc_is_not_blank_email( $to, $replace['content'] ) ) { | |
| 1197 | + $email_result = $mail_api->send( $to, $replace ); | |
| 1198 | + } | |
| 1057 | 1199 | } |
| 1058 | 1200 | |
| 1059 | 1201 | make_bk_action( 'wpbc_mu_set_environment_for_user', $previous_active_user ); // MU |
| 1060 | 1202 | |