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