| @@ -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 " > |
| @@ -193,9 +193,9 @@ | ||
| 193 | 193 | |
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | 196 | |
| 197 | -//FixIn: 8.1.2.17 | |
| 197 | +// FixIn: 8.1.2.17. | |
| 198 | 198 | $this->fields['to_html_prefix'] = array( |
| 199 | 199 | 'type' => 'pure_html' |
| 200 | 200 | , 'group' => 'general' |
| 201 | 201 | , 'html' => '<tr valign="top" class="wpbc_tr_copy_to_admin_to"> |
| @@ -268,9 +268,9 @@ | ||
| 268 | 268 | 'type' => 'email' // Its can be only 1 email, so check it as Email field. |
| 269 | 269 | , 'default' => get_option( 'admin_email' ) |
| 270 | 270 | //, 'placeholder' => '' |
| 271 | 271 | , 'title' => '' |
| 272 | - , 'description' => __('Email Address', 'booking') . '. ' . __('Required', 'booking') . '. ' . __('Email Address will be used in the FROM field of response to Visitor.', 'booking') //FixIn: 8.1.2.17 | |
| 272 | + , 'description' => __('Email Address', 'booking') . '. ' . __('Required', 'booking') . '. ' . __('Email Address will be used in the FROM field of response to Visitor.', 'booking') // FixIn: 8.1.2.17. | |
| 273 | 273 | , 'description_tag' => '' |
| 274 | 274 | , 'css' => 'width:100%' |
| 275 | 275 | , 'group' => 'general' |
| 276 | 276 | , 'tr_class' => '' |
| @@ -328,9 +328,10 @@ | ||
| 328 | 328 | , 'only_field' => true |
| 329 | 329 | ); |
| 330 | 330 | $this->fields['subject_after'] = array( 'type' => 'pure_html', 'group' => 'general_content', |
| 331 | 331 | 'html' => '<p style="text-align: right;font-size:12px;">' |
| 332 | - . sprintf(__('Type your email %ssubject%s for the booking confirmation message.' ,'booking'),'<b>','</b>') . ' ' . __('Required', 'booking') | |
| 332 | + /* translators: 1: ... */ | |
| 333 | + . sprintf( __( 'Type your email %1$ssubject%2$s for the booking confirmation message.', 'booking' ),'<b>','</b>') . ' ' . __('Required', 'booking') | |
| 333 | 334 | . '.</p>' . '</td></tr>' ); |
| 334 | 335 | |
| 335 | 336 | $blg_title = get_option( 'blogname' ); |
| 336 | 337 | $blg_title = str_replace( array( '"', "'" ), '', $blg_title ); |
| @@ -335,11 +336,13 @@ | ||
| 335 | 336 | $blg_title = get_option( 'blogname' ); |
| 336 | 337 | $blg_title = str_replace( array( '"', "'" ), '', $blg_title ); |
| 337 | 338 | |
| 338 | 339 | if ( class_exists( 'wpdev_bk_personal' ) ) { |
| 339 | - $email_content = sprintf( __( 'Your reservation %s for: %s has been approved.%sYou can edit the booking on this page: %s Thank you, %s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', '[visitorbookingediturl]<br/><br/>', $blg_title . '<br/>[siteurl]' ); | |
| 340 | + /* translators: 1: ... */ | |
| 341 | + $email_content = sprintf( __( 'Your reservation %1$s for: %2$s has been approved.%3$sYou can edit the booking on this page: %4$s Thank you, %5$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', '[visitorbookingediturl]<br/><br/>', $blg_title . '<br/>[siteurl]' ); | |
| 340 | 342 | } else { |
| 341 | - $email_content = sprintf( __( 'Your booking %s for: %s has been approved.%sThank you, %s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' ); | |
| 343 | + /* translators: 1: ... */ | |
| 344 | + $email_content = sprintf( __( 'Your booking %1$s for: %2$s has been approved.%3$sThank you, %4$s', 'booking' ), '[bookingtype]', '[dates]', '<br/><br/>[content]<br/><br/>', $blg_title . '<br/>[siteurl]' ); | |
| 342 | 345 | } |
| 343 | 346 | |
| 344 | 347 | $this->fields['content_before'] = array( |
| 345 | 348 | 'type' => 'pure_html', |
| @@ -411,9 +414,10 @@ | ||
| 411 | 414 | ); |
| 412 | 415 | |
| 413 | 416 | $this->fields['template_file_help'] = array( |
| 414 | 417 | 'type' => 'help' |
| 415 | - , 'value' => array( sprintf( __('You can override this email template in this folder %s', 'booking') | |
| 418 | + /* translators: 1: ... */ | |
| 419 | + , 'value' => array( sprintf( __( 'You can override this email template in this folder %s', 'booking') | |
| 416 | 420 | , '<code>' . realpath( dirname(__FILE__) . '/../any/emails_tpl/' ) . '</code>' ) |
| 417 | 421 | ) |
| 418 | 422 | , 'cols' => 2 |
| 419 | 423 | , 'group' => 'style' |
| @@ -506,9 +510,10 @@ | ||
| 506 | 510 | //, 'visitorbookingslisting' //FixIn: 8.1.3.5.1 |
| 507 | 511 | , 'visitorbookingcancelurl' |
| 508 | 512 | , 'visitorbookingpayurl' |
| 509 | 513 | ); |
| 510 | - $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/> '); | |
| 514 | + /* translators: 1: ... */ | |
| 515 | + $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/> '); | |
| 511 | 516 | |
| 512 | 517 | $help_fields = wpbc_get_email_help_shortcodes( $skip_shortcodes, $email_example ); |
| 513 | 518 | |
| 514 | 519 | foreach ( $help_fields as $help_fields_key => $help_fields_value ) { |
| @@ -579,10 +584,10 @@ | ||
| 579 | 584 | } |
| 580 | 585 | |
| 581 | 586 | $subtabs['approved'] = array( |
| 582 | 587 | 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html' |
| 583 | - , 'title' => '<span>' . __( 'Approved', 'booking' ) . $sufix . '</span>' // Title of TAB | |
| 584 | - , 'page_title' => __('Emails Settings', 'booking') // Title of Page | |
| 588 | + , 'title' => '<span>' . esc_html__( 'Approved', 'booking' ) . $sufix . '</span>' // Title of TAB | |
| 589 | + , 'page_title' => __('Emails Settings', 'booking') . ' - <span>' . esc_html__( 'Approved', 'booking' ) . $sufix . '</span>' // Title of Page. | |
| 585 | 590 | , 'hint' => __('Customization of email template, which is sent to Visitor after approval of booking' ,'booking') //FixIn: 8.1.2.17.1 |
| 586 | 591 | , 'link' => '' // link |
| 587 | 592 | , 'position' => '' // 'left' || 'right' || '' |
| 588 | 593 | , 'css_classes' => '' // CSS class(es) |
| @@ -587,14 +592,13 @@ | ||
| 587 | 592 | , 'position' => '' // 'left' || 'right' || '' |
| 588 | 593 | , 'css_classes' => '' // CSS class(es) |
| 589 | 594 | //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img |
| 590 | 595 | //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon |
| 591 | - , 'header_font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon //FixIn: 9.6.1.4 | |
| 592 | - , 'default' => false // Is this sub tab activated by default or not: true || false. | |
| 596 | + , 'default' => false // Is this sub tab activated by default or not: true || false. | |
| 593 | 597 | , 'disabled' => false // Is this sub tab deactivated: true || false. |
| 594 | 598 | , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' ) |
| 595 | 599 | , 'content' => 'content' // Function to load as conten of this TAB |
| 596 | - , 'is_use_left_navigation' => true | |
| 600 | + , 'font_icon' => 'wpbc_icn_done_all' | |
| 597 | 601 | , 'show_checked_icon' => true |
| 598 | 602 | , 'checked_data' => WPBC_EMAIL_NEW_ADMIN_PREFIX . WPBC_EMAIL_APPROVED_ID // This is where we get content |
| 599 | 603 | ); |
| 600 | 604 | |
| @@ -642,13 +646,13 @@ | ||
| 642 | 646 | <div class="clear"></div> |
| 643 | 647 | |
| 644 | 648 | <span class="metabox-holder"> |
| 645 | 649 | |
| 646 | - <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" autocomplete="off"> | |
| 650 | + <form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" autocomplete="off"> | |
| 647 | 651 | <?php |
| 648 | 652 | // N o n c e field, and key for checking S u b m i t |
| 649 | 653 | wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name ); |
| 650 | - ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /> | |
| 654 | + ?><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"/> | |
| 651 | 655 | |
| 652 | 656 | <div class="clear"></div> |
| 653 | 657 | <?php |
| 654 | 658 | |
| @@ -732,9 +736,9 @@ | ||
| 732 | 736 | |
| 733 | 737 | $init_fields_values = wpbc_import6_email__approved__get_fields_array_for_activation(); |
| 734 | 738 | |
| 735 | 739 | // 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 |
| 736 | - $init_fields_values_temp = array_values( $init_fields_values ); //FixIn: 7.0.1.32 | |
| 740 | + $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32. | |
| 737 | 741 | $init_fields_values = array_shift( $init_fields_values_temp ); |
| 738 | 742 | |
| 739 | 743 | |
| 740 | 744 | $this->mail_api( WPBC_EMAIL_APPROVED_ID, $init_fields_values ); |
| @@ -747,8 +751,9 @@ | ||
| 747 | 751 | $submit_form_name = 'wpbc_emails_template'; // Define form name |
| 748 | 752 | |
| 749 | 753 | $this->mail_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields before submit. |
| 750 | 754 | |
| 755 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 751 | 756 | if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { |
| 752 | 757 | |
| 753 | 758 | // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. } |
| 754 | 759 | $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 |
| @@ -821,9 +826,9 @@ | ||
| 821 | 826 | $js_script .= " jQuery('#approved_from_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'booking' ))."</div>')"; |
| 822 | 827 | $js_script .= " }"; |
| 823 | 828 | $js_script .= " }); "; |
| 824 | 829 | |
| 825 | - //FixIn: 8.1.2.17 | |
| 830 | + // FixIn: 8.1.2.17. | |
| 826 | 831 | $js_script .= " jQuery('#approved_copy_to_admin').on( 'change', function(){ "; |
| 827 | 832 | $js_script .= " if ( jQuery('#approved_copy_to_admin').is(':checked') ) {"; |
| 828 | 833 | $js_script .= " jQuery('.wpbc_tr_copy_to_admin_to').show();"; |
| 829 | 834 | $js_script .= " } else { "; |
| @@ -863,49 +868,65 @@ | ||
| 863 | 868 | $replace = array(); |
| 864 | 869 | |
| 865 | 870 | // Resources /////////////////////////////////////////////////////////////// |
| 866 | 871 | $bk_title = wpbc_get_resource_title( $bktype ); |
| 872 | + $parent_resource_title = wpbc_get_parent_resource_title( $bktype ); // FixIn: 10.9.2.4. | |
| 867 | 873 | |
| 868 | 874 | // Dates /////////////////////////////////////////////////////////////////// |
| 869 | 875 | $my_dates4emeil = wpbc_db__get_sql_dates__in_booking__as_str( $booking_id ); |
| 870 | - if ( get_bk_option( 'booking_date_view_type' ) == 'short' ) | |
| 871 | - $my_dates_4_send = wpbc_get_dates_short_format( $my_dates4emeil ); | |
| 872 | - else | |
| 873 | - $my_dates_4_send = wpbc_get_dates_comma_string_localized( $my_dates4emeil ); | |
| 874 | - | |
| 875 | - $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil ); | |
| 876 | 876 | |
| 877 | - $my_check_in_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[0] ); | |
| 878 | - $my_check_out_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); | |
| 879 | - //FixIn: 8.7.2.5 | |
| 880 | - $my_check_in_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( date( 'Y-m-d 00:00:00', strtotime( $my_dates4emeil_check_in_out[0] ) ), 'Y-m-d 00:00:00' ) ); | |
| 881 | - $my_check_out_onlydate = wpbc_get_dates_comma_string_localized( wpbc_datetime_localized( date( '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' ) ); | |
| 877 | + $my_dates_4_send = ( 'short' === get_bk_option( 'booking_date_view_type' ) ) | |
| 878 | + ? wpbc_get_dates_short_format( $my_dates4emeil ) | |
| 879 | + : wpbc_get_dates_comma_string_localized( $my_dates4emeil ); | |
| 880 | + $my_dates4emeil_check_in_out = explode( ',', $my_dates4emeil ); | |
| 882 | 881 | |
| 883 | - $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' ) ); //FixIn: 6.0.1.11 | |
| 882 | + $my_check_in_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[0] ); | |
| 883 | + $my_check_out_date = wpbc_get_dates_comma_string_localized( $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); | |
| 884 | + $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. | |
| 885 | + $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' ) ); | |
| 886 | + $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' ) ); // FixIn: 6.0.1.11. | |
| 884 | 887 | |
| 888 | + // FixIn: 10.1.5.6. | |
| 889 | + $dates_only_arr = wpbc_get_only_dates__from_dates_ymd_his_csv__as_arr( $my_dates4emeil ); // -> '2023-10-09, 2023-10-09' | |
| 890 | + $dates_only_str = implode( ',', $dates_only_arr ); | |
| 891 | + $dates_only_str_formatted = ( 'short' === get_bk_option( 'booking_date_view_type' ) ) | |
| 892 | + ? wpbc_get_dates_short_format( $dates_only_str ) | |
| 893 | + : wpbc_get_dates_comma_string_localized( $dates_only_str ); | |
| 894 | + | |
| 885 | 895 | // Cost //////////////////////////////////////////////////////////////////// |
| 886 | - $booking_cost_digits_only = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id ); //FixIn: 9.2.3.1 | |
| 896 | + $booking_cost_digits_only = apply_bk_filter( 'get_booking_cost_from_db', '', $booking_id ); // FixIn: 9.2.3.1. | |
| 887 | 897 | $booking_cost = wpbc_get_cost_with_currency_for_user( $booking_cost_digits_only ); |
| 888 | 898 | // Other /////////////////////////////////////////////////////////////////// |
| 889 | 899 | $replace[ 'booking_id' ] = $booking_id; |
| 890 | 900 | $replace[ 'id' ] = $replace[ 'booking_id' ]; |
| 891 | 901 | $replace[ 'dates' ] = $my_dates_4_send; |
| 902 | + $replace[ 'only_dates' ] = $dates_only_str_formatted; | |
| 903 | + $replace[ 'dates_only' ] = $dates_only_str_formatted; | |
| 892 | 904 | $replace[ 'check_in_date' ] = $my_check_in_date; |
| 893 | 905 | $replace[ 'check_out_date' ] = $my_check_out_date; |
| 894 | - //FixIn: 8.7.2.5 | |
| 906 | + // FixIn: 8.7.2.5. | |
| 895 | 907 | $replace[ 'check_in_only_date' ] = $my_check_in_onlydate; |
| 896 | 908 | $replace[ 'check_out_only_date' ] = $my_check_out_onlydate; |
| 897 | 909 | |
| 898 | - $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; //FixIn: 6.0.1.11 | |
| 899 | - $replace[ 'dates_count' ] = count( $my_dates4emeil_check_in_out ); | |
| 910 | + $replace[ 'check_out_plus1day'] = $my_check_out_plus1day; // FixIn: 6.0.1.11. | |
| 911 | + | |
| 912 | + $replace['dates_count'] = count( $my_dates4emeil_check_in_out ); | |
| 913 | + $replace['days_count'] = intval( $replace['dates_count'] ); // FixIn: 10.15.1.3. | |
| 914 | + $replace['nights_count'] = ( $replace['days_count'] > 1 ) ? intval( $replace['days_count'] - 1 ) : 1; | |
| 915 | + $replace['days_count_plus1day'] = intval( $replace['days_count'] + 1 ); | |
| 916 | + | |
| 917 | + | |
| 900 | 918 | $replace['cost'] = $booking_cost; |
| 901 | 919 | $replace['cost_digits_only'] = $booking_cost_digits_only; |
| 902 | - $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . home_url() . '">' . home_url() . '</a>' ); | |
| 920 | + $replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . esc_url( home_url() ) . '">' . home_url() . '</a>' ); | |
| 903 | 921 | $replace[ 'resource_title'] = wpbc_lang( $bk_title ); |
| 922 | + $replace[ 'parent_resource_title'] = wpbc_lang( $parent_resource_title ); // FixIn: 10.9.2.4. | |
| 904 | 923 | $replace[ 'bookingtype' ] = $replace[ 'resource_title']; |
| 905 | - $replace[ 'remote_ip' ] = wpbc_get_user_ip(); //FixIn:7.1.2.4 // The IP address from which the user is viewing the current page. | |
| 906 | - $replace[ 'user_agent' ] = $_SERVER['HTTP_USER_AGENT']; // Contents of the User-Agent: header from the current request, if there is one. | |
| 907 | - $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 | |
| 924 | + $replace['remote_ip'] = wpbc_get_user_ip(); | |
| 925 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 926 | + $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. | |
| 927 | + $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 */ | |
| 928 | + $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 | |
| 908 | 929 | $replace[ 'current_date' ] = date_i18n( get_bk_option( 'booking_date_format' ) ); |
| 909 | 930 | $replace[ 'current_time' ] = date_i18n( get_bk_option( 'booking_time_format' ) ); |
| 910 | 931 | |
| 911 | 932 | // Form Fields ///////////////////////////////////////////////////////////// |
| @@ -920,10 +941,10 @@ | ||
| 920 | 941 | |
| 921 | 942 | // Links /////////////////////////////////////////////////////////////////// |
| 922 | 943 | $replace[ 'moderatelink' ] = htmlspecialchars_decode( |
| 923 | 944 | // '<a href="' . |
| 924 | - esc_url( wpbc_get_bookings_url() . '&view_mode=vm_listing&tab=actions&wh_booking_id=' . $booking_id ) | |
| 925 | - // . '">' . __('here', 'booking') . '</a>' | |
| 945 | + esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing&wh_booking_id=' . $booking_id ) | |
| 946 | + // . '">' . esc_html__('here', 'booking') . '</a>' | |
| 926 | 947 | ); |
| 927 | 948 | $replace[ 'visitorbookingediturl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingediturl]', $booking_id ); |
| 928 | 949 | $replace[ 'visitorbookingslisting' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingslisting]', $booking_id ); //FixIn: 8.1.3.5.1 |
| 929 | 950 | $replace[ 'visitorbookingcancelurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $booking_id ); |
| @@ -929,18 +950,18 @@ | ||
| 929 | 950 | $replace[ 'visitorbookingcancelurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingcancelurl]', $booking_id ); |
| 930 | 951 | $replace[ 'visitorbookingpayurl' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[visitorbookingpayurl]', $booking_id ); |
| 931 | 952 | $replace[ 'bookinghash' ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '[bookinghash]', $booking_id ); |
| 932 | 953 | |
| 933 | - //FixIn: 7.1.2.5 8.5.2.13 | |
| 954 | + // FixIn: 8.5.2.13. | |
| 934 | 955 | // $booking_data = array( 'form_data' => $booking_form_show_array ); |
| 935 | 956 | // $booking_data[ 'dates_short' ] = array( $my_dates4emeil_check_in_out[ 0 ], '-', $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] ); |
| 936 | 957 | // $replace[ 'add_to_google_cal_url' ] = htmlspecialchars_decode( esc_url( |
| 937 | 958 | // wpbc_btn_add_booking_to_google_calendar( $booking_data , array( 'is_only_url' => true ), false ) |
| 938 | 959 | // ) ); |
| 939 | - //FixIn: 9.6.3.8 | |
| 960 | + // FixIn: 9.6.3.8. | |
| 940 | 961 | $google_calendar_link = wpbc_booking_do_action__get_google_calendar_link( array( |
| 941 | 962 | 'form_data' => $booking_form_show_array['_all_fields_'], |
| 942 | - 'form_show' => $booking_form_show_array['content'], //strip_tags( $parsed_form_show ), | |
| 963 | + 'form_show' => $booking_form_show_array['content'], | |
| 943 | 964 | 'dates_short' => array( |
| 944 | 965 | $my_dates4emeil_check_in_out[0] |
| 945 | 966 | , '-' |
| 946 | 967 | , $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] |
| @@ -946,13 +967,13 @@ | ||
| 946 | 967 | , $my_dates4emeil_check_in_out[ count( $my_dates4emeil_check_in_out ) - 1 ] |
| 947 | 968 | ) |
| 948 | 969 | ) ); |
| 949 | 970 | $replace['add_to_google_cal_url'] = htmlspecialchars_decode( esc_url( $google_calendar_link ) ); |
| 950 | - $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>'; | |
| 971 | + $replace['add_to_google_cal_button'] = '<a href="' . esc_attr( $replace['add_to_google_cal_url'] ) . '" target="_blank" rel="nofollow">' . esc_html__( 'Add to Google Calendar', 'booking' ) . '</a>'; | |
| 951 | 972 | |
| 952 | - //////////////////////////////////////////////////////////////////////////// | |
| 973 | + // ----------------------------------------------------------------------------------------------------------------- | |
| 953 | 974 | // Get additional replace paramaters to the email shortcodes |
| 954 | - $replace = apply_filters( 'wpbc_replace_params_for_booking', $replace, $booking_id, $bktype, $formdata ); //FixIn: 8.0.1.7 | |
| 975 | + $replace = apply_filters( 'wpbc_replace_params_for_booking', $replace, $booking_id, $bktype, $formdata ); // FixIn: 8.0.1.7. | |
| 955 | 976 | |
| 956 | 977 | |
| 957 | 978 | return $replace; |
| 958 | 979 | |
| @@ -960,53 +981,56 @@ | ||
| 960 | 981 | } |
| 961 | 982 | |
| 962 | 983 | |
| 963 | 984 | /** |
| 964 | - * Send email | |
| 965 | - * | |
| 966 | - * @param type $booking_id - ID of booking | |
| 967 | - * @param type $bktype - type | |
| 968 | - * @param type $formdata - booking form data | |
| 985 | + * Send approved email | |
| 986 | + * @param $approved_id_str | |
| 987 | + * @param $is_send_emeils | |
| 988 | + * @param $denyreason | |
| 989 | + * | |
| 990 | + * @return bool | |
| 969 | 991 | */ |
| 970 | 992 | function wpbc_send_email_approved( $approved_id_str, $is_send_emeils, $denyreason = '' ) { |
| 971 | - | |
| 972 | - global $wpdb; | |
| 973 | - $sql = "SELECT * FROM {$wpdb->prefix}booking as bk WHERE bk.booking_id IN ({$approved_id_str})"; | |
| 974 | - $result = $wpdb->get_results( $sql ); | |
| 975 | 993 | |
| 976 | - foreach ( $result as $res ) { | |
| 977 | - | |
| 978 | - $booking_id = $res->booking_id; | |
| 979 | - $bktype = $res->booking_type; | |
| 980 | - $formdata = $res->form; | |
| 981 | - | |
| 982 | - $previous_active_user = apply_bk_filter( 'wpbc_mu_set_environment_for_owner_of_resource', -1, $bktype ); // MU | |
| 983 | - | |
| 984 | - make_bk_action( 'booking_aproved', $res, '' ); // Check for ability to change HASH during approving booking //FixIn: 7.0.1.35 | |
| 985 | - | |
| 986 | - //////////////////////////////////////////////////////////////////////// | |
| 987 | - // Load Data | |
| 988 | - //////////////////////////////////////////////////////////////////////// | |
| 994 | + global $wpdb; | |
| 995 | + $sql = "SELECT * FROM {$wpdb->prefix}booking as bk WHERE bk.booking_id IN ({$approved_id_str})"; | |
| 996 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter | |
| 997 | + $result = $wpdb->get_results( $sql ); | |
| 989 | 998 | |
| 990 | - /* Check if New Email Template Exist or NOT | |
| 991 | - * Exist - return empty array in format: array( OPTION_NAME => array() ) | |
| 992 | - * Its will load DATA from DB, during creattion mail_api CLASS | |
| 993 | - * during initial activation of the API its try to get option from DB | |
| 994 | - * We need to define this API before checking POST, to know all available fields | |
| 995 | - * Define Email Name & define field values from DB, if not exist, then default values. | |
| 996 | - * Not Exist - import Old Data from DB | |
| 997 | - * or get "default" data from settings and return array with this data | |
| 998 | - * This data its initial parameters for definition fields in mail_api CLASS | |
| 999 | - * | |
| 1000 | - */ | |
| 999 | + foreach ( $result as $res ) { | |
| 1001 | 1000 | |
| 1002 | - $init_fields_values = wpbc_import6_email__approved__get_fields_array_for_activation(); | |
| 1001 | + $booking_id = $res->booking_id; | |
| 1002 | + $bktype = $res->booking_type; | |
| 1003 | + $formdata = $res->form; | |
| 1003 | 1004 | |
| 1004 | - // 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 | |
| 1005 | - $init_fields_values_temp = array_values( $init_fields_values ); //FixIn: 7.0.1.32 | |
| 1006 | - $init_fields_values = array_shift( $init_fields_values_temp ); | |
| 1005 | + $previous_active_user = apply_bk_filter( 'wpbc_mu_set_environment_for_owner_of_resource', - 1, $bktype ); // MU. | |
| 1007 | 1006 | |
| 1007 | + // Check for ability to change HASH during approving booking //FixIn: 7.0.1.35. | |
| 1008 | + make_bk_action( 'booking_aproved', $res, '' ); | |
| 1008 | 1009 | |
| 1010 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1011 | + // Load Data | |
| 1012 | + // ------------------------------------------------------------------------------------------------------------- | |
| 1013 | + | |
| 1014 | + /** | |
| 1015 | + * Check if New Email Template Exist or NOT | |
| 1016 | + * Exist - return empty array in format: array( OPTION_NAME => array() ) | |
| 1017 | + * Its will load DATA from DB, during creattion mail_api CLASS | |
| 1018 | + * during initial activation of the API its try to get option from DB | |
| 1019 | + * We need to define this API before checking POST, to know all available fields | |
| 1020 | + * Define Email Name & define field values from DB, if not exist, then default values. | |
| 1021 | + * Not Exist - import Old Data from DB | |
| 1022 | + * or get "default" data from settings and return array with this data | |
| 1023 | + * This data its initial parameters for definition fields in mail_api CLASS | |
| 1024 | + */ | |
| 1025 | + | |
| 1026 | + $init_fields_values = wpbc_import6_email__approved__get_fields_array_for_activation(); | |
| 1027 | + | |
| 1028 | + // 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 | |
| 1029 | + $init_fields_values_temp = array_values( $init_fields_values ); // FixIn: 7.0.1.32. | |
| 1030 | + $init_fields_values = array_shift( $init_fields_values_temp ); | |
| 1031 | + | |
| 1032 | + | |
| 1009 | 1033 | $mail_api = new WPBC_Emails_API_Approved( WPBC_EMAIL_APPROVED_ID, $init_fields_values ); |
| 1010 | 1034 | |
| 1011 | 1035 | //////////////////////////////////////////////////////////////////////////// |
| 1012 | 1036 | |
| @@ -1012,20 +1036,21 @@ | ||
| 1012 | 1036 | |
| 1013 | 1037 | if ( $mail_api->fields_values['enabled'] == 'Off' ) return false; // Email template deactivated - exit. |
| 1014 | 1038 | |
| 1015 | 1039 | |
| 1016 | - $replace = wpbc__get_replace_shortcodes__email_approved( $booking_id, $bktype, $formdata ); | |
| 1017 | - $replace[ 'denyreason' ] = $denyreason; //FixIn: 7.0.1.1 | |
| 1018 | - $replace[ 'approvereason' ] = $denyreason; //FixIn: 7.0.1.1 | |
| 1019 | - $replace[ 'reason' ] = $denyreason; //FixIn: 7.0.1.1 | |
| 1020 | - if ( ! empty( $res->remark ) ) //FixIn: 8.1.2.6 | |
| 1021 | - $replace[ 'remark' ] = $res->remark; //FixIn: 7.2.1.19 | |
| 1040 | + $replace = wpbc__get_replace_shortcodes__email_approved( $booking_id, $bktype, $formdata ); | |
| 1041 | + $replace['denyreason'] = $denyreason; // FixIn: 7.0.1.1. | |
| 1042 | + $replace['approvereason'] = $denyreason; // FixIn: 7.0.1.1. | |
| 1043 | + $replace['reason'] = $denyreason; // FixIn: 7.0.1.1. | |
| 1044 | + if ( ! empty( $res->remark ) ) { | |
| 1045 | + $replace['remark'] = $res->remark; | |
| 1046 | + } // FixIn: 7.2.1.19. | |
| 1022 | 1047 | |
| 1023 | 1048 | // Replace shortcodes with custom URL parameter, like: 'visitorbookingediturl', 'visitorbookingcancelurl', 'visitorbookingpayurl' |
| 1024 | 1049 | foreach ( array( 'visitorbookingediturl', 'visitorbookingcancelurl', 'visitorbookingpayurl' , 'visitorbookingslisting' ) as $url_shortcode ) { //FixIn: 7.0.1.8 //FixIn: 8.1.3.5.1 |
| 1025 | 1050 | |
| 1026 | 1051 | // Loop to search if we are having several such shortcodes in our $mail_api->fields_values['content'] (For example, if we have several languges ). |
| 1027 | - $pos = 0; //FixIn: 7.0.1.52 | |
| 1052 | + $pos = 0; // FixIn: 7.0.1.52. | |
| 1028 | 1053 | do { |
| 1029 | 1054 | $shortcode_params = wpbc_get_params_of_shortcode_in_string( $url_shortcode, $mail_api->fields_values['content'] , $pos ); |
| 1030 | 1055 | |
| 1031 | 1056 | if ( ( ! empty( $shortcode_params ) ) && ( isset( $shortcode_params['url'] ) ) ){ |
| @@ -1033,15 +1058,15 @@ | ||
| 1033 | 1058 | $pos = $shortcode_params['end']; |
| 1034 | 1059 | |
| 1035 | 1060 | $exist_replace = substr( $mail_api->fields_values['content'], $shortcode_params['start'], ( $shortcode_params['end'] - $shortcode_params['start'] ) ); |
| 1036 | 1061 | |
| 1037 | - $new_replace = $url_shortcode . rand(1000,9000); | |
| 1062 | + $new_replace = $url_shortcode . wp_rand(1000,9000); | |
| 1038 | 1063 | |
| 1039 | 1064 | $mail_api->fields_values['content'] = str_replace( $exist_replace, $new_replace ,$mail_api->fields_values['content'] ); |
| 1040 | 1065 | |
| 1041 | 1066 | $pos = $shortcode_params['start'] + strlen( $new_replace ); //FixIn: 9.7.3.5.1 |
| 1042 | 1067 | $replace[ $new_replace ] = apply_bk_filter( 'wpdev_booking_set_booking_edit_link_at_email', '['.$exist_replace.']', $booking_id ); |
| 1043 | - } else if ( //FixIn: 8.1.1.8 | |
| 1068 | + } else if ( // FixIn: 8.1.1.8. | |
| 1044 | 1069 | ( ! empty( $shortcode_params ) ) |
| 1045 | 1070 | && ( isset( $shortcode_params['end'] ) ) |
| 1046 | 1071 | && ( $shortcode_params['end'] < strlen( $mail_api->fields_values['content'] ) ) |
| 1047 | 1072 | ) { |
| @@ -1046,17 +1071,17 @@ | ||
| 1046 | 1071 | && ( $shortcode_params['end'] < strlen( $mail_api->fields_values['content'] ) ) |
| 1047 | 1072 | ) { |
| 1048 | 1073 | $pos = $shortcode_params['end']; |
| 1049 | 1074 | } else { |
| 1050 | - $shortcode_params = false; //FixIn: 7.0.1.58 | |
| 1075 | + $shortcode_params = false; // FixIn: 7.0.1.58. | |
| 1051 | 1076 | } |
| 1052 | 1077 | |
| 1053 | - } while ( ! empty( $shortcode_params ) ); //FixIn: 7.0.1.52 | |
| 1078 | + } while ( ! empty( $shortcode_params ) ); // FixIn: 7.0.1.52. | |
| 1054 | 1079 | |
| 1055 | 1080 | } |
| 1056 | 1081 | |
| 1057 | 1082 | $mail_api->set_replace( $replace ); |
| 1058 | - $mail_api->fields_values['from_name'] = $mail_api->replace_shortcodes( $mail_api->fields_values['from_name'] ); //FixIn: 7.0.1.29 | |
| 1083 | + $mail_api->fields_values['from_name'] = $mail_api->replace_shortcodes( $mail_api->fields_values['from_name'] ); // FixIn: 7.0.1.29. | |
| 1059 | 1084 | |
| 1060 | 1085 | |
| 1061 | 1086 | $to = ( isset( $replace['email'] ) ) ? $replace['email'] : ''; // Get To field |
| 1062 | 1087 | |
| @@ -1063,9 +1088,9 @@ | ||
| 1063 | 1088 | if ( ! empty( $replace['email'] ) ) { |
| 1064 | 1089 | $to = wpbc_email_prepand_person_name( $replace['email'], $replace ); |
| 1065 | 1090 | } |
| 1066 | 1091 | |
| 1067 | - $to = wpbc_check_for_several_emails_in_form( $to, $formdata, $bktype ); //FixIn: 6.0.1.9 | |
| 1092 | + $to = wpbc_check_for_several_emails_in_form( $to, $formdata, $bktype ); // FixIn: 6.0.1.9. | |
| 1068 | 1093 | |
| 1069 | 1094 | $to = str_replace( ';', ',', $to ); |
| 1070 | 1095 | |
| 1071 | 1096 | if ( wpbc_is_not_blank_email( $to, $replace['content'] ) ) { |