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