PluginProbe
Easy Hotel – Powerful Hotel Booking / 2.0.4
Easy Hotel – Powerful Hotel Booking v2.0.4
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / framework / functions / actions.php

actions.php in Easy Hotel – Powerful Hotel Booking 2.0.4, at admin/includes/framework/functions/actions.php

207 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Get icons from admin ajax
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! function_exists( 'eshb_get_icons' ) ) {
11 function eshb_get_icons() {
12
13 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
14
15 if ( ! wp_verify_nonce( $nonce, 'eshb_icon_nonce' ) ) {
16 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'easy-hotel' ) ) );
17 }
18
19 ob_start();
20
21 $icon_library = ( apply_filters( 'eshb_fa4', false ) ) ? 'fa4' : 'fa5';
22
23 ESHB::include_plugin_file( 'fields/icon/'. $icon_library .'-icons.php' );
24
25 $icon_lists = apply_filters( 'eshb_field_icon_add_icons', eshb_get_default_icons() );
26
27 if ( ! empty( $icon_lists ) ) {
28
29 foreach ( $icon_lists as $list ) {
30
31 echo ( count( $icon_lists ) >= 2 ) ? '<div class="csf-icon-title">'. esc_attr( $list['title'] ) .'</div>' : '';
32
33 foreach ( $list['icons'] as $icon ) {
34 echo '<i title="'. esc_attr( $icon ) .'" class="'. esc_attr( $icon ) .'"></i>';
35 }
36
37 }
38
39 } else {
40
41 echo '<div class="csf-error-text">'. esc_html__( 'No data available.', 'easy-hotel' ) .'</div>';
42
43 }
44
45 $content = ob_get_clean();
46
47 wp_send_json_success( array( 'content' => $content ) );
48
49 }
50 add_action( 'wp_ajax_eshb-get-icons', 'eshb_get_icons' );
51 }
52
53 /**
54 *
55 * Export
56 *
57 * @since 1.0.0
58 * @version 1.0.0
59 *
60 */
61 if ( ! function_exists( 'eshb_export' ) ) {
62 function eshb_export() {
63
64 $nonce = ( ! empty( $_GET[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'nonce' ] ) ) : '';
65 $unique = ( ! empty( $_GET[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_GET[ 'unique' ] ) ) : '';
66
67 if ( ! wp_verify_nonce( $nonce, 'eshb_backup_nonce' ) ) {
68 die( esc_html__( 'Error: Invalid nonce verification.', 'easy-hotel' ) );
69 }
70
71 if ( empty( $unique ) ) {
72 die( esc_html__( 'Error: Invalid key.', 'easy-hotel' ) );
73 }
74
75 // Export
76 header('Content-Type: application/json');
77 header('Content-disposition: attachment; filename=backup-'. gmdate( 'd-m-Y' ) .'.json');
78 header('Content-Transfer-Encoding: binary');
79 header('Pragma: no-cache');
80 header('Expires: 0');
81
82 echo wp_json_encode( get_option( $unique ) );
83
84 die();
85
86 }
87 add_action( 'wp_ajax_eshb-export', 'eshb_export' );
88 }
89
90 /**
91 *
92 * Import Ajax
93 *
94 * @since 1.0.0
95 * @version 1.0.0
96 *
97 */
98 if ( ! function_exists( 'eshb_import_ajax' ) ) {
99 function eshb_import_ajax() {
100
101 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
102 $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
103 //$data = ( ! empty( $_POST[ 'data' ] ) ) ? wp_kses_post_deep( wp_json_decode( trim( wp_unslash( $_POST[ 'data' ] ) ), true ) ) : array();
104 $data = array();
105
106 if ( ! empty( $_POST['data'] ) ) {
107 // Sanitize $_POST['data'] immediately after retrieving it
108 $post_data = sanitize_text_field( wp_unslash( $_POST['data'] ) );
109
110 // Decode the sanitized JSON data
111 $decoded_data = wp_json_decode( trim( $post_data ), true );
112
113 // Sanitize the decoded data deeply using wp_kses_post_deep to allow safe HTML
114 if ( is_array( $decoded_data ) ) {
115 $data = wp_kses_post_deep( $decoded_data );
116 }
117 }
118
119
120
121 if ( ! wp_verify_nonce( $nonce, 'eshb_backup_nonce' ) ) {
122 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'easy-hotel' ) ) );
123 }
124
125 if ( empty( $unique ) ) {
126 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid key.', 'easy-hotel' ) ) );
127 }
128
129 if ( empty( $data ) || ! is_array( $data ) ) {
130 wp_send_json_error( array( 'error' => esc_html__( 'Error: The response is not a valid JSON response.', 'easy-hotel' ) ) );
131 }
132
133 // Success
134 update_option( $unique, $data );
135
136 wp_send_json_success();
137
138 }
139 add_action( 'wp_ajax_eshb-import', 'eshb_import_ajax' );
140 }
141
142 /**
143 *
144 * Reset Ajax
145 *
146 * @since 1.0.0
147 * @version 1.0.0
148 *
149 */
150 if ( ! function_exists( 'eshb_reset_ajax' ) ) {
151 function eshb_reset_ajax() {
152
153 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
154 $unique = ( ! empty( $_POST[ 'unique' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'unique' ] ) ) : '';
155
156 if ( ! wp_verify_nonce( $nonce, 'eshb_backup_nonce' ) ) {
157 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'easy-hotel' ) ) );
158 }
159
160 // Success
161 delete_option( $unique );
162
163 wp_send_json_success();
164
165 }
166 add_action( 'wp_ajax_eshb-reset', 'eshb_reset_ajax' );
167 }
168
169 /**
170 *
171 * Chosen Ajax
172 *
173 * @since 1.0.0
174 * @version 1.0.0
175 *
176 */
177 if ( ! function_exists( 'eshb_chosen_ajax' ) ) {
178 function eshb_chosen_ajax() {
179
180 $nonce = ( ! empty( $_POST[ 'nonce' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'nonce' ] ) ) : '';
181 $type = ( ! empty( $_POST[ 'type' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'type' ] ) ) : '';
182 $term = ( ! empty( $_POST[ 'term' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'term' ] ) ) : '';
183 $query = ( ! empty( $_POST[ 'query_args' ] ) ) ? wp_kses_post_deep( array_map( 'sanitize_text_field', wp_unslash($_POST[ 'query_args' ])) ) : array();
184
185 if ( ! wp_verify_nonce( $nonce, 'eshb_chosen_ajax_nonce' ) ) {
186 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid nonce verification.', 'easy-hotel' ) ) );
187 }
188
189 if ( empty( $type ) || empty( $term ) ) {
190 wp_send_json_error( array( 'error' => esc_html__( 'Error: Invalid term ID.', 'easy-hotel' ) ) );
191 }
192
193 $capability = apply_filters( 'eshb_chosen_ajax_capability', 'manage_options' );
194
195 if ( ! current_user_can( $capability ) ) {
196 wp_send_json_error( array( 'error' => esc_html__( 'Error: You do not have permission to do that.', 'easy-hotel' ) ) );
197 }
198
199 // Success
200 $options = ESHB_Fields::field_data( $type, $term, $query );
201
202 wp_send_json_success( $options );
203
204 }
205 add_action( 'wp_ajax_eshb-chosen', 'eshb_chosen_ajax' );
206 }
207