PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.1.22
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.1.22
2.1.22 2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 All 56 releases
booking-manager / core / admin / page-settings-listing.php

page-settings-listing.php in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar 2.1.22, at core/admin/page-settings-listing.php

556 lines 27.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php /**
2 * @version 1.0
3 * @package Booking Manager
4 * @category Content of item Listing page
5 * @author wpdevelop
6 *
7 * @web-site https://oplugins.com/
8 * @email [email protected]
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_SettingsListing extends WPBM_Page_Structure {
22
23
24 public function in_page() {
25 return 'oplugins';// 'wpbm-settings';
26 }
27
28
29 public function tabs() {
30
31 $tabs = array();
32 $tabs[ 'wpbm-settings' ] = array(
33 'title' => __( 'Settings', 'booking-manager' ) // Title of TAB
34 , 'page_title' => __( 'Settings', 'booking-manager' ) // Title of Page
35 , 'hint' => __( 'Settings', 'booking-manager' ) // Hint
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-menu-hamburger' // CSS definition of forn Icon
41 , 'default' => false // Is this tab activated by default or not: true || false.
42 , 'disabled' => false // Is this tab disbaled: true || false.
43 , 'hided' => false // Is this tab hided: true || false.
44 , 'subtabs' => array()
45 );
46 // $subtabs = array();
47 // $tabs[ 'items' ][ 'subtabs' ] = $subtabs;
48
49 $subtabs['listing'] = array(
50 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
51 , 'title' => __('Listing Template' , 'booking-manager') // Title of TAB
52 , 'page_title' => __('Listing Template', 'booking-manager') // Title of Page
53 , 'hint' => __('Listing Template' , 'booking-manager') // Hint
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 );
64
65 $tabs[ 'wpbm-settings' ]['subtabs'] = $subtabs;
66 return $tabs;
67 }
68
69
70 public function content() {
71
72 if ( ! $this->can_manage_listing_template() ) {
73 wp_die(
74 esc_html__( 'Sorry, you are not allowed to manage the Booking Manager listing template.', 'booking-manager' )
75 , esc_html__( 'Forbidden', 'booking-manager' )
76 , array( 'response' => 403 )
77 );
78 }
79
80 do_action( 'wpbm_hook_settings_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed.
81
82 ////////////////////////////////////////////////////////////////////////
83 // Submit /////////////////////////////////////////////////////////////
84
85 $submit_form_name = 'wpbm_form_listing'; // Define form name
86
87 if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) {
88
89 // Nonce checking {Return false if invalid, 1 if generated between, 0-12 hours ago, 2 if generated between 12-24 hours ago. }
90 $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
91
92 // Save Changes
93 $this->update();
94 }
95
96 ////////////////////////////////////////////////////////////////////////
97 // Get Data from DB ////////////////////////////////////////////////////
98 $data_list_tmpl = get_wpbm_option( 'wpbm_listing_template' );
99 //$data_list_tmpl = wpbm_nl_after_br( $data_list_tmpl );
100
101
102 ////////////////////////////////////////////////////////////////////////
103 // Toolbar /////////////////////////////////////////////////////////////
104 wpbm_bs_toolbar_sub_html_container_start();
105
106 ?><span class="wpdevelop0"><div class="visibility_container clearfix-height" style="display:block;"><?php
107
108 wpbm_js_for_items_page(); // JavaScript functions
109
110 $this->toolbar_reset_to_default(); // Reset to Default Forms
111
112 $save_button = array( 'title' => __('Save Changes', 'booking-manager'), 'form' => $submit_form_name );
113 $this->toolbar_save_button( $save_button ); // Save Button
114
115 ?></div></span><?php
116
117 wpbm_bs_toolbar_sub_html_container_end();
118
119 ?><div class="clear"></div><?php
120
121 if ( 0 ) {
122 // Scroll links ////////////////////////////////////////////////////////
123 ?>
124 <div class="wpdvlp-sub-tabs" style="background:none;border:none;box-shadow: none;padding:0;"><span class="nav-tabs" style="text-align:right;">
125 <a href="javascript:void(0);" onclick="javascript:wpbm_scroll_to('#wpbm_settings_listing_metabox' );" original-title="" class="nav-tab go-to-link"><span><?php echo ucwords( __('Listing', 'booking-manager') ); ?></span></a>
126 </span></div>
127 <?php
128 }
129
130 ////////////////////////////////////////////////////////////////////////
131 // Content ////////////////////////////////////////////////////////////
132 ?>
133 <div class="clear" style="margin-bottom:10px;"></div>
134 <span class="metabox-holder">
135 <form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post">
136 <?php
137 // N o n c e field, and key for checking S u b m i t
138 wp_nonce_field( 'wpbm_settings_page_' . $submit_form_name );
139 ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" /><?php
140
141 ?><input type="hidden" name="reset_to_default_form" id="reset_to_default_form" value="" /><?php
142
143 ?><div class="wpbm_settings_row wpbm_settings_row_left"><?php
144
145 wpbm_open_meta_box_section( 'wpbm_settings_listing', __('Event template - row for event listing', 'booking-manager') );
146
147 $this->show_listing_template( $data_list_tmpl );
148
149 wpbm_close_meta_box_section();
150 ?>
151 </div>
152 <div class="wpbm_settings_row wpbm_settings_row_right"><?php
153
154 wpbm_open_meta_box_section( 'wpbm_settings_listing_help', __('Help', 'booking-manager') );
155
156 $this->show_content_data_form_help();
157
158 wpbm_close_meta_box_section();
159 ?>
160 </div>
161 <div class="clear"></div>
162 <input type="submit" value="<?php _e('Save Changes','booking-manager'); ?>" class="button button-primary wpbm_submit_button" />
163 </form>
164 </span>
165 <?php
166
167 $this->css();
168 $this->js();
169
170 do_action( 'wpbm_hook_settings_page_footer', 'listing_template' );
171
172 }
173
174
175 /** Save Chanages */
176 public function update() {
177
178 if ( ! $this->can_manage_listing_template() ) {
179 wp_die(
180 esc_html__( 'Sorry, you are not allowed to manage the Booking Manager listing template.', 'booking-manager' )
181 , esc_html__( 'Forbidden', 'booking-manager' )
182 , array( 'response' => 403 )
183 );
184 }
185
186 $data_list_tmpl = isset( $_POST['listing_template'] ) ? trim( wp_unslash( $_POST['listing_template'] ) ) : '';
187 $data_list_tmpl = wpbm_sanitize_listing_template( $data_list_tmpl );
188 update_wpbm_option( 'wpbm_listing_template' , $data_list_tmpl );
189
190 wpbm_show_changes_saved_message();
191 }
192
193
194 /**
195 * Listing template is a global frontend template, so managing it requires
196 * administrator-level options access rather than the general plugin menu role.
197 *
198 * @return bool
199 */
200 private function can_manage_listing_template() {
201
202 return current_user_can( 'manage_options' );
203 }
204
205
206 // <editor-fold defaultstate="collapsed" desc=" CSS / JS " >
207
208 /** CSS for this page */
209 private function css() {
210 ?>
211 <style type="text/css">
212 .wpbm-help-message {
213 border:none;
214 }
215 /* toolbar fix */
216 .wpdevelop .visibility_container .control-group {
217 margin: 0 8px 5px 0;
218 }
219 /* Selectbox element in toolbar */
220 .visibility_container select optgroup{
221 color:#999;
222 vertical-align: middle;
223 font-style: italic;
224 font-weight: 400;
225 }
226 .visibility_container select option {
227 padding:5px;
228 font-weight: 600;
229 }
230 .visibility_container select optgroup option{
231 padding: 5px 20px;
232 color:#555;
233 font-weight: 600;
234 }
235 @media (max-width: 399px) {
236 #wpbm_create_new_custom_form_name_fields {
237 width: 100%;
238 }
239 }
240 /* iPad mini and all iPhones and other Mobile Devices */
241 @media (max-width: 782px) {
242 .wpbm_page .wpbm_send_button {
243 padding: 2px;
244 margin-top: 1px;
245 }
246 }
247 </style>
248 <?php
249 }
250
251
252 public function js() {
253 ?>
254 <script type="text/javascript">
255
256 /** Reset form to default template
257 *
258 * @param string template_name
259 */
260 function wpbm_reset_from_to_template( template_name ) {
261
262 var editor_textarea_id = 'listing_template';
263
264 var editor_textarea_content = wpbm_get_standard_template( template_name );
265
266 if( typeof tinymce != "undefined" ) {
267 var editor = tinymce.get( editor_textarea_id );
268 if( editor && editor instanceof tinymce.Editor ) {
269 editor.setContent( editor_textarea_content );
270 editor.save( { no_events: true } );
271 } else {
272 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
273 }
274 } else {
275 jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
276 }
277 }
278
279 /** Get Standard Template
280 *
281 * @param string form_type
282 * @returns string
283 */
284 function wpbm_get_standard_template( template_name ) {
285
286 var form_content = '';
287
288 if ( ( 'standard' == template_name ) ){
289 form_content = '';
290 form_content +='<div class="wpbm-event"> \n';
291 form_content +=' <div style="width:35%;float:left;margin-right:5%;">[DATES]</div> \n';
292 form_content +=' <div style="width:60%;float:left;"> \n';
293 form_content +=' <h2>[SUMMARY]</h2> <span style="display:none;">[UID]</span> \n';
294 form_content +=' <p class="desciption">[DESCRIPTION]</p> \n';
295 form_content +=' </div> \n';
296 form_content +=' <div style="clear:both;"></div> \n';
297 form_content +='</div> \n';
298 form_content +='<hr />';
299 }
300 return form_content;
301 }
302
303 </script>
304 <?php
305 }
306
307
308
309 // </editor-fold>
310
311
312 // <editor-fold defaultstate="collapsed" desc=" Toolbar " >
313
314 /** Show Save button in toolbar for saving form */
315 private function toolbar_save_button( $save_button ) {
316
317 ?>
318 <div class="clear-for-mobile"></div><input
319 type="button"
320 class="button button-primary wpbm_submit_button"
321 value="<?php echo $save_button['title']; ?>"
322 onclick="if (typeof document.forms['<?php echo $save_button['form']; ?>'] !== 'undefined'){
323 document.forms['<?php echo $save_button['form']; ?>'].submit();
324 } else {
325 wpbm_admin_show_message( '<?php echo ' <strong>Error!</strong> Form <strong>' , $save_button['form'] , '</strong> does not exist.'; ?>.', 'error', 10000 ); //FixIn: 7.0.1.56
326 }"
327 />
328 <?php
329 }
330
331
332 /** Selection of default Template and Button for Reseting */
333 private function toolbar_reset_to_default() {
334
335 $templates = array();
336
337 $templates['selector_hint'] = array(
338 'title' => __('Select', 'booking-manager') . ' ' . __('Form Template', 'booking-manager')
339 , 'id' => ''
340 , 'name' => ''
341 , 'style' => 'font-weight: 400;border-bottom:1px dashed #ccc;'
342 , 'class' => ''
343 , 'disabled' => false
344 , 'selected' => false
345 , 'attr' => array()
346 );
347
348 $templates[ 'optgroup_sf_s' ] = array(
349 'optgroup' => true
350 , 'close' => false
351 , 'title' => '&nbsp;' . __('Standard Templates' ,'booking-manager')
352 );
353 $templates[ 'standard' ] = array(
354 'title' => __('Standard', 'booking-manager')
355 , 'id' => ''
356 , 'name' => ''
357 , 'style' => ''
358 , 'class' => ''
359 , 'disabled' => false
360 , 'selected' => false
361 , 'attr' => array()
362 );
363 /*
364 $templates[ '2collumns' ] = array(
365 'title' => '2 ' . __('Columns', 'booking-manager')
366 , 'id' => ''
367 , 'name' => ''
368 , 'style' => ''
369 , 'class' => ''
370 , 'disabled' => false
371 , 'selected' => false
372 , 'attr' => array()
373 );
374 */
375 $templates[ 'optgroup_sf_e' ] = array( 'optgroup' => true, 'close' => true );
376
377 /*
378 $templates[ 'optgroup_af_s' ] = array(
379 'optgroup' => true
380 , 'close' => false
381 , 'title' => '&nbsp;' . __('Advanced Templates' ,'booking-manager')
382 );
383 $templates[ 'wizard' ] = array(
384 'title' => __('Wizard (several steps)', 'booking-manager')
385 , 'id' => ''
386 , 'name' => ''
387 , 'style' => ''
388 , 'class' => ''
389 , 'disabled' => false
390 , 'selected' => false
391 , 'attr' => array()
392 );
393
394
395 $templates[ 'optgroup_af_e' ] = array( 'optgroup' => true, 'close' => true );
396 */
397
398 $params = array(
399 'label_for' => 'select_form_help_shortcode' // "For" parameter of label element
400 , 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
401 , 'style' => '' // CSS Style of entire div element
402 , 'items' => array(
403 array(
404 'type' => 'addon'
405 , 'element' => 'text' // text | radio | checkbox
406 , 'text' => __('Reset Form', 'booking-manager') . ':'
407 , 'class' => '' // Any CSS class here
408 , 'style' => 'font-weight:600;' // CSS Style of entire div element
409 )
410 // Warning! Can be text or selectbox, not both OR you need to define width
411 , array(
412 'type' => 'select'
413 , 'id' => 'select_default_form_template'
414 , 'name' => 'select_default_form_template'
415 , 'style' => ''
416 , 'class' => ''
417 , 'multiple' => false
418 , 'disabled' => false
419 , 'disabled_options' => array() // If some options disbaled, then its must list here
420 , 'attr' => array() // Any additional attributes, if this radio | checkbox element
421 , 'options' => $templates // Associated array of titles and values
422 , 'value' => '' // Some Value from optins array that selected by default
423 , 'onfocus' => ''
424 //, 'onchange' => "wpbm_show_fields_generator( this.options[this.selectedIndex].value );"
425 )
426 )
427 );
428
429
430
431
432 ?><div class="control-group wpbm-no-padding"><?php
433 wpbm_bs_input_group( $params );
434 ?></div><?php
435
436
437 $params = array(
438 'label_for' => 'min_cost' // "For" parameter of label element
439 , 'label' => '' //__('Add New Field', 'booking-manager') // Label above the input group
440 , 'style' => '' // CSS Style of entire div element
441 , 'items' => array(
442 array(
443 'type' => 'button'
444 , 'title' => __('Reset', 'booking-manager') // __('Reset', 'booking-manager')
445 , 'hint' => array( 'title' => __('Reset Form' ,'booking-manager') , 'position' => 'top' )
446 , 'class' => 'button tooltip_top'
447 , 'font_icon' => 'glyphicon glyphicon-repeat'
448 , 'icon_position' => 'right'
449 , 'action' => " var sel_res_val = document.getElementById('select_default_form_template').options[ document.getElementById('select_default_form_template').selectedIndex ].value;"
450 . " if ( sel_res_val == 'selector_hint') { "
451 . " wpbm_field_highlight( '#select_default_form_template' ); return;" //. " jQuery('#wpbm_form_field').trigger( 'submit' );"
452 . " }"
453 //. " if ( wpbm_are_you_sure('" . esc_js(__('Do you really want to do this ?' ,'booking-manager')) . "') ) {"
454 . " wpbm_reset_from_to_template( sel_res_val ); " //. " jQuery('#wpbm_form_field').trigger( 'submit' );"
455 //. " }"
456 )
457 )
458 );
459
460 ?><div class="control-group wpbm-no-padding"><?php
461 wpbm_bs_input_group( $params );
462 ?></div><?php
463
464 }
465
466 // </editor-fold>
467
468
469 // <editor-fold defaultstate="collapsed" desc=" C O N T E N T F o r m s " >
470
471
472 /** Show Booking Form - in Settings page */
473 private function show_listing_template( $data ) {
474
475 wp_editor( $data,
476 'listing_template',
477 array(
478 'wpautop' => false
479 , 'media_buttons' => false
480 , 'textarea_name' => 'listing_template'
481 , 'textarea_rows' => 10
482 , 'tinymce' => !false // Remove Visual Mode from the Editor
483 , 'default_editor' => 'html' // 'tinymce' | 'html' // 'html' is used for the "Text" editor tab.
484 , 'editor_class' => 'wpbm-textarea-tinymce' // Any extra CSS Classes to append to the Editor textarea
485 , 'teeny' => true // Whether to output the minimal editor configuration used in PressThis
486 , 'drag_drop_upload' => false // Enable Drag & Drop Upload Support (since WordPress 3.9)
487 )
488 );
489 //echo '<textarea id="listing_template" name="listing_template" class="darker-border" style="width:100%;" rows="33">' . htmlspecialchars($listing_template, ENT_NOQUOTES ) . '</textarea>';
490 ?><div class="clear"></div><?php
491 }
492
493
494
495 /** Show Help section for Content Fields Data Form - in Settings page */
496 private function show_content_data_form_help() {
497
498 ?>
499 <div class="wpbm-help-message">
500 <span class="description"><strong><?php printf(__('Use these shortcodes for customization: ' ,'booking-manager'));?></strong></span><br/>
501 <?php
502 ?><span class="description"><?php
503 printf( __( '%s - date(s) of event', 'booking-manager' ) , '<code>[DATES]</code>' );
504 ?></span><br/>
505 <span class="description"><?php
506 printf( __( '%s - summary info of event', 'booking-manager' ) , '<code>[SUMMARY]</code>' );
507 ?></span><br/>
508 <span class="description"><?php
509 printf( __( '%s - ID of event', 'booking-manager' ) , '<code>[UID]</code>' );
510 ?></span><br/>
511 <span class="description"><?php
512 printf( __( '%s - description of event', 'booking-manager' ) , '<code>[DESCRIPTION]</code>' );
513 ?></span><br/>
514 <span class="description"><?php
515 printf( __( '%s - date of event editing, creation', 'booking-manager' ), '<code>[MODIFIED]</code>' );
516 ?></span><br/>
517 <span class="description"><?php
518 printf( __( '%s - location of event', 'booking-manager' ) , '<code>[LOCATION]</code>' );
519 ?></span><br/>
520 <hr/>
521 <span class="description"><?php //FixIn: 2.0.11.4
522 printf( __( '%s - ID of booking (in Booking Calendar plugin), if event has been imported', 'booking-manager' ) , '<code>[BOOKING_ID]</code>' );
523 ?></span><br/>
524 <span class="description"><?php //FixIn: 2.0.11.5
525 printf( __( '%s - link to booking (in Booking Calendar plugin), if event has been imported', 'booking-manager' ) , '<code>[BOOKING_LINK]</code>' );
526 ?></span><br/>
527 <span class="description"><?php //FixIn: 2.0.11.5
528 echo '<strong>' . __('Example' ,'booking-manager') . ':</strong><br/>';
529 echo '<em>' . '&lt;a href="[BOOKING_LINK]" target="_blank"&gt;[BOOKING_ID]&lt;/a&gt;' . '</em>'
530 ?></span><br/>
531
532 <hr/>
533 <span class="description"><?php printf(__('%s - inserting new line' ,'booking-manager'),'<code>&lt;br/&gt;</code>');?></span><br/>
534 <span class="description">
535 <?php
536 echo '<strong>' . __('HTML' ,'booking-manager') . '.</strong> '
537 . sprintf(__('You can use any %sHTML tags%s in the booking form. Please use the HTML tags carefully. Be sure, that all "open" tags (like %s) are closed (like this %s).' ,'booking-manager')
538 ,'<strong>','</strong>'
539 ,'<code>&lt;div&gt;</code>'
540 ,'<code>&lt;/div&gt;</code>'
541 );
542 ?>
543 </span>
544 </div>
545 <?php
546 //echo '<hr />';
547
548 }
549
550 // </editor-fold>
551
552
553 }
554 add_action('wpbm_menu_created', array( new WPBM_Page_SettingsListing() , '__construct') ); // Executed after creation of Menu
555
556