| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package FEEDBACK |
| 5 |
* @subpackage FEEDBACK functions |
| 6 |
* @category Functions |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://wpbookingcalendar.com/ |
| 10 |
* @email info@wpbookingcalendar.com |
| 11 |
* |
| 12 |
* @modified 2024-05-14 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
if ( ! defined( 'WPBC_FEEDBACK_TIMEOUT' ) ) { define( 'WPBC_FEEDBACK_TIMEOUT', '+2 days' ); } |
| 18 |
//if ( ! defined( 'WPBC_FEEDBACK_TIMEOUT' ) ) { define( 'WPBC_FEEDBACK_TIMEOUT', '+30 seconds' ); } |
| 19 |
|
| 20 |
// == For testing == |
| 21 |
//update_option( 'booking_feedback_04', gmdate( 'Y-m-d H:i:s', strtotime( '+10 seconds', strtotime( 'now' ) ) ) ); |
| 22 |
|
| 23 |
// Init Timer |
| 24 |
// update_option( 'booking_feedback_04', gmdate( 'Y-m-d H:i:s', strtotime( WPBC_FEEDBACK_TIMEOUT, strtotime( 'now' ) ) ) ); |
| 25 |
|
| 26 |
// Reset |
| 27 |
// delete_option( 'booking_feedback_04'); |
| 28 |
|
| 29 |
function wpbc_get_feedback_defaults( $param_name ){ |
| 30 |
|
| 31 |
$defaults = array( |
| 32 |
'page_where_load' => 'wpbc-ajx_booking_availability', // Name of page, where to load feedback. Defined in pages, like this: do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_availability' ); |
| 33 |
'max_version' => '12.0', // If version of Booking Calendar 12.0 or newer than do not show this Feedback |
| 34 |
'feedback_email' => 'feedback2@wpbookingcalendar.com' |
| 35 |
); |
| 36 |
|
| 37 |
return $defaults[ $param_name ]; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
class WPBC_Feedback_01 { |
| 42 |
|
| 43 |
// <editor-fold defaultstate="collapsed" desc=" /// A J A X /// " > |
| 44 |
|
| 45 |
// A J A X ===================================================================================================== |
| 46 |
|
| 47 |
/** |
| 48 |
* Define HOOKs for start loading Ajax |
| 49 |
*/ |
| 50 |
public function define_ajax_hook(){ |
| 51 |
|
| 52 |
// Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php |
| 53 |
add_action( 'wp_ajax_' . 'WPBC_AJX_FEEDBACK', array( $this, 'ajax_' . 'WPBC_AJX_FEEDBACK' ) ); // Admin & Client (logged in usres) |
| 54 |
|
| 55 |
// Ajax Handlers for actions |
| 56 |
// add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in) |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
/** |
| 61 |
* Ajax - Get Listing Data and Response to JS script |
| 62 |
*/ |
| 63 |
public function ajax_WPBC_AJX_FEEDBACK() { |
| 64 |
|
| 65 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 66 |
if ( ! isset( $_POST['action_params'] ) || empty( $_POST['action_params'] ) ) { exit; } |
| 67 |
|
| 68 |
$ajax_errors = new WPBC_AJAX_ERROR_CATCHING(); |
| 69 |
|
| 70 |
// Security ----------------------------------------------------------------------------------------------- // in Ajax Post: 'nonce': wpbc_ajx_booking_listing.get_secure_param( 'nonce' ), |
| 71 |
$action_name = 'wpbc_ajx__feedback_ajx' . '_wpbcnonce'; |
| 72 |
$nonce_post_key = 'nonce'; |
| 73 |
$result_check = check_ajax_referer( $action_name, $nonce_post_key ); |
| 74 |
|
| 75 |
$user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 76 |
|
| 77 |
/** |
| 78 |
* SQL --------------------------------------------------------------------------- |
| 79 |
* |
| 80 |
* in Ajax Post: 'search_params': wpbc_ajx_booking_listing.search_get_all_params() |
| 81 |
* |
| 82 |
* Use prefix "search_params", if Ajax sent - |
| 83 |
* $_REQUEST['search_params']['page_num'], $_REQUEST['search_params']['page_items_count'],.. |
| 84 |
*/ |
| 85 |
|
| 86 |
$user_request = new WPBC_AJX__REQUEST( array( |
| 87 |
'db_option_name' => 'booking_feedback_request_params', |
| 88 |
'user_id' => $user_id, |
| 89 |
'request_rules_structure' => array( |
| 90 |
'booking_action' => array( 'validate' => array( 'feedback_01' ), 'default' => 'none' ) |
| 91 |
, 'feedback_stars' => array( 'validate' => 'd', 'default' => 0 ) |
| 92 |
, 'feedback__note' => array( 'validate' => 's', 'default' => '' ) |
| 93 |
, 'ui_clicked_element_id' => array( 'validate' => 's', 'default' => '' ) |
| 94 |
) |
| 95 |
) |
| 96 |
); |
| 97 |
$request_prefix = 'action_params'; |
| 98 |
$request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['action_params']['feedback_stars'] |
| 99 |
|
| 100 |
//---------------------------------------------------------------------------------------------------------- |
| 101 |
|
| 102 |
$action_result = wpbc_booking_do_action__feedback_01( $request_params |
| 103 |
, array( |
| 104 |
'user_id' => $user_id |
| 105 |
) |
| 106 |
); |
| 107 |
|
| 108 |
$defaults = array( |
| 109 |
'new_listing_params' => false // required for Import Google Calendar bookings |
| 110 |
, 'after_action_result' => false |
| 111 |
/* translators: 1: ... */ |
| 112 |
, 'after_action_message' => sprintf( __( 'No actions %s has been processed.', 'booking') |
| 113 |
, ' <strong>' . $request_params['booking_action'] . '</strong> ' ) |
| 114 |
); |
| 115 |
$action_result = wp_parse_args( $action_result, $defaults ); |
| 116 |
|
| 117 |
// Check if there were some errors -------------------------------------------------------------------------------- |
| 118 |
$error_messages = $ajax_errors->get_error_messages(); |
| 119 |
if ( ! empty( $error_messages ) ) { |
| 120 |
$action_result['after_action_message'] .= $error_messages; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
//------------------------------------------------------------------------------------------------------------------ |
| 126 |
// Send JSON. Its will make "wp_json_encode" - so pass only array, and This function call wp_die( '', '', array( 'response' => null, ) ) Pass JS OBJ: response_data in "jQuery.post( " function on success. |
| 127 |
wp_send_json( array( |
| 128 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 129 |
'ajx_action_params' => $_REQUEST['action_params'], // Do not clean input parameters |
| 130 |
'ajx_cleaned_params' => $request_params, // Cleaned input parameters |
| 131 |
'ajx_after_action_message' => $action_result['after_action_message'], // Message to show |
| 132 |
'ajx_after_action_result' => (int) $action_result['after_action_result'], // Result key 0 | 1 |
| 133 |
'ajx_after_action_result_all_params_arr' => $action_result // All result parameters |
| 134 |
) ); |
| 135 |
} |
| 136 |
|
| 137 |
// </editor-fold> |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
/** |
| 142 |
* Define HOOKs for loading CSS and JavaScript files |
| 143 |
*/ |
| 144 |
public function init_load_css_js() { |
| 145 |
// JS & CSS |
| 146 |
add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 ); |
| 147 |
add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 ); |
| 148 |
// Template |
| 149 |
add_action( 'wpbc_hook_settings_page_footer', array( $this, 'wpbc_hidden_template__content_for_feedback_01' ), 50 ); |
| 150 |
} |
| 151 |
|
| 152 |
/** JSS */ |
| 153 |
public function js_load_files( $where_to_load ) { |
| 154 |
|
| 155 |
$in_footer = true; |
| 156 |
|
| 157 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 158 |
|
| 159 |
wp_enqueue_script( 'wpbc-feedback_02', trailingslashit( plugins_url( '', __FILE__ ) ) . 'feedback.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */ |
| 160 |
, array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); |
| 161 |
/** |
| 162 |
wp_localize_script( 'wpbc_all', 'wpbc_live_request_obj' |
| 163 |
, array( |
| 164 |
'contacts' => '', |
| 165 |
'reminders' => '' |
| 166 |
) |
| 167 |
); |
| 168 |
*/ |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
/** CSS */ |
| 173 |
public function enqueue_css_files( $where_to_load ) { |
| 174 |
|
| 175 |
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { |
| 176 |
|
| 177 |
wp_enqueue_style( 'wpbc-feedback_02', trailingslashit( plugins_url( '', __FILE__ ) ) . 'feedback.css', array(), WP_BK_VERSION_NUM ); |
| 178 |
} |
| 179 |
} |
| 180 |
|
| 181 |
/** Feedback Layout - Modal Window structure */ |
| 182 |
function wpbc_hidden_template__content_for_feedback_01( $page ) { |
| 183 |
|
| 184 |
if ( wpbc_get_feedback_defaults( 'page_where_load' ) != $page ) { // Load feedback only at this page |
| 185 |
return false; |
| 186 |
} |
| 187 |
|
| 188 |
if ( wpbc_is__feedback_01__timeout_need_to_show() ) { // Check if time go out |
| 189 |
update_option( 'booking_feedback_04', '' ); |
| 190 |
} else { |
| 191 |
return false; |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
// Nonce for Ajax and some other data |
| 196 |
?><div id="wpbc_ajax__feedback_01" style="display:none;" |
| 197 |
data-nonce="<?php echo esc_attr( wp_create_nonce( 'wpbc_ajx__feedback_ajx' . '_wpbcnonce' ) ); ?>" |
| 198 |
data-user-id="<?php echo esc_attr( wpbc_get_current_user_id() ); ?>" |
| 199 |
></div><?php |
| 200 |
|
| 201 |
|
| 202 |
?><div id="wpbc_modal__feedback_01__section_mover"> |
| 203 |
<span class="wpdevelop"> |
| 204 |
<div id="wpbc_modal__feedback_01__section" class="modal wpbc_popup_modal wpbc_modal__feedback_01__section" tabindex="-1" role="dialog"> |
| 205 |
<div class="modal-dialog"> |
| 206 |
<div class="modal-content"> |
| 207 |
<div class="modal-header"> |
| 208 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 209 |
<h4 class="modal-title"><?php esc_html_e( 'Feedback', 'booking' ); ?></h4> |
| 210 |
</div> |
| 211 |
<div class="modal-body"> |
| 212 |
<?php |
| 213 |
|
| 214 |
$this->wpbc_hidden_template__content_for_feedback_01_steps(); |
| 215 |
|
| 216 |
?> |
| 217 |
</div> |
| 218 |
<div class="modal-footer" style="display: none"> |
| 219 |
|
| 220 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal" style="float: left;">Do not show anymore</a> |
| 221 |
<a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal" style="float: left;margin-left: 1em;">Remind me later</a> |
| 222 |
|
| 223 |
<a id="wpbc_modal__feedback_01__button_send" class="button button-primary" |
| 224 |
onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01();" href="javascript:void(0);" |
| 225 |
><?php esc_html_e('Next' ,'booking'); ?> 1/3</a> |
| 226 |
</div> |
| 227 |
</div><!-- /.modal-content --> |
| 228 |
</div><!-- /.modal-dialog --> |
| 229 |
</div><!-- /.modal --> |
| 230 |
</span> |
| 231 |
</div><?php |
| 232 |
// Open modal window just after page loaded |
| 233 |
?><script type="text/javascript"> |
| 234 |
jQuery(document).ready(function(){ |
| 235 |
setTimeout(function() { |
| 236 |
wpbc_open_feedback_modal(); |
| 237 |
}, 2000); |
| 238 |
}); |
| 239 |
</script><?php |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
/** Feedback Steps Content */ |
| 245 |
function wpbc_hidden_template__content_for_feedback_01_steps(){ |
| 246 |
|
| 247 |
/* S T A R S */ ?> |
| 248 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_1" > |
| 249 |
<h4 class="modal-title"><?php echo wp_kses_post( sprintf( 'Do you like the new %sNew Update%s of Booking Calendar?' ,'<strong>','</strong>') ); ?></h4> |
| 250 |
<div class="wpbc_feedback_01__content_rating"> |
| 251 |
<div class="wpbc_feedback_01__content_rating_stars"><?php |
| 252 |
for( $i = 1; $i < 6; $i++) { |
| 253 |
?><a id="wpbc_feedback_01_star_<?php echo esc_attr( $i ); ?>" |
| 254 |
href="javascript:void(0)" |
| 255 |
onmouseover="javascript:wpbc_feedback_01__over_star(<?php echo esc_attr( $i ); ?>, 'over');" |
| 256 |
onmouseout="javascript:wpbc_feedback_01__over_star(<?php echo esc_attr( $i ); ?>, 'out');" |
| 257 |
onclick="javascript:wpbc_feedback_01__over_star(<?php echo esc_attr( $i ); ?>, 'click');" |
| 258 |
data-original-title="<?php |
| 259 |
/* translators: 1: ... */ |
| 260 |
echo esc_attr( sprintf( __('Rate with %s star', 'booking'), $i ) ); ?>" |
| 261 |
class="tooltip_top "><i class="menu_icon icon-1x wpbc-bi-star 0wpbc_icn_star_outline"></i></a><?php |
| 262 |
} |
| 263 |
?> |
| 264 |
</div> |
| 265 |
</div> |
| 266 |
<div class="modal-footer modal-footer-inside"> |
| 267 |
<a href="javascript:void(0)" class="wpbc_btn_as_link" data-dismiss="modal"><?php esc_html_e('Do not show anymore' ,'booking'); ?></a> |
| 268 |
<a href="javascript:void(0)" class="wpbc_btn_as_link" onclick="javascript: wpbc_ajx_booking__ui_click__feedback_01_remind_later();"><?php esc_html_e('Remind me later' ,'booking'); ?></a> |
| 269 |
<a id="wpbc_modal__feedback_01__button_next__step_1" class="button button-primary wpbc_btn_next disabled" |
| 270 |
onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01(this);" href="javascript:void(0);" |
| 271 |
><?php esc_html_e('Next' ,'booking'); ?> <!--span>1/2</span--></a> |
| 272 |
</div> |
| 273 |
</div> |
| 274 |
|
| 275 |
<?php // Star 1 - 2 Reason ?> |
| 276 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_2" style="display:none;"> |
| 277 |
<h5 class="modal-title"><?php |
| 278 |
/* translators: 1: ... */ |
| 279 |
echo wp_kses_post( sprintf(__('Sorry to hear that... %s' ,'booking') |
| 280 |
,'<i class="menu_icon icon-1x wpbc-bi-emoji-frown 0wpbc_icn_sentiment_very_dissatisfied" style="color:#ca930b;"></i>') ); |
| 281 |
?></h5><br> |
| 282 |
<h4 class="modal-title"><?php esc_html_e('How can we improve it for you?' ,'booking'); ?></h4> |
| 283 |
<textarea id="wpbc_modal__feedback_01__reason_of_action__step_2" name="wpbc_modal__feedback_01__reason_of_action__step_2" |
| 284 |
style="width:100%;" cols="57" rows="3" autocomplete="off" |
| 285 |
onkeyup="javascript:if(jQuery( this ).val() != '' ){ jQuery( '#wpbc_modal__feedback_01__button_next__step_2').removeClass('disabled'); }" |
| 286 |
></textarea> |
| 287 |
<div class="modal-footer modal-footer-inside"> |
| 288 |
|
| 289 |
<a onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01( this, '.wpbc_modal__feedback_01__step_1' );" href="javascript:void(0);" |
| 290 |
class="button button-secondary"><?php esc_html_e('Back' ,'booking'); ?></a> |
| 291 |
|
| 292 |
<a id="wpbc_modal__feedback_01__button_next__step_2" class="button button-primary wpbc_btn_next" |
| 293 |
onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01( this, '.wpbc_modal__feedback_01__step_3');" href="javascript:void(0);" |
| 294 |
><?php esc_html_e('Next' ,'booking'); ?> <span>2/3</span></a> |
| 295 |
</div> |
| 296 |
</div> |
| 297 |
|
| 298 |
<?php /* Star 1 - 2 Done */ ?> |
| 299 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_3" style="display:none;"> |
| 300 |
<h5 class="modal-title"><?php |
| 301 |
/* translators: 1: ... */ |
| 302 |
echo wp_kses_post( sprintf(__('Thank you for your feedback! %s' ,'booking') |
| 303 |
,'<i class="menu_icon icon-1x wpbc-bi-hand-thumbs-up" style="color: #dd2e44;"></i>' ) ); |
| 304 |
?></h5><br> |
| 305 |
<h4 class="modal-title"><?php echo wp_kses_post( sprintf(__('You\'re helping us do a better job. :) We appreciate that!' ,'booking') |
| 306 |
,'<i class="menu_icon icon-1x wpbc-bi-hand-thumbs-up" style="color: #dd2e44;"></i>' ) ); |
| 307 |
?></h4><br> |
| 308 |
<h4 class="modal-title"><?php |
| 309 |
/* translators: 1: ... */ |
| 310 |
echo wp_kses_post( sprintf(__('Thanks for being with us! %s' ,'booking') |
| 311 |
,'<i class="menu_icon icon-1x wpbc-bi-heart-fill 0wpbc_icn_favorite" style="color: #dd2e44;"></i>' ) ); |
| 312 |
?></h4> |
| 313 |
<div class="modal-footer modal-footer-inside ui_element"> |
| 314 |
<a class="button button-primary wpbc_ui_button wpbc_ui_button_primary" id="wpbc_modal__feedback_01__submit_1_2" |
| 315 |
onclick="javascript: wpbc_ajx_booking__ui_click__submit_feedback_01( this, '.wpbc_modal__feedback_01__step_3');" href="javascript:void(0);" |
| 316 |
><span><?php esc_html_e('Done' ,'booking'); ?></span> <i class="menu_icon icon-1x wpbc_icn_done_all"></i></a> |
| 317 |
</div> |
| 318 |
</div> |
| 319 |
|
| 320 |
<?php /* Star 3 - 4 Reason */ ?> |
| 321 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_4" style="display:none;"> |
| 322 |
<h4 class="modal-title"><?php esc_html_e('What functionality important to you are missing in the plugin?', 'booking'); ?></h4><br> |
| 323 |
<textarea id="wpbc_modal__feedback_01__reason_of_action__step_4" name="wpbc_modal__feedback_01__reason_of_action__step_4" |
| 324 |
style="width:100%;" cols="57" rows="3" autocomplete="off" |
| 325 |
onkeyup="javascript:if(jQuery( this ).val() != '' ){ jQuery( '#wpbc_modal__feedback_01__button_next__step_4').removeClass('disabled'); }" |
| 326 |
></textarea> |
| 327 |
<label class="help-block"><?php |
| 328 |
/* translators: 1: ... */ |
| 329 |
echo wp_kses_post( sprintf( __( 'It\'s an %1$soptional question%2$s. But, we\'d love to hear your thoughts!', 'booking' ), '<b>', '</b>' ) ); ?></label> |
| 330 |
<div class="modal-footer modal-footer-inside"> |
| 331 |
|
| 332 |
<a onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01( this, '.wpbc_modal__feedback_01__step_1' );" href="javascript:void(0);" |
| 333 |
class="button button-secondary"><?php esc_html_e('Back' ,'booking'); ?></a> |
| 334 |
|
| 335 |
<a id="wpbc_modal__feedback_01__button_next__step_4" class="button button-primary wpbc_btn_next " |
| 336 |
onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01( this, '.wpbc_modal__feedback_01__step_5');" href="javascript:void(0);" |
| 337 |
><?php esc_html_e('Next' ,'booking'); ?> <span>2/3</span></a> |
| 338 |
</div> |
| 339 |
</div> |
| 340 |
|
| 341 |
<?php /* Star 3 - 4 Done */ ?> |
| 342 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_5" style="display:none;"> |
| 343 |
<h4 class="modal-title"><?php |
| 344 |
/* translators: 1: ... */ |
| 345 |
echo wp_kses_post( sprintf( __( '%1$sFantastic!%2$s Thanks for taking the time! %3$s', 'booking' ) |
| 346 |
,'<strong>','</strong>' |
| 347 |
,'<i class="menu_icon icon-1x wpbc-bi-heart-fill 0wpbc_icn_favorite" style="color: #dd2e44;"></i>' ) ); |
| 348 |
?></h4><br> |
| 349 |
<h4 class="modal-title"><?php esc_html_e('Your answers will help us to make the plugin better for you!' ,'booking'); ?></h4><br> |
| 350 |
<h4 class="modal-title"><?php esc_html_e('Thanks for sharing your feedback! Have a great day :)' ,'booking'); ?></h4> |
| 351 |
<div class="modal-footer modal-footer-inside ui_element"> |
| 352 |
<a class="button button-primary wpbc_ui_button wpbc_ui_button_primary" id="wpbc_modal__feedback_01__submit_3_4" |
| 353 |
onclick="javascript: wpbc_ajx_booking__ui_click__submit_feedback_01( this, '.wpbc_modal__feedback_01__step_5');" href="javascript:void(0);" |
| 354 |
><span><?php esc_html_e('Done' ,'booking'); ?></span> <i class="menu_icon icon-1x wpbc_icn_done_all"></i></a> |
| 355 |
</div> |
| 356 |
</div> |
| 357 |
|
| 358 |
<?php /* Star 5 Review */ ?> |
| 359 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_6" style="display:none;"> |
| 360 |
<h4 class="modal-title" style="line-height: 2.4em;"><?php |
| 361 |
/* translators: 1: ... */ |
| 362 |
printf( '%sAwesome!%s Can you do us a HUGE favor and leave a 5-star rating for our plugin on WordPress to help us spread the word and boost our motivation? %s' |
| 363 |
,'<strong>','</strong>' |
| 364 |
,'<i class="menu_icon icon-1x wpbc-bi-heart-fill" style="color: #dd2e44;"></i>' |
| 365 |
,'<i class="menu_icon icon-1x wpbc-bi-balloon-heart" style="color: #dd2e44;"></i>' |
| 366 |
,'<i class="menu_icon icon-1x wpbc-bi-balloon-heart" style="color: #dd2e44;"></i>' |
| 367 |
); |
| 368 |
?></h4><br> |
| 369 |
<h4 class="modal-title"><?php |
| 370 |
printf( 'Your support would mean a lot to us and we would be over the moon! :) %s%s%s' |
| 371 |
|
| 372 |
,'<i class="menu_icon icon-1x wpbc-bi-balloon-heart" style="color: #dd2e44;"></i>' |
| 373 |
,'<i class="menu_icon icon-1x wpbc-bi-balloon-heart" style="color: #dd2e44;"></i>' |
| 374 |
,'<i class="menu_icon icon-1x wpbc-bi-balloon-heart" style="color: #dd2e44;"></i>' |
| 375 |
); ?></h4><br> |
| 376 |
<textarea id="wpbc_modal__feedback_01__reason_of_action__step_7" name="wpbc_modal__feedback_01__reason_of_action__step_7" style="display:none;" |
| 377 |
style="width:100%;" cols="57" rows="3" autocomplete="off" |
| 378 |
onkeyup="javascript:if(jQuery( this ).val() != '' ){ jQuery( '#wpbc_modal__feedback_01__button_next__step_7').removeClass('disabled'); }" |
| 379 |
placeholder="<?php esc_attr_e( 'What\'s the main benefit from Booking Calendar for you?', 'booking' ); ?>" |
| 380 |
>not_now</textarea> |
| 381 |
<?php //echo 'How it helps you or your business? Is it ease of use? Do you like the Product design ? Value for money...' ; ?> |
| 382 |
|
| 383 |
<div class="modal-footer modal-footer-inside ui_element" style="justify-content: flex-end;"> |
| 384 |
<a id="wpbc_modal__feedback_01__button_next__step_6" class="button button-primary wpbc_btn_next " |
| 385 |
onclick="javascript: jQuery( '#wpbc_modal__feedback_01__reason_of_action__step_7').val('rate5'); wpbc_ajx_booking__ui_click__submit_feedback_01( this, '.wpbc_modal__feedback_01__step_7');" href="javascript:void(0);" |
| 386 |
><?php esc_html_e('Yes! Sure, I\'d love to help!' ,'booking'); ?> <i class="menu_icon icon-1x wpbc-bi-emoji-smile"></i></a> |
| 387 |
|
| 388 |
<a onclick="javascript: wpbc_ajx_booking__ui_click__submit_feedback_01( this, '.wpbc_modal__feedback_01__step_7');" href="javascript:void(0);" |
| 389 |
class="button button-secondary wpbc_ui_button" id="wpbc_modal__feedback_01__submit_5_none"><?php esc_html_e('No, sorry - not this time.' ,'booking'); ?> <i class="menu_icon icon-1x wpbc-bi-emoji-neutral"></i></a> |
| 390 |
|
| 391 |
<?php /* ?> |
| 392 |
<a id="wpbc_modal__feedback_01__button_next__step_6" class="button button-primary wpbc_btn_next " |
| 393 |
onclick="javascript: wpbc_ajx_booking__ui_click__send_feedback_01( this, '.wpbc_modal__feedback_01__step_7');" href="javascript:void(0);" |
| 394 |
><?php esc_html_e('Yes! Sure, I\'d love to help!' ,'booking'); ?> <i class="menu_icon icon-1x wpbc-bi-emoji-smile"></i></a> |
| 395 |
<?php */ ?> |
| 396 |
</div> |
| 397 |
|
| 398 |
</div> |
| 399 |
|
| 400 |
<?php /* Star 5 Done */ ?> |
| 401 |
<div class="wpbc_modal__feedback_01__steps wpbc_modal__feedback_01__step_7" style="display:none;"> |
| 402 |
<h4 class="modal-title"><?php |
| 403 |
/* translators: 1: ... */ |
| 404 |
echo wp_kses_post( sprintf( __( '%1$sPerfect!%2$s Thanks for taking the time! %3$s', 'booking' ) |
| 405 |
,'<strong>','</strong>' |
| 406 |
,'<i class="menu_icon icon-1x wpbc-bi-heart-fill 0wpbc_icn_favorite" style="color: #dd2e44;"></i>' ) ); |
| 407 |
?></h4><br> |
| 408 |
<h4 class="modal-title"><?php esc_html_e('Your answers will help us to make the plugin better for you!' ,'booking'); ?></h4><br> |
| 409 |
<h4 class="modal-title"><?php esc_html_e('Thanks for sharing your feedback! Have a great day :)' ,'booking'); ?></h4> |
| 410 |
<div class="modal-footer modal-footer-inside ui_element"> |
| 411 |
<a class="button button-primary wpbc_ui_button wpbc_ui_button_primary" id="wpbc_modal__feedback_01__submit_5" |
| 412 |
onclick="javascript: wpbc_ajx_booking__ui_click__submit_feedback_01( this, '.wpbc_modal__feedback_01__step_7');" href="javascript:void(0);" |
| 413 |
><span><?php esc_html_e('Done' ,'booking'); ?></span> <i class="menu_icon icon-1x wpbc_icn_done_all"></i></a> |
| 414 |
</div> |
| 415 |
</div> |
| 416 |
<?php |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
|
| 421 |
/** |
| 422 |
* Ajax Response |
| 423 |
* |
| 424 |
* @param $request_params |
| 425 |
* @param $params |
| 426 |
* |
| 427 |
* @return array |
| 428 |
*/ |
| 429 |
function wpbc_booking_do_action__feedback_01( $request_params, $params ) { |
| 430 |
|
| 431 |
$feedback_stars = intval( $request_params['feedback_stars'] ); |
| 432 |
$feedback__note = $request_params['feedback__note'];//esc_textarea( $request_params['feedback__note'] ); |
| 433 |
|
| 434 |
$after_action_result = true; |
| 435 |
/* translators: 1: ... */ |
| 436 |
$after_action_message = sprintf( __( 'Thanks for sharing your rating %s', 'booking' ), '<strong style="font-size: 1.1em;">' . $feedback_stars . '</strong>/5' ); |
| 437 |
|
| 438 |
if ( 'remind_later' == $feedback__note ) { |
| 439 |
|
| 440 |
$after_action_message = __( 'Done', 'booking' ); |
| 441 |
|
| 442 |
// Update new period for showing Feedback |
| 443 |
$feedback_date = gmdate('Y-m-d H:i:s', strtotime( WPBC_FEEDBACK_TIMEOUT, strtotime( 'now' ) ) ); |
| 444 |
update_option('booking_feedback_04', $feedback_date ); |
| 445 |
|
| 446 |
} elseif ( ( $feedback_stars > 0 ) && ( $feedback_stars <= 5 ) ) { |
| 447 |
|
| 448 |
// Send email |
| 449 |
wpbc_feedback_01__send_email( $feedback_stars, $feedback__note ); |
| 450 |
update_option('booking_feedback_04_rating', $feedback_stars ); |
| 451 |
|
| 452 |
} |
| 453 |
|
| 454 |
if ( ( 5 == $feedback_stars ) && ( 'rate5' != $feedback__note ) ) { |
| 455 |
$feedback_stars = 0; |
| 456 |
} |
| 457 |
|
| 458 |
return array( |
| 459 |
'after_action_result' => $after_action_result, |
| 460 |
'after_action_message' => $after_action_message, |
| 461 |
'feedback_stars' => $feedback_stars |
| 462 |
); |
| 463 |
} |
| 464 |
|
| 465 |
|
| 466 |
/** |
| 467 |
* Send email with feedback |
| 468 |
* |
| 469 |
* @param $stars_num |
| 470 |
* @param $feedback_description |
| 471 |
* |
| 472 |
* @return void |
| 473 |
*/ |
| 474 |
function wpbc_feedback_01__send_email( $stars_num, $feedback_description ) { |
| 475 |
|
| 476 |
$us_data = wp_get_current_user(); |
| 477 |
|
| 478 |
$fields_values = array(); |
| 479 |
$fields_values['from_email'] = get_option( 'admin_email' ); |
| 480 |
$fields_values['from_name'] = $us_data->display_name; |
| 481 |
$fields_values['from_name'] = wp_specialchars_decode( esc_html( stripslashes( $fields_values['from_name'] ) ), ENT_QUOTES ); |
| 482 |
$fields_values['from_email'] = sanitize_email( $fields_values['from_email'] ); |
| 483 |
|
| 484 |
$subject = 'Booking Calendar Feedback ' . $stars_num . '/5'; |
| 485 |
|
| 486 |
|
| 487 |
$message = '=============================================' . "\n"; |
| 488 |
$message .= $feedback_description . "\n"; |
| 489 |
$message .= '=============================================' . "\n"; |
| 490 |
$message .="\n"; |
| 491 |
|
| 492 |
$message .= $fields_values['from_name'] . "\n"; |
| 493 |
$message .="\n"; |
| 494 |
$message .= 'Booking Calendar Rating: ' . $stars_num . '/5' . "\n"; |
| 495 |
$message .= '---------------------------------------------' . "\n"; |
| 496 |
|
| 497 |
$message .= 'Booking Calendar ' . wpbc_feedback_01_get_version() . "\n"; |
| 498 |
|
| 499 |
$how_old_info_arr = wpbc_get_info__about_how_old(); |
| 500 |
if ( ! empty( $how_old_info_arr ) ) { |
| 501 |
$message .= "\n"; |
| 502 |
$message .= 'From: ' . $how_old_info_arr['date_echo']; |
| 503 |
$message .= ' - ' . $how_old_info_arr['days'] . ' days ago.'; |
| 504 |
} |
| 505 |
|
| 506 |
$message .="\n"; |
| 507 |
$message .= '---------------------------------------------' . "\n"; |
| 508 |
$message .= '[' . date_i18n( get_bk_option( 'booking_date_format' ) ) . ' ' . date_i18n( get_bk_option( 'booking_time_format' ) ) . ']'. "\n"; |
| 509 |
$message .= home_url() ; |
| 510 |
|
| 511 |
|
| 512 |
$headers = ''; |
| 513 |
|
| 514 |
if ( ! empty( $fields_values['from_email'] ) ) { |
| 515 |
|
| 516 |
$headers .= 'From: ' . $fields_values['from_name'] . ' <' . $fields_values['from_email'] . '> ' . "\r\n"; |
| 517 |
} else { |
| 518 |
/* If we don't have an email from the input headers default to wordpress@$sitename |
| 519 |
* Some hosts will block outgoing mail from this address if it doesn't exist but |
| 520 |
* there's no easy alternative. Defaulting to admin_email might appear to be another |
| 521 |
* option but some hosts may refuse to relay mail from an unknown domain. See |
| 522 |
* https://core.trac.wordpress.org/ticket/5007. |
| 523 |
*/ |
| 524 |
} |
| 525 |
$headers .= 'Content-Type: ' . 'text/plain' . "\r\n" ; // 'text/html' |
| 526 |
|
| 527 |
$attachments = ''; |
| 528 |
|
| 529 |
|
| 530 |
$to = wpbc_get_feedback_defaults( 'feedback_email' ); |
| 531 |
|
| 532 |
// debuge('In email', htmlentities($to), $subject, htmlentities($message), $headers, $attachments) ; |
| 533 |
// debuge( '$to, $subject, $message, $headers, $attachments',htmlspecialchars($to), htmlspecialchars($subject), htmlspecialchars($message), htmlspecialchars($headers), htmlspecialchars($attachments)); |
| 534 |
if ( wpbc_email_api_is_allow_send( true, '', '' ) ) { |
| 535 |
$return = wp_mail( $to, $subject, $message, $headers, $attachments ); |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
/** |
| 542 |
* Get data about Booking Calendar version. Support function |
| 543 |
* @return string |
| 544 |
*/ |
| 545 |
function wpbc_feedback_01_get_version(){ |
| 546 |
|
| 547 |
// if ( substr( WPDEV_BK_VERSION, 0, 3 ) == '11.' ) { |
| 548 |
// $show_version = substr( WPDEV_BK_VERSION, 3 ); |
| 549 |
// if ( substr( $show_version, ( - 1 * ( strlen( WP_BK_VERSION_NUM ) ) ) ) === WP_BK_VERSION_NUM ) { |
| 550 |
// $show_version = substr( $show_version, 0, ( - 1 * ( strlen( WP_BK_VERSION_NUM ) ) - 1 ) ); |
| 551 |
// $show_version = str_replace( '.', ' ', $show_version ) . ' ' . WP_BK_VERSION_NUM; |
| 552 |
// } |
| 553 |
// |
| 554 |
// } else { |
| 555 |
// $show_version = WPDEV_BK_VERSION; |
| 556 |
// } |
| 557 |
|
| 558 |
$show_version = wpbc_get_wpbc_versions_numbers(); |
| 559 |
|
| 560 |
$ver = wpbc_get_plugin_version_type(); |
| 561 |
if ( class_exists( 'wpdev_bk_multiuser' ) ) { |
| 562 |
$ver = 'MultiUser'; |
| 563 |
} |
| 564 |
$ver = str_replace( '_m', ' Medium', $ver ); |
| 565 |
$ver = str_replace( '_l', ' Large', $ver ); |
| 566 |
$ver = str_replace( '_s', ' Small', $ver ); |
| 567 |
$ver = str_replace( 'biz', 'Business', $ver ); |
| 568 |
$ver = ucwords( $ver ); |
| 569 |
|
| 570 |
|
| 571 |
$v_type = ''; |
| 572 |
if ( strpos( strtolower( WPDEV_BK_VERSION ), 'multisite' ) !== false ) { |
| 573 |
$v_type = '5'; |
| 574 |
} else if ( strpos( strtolower( WPDEV_BK_VERSION ), 'develop' ) !== false ) { |
| 575 |
$v_type = '2'; |
| 576 |
} |
| 577 |
if ( ! empty( $v_type ) ) { |
| 578 |
$v_type = ' ' . $v_type . ' ' . __( 'websites', 'booking' ); |
| 579 |
} else { |
| 580 |
$v_type = ' 1' . ' ' . __( 'website', 'booking' ); |
| 581 |
} |
| 582 |
|
| 583 |
return $ver . ' (' . $show_version . ') ' |
| 584 |
. ( ( 'Free' !== $ver ) ? ' :: ' . $v_type . '.' : '' ) |
| 585 |
. ' :: ' . gmdate( "d.m.Y", filemtime( WPBC_FILE ) ); |
| 586 |
} |
| 587 |
|
| 588 |
|
| 589 |
/** |
| 590 |
* Check if we need to show the Feedback - is it Timer expired already ? |
| 591 |
* @return bool |
| 592 |
*/ |
| 593 |
function wpbc_is__feedback_01__timeout_need_to_show() { |
| 594 |
|
| 595 |
//return true; |
| 596 |
|
| 597 |
$feedback_01_date = get_option( 'booking_feedback_04' ); |
| 598 |
|
| 599 |
if ( |
| 600 |
( ! empty( $feedback_01_date ) ) |
| 601 |
&& ( ( strtotime( 'now' ) - strtotime( $feedback_01_date ) ) > 0 ) |
| 602 |
) { |
| 603 |
return true; |
| 604 |
} else { |
| 605 |
return false; |
| 606 |
} |
| 607 |
|
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
/** |
| 613 |
* Set timer to show Feedback after this amount of time |
| 614 |
* @return void |
| 615 |
*/ |
| 616 |
function wpbc_is__feedback_01__timer_install() { |
| 617 |
|
| 618 |
// If version of Booking Calendar 9.6 (e.g. 'max_version') or newer than do not show this Feedback |
| 619 |
if ( version_compare( WP_BK_VERSION_NUM, wpbc_get_feedback_defaults( 'max_version' ) , '>=') ) { |
| 620 |
return false; |
| 621 |
} |
| 622 |
$feedback_date = gmdate( 'Y-m-d H:i:s', strtotime( WPBC_FEEDBACK_TIMEOUT, strtotime( 'now' ) ) ); |
| 623 |
add_option( 'booking_feedback_04', $feedback_date ); |
| 624 |
} |
| 625 |
add_bk_action( 'wpbc_before_activation' , 'wpbc_is__feedback_01__timer_install' ); |
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
/** |
| 630 |
* Just for loading CSS and JavaScript files and define Ajax hook |
| 631 |
*/ |
| 632 |
if ( |
| 633 |
( ! wpbc_is_this_demo() ) |
| 634 |
) { |
| 635 |
$wpbc_js_css_loading = new WPBC_Feedback_01; |
| 636 |
$wpbc_js_css_loading->define_ajax_hook(); |
| 637 |
|
| 638 |
if ( ! empty( get_option( 'booking_feedback_04' ) ) ){ |
| 639 |
$wpbc_js_css_loading->init_load_css_js(); |
| 640 |
} |
| 641 |
} |
| 642 |
|