PluginProbe
Booking Calendar / 11.6
Booking Calendar v11.6
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / includes / page-bookings / booking_action / change_locale.php

change_locale.php in Booking Calendar 11.6, at includes/page-bookings/booking_action/change_locale.php

139 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Change Locale of the Booking - Option for "Actions Dropdown Menu"
4 *
5 * @package Support functions.
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit, if accessed directly.
10 }
11
12 /**
13 * Class WPBC_Action_Change_Locale
14 */
15 class WPBC_Action_Change_Locale {
16
17 const ACTION = 'set_booking_locale';
18
19 /**
20 * Get Action Button
21 *
22 * @return false|string
23 */
24 public static function get_button() {
25
26 if ( ! wpbc_is_user_can( self::ACTION, wpbc_get_current_user_id() ) ) {
27 return false;
28 }
29
30 // Change booking resource.
31 $html = "<#
32 var selected_locale_value = '';
33 if (
34 ( 'undefined' !== typeof( data.parsed_fields.booking_options) )
35 && ( 'undefined' !== typeof( data.parsed_fields.booking_options.booking_meta_locale ) )
36 ){
37 var selected_locale_value = data.parsed_fields.booking_options.booking_meta_locale;
38 }
39 #><a class=\"ul_dropdown_menu_li_action ul_dropdown_menu_li_action_" . esc_js( self::ACTION ) . "\"
40 href=\"javascript:void(0)\"
41 onclick=\"wpbc_boo_listing__click__set_booking_locale( {{data['parsed_fields']['booking_id']}}, '{{selected_locale_value}}' );\"
42 >" .
43 esc_js( __( 'Change language', 'booking' ) ) .
44 " <# if ( '' === selected_locale_value ) { #>" .
45 "<i class='menu_icon icon-1x wpbc_icn_language'></i>" .
46 ' <# } else { #>' .
47 "<span class='hint_value_instead_icon'>{{selected_locale_value}}</span>" .
48 ' <# } #>' .
49 '</a>';
50
51 return $html;
52 }
53
54
55 /**
56 * Get Template for Modal Window - Booking Change Locale - Modal Window structure
57 *
58 * @return false|void
59 */
60 public static function template_for_modal() {
61
62 $el_id = 'wpbc_modal__set_booking_locale';
63
64 $availbale_locales_in_system = get_available_languages();
65 $select_box_options = array();
66 $select_box_options[''] = __( 'Default Locale', 'booking' );
67 $select_box_options['en_US'] = 'English (United States)';
68
69 foreach ( $availbale_locales_in_system as $locale ) {
70 $select_box_options[ $locale ] = $locale;
71 }
72 $params_select = array(
73 'id' => $el_id,
74 'name' => $el_id,
75 'label' => '',
76 'style' => '',
77 'class' => 'set_booking_locale_selectbox',
78 'disabled' => false,
79 'disabled_options' => array(),
80 'options' => $select_box_options,
81 );
82
83 ?>
84 <span class="wpdevelop">
85 <div id="wpbc_modal__set_booking_locale__section" class="modal wpbc_popup_modal wpbc_modal_in_listing" tabindex="-1" role="dialog">
86 <div class="modal-dialog">
87 <div class="modal-content">
88 <div class="modal-header">
89 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
90 <h4 class="modal-title">
91 <?php
92 esc_html_e( 'Change locale', 'booking' );
93 ?>
94 <sup class="wpbc_modal__set_booking_locale__booking_id wpbc_modal__booking_id__in_title"></sup>
95 </h4>
96 </div>
97 <div class="modal-body">
98 <?php
99 wpbc_flex_select( $params_select );
100 ?>
101 <label class="help-block">
102 <?php
103 esc_html_e( 'Select locale for this booking', 'booking' );
104 ?>
105 </label>
106 <input type="hidden" id="wpbc_modal__set_booking_locale__booking_id" value=""/>
107 </div>
108 <div class="modal-footer">
109 <a id="wpbc_modal__set_booking_locale__button_send" class="button button-primary"
110 href="javascript:void(0);"
111 onclick="javascript: wpbc_ajx_booking_ajax_action_request( {
112 'booking_action' : '<?php echo esc_js( self::ACTION ); ?>',
113 'booking_id' : jQuery( '#wpbc_modal__set_booking_locale__booking_id' ).val(),
114 'booking_meta_locale' : jQuery( '#wpbc_modal__set_booking_locale' ).val(),
115 'ui_clicked_element_id': 'wpbc_modal__set_booking_locale__button_send'
116 } );
117 wpbc_button_enable_loading_icon( this );
118 jQuery( '#wpbc_modal__set_booking_locale__section' ).wpbc_my_modal( 'hide' );" >
119 <?php
120 esc_html_e( 'Change locale', 'booking' );
121 ?>
122 </a>
123 <a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal">
124 <?php
125 esc_html_e( 'Cancel', 'booking' );
126 ?>
127 </a>
128 </div>
129 </div><!-- /.modal-content -->
130 </div><!-- /.modal-dialog -->
131 </div><!-- /.modal -->
132 </span>
133 <?php
134 }
135 }
136
137 // Loads hidden modal template.
138 add_action( 'wpbc_hook_booking_template__hidden_templates', array( new WPBC_Action_Change_Locale(), 'template_for_modal' ) );
139