PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.0.18
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.0.18
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.0.18, at core/admin/page-settings-listing.php

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