| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @package Booking Manager |
| 4 |
* @category Content of item Listing page |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2015-11-13 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
|
| 16 |
/** Show Content |
| 17 |
* Update Content |
| 18 |
* Define Slug |
| 19 |
* Define where to show |
| 20 |
*/ |
| 21 |
class WPBM_Page_Single extends WPBM_Page_Structure { |
| 22 |
|
| 23 |
|
| 24 |
public function in_page() { |
| 25 |
return 'oplugins'; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
public function tabs() { |
| 30 |
|
| 31 |
$tabs = array(); |
| 32 |
$tabs[ 'wpbm' ] = array( |
| 33 |
'title' => __( 'Manage .ics', 'booking-manager' ) // Title of TAB |
| 34 |
, 'hint' => __( 'Upload .ics File', 'booking-manager' ) // Hint |
| 35 |
, 'page_title' => __( 'Booking Manager', 'booking-manager' ) // Title of Page |
| 36 |
, 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link |
| 37 |
, 'position' => '' // 'left' || 'right' || '' |
| 38 |
, 'css_classes' => '' // CSS class(es) |
| 39 |
, 'icon' => '' // Icon - link to the real PNG img |
| 40 |
, 'font_icon' => 'glyphicon glyphicon-tasks' // CSS definition of forn Icon |
| 41 |
, 'default' => true // Is this tab activated by default or not: true || false. |
| 42 |
, 'disabled' => false // Is this tab disbaled: true || false. |
| 43 |
, 'hided' => ! true // Is this tab hided: true || false. |
| 44 |
, 'subtabs' => array() |
| 45 |
|
| 46 |
); |
| 47 |
$subtabs = array(); |
| 48 |
// $tabs[ 'items' ][ 'subtabs' ] = $subtabs; |
| 49 |
// $subtabs['manage'] = array( |
| 50 |
// 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html' |
| 51 |
// , 'title' => __( 'Manage .ics', 'booking-manager' ) // Title of TAB |
| 52 |
// , 'hint' => __( 'Upload .ics File', 'booking-manager' ) // Hint |
| 53 |
// , 'page_title' => __( 'Booking Manager', 'booking-manager' ) // Title of Page |
| 54 |
// , 'link' => '' // link |
| 55 |
// , 'position' => '' // 'left' || 'right' || '' |
| 56 |
// , 'css_classes' => '' // CSS class(es) |
| 57 |
// //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img |
| 58 |
// //, 'font_icon' => 'glyphicon glyphicon-envelope' // CSS definition of Font Icon |
| 59 |
// , 'default' => true // Is this sub tab activated by default or not: true || false. |
| 60 |
// , 'disabled' => false // Is this sub tab deactivated: true || false. |
| 61 |
// , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' ) |
| 62 |
// , 'content' => 'content' // Function to load as conten of this TAB |
| 63 |
// , 'hided' => true // Is this tab hided: true || false. |
| 64 |
// ); |
| 65 |
|
| 66 |
$tabs[ 'wpbm' ]['subtabs'] = $subtabs; |
| 67 |
return $tabs; |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
public function content() { |
| 73 |
|
| 74 |
// Checking //////////////////////////////////////////////////////////// |
| 75 |
|
| 76 |
do_action( 'wpbm_hook_settings_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed. |
| 77 |
|
| 78 |
// $this->settings_api(); // Init Settings API & Get Data from DB |
| 79 |
|
| 80 |
// Submit ///////////////////////////////////////////////////////////// |
| 81 |
|
| 82 |
$submit_form_name = 'wpbm_ics_files_form'; // Define form name |
| 83 |
|
| 84 |
|
| 85 |
if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { |
| 86 |
|
| 87 |
// Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. } |
| 88 |
$nonce_gen_time = check_admin_referer( 'wpbm_settings_page_' . $submit_form_name ); // Its stop show anything on submiting, if its not refear to the original page |
| 89 |
|
| 90 |
// Save Changes |
| 91 |
$data_after_update = $this->update(); |
| 92 |
} |
| 93 |
|
| 94 |
// $wpbm_user_role_master = get_wpbm_option( 'wpbm_user_role_master' ); // O L D W A Y: Get Fields Data |
| 95 |
?><div class="wpbm-replace-container" style="display:none;"><?php |
| 96 |
|
| 97 |
?><span class="wpbm_help_upgrade"><?php |
| 98 |
wpbm_bs_dropdown_menu( array( |
| 99 |
'title' => __( 'Help', 'booking-manager' ) |
| 100 |
, 'font_icon' => 'glyphicon glyphicon-info-sign' |
| 101 |
, 'position' => 'right' |
| 102 |
, 'items' => array( |
| 103 |
array( 'type' => 'link', 'title' => __('Shortcode configuration', 'booking-manager') |
| 104 |
, 'url' => 'http://oplugins.com/plugins/wp-booking-manager/booking-manager-help/' //esc_url( admin_url( add_query_arg( array( 'page' => 'oplugins', 'tab' => 'wpbm', 'subtab' => 'help_shortcodes' ), 'admin.php' ) ) ) |
| 105 |
) |
| 106 |
, array( 'type' => 'divider' ) |
| 107 |
, array( 'type' => 'link', 'title' => __('Help', 'booking-manager'), 'url' => 'http://oplugins.com/plugins/booking-manager/#faq' ) |
| 108 |
//, array( 'type' => 'link', 'title' => __('FAQ', 'booking-manager'), 'url' => 'http://oplugins.com/plugins/booking-manager/#faq' ) |
| 109 |
, array( 'type' => 'link', 'title' => __('Technical Support', 'booking-manager'), 'url' => 'mailto:support@oplugins.com?subject=booking-manager' ) |
| 110 |
, array( 'type' => 'divider' ) |
| 111 |
, array( 'type' => 'link', 'title' => __('Upgrade Now', 'booking-manager'), 'url' => wpbm_up_link() |
| 112 |
, 'attr' => array( |
| 113 |
'target' => '_blank' |
| 114 |
, 'style' => 'font-weight: 600;font-size: 1em;' |
| 115 |
) |
| 116 |
) |
| 117 |
) |
| 118 |
) ); |
| 119 |
?></span><?php |
| 120 |
|
| 121 |
?></div><?php |
| 122 |
?><script type="text/javascript"> |
| 123 |
jQuery(document).ready(function(){ |
| 124 |
jQuery( '.wpbm_help_upgrade' ).insertAfter( '.wpdevelop.wpdvlp-nav-tabs-container .wpdvlp-top-tabs .nav-tabs a:last' ); |
| 125 |
//jQuery( '.wpdvlp-sub-tabs' ).hide(); |
| 126 |
}); |
| 127 |
</script><?php |
| 128 |
|
| 129 |
|
| 130 |
?><span class="wpdevelop"><?php |
| 131 |
|
| 132 |
wpbm_js_for_items_page(); // JavaScript: - Tooltips, Popover, Datepick (js & css) |
| 133 |
|
| 134 |
// wpbm_items_toolbar(); // T o o l b a r s - BS UI CSS Class |
| 135 |
|
| 136 |
?></span><?php |
| 137 |
?><div class="clear" style="height:0px;"></div><?php |
| 138 |
// Content //////////////////////////////////////////////////////////// |
| 139 |
?> |
| 140 |
<div class="clear" style="margin-bottom:10px;"></div> |
| 141 |
<span class="metabox-holder"> |
| 142 |
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" > |
| 143 |
<?php |
| 144 |
// N o n c e field, and key for checking S u b m i t |
| 145 |
wp_nonce_field( 'wpbm_settings_page_' . $submit_form_name ); |
| 146 |
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /> |
| 147 |
|
| 148 |
<div class="clear" style="margin-bottom:0px;"></div> |
| 149 |
|
| 150 |
<?php |
| 151 |
wpbm_open_meta_box_section( 'wpbm_settings_ics_upload_section', __( 'Upload .ics file and show events', 'booking-manager' ) ); |
| 152 |
|
| 153 |
$this->show_toolbar_upload(); |
| 154 |
|
| 155 |
wpbm_close_meta_box_section(); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
/////////////////////////////////////////////////////////// |
| 160 |
$notice_id = 'wpbm_system_notice_ics_description'; |
| 161 |
/////////////////////////////////////////////////////////// |
| 162 |
if ( ( ! wpbm_section_is_dismissed( $notice_id ) ) |
| 163 |
// || true |
| 164 |
) { |
| 165 |
|
| 166 |
?><div id="<?php echo $notice_id; ?>" |
| 167 |
class="wpbm_system_notice wpbm_is_dismissible wpbm_is_hideable wpbm-settings-notice notice-info"" |
| 168 |
data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_wpbmnonce' ); ?>" |
| 169 |
data-user-id="<?php echo get_current_user_id(); ?>" |
| 170 |
style="margin: 20px 0 !important;line-height: 2em;padding: 10px 20px;" |
| 171 |
><?php |
| 172 |
|
| 173 |
wpbm_x_dismiss_button(); |
| 174 |
|
| 175 |
//echo '<strong>' . __( 'Note!', 'booking-manager' ) . '</strong> '; |
| 176 |
|
| 177 |
$message_ics = sprintf( |
| 178 |
__( '.ics - is a file format of iCalendar standard for exchanging calendar and scheduling information between different sources %s Using a common calendar format (.ics), you can keep all your calendars updated and synchronized.', 'booking-manager' ) |
| 179 |
, |
| 180 |
'<br/><em>(<strong><a href="https://www.airbnb.com/help/article/99/how-do-i-sync-my-airbnb-calendar-with-another-calendar" target="_blank">Airbnb</a></strong>, ' |
| 181 |
. '<strong><a href="https://partnersupport.booking.com/hc/en-us/articles/213424709-How-do-I-export-my-calendar-" target="_blank">Booking.com</a></strong>, ' |
| 182 |
. '<strong><a href="https://help.homeaway.com/articles/How-do-I-export-my-calendar-data-to-a-Google-calendar" target="_blank">HomeAway</a></strong>, ' |
| 183 |
. '<strong><a href="https://rentalsupport.tripadvisor.com/articles/FAQ/noc-How-does-calendar-sync-work" target="_blank">TripAdvisor</a></strong>, ' |
| 184 |
. '<strong><a href="https://help.vrbo.com/articles/How-do-I-export-my-calendar-data-to-a-Google-calendar" target="_blank">VRBO</a></strong>, ' |
| 185 |
. '<strong><a href="https://helpcenter.flipkey.com/articles/FAQ/noc-How-does-calendar-sync-work" target="_blank">FlipKey</a></strong> ' |
| 186 |
. str_replace( array( '.ics', 'iCalendar' ), array( '<strong>.ics</strong>', '<strong>iCalendar</strong>' ), |
| 187 |
__( 'and any other calendar that uses .ics format', 'booking-manager' ) |
| 188 |
) |
| 189 |
. ')</em>.<br/>' |
| 190 |
); |
| 191 |
$message_ics = str_replace( array( '.ics', 'iCalendar' ), array( '<strong>.ics</strong>', '<strong>iCalendar</strong>' ), $message_ics ); |
| 192 |
echo $message_ics; |
| 193 |
|
| 194 |
|
| 195 |
?></div><?php |
| 196 |
} |
| 197 |
/////////////////////////////////////////////////////////// |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
wpbm_open_meta_box_section( 'wpbm_settings_ics_listing_log', __( 'Log', 'booking-manager' ) ); |
| 204 |
?><div class="wpbm_system_info_log"></div><?php |
| 205 |
wpbm_close_meta_box_section(); |
| 206 |
/* ?> |
| 207 |
<input type="button" value="<?php _e('Send', 'booking-manager'); ?>" class="button button-primary wpbm_send_button" /> |
| 208 |
<input type="submit" value="<?php _e('Submit', 'booking-manager'); ?>" class="button button-primary wpbm_submit_button" /> |
| 209 |
<?php /**/ |
| 210 |
?> |
| 211 |
</form> |
| 212 |
<?php |
| 213 |
|
| 214 |
?> |
| 215 |
</span> |
| 216 |
<?php |
| 217 |
|
| 218 |
wpbm_show_wpbm_footer(); // Rating |
| 219 |
|
| 220 |
wpbm_ics_listing_ajax_js(); |
| 221 |
|
| 222 |
$this->css(); |
| 223 |
|
| 224 |
do_action( 'wpbm_hook_settings_page_footer', 'ics_files' ); |
| 225 |
} |
| 226 |
|
| 227 |
/** Currently is not being used */ |
| 228 |
public function update() { |
| 229 |
|
| 230 |
return false; |
| 231 |
|
| 232 |
$post_action_key = 'wpbm_action'; |
| 233 |
if ( isset( $_POST[ $post_action_key ] ) && ( $_POST[ $post_action_key ] == 'go_send' ) ) { |
| 234 |
|
| 235 |
// Get Validated post |
| 236 |
$validated = array(); |
| 237 |
|
| 238 |
// Email |
| 239 |
$validated[ 'wpbm_textdata' ] = WPBM_Settings_API::validate_textarea_post_static( 'wpbm_textdata' ); |
| 240 |
//debuge( $validated ); |
| 241 |
|
| 242 |
//////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 243 |
|
| 244 |
wpbm_show_fixed_message ( __('Done', 'booking-manager'), 3 ); //, 'updated warning' ); // Show Message |
| 245 |
|
| 246 |
return array ( 'validated_data' => $validated ); // Exit, for do not parse |
| 247 |
} |
| 248 |
|
| 249 |
/** Buld data saving to DB from POST |
| 250 |
//$validated_fields = $this->settings_api()->validate_post(); // Get Validated Settings fields in $_POST request. |
| 251 |
//$validated_fields = apply_filters( 'wpbm_settings_validate_fields_before_saving', $validated_fields ); // Hook for validated fields. |
| 252 |
|
| 253 |
// unset($validated_fields['wpbm_start_day_weeek']); // Skip saving specific option, for example in Demo mode. |
| 254 |
//$this->settings_api()->save_to_db( $validated_fields ); // Save fields to DB |
| 255 |
//wpbm_show_changes_saved_message(); |
| 256 |
//wpbm_show_fixed_message ( __('Done', 'booking-manager'), 0 ); // Show Message |
| 257 |
*/ |
| 258 |
|
| 259 |
/** O L D W A Y: Saving Fields Data |
| 260 |
// update_wpbm_option( 'wpbm_is_delete_if_deactive' |
| 261 |
// , WPBM_Settings_API::validate_checkbox_post('wpbm_is_delete_if_deactive') ); |
| 262 |
// ( (isset( $_POST['wpbm_is_delete_if_deactive'] ))?'On':'Off') ); |
| 263 |
*/ |
| 264 |
|
| 265 |
return false; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
/** Show Toolbar with Upload / List fields */ |
| 270 |
function show_toolbar_upload() { |
| 271 |
|
| 272 |
// Parameters for Ajax: |
| 273 |
|
| 274 |
?><div class="wpbm_listing_ics_bar" id="wpbm_listing_ics_bar" |
| 275 |
data-nonce="<?php echo wp_create_nonce( $nonce_name = 'wpbm_listing_ics_nonce_actn' ); ?>" |
| 276 |
data-user-id="<?php echo get_current_user_id(); ?>" |
| 277 |
><?php |
| 278 |
?> |
| 279 |
<div class="wpbm_listing_div"> |
| 280 |
<input type="text" |
| 281 |
class="wpbm_listing_url" name="wpbm_listing_url" id="wpbm_listing_url" |
| 282 |
placeholder="<?php _e( 'URL to .ics feed', 'booking-manager' ) ?>" |
| 283 |
value="" wrap="off" |
| 284 |
/> |
| 285 |
<?php if ( function_exists( 'wpbm_upload' ) ) { ?> |
| 286 |
<a href="javascript:void(0)" class="button button-secondary wpbm_upload_btn" |
| 287 |
data-modal_title="<?php echo esc_attr( __( 'Choose file', 'booking-manager' ) ); ?>" |
| 288 |
data-btn_title="<?php echo esc_attr( __( 'Insert file URL', 'booking-manager' ) ); ?>" |
| 289 |
><?php _e('Upload / Select ', 'booking-manager' ); ?> <strong>(.ics)</strong></a> |
| 290 |
<?php } ?> |
| 291 |
<a class="button button-primary wpbm_listing_btn" href="javascript:void(0)"><?php _e('Show Events (.ics)', 'booking-manager'); ?></a> |
| 292 |
</div> |
| 293 |
<?php |
| 294 |
if ( function_exists( 'wpbm_upload' ) ) { // Get WPBM_Upload obj. instance |
| 295 |
|
| 296 |
$wpbm_upload = wpbm_upload(); |
| 297 |
|
| 298 |
$wpbm_upload->set_upload_button( '.wpbm_upload_btn' ); |
| 299 |
|
| 300 |
$wpbm_upload->set_element_insert_url( '.wpbm_listing_url' ); |
| 301 |
} |
| 302 |
?> |
| 303 |
<div class="clear"></div> |
| 304 |
<div class="wpbm_system_info_log0"></div> |
| 305 |
<div class="clear"></div> |
| 306 |
</div> |
| 307 |
<?php |
| 308 |
} |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
// <editor-fold defaultstate="collapsed" desc=" C S S " > |
| 313 |
public function css() { |
| 314 |
?> |
| 315 |
<style type="text/css"> |
| 316 |
.wpbm_listing_ics_bar .wpbm_listing_btn, |
| 317 |
.wpbm_listing_ics_bar .wpbm_upload_btn{ |
| 318 |
float:left; |
| 319 |
margin:9px 5px 10px 1px; |
| 320 |
|
| 321 |
} |
| 322 |
.wpbm_listing_ics_bar .wpbm_listing_div { |
| 323 |
float:left; |
| 324 |
width:100%; |
| 325 |
} |
| 326 |
.wpbm_listing_ics_bar .wpbm_listing_br_selection, |
| 327 |
.wpbm_listing_ics_bar .wpbm_listing_url { |
| 328 |
float:left; |
| 329 |
width:28%; |
| 330 |
height: 2em; |
| 331 |
padding: 2px; |
| 332 |
border-radius: 0; |
| 333 |
margin:10px 5px 10px 1px; |
| 334 |
} |
| 335 |
.wpbm_listing_ics_bar .wpbm_listing_url { |
| 336 |
width:50%; |
| 337 |
padding: 2px 5px; |
| 338 |
} |
| 339 |
.wpbm_system_info_log { |
| 340 |
font-size: 11px; |
| 341 |
line-height: 1.5em; |
| 342 |
/* border: 2px dashed #e85; */ |
| 343 |
padding: 5px 20px; |
| 344 |
margin-top:10px; |
| 345 |
} |
| 346 |
|
| 347 |
#wpbm_textdata { |
| 348 |
width: 100%; |
| 349 |
font-size: 1.4em; |
| 350 |
font-weight: 600; |
| 351 |
} |
| 352 |
/* iPad mini and all iPhones and other Mobile Devices */ |
| 353 |
@media (max-width: 782px) { |
| 354 |
.wpbm_listing_ics_bar .wpbm_listing_url { |
| 355 |
width:100%; |
| 356 |
} |
| 357 |
.wpbm_page .wpbm_send_button { |
| 358 |
padding: 2px; |
| 359 |
margin-top: 1px; |
| 360 |
} |
| 361 |
} |
| 362 |
</style> |
| 363 |
<?php |
| 364 |
} |
| 365 |
// </editor-fold> |
| 366 |
} |
| 367 |
add_action('wpbm_menu_created', array( new WPBM_Page_Single() , '__construct') ); // Executed after creation of Menu |
| 368 |
|
| 369 |
|
| 370 |
// <editor-fold defaultstate="collapsed" desc=" A J A X R e q u e s t " > |
| 371 |
//////////////////////////////////////////////////////////////////////////////// |
| 372 |
// AJAX Request |
| 373 |
//////////////////////////////////////////////////////////////////////////////// |
| 374 |
|
| 375 |
/** JavaScript for Ajax */ |
| 376 |
function wpbm_ics_listing_ajax_js() { |
| 377 |
|
| 378 |
$ajx_el_id = 'wpbm_listing_ics_bar'; |
| 379 |
|
| 380 |
// In "wpbm-ajax.php" having this: , 'WPBM_LISTING_ICS_URL' => 'admin' |
| 381 |
|
| 382 |
?> |
| 383 |
<script type="text/javascript"> |
| 384 |
// Ajax Request |
| 385 |
jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... }); |
| 386 |
|
| 387 |
jQuery( '.wpbm_listing_ics_bar' ).on( 'click', '.wpbm_listing_btn', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded |
| 388 |
|
| 389 |
wpbm_admin_show_message_processing( '' ); |
| 390 |
|
| 391 |
var jq_el = jQuery( this ).closest( '.wpbm_listing_ics_bar' ); |
| 392 |
|
| 393 |
var params_obj = {}; |
| 394 |
params_obj.id = jq_el.attr( 'id' ); |
| 395 |
params_obj.nonce = jq_el.attr( 'data-nonce' ); |
| 396 |
params_obj.user_id = jq_el.attr( 'data-user-id' ); |
| 397 |
|
| 398 |
params_obj.wpbm_listing_url = jQuery( '#wpbm_listing_url' ).val(); |
| 399 |
// params_obj.wpbm_listing_br_selection = 1; |
| 400 |
// if ( jQuery( '#wpbm_listing_br_selection option' ).length > 0 ) |
| 401 |
// params_obj.wpbm_listing_br_selection = jQuery( '#wpbm_listing_br_selection option' ).filter( ':selected' ).val(); |
| 402 |
|
| 403 |
// console.log(params_obj); |
| 404 |
|
| 405 |
jQuery.post( wpbm_ajaxurl, { |
| 406 |
action: 'WPBM_LISTING_ICS_URL', |
| 407 |
user_id: params_obj.user_id , |
| 408 |
nonce: params_obj.nonce, |
| 409 |
params: params_obj |
| 410 |
}, |
| 411 |
function ( response_data, textStatus, jqXHR ) { // success |
| 412 |
|
| 413 |
var my_message = '<?php echo html_entity_decode( esc_js( __('Done' ,'booking-manager') ),ENT_QUOTES) ; ?>'; |
| 414 |
wpbm_admin_show_message( my_message, 'info', 10000 , false ); |
| 415 |
|
| 416 |
//console.log( response_data ); console.log( textStatus); console.log( jqXHR ); // Debug |
| 417 |
//jQuery( '.wpbm_system_info_log' ).show(); //Show Debug info |
| 418 |
response_data = response_data.replace( '{"response":"success"}', '' ); |
| 419 |
jQuery( '.wpbm_system_info_log' ).html( response_data ); // For ability to show response, add such DIV element to page |
| 420 |
wpbm_scroll_to('#wpbm_settings_ics_listing_log_metabox' ); |
| 421 |
} |
| 422 |
).fail( function ( jqXHR, textStatus, errorThrown ) { |
| 423 |
wpbm_admin_show_message( '<strong style="text-transform: uppercase;">' + textStatus + '</strong> ~ ' + errorThrown , 'error', 5000 ); |
| 424 |
if ( window.console && window.console.log ){ console.log( 'Ajax_Error', jqXHR, textStatus, errorThrown ); } |
| 425 |
}) |
| 426 |
// .done( function ( data, textStatus, jqXHR ) { if ( window.console && window.console.log ){ console.log( 'second success', data, textStatus, jqXHR ); } }) |
| 427 |
// .always( function ( data_jqXHR, textStatus, jqXHR_errorThrown ) { if ( window.console && window.console.log ){ console.log( 'always finished', data_jqXHR, textStatus, jqXHR_errorThrown ); } }) |
| 428 |
; |
| 429 |
|
| 430 |
}); |
| 431 |
|
| 432 |
}); |
| 433 |
</script> |
| 434 |
<?php |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
/** Ajax Response */ |
| 439 |
function wpbm_ajax_WPBM_LISTING_ICS_URL() { |
| 440 |
|
| 441 |
if ( ! isset( $_POST['params'] ) || empty( $_POST['params'] ) ) { |
| 442 |
exit; |
| 443 |
} |
| 444 |
|
| 445 |
// Check Security |
| 446 |
$action_nonce_name = 'wpbm_listing_ics_nonce_actn'; |
| 447 |
$nonce_post_key = 'nonce'; |
| 448 |
$result = check_ajax_referer( $action_nonce_name, $nonce_post_key ); // Check Security |
| 449 |
|
| 450 |
$is_show_debug_info = false; |
| 451 |
if ( function_exists( 'get_bk_option' ) ) |
| 452 |
$is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false ); // Based on "Booking Calendar" - "show_system_debug_log" option !!! |
| 453 |
|
| 454 |
if ( $is_show_debug_info ) |
| 455 |
add_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10, 1 ); |
| 456 |
|
| 457 |
do_action( 'wpbm_show_debug', array( 'Import Parameters' , $_POST ) ); // S_Y_S_T_E_M L_O_G |
| 458 |
|
| 459 |
if ( empty( $_POST[ 'params' ][ 'wpbm_listing_url'] ) ) { |
| 460 |
do_action( 'wpbm_admin_show_top_notice', __( 'No ics url feed', 'booking-manager' ), 'error', 5000 ); // N_O_T_I_C_E in H_E_A_D_E_R |
| 461 |
return false; |
| 462 |
} |
| 463 |
|
| 464 |
$params = array( |
| 465 |
'url' => esc_url( $_POST[ 'params' ][ 'wpbm_listing_url'] ) |
| 466 |
, 'from' => 'any' //'today' // '00:00 today' |
| 467 |
, 'from_offset' => '' |
| 468 |
, 'until' => 'any' //'year-end' // '00:00 today' |
| 469 |
, 'until_offset' => '' |
| 470 |
, 'max' => '' |
| 471 |
, 'is_all_dates_in' => true |
| 472 |
); |
| 473 |
$listing_echo = wpbm_ics_get_listing( $params ); |
| 474 |
|
| 475 |
do_action( 'wpbm_show_debug', array( '$listing_echo', $listing_echo ) ); // S_Y_S_T_E_M L_O_G |
| 476 |
|
| 477 |
/////////////////////////////////////////////////////////////////////////////////////// |
| 478 |
// Get Listing Shortcode |
| 479 |
/////////////////////////////////////////////////////////////////////////////////////// |
| 480 |
ob_start(); |
| 481 |
?> |
| 482 |
<div class="wpbm-settings-notice notice-info" |
| 483 |
style="text-align:left;border-top:1px solid #f0f0f0;border-right:1px solid #f0f0f0;line-height: 2em;font-size: 13px;margin:10px 0 20px;"> |
| 484 |
<?php echo ( esc_js( __( 'Insert this shortcode into page for showing these events at front-end side of your website.', 'booking-manager' ) ) ); ?> |
| 485 |
<br> |
| 486 |
<code>[booking-manager-listing url='<?php echo esc_url( $_POST[ 'params' ][ 'wpbm_listing_url'] ); ?>' from='any' until='any']</code> |
| 487 |
</div> |
| 488 |
<div class="clear" style="border-top: 2px dashed #e85;height:20px;"></div> |
| 489 |
<?php |
| 490 |
$echo_results = ob_get_contents(); |
| 491 |
|
| 492 |
ob_end_clean(); |
| 493 |
/////////////////////////////////////////////////////////////////////////////////////// |
| 494 |
|
| 495 |
echo $echo_results. $listing_echo; |
| 496 |
|
| 497 |
if ( $is_show_debug_info ) |
| 498 |
remove_action( 'wpbm_show_debug', 'wpbm_start_showing_debug', 10 ); |
| 499 |
|
| 500 |
/* |
| 501 |
if ( $is_show_debug_info ) { |
| 502 |
// Showingdebug log section |
| 503 |
?><script type="text/javascript"> jQuery( '.wpbm_system_info_log' ).show(); </script><?php |
| 504 |
} |
| 505 |
*/ |
| 506 |
|
| 507 |
// send JSON |
| 508 |
// FixIn: 2.0.2.1 //Fix: We need to comment this line, because previously its possible that we already sent some messages, and its does not correct json format in this case. |
| 509 |
//Fix: of showing "parsererror ~ SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" |
| 510 |
//wp_send_json( array( 'response' => 'success' ) ); // Return JS OBJ: response_data = { response: "success" } |
| 511 |
wp_die( '', '', array( 'response' => null ) ); |
| 512 |
} |
| 513 |
// </editor-fold> |