@@ -12,50 +12,50 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public static $plug_version = '2.04.02b1'; |
14 | 14 | |
15 | - /** |
|
16 | - * @since 1.07.02 |
|
17 | - * |
|
18 | - * @param none |
|
19 | - * @return string The version of this plugin |
|
20 | - */ |
|
21 | - public static function plugin_version() { |
|
22 | - return self::$plug_version; |
|
23 | - } |
|
24 | - |
|
25 | - public static function plugin_folder() { |
|
26 | - return basename(self::plugin_path()); |
|
27 | - } |
|
28 | - |
|
29 | - public static function plugin_path() { |
|
30 | - return dirname(dirname(dirname(__FILE__))); |
|
31 | - } |
|
32 | - |
|
33 | - public static function plugin_url() { |
|
34 | - //prevously FRM_URL constant |
|
15 | + /** |
|
16 | + * @since 1.07.02 |
|
17 | + * |
|
18 | + * @param none |
|
19 | + * @return string The version of this plugin |
|
20 | + */ |
|
21 | + public static function plugin_version() { |
|
22 | + return self::$plug_version; |
|
23 | + } |
|
24 | + |
|
25 | + public static function plugin_folder() { |
|
26 | + return basename(self::plugin_path()); |
|
27 | + } |
|
28 | + |
|
29 | + public static function plugin_path() { |
|
30 | + return dirname(dirname(dirname(__FILE__))); |
|
31 | + } |
|
32 | + |
|
33 | + public static function plugin_url() { |
|
34 | + //prevously FRM_URL constant |
|
35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | public static function relative_plugin_url() { |
39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * @return string Site URL |
|
44 | - */ |
|
45 | - public static function site_url() { |
|
46 | - return site_url(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Get the name of this site |
|
51 | - * Used for [sitename] shortcode |
|
52 | - * |
|
53 | - * @since 2.0 |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public static function site_name() { |
|
57 | - return get_option('blogname'); |
|
58 | - } |
|
42 | + /** |
|
43 | + * @return string Site URL |
|
44 | + */ |
|
45 | + public static function site_url() { |
|
46 | + return site_url(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Get the name of this site |
|
51 | + * Used for [sitename] shortcode |
|
52 | + * |
|
53 | + * @since 2.0 |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public static function site_name() { |
|
57 | + return get_option('blogname'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -69,83 +69,83 @@ discard block |
||
69 | 69 | return ''; |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Get the Formidable settings |
|
74 | - * |
|
75 | - * @since 2.0 |
|
76 | - * |
|
77 | - * @param None |
|
78 | - * @return FrmSettings $frm_setings |
|
79 | - */ |
|
80 | - public static function get_settings() { |
|
81 | - global $frm_settings; |
|
82 | - if ( empty($frm_settings) ) { |
|
83 | - $frm_settings = new FrmSettings(); |
|
84 | - } |
|
85 | - return $frm_settings; |
|
86 | - } |
|
72 | + /** |
|
73 | + * Get the Formidable settings |
|
74 | + * |
|
75 | + * @since 2.0 |
|
76 | + * |
|
77 | + * @param None |
|
78 | + * @return FrmSettings $frm_setings |
|
79 | + */ |
|
80 | + public static function get_settings() { |
|
81 | + global $frm_settings; |
|
82 | + if ( empty($frm_settings) ) { |
|
83 | + $frm_settings = new FrmSettings(); |
|
84 | + } |
|
85 | + return $frm_settings; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | public static function get_menu_name() { |
89 | 89 | $frm_settings = FrmAppHelper::get_settings(); |
90 | 90 | return $frm_settings->menu; |
91 | 91 | } |
92 | 92 | |
93 | - /** |
|
94 | - * Show a message in place of pro features |
|
95 | - * |
|
96 | - * @since 2.0 |
|
97 | - */ |
|
93 | + /** |
|
94 | + * Show a message in place of pro features |
|
95 | + * |
|
96 | + * @since 2.0 |
|
97 | + */ |
|
98 | 98 | public static function update_message() { |
99 | 99 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
100 | - } |
|
101 | - |
|
102 | - public static function pro_is_installed() { |
|
103 | - return apply_filters('frm_pro_installed', false); |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Check for certain page in Formidable settings |
|
108 | - * |
|
109 | - * @since 2.0 |
|
110 | - * |
|
111 | - * @param string $page The name of the page to check |
|
112 | - * @return boolean |
|
113 | - */ |
|
100 | + } |
|
101 | + |
|
102 | + public static function pro_is_installed() { |
|
103 | + return apply_filters('frm_pro_installed', false); |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Check for certain page in Formidable settings |
|
108 | + * |
|
109 | + * @since 2.0 |
|
110 | + * |
|
111 | + * @param string $page The name of the page to check |
|
112 | + * @return boolean |
|
113 | + */ |
|
114 | 114 | public static function is_admin_page( $page = 'formidable' ) { |
115 | - global $pagenow; |
|
115 | + global $pagenow; |
|
116 | 116 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
117 | - if ( $pagenow ) { |
|
117 | + if ( $pagenow ) { |
|
118 | 118 | return $pagenow == 'admin.php' && $get_page == $page; |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | return is_admin() && $get_page == $page; |
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Check for the form preview page |
|
126 | - * |
|
127 | - * @since 2.0 |
|
128 | - * |
|
129 | - * @param None |
|
130 | - * @return boolean |
|
131 | - */ |
|
132 | - public static function is_preview_page() { |
|
133 | - global $pagenow; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Check for the form preview page |
|
126 | + * |
|
127 | + * @since 2.0 |
|
128 | + * |
|
129 | + * @param None |
|
130 | + * @return boolean |
|
131 | + */ |
|
132 | + public static function is_preview_page() { |
|
133 | + global $pagenow; |
|
134 | 134 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
135 | 135 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
136 | - } |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Check for ajax except the form preview page |
|
140 | - * |
|
141 | - * @since 2.0 |
|
142 | - * |
|
143 | - * @param None |
|
144 | - * @return boolean |
|
145 | - */ |
|
146 | - public static function doing_ajax() { |
|
147 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
148 | - } |
|
138 | + /** |
|
139 | + * Check for ajax except the form preview page |
|
140 | + * |
|
141 | + * @since 2.0 |
|
142 | + * |
|
143 | + * @param None |
|
144 | + * @return boolean |
|
145 | + */ |
|
146 | + public static function doing_ajax() { |
|
147 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | /** |
151 | 151 | * @since 2.0.8 |
@@ -155,102 +155,102 @@ discard block |
||
155 | 155 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
156 | 156 | } |
157 | 157 | |
158 | - /** |
|
159 | - * Check if on an admin page |
|
160 | - * |
|
161 | - * @since 2.0 |
|
162 | - * |
|
163 | - * @param None |
|
164 | - * @return boolean |
|
165 | - */ |
|
166 | - public static function is_admin() { |
|
167 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Check if value contains blank value or empty array |
|
172 | - * |
|
173 | - * @since 2.0 |
|
174 | - * @param mixed $value - value to check |
|
158 | + /** |
|
159 | + * Check if on an admin page |
|
160 | + * |
|
161 | + * @since 2.0 |
|
162 | + * |
|
163 | + * @param None |
|
164 | + * @return boolean |
|
165 | + */ |
|
166 | + public static function is_admin() { |
|
167 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Check if value contains blank value or empty array |
|
172 | + * |
|
173 | + * @since 2.0 |
|
174 | + * @param mixed $value - value to check |
|
175 | 175 | * @param string |
176 | - * @return boolean |
|
177 | - */ |
|
178 | - public static function is_empty_value( $value, $empty = '' ) { |
|
179 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
180 | - } |
|
181 | - |
|
182 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
183 | - return ! self::is_empty_value( $value, $empty ); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Get any value from the $_SERVER |
|
188 | - * |
|
189 | - * @since 2.0 |
|
190 | - * @param string $value |
|
191 | - * @return string |
|
192 | - */ |
|
176 | + * @return boolean |
|
177 | + */ |
|
178 | + public static function is_empty_value( $value, $empty = '' ) { |
|
179 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
180 | + } |
|
181 | + |
|
182 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
183 | + return ! self::is_empty_value( $value, $empty ); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Get any value from the $_SERVER |
|
188 | + * |
|
189 | + * @since 2.0 |
|
190 | + * @param string $value |
|
191 | + * @return string |
|
192 | + */ |
|
193 | 193 | public static function get_server_value( $value ) { |
194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Check for the IP address in several places |
|
199 | - * Used by [ip] shortcode |
|
200 | - * |
|
201 | - * @return string The IP address of the current user |
|
202 | - */ |
|
203 | - public static function get_ip_address() { |
|
194 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Check for the IP address in several places |
|
199 | + * Used by [ip] shortcode |
|
200 | + * |
|
201 | + * @return string The IP address of the current user |
|
202 | + */ |
|
203 | + public static function get_ip_address() { |
|
204 | 204 | $ip = ''; |
205 | - foreach ( array( |
|
206 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
207 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
208 | - ) as $key ) { |
|
209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
210 | - continue; |
|
211 | - } |
|
212 | - |
|
213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
214 | - $ip = trim($ip); // just to be safe |
|
215 | - |
|
216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
217 | - return $ip; |
|
218 | - } |
|
219 | - } |
|
220 | - } |
|
205 | + foreach ( array( |
|
206 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
207 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
208 | + ) as $key ) { |
|
209 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
210 | + continue; |
|
211 | + } |
|
212 | + |
|
213 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
214 | + $ip = trim($ip); // just to be safe |
|
215 | + |
|
216 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
217 | + return $ip; |
|
218 | + } |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | 222 | return sanitize_text_field( $ip ); |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
226 | - if ( strpos($param, '[') ) { |
|
227 | - $params = explode('[', $param); |
|
228 | - $param = $params[0]; |
|
229 | - } |
|
225 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
226 | + if ( strpos($param, '[') ) { |
|
227 | + $params = explode('[', $param); |
|
228 | + $param = $params[0]; |
|
229 | + } |
|
230 | 230 | |
231 | 231 | if ( $src == 'get' ) { |
232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
234 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
235 | - } |
|
232 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
233 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
234 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
235 | + } |
|
236 | 236 | self::sanitize_value( $sanitize, $value ); |
237 | 237 | } else { |
238 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
239 | - } |
|
238 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
242 | - foreach ( $params as $k => $p ) { |
|
243 | - if ( ! $k || ! is_array($value) ) { |
|
244 | - continue; |
|
245 | - } |
|
242 | + foreach ( $params as $k => $p ) { |
|
243 | + if ( ! $k || ! is_array($value) ) { |
|
244 | + continue; |
|
245 | + } |
|
246 | 246 | |
247 | - $p = trim($p, ']'); |
|
248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
249 | - } |
|
250 | - } |
|
247 | + $p = trim($p, ']'); |
|
248 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
249 | + } |
|
250 | + } |
|
251 | 251 | |
252 | - return $value; |
|
253 | - } |
|
252 | + return $value; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
256 | 256 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
268 | 268 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
269 | - } |
|
269 | + } |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
306 | - * |
|
307 | - * @since 2.0.8 |
|
308 | - * @param string $value |
|
309 | - * @return string $value |
|
310 | - */ |
|
305 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
306 | + * |
|
307 | + * @since 2.0.8 |
|
308 | + * @param string $value |
|
309 | + * @return string $value |
|
310 | + */ |
|
311 | 311 | public static function preserve_backslashes( $value ) { |
312 | 312 | // If backslashes have already been added, don't add them again |
313 | 313 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
333 | - $temp_values = $values; |
|
334 | - foreach ( $temp_values as $k => $val ) { |
|
335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
332 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
333 | + $temp_values = $values; |
|
334 | + foreach ( $temp_values as $k => $val ) { |
|
335 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
336 | 336 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
337 | - } |
|
338 | - } |
|
339 | - } |
|
337 | + } |
|
338 | + } |
|
339 | + } |
|
340 | 340 | |
341 | 341 | public static function sanitize_array( &$values ) { |
342 | 342 | $temp_values = $values; |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public static function kses( $value, $allowed = array() ) { |
356 | 356 | $html = array( |
357 | - 'a' => array( |
|
357 | + 'a' => array( |
|
358 | 358 | 'href' => array(), |
359 | 359 | 'title' => array(), |
360 | 360 | 'id' => array(), |
361 | 361 | 'class' => array(), |
362 | - ), |
|
362 | + ), |
|
363 | 363 | ); |
364 | 364 | |
365 | 365 | $allowed_html = array(); |
@@ -370,77 +370,77 @@ discard block |
||
370 | 370 | return wp_kses( $value, $allowed_html ); |
371 | 371 | } |
372 | 372 | |
373 | - /** |
|
374 | - * Used when switching the action for a bulk action |
|
375 | - * @since 2.0 |
|
376 | - */ |
|
377 | - public static function remove_get_action() { |
|
378 | - if ( ! isset($_GET) ) { |
|
379 | - return; |
|
380 | - } |
|
373 | + /** |
|
374 | + * Used when switching the action for a bulk action |
|
375 | + * @since 2.0 |
|
376 | + */ |
|
377 | + public static function remove_get_action() { |
|
378 | + if ( ! isset($_GET) ) { |
|
379 | + return; |
|
380 | + } |
|
381 | 381 | |
382 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
383 | - if ( ! empty( $new_action ) ) { |
|
382 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
383 | + if ( ! empty( $new_action ) ) { |
|
384 | 384 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
385 | - } |
|
386 | - } |
|
387 | - |
|
388 | - /** |
|
389 | - * Check the WP query for a parameter |
|
390 | - * |
|
391 | - * @since 2.0 |
|
392 | - * @return string|array |
|
393 | - */ |
|
394 | - public static function get_query_var( $value, $param ) { |
|
395 | - if ( $value != '' ) { |
|
396 | - return $value; |
|
397 | - } |
|
398 | - |
|
399 | - global $wp_query; |
|
400 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
401 | - $value = $wp_query->query_vars[ $param ]; |
|
402 | - } |
|
403 | - |
|
404 | - return $value; |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * @param string $type |
|
409 | - */ |
|
410 | - public static function trigger_hook_load( $type, $object = null ) { |
|
411 | - // only load the form hooks once |
|
385 | + } |
|
386 | + } |
|
387 | + |
|
388 | + /** |
|
389 | + * Check the WP query for a parameter |
|
390 | + * |
|
391 | + * @since 2.0 |
|
392 | + * @return string|array |
|
393 | + */ |
|
394 | + public static function get_query_var( $value, $param ) { |
|
395 | + if ( $value != '' ) { |
|
396 | + return $value; |
|
397 | + } |
|
398 | + |
|
399 | + global $wp_query; |
|
400 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
401 | + $value = $wp_query->query_vars[ $param ]; |
|
402 | + } |
|
403 | + |
|
404 | + return $value; |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * @param string $type |
|
409 | + */ |
|
410 | + public static function trigger_hook_load( $type, $object = null ) { |
|
411 | + // only load the form hooks once |
|
412 | 412 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
413 | - if ( ! $hooks_loaded ) { |
|
413 | + if ( ! $hooks_loaded ) { |
|
414 | 414 | do_action( 'frm_load_' . $type . '_hooks' ); |
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Check cache before fetching values and saving to cache |
|
420 | - * |
|
421 | - * @since 2.0 |
|
422 | - * |
|
423 | - * @param string $cache_key The unique name for this cache |
|
424 | - * @param string $group The name of the cache group |
|
425 | - * @param string $query If blank, don't run a db call |
|
426 | - * @param string $type The wpdb function to use with this query |
|
427 | - * @return mixed $results The cache or query results |
|
428 | - */ |
|
429 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
430 | - $results = wp_cache_get($cache_key, $group); |
|
431 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
432 | - return $results; |
|
433 | - } |
|
434 | - |
|
435 | - if ( 'get_posts' == $type ) { |
|
436 | - $results = get_posts($query); |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Check cache before fetching values and saving to cache |
|
420 | + * |
|
421 | + * @since 2.0 |
|
422 | + * |
|
423 | + * @param string $cache_key The unique name for this cache |
|
424 | + * @param string $group The name of the cache group |
|
425 | + * @param string $query If blank, don't run a db call |
|
426 | + * @param string $type The wpdb function to use with this query |
|
427 | + * @return mixed $results The cache or query results |
|
428 | + */ |
|
429 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
430 | + $results = wp_cache_get($cache_key, $group); |
|
431 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
432 | + return $results; |
|
433 | + } |
|
434 | + |
|
435 | + if ( 'get_posts' == $type ) { |
|
436 | + $results = get_posts($query); |
|
437 | 437 | } else if ( 'get_associative_results' == $type ) { |
438 | 438 | global $wpdb; |
439 | 439 | $results = $wpdb->get_results( $query, OBJECT_K ); |
440 | - } else { |
|
441 | - global $wpdb; |
|
442 | - $results = $wpdb->{$type}($query); |
|
443 | - } |
|
440 | + } else { |
|
441 | + global $wpdb; |
|
442 | + $results = $wpdb->{$type}($query); |
|
443 | + } |
|
444 | 444 | |
445 | 445 | self::set_cache( $cache_key, $results, $group, $time ); |
446 | 446 | |
@@ -473,44 +473,44 @@ discard block |
||
473 | 473 | return $cached; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Data that should be stored for a long time can be stored in a transient. |
|
478 | - * First check the cache, then check the transient |
|
479 | - * @since 2.0 |
|
480 | - * @return mixed The cached value or false |
|
481 | - */ |
|
476 | + /** |
|
477 | + * Data that should be stored for a long time can be stored in a transient. |
|
478 | + * First check the cache, then check the transient |
|
479 | + * @since 2.0 |
|
480 | + * @return mixed The cached value or false |
|
481 | + */ |
|
482 | 482 | public static function check_cache_and_transient( $cache_key ) { |
483 | - // check caching layer first |
|
484 | - $results = self::check_cache( $cache_key ); |
|
485 | - if ( $results ) { |
|
486 | - return $results; |
|
487 | - } |
|
488 | - |
|
489 | - // then check the transient |
|
490 | - $results = get_transient($cache_key); |
|
491 | - if ( $results ) { |
|
492 | - wp_cache_set($cache_key, $results); |
|
493 | - } |
|
494 | - |
|
495 | - return $results; |
|
496 | - } |
|
497 | - |
|
498 | - /** |
|
499 | - * @since 2.0 |
|
500 | - * @param string $cache_key |
|
501 | - */ |
|
483 | + // check caching layer first |
|
484 | + $results = self::check_cache( $cache_key ); |
|
485 | + if ( $results ) { |
|
486 | + return $results; |
|
487 | + } |
|
488 | + |
|
489 | + // then check the transient |
|
490 | + $results = get_transient($cache_key); |
|
491 | + if ( $results ) { |
|
492 | + wp_cache_set($cache_key, $results); |
|
493 | + } |
|
494 | + |
|
495 | + return $results; |
|
496 | + } |
|
497 | + |
|
498 | + /** |
|
499 | + * @since 2.0 |
|
500 | + * @param string $cache_key |
|
501 | + */ |
|
502 | 502 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
503 | 503 | delete_transient($cache_key); |
504 | 504 | wp_cache_delete( $cache_key, $group ); |
505 | 505 | } |
506 | 506 | |
507 | - /** |
|
508 | - * Delete all caching in a single group |
|
509 | - * |
|
510 | - * @since 2.0 |
|
511 | - * |
|
512 | - * @param string $group The name of the cache group |
|
513 | - */ |
|
507 | + /** |
|
508 | + * Delete all caching in a single group |
|
509 | + * |
|
510 | + * @since 2.0 |
|
511 | + * |
|
512 | + * @param string $group The name of the cache group |
|
513 | + */ |
|
514 | 514 | public static function cache_delete_group( $group ) { |
515 | 515 | $cached_keys = self::get_group_cached_keys( $group ); |
516 | 516 | |
@@ -523,34 +523,34 @@ discard block |
||
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
526 | - /** |
|
527 | - * Check a value from a shortcode to see if true or false. |
|
528 | - * True when value is 1, true, 'true', 'yes' |
|
529 | - * |
|
530 | - * @since 1.07.10 |
|
531 | - * |
|
532 | - * @param string $value The value to compare |
|
533 | - * @return boolean True or False |
|
534 | - */ |
|
526 | + /** |
|
527 | + * Check a value from a shortcode to see if true or false. |
|
528 | + * True when value is 1, true, 'true', 'yes' |
|
529 | + * |
|
530 | + * @since 1.07.10 |
|
531 | + * |
|
532 | + * @param string $value The value to compare |
|
533 | + * @return boolean True or False |
|
534 | + */ |
|
535 | 535 | public static function is_true( $value ) { |
536 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
537 | - } |
|
536 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
537 | + } |
|
538 | 538 | |
539 | - /** |
|
540 | - * Used to filter shortcode in text widgets |
|
541 | - */ |
|
542 | - public static function widget_text_filter_callback( $matches ) { |
|
543 | - return do_shortcode( $matches[0] ); |
|
544 | - } |
|
539 | + /** |
|
540 | + * Used to filter shortcode in text widgets |
|
541 | + */ |
|
542 | + public static function widget_text_filter_callback( $matches ) { |
|
543 | + return do_shortcode( $matches[0] ); |
|
544 | + } |
|
545 | 545 | |
546 | - public static function get_pages() { |
|
546 | + public static function get_pages() { |
|
547 | 547 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
548 | - } |
|
548 | + } |
|
549 | 549 | |
550 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
551 | - $pages = self::get_pages(); |
|
550 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
551 | + $pages = self::get_pages(); |
|
552 | 552 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
553 | - ?> |
|
553 | + ?> |
|
554 | 554 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
555 | 555 | <option value=""> </option> |
556 | 556 | <?php foreach ( $pages as $page ) { ?> |
@@ -560,108 +560,108 @@ discard block |
||
560 | 560 | <?php } ?> |
561 | 561 | </select> |
562 | 562 | <?php |
563 | - } |
|
563 | + } |
|
564 | 564 | |
565 | 565 | public static function post_edit_link( $post_id ) { |
566 | - $post = get_post($post_id); |
|
567 | - if ( $post ) { |
|
566 | + $post = get_post($post_id); |
|
567 | + if ( $post ) { |
|
568 | 568 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
569 | 569 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
570 | - } |
|
571 | - return ''; |
|
572 | - } |
|
570 | + } |
|
571 | + return ''; |
|
572 | + } |
|
573 | 573 | |
574 | 574 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
575 | - ?> |
|
575 | + ?> |
|
576 | 576 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
577 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
578 | - ?> class="frm_multiselect"> |
|
577 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
578 | + ?> class="frm_multiselect"> |
|
579 | 579 | <?php self::roles_options($capability); ?> |
580 | 580 | </select> |
581 | 581 | <?php |
582 | - } |
|
582 | + } |
|
583 | 583 | |
584 | 584 | public static function roles_options( $capability ) { |
585 | - global $frm_vars; |
|
586 | - if ( isset($frm_vars['editable_roles']) ) { |
|
587 | - $editable_roles = $frm_vars['editable_roles']; |
|
588 | - } else { |
|
589 | - $editable_roles = get_editable_roles(); |
|
590 | - $frm_vars['editable_roles'] = $editable_roles; |
|
591 | - } |
|
592 | - |
|
593 | - foreach ( $editable_roles as $role => $details ) { |
|
594 | - $name = translate_user_role($details['name'] ); ?> |
|
585 | + global $frm_vars; |
|
586 | + if ( isset($frm_vars['editable_roles']) ) { |
|
587 | + $editable_roles = $frm_vars['editable_roles']; |
|
588 | + } else { |
|
589 | + $editable_roles = get_editable_roles(); |
|
590 | + $frm_vars['editable_roles'] = $editable_roles; |
|
591 | + } |
|
592 | + |
|
593 | + foreach ( $editable_roles as $role => $details ) { |
|
594 | + $name = translate_user_role($details['name'] ); ?> |
|
595 | 595 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
596 | 596 | <?php |
597 | - unset($role, $details); |
|
598 | - } |
|
599 | - } |
|
597 | + unset($role, $details); |
|
598 | + } |
|
599 | + } |
|
600 | 600 | |
601 | 601 | public static function frm_capabilities( $type = 'auto' ) { |
602 | - $cap = array( |
|
603 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
604 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
605 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
606 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
607 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
608 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
609 | - ); |
|
602 | + $cap = array( |
|
603 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
604 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
605 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
606 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
607 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
608 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
609 | + ); |
|
610 | 610 | |
611 | 611 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
612 | - return $cap; |
|
613 | - } |
|
612 | + return $cap; |
|
613 | + } |
|
614 | 614 | |
615 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
616 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
617 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
618 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
615 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
616 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
617 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
618 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
619 | 619 | |
620 | - return $cap; |
|
621 | - } |
|
620 | + return $cap; |
|
621 | + } |
|
622 | 622 | |
623 | 623 | public static function user_has_permission( $needed_role ) { |
624 | - if ( $needed_role == '-1' ) { |
|
625 | - return false; |
|
624 | + if ( $needed_role == '-1' ) { |
|
625 | + return false; |
|
626 | 626 | } |
627 | 627 | |
628 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
629 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
630 | - return true; |
|
631 | - } |
|
628 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
629 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
630 | + return true; |
|
631 | + } |
|
632 | 632 | |
633 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
634 | - foreach ( $roles as $role ) { |
|
633 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
634 | + foreach ( $roles as $role ) { |
|
635 | 635 | if ( current_user_can( $role ) ) { |
636 | - return true; |
|
636 | + return true; |
|
637 | 637 | } |
638 | - if ( $role == $needed_role ) { |
|
639 | - break; |
|
638 | + if ( $role == $needed_role ) { |
|
639 | + break; |
|
640 | 640 | } |
641 | - } |
|
642 | - return false; |
|
643 | - } |
|
644 | - |
|
645 | - /** |
|
646 | - * Make sure administrators can see Formidable menu |
|
647 | - * |
|
648 | - * @since 2.0 |
|
649 | - */ |
|
650 | - public static function maybe_add_permissions() { |
|
641 | + } |
|
642 | + return false; |
|
643 | + } |
|
644 | + |
|
645 | + /** |
|
646 | + * Make sure administrators can see Formidable menu |
|
647 | + * |
|
648 | + * @since 2.0 |
|
649 | + */ |
|
650 | + public static function maybe_add_permissions() { |
|
651 | 651 | self::force_capability( 'frm_view_entries' ); |
652 | 652 | |
653 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
654 | - return; |
|
655 | - } |
|
653 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
654 | + return; |
|
655 | + } |
|
656 | 656 | |
657 | 657 | $user_id = get_current_user_id(); |
658 | 658 | $user = new WP_User( $user_id ); |
659 | - $frm_roles = self::frm_capabilities(); |
|
660 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
659 | + $frm_roles = self::frm_capabilities(); |
|
660 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
661 | 661 | $user->add_cap( $frm_role ); |
662 | - unset($frm_role, $frm_role_description); |
|
663 | - } |
|
664 | - } |
|
662 | + unset($frm_role, $frm_role_description); |
|
663 | + } |
|
664 | + } |
|
665 | 665 | |
666 | 666 | /** |
667 | 667 | * Make sure admins have permission to see the menu items |
@@ -677,28 +677,28 @@ discard block |
||
677 | 677 | } |
678 | 678 | } |
679 | 679 | |
680 | - /** |
|
681 | - * Check if the user has permision for action. |
|
682 | - * Return permission message and stop the action if no permission |
|
683 | - * @since 2.0 |
|
684 | - * @param string $permission |
|
685 | - */ |
|
680 | + /** |
|
681 | + * Check if the user has permision for action. |
|
682 | + * Return permission message and stop the action if no permission |
|
683 | + * @since 2.0 |
|
684 | + * @param string $permission |
|
685 | + */ |
|
686 | 686 | public static function permission_check( $permission, $show_message = 'show' ) { |
687 | - $permission_error = self::permission_nonce_error($permission); |
|
688 | - if ( $permission_error !== false ) { |
|
689 | - if ( 'hide' == $show_message ) { |
|
690 | - $permission_error = ''; |
|
691 | - } |
|
692 | - wp_die($permission_error); |
|
693 | - } |
|
694 | - } |
|
695 | - |
|
696 | - /** |
|
697 | - * Check user permission and nonce |
|
698 | - * @since 2.0 |
|
699 | - * @param string $permission |
|
700 | - * @return false|string The permission message or false if allowed |
|
701 | - */ |
|
687 | + $permission_error = self::permission_nonce_error($permission); |
|
688 | + if ( $permission_error !== false ) { |
|
689 | + if ( 'hide' == $show_message ) { |
|
690 | + $permission_error = ''; |
|
691 | + } |
|
692 | + wp_die($permission_error); |
|
693 | + } |
|
694 | + } |
|
695 | + |
|
696 | + /** |
|
697 | + * Check user permission and nonce |
|
698 | + * @since 2.0 |
|
699 | + * @param string $permission |
|
700 | + * @return false|string The permission message or false if allowed |
|
701 | + */ |
|
702 | 702 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
703 | 703 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
704 | 704 | $frm_settings = self::get_settings(); |
@@ -706,23 +706,23 @@ discard block |
||
706 | 706 | } |
707 | 707 | |
708 | 708 | $error = false; |
709 | - if ( empty($nonce_name) ) { |
|
710 | - return $error; |
|
711 | - } |
|
709 | + if ( empty($nonce_name) ) { |
|
710 | + return $error; |
|
711 | + } |
|
712 | 712 | |
713 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
714 | - $frm_settings = self::get_settings(); |
|
715 | - $error = $frm_settings->admin_permission; |
|
716 | - } |
|
713 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
714 | + $frm_settings = self::get_settings(); |
|
715 | + $error = $frm_settings->admin_permission; |
|
716 | + } |
|
717 | 717 | |
718 | - return $error; |
|
719 | - } |
|
718 | + return $error; |
|
719 | + } |
|
720 | 720 | |
721 | - public static function checked( $values, $current ) { |
|
721 | + public static function checked( $values, $current ) { |
|
722 | 722 | if ( self::check_selected( $values, $current ) ) { |
723 | - echo ' checked="checked"'; |
|
723 | + echo ' checked="checked"'; |
|
724 | 724 | } |
725 | - } |
|
725 | + } |
|
726 | 726 | |
727 | 727 | public static function check_selected( $values, $current ) { |
728 | 728 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -732,50 +732,50 @@ discard block |
||
732 | 732 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
733 | 733 | } |
734 | 734 | |
735 | - /** |
|
736 | - * Check if current field option is an "other" option |
|
737 | - * |
|
738 | - * @since 2.0 |
|
739 | - * |
|
740 | - * @param string $opt_key |
|
741 | - * @return boolean Returns true if current field option is an "Other" option |
|
742 | - */ |
|
743 | - public static function is_other_opt( $opt_key ) { |
|
744 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
745 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
746 | - } |
|
747 | - |
|
748 | - /** |
|
749 | - * Get value that belongs in "Other" text box |
|
750 | - * |
|
751 | - * @since 2.0 |
|
752 | - * |
|
753 | - * @param string $opt_key |
|
754 | - * @param array $field |
|
755 | - * @return string $other_val |
|
756 | - */ |
|
757 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
735 | + /** |
|
736 | + * Check if current field option is an "other" option |
|
737 | + * |
|
738 | + * @since 2.0 |
|
739 | + * |
|
740 | + * @param string $opt_key |
|
741 | + * @return boolean Returns true if current field option is an "Other" option |
|
742 | + */ |
|
743 | + public static function is_other_opt( $opt_key ) { |
|
744 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
745 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
746 | + } |
|
747 | + |
|
748 | + /** |
|
749 | + * Get value that belongs in "Other" text box |
|
750 | + * |
|
751 | + * @since 2.0 |
|
752 | + * |
|
753 | + * @param string $opt_key |
|
754 | + * @param array $field |
|
755 | + * @return string $other_val |
|
756 | + */ |
|
757 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
758 | 758 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
759 | 759 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
760 | - } |
|
761 | - |
|
762 | - /** |
|
763 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
764 | - * Intended for front-end use |
|
765 | - * |
|
766 | - * @since 2.0 |
|
767 | - * |
|
768 | - * @param array $field |
|
769 | - * @param boolean $other_opt |
|
770 | - * @param string $checked |
|
771 | - * @param array $args should include opt_key and field name |
|
772 | - * @return string $other_val |
|
773 | - */ |
|
774 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
760 | + } |
|
761 | + |
|
762 | + /** |
|
763 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
764 | + * Intended for front-end use |
|
765 | + * |
|
766 | + * @since 2.0 |
|
767 | + * |
|
768 | + * @param array $field |
|
769 | + * @param boolean $other_opt |
|
770 | + * @param string $checked |
|
771 | + * @param array $args should include opt_key and field name |
|
772 | + * @return string $other_val |
|
773 | + */ |
|
774 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
775 | 775 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
776 | 776 | $args['field'] = $field; |
777 | 777 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
778 | - } |
|
778 | + } |
|
779 | 779 | |
780 | 780 | public static function recursive_function_map( $value, $function ) { |
781 | 781 | if ( is_array( $value ) ) { |
@@ -805,24 +805,24 @@ discard block |
||
805 | 805 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
806 | 806 | } |
807 | 807 | |
808 | - /** |
|
809 | - * Flatten a multi-dimensional array |
|
810 | - */ |
|
808 | + /** |
|
809 | + * Flatten a multi-dimensional array |
|
810 | + */ |
|
811 | 811 | public static function array_flatten( $array, $keys = 'keep' ) { |
812 | - $return = array(); |
|
813 | - foreach ( $array as $key => $value ) { |
|
814 | - if ( is_array($value) ) { |
|
812 | + $return = array(); |
|
813 | + foreach ( $array as $key => $value ) { |
|
814 | + if ( is_array($value) ) { |
|
815 | 815 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
816 | - } else { |
|
816 | + } else { |
|
817 | 817 | if ( $keys == 'keep' ) { |
818 | 818 | $return[ $key ] = $value; |
819 | 819 | } else { |
820 | 820 | $return[] = $value; |
821 | 821 | } |
822 | - } |
|
823 | - } |
|
824 | - return $return; |
|
825 | - } |
|
822 | + } |
|
823 | + } |
|
824 | + return $return; |
|
825 | + } |
|
826 | 826 | |
827 | 827 | public static function esc_textarea( $text, $is_rich_text = false ) { |
828 | 828 | $safe_text = str_replace( '"', '"', $text ); |
@@ -833,38 +833,38 @@ discard block |
||
833 | 833 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
834 | 834 | } |
835 | 835 | |
836 | - /** |
|
837 | - * Add auto paragraphs to text areas |
|
838 | - * @since 2.0 |
|
839 | - */ |
|
836 | + /** |
|
837 | + * Add auto paragraphs to text areas |
|
838 | + * @since 2.0 |
|
839 | + */ |
|
840 | 840 | public static function use_wpautop( $content ) { |
841 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
842 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
843 | - } |
|
844 | - return $content; |
|
845 | - } |
|
841 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
842 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
843 | + } |
|
844 | + return $content; |
|
845 | + } |
|
846 | 846 | |
847 | 847 | public static function replace_quotes( $val ) { |
848 | - //Replace double quotes |
|
848 | + //Replace double quotes |
|
849 | 849 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
850 | - //Replace single quotes |
|
851 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
852 | - return $val; |
|
853 | - } |
|
854 | - |
|
855 | - /** |
|
856 | - * @since 2.0 |
|
857 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
858 | - */ |
|
859 | - public static function jquery_ui_base_url() { |
|
850 | + //Replace single quotes |
|
851 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
852 | + return $val; |
|
853 | + } |
|
854 | + |
|
855 | + /** |
|
856 | + * @since 2.0 |
|
857 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
858 | + */ |
|
859 | + public static function jquery_ui_base_url() { |
|
860 | 860 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
861 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
862 | - return $url; |
|
863 | - } |
|
861 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
862 | + return $url; |
|
863 | + } |
|
864 | 864 | |
865 | - /** |
|
866 | - * @param string $handle |
|
867 | - */ |
|
865 | + /** |
|
866 | + * @param string $handle |
|
867 | + */ |
|
868 | 868 | public static function script_version( $handle, $default = 0 ) { |
869 | 869 | global $wp_scripts; |
870 | 870 | if ( ! $wp_scripts ) { |
@@ -886,241 +886,241 @@ discard block |
||
886 | 886 | |
887 | 887 | public static function js_redirect( $url ) { |
888 | 888 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
889 | - } |
|
889 | + } |
|
890 | 890 | |
891 | 891 | public static function get_user_id_param( $user_id ) { |
892 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
893 | - return $user_id; |
|
894 | - } |
|
892 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
893 | + return $user_id; |
|
894 | + } |
|
895 | 895 | |
896 | 896 | if ( $user_id == 'current' ) { |
897 | 897 | $user_id = get_current_user_id(); |
898 | 898 | } else { |
899 | - if ( is_email($user_id) ) { |
|
900 | - $user = get_user_by('email', $user_id); |
|
901 | - } else { |
|
902 | - $user = get_user_by('login', $user_id); |
|
903 | - } |
|
899 | + if ( is_email($user_id) ) { |
|
900 | + $user = get_user_by('email', $user_id); |
|
901 | + } else { |
|
902 | + $user = get_user_by('login', $user_id); |
|
903 | + } |
|
904 | 904 | |
905 | - if ( $user ) { |
|
906 | - $user_id = $user->ID; |
|
907 | - } |
|
908 | - unset($user); |
|
909 | - } |
|
905 | + if ( $user ) { |
|
906 | + $user_id = $user->ID; |
|
907 | + } |
|
908 | + unset($user); |
|
909 | + } |
|
910 | 910 | |
911 | - return $user_id; |
|
912 | - } |
|
911 | + return $user_id; |
|
912 | + } |
|
913 | 913 | |
914 | 914 | public static function get_file_contents( $filename, $atts = array() ) { |
915 | - if ( ! is_file($filename) ) { |
|
916 | - return false; |
|
917 | - } |
|
918 | - |
|
919 | - extract($atts); |
|
920 | - ob_start(); |
|
921 | - include($filename); |
|
922 | - $contents = ob_get_contents(); |
|
923 | - ob_end_clean(); |
|
924 | - return $contents; |
|
925 | - } |
|
926 | - |
|
927 | - /** |
|
928 | - * @param string $table_name |
|
929 | - * @param string $column |
|
915 | + if ( ! is_file($filename) ) { |
|
916 | + return false; |
|
917 | + } |
|
918 | + |
|
919 | + extract($atts); |
|
920 | + ob_start(); |
|
921 | + include($filename); |
|
922 | + $contents = ob_get_contents(); |
|
923 | + ob_end_clean(); |
|
924 | + return $contents; |
|
925 | + } |
|
926 | + |
|
927 | + /** |
|
928 | + * @param string $table_name |
|
929 | + * @param string $column |
|
930 | 930 | * @param int $id |
931 | 931 | * @param int $num_chars |
932 | - */ |
|
933 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
934 | - $key = ''; |
|
932 | + */ |
|
933 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
934 | + $key = ''; |
|
935 | 935 | |
936 | - if ( ! empty( $name ) ) { |
|
937 | - $key = sanitize_key($name); |
|
938 | - } |
|
936 | + if ( ! empty( $name ) ) { |
|
937 | + $key = sanitize_key($name); |
|
938 | + } |
|
939 | 939 | |
940 | 940 | if ( empty( $key ) ) { |
941 | - $max_slug_value = pow(36, $num_chars); |
|
942 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
943 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
944 | - } |
|
941 | + $max_slug_value = pow(36, $num_chars); |
|
942 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
943 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
944 | + } |
|
945 | 945 | |
946 | 946 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
947 | 947 | $key = $key . 'a'; |
948 | - } |
|
948 | + } |
|
949 | 949 | |
950 | 950 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
951 | 951 | |
952 | - if ( $key_check || is_numeric($key_check) ) { |
|
953 | - $suffix = 2; |
|
952 | + if ( $key_check || is_numeric($key_check) ) { |
|
953 | + $suffix = 2; |
|
954 | 954 | do { |
955 | 955 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
956 | 956 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
957 | 957 | $suffix++; |
958 | 958 | } while ( $key_check || is_numeric( $key_check ) ); |
959 | 959 | $key = $alt_post_name; |
960 | - } |
|
961 | - return $key; |
|
962 | - } |
|
963 | - |
|
964 | - /** |
|
965 | - * Editing a Form or Entry |
|
966 | - * @param string $table |
|
967 | - * @return bool|array |
|
968 | - */ |
|
969 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
970 | - if ( ! $record ) { |
|
971 | - return false; |
|
972 | - } |
|
973 | - |
|
974 | - if ( empty($post_values) ) { |
|
975 | - $post_values = stripslashes_deep($_POST); |
|
976 | - } |
|
960 | + } |
|
961 | + return $key; |
|
962 | + } |
|
963 | + |
|
964 | + /** |
|
965 | + * Editing a Form or Entry |
|
966 | + * @param string $table |
|
967 | + * @return bool|array |
|
968 | + */ |
|
969 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
970 | + if ( ! $record ) { |
|
971 | + return false; |
|
972 | + } |
|
973 | + |
|
974 | + if ( empty($post_values) ) { |
|
975 | + $post_values = stripslashes_deep($_POST); |
|
976 | + } |
|
977 | 977 | |
978 | 978 | $values = array( 'id' => $record->id, 'fields' => array() ); |
979 | 979 | |
980 | 980 | foreach ( array( 'name', 'description' ) as $var ) { |
981 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
981 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
982 | 982 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
983 | - unset($var, $default_val); |
|
984 | - } |
|
985 | - |
|
986 | - $values['description'] = self::use_wpautop($values['description']); |
|
987 | - $frm_settings = self::get_settings(); |
|
988 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
989 | - |
|
990 | - foreach ( (array) $fields as $field ) { |
|
991 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
992 | - if ( ! $is_form_builder ) { |
|
993 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
994 | - } |
|
983 | + unset($var, $default_val); |
|
984 | + } |
|
985 | + |
|
986 | + $values['description'] = self::use_wpautop($values['description']); |
|
987 | + $frm_settings = self::get_settings(); |
|
988 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
989 | + |
|
990 | + foreach ( (array) $fields as $field ) { |
|
991 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
992 | + if ( ! $is_form_builder ) { |
|
993 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
994 | + } |
|
995 | 995 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
996 | 996 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
999 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
1000 | 1000 | |
1001 | - if ( $table == 'entries' ) { |
|
1002 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1003 | - } else if ( $table == 'forms' ) { |
|
1004 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1005 | - } |
|
1001 | + if ( $table == 'entries' ) { |
|
1002 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1003 | + } else if ( $table == 'forms' ) { |
|
1004 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1005 | + } |
|
1006 | 1006 | |
1007 | - return $values; |
|
1008 | - } |
|
1007 | + return $values; |
|
1008 | + } |
|
1009 | 1009 | |
1010 | 1010 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
1011 | - $post_values = $args['post_values']; |
|
1012 | - |
|
1013 | - if ( $args['default'] ) { |
|
1014 | - $meta_value = $field->default_value; |
|
1015 | - } else { |
|
1016 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1017 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1018 | - $field->field_options['custom_field'] = ''; |
|
1019 | - } |
|
1011 | + $post_values = $args['post_values']; |
|
1012 | + |
|
1013 | + if ( $args['default'] ) { |
|
1014 | + $meta_value = $field->default_value; |
|
1015 | + } else { |
|
1016 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1017 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
1018 | + $field->field_options['custom_field'] = ''; |
|
1019 | + } |
|
1020 | 1020 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
1021 | - } else { |
|
1021 | + } else { |
|
1022 | 1022 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
1023 | - } |
|
1024 | - } |
|
1023 | + } |
|
1024 | + } |
|
1025 | 1025 | |
1026 | 1026 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
1027 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1028 | - |
|
1029 | - $field_array = array( |
|
1030 | - 'id' => $field->id, |
|
1031 | - 'value' => $new_value, |
|
1032 | - 'default_value' => $field->default_value, |
|
1033 | - 'name' => $field->name, |
|
1034 | - 'description' => $field->description, |
|
1035 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1036 | - 'options' => $field->options, |
|
1037 | - 'required' => $field->required, |
|
1038 | - 'field_key' => $field->field_key, |
|
1039 | - 'field_order' => $field->field_order, |
|
1040 | - 'form_id' => $field->form_id, |
|
1027 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1028 | + |
|
1029 | + $field_array = array( |
|
1030 | + 'id' => $field->id, |
|
1031 | + 'value' => $new_value, |
|
1032 | + 'default_value' => $field->default_value, |
|
1033 | + 'name' => $field->name, |
|
1034 | + 'description' => $field->description, |
|
1035 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1036 | + 'options' => $field->options, |
|
1037 | + 'required' => $field->required, |
|
1038 | + 'field_key' => $field->field_key, |
|
1039 | + 'field_order' => $field->field_order, |
|
1040 | + 'form_id' => $field->form_id, |
|
1041 | 1041 | 'parent_form_id' => $args['parent_form_id'], |
1042 | - ); |
|
1042 | + ); |
|
1043 | 1043 | |
1044 | - $args['field_type'] = $field_type; |
|
1045 | - self::fill_field_opts($field, $field_array, $args); |
|
1044 | + $args['field_type'] = $field_type; |
|
1045 | + self::fill_field_opts($field, $field_array, $args); |
|
1046 | 1046 | // Track the original field's type |
1047 | 1047 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1048 | 1048 | |
1049 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1049 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1050 | 1050 | |
1051 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1052 | - $field_array['unique_msg'] = ''; |
|
1053 | - } |
|
1051 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1052 | + $field_array['unique_msg'] = ''; |
|
1053 | + } |
|
1054 | 1054 | |
1055 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1055 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1056 | 1056 | |
1057 | - $values['fields'][ $field->id ] = $field_array; |
|
1058 | - } |
|
1057 | + $values['fields'][ $field->id ] = $field_array; |
|
1058 | + } |
|
1059 | 1059 | |
1060 | 1060 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1061 | - $post_values = $args['post_values']; |
|
1062 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1061 | + $post_values = $args['post_values']; |
|
1062 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1063 | 1063 | |
1064 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1064 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1065 | 1065 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
1066 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1067 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1068 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1069 | - if ( $args['field_type'] == 'captcha' ) { |
|
1070 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1071 | - } else { |
|
1072 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1073 | - } |
|
1074 | - } |
|
1075 | - } |
|
1076 | - |
|
1077 | - if ( $field_array['custom_html'] == '' ) { |
|
1078 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1079 | - } |
|
1080 | - } |
|
1081 | - |
|
1082 | - /** |
|
1083 | - * @param string $table |
|
1084 | - */ |
|
1066 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1067 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1068 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1069 | + if ( $args['field_type'] == 'captcha' ) { |
|
1070 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1071 | + } else { |
|
1072 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1073 | + } |
|
1074 | + } |
|
1075 | + } |
|
1076 | + |
|
1077 | + if ( $field_array['custom_html'] == '' ) { |
|
1078 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1079 | + } |
|
1080 | + } |
|
1081 | + |
|
1082 | + /** |
|
1083 | + * @param string $table |
|
1084 | + */ |
|
1085 | 1085 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1086 | - if ( $table == 'entries' ) { |
|
1087 | - $form = $record->form_id; |
|
1086 | + if ( $table == 'entries' ) { |
|
1087 | + $form = $record->form_id; |
|
1088 | 1088 | FrmForm::maybe_get_form( $form ); |
1089 | - } else { |
|
1090 | - $form = $record; |
|
1091 | - } |
|
1089 | + } else { |
|
1090 | + $form = $record; |
|
1091 | + } |
|
1092 | 1092 | |
1093 | - if ( ! $form ) { |
|
1094 | - return; |
|
1095 | - } |
|
1093 | + if ( ! $form ) { |
|
1094 | + return; |
|
1095 | + } |
|
1096 | 1096 | |
1097 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1097 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1098 | 1098 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1099 | 1099 | |
1100 | - if ( ! is_array($form->options) ) { |
|
1101 | - return; |
|
1102 | - } |
|
1100 | + if ( ! is_array($form->options) ) { |
|
1101 | + return; |
|
1102 | + } |
|
1103 | 1103 | |
1104 | - foreach ( $form->options as $opt => $value ) { |
|
1105 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1106 | - } |
|
1104 | + foreach ( $form->options as $opt => $value ) { |
|
1105 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1106 | + } |
|
1107 | 1107 | |
1108 | - self::fill_form_defaults($post_values, $values); |
|
1109 | - } |
|
1108 | + self::fill_form_defaults($post_values, $values); |
|
1109 | + } |
|
1110 | 1110 | |
1111 | - /** |
|
1112 | - * Set to POST value or default |
|
1113 | - */ |
|
1111 | + /** |
|
1112 | + * Set to POST value or default |
|
1113 | + */ |
|
1114 | 1114 | private static function fill_form_defaults( $post_values, array &$values ) { |
1115 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1115 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1116 | 1116 | |
1117 | - foreach ( $form_defaults as $opt => $default ) { |
|
1118 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1117 | + foreach ( $form_defaults as $opt => $default ) { |
|
1118 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1119 | 1119 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1120 | - } |
|
1120 | + } |
|
1121 | 1121 | |
1122 | - unset($opt, $defaut); |
|
1123 | - } |
|
1122 | + unset($opt, $defaut); |
|
1123 | + } |
|
1124 | 1124 | |
1125 | 1125 | if ( ! isset( $values['custom_style'] ) ) { |
1126 | 1126 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1129,10 +1129,10 @@ discard block |
||
1129 | 1129 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1130 | 1130 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
1131 | 1131 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
1132 | - } |
|
1133 | - unset($h); |
|
1134 | - } |
|
1135 | - } |
|
1132 | + } |
|
1133 | + unset($h); |
|
1134 | + } |
|
1135 | + } |
|
1136 | 1136 | |
1137 | 1137 | /** |
1138 | 1138 | * @since 2.2.10 |
@@ -1155,59 +1155,59 @@ discard block |
||
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | public static function insert_opt_html( $args ) { |
1158 | - $class = ''; |
|
1159 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1160 | - $class .= 'show_frm_not_email_to'; |
|
1161 | - } |
|
1162 | - ?> |
|
1158 | + $class = ''; |
|
1159 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1160 | + $class .= 'show_frm_not_email_to'; |
|
1161 | + } |
|
1162 | + ?> |
|
1163 | 1163 | <li> |
1164 | 1164 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
1165 | 1165 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
1166 | 1166 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
1167 | 1167 | </li> |
1168 | 1168 | <?php |
1169 | - } |
|
1169 | + } |
|
1170 | 1170 | |
1171 | 1171 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1172 | - if ( is_array( $str ) ) { |
|
1173 | - return ''; |
|
1172 | + if ( is_array( $str ) ) { |
|
1173 | + return ''; |
|
1174 | 1174 | } |
1175 | 1175 | |
1176 | - $length = (int) $length; |
|
1176 | + $length = (int) $length; |
|
1177 | 1177 | $str = wp_strip_all_tags( $str ); |
1178 | 1178 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1179 | 1179 | |
1180 | 1180 | if ( $length == 0 ) { |
1181 | - return ''; |
|
1182 | - } else if ( $length <= 10 ) { |
|
1181 | + return ''; |
|
1182 | + } else if ( $length <= 10 ) { |
|
1183 | 1183 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1184 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1185 | - } |
|
1184 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1185 | + } |
|
1186 | 1186 | |
1187 | - $sub = ''; |
|
1188 | - $len = 0; |
|
1187 | + $sub = ''; |
|
1188 | + $len = 0; |
|
1189 | 1189 | |
1190 | 1190 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1191 | 1191 | |
1192 | 1192 | foreach ( $words as $word ) { |
1193 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1193 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1194 | 1194 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1195 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1196 | - break; |
|
1197 | - } |
|
1195 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1196 | + break; |
|
1197 | + } |
|
1198 | 1198 | |
1199 | - $sub .= $part; |
|
1199 | + $sub .= $part; |
|
1200 | 1200 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1201 | 1201 | |
1202 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1203 | - break; |
|
1204 | - } |
|
1202 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1203 | + break; |
|
1204 | + } |
|
1205 | 1205 | |
1206 | - unset($total_len, $word); |
|
1207 | - } |
|
1206 | + unset($total_len, $word); |
|
1207 | + } |
|
1208 | 1208 | |
1209 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1210 | - } |
|
1209 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1210 | + } |
|
1211 | 1211 | |
1212 | 1212 | public static function mb_function( $function_names, $args ) { |
1213 | 1213 | $mb_function_name = $function_names[0]; |
@@ -1219,18 +1219,18 @@ discard block |
||
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1222 | - if ( empty($date) ) { |
|
1223 | - return $date; |
|
1224 | - } |
|
1222 | + if ( empty($date) ) { |
|
1223 | + return $date; |
|
1224 | + } |
|
1225 | 1225 | |
1226 | - if ( empty($date_format) ) { |
|
1227 | - $date_format = get_option('date_format'); |
|
1228 | - } |
|
1226 | + if ( empty($date_format) ) { |
|
1227 | + $date_format = get_option('date_format'); |
|
1228 | + } |
|
1229 | 1229 | |
1230 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1231 | - $frmpro_settings = new FrmProSettings(); |
|
1232 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1233 | - } |
|
1230 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1231 | + $frmpro_settings = new FrmProSettings(); |
|
1232 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1233 | + } |
|
1234 | 1234 | |
1235 | 1235 | $formatted = self::get_localized_date( $date_format, $date ); |
1236 | 1236 | |
@@ -1239,8 +1239,8 @@ discard block |
||
1239 | 1239 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1240 | 1240 | } |
1241 | 1241 | |
1242 | - return $formatted; |
|
1243 | - } |
|
1242 | + return $formatted; |
|
1243 | + } |
|
1244 | 1244 | |
1245 | 1245 | private static function add_time_to_date( $time_format, $date ) { |
1246 | 1246 | if ( empty( $time_format ) ) { |
@@ -1322,61 +1322,61 @@ discard block |
||
1322 | 1322 | ); |
1323 | 1323 | } |
1324 | 1324 | |
1325 | - /** |
|
1326 | - * Added for < WP 4.0 compatability |
|
1327 | - * |
|
1328 | - * @since 1.07.10 |
|
1329 | - * |
|
1330 | - * @param string $term The value to escape |
|
1331 | - * @return string The escaped value |
|
1332 | - */ |
|
1325 | + /** |
|
1326 | + * Added for < WP 4.0 compatability |
|
1327 | + * |
|
1328 | + * @since 1.07.10 |
|
1329 | + * |
|
1330 | + * @param string $term The value to escape |
|
1331 | + * @return string The escaped value |
|
1332 | + */ |
|
1333 | 1333 | public static function esc_like( $term ) { |
1334 | - global $wpdb; |
|
1335 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1334 | + global $wpdb; |
|
1335 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1336 | 1336 | // WP 4.0 |
1337 | - $term = $wpdb->esc_like( $term ); |
|
1338 | - } else { |
|
1339 | - $term = like_escape( $term ); |
|
1340 | - } |
|
1337 | + $term = $wpdb->esc_like( $term ); |
|
1338 | + } else { |
|
1339 | + $term = like_escape( $term ); |
|
1340 | + } |
|
1341 | 1341 | |
1342 | - return $term; |
|
1343 | - } |
|
1342 | + return $term; |
|
1343 | + } |
|
1344 | 1344 | |
1345 | - /** |
|
1346 | - * @param string $order_query |
|
1347 | - */ |
|
1345 | + /** |
|
1346 | + * @param string $order_query |
|
1347 | + */ |
|
1348 | 1348 | public static function esc_order( $order_query ) { |
1349 | - if ( empty($order_query) ) { |
|
1350 | - return ''; |
|
1351 | - } |
|
1352 | - |
|
1353 | - // remove ORDER BY before santizing |
|
1354 | - $order_query = strtolower($order_query); |
|
1355 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1356 | - $order_query = str_replace('order by', '', $order_query); |
|
1357 | - } |
|
1358 | - |
|
1359 | - $order_query = explode(' ', trim($order_query)); |
|
1360 | - |
|
1361 | - $order_fields = array( |
|
1362 | - 'id', 'form_key', 'name', 'description', |
|
1363 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1364 | - 'default_template', 'status', 'created_at', |
|
1365 | - ); |
|
1366 | - |
|
1367 | - $order = trim(trim(reset($order_query), ',')); |
|
1368 | - if ( ! in_array($order, $order_fields) ) { |
|
1369 | - return ''; |
|
1370 | - } |
|
1371 | - |
|
1372 | - $order_by = ''; |
|
1373 | - if ( count($order_query) > 1 ) { |
|
1349 | + if ( empty($order_query) ) { |
|
1350 | + return ''; |
|
1351 | + } |
|
1352 | + |
|
1353 | + // remove ORDER BY before santizing |
|
1354 | + $order_query = strtolower($order_query); |
|
1355 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1356 | + $order_query = str_replace('order by', '', $order_query); |
|
1357 | + } |
|
1358 | + |
|
1359 | + $order_query = explode(' ', trim($order_query)); |
|
1360 | + |
|
1361 | + $order_fields = array( |
|
1362 | + 'id', 'form_key', 'name', 'description', |
|
1363 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1364 | + 'default_template', 'status', 'created_at', |
|
1365 | + ); |
|
1366 | + |
|
1367 | + $order = trim(trim(reset($order_query), ',')); |
|
1368 | + if ( ! in_array($order, $order_fields) ) { |
|
1369 | + return ''; |
|
1370 | + } |
|
1371 | + |
|
1372 | + $order_by = ''; |
|
1373 | + if ( count($order_query) > 1 ) { |
|
1374 | 1374 | $order_by = end( $order_query ); |
1375 | 1375 | self::esc_order_by( $order_by ); |
1376 | - } |
|
1376 | + } |
|
1377 | 1377 | |
1378 | 1378 | return ' ORDER BY ' . $order . ' ' . $order_by; |
1379 | - } |
|
1379 | + } |
|
1380 | 1380 | |
1381 | 1381 | /** |
1382 | 1382 | * Make sure this is ordering by either ASC or DESC |
@@ -1388,169 +1388,169 @@ discard block |
||
1388 | 1388 | } |
1389 | 1389 | } |
1390 | 1390 | |
1391 | - /** |
|
1392 | - * @param string $limit |
|
1393 | - */ |
|
1391 | + /** |
|
1392 | + * @param string $limit |
|
1393 | + */ |
|
1394 | 1394 | public static function esc_limit( $limit ) { |
1395 | - if ( empty($limit) ) { |
|
1396 | - return ''; |
|
1397 | - } |
|
1395 | + if ( empty($limit) ) { |
|
1396 | + return ''; |
|
1397 | + } |
|
1398 | 1398 | |
1399 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1400 | - if ( is_numeric($limit) ) { |
|
1399 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1400 | + if ( is_numeric($limit) ) { |
|
1401 | 1401 | return ' LIMIT ' . $limit; |
1402 | - } |
|
1402 | + } |
|
1403 | 1403 | |
1404 | - $limit = explode(',', trim($limit)); |
|
1405 | - foreach ( $limit as $k => $l ) { |
|
1406 | - if ( is_numeric( $l ) ) { |
|
1407 | - $limit[ $k ] = $l; |
|
1408 | - } |
|
1409 | - } |
|
1404 | + $limit = explode(',', trim($limit)); |
|
1405 | + foreach ( $limit as $k => $l ) { |
|
1406 | + if ( is_numeric( $l ) ) { |
|
1407 | + $limit[ $k ] = $l; |
|
1408 | + } |
|
1409 | + } |
|
1410 | 1410 | |
1411 | - $limit = implode(',', $limit); |
|
1411 | + $limit = implode(',', $limit); |
|
1412 | 1412 | return ' LIMIT ' . $limit; |
1413 | - } |
|
1414 | - |
|
1415 | - /** |
|
1416 | - * Get an array of values ready to go through $wpdb->prepare |
|
1417 | - * @since 2.0 |
|
1418 | - */ |
|
1419 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1420 | - $placeholders = array_fill(0, count($array), $type); |
|
1421 | - return implode(', ', $placeholders); |
|
1422 | - } |
|
1423 | - |
|
1424 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1425 | - if ( empty($where) ) { |
|
1426 | - return ''; |
|
1427 | - } |
|
1413 | + } |
|
1414 | + |
|
1415 | + /** |
|
1416 | + * Get an array of values ready to go through $wpdb->prepare |
|
1417 | + * @since 2.0 |
|
1418 | + */ |
|
1419 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1420 | + $placeholders = array_fill(0, count($array), $type); |
|
1421 | + return implode(', ', $placeholders); |
|
1422 | + } |
|
1423 | + |
|
1424 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1425 | + if ( empty($where) ) { |
|
1426 | + return ''; |
|
1427 | + } |
|
1428 | 1428 | |
1429 | 1429 | if ( is_array( $where ) ) { |
1430 | - global $wpdb; |
|
1431 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1430 | + global $wpdb; |
|
1431 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1432 | 1432 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1433 | 1433 | } else { |
1434 | - $where = $starts_with . $where; |
|
1435 | - } |
|
1434 | + $where = $starts_with . $where; |
|
1435 | + } |
|
1436 | 1436 | |
1437 | - return $where; |
|
1438 | - } |
|
1437 | + return $where; |
|
1438 | + } |
|
1439 | 1439 | |
1440 | - // Pagination Methods |
|
1440 | + // Pagination Methods |
|
1441 | 1441 | |
1442 | - /** |
|
1443 | - * @param integer $current_p |
|
1444 | - */ |
|
1442 | + /** |
|
1443 | + * @param integer $current_p |
|
1444 | + */ |
|
1445 | 1445 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1446 | 1446 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1447 | 1447 | } |
1448 | 1448 | |
1449 | - /** |
|
1450 | - * @param integer $current_p |
|
1451 | - */ |
|
1452 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1453 | - if ( $current_p == 1 ) { |
|
1454 | - return 1; |
|
1455 | - } else { |
|
1456 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1457 | - } |
|
1458 | - } |
|
1449 | + /** |
|
1450 | + * @param integer $current_p |
|
1451 | + */ |
|
1452 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1453 | + if ( $current_p == 1 ) { |
|
1454 | + return 1; |
|
1455 | + } else { |
|
1456 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1457 | + } |
|
1458 | + } |
|
1459 | 1459 | |
1460 | 1460 | /** |
1461 | 1461 | * @return array |
1462 | 1462 | */ |
1463 | 1463 | public static function json_to_array( $json_vars ) { |
1464 | - $vars = array(); |
|
1465 | - foreach ( $json_vars as $jv ) { |
|
1466 | - $jv_name = explode('[', $jv['name']); |
|
1467 | - $last = count($jv_name) - 1; |
|
1468 | - foreach ( $jv_name as $p => $n ) { |
|
1469 | - $name = trim($n, ']'); |
|
1470 | - if ( ! isset($l1) ) { |
|
1471 | - $l1 = $name; |
|
1472 | - } |
|
1473 | - |
|
1474 | - if ( ! isset($l2) ) { |
|
1475 | - $l2 = $name; |
|
1476 | - } |
|
1477 | - |
|
1478 | - if ( ! isset($l3) ) { |
|
1479 | - $l3 = $name; |
|
1480 | - } |
|
1481 | - |
|
1482 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1483 | - |
|
1484 | - switch ( $p ) { |
|
1485 | - case 0: |
|
1486 | - $l1 = $name; |
|
1487 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1488 | - break; |
|
1489 | - |
|
1490 | - case 1: |
|
1491 | - $l2 = $name; |
|
1492 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1493 | - break; |
|
1494 | - |
|
1495 | - case 2: |
|
1496 | - $l3 = $name; |
|
1497 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1498 | - break; |
|
1499 | - |
|
1500 | - case 3: |
|
1501 | - $l4 = $name; |
|
1502 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1503 | - break; |
|
1504 | - } |
|
1505 | - |
|
1506 | - unset($this_val, $n); |
|
1507 | - } |
|
1508 | - |
|
1509 | - unset($last, $jv); |
|
1510 | - } |
|
1511 | - |
|
1512 | - return $vars; |
|
1513 | - } |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * @param string $name |
|
1517 | - * @param string $l1 |
|
1518 | - */ |
|
1519 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1520 | - if ( $name == '' ) { |
|
1521 | - $vars[] = $val; |
|
1522 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1523 | - $vars[ $l1 ] = $val; |
|
1524 | - } |
|
1525 | - } |
|
1464 | + $vars = array(); |
|
1465 | + foreach ( $json_vars as $jv ) { |
|
1466 | + $jv_name = explode('[', $jv['name']); |
|
1467 | + $last = count($jv_name) - 1; |
|
1468 | + foreach ( $jv_name as $p => $n ) { |
|
1469 | + $name = trim($n, ']'); |
|
1470 | + if ( ! isset($l1) ) { |
|
1471 | + $l1 = $name; |
|
1472 | + } |
|
1473 | + |
|
1474 | + if ( ! isset($l2) ) { |
|
1475 | + $l2 = $name; |
|
1476 | + } |
|
1477 | + |
|
1478 | + if ( ! isset($l3) ) { |
|
1479 | + $l3 = $name; |
|
1480 | + } |
|
1481 | + |
|
1482 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1483 | + |
|
1484 | + switch ( $p ) { |
|
1485 | + case 0: |
|
1486 | + $l1 = $name; |
|
1487 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1488 | + break; |
|
1489 | + |
|
1490 | + case 1: |
|
1491 | + $l2 = $name; |
|
1492 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1493 | + break; |
|
1494 | + |
|
1495 | + case 2: |
|
1496 | + $l3 = $name; |
|
1497 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1498 | + break; |
|
1499 | + |
|
1500 | + case 3: |
|
1501 | + $l4 = $name; |
|
1502 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1503 | + break; |
|
1504 | + } |
|
1505 | + |
|
1506 | + unset($this_val, $n); |
|
1507 | + } |
|
1508 | + |
|
1509 | + unset($last, $jv); |
|
1510 | + } |
|
1511 | + |
|
1512 | + return $vars; |
|
1513 | + } |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * @param string $name |
|
1517 | + * @param string $l1 |
|
1518 | + */ |
|
1519 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1520 | + if ( $name == '' ) { |
|
1521 | + $vars[] = $val; |
|
1522 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1523 | + $vars[ $l1 ] = $val; |
|
1524 | + } |
|
1525 | + } |
|
1526 | 1526 | |
1527 | 1527 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1528 | - $tooltips = array( |
|
1529 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1530 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1531 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1532 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1533 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1534 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1535 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1536 | - ); |
|
1537 | - |
|
1538 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1539 | - return; |
|
1540 | - } |
|
1541 | - |
|
1542 | - if ( 'open' == $class ) { |
|
1543 | - echo ' frm_help"'; |
|
1544 | - } else { |
|
1545 | - echo ' class="frm_help"'; |
|
1546 | - } |
|
1528 | + $tooltips = array( |
|
1529 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1530 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1531 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1532 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1533 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1534 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1535 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1536 | + ); |
|
1537 | + |
|
1538 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1539 | + return; |
|
1540 | + } |
|
1541 | + |
|
1542 | + if ( 'open' == $class ) { |
|
1543 | + echo ' frm_help"'; |
|
1544 | + } else { |
|
1545 | + echo ' class="frm_help"'; |
|
1546 | + } |
|
1547 | 1547 | |
1548 | 1548 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
1549 | 1549 | |
1550 | - if ( 'open' != $class ) { |
|
1551 | - echo '"'; |
|
1552 | - } |
|
1553 | - } |
|
1550 | + if ( 'open' != $class ) { |
|
1551 | + echo '"'; |
|
1552 | + } |
|
1553 | + } |
|
1554 | 1554 | |
1555 | 1555 | /** |
1556 | 1556 | * Add the current_page class to that page in the form nav |
@@ -1566,35 +1566,35 @@ discard block |
||
1566 | 1566 | } |
1567 | 1567 | } |
1568 | 1568 | |
1569 | - /** |
|
1570 | - * Prepare and json_encode post content |
|
1571 | - * |
|
1572 | - * @since 2.0 |
|
1573 | - * |
|
1574 | - * @param array $post_content |
|
1575 | - * @return string $post_content ( json encoded array ) |
|
1576 | - */ |
|
1577 | - public static function prepare_and_encode( $post_content ) { |
|
1578 | - //Loop through array to strip slashes and add only the needed ones |
|
1569 | + /** |
|
1570 | + * Prepare and json_encode post content |
|
1571 | + * |
|
1572 | + * @since 2.0 |
|
1573 | + * |
|
1574 | + * @param array $post_content |
|
1575 | + * @return string $post_content ( json encoded array ) |
|
1576 | + */ |
|
1577 | + public static function prepare_and_encode( $post_content ) { |
|
1578 | + //Loop through array to strip slashes and add only the needed ones |
|
1579 | 1579 | foreach ( $post_content as $key => $val ) { |
1580 | 1580 | // Replace problematic characters (like ") |
1581 | 1581 | $val = str_replace( '"', '"', $val ); |
1582 | 1582 | |
1583 | 1583 | self::prepare_action_slashes( $val, $key, $post_content ); |
1584 | - unset( $key, $val ); |
|
1585 | - } |
|
1584 | + unset( $key, $val ); |
|
1585 | + } |
|
1586 | 1586 | |
1587 | - // json_encode the array |
|
1588 | - $post_content = json_encode( $post_content ); |
|
1587 | + // json_encode the array |
|
1588 | + $post_content = json_encode( $post_content ); |
|
1589 | 1589 | |
1590 | - // add extra slashes for \r\n since WP strips them |
|
1590 | + // add extra slashes for \r\n since WP strips them |
|
1591 | 1591 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1592 | 1592 | |
1593 | - // allow for " |
|
1594 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1593 | + // allow for " |
|
1594 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1595 | 1595 | |
1596 | - return $post_content; |
|
1597 | - } |
|
1596 | + return $post_content; |
|
1597 | + } |
|
1598 | 1598 | |
1599 | 1599 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1600 | 1600 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1662,64 +1662,64 @@ discard block |
||
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | public static function maybe_json_decode( $string ) { |
1665 | - if ( is_array($string) ) { |
|
1666 | - return $string; |
|
1667 | - } |
|
1665 | + if ( is_array($string) ) { |
|
1666 | + return $string; |
|
1667 | + } |
|
1668 | 1668 | |
1669 | - $new_string = json_decode($string, true); |
|
1670 | - if ( function_exists('json_last_error') ) { |
|
1669 | + $new_string = json_decode($string, true); |
|
1670 | + if ( function_exists('json_last_error') ) { |
|
1671 | 1671 | // php 5.3+ |
1672 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1673 | - $string = $new_string; |
|
1674 | - } |
|
1675 | - } else if ( isset($new_string) ) { |
|
1672 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1673 | + $string = $new_string; |
|
1674 | + } |
|
1675 | + } else if ( isset($new_string) ) { |
|
1676 | 1676 | // php < 5.3 fallback |
1677 | - $string = $new_string; |
|
1678 | - } |
|
1679 | - return $string; |
|
1680 | - } |
|
1681 | - |
|
1682 | - /** |
|
1683 | - * @since 1.07.10 |
|
1684 | - * |
|
1685 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1686 | - * echo The javascript to open and highlight the Formidable menu |
|
1687 | - */ |
|
1677 | + $string = $new_string; |
|
1678 | + } |
|
1679 | + return $string; |
|
1680 | + } |
|
1681 | + |
|
1682 | + /** |
|
1683 | + * @since 1.07.10 |
|
1684 | + * |
|
1685 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1686 | + * echo The javascript to open and highlight the Formidable menu |
|
1687 | + */ |
|
1688 | 1688 | public static function maybe_highlight_menu( $post_type ) { |
1689 | - global $post; |
|
1689 | + global $post; |
|
1690 | 1690 | |
1691 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1692 | - return; |
|
1693 | - } |
|
1691 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1692 | + return; |
|
1693 | + } |
|
1694 | 1694 | |
1695 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1696 | - return; |
|
1697 | - } |
|
1695 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1696 | + return; |
|
1697 | + } |
|
1698 | 1698 | |
1699 | - self::load_admin_wide_js(); |
|
1700 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1701 | - } |
|
1699 | + self::load_admin_wide_js(); |
|
1700 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1701 | + } |
|
1702 | 1702 | |
1703 | - /** |
|
1704 | - * Load the JS file on non-Formidable pages in the admin area |
|
1705 | - * @since 2.0 |
|
1706 | - */ |
|
1703 | + /** |
|
1704 | + * Load the JS file on non-Formidable pages in the admin area |
|
1705 | + * @since 2.0 |
|
1706 | + */ |
|
1707 | 1707 | public static function load_admin_wide_js( $load = true ) { |
1708 | - $version = FrmAppHelper::plugin_version(); |
|
1708 | + $version = FrmAppHelper::plugin_version(); |
|
1709 | 1709 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1710 | 1710 | |
1711 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1711 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1712 | 1712 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1713 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1713 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1714 | 1714 | 'url' => FrmAppHelper::plugin_url(), |
1715 | 1715 | 'loading' => __( 'Loading…' ), |
1716 | 1716 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1717 | - ) ); |
|
1717 | + ) ); |
|
1718 | 1718 | |
1719 | 1719 | if ( $load ) { |
1720 | 1720 | wp_enqueue_script( 'formidable_admin_global' ); |
1721 | 1721 | } |
1722 | - } |
|
1722 | + } |
|
1723 | 1723 | |
1724 | 1724 | /** |
1725 | 1725 | * @since 2.0.9 |
@@ -1728,9 +1728,9 @@ discard block |
||
1728 | 1728 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1729 | 1729 | } |
1730 | 1730 | |
1731 | - /** |
|
1732 | - * @param string $location |
|
1733 | - */ |
|
1731 | + /** |
|
1732 | + * @param string $location |
|
1733 | + */ |
|
1734 | 1734 | public static function localize_script( $location ) { |
1735 | 1735 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1736 | 1736 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1785,81 +1785,81 @@ discard block |
||
1785 | 1785 | } |
1786 | 1786 | } |
1787 | 1787 | |
1788 | - /** |
|
1788 | + /** |
|
1789 | 1789 | * echo the message on the plugins listing page |
1790 | - * @since 1.07.10 |
|
1791 | - * |
|
1792 | - * @param float $min_version The version the add-on requires |
|
1793 | - */ |
|
1790 | + * @since 1.07.10 |
|
1791 | + * |
|
1792 | + * @param float $min_version The version the add-on requires |
|
1793 | + */ |
|
1794 | 1794 | public static function min_version_notice( $min_version ) { |
1795 | - $frm_version = self::plugin_version(); |
|
1795 | + $frm_version = self::plugin_version(); |
|
1796 | 1796 | |
1797 | - // check if Formidable meets minimum requirements |
|
1798 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1799 | - return; |
|
1800 | - } |
|
1797 | + // check if Formidable meets minimum requirements |
|
1798 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1799 | + return; |
|
1800 | + } |
|
1801 | 1801 | |
1802 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1802 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1803 | 1803 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
1804 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1805 | - '</div></td></tr>'; |
|
1806 | - } |
|
1807 | - |
|
1808 | - public static function locales( $type = 'date' ) { |
|
1809 | - $locales = array( |
|
1810 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1811 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1812 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1813 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1814 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1815 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1816 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1817 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1818 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1819 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1820 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1821 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1822 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1823 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1824 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1825 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1826 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1827 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1828 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1829 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1830 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1831 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1832 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1833 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1834 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1835 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1836 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1837 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1838 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1839 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1840 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1841 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1842 | - ); |
|
1843 | - |
|
1844 | - if ( $type == 'captcha' ) { |
|
1845 | - // remove the languages unavailable for the captcha |
|
1846 | - $unset = array( |
|
1847 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1848 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1849 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1850 | - ); |
|
1851 | - } else { |
|
1852 | - // remove the languages unavailable for the datepicker |
|
1853 | - $unset = array( |
|
1854 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1855 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1856 | - 'es-419', 'tr', |
|
1857 | - ); |
|
1858 | - } |
|
1859 | - |
|
1860 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1861 | - $locales = apply_filters('frm_locales', $locales); |
|
1862 | - |
|
1863 | - return $locales; |
|
1864 | - } |
|
1804 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1805 | + '</div></td></tr>'; |
|
1806 | + } |
|
1807 | + |
|
1808 | + public static function locales( $type = 'date' ) { |
|
1809 | + $locales = array( |
|
1810 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1811 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1812 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1813 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1814 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1815 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1816 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1817 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1818 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1819 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1820 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1821 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1822 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1823 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1824 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1825 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1826 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1827 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1828 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1829 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1830 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1831 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1832 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1833 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1834 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1835 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1836 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1837 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1838 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1839 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1840 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1841 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1842 | + ); |
|
1843 | + |
|
1844 | + if ( $type == 'captcha' ) { |
|
1845 | + // remove the languages unavailable for the captcha |
|
1846 | + $unset = array( |
|
1847 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1848 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1849 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1850 | + ); |
|
1851 | + } else { |
|
1852 | + // remove the languages unavailable for the datepicker |
|
1853 | + $unset = array( |
|
1854 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1855 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1856 | + 'es-419', 'tr', |
|
1857 | + ); |
|
1858 | + } |
|
1859 | + |
|
1860 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1861 | + $locales = apply_filters('frm_locales', $locales); |
|
1862 | + |
|
1863 | + return $locales; |
|
1864 | + } |
|
1865 | 1865 | } |