@@ -746,6 +746,9 @@ discard block |
||
746 | 746 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
747 | 747 | } |
748 | 748 | |
749 | + /** |
|
750 | + * @param string $function |
|
751 | + */ |
|
749 | 752 | public static function recursive_function_map( $value, $function ) { |
750 | 753 | if ( is_array( $value ) ) { |
751 | 754 | $original_function = $function; |
@@ -1173,6 +1176,9 @@ discard block |
||
1173 | 1176 | return $sub . (($len < $original_len) ? $continue : ''); |
1174 | 1177 | } |
1175 | 1178 | |
1179 | + /** |
|
1180 | + * @param string[] $function_names |
|
1181 | + */ |
|
1176 | 1182 | public static function mb_function( $function_names, $args ) { |
1177 | 1183 | $mb_function_name = $function_names[0]; |
1178 | 1184 | $function_name = $function_names[1]; |
@@ -1206,6 +1212,9 @@ discard block |
||
1206 | 1212 | return $formatted; |
1207 | 1213 | } |
1208 | 1214 | |
1215 | + /** |
|
1216 | + * @param string $time_format |
|
1217 | + */ |
|
1209 | 1218 | private static function add_time_to_date( $time_format, $date ) { |
1210 | 1219 | if ( empty( $time_format ) ) { |
1211 | 1220 | $time_format = get_option('time_format'); |
@@ -12,50 +12,50 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public static $plug_version = '2.01.01'; |
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() { |
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 ) { |
@@ -337,14 +337,14 @@ discard block |
||
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
341 | - $temp_values = $values; |
|
342 | - foreach ( $temp_values as $k => $val ) { |
|
343 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
340 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
341 | + $temp_values = $values; |
|
342 | + foreach ( $temp_values as $k => $val ) { |
|
343 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
344 | 344 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
345 | - } |
|
346 | - } |
|
347 | - } |
|
345 | + } |
|
346 | + } |
|
347 | + } |
|
348 | 348 | |
349 | 349 | public static function sanitize_array( &$values ) { |
350 | 350 | $temp_values = $values; |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | */ |
360 | 360 | public static function kses( $value, $allowed = array() ) { |
361 | 361 | $html = array( |
362 | - 'a' => array( |
|
362 | + 'a' => array( |
|
363 | 363 | 'href' => array(), |
364 | 364 | 'title' => array(), |
365 | 365 | 'id' => array(), |
366 | 366 | 'class' => array(), |
367 | - ), |
|
367 | + ), |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | $allowed_html = array(); |
@@ -375,123 +375,123 @@ discard block |
||
375 | 375 | return wp_kses( $value, $allowed_html ); |
376 | 376 | } |
377 | 377 | |
378 | - /** |
|
379 | - * Used when switching the action for a bulk action |
|
380 | - * @since 2.0 |
|
381 | - */ |
|
382 | - public static function remove_get_action() { |
|
383 | - if ( ! isset($_GET) ) { |
|
384 | - return; |
|
385 | - } |
|
378 | + /** |
|
379 | + * Used when switching the action for a bulk action |
|
380 | + * @since 2.0 |
|
381 | + */ |
|
382 | + public static function remove_get_action() { |
|
383 | + if ( ! isset($_GET) ) { |
|
384 | + return; |
|
385 | + } |
|
386 | 386 | |
387 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
388 | - if ( ! empty( $new_action ) ) { |
|
387 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
388 | + if ( ! empty( $new_action ) ) { |
|
389 | 389 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Check the WP query for a parameter |
|
395 | - * |
|
396 | - * @since 2.0 |
|
397 | - * @return string|array |
|
398 | - */ |
|
399 | - public static function get_query_var( $value, $param ) { |
|
400 | - if ( $value != '' ) { |
|
401 | - return $value; |
|
402 | - } |
|
403 | - |
|
404 | - global $wp_query; |
|
405 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
406 | - $value = $wp_query->query_vars[ $param ]; |
|
407 | - } |
|
408 | - |
|
409 | - return $value; |
|
410 | - } |
|
411 | - |
|
412 | - /** |
|
413 | - * @param string $type |
|
414 | - */ |
|
415 | - public static function trigger_hook_load( $type, $object = null ) { |
|
416 | - // only load the form hooks once |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Check the WP query for a parameter |
|
395 | + * |
|
396 | + * @since 2.0 |
|
397 | + * @return string|array |
|
398 | + */ |
|
399 | + public static function get_query_var( $value, $param ) { |
|
400 | + if ( $value != '' ) { |
|
401 | + return $value; |
|
402 | + } |
|
403 | + |
|
404 | + global $wp_query; |
|
405 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
406 | + $value = $wp_query->query_vars[ $param ]; |
|
407 | + } |
|
408 | + |
|
409 | + return $value; |
|
410 | + } |
|
411 | + |
|
412 | + /** |
|
413 | + * @param string $type |
|
414 | + */ |
|
415 | + public static function trigger_hook_load( $type, $object = null ) { |
|
416 | + // only load the form hooks once |
|
417 | 417 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
418 | - if ( ! $hooks_loaded ) { |
|
418 | + if ( ! $hooks_loaded ) { |
|
419 | 419 | do_action( 'frm_load_' . $type . '_hooks' ); |
420 | - } |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Check cache before fetching values and saving to cache |
|
425 | - * |
|
426 | - * @since 2.0 |
|
427 | - * |
|
428 | - * @param string $cache_key The unique name for this cache |
|
429 | - * @param string $group The name of the cache group |
|
430 | - * @param string $query If blank, don't run a db call |
|
431 | - * @param string $type The wpdb function to use with this query |
|
432 | - * @return mixed $results The cache or query results |
|
433 | - */ |
|
434 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
435 | - $results = wp_cache_get($cache_key, $group); |
|
436 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
437 | - return $results; |
|
438 | - } |
|
439 | - |
|
440 | - if ( 'get_posts' == $type ) { |
|
441 | - $results = get_posts($query); |
|
442 | - } else { |
|
443 | - global $wpdb; |
|
444 | - $results = $wpdb->{$type}($query); |
|
445 | - } |
|
420 | + } |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Check cache before fetching values and saving to cache |
|
425 | + * |
|
426 | + * @since 2.0 |
|
427 | + * |
|
428 | + * @param string $cache_key The unique name for this cache |
|
429 | + * @param string $group The name of the cache group |
|
430 | + * @param string $query If blank, don't run a db call |
|
431 | + * @param string $type The wpdb function to use with this query |
|
432 | + * @return mixed $results The cache or query results |
|
433 | + */ |
|
434 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
435 | + $results = wp_cache_get($cache_key, $group); |
|
436 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
437 | + return $results; |
|
438 | + } |
|
439 | + |
|
440 | + if ( 'get_posts' == $type ) { |
|
441 | + $results = get_posts($query); |
|
442 | + } else { |
|
443 | + global $wpdb; |
|
444 | + $results = $wpdb->{$type}($query); |
|
445 | + } |
|
446 | 446 | |
447 | 447 | if ( ! self::prevent_caching() ) { |
448 | 448 | wp_cache_set( $cache_key, $results, $group, $time ); |
449 | 449 | } |
450 | 450 | |
451 | - return $results; |
|
452 | - } |
|
451 | + return $results; |
|
452 | + } |
|
453 | 453 | |
454 | - /** |
|
455 | - * Data that should be stored for a long time can be stored in a transient. |
|
456 | - * First check the cache, then check the transient |
|
457 | - * @since 2.0 |
|
458 | - * @return mixed The cached value or false |
|
459 | - */ |
|
454 | + /** |
|
455 | + * Data that should be stored for a long time can be stored in a transient. |
|
456 | + * First check the cache, then check the transient |
|
457 | + * @since 2.0 |
|
458 | + * @return mixed The cached value or false |
|
459 | + */ |
|
460 | 460 | public static function check_cache_and_transient( $cache_key ) { |
461 | - // check caching layer first |
|
462 | - $results = self::check_cache( $cache_key ); |
|
463 | - if ( $results ) { |
|
464 | - return $results; |
|
465 | - } |
|
466 | - |
|
467 | - // then check the transient |
|
468 | - $results = get_transient($cache_key); |
|
469 | - if ( $results ) { |
|
470 | - wp_cache_set($cache_key, $results); |
|
471 | - } |
|
472 | - |
|
473 | - return $results; |
|
474 | - } |
|
475 | - |
|
476 | - /** |
|
477 | - * @since 2.0 |
|
478 | - * @param string $cache_key |
|
479 | - */ |
|
461 | + // check caching layer first |
|
462 | + $results = self::check_cache( $cache_key ); |
|
463 | + if ( $results ) { |
|
464 | + return $results; |
|
465 | + } |
|
466 | + |
|
467 | + // then check the transient |
|
468 | + $results = get_transient($cache_key); |
|
469 | + if ( $results ) { |
|
470 | + wp_cache_set($cache_key, $results); |
|
471 | + } |
|
472 | + |
|
473 | + return $results; |
|
474 | + } |
|
475 | + |
|
476 | + /** |
|
477 | + * @since 2.0 |
|
478 | + * @param string $cache_key |
|
479 | + */ |
|
480 | 480 | public static function delete_cache_and_transient( $cache_key ) { |
481 | - delete_transient($cache_key); |
|
482 | - wp_cache_delete($cache_key); |
|
483 | - } |
|
484 | - |
|
485 | - /** |
|
486 | - * Delete all caching in a single group |
|
487 | - * |
|
488 | - * @since 2.0 |
|
489 | - * |
|
490 | - * @param string $group The name of the cache group |
|
491 | - * @return boolean True or False |
|
492 | - */ |
|
481 | + delete_transient($cache_key); |
|
482 | + wp_cache_delete($cache_key); |
|
483 | + } |
|
484 | + |
|
485 | + /** |
|
486 | + * Delete all caching in a single group |
|
487 | + * |
|
488 | + * @since 2.0 |
|
489 | + * |
|
490 | + * @param string $group The name of the cache group |
|
491 | + * @return boolean True or False |
|
492 | + */ |
|
493 | 493 | public static function cache_delete_group( $group ) { |
494 | - global $wp_object_cache; |
|
494 | + global $wp_object_cache; |
|
495 | 495 | |
496 | 496 | if ( is_callable( array( $wp_object_cache, '__get' ) ) ) { |
497 | 497 | $group_cache = $wp_object_cache->__get('cache'); |
@@ -507,51 +507,51 @@ discard block |
||
507 | 507 | return true; |
508 | 508 | } |
509 | 509 | |
510 | - return false; |
|
511 | - } |
|
510 | + return false; |
|
511 | + } |
|
512 | 512 | |
513 | - /** |
|
514 | - * Check a value from a shortcode to see if true or false. |
|
515 | - * True when value is 1, true, 'true', 'yes' |
|
516 | - * |
|
517 | - * @since 1.07.10 |
|
518 | - * |
|
519 | - * @param string $value The value to compare |
|
520 | - * @return boolean True or False |
|
521 | - */ |
|
513 | + /** |
|
514 | + * Check a value from a shortcode to see if true or false. |
|
515 | + * True when value is 1, true, 'true', 'yes' |
|
516 | + * |
|
517 | + * @since 1.07.10 |
|
518 | + * |
|
519 | + * @param string $value The value to compare |
|
520 | + * @return boolean True or False |
|
521 | + */ |
|
522 | 522 | public static function is_true( $value ) { |
523 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
524 | - } |
|
523 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
524 | + } |
|
525 | 525 | |
526 | - /** |
|
527 | - * Used to filter shortcode in text widgets |
|
528 | - */ |
|
529 | - public static function widget_text_filter_callback( $matches ) { |
|
530 | - return do_shortcode( $matches[0] ); |
|
531 | - } |
|
526 | + /** |
|
527 | + * Used to filter shortcode in text widgets |
|
528 | + */ |
|
529 | + public static function widget_text_filter_callback( $matches ) { |
|
530 | + return do_shortcode( $matches[0] ); |
|
531 | + } |
|
532 | 532 | |
533 | 533 | public static function load_scripts( $scripts ) { |
534 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
535 | - foreach ( (array) $scripts as $s ) { |
|
536 | - wp_enqueue_script($s); |
|
537 | - } |
|
538 | - } |
|
534 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
535 | + foreach ( (array) $scripts as $s ) { |
|
536 | + wp_enqueue_script($s); |
|
537 | + } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | public static function load_styles( $styles ) { |
541 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
542 | - foreach ( (array) $styles as $s ) { |
|
543 | - wp_enqueue_style($s); |
|
544 | - } |
|
545 | - } |
|
541 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
542 | + foreach ( (array) $styles as $s ) { |
|
543 | + wp_enqueue_style($s); |
|
544 | + } |
|
545 | + } |
|
546 | 546 | |
547 | - public static function get_pages() { |
|
547 | + public static function get_pages() { |
|
548 | 548 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
549 | - } |
|
549 | + } |
|
550 | 550 | |
551 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
552 | - $pages = self::get_pages(); |
|
551 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
552 | + $pages = self::get_pages(); |
|
553 | 553 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
554 | - ?> |
|
554 | + ?> |
|
555 | 555 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
556 | 556 | <option value=""> </option> |
557 | 557 | <?php foreach ( $pages as $page ) { ?> |
@@ -561,108 +561,108 @@ discard block |
||
561 | 561 | <?php } ?> |
562 | 562 | </select> |
563 | 563 | <?php |
564 | - } |
|
564 | + } |
|
565 | 565 | |
566 | 566 | public static function post_edit_link( $post_id ) { |
567 | - $post = get_post($post_id); |
|
568 | - if ( $post ) { |
|
567 | + $post = get_post($post_id); |
|
568 | + if ( $post ) { |
|
569 | 569 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
570 | 570 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
571 | - } |
|
572 | - return ''; |
|
573 | - } |
|
571 | + } |
|
572 | + return ''; |
|
573 | + } |
|
574 | 574 | |
575 | 575 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
576 | - ?> |
|
576 | + ?> |
|
577 | 577 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
578 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
579 | - ?> class="frm_multiselect"> |
|
578 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
579 | + ?> class="frm_multiselect"> |
|
580 | 580 | <?php self::roles_options($capability); ?> |
581 | 581 | </select> |
582 | 582 | <?php |
583 | - } |
|
583 | + } |
|
584 | 584 | |
585 | 585 | public static function roles_options( $capability ) { |
586 | - global $frm_vars; |
|
587 | - if ( isset($frm_vars['editable_roles']) ) { |
|
588 | - $editable_roles = $frm_vars['editable_roles']; |
|
589 | - } else { |
|
590 | - $editable_roles = get_editable_roles(); |
|
591 | - $frm_vars['editable_roles'] = $editable_roles; |
|
592 | - } |
|
593 | - |
|
594 | - foreach ( $editable_roles as $role => $details ) { |
|
595 | - $name = translate_user_role($details['name'] ); ?> |
|
586 | + global $frm_vars; |
|
587 | + if ( isset($frm_vars['editable_roles']) ) { |
|
588 | + $editable_roles = $frm_vars['editable_roles']; |
|
589 | + } else { |
|
590 | + $editable_roles = get_editable_roles(); |
|
591 | + $frm_vars['editable_roles'] = $editable_roles; |
|
592 | + } |
|
593 | + |
|
594 | + foreach ( $editable_roles as $role => $details ) { |
|
595 | + $name = translate_user_role($details['name'] ); ?> |
|
596 | 596 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
597 | 597 | <?php |
598 | - unset($role, $details); |
|
599 | - } |
|
600 | - } |
|
598 | + unset($role, $details); |
|
599 | + } |
|
600 | + } |
|
601 | 601 | |
602 | 602 | public static function frm_capabilities( $type = 'auto' ) { |
603 | - $cap = array( |
|
604 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
605 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
606 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
607 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
608 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
609 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
610 | - ); |
|
603 | + $cap = array( |
|
604 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
605 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
606 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
607 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
608 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
609 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
610 | + ); |
|
611 | 611 | |
612 | 612 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
613 | - return $cap; |
|
614 | - } |
|
613 | + return $cap; |
|
614 | + } |
|
615 | 615 | |
616 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
617 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
618 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
619 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
616 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
617 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
618 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
619 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
620 | 620 | |
621 | - return $cap; |
|
622 | - } |
|
621 | + return $cap; |
|
622 | + } |
|
623 | 623 | |
624 | 624 | public static function user_has_permission( $needed_role ) { |
625 | - if ( $needed_role == '-1' ) { |
|
626 | - return false; |
|
625 | + if ( $needed_role == '-1' ) { |
|
626 | + return false; |
|
627 | 627 | } |
628 | 628 | |
629 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
630 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
631 | - return true; |
|
632 | - } |
|
629 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
630 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
631 | + return true; |
|
632 | + } |
|
633 | 633 | |
634 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
635 | - foreach ( $roles as $role ) { |
|
634 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
635 | + foreach ( $roles as $role ) { |
|
636 | 636 | if ( current_user_can( $role ) ) { |
637 | - return true; |
|
637 | + return true; |
|
638 | 638 | } |
639 | - if ( $role == $needed_role ) { |
|
640 | - break; |
|
639 | + if ( $role == $needed_role ) { |
|
640 | + break; |
|
641 | 641 | } |
642 | - } |
|
643 | - return false; |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Make sure administrators can see Formidable menu |
|
648 | - * |
|
649 | - * @since 2.0 |
|
650 | - */ |
|
651 | - public static function maybe_add_permissions() { |
|
642 | + } |
|
643 | + return false; |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Make sure administrators can see Formidable menu |
|
648 | + * |
|
649 | + * @since 2.0 |
|
650 | + */ |
|
651 | + public static function maybe_add_permissions() { |
|
652 | 652 | self::force_capability( 'frm_view_entries' ); |
653 | 653 | |
654 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
655 | - return; |
|
656 | - } |
|
654 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
655 | + return; |
|
656 | + } |
|
657 | 657 | |
658 | 658 | $user_id = get_current_user_id(); |
659 | 659 | $user = new WP_User( $user_id ); |
660 | - $frm_roles = self::frm_capabilities(); |
|
661 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
660 | + $frm_roles = self::frm_capabilities(); |
|
661 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
662 | 662 | $user->add_cap( $frm_role ); |
663 | - unset($frm_role, $frm_role_description); |
|
664 | - } |
|
665 | - } |
|
663 | + unset($frm_role, $frm_role_description); |
|
664 | + } |
|
665 | + } |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * Make sure admins have permission to see the menu items |
@@ -678,28 +678,28 @@ discard block |
||
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | - /** |
|
682 | - * Check if the user has permision for action. |
|
683 | - * Return permission message and stop the action if no permission |
|
684 | - * @since 2.0 |
|
685 | - * @param string $permission |
|
686 | - */ |
|
681 | + /** |
|
682 | + * Check if the user has permision for action. |
|
683 | + * Return permission message and stop the action if no permission |
|
684 | + * @since 2.0 |
|
685 | + * @param string $permission |
|
686 | + */ |
|
687 | 687 | public static function permission_check( $permission, $show_message = 'show' ) { |
688 | - $permission_error = self::permission_nonce_error($permission); |
|
689 | - if ( $permission_error !== false ) { |
|
690 | - if ( 'hide' == $show_message ) { |
|
691 | - $permission_error = ''; |
|
692 | - } |
|
693 | - wp_die($permission_error); |
|
694 | - } |
|
695 | - } |
|
696 | - |
|
697 | - /** |
|
698 | - * Check user permission and nonce |
|
699 | - * @since 2.0 |
|
700 | - * @param string $permission |
|
701 | - * @return false|string The permission message or false if allowed |
|
702 | - */ |
|
688 | + $permission_error = self::permission_nonce_error($permission); |
|
689 | + if ( $permission_error !== false ) { |
|
690 | + if ( 'hide' == $show_message ) { |
|
691 | + $permission_error = ''; |
|
692 | + } |
|
693 | + wp_die($permission_error); |
|
694 | + } |
|
695 | + } |
|
696 | + |
|
697 | + /** |
|
698 | + * Check user permission and nonce |
|
699 | + * @since 2.0 |
|
700 | + * @param string $permission |
|
701 | + * @return false|string The permission message or false if allowed |
|
702 | + */ |
|
703 | 703 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
704 | 704 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
705 | 705 | $frm_settings = self::get_settings(); |
@@ -707,23 +707,23 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | $error = false; |
710 | - if ( empty($nonce_name) ) { |
|
711 | - return $error; |
|
712 | - } |
|
710 | + if ( empty($nonce_name) ) { |
|
711 | + return $error; |
|
712 | + } |
|
713 | 713 | |
714 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
715 | - $frm_settings = self::get_settings(); |
|
716 | - $error = $frm_settings->admin_permission; |
|
717 | - } |
|
714 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
715 | + $frm_settings = self::get_settings(); |
|
716 | + $error = $frm_settings->admin_permission; |
|
717 | + } |
|
718 | 718 | |
719 | - return $error; |
|
720 | - } |
|
719 | + return $error; |
|
720 | + } |
|
721 | 721 | |
722 | - public static function checked( $values, $current ) { |
|
722 | + public static function checked( $values, $current ) { |
|
723 | 723 | if ( self::check_selected( $values, $current ) ) { |
724 | - echo ' checked="checked"'; |
|
724 | + echo ' checked="checked"'; |
|
725 | 725 | } |
726 | - } |
|
726 | + } |
|
727 | 727 | |
728 | 728 | public static function check_selected( $values, $current ) { |
729 | 729 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -733,50 +733,50 @@ discard block |
||
733 | 733 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
734 | 734 | } |
735 | 735 | |
736 | - /** |
|
737 | - * Check if current field option is an "other" option |
|
738 | - * |
|
739 | - * @since 2.0 |
|
740 | - * |
|
741 | - * @param string $opt_key |
|
742 | - * @return boolean Returns true if current field option is an "Other" option |
|
743 | - */ |
|
744 | - public static function is_other_opt( $opt_key ) { |
|
745 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
746 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
747 | - } |
|
748 | - |
|
749 | - /** |
|
750 | - * Get value that belongs in "Other" text box |
|
751 | - * |
|
752 | - * @since 2.0 |
|
753 | - * |
|
754 | - * @param string $opt_key |
|
755 | - * @param array $field |
|
756 | - * @return string $other_val |
|
757 | - */ |
|
758 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
736 | + /** |
|
737 | + * Check if current field option is an "other" option |
|
738 | + * |
|
739 | + * @since 2.0 |
|
740 | + * |
|
741 | + * @param string $opt_key |
|
742 | + * @return boolean Returns true if current field option is an "Other" option |
|
743 | + */ |
|
744 | + public static function is_other_opt( $opt_key ) { |
|
745 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
746 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
747 | + } |
|
748 | + |
|
749 | + /** |
|
750 | + * Get value that belongs in "Other" text box |
|
751 | + * |
|
752 | + * @since 2.0 |
|
753 | + * |
|
754 | + * @param string $opt_key |
|
755 | + * @param array $field |
|
756 | + * @return string $other_val |
|
757 | + */ |
|
758 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
759 | 759 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
760 | 760 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
761 | - } |
|
762 | - |
|
763 | - /** |
|
764 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
765 | - * Intended for front-end use |
|
766 | - * |
|
767 | - * @since 2.0 |
|
768 | - * |
|
769 | - * @param array $field |
|
770 | - * @param boolean $other_opt |
|
771 | - * @param string $checked |
|
772 | - * @param array $args should include opt_key and field name |
|
773 | - * @return string $other_val |
|
774 | - */ |
|
775 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
761 | + } |
|
762 | + |
|
763 | + /** |
|
764 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
765 | + * Intended for front-end use |
|
766 | + * |
|
767 | + * @since 2.0 |
|
768 | + * |
|
769 | + * @param array $field |
|
770 | + * @param boolean $other_opt |
|
771 | + * @param string $checked |
|
772 | + * @param array $args should include opt_key and field name |
|
773 | + * @return string $other_val |
|
774 | + */ |
|
775 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
776 | 776 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
777 | 777 | $args['field'] = $field; |
778 | 778 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
779 | - } |
|
779 | + } |
|
780 | 780 | |
781 | 781 | public static function recursive_function_map( $value, $function ) { |
782 | 782 | if ( is_array( $value ) ) { |
@@ -806,24 +806,24 @@ discard block |
||
806 | 806 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
807 | 807 | } |
808 | 808 | |
809 | - /** |
|
810 | - * Flatten a multi-dimensional array |
|
811 | - */ |
|
809 | + /** |
|
810 | + * Flatten a multi-dimensional array |
|
811 | + */ |
|
812 | 812 | public static function array_flatten( $array, $keys = 'keep' ) { |
813 | - $return = array(); |
|
814 | - foreach ( $array as $key => $value ) { |
|
815 | - if ( is_array($value) ) { |
|
813 | + $return = array(); |
|
814 | + foreach ( $array as $key => $value ) { |
|
815 | + if ( is_array($value) ) { |
|
816 | 816 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
817 | - } else { |
|
817 | + } else { |
|
818 | 818 | if ( $keys == 'keep' ) { |
819 | 819 | $return[ $key ] = $value; |
820 | 820 | } else { |
821 | 821 | $return[] = $value; |
822 | 822 | } |
823 | - } |
|
824 | - } |
|
825 | - return $return; |
|
826 | - } |
|
823 | + } |
|
824 | + } |
|
825 | + return $return; |
|
826 | + } |
|
827 | 827 | |
828 | 828 | public static function esc_textarea( $text ) { |
829 | 829 | $safe_text = str_replace( '"', '"', $text ); |
@@ -832,308 +832,308 @@ discard block |
||
832 | 832 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
833 | 833 | } |
834 | 834 | |
835 | - /** |
|
836 | - * Add auto paragraphs to text areas |
|
837 | - * @since 2.0 |
|
838 | - */ |
|
835 | + /** |
|
836 | + * Add auto paragraphs to text areas |
|
837 | + * @since 2.0 |
|
838 | + */ |
|
839 | 839 | public static function use_wpautop( $content ) { |
840 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
841 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
842 | - } |
|
843 | - return $content; |
|
844 | - } |
|
840 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
841 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
842 | + } |
|
843 | + return $content; |
|
844 | + } |
|
845 | 845 | |
846 | 846 | public static function replace_quotes( $val ) { |
847 | - //Replace double quotes |
|
847 | + //Replace double quotes |
|
848 | 848 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
849 | - //Replace single quotes |
|
850 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
851 | - return $val; |
|
852 | - } |
|
853 | - |
|
854 | - /** |
|
855 | - * @since 2.0 |
|
856 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
857 | - */ |
|
858 | - public static function jquery_ui_base_url() { |
|
849 | + //Replace single quotes |
|
850 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
851 | + return $val; |
|
852 | + } |
|
853 | + |
|
854 | + /** |
|
855 | + * @since 2.0 |
|
856 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
857 | + */ |
|
858 | + public static function jquery_ui_base_url() { |
|
859 | 859 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
860 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
861 | - return $url; |
|
862 | - } |
|
860 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
861 | + return $url; |
|
862 | + } |
|
863 | 863 | |
864 | - /** |
|
865 | - * @param string $handle |
|
866 | - */ |
|
864 | + /** |
|
865 | + * @param string $handle |
|
866 | + */ |
|
867 | 867 | public static function script_version( $handle ) { |
868 | - global $wp_scripts; |
|
869 | - if ( ! $wp_scripts ) { |
|
870 | - return false; |
|
871 | - } |
|
868 | + global $wp_scripts; |
|
869 | + if ( ! $wp_scripts ) { |
|
870 | + return false; |
|
871 | + } |
|
872 | 872 | |
873 | - $ver = 0; |
|
873 | + $ver = 0; |
|
874 | 874 | |
875 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
876 | - return $ver; |
|
877 | - } |
|
875 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
876 | + return $ver; |
|
877 | + } |
|
878 | 878 | |
879 | - $query = $wp_scripts->registered[ $handle ]; |
|
880 | - if ( is_object( $query ) ) { |
|
881 | - $ver = $query->ver; |
|
882 | - } |
|
879 | + $query = $wp_scripts->registered[ $handle ]; |
|
880 | + if ( is_object( $query ) ) { |
|
881 | + $ver = $query->ver; |
|
882 | + } |
|
883 | 883 | |
884 | - return $ver; |
|
885 | - } |
|
884 | + return $ver; |
|
885 | + } |
|
886 | 886 | |
887 | 887 | public static function js_redirect( $url ) { |
888 | 888 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
889 | - } |
|
889 | + } |
|
890 | 890 | |
891 | 891 | public static function get_user_id_param( $user_id ) { |
892 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
893 | - return $user_id; |
|
894 | - } |
|
892 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
893 | + return $user_id; |
|
894 | + } |
|
895 | 895 | |
896 | 896 | if ( $user_id == 'current' ) { |
897 | 897 | $user_id = get_current_user_id(); |
898 | 898 | } else { |
899 | - if ( is_email($user_id) ) { |
|
900 | - $user = get_user_by('email', $user_id); |
|
901 | - } else { |
|
902 | - $user = get_user_by('login', $user_id); |
|
903 | - } |
|
899 | + if ( is_email($user_id) ) { |
|
900 | + $user = get_user_by('email', $user_id); |
|
901 | + } else { |
|
902 | + $user = get_user_by('login', $user_id); |
|
903 | + } |
|
904 | 904 | |
905 | - if ( $user ) { |
|
906 | - $user_id = $user->ID; |
|
907 | - } |
|
908 | - unset($user); |
|
909 | - } |
|
905 | + if ( $user ) { |
|
906 | + $user_id = $user->ID; |
|
907 | + } |
|
908 | + unset($user); |
|
909 | + } |
|
910 | 910 | |
911 | - return $user_id; |
|
912 | - } |
|
911 | + return $user_id; |
|
912 | + } |
|
913 | 913 | |
914 | 914 | public static function get_file_contents( $filename, $atts = array() ) { |
915 | - if ( ! is_file($filename) ) { |
|
916 | - return false; |
|
917 | - } |
|
918 | - |
|
919 | - extract($atts); |
|
920 | - ob_start(); |
|
921 | - include($filename); |
|
922 | - $contents = ob_get_contents(); |
|
923 | - ob_end_clean(); |
|
924 | - return $contents; |
|
925 | - } |
|
926 | - |
|
927 | - /** |
|
928 | - * @param string $table_name |
|
929 | - * @param string $column |
|
915 | + if ( ! is_file($filename) ) { |
|
916 | + return false; |
|
917 | + } |
|
918 | + |
|
919 | + extract($atts); |
|
920 | + ob_start(); |
|
921 | + include($filename); |
|
922 | + $contents = ob_get_contents(); |
|
923 | + ob_end_clean(); |
|
924 | + return $contents; |
|
925 | + } |
|
926 | + |
|
927 | + /** |
|
928 | + * @param string $table_name |
|
929 | + * @param string $column |
|
930 | 930 | * @param int $id |
931 | 931 | * @param int $num_chars |
932 | - */ |
|
933 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
934 | - $key = ''; |
|
932 | + */ |
|
933 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
934 | + $key = ''; |
|
935 | 935 | |
936 | - if ( ! empty( $name ) ) { |
|
937 | - $key = sanitize_key($name); |
|
938 | - } |
|
936 | + if ( ! empty( $name ) ) { |
|
937 | + $key = sanitize_key($name); |
|
938 | + } |
|
939 | 939 | |
940 | 940 | if ( empty( $key ) ) { |
941 | - $max_slug_value = pow(36, $num_chars); |
|
942 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
943 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
944 | - } |
|
941 | + $max_slug_value = pow(36, $num_chars); |
|
942 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
943 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
944 | + } |
|
945 | 945 | |
946 | 946 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
947 | 947 | $key = $key . 'a'; |
948 | - } |
|
948 | + } |
|
949 | 949 | |
950 | 950 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
951 | 951 | |
952 | - if ( $key_check || is_numeric($key_check) ) { |
|
953 | - $suffix = 2; |
|
952 | + if ( $key_check || is_numeric($key_check) ) { |
|
953 | + $suffix = 2; |
|
954 | 954 | do { |
955 | 955 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
956 | 956 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
957 | 957 | $suffix++; |
958 | 958 | } while ($key_check || is_numeric($key_check)); |
959 | 959 | $key = $alt_post_name; |
960 | - } |
|
961 | - return $key; |
|
962 | - } |
|
963 | - |
|
964 | - /** |
|
965 | - * Editing a Form or Entry |
|
966 | - * @param string $table |
|
967 | - * @return bool|array |
|
968 | - */ |
|
969 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
970 | - if ( ! $record ) { |
|
971 | - return false; |
|
972 | - } |
|
973 | - |
|
974 | - if ( empty($post_values) ) { |
|
975 | - $post_values = stripslashes_deep($_POST); |
|
976 | - } |
|
960 | + } |
|
961 | + return $key; |
|
962 | + } |
|
963 | + |
|
964 | + /** |
|
965 | + * Editing a Form or Entry |
|
966 | + * @param string $table |
|
967 | + * @return bool|array |
|
968 | + */ |
|
969 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
970 | + if ( ! $record ) { |
|
971 | + return false; |
|
972 | + } |
|
973 | + |
|
974 | + if ( empty($post_values) ) { |
|
975 | + $post_values = stripslashes_deep($_POST); |
|
976 | + } |
|
977 | 977 | |
978 | 978 | $values = array( 'id' => $record->id, 'fields' => array() ); |
979 | 979 | |
980 | 980 | foreach ( array( 'name', 'description' ) as $var ) { |
981 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
981 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
982 | 982 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
983 | - unset($var, $default_val); |
|
984 | - } |
|
985 | - |
|
986 | - $values['description'] = self::use_wpautop($values['description']); |
|
987 | - $frm_settings = self::get_settings(); |
|
988 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
989 | - |
|
990 | - foreach ( (array) $fields as $field ) { |
|
991 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
992 | - if ( ! $is_form_builder ) { |
|
993 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
994 | - } |
|
983 | + unset($var, $default_val); |
|
984 | + } |
|
985 | + |
|
986 | + $values['description'] = self::use_wpautop($values['description']); |
|
987 | + $frm_settings = self::get_settings(); |
|
988 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
989 | + |
|
990 | + foreach ( (array) $fields as $field ) { |
|
991 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
992 | + if ( ! $is_form_builder ) { |
|
993 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
994 | + } |
|
995 | 995 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
996 | 996 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
997 | - } |
|
997 | + } |
|
998 | 998 | |
999 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
999 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
1000 | 1000 | |
1001 | - if ( $table == 'entries' ) { |
|
1002 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1003 | - } else if ( $table == 'forms' ) { |
|
1004 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1005 | - } |
|
1001 | + if ( $table == 'entries' ) { |
|
1002 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
1003 | + } else if ( $table == 'forms' ) { |
|
1004 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
1005 | + } |
|
1006 | 1006 | |
1007 | - return $values; |
|
1008 | - } |
|
1007 | + return $values; |
|
1008 | + } |
|
1009 | 1009 | |
1010 | 1010 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
1011 | - $post_values = $args['post_values']; |
|
1012 | - |
|
1013 | - if ( $args['default'] ) { |
|
1014 | - $meta_value = $field->default_value; |
|
1015 | - } else { |
|
1016 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1017 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1018 | - $field->field_options['custom_field'] = ''; |
|
1019 | - } |
|
1011 | + $post_values = $args['post_values']; |
|
1012 | + |
|
1013 | + if ( $args['default'] ) { |
|
1014 | + $meta_value = $field->default_value; |
|
1015 | + } else { |
|
1016 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1017 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
1018 | + $field->field_options['custom_field'] = ''; |
|
1019 | + } |
|
1020 | 1020 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
1021 | - } else { |
|
1021 | + } else { |
|
1022 | 1022 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
1023 | - } |
|
1024 | - } |
|
1023 | + } |
|
1024 | + } |
|
1025 | 1025 | |
1026 | 1026 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
1027 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1028 | - |
|
1029 | - $field_array = array( |
|
1030 | - 'id' => $field->id, |
|
1031 | - 'value' => $new_value, |
|
1032 | - 'default_value' => $field->default_value, |
|
1033 | - 'name' => $field->name, |
|
1034 | - 'description' => $field->description, |
|
1035 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1036 | - 'options' => $field->options, |
|
1037 | - 'required' => $field->required, |
|
1038 | - 'field_key' => $field->field_key, |
|
1039 | - 'field_order' => $field->field_order, |
|
1040 | - 'form_id' => $field->form_id, |
|
1027 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1028 | + |
|
1029 | + $field_array = array( |
|
1030 | + 'id' => $field->id, |
|
1031 | + 'value' => $new_value, |
|
1032 | + 'default_value' => $field->default_value, |
|
1033 | + 'name' => $field->name, |
|
1034 | + 'description' => $field->description, |
|
1035 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1036 | + 'options' => $field->options, |
|
1037 | + 'required' => $field->required, |
|
1038 | + 'field_key' => $field->field_key, |
|
1039 | + 'field_order' => $field->field_order, |
|
1040 | + 'form_id' => $field->form_id, |
|
1041 | 1041 | 'parent_form_id' => $args['parent_form_id'], |
1042 | - ); |
|
1042 | + ); |
|
1043 | 1043 | |
1044 | - $args['field_type'] = $field_type; |
|
1045 | - self::fill_field_opts($field, $field_array, $args); |
|
1044 | + $args['field_type'] = $field_type; |
|
1045 | + self::fill_field_opts($field, $field_array, $args); |
|
1046 | 1046 | // Track the original field's type |
1047 | 1047 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1048 | 1048 | |
1049 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1049 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
1050 | 1050 | |
1051 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1052 | - $field_array['unique_msg'] = ''; |
|
1053 | - } |
|
1051 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1052 | + $field_array['unique_msg'] = ''; |
|
1053 | + } |
|
1054 | 1054 | |
1055 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1055 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1056 | 1056 | |
1057 | - $values['fields'][ $field->id ] = $field_array; |
|
1058 | - } |
|
1057 | + $values['fields'][ $field->id ] = $field_array; |
|
1058 | + } |
|
1059 | 1059 | |
1060 | 1060 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1061 | - $post_values = $args['post_values']; |
|
1062 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1061 | + $post_values = $args['post_values']; |
|
1062 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1063 | 1063 | |
1064 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1064 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1065 | 1065 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
1066 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1067 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1068 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1069 | - if ( $args['field_type'] == 'captcha' ) { |
|
1070 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1071 | - } else { |
|
1072 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1073 | - } |
|
1074 | - } |
|
1075 | - } |
|
1076 | - |
|
1077 | - if ( $field_array['custom_html'] == '' ) { |
|
1078 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1079 | - } |
|
1080 | - } |
|
1081 | - |
|
1082 | - /** |
|
1083 | - * @param string $table |
|
1084 | - */ |
|
1066 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1067 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1068 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1069 | + if ( $args['field_type'] == 'captcha' ) { |
|
1070 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1071 | + } else { |
|
1072 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1073 | + } |
|
1074 | + } |
|
1075 | + } |
|
1076 | + |
|
1077 | + if ( $field_array['custom_html'] == '' ) { |
|
1078 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1079 | + } |
|
1080 | + } |
|
1081 | + |
|
1082 | + /** |
|
1083 | + * @param string $table |
|
1084 | + */ |
|
1085 | 1085 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1086 | - if ( $table == 'entries' ) { |
|
1087 | - $form = $record->form_id; |
|
1086 | + if ( $table == 'entries' ) { |
|
1087 | + $form = $record->form_id; |
|
1088 | 1088 | FrmForm::maybe_get_form( $form ); |
1089 | - } else { |
|
1090 | - $form = $record; |
|
1091 | - } |
|
1089 | + } else { |
|
1090 | + $form = $record; |
|
1091 | + } |
|
1092 | 1092 | |
1093 | - if ( ! $form ) { |
|
1094 | - return; |
|
1095 | - } |
|
1093 | + if ( ! $form ) { |
|
1094 | + return; |
|
1095 | + } |
|
1096 | 1096 | |
1097 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1097 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1098 | 1098 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1099 | 1099 | |
1100 | - if ( ! is_array($form->options) ) { |
|
1101 | - return; |
|
1102 | - } |
|
1100 | + if ( ! is_array($form->options) ) { |
|
1101 | + return; |
|
1102 | + } |
|
1103 | 1103 | |
1104 | - foreach ( $form->options as $opt => $value ) { |
|
1105 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1106 | - } |
|
1104 | + foreach ( $form->options as $opt => $value ) { |
|
1105 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1106 | + } |
|
1107 | 1107 | |
1108 | - self::fill_form_defaults($post_values, $values); |
|
1109 | - } |
|
1108 | + self::fill_form_defaults($post_values, $values); |
|
1109 | + } |
|
1110 | 1110 | |
1111 | - /** |
|
1112 | - * Set to POST value or default |
|
1113 | - */ |
|
1111 | + /** |
|
1112 | + * Set to POST value or default |
|
1113 | + */ |
|
1114 | 1114 | private static function fill_form_defaults( $post_values, array &$values ) { |
1115 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1115 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1116 | 1116 | |
1117 | - foreach ( $form_defaults as $opt => $default ) { |
|
1118 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1117 | + foreach ( $form_defaults as $opt => $default ) { |
|
1118 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1119 | 1119 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1120 | - } |
|
1120 | + } |
|
1121 | 1121 | |
1122 | - unset($opt, $defaut); |
|
1123 | - } |
|
1122 | + unset($opt, $defaut); |
|
1123 | + } |
|
1124 | 1124 | |
1125 | - if ( ! isset($values['custom_style']) ) { |
|
1126 | - $frm_settings = self::get_settings(); |
|
1125 | + if ( ! isset($values['custom_style']) ) { |
|
1126 | + $frm_settings = self::get_settings(); |
|
1127 | 1127 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1128 | - } |
|
1128 | + } |
|
1129 | 1129 | |
1130 | 1130 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1131 | 1131 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
1132 | 1132 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
1133 | - } |
|
1134 | - unset($h); |
|
1135 | - } |
|
1136 | - } |
|
1133 | + } |
|
1134 | + unset($h); |
|
1135 | + } |
|
1136 | + } |
|
1137 | 1137 | |
1138 | 1138 | public static function get_meta_value( $field_id, $entry ) { |
1139 | 1139 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1141,69 +1141,69 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | public static function insert_opt_html( $args ) { |
1144 | - $class = ''; |
|
1145 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1146 | - $class .= 'show_frm_not_email_to'; |
|
1147 | - } |
|
1148 | - ?> |
|
1144 | + $class = ''; |
|
1145 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1146 | + $class .= 'show_frm_not_email_to'; |
|
1147 | + } |
|
1148 | + ?> |
|
1149 | 1149 | <li> |
1150 | 1150 | <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> |
1151 | 1151 | <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> |
1152 | 1152 | <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> |
1153 | 1153 | </li> |
1154 | 1154 | <?php |
1155 | - } |
|
1155 | + } |
|
1156 | 1156 | |
1157 | - public static function get_us_states() { |
|
1158 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1159 | - return FrmFieldsHelper::get_us_states(); |
|
1160 | - } |
|
1157 | + public static function get_us_states() { |
|
1158 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1159 | + return FrmFieldsHelper::get_us_states(); |
|
1160 | + } |
|
1161 | 1161 | |
1162 | - public static function get_countries() { |
|
1163 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1164 | - return FrmFieldsHelper::get_countries(); |
|
1165 | - } |
|
1162 | + public static function get_countries() { |
|
1163 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1164 | + return FrmFieldsHelper::get_countries(); |
|
1165 | + } |
|
1166 | 1166 | |
1167 | 1167 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1168 | - if ( is_array( $str ) ) { |
|
1169 | - return ''; |
|
1168 | + if ( is_array( $str ) ) { |
|
1169 | + return ''; |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | - $length = (int) $length; |
|
1172 | + $length = (int) $length; |
|
1173 | 1173 | $str = wp_strip_all_tags( $str ); |
1174 | 1174 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1175 | 1175 | |
1176 | 1176 | if ( $length == 0 ) { |
1177 | - return ''; |
|
1178 | - } else if ( $length <= 10 ) { |
|
1177 | + return ''; |
|
1178 | + } else if ( $length <= 10 ) { |
|
1179 | 1179 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1180 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1181 | - } |
|
1180 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1181 | + } |
|
1182 | 1182 | |
1183 | - $sub = ''; |
|
1184 | - $len = 0; |
|
1183 | + $sub = ''; |
|
1184 | + $len = 0; |
|
1185 | 1185 | |
1186 | 1186 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1187 | 1187 | |
1188 | 1188 | foreach ( $words as $word ) { |
1189 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1189 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1190 | 1190 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1191 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1192 | - break; |
|
1193 | - } |
|
1191 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1192 | + break; |
|
1193 | + } |
|
1194 | 1194 | |
1195 | - $sub .= $part; |
|
1195 | + $sub .= $part; |
|
1196 | 1196 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1197 | 1197 | |
1198 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1199 | - break; |
|
1200 | - } |
|
1198 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1199 | + break; |
|
1200 | + } |
|
1201 | 1201 | |
1202 | - unset($total_len, $word); |
|
1203 | - } |
|
1202 | + unset($total_len, $word); |
|
1203 | + } |
|
1204 | 1204 | |
1205 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1206 | - } |
|
1205 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1206 | + } |
|
1207 | 1207 | |
1208 | 1208 | public static function mb_function( $function_names, $args ) { |
1209 | 1209 | $mb_function_name = $function_names[0]; |
@@ -1215,18 +1215,18 @@ discard block |
||
1215 | 1215 | } |
1216 | 1216 | |
1217 | 1217 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1218 | - if ( empty($date) ) { |
|
1219 | - return $date; |
|
1220 | - } |
|
1218 | + if ( empty($date) ) { |
|
1219 | + return $date; |
|
1220 | + } |
|
1221 | 1221 | |
1222 | - if ( empty($date_format) ) { |
|
1223 | - $date_format = get_option('date_format'); |
|
1224 | - } |
|
1222 | + if ( empty($date_format) ) { |
|
1223 | + $date_format = get_option('date_format'); |
|
1224 | + } |
|
1225 | 1225 | |
1226 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1227 | - $frmpro_settings = new FrmProSettings(); |
|
1228 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1229 | - } |
|
1226 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1227 | + $frmpro_settings = new FrmProSettings(); |
|
1228 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1229 | + } |
|
1230 | 1230 | |
1231 | 1231 | $formatted = self::get_localized_date( $date_format, $date ); |
1232 | 1232 | |
@@ -1235,8 +1235,8 @@ discard block |
||
1235 | 1235 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1236 | 1236 | } |
1237 | 1237 | |
1238 | - return $formatted; |
|
1239 | - } |
|
1238 | + return $formatted; |
|
1239 | + } |
|
1240 | 1240 | |
1241 | 1241 | private static function add_time_to_date( $time_format, $date ) { |
1242 | 1242 | if ( empty( $time_format ) ) { |
@@ -1317,61 +1317,61 @@ discard block |
||
1317 | 1317 | ); |
1318 | 1318 | } |
1319 | 1319 | |
1320 | - /** |
|
1321 | - * Added for < WP 4.0 compatability |
|
1322 | - * |
|
1323 | - * @since 1.07.10 |
|
1324 | - * |
|
1325 | - * @param string $term The value to escape |
|
1326 | - * @return string The escaped value |
|
1327 | - */ |
|
1320 | + /** |
|
1321 | + * Added for < WP 4.0 compatability |
|
1322 | + * |
|
1323 | + * @since 1.07.10 |
|
1324 | + * |
|
1325 | + * @param string $term The value to escape |
|
1326 | + * @return string The escaped value |
|
1327 | + */ |
|
1328 | 1328 | public static function esc_like( $term ) { |
1329 | - global $wpdb; |
|
1330 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1329 | + global $wpdb; |
|
1330 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1331 | 1331 | // WP 4.0 |
1332 | - $term = $wpdb->esc_like( $term ); |
|
1333 | - } else { |
|
1334 | - $term = like_escape( $term ); |
|
1335 | - } |
|
1332 | + $term = $wpdb->esc_like( $term ); |
|
1333 | + } else { |
|
1334 | + $term = like_escape( $term ); |
|
1335 | + } |
|
1336 | 1336 | |
1337 | - return $term; |
|
1338 | - } |
|
1337 | + return $term; |
|
1338 | + } |
|
1339 | 1339 | |
1340 | - /** |
|
1341 | - * @param string $order_query |
|
1342 | - */ |
|
1340 | + /** |
|
1341 | + * @param string $order_query |
|
1342 | + */ |
|
1343 | 1343 | public static function esc_order( $order_query ) { |
1344 | - if ( empty($order_query) ) { |
|
1345 | - return ''; |
|
1346 | - } |
|
1347 | - |
|
1348 | - // remove ORDER BY before santizing |
|
1349 | - $order_query = strtolower($order_query); |
|
1350 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1351 | - $order_query = str_replace('order by', '', $order_query); |
|
1352 | - } |
|
1353 | - |
|
1354 | - $order_query = explode(' ', trim($order_query)); |
|
1355 | - |
|
1356 | - $order_fields = array( |
|
1357 | - 'id', 'form_key', 'name', 'description', |
|
1358 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1359 | - 'default_template', 'status', 'created_at', |
|
1360 | - ); |
|
1361 | - |
|
1362 | - $order = trim(trim(reset($order_query), ',')); |
|
1363 | - if ( ! in_array($order, $order_fields) ) { |
|
1364 | - return ''; |
|
1365 | - } |
|
1366 | - |
|
1367 | - $order_by = ''; |
|
1368 | - if ( count($order_query) > 1 ) { |
|
1344 | + if ( empty($order_query) ) { |
|
1345 | + return ''; |
|
1346 | + } |
|
1347 | + |
|
1348 | + // remove ORDER BY before santizing |
|
1349 | + $order_query = strtolower($order_query); |
|
1350 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1351 | + $order_query = str_replace('order by', '', $order_query); |
|
1352 | + } |
|
1353 | + |
|
1354 | + $order_query = explode(' ', trim($order_query)); |
|
1355 | + |
|
1356 | + $order_fields = array( |
|
1357 | + 'id', 'form_key', 'name', 'description', |
|
1358 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1359 | + 'default_template', 'status', 'created_at', |
|
1360 | + ); |
|
1361 | + |
|
1362 | + $order = trim(trim(reset($order_query), ',')); |
|
1363 | + if ( ! in_array($order, $order_fields) ) { |
|
1364 | + return ''; |
|
1365 | + } |
|
1366 | + |
|
1367 | + $order_by = ''; |
|
1368 | + if ( count($order_query) > 1 ) { |
|
1369 | 1369 | $order_by = end( $order_query ); |
1370 | 1370 | self::esc_order_by( $order_by ); |
1371 | - } |
|
1371 | + } |
|
1372 | 1372 | |
1373 | 1373 | return ' ORDER BY ' . $order . ' ' . $order_by; |
1374 | - } |
|
1374 | + } |
|
1375 | 1375 | |
1376 | 1376 | /** |
1377 | 1377 | * Make sure this is ordering by either ASC or DESC |
@@ -1383,183 +1383,183 @@ discard block |
||
1383 | 1383 | } |
1384 | 1384 | } |
1385 | 1385 | |
1386 | - /** |
|
1387 | - * @param string $limit |
|
1388 | - */ |
|
1386 | + /** |
|
1387 | + * @param string $limit |
|
1388 | + */ |
|
1389 | 1389 | public static function esc_limit( $limit ) { |
1390 | - if ( empty($limit) ) { |
|
1391 | - return ''; |
|
1392 | - } |
|
1390 | + if ( empty($limit) ) { |
|
1391 | + return ''; |
|
1392 | + } |
|
1393 | 1393 | |
1394 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1395 | - if ( is_numeric($limit) ) { |
|
1394 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1395 | + if ( is_numeric($limit) ) { |
|
1396 | 1396 | return ' LIMIT ' . $limit; |
1397 | - } |
|
1397 | + } |
|
1398 | 1398 | |
1399 | - $limit = explode(',', trim($limit)); |
|
1400 | - foreach ( $limit as $k => $l ) { |
|
1401 | - if ( is_numeric( $l ) ) { |
|
1402 | - $limit[ $k ] = $l; |
|
1403 | - } |
|
1404 | - } |
|
1399 | + $limit = explode(',', trim($limit)); |
|
1400 | + foreach ( $limit as $k => $l ) { |
|
1401 | + if ( is_numeric( $l ) ) { |
|
1402 | + $limit[ $k ] = $l; |
|
1403 | + } |
|
1404 | + } |
|
1405 | 1405 | |
1406 | - $limit = implode(',', $limit); |
|
1406 | + $limit = implode(',', $limit); |
|
1407 | 1407 | return ' LIMIT ' . $limit; |
1408 | - } |
|
1409 | - |
|
1410 | - /** |
|
1411 | - * Get an array of values ready to go through $wpdb->prepare |
|
1412 | - * @since 2.0 |
|
1413 | - */ |
|
1414 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1415 | - $placeholders = array_fill(0, count($array), $type); |
|
1416 | - return implode(', ', $placeholders); |
|
1417 | - } |
|
1418 | - |
|
1419 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1420 | - if ( empty($where) ) { |
|
1421 | - return ''; |
|
1422 | - } |
|
1408 | + } |
|
1409 | + |
|
1410 | + /** |
|
1411 | + * Get an array of values ready to go through $wpdb->prepare |
|
1412 | + * @since 2.0 |
|
1413 | + */ |
|
1414 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1415 | + $placeholders = array_fill(0, count($array), $type); |
|
1416 | + return implode(', ', $placeholders); |
|
1417 | + } |
|
1418 | + |
|
1419 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1420 | + if ( empty($where) ) { |
|
1421 | + return ''; |
|
1422 | + } |
|
1423 | 1423 | |
1424 | 1424 | if ( is_array( $where ) ) { |
1425 | - global $wpdb; |
|
1426 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1425 | + global $wpdb; |
|
1426 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1427 | 1427 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1428 | 1428 | } else { |
1429 | - $where = $starts_with . $where; |
|
1430 | - } |
|
1429 | + $where = $starts_with . $where; |
|
1430 | + } |
|
1431 | 1431 | |
1432 | - return $where; |
|
1433 | - } |
|
1432 | + return $where; |
|
1433 | + } |
|
1434 | 1434 | |
1435 | - // Pagination Methods |
|
1435 | + // Pagination Methods |
|
1436 | 1436 | |
1437 | - /** |
|
1438 | - * @param integer $current_p |
|
1439 | - */ |
|
1437 | + /** |
|
1438 | + * @param integer $current_p |
|
1439 | + */ |
|
1440 | 1440 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1441 | 1441 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1442 | 1442 | } |
1443 | 1443 | |
1444 | - /** |
|
1445 | - * @param integer $current_p |
|
1446 | - */ |
|
1447 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1448 | - if ( $current_p == 1 ) { |
|
1449 | - return 1; |
|
1450 | - } else { |
|
1451 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1452 | - } |
|
1453 | - } |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * @param string $table_name |
|
1457 | - */ |
|
1458 | - public static function &getRecordCount( $where = '', $table_name ) { |
|
1459 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1460 | - $count = FrmDb::get_count( $table_name, $where ); |
|
1461 | - return $count; |
|
1462 | - } |
|
1463 | - |
|
1464 | - public static function get_referer_info() { |
|
1465 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1466 | - return self::get_server_value('HTTP_REFERER'); |
|
1467 | - } |
|
1444 | + /** |
|
1445 | + * @param integer $current_p |
|
1446 | + */ |
|
1447 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1448 | + if ( $current_p == 1 ) { |
|
1449 | + return 1; |
|
1450 | + } else { |
|
1451 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1452 | + } |
|
1453 | + } |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * @param string $table_name |
|
1457 | + */ |
|
1458 | + public static function &getRecordCount( $where = '', $table_name ) { |
|
1459 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1460 | + $count = FrmDb::get_count( $table_name, $where ); |
|
1461 | + return $count; |
|
1462 | + } |
|
1463 | + |
|
1464 | + public static function get_referer_info() { |
|
1465 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1466 | + return self::get_server_value('HTTP_REFERER'); |
|
1467 | + } |
|
1468 | 1468 | |
1469 | 1469 | /** |
1470 | 1470 | * @return array |
1471 | 1471 | */ |
1472 | 1472 | public static function json_to_array( $json_vars ) { |
1473 | - $vars = array(); |
|
1474 | - foreach ( $json_vars as $jv ) { |
|
1475 | - $jv_name = explode('[', $jv['name']); |
|
1476 | - $last = count($jv_name) - 1; |
|
1477 | - foreach ( $jv_name as $p => $n ) { |
|
1478 | - $name = trim($n, ']'); |
|
1479 | - if ( ! isset($l1) ) { |
|
1480 | - $l1 = $name; |
|
1481 | - } |
|
1482 | - |
|
1483 | - if ( ! isset($l2) ) { |
|
1484 | - $l2 = $name; |
|
1485 | - } |
|
1486 | - |
|
1487 | - if ( ! isset($l3) ) { |
|
1488 | - $l3 = $name; |
|
1489 | - } |
|
1490 | - |
|
1491 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1492 | - |
|
1493 | - switch ( $p ) { |
|
1494 | - case 0: |
|
1495 | - $l1 = $name; |
|
1496 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1497 | - break; |
|
1498 | - |
|
1499 | - case 1: |
|
1500 | - $l2 = $name; |
|
1501 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1502 | - break; |
|
1503 | - |
|
1504 | - case 2: |
|
1505 | - $l3 = $name; |
|
1506 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1507 | - break; |
|
1508 | - |
|
1509 | - case 3: |
|
1510 | - $l4 = $name; |
|
1511 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1512 | - break; |
|
1513 | - } |
|
1514 | - |
|
1515 | - unset($this_val, $n); |
|
1516 | - } |
|
1517 | - |
|
1518 | - unset($last, $jv); |
|
1519 | - } |
|
1520 | - |
|
1521 | - return $vars; |
|
1522 | - } |
|
1523 | - |
|
1524 | - /** |
|
1525 | - * @param string $name |
|
1526 | - * @param string $l1 |
|
1527 | - */ |
|
1528 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1529 | - if ( $name == '' ) { |
|
1530 | - $vars[] = $val; |
|
1531 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1532 | - $vars[ $l1 ] = $val; |
|
1533 | - } |
|
1534 | - } |
|
1473 | + $vars = array(); |
|
1474 | + foreach ( $json_vars as $jv ) { |
|
1475 | + $jv_name = explode('[', $jv['name']); |
|
1476 | + $last = count($jv_name) - 1; |
|
1477 | + foreach ( $jv_name as $p => $n ) { |
|
1478 | + $name = trim($n, ']'); |
|
1479 | + if ( ! isset($l1) ) { |
|
1480 | + $l1 = $name; |
|
1481 | + } |
|
1482 | + |
|
1483 | + if ( ! isset($l2) ) { |
|
1484 | + $l2 = $name; |
|
1485 | + } |
|
1486 | + |
|
1487 | + if ( ! isset($l3) ) { |
|
1488 | + $l3 = $name; |
|
1489 | + } |
|
1490 | + |
|
1491 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1492 | + |
|
1493 | + switch ( $p ) { |
|
1494 | + case 0: |
|
1495 | + $l1 = $name; |
|
1496 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1497 | + break; |
|
1498 | + |
|
1499 | + case 1: |
|
1500 | + $l2 = $name; |
|
1501 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1502 | + break; |
|
1503 | + |
|
1504 | + case 2: |
|
1505 | + $l3 = $name; |
|
1506 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1507 | + break; |
|
1508 | + |
|
1509 | + case 3: |
|
1510 | + $l4 = $name; |
|
1511 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1512 | + break; |
|
1513 | + } |
|
1514 | + |
|
1515 | + unset($this_val, $n); |
|
1516 | + } |
|
1517 | + |
|
1518 | + unset($last, $jv); |
|
1519 | + } |
|
1520 | + |
|
1521 | + return $vars; |
|
1522 | + } |
|
1523 | + |
|
1524 | + /** |
|
1525 | + * @param string $name |
|
1526 | + * @param string $l1 |
|
1527 | + */ |
|
1528 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1529 | + if ( $name == '' ) { |
|
1530 | + $vars[] = $val; |
|
1531 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1532 | + $vars[ $l1 ] = $val; |
|
1533 | + } |
|
1534 | + } |
|
1535 | 1535 | |
1536 | 1536 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1537 | - $tooltips = array( |
|
1538 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1539 | - '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' ), |
|
1540 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1541 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1542 | - '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' ), |
|
1543 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1544 | - '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() ) ), |
|
1545 | - ); |
|
1546 | - |
|
1547 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1548 | - return; |
|
1549 | - } |
|
1550 | - |
|
1551 | - if ( 'open' == $class ) { |
|
1552 | - echo ' frm_help"'; |
|
1553 | - } else { |
|
1554 | - echo ' class="frm_help"'; |
|
1555 | - } |
|
1537 | + $tooltips = array( |
|
1538 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1539 | + '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' ), |
|
1540 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1541 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1542 | + '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' ), |
|
1543 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1544 | + '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() ) ), |
|
1545 | + ); |
|
1546 | + |
|
1547 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1548 | + return; |
|
1549 | + } |
|
1550 | + |
|
1551 | + if ( 'open' == $class ) { |
|
1552 | + echo ' frm_help"'; |
|
1553 | + } else { |
|
1554 | + echo ' class="frm_help"'; |
|
1555 | + } |
|
1556 | 1556 | |
1557 | 1557 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
1558 | 1558 | |
1559 | - if ( 'open' != $class ) { |
|
1560 | - echo '"'; |
|
1561 | - } |
|
1562 | - } |
|
1559 | + if ( 'open' != $class ) { |
|
1560 | + echo '"'; |
|
1561 | + } |
|
1562 | + } |
|
1563 | 1563 | |
1564 | 1564 | /** |
1565 | 1565 | * Add the current_page class to that page in the form nav |
@@ -1575,35 +1575,35 @@ discard block |
||
1575 | 1575 | } |
1576 | 1576 | } |
1577 | 1577 | |
1578 | - /** |
|
1579 | - * Prepare and json_encode post content |
|
1580 | - * |
|
1581 | - * @since 2.0 |
|
1582 | - * |
|
1583 | - * @param array $post_content |
|
1584 | - * @return string $post_content ( json encoded array ) |
|
1585 | - */ |
|
1586 | - public static function prepare_and_encode( $post_content ) { |
|
1587 | - //Loop through array to strip slashes and add only the needed ones |
|
1578 | + /** |
|
1579 | + * Prepare and json_encode post content |
|
1580 | + * |
|
1581 | + * @since 2.0 |
|
1582 | + * |
|
1583 | + * @param array $post_content |
|
1584 | + * @return string $post_content ( json encoded array ) |
|
1585 | + */ |
|
1586 | + public static function prepare_and_encode( $post_content ) { |
|
1587 | + //Loop through array to strip slashes and add only the needed ones |
|
1588 | 1588 | foreach ( $post_content as $key => $val ) { |
1589 | 1589 | // Replace problematic characters (like ") |
1590 | 1590 | $val = str_replace( '"', '"', $val ); |
1591 | 1591 | |
1592 | 1592 | self::prepare_action_slashes( $val, $key, $post_content ); |
1593 | - unset( $key, $val ); |
|
1594 | - } |
|
1593 | + unset( $key, $val ); |
|
1594 | + } |
|
1595 | 1595 | |
1596 | - // json_encode the array |
|
1597 | - $post_content = json_encode( $post_content ); |
|
1596 | + // json_encode the array |
|
1597 | + $post_content = json_encode( $post_content ); |
|
1598 | 1598 | |
1599 | - // add extra slashes for \r\n since WP strips them |
|
1599 | + // add extra slashes for \r\n since WP strips them |
|
1600 | 1600 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1601 | 1601 | |
1602 | - // allow for " |
|
1603 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1602 | + // allow for " |
|
1603 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1604 | 1604 | |
1605 | - return $post_content; |
|
1606 | - } |
|
1605 | + return $post_content; |
|
1606 | + } |
|
1607 | 1607 | |
1608 | 1608 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1609 | 1609 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1671,64 +1671,64 @@ discard block |
||
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | public static function maybe_json_decode( $string ) { |
1674 | - if ( is_array($string) ) { |
|
1675 | - return $string; |
|
1676 | - } |
|
1674 | + if ( is_array($string) ) { |
|
1675 | + return $string; |
|
1676 | + } |
|
1677 | 1677 | |
1678 | - $new_string = json_decode($string, true); |
|
1679 | - if ( function_exists('json_last_error') ) { |
|
1678 | + $new_string = json_decode($string, true); |
|
1679 | + if ( function_exists('json_last_error') ) { |
|
1680 | 1680 | // php 5.3+ |
1681 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1682 | - $string = $new_string; |
|
1683 | - } |
|
1684 | - } else if ( isset($new_string) ) { |
|
1681 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1682 | + $string = $new_string; |
|
1683 | + } |
|
1684 | + } else if ( isset($new_string) ) { |
|
1685 | 1685 | // php < 5.3 fallback |
1686 | - $string = $new_string; |
|
1687 | - } |
|
1688 | - return $string; |
|
1689 | - } |
|
1690 | - |
|
1691 | - /** |
|
1692 | - * @since 1.07.10 |
|
1693 | - * |
|
1694 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1695 | - * echo The javascript to open and highlight the Formidable menu |
|
1696 | - */ |
|
1686 | + $string = $new_string; |
|
1687 | + } |
|
1688 | + return $string; |
|
1689 | + } |
|
1690 | + |
|
1691 | + /** |
|
1692 | + * @since 1.07.10 |
|
1693 | + * |
|
1694 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1695 | + * echo The javascript to open and highlight the Formidable menu |
|
1696 | + */ |
|
1697 | 1697 | public static function maybe_highlight_menu( $post_type ) { |
1698 | - global $post; |
|
1698 | + global $post; |
|
1699 | 1699 | |
1700 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1701 | - return; |
|
1702 | - } |
|
1700 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1701 | + return; |
|
1702 | + } |
|
1703 | 1703 | |
1704 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1705 | - return; |
|
1706 | - } |
|
1704 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1705 | + return; |
|
1706 | + } |
|
1707 | 1707 | |
1708 | - self::load_admin_wide_js(); |
|
1709 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1710 | - } |
|
1708 | + self::load_admin_wide_js(); |
|
1709 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1710 | + } |
|
1711 | 1711 | |
1712 | - /** |
|
1713 | - * Load the JS file on non-Formidable pages in the admin area |
|
1714 | - * @since 2.0 |
|
1715 | - */ |
|
1712 | + /** |
|
1713 | + * Load the JS file on non-Formidable pages in the admin area |
|
1714 | + * @since 2.0 |
|
1715 | + */ |
|
1716 | 1716 | public static function load_admin_wide_js( $load = true ) { |
1717 | - $version = FrmAppHelper::plugin_version(); |
|
1717 | + $version = FrmAppHelper::plugin_version(); |
|
1718 | 1718 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1719 | 1719 | |
1720 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1720 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1721 | 1721 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1722 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1722 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1723 | 1723 | 'url' => FrmAppHelper::plugin_url(), |
1724 | 1724 | 'loading' => __( 'Loading…' ), |
1725 | 1725 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1726 | - ) ); |
|
1726 | + ) ); |
|
1727 | 1727 | |
1728 | 1728 | if ( $load ) { |
1729 | 1729 | wp_enqueue_script( 'formidable_admin_global' ); |
1730 | 1730 | } |
1731 | - } |
|
1731 | + } |
|
1732 | 1732 | |
1733 | 1733 | /** |
1734 | 1734 | * @since 2.0.9 |
@@ -1737,9 +1737,9 @@ discard block |
||
1737 | 1737 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1738 | 1738 | } |
1739 | 1739 | |
1740 | - /** |
|
1741 | - * @param string $location |
|
1742 | - */ |
|
1740 | + /** |
|
1741 | + * @param string $location |
|
1742 | + */ |
|
1743 | 1743 | public static function localize_script( $location ) { |
1744 | 1744 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1745 | 1745 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1790,81 +1790,81 @@ discard block |
||
1790 | 1790 | } |
1791 | 1791 | } |
1792 | 1792 | |
1793 | - /** |
|
1793 | + /** |
|
1794 | 1794 | * echo the message on the plugins listing page |
1795 | - * @since 1.07.10 |
|
1796 | - * |
|
1797 | - * @param float $min_version The version the add-on requires |
|
1798 | - */ |
|
1795 | + * @since 1.07.10 |
|
1796 | + * |
|
1797 | + * @param float $min_version The version the add-on requires |
|
1798 | + */ |
|
1799 | 1799 | public static function min_version_notice( $min_version ) { |
1800 | - $frm_version = self::plugin_version(); |
|
1800 | + $frm_version = self::plugin_version(); |
|
1801 | 1801 | |
1802 | - // check if Formidable meets minimum requirements |
|
1803 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1804 | - return; |
|
1805 | - } |
|
1802 | + // check if Formidable meets minimum requirements |
|
1803 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1804 | + return; |
|
1805 | + } |
|
1806 | 1806 | |
1807 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1807 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1808 | 1808 | 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">' . |
1809 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1810 | - '</div></td></tr>'; |
|
1811 | - } |
|
1812 | - |
|
1813 | - public static function locales( $type = 'date' ) { |
|
1814 | - $locales = array( |
|
1815 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1816 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1817 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1818 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1819 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1820 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1821 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1822 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1823 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1824 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1825 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1826 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1827 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1828 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1829 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1830 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1831 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1832 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1833 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1834 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1835 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1836 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1837 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1838 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1839 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1840 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1841 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1842 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1843 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1844 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1845 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1846 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1847 | - ); |
|
1848 | - |
|
1849 | - if ( $type == 'captcha' ) { |
|
1850 | - // remove the languages unavailable for the captcha |
|
1851 | - $unset = array( |
|
1852 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1853 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1854 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1855 | - ); |
|
1856 | - } else { |
|
1857 | - // remove the languages unavailable for the datepicker |
|
1858 | - $unset = array( |
|
1859 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1860 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1861 | - 'es-419', 'tr', |
|
1862 | - ); |
|
1863 | - } |
|
1864 | - |
|
1865 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1866 | - $locales = apply_filters('frm_locales', $locales); |
|
1867 | - |
|
1868 | - return $locales; |
|
1869 | - } |
|
1809 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1810 | + '</div></td></tr>'; |
|
1811 | + } |
|
1812 | + |
|
1813 | + public static function locales( $type = 'date' ) { |
|
1814 | + $locales = array( |
|
1815 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1816 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1817 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1818 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1819 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1820 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1821 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1822 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1823 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1824 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1825 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1826 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1827 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1828 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1829 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1830 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1831 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1832 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1833 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1834 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1835 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1836 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1837 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1838 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1839 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1840 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1841 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1842 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1843 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1844 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1845 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1846 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1847 | + ); |
|
1848 | + |
|
1849 | + if ( $type == 'captcha' ) { |
|
1850 | + // remove the languages unavailable for the captcha |
|
1851 | + $unset = array( |
|
1852 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1853 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1854 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1855 | + ); |
|
1856 | + } else { |
|
1857 | + // remove the languages unavailable for the datepicker |
|
1858 | + $unset = array( |
|
1859 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1860 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1861 | + 'es-419', 'tr', |
|
1862 | + ); |
|
1863 | + } |
|
1864 | + |
|
1865 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1866 | + $locales = apply_filters('frm_locales', $locales); |
|
1867 | + |
|
1868 | + return $locales; |
|
1869 | + } |
|
1870 | 1870 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function plugin_folder() { |
26 | - return basename(self::plugin_path()); |
|
26 | + return basename( self::plugin_path() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public static function plugin_path() { |
30 | - return dirname(dirname(dirname(__FILE__))); |
|
30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public static function plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function site_name() { |
57 | - return get_option('blogname'); |
|
57 | + return get_option( 'blogname' ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | public static function make_affiliate_url( $url ) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function get_affiliate() { |
69 | - $affiliate_id = apply_filters( 'frm_affiliate_link', get_option('frm_aff') ); |
|
69 | + $affiliate_id = apply_filters( 'frm_affiliate_link', get_option( 'frm_aff' ) ); |
|
70 | 70 | $affiliate_id = strtolower( $affiliate_id ); |
71 | 71 | $allowed_affiliates = array( 'mojo' ); |
72 | 72 | if ( ! in_array( $affiliate_id, $allowed_affiliates ) ) { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_settings() { |
87 | 87 | global $frm_settings; |
88 | - if ( empty($frm_settings) ) { |
|
88 | + if ( empty( $frm_settings ) ) { |
|
89 | 89 | $frm_settings = new FrmSettings(); |
90 | 90 | } |
91 | 91 | return $frm_settings; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | public static function pro_is_installed() { |
109 | - return apply_filters('frm_pro_installed', false); |
|
109 | + return apply_filters( 'frm_pro_installed', false ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | 152 | public static function doing_ajax() { |
153 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
153 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return boolean |
171 | 171 | */ |
172 | 172 | public static function is_admin() { |
173 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
173 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return string |
197 | 197 | */ |
198 | 198 | public static function get_server_value( $value ) { |
199 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
199 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
212 | 212 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
213 | 213 | ) as $key ) { |
214 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
214 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
215 | 215 | continue; |
216 | 216 | } |
217 | 217 | |
218 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
219 | - $ip = trim($ip); // just to be safe |
|
218 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
219 | + $ip = trim( $ip ); // just to be safe |
|
220 | 220 | |
221 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
221 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
222 | 222 | return $ip; |
223 | 223 | } |
224 | 224 | } |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
231 | - if ( strpos($param, '[') ) { |
|
232 | - $params = explode('[', $param); |
|
231 | + if ( strpos( $param, '[' ) ) { |
|
232 | + $params = explode( '[', $param ); |
|
233 | 233 | $param = $params[0]; |
234 | 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 ] ) ) ); |
|
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 | 240 | } |
241 | 241 | self::sanitize_value( $sanitize, $value ); |
242 | 242 | } else { |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | |
246 | 246 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
247 | 247 | foreach ( $params as $k => $p ) { |
248 | - if ( ! $k || ! is_array($value) ) { |
|
248 | + if ( ! $k || ! is_array( $value ) ) { |
|
249 | 249 | continue; |
250 | 250 | } |
251 | 251 | |
252 | - $p = trim($p, ']'); |
|
253 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
252 | + $p = trim( $p, ']' ); |
|
253 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
@@ -292,16 +292,16 @@ discard block |
||
292 | 292 | |
293 | 293 | $value = $args['default']; |
294 | 294 | if ( $args['type'] == 'get' ) { |
295 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
296 | - $value = $_GET[ $args['param'] ]; |
|
295 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
296 | + $value = $_GET[$args['param']]; |
|
297 | 297 | } |
298 | 298 | } else if ( $args['type'] == 'post' ) { |
299 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
300 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
299 | + if ( isset( $_POST[$args['param']] ) ) { |
|
300 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
301 | 301 | } |
302 | 302 | } else { |
303 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
304 | - $value = $_REQUEST[ $args['param'] ]; |
|
303 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
304 | + $value = $_REQUEST[$args['param']]; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ( is_array( $value ) ) { |
330 | 330 | $temp_values = $value; |
331 | 331 | foreach ( $temp_values as $k => $v ) { |
332 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
332 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
333 | 333 | } |
334 | 334 | } else { |
335 | 335 | $value = call_user_func( $sanitize, $value ); |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | public static function sanitize_request( $sanitize_method, &$values ) { |
341 | 341 | $temp_values = $values; |
342 | 342 | foreach ( $temp_values as $k => $val ) { |
343 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
344 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
343 | + if ( isset( $sanitize_method[$k] ) ) { |
|
344 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | public static function sanitize_array( &$values ) { |
350 | 350 | $temp_values = $values; |
351 | 351 | foreach ( $temp_values as $k => $val ) { |
352 | - $values[ $k ] = wp_kses_post( $val ); |
|
352 | + $values[$k] = wp_kses_post( $val ); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | $allowed_html = array(); |
371 | 371 | foreach ( $allowed as $a ) { |
372 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
372 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | return wp_kses( $value, $allowed_html ); |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @since 2.0 |
381 | 381 | */ |
382 | 382 | public static function remove_get_action() { |
383 | - if ( ! isset($_GET) ) { |
|
383 | + if ( ! isset( $_GET ) ) { |
|
384 | 384 | return; |
385 | 385 | } |
386 | 386 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | global $wp_query; |
405 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
406 | - $value = $wp_query->query_vars[ $param ]; |
|
405 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
406 | + $value = $wp_query->query_vars[$param]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $value; |
@@ -432,16 +432,16 @@ discard block |
||
432 | 432 | * @return mixed $results The cache or query results |
433 | 433 | */ |
434 | 434 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
435 | - $results = wp_cache_get($cache_key, $group); |
|
436 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
435 | + $results = wp_cache_get( $cache_key, $group ); |
|
436 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
437 | 437 | return $results; |
438 | 438 | } |
439 | 439 | |
440 | 440 | if ( 'get_posts' == $type ) { |
441 | - $results = get_posts($query); |
|
441 | + $results = get_posts( $query ); |
|
442 | 442 | } else { |
443 | 443 | global $wpdb; |
444 | - $results = $wpdb->{$type}($query); |
|
444 | + $results = $wpdb->{$type}( $query ); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | if ( ! self::prevent_caching() ) { |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | // then check the transient |
468 | - $results = get_transient($cache_key); |
|
468 | + $results = get_transient( $cache_key ); |
|
469 | 469 | if ( $results ) { |
470 | - wp_cache_set($cache_key, $results); |
|
470 | + wp_cache_set( $cache_key, $results ); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | return $results; |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $cache_key |
479 | 479 | */ |
480 | 480 | public static function delete_cache_and_transient( $cache_key ) { |
481 | - delete_transient($cache_key); |
|
482 | - wp_cache_delete($cache_key); |
|
481 | + delete_transient( $cache_key ); |
|
482 | + wp_cache_delete( $cache_key ); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -494,14 +494,14 @@ discard block |
||
494 | 494 | global $wp_object_cache; |
495 | 495 | |
496 | 496 | if ( is_callable( array( $wp_object_cache, '__get' ) ) ) { |
497 | - $group_cache = $wp_object_cache->__get('cache'); |
|
497 | + $group_cache = $wp_object_cache->__get( 'cache' ); |
|
498 | 498 | } else { |
499 | 499 | // version < 4.0 fallback |
500 | 500 | $group_cache = $wp_object_cache->cache; |
501 | 501 | } |
502 | 502 | |
503 | - if ( isset( $group_cache[ $group ] ) ) { |
|
504 | - foreach ( $group_cache[ $group ] as $k => $v ) { |
|
503 | + if ( isset( $group_cache[$group] ) ) { |
|
504 | + foreach ( $group_cache[$group] as $k => $v ) { |
|
505 | 505 | wp_cache_delete( $k, $group ); |
506 | 506 | } |
507 | 507 | return true; |
@@ -533,29 +533,29 @@ discard block |
||
533 | 533 | public static function load_scripts( $scripts ) { |
534 | 534 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
535 | 535 | foreach ( (array) $scripts as $s ) { |
536 | - wp_enqueue_script($s); |
|
536 | + wp_enqueue_script( $s ); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
540 | 540 | public static function load_styles( $styles ) { |
541 | 541 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
542 | 542 | foreach ( (array) $styles as $s ) { |
543 | - wp_enqueue_style($s); |
|
543 | + wp_enqueue_style( $s ); |
|
544 | 544 | } |
545 | 545 | } |
546 | 546 | |
547 | 547 | public static function get_pages() { |
548 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
548 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
552 | 552 | $pages = self::get_pages(); |
553 | 553 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
554 | 554 | ?> |
555 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
555 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
556 | 556 | <option value=""> </option> |
557 | 557 | <?php foreach ( $pages as $page ) { ?> |
558 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
558 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
559 | 559 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
560 | 560 | </option> |
561 | 561 | <?php } ?> |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | public static function post_edit_link( $post_id ) { |
567 | - $post = get_post($post_id); |
|
567 | + $post = get_post( $post_id ); |
|
568 | 568 | if ( $post ) { |
569 | 569 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
570 | 570 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -574,17 +574,17 @@ discard block |
||
574 | 574 | |
575 | 575 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
576 | 576 | ?> |
577 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
577 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
578 | 578 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
579 | 579 | ?> class="frm_multiselect"> |
580 | - <?php self::roles_options($capability); ?> |
|
580 | + <?php self::roles_options( $capability ); ?> |
|
581 | 581 | </select> |
582 | 582 | <?php |
583 | 583 | } |
584 | 584 | |
585 | 585 | public static function roles_options( $capability ) { |
586 | 586 | global $frm_vars; |
587 | - if ( isset($frm_vars['editable_roles']) ) { |
|
587 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
588 | 588 | $editable_roles = $frm_vars['editable_roles']; |
589 | 589 | } else { |
590 | 590 | $editable_roles = get_editable_roles(); |
@@ -592,10 +592,10 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | foreach ( $editable_roles as $role => $details ) { |
595 | - $name = translate_user_role($details['name'] ); ?> |
|
596 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
595 | + $name = translate_user_role( $details['name'] ); ?> |
|
596 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
597 | 597 | <?php |
598 | - unset($role, $details); |
|
598 | + unset( $role, $details ); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | public static function maybe_add_permissions() { |
652 | 652 | self::force_capability( 'frm_view_entries' ); |
653 | 653 | |
654 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
654 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
655 | 655 | return; |
656 | 656 | } |
657 | 657 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | $frm_roles = self::frm_capabilities(); |
661 | 661 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
662 | 662 | $user->add_cap( $frm_role ); |
663 | - unset($frm_role, $frm_role_description); |
|
663 | + unset( $frm_role, $frm_role_description ); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
@@ -685,12 +685,12 @@ discard block |
||
685 | 685 | * @param string $permission |
686 | 686 | */ |
687 | 687 | public static function permission_check( $permission, $show_message = 'show' ) { |
688 | - $permission_error = self::permission_nonce_error($permission); |
|
688 | + $permission_error = self::permission_nonce_error( $permission ); |
|
689 | 689 | if ( $permission_error !== false ) { |
690 | 690 | if ( 'hide' == $show_message ) { |
691 | 691 | $permission_error = ''; |
692 | 692 | } |
693 | - wp_die($permission_error); |
|
693 | + wp_die( $permission_error ); |
|
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
@@ -707,11 +707,11 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | $error = false; |
710 | - if ( empty($nonce_name) ) { |
|
710 | + if ( empty( $nonce_name ) ) { |
|
711 | 711 | return $error; |
712 | 712 | } |
713 | 713 | |
714 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
714 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
715 | 715 | $frm_settings = self::get_settings(); |
716 | 716 | $error = $frm_settings->admin_permission; |
717 | 717 | } |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | } else { |
792 | 792 | foreach ( $value as $k => $v ) { |
793 | 793 | if ( ! is_array( $v ) ) { |
794 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
794 | + $value[$k] = call_user_func( $original_function, $v ); |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | } |
@@ -812,11 +812,11 @@ discard block |
||
812 | 812 | public static function array_flatten( $array, $keys = 'keep' ) { |
813 | 813 | $return = array(); |
814 | 814 | foreach ( $array as $key => $value ) { |
815 | - if ( is_array($value) ) { |
|
815 | + if ( is_array( $value ) ) { |
|
816 | 816 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
817 | 817 | } else { |
818 | 818 | if ( $keys == 'keep' ) { |
819 | - $return[ $key ] = $value; |
|
819 | + $return[$key] = $value; |
|
820 | 820 | } else { |
821 | 821 | $return[] = $value; |
822 | 822 | } |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | * @since 2.0 |
838 | 838 | */ |
839 | 839 | public static function use_wpautop( $content ) { |
840 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
841 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
840 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
841 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
842 | 842 | } |
843 | 843 | return $content; |
844 | 844 | } |
@@ -856,8 +856,8 @@ discard block |
||
856 | 856 | * @return string The base Google APIS url for the current version of jQuery UI |
857 | 857 | */ |
858 | 858 | public static function jquery_ui_base_url() { |
859 | - $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version('jquery-ui-core'); |
|
860 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
859 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
860 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
861 | 861 | return $url; |
862 | 862 | } |
863 | 863 | |
@@ -872,11 +872,11 @@ discard block |
||
872 | 872 | |
873 | 873 | $ver = 0; |
874 | 874 | |
875 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
875 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
876 | 876 | return $ver; |
877 | 877 | } |
878 | 878 | |
879 | - $query = $wp_scripts->registered[ $handle ]; |
|
879 | + $query = $wp_scripts->registered[$handle]; |
|
880 | 880 | if ( is_object( $query ) ) { |
881 | 881 | $ver = $query->ver; |
882 | 882 | } |
@@ -889,36 +889,36 @@ discard block |
||
889 | 889 | } |
890 | 890 | |
891 | 891 | public static function get_user_id_param( $user_id ) { |
892 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
892 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
893 | 893 | return $user_id; |
894 | 894 | } |
895 | 895 | |
896 | 896 | if ( $user_id == 'current' ) { |
897 | 897 | $user_id = get_current_user_id(); |
898 | 898 | } else { |
899 | - if ( is_email($user_id) ) { |
|
900 | - $user = get_user_by('email', $user_id); |
|
899 | + if ( is_email( $user_id ) ) { |
|
900 | + $user = get_user_by( 'email', $user_id ); |
|
901 | 901 | } else { |
902 | - $user = get_user_by('login', $user_id); |
|
902 | + $user = get_user_by( 'login', $user_id ); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | if ( $user ) { |
906 | 906 | $user_id = $user->ID; |
907 | 907 | } |
908 | - unset($user); |
|
908 | + unset( $user ); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | return $user_id; |
912 | 912 | } |
913 | 913 | |
914 | 914 | public static function get_file_contents( $filename, $atts = array() ) { |
915 | - if ( ! is_file($filename) ) { |
|
915 | + if ( ! is_file( $filename ) ) { |
|
916 | 916 | return false; |
917 | 917 | } |
918 | 918 | |
919 | - extract($atts); |
|
919 | + extract( $atts ); |
|
920 | 920 | ob_start(); |
921 | - include($filename); |
|
921 | + include( $filename ); |
|
922 | 922 | $contents = ob_get_contents(); |
923 | 923 | ob_end_clean(); |
924 | 924 | return $contents; |
@@ -934,28 +934,28 @@ discard block |
||
934 | 934 | $key = ''; |
935 | 935 | |
936 | 936 | if ( ! empty( $name ) ) { |
937 | - $key = sanitize_key($name); |
|
937 | + $key = sanitize_key( $name ); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | if ( empty( $key ) ) { |
941 | - $max_slug_value = pow(36, $num_chars); |
|
941 | + $max_slug_value = pow( 36, $num_chars ); |
|
942 | 942 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
943 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
943 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
944 | 944 | } |
945 | 945 | |
946 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
946 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
947 | 947 | $key = $key . 'a'; |
948 | 948 | } |
949 | 949 | |
950 | 950 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
951 | 951 | |
952 | - if ( $key_check || is_numeric($key_check) ) { |
|
952 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
953 | 953 | $suffix = 2; |
954 | 954 | do { |
955 | 955 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
956 | 956 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
957 | - $suffix++; |
|
958 | - } while ($key_check || is_numeric($key_check)); |
|
957 | + $suffix ++; |
|
958 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
959 | 959 | $key = $alt_post_name; |
960 | 960 | } |
961 | 961 | return $key; |
@@ -971,32 +971,32 @@ discard block |
||
971 | 971 | return false; |
972 | 972 | } |
973 | 973 | |
974 | - if ( empty($post_values) ) { |
|
975 | - $post_values = stripslashes_deep($_POST); |
|
974 | + if ( empty( $post_values ) ) { |
|
975 | + $post_values = stripslashes_deep( $_POST ); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | $values = array( 'id' => $record->id, 'fields' => array() ); |
979 | 979 | |
980 | 980 | foreach ( array( 'name', 'description' ) as $var ) { |
981 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
982 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
983 | - unset($var, $default_val); |
|
981 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
982 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
983 | + unset( $var, $default_val ); |
|
984 | 984 | } |
985 | 985 | |
986 | - $values['description'] = self::use_wpautop($values['description']); |
|
986 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
987 | 987 | $frm_settings = self::get_settings(); |
988 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
988 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
989 | 989 | |
990 | 990 | foreach ( (array) $fields as $field ) { |
991 | 991 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
992 | 992 | if ( ! $is_form_builder ) { |
993 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
993 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
994 | 994 | } |
995 | 995 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
996 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
996 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
997 | 997 | } |
998 | 998 | |
999 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
999 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
1000 | 1000 | |
1001 | 1001 | if ( $table == 'entries' ) { |
1002 | 1002 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1013,8 +1013,8 @@ discard block |
||
1013 | 1013 | if ( $args['default'] ) { |
1014 | 1014 | $meta_value = $field->default_value; |
1015 | 1015 | } else { |
1016 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1017 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1016 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1017 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1018 | 1018 | $field->field_options['custom_field'] = ''; |
1019 | 1019 | } |
1020 | 1020 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -1023,8 +1023,8 @@ discard block |
||
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
1027 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1026 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1027 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1028 | 1028 | |
1029 | 1029 | $field_array = array( |
1030 | 1030 | 'id' => $field->id, |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | 'default_value' => $field->default_value, |
1033 | 1033 | 'name' => $field->name, |
1034 | 1034 | 'description' => $field->description, |
1035 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1035 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1036 | 1036 | 'options' => $field->options, |
1037 | 1037 | 'required' => $field->required, |
1038 | 1038 | 'field_key' => $field->field_key, |
@@ -1042,40 +1042,40 @@ discard block |
||
1042 | 1042 | ); |
1043 | 1043 | |
1044 | 1044 | $args['field_type'] = $field_type; |
1045 | - self::fill_field_opts($field, $field_array, $args); |
|
1045 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1046 | 1046 | // Track the original field's type |
1047 | 1047 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
1048 | 1048 | |
1049 | 1049 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
1050 | 1050 | |
1051 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1051 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1052 | 1052 | $field_array['unique_msg'] = ''; |
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | $field_array = array_merge( $field->field_options, $field_array ); |
1056 | 1056 | |
1057 | - $values['fields'][ $field->id ] = $field_array; |
|
1057 | + $values['fields'][$field->id] = $field_array; |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1061 | 1061 | $post_values = $args['post_values']; |
1062 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1062 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1063 | 1063 | |
1064 | 1064 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1065 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1066 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1067 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1068 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1065 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
1066 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1067 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1068 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1069 | 1069 | if ( $args['field_type'] == 'captcha' ) { |
1070 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1070 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1071 | 1071 | } else { |
1072 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1072 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1073 | 1073 | } |
1074 | 1074 | } |
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | if ( $field_array['custom_html'] == '' ) { |
1078 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1078 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
@@ -1094,18 +1094,18 @@ discard block |
||
1094 | 1094 | return; |
1095 | 1095 | } |
1096 | 1096 | |
1097 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1097 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1098 | 1098 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1099 | 1099 | |
1100 | - if ( ! is_array($form->options) ) { |
|
1100 | + if ( ! is_array( $form->options ) ) { |
|
1101 | 1101 | return; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | foreach ( $form->options as $opt => $value ) { |
1105 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1105 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | - self::fill_form_defaults($post_values, $values); |
|
1108 | + self::fill_form_defaults( $post_values, $values ); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | /** |
@@ -1115,23 +1115,23 @@ discard block |
||
1115 | 1115 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1116 | 1116 | |
1117 | 1117 | foreach ( $form_defaults as $opt => $default ) { |
1118 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1119 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1118 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1119 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | - unset($opt, $defaut); |
|
1122 | + unset( $opt, $defaut ); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | - if ( ! isset($values['custom_style']) ) { |
|
1125 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1126 | 1126 | $frm_settings = self::get_settings(); |
1127 | 1127 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1131 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
1132 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1131 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1132 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1133 | 1133 | } |
1134 | - unset($h); |
|
1134 | + unset( $h ); |
|
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | |
@@ -1147,9 +1147,9 @@ discard block |
||
1147 | 1147 | } |
1148 | 1148 | ?> |
1149 | 1149 | <li> |
1150 | - <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> |
|
1151 | - <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> |
|
1152 | - <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> |
|
1150 | + <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> |
|
1151 | + <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> |
|
1152 | + <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> |
|
1153 | 1153 | </li> |
1154 | 1154 | <?php |
1155 | 1155 | } |
@@ -1177,7 +1177,7 @@ discard block |
||
1177 | 1177 | return ''; |
1178 | 1178 | } else if ( $length <= 10 ) { |
1179 | 1179 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1180 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1180 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | $sub = ''; |
@@ -1186,23 +1186,23 @@ discard block |
||
1186 | 1186 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1187 | 1187 | |
1188 | 1188 | foreach ( $words as $word ) { |
1189 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1189 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1190 | 1190 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1191 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1191 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1192 | 1192 | break; |
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | $sub .= $part; |
1196 | 1196 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1197 | 1197 | |
1198 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1198 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1199 | 1199 | break; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - unset($total_len, $word); |
|
1202 | + unset( $total_len, $word ); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1205 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | public static function mb_function( $function_names, $args ) { |
@@ -1215,17 +1215,17 @@ discard block |
||
1215 | 1215 | } |
1216 | 1216 | |
1217 | 1217 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1218 | - if ( empty($date) ) { |
|
1218 | + if ( empty( $date ) ) { |
|
1219 | 1219 | return $date; |
1220 | 1220 | } |
1221 | 1221 | |
1222 | - if ( empty($date_format) ) { |
|
1223 | - $date_format = get_option('date_format'); |
|
1222 | + if ( empty( $date_format ) ) { |
|
1223 | + $date_format = get_option( 'date_format' ); |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1226 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1227 | 1227 | $frmpro_settings = new FrmProSettings(); |
1228 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1228 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | |
1241 | 1241 | private static function add_time_to_date( $time_format, $date ) { |
1242 | 1242 | if ( empty( $time_format ) ) { |
1243 | - $time_format = get_option('time_format'); |
|
1243 | + $time_format = get_option( 'time_format' ); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | $trimmed_format = trim( $time_format ); |
@@ -1286,10 +1286,10 @@ discard block |
||
1286 | 1286 | $time_strings = self::get_time_strings(); |
1287 | 1287 | |
1288 | 1288 | foreach ( $time_strings as $k => $v ) { |
1289 | - if ( $diff[ $k ] ) { |
|
1290 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1289 | + if ( $diff[$k] ) { |
|
1290 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1291 | 1291 | } else { |
1292 | - unset( $time_strings[ $k ] ); |
|
1292 | + unset( $time_strings[$k] ); |
|
1293 | 1293 | } |
1294 | 1294 | } |
1295 | 1295 | |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | */ |
1328 | 1328 | public static function esc_like( $term ) { |
1329 | 1329 | global $wpdb; |
1330 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1330 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1331 | 1331 | // WP 4.0 |
1332 | 1332 | $term = $wpdb->esc_like( $term ); |
1333 | 1333 | } else { |
@@ -1341,17 +1341,17 @@ discard block |
||
1341 | 1341 | * @param string $order_query |
1342 | 1342 | */ |
1343 | 1343 | public static function esc_order( $order_query ) { |
1344 | - if ( empty($order_query) ) { |
|
1344 | + if ( empty( $order_query ) ) { |
|
1345 | 1345 | return ''; |
1346 | 1346 | } |
1347 | 1347 | |
1348 | 1348 | // remove ORDER BY before santizing |
1349 | - $order_query = strtolower($order_query); |
|
1350 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1351 | - $order_query = str_replace('order by', '', $order_query); |
|
1349 | + $order_query = strtolower( $order_query ); |
|
1350 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1351 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | - $order_query = explode(' ', trim($order_query)); |
|
1354 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1355 | 1355 | |
1356 | 1356 | $order_fields = array( |
1357 | 1357 | 'id', 'form_key', 'name', 'description', |
@@ -1359,13 +1359,13 @@ discard block |
||
1359 | 1359 | 'default_template', 'status', 'created_at', |
1360 | 1360 | ); |
1361 | 1361 | |
1362 | - $order = trim(trim(reset($order_query), ',')); |
|
1363 | - if ( ! in_array($order, $order_fields) ) { |
|
1362 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1363 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1364 | 1364 | return ''; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | 1367 | $order_by = ''; |
1368 | - if ( count($order_query) > 1 ) { |
|
1368 | + if ( count( $order_query ) > 1 ) { |
|
1369 | 1369 | $order_by = end( $order_query ); |
1370 | 1370 | self::esc_order_by( $order_by ); |
1371 | 1371 | } |
@@ -1387,23 +1387,23 @@ discard block |
||
1387 | 1387 | * @param string $limit |
1388 | 1388 | */ |
1389 | 1389 | public static function esc_limit( $limit ) { |
1390 | - if ( empty($limit) ) { |
|
1390 | + if ( empty( $limit ) ) { |
|
1391 | 1391 | return ''; |
1392 | 1392 | } |
1393 | 1393 | |
1394 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1395 | - if ( is_numeric($limit) ) { |
|
1394 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1395 | + if ( is_numeric( $limit ) ) { |
|
1396 | 1396 | return ' LIMIT ' . $limit; |
1397 | 1397 | } |
1398 | 1398 | |
1399 | - $limit = explode(',', trim($limit)); |
|
1399 | + $limit = explode( ',', trim( $limit ) ); |
|
1400 | 1400 | foreach ( $limit as $k => $l ) { |
1401 | 1401 | if ( is_numeric( $l ) ) { |
1402 | - $limit[ $k ] = $l; |
|
1402 | + $limit[$k] = $l; |
|
1403 | 1403 | } |
1404 | 1404 | } |
1405 | 1405 | |
1406 | - $limit = implode(',', $limit); |
|
1406 | + $limit = implode( ',', $limit ); |
|
1407 | 1407 | return ' LIMIT ' . $limit; |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1412,12 +1412,12 @@ discard block |
||
1412 | 1412 | * @since 2.0 |
1413 | 1413 | */ |
1414 | 1414 | public static function prepare_array_values( $array, $type = '%s' ) { |
1415 | - $placeholders = array_fill(0, count($array), $type); |
|
1416 | - return implode(', ', $placeholders); |
|
1415 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1416 | + return implode( ', ', $placeholders ); |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1420 | - if ( empty($where) ) { |
|
1420 | + if ( empty( $where ) ) { |
|
1421 | 1421 | return ''; |
1422 | 1422 | } |
1423 | 1423 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | |
1464 | 1464 | public static function get_referer_info() { |
1465 | 1465 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
1466 | - return self::get_server_value('HTTP_REFERER'); |
|
1466 | + return self::get_server_value( 'HTTP_REFERER' ); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | /** |
@@ -1472,19 +1472,19 @@ discard block |
||
1472 | 1472 | public static function json_to_array( $json_vars ) { |
1473 | 1473 | $vars = array(); |
1474 | 1474 | foreach ( $json_vars as $jv ) { |
1475 | - $jv_name = explode('[', $jv['name']); |
|
1476 | - $last = count($jv_name) - 1; |
|
1475 | + $jv_name = explode( '[', $jv['name'] ); |
|
1476 | + $last = count( $jv_name ) - 1; |
|
1477 | 1477 | foreach ( $jv_name as $p => $n ) { |
1478 | - $name = trim($n, ']'); |
|
1479 | - if ( ! isset($l1) ) { |
|
1478 | + $name = trim( $n, ']' ); |
|
1479 | + if ( ! isset( $l1 ) ) { |
|
1480 | 1480 | $l1 = $name; |
1481 | 1481 | } |
1482 | 1482 | |
1483 | - if ( ! isset($l2) ) { |
|
1483 | + if ( ! isset( $l2 ) ) { |
|
1484 | 1484 | $l2 = $name; |
1485 | 1485 | } |
1486 | 1486 | |
1487 | - if ( ! isset($l3) ) { |
|
1487 | + if ( ! isset( $l3 ) ) { |
|
1488 | 1488 | $l3 = $name; |
1489 | 1489 | } |
1490 | 1490 | |
@@ -1498,24 +1498,24 @@ discard block |
||
1498 | 1498 | |
1499 | 1499 | case 1: |
1500 | 1500 | $l2 = $name; |
1501 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1501 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1502 | 1502 | break; |
1503 | 1503 | |
1504 | 1504 | case 2: |
1505 | 1505 | $l3 = $name; |
1506 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1506 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1507 | 1507 | break; |
1508 | 1508 | |
1509 | 1509 | case 3: |
1510 | 1510 | $l4 = $name; |
1511 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1511 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1512 | 1512 | break; |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - unset($this_val, $n); |
|
1515 | + unset( $this_val, $n ); |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | - unset($last, $jv); |
|
1518 | + unset( $last, $jv ); |
|
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | return $vars; |
@@ -1528,8 +1528,8 @@ discard block |
||
1528 | 1528 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1529 | 1529 | if ( $name == '' ) { |
1530 | 1530 | $vars[] = $val; |
1531 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1532 | - $vars[ $l1 ] = $val; |
|
1531 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1532 | + $vars[$l1] = $val; |
|
1533 | 1533 | } |
1534 | 1534 | } |
1535 | 1535 | |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | '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() ) ), |
1545 | 1545 | ); |
1546 | 1546 | |
1547 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1547 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1548 | 1548 | return; |
1549 | 1549 | } |
1550 | 1550 | |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | echo ' class="frm_help"'; |
1555 | 1555 | } |
1556 | 1556 | |
1557 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
1557 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1558 | 1558 | |
1559 | 1559 | if ( 'open' != $class ) { |
1560 | 1560 | echo '"'; |
@@ -1606,13 +1606,13 @@ discard block |
||
1606 | 1606 | } |
1607 | 1607 | |
1608 | 1608 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1609 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1609 | + if ( ! isset( $post_content[$key] ) ) { |
|
1610 | 1610 | return; |
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | if ( is_array( $val ) ) { |
1614 | 1614 | foreach ( $val as $k1 => $v1 ) { |
1615 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1615 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1616 | 1616 | unset( $k1, $v1 ); |
1617 | 1617 | } |
1618 | 1618 | } else { |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | $val = stripslashes( $val ); |
1621 | 1621 | |
1622 | 1622 | // Add backslashes before double quotes and forward slashes only |
1623 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1623 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1624 | 1624 | } |
1625 | 1625 | } |
1626 | 1626 | |
@@ -1637,7 +1637,7 @@ discard block |
||
1637 | 1637 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1638 | 1638 | |
1639 | 1639 | if ( empty( $settings['ID'] ) ) { |
1640 | - unset( $settings['ID']); |
|
1640 | + unset( $settings['ID'] ); |
|
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | // delete all caches for this group |
@@ -1671,17 +1671,17 @@ discard block |
||
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | public static function maybe_json_decode( $string ) { |
1674 | - if ( is_array($string) ) { |
|
1674 | + if ( is_array( $string ) ) { |
|
1675 | 1675 | return $string; |
1676 | 1676 | } |
1677 | 1677 | |
1678 | - $new_string = json_decode($string, true); |
|
1679 | - if ( function_exists('json_last_error') ) { |
|
1678 | + $new_string = json_decode( $string, true ); |
|
1679 | + if ( function_exists( 'json_last_error' ) ) { |
|
1680 | 1680 | // php 5.3+ |
1681 | 1681 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1682 | 1682 | $string = $new_string; |
1683 | 1683 | } |
1684 | - } else if ( isset($new_string) ) { |
|
1684 | + } else if ( isset( $new_string ) ) { |
|
1685 | 1685 | // php < 5.3 fallback |
1686 | 1686 | $string = $new_string; |
1687 | 1687 | } |
@@ -1697,11 +1697,11 @@ discard block |
||
1697 | 1697 | public static function maybe_highlight_menu( $post_type ) { |
1698 | 1698 | global $post; |
1699 | 1699 | |
1700 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1700 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1701 | 1701 | return; |
1702 | 1702 | } |
1703 | 1703 | |
1704 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1704 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1705 | 1705 | return; |
1706 | 1706 | } |
1707 | 1707 | |
@@ -1800,11 +1800,11 @@ discard block |
||
1800 | 1800 | $frm_version = self::plugin_version(); |
1801 | 1801 | |
1802 | 1802 | // check if Formidable meets minimum requirements |
1803 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1803 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1804 | 1804 | return; |
1805 | 1805 | } |
1806 | 1806 | |
1807 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1807 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1808 | 1808 | 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">' . |
1809 | 1809 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1810 | 1810 | '</div></td></tr>'; |
@@ -1812,38 +1812,38 @@ discard block |
||
1812 | 1812 | |
1813 | 1813 | public static function locales( $type = 'date' ) { |
1814 | 1814 | $locales = array( |
1815 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1816 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1817 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1815 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1816 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1817 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1818 | 1818 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1819 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1820 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1819 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1820 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1821 | 1821 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1822 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1823 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1822 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1823 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1824 | 1824 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1825 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1825 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1826 | 1826 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1827 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1827 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1828 | 1828 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1829 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1829 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1830 | 1830 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1831 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1832 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1833 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1834 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1835 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1831 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1832 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1833 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1834 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1835 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1836 | 1836 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1837 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1837 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1838 | 1838 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1839 | 1839 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1840 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1840 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1841 | 1841 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1842 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1842 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1843 | 1843 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1844 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1845 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1846 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1844 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1845 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1846 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1847 | 1847 | ); |
1848 | 1848 | |
1849 | 1849 | if ( $type == 'captcha' ) { |
@@ -1862,8 +1862,8 @@ discard block |
||
1862 | 1862 | ); |
1863 | 1863 | } |
1864 | 1864 | |
1865 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1866 | - $locales = apply_filters('frm_locales', $locales); |
|
1865 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1866 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1867 | 1867 | |
1868 | 1868 | return $locales; |
1869 | 1869 | } |
@@ -61,6 +61,9 @@ discard block |
||
61 | 61 | return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
62 | 62 | } |
63 | 63 | |
64 | + /** |
|
65 | + * @param integer $entry_id |
|
66 | + */ |
|
64 | 67 | public static function update_entry_metas( $entry_id, $values ) { |
65 | 68 | global $wpdb; |
66 | 69 | |
@@ -286,6 +289,7 @@ discard block |
||
286 | 289 | * @param string|array $where |
287 | 290 | * @param string $order_by |
288 | 291 | * @param string $limit |
292 | + * @param boolean $unique |
|
289 | 293 | */ |
290 | 294 | private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { |
291 | 295 | global $wpdb; |
@@ -5,25 +5,25 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntryMeta { |
7 | 7 | |
8 | - /** |
|
9 | - * @param string $meta_key |
|
10 | - */ |
|
8 | + /** |
|
9 | + * @param string $meta_key |
|
10 | + */ |
|
11 | 11 | public static function add_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
12 | - global $wpdb; |
|
12 | + global $wpdb; |
|
13 | 13 | |
14 | - if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
15 | - // don't save blank fields |
|
16 | - return; |
|
17 | - } |
|
14 | + if ( FrmAppHelper::is_empty_value( $meta_value ) ) { |
|
15 | + // don't save blank fields |
|
16 | + return; |
|
17 | + } |
|
18 | 18 | |
19 | - $new_values = array( |
|
19 | + $new_values = array( |
|
20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
21 | - 'item_id' => $entry_id, |
|
22 | - 'field_id' => $field_id, |
|
23 | - 'created_at' => current_time('mysql', 1), |
|
24 | - ); |
|
21 | + 'item_id' => $entry_id, |
|
22 | + 'field_id' => $field_id, |
|
23 | + 'created_at' => current_time('mysql', 1), |
|
24 | + ); |
|
25 | 25 | |
26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
26 | + $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
27 | 27 | |
28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
29 | 29 | |
@@ -34,40 +34,40 @@ discard block |
||
34 | 34 | $id = 0; |
35 | 35 | } |
36 | 36 | |
37 | - return $id; |
|
38 | - } |
|
37 | + return $id; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $meta_key |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @param string $meta_key |
|
42 | + */ |
|
43 | 43 | public static function update_entry_meta( $entry_id, $field_id, $meta_key = null, $meta_value ) { |
44 | - if ( ! $field_id ) { |
|
45 | - return false; |
|
46 | - } |
|
44 | + if ( ! $field_id ) { |
|
45 | + return false; |
|
46 | + } |
|
47 | 47 | |
48 | - global $wpdb; |
|
48 | + global $wpdb; |
|
49 | 49 | |
50 | - $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
|
51 | - $values['meta_value'] = $meta_value; |
|
52 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
50 | + $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
|
51 | + $values['meta_value'] = $meta_value; |
|
52 | + $values = apply_filters('frm_update_entry_meta', $values); |
|
53 | 53 | if ( is_array($values['meta_value']) ) { |
54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
55 | 55 | } |
56 | - $meta_value = maybe_serialize($values['meta_value']); |
|
56 | + $meta_value = maybe_serialize($values['meta_value']); |
|
57 | 57 | |
58 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
58 | + wp_cache_delete( $entry_id, 'frm_entry'); |
|
59 | 59 | self::clear_cache(); |
60 | 60 | |
61 | 61 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | public static function update_entry_metas( $entry_id, $values ) { |
65 | - global $wpdb; |
|
65 | + global $wpdb; |
|
66 | 66 | |
67 | 67 | $prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
68 | 68 | |
69 | - foreach ( $values as $field_id => $meta_value ) { |
|
70 | - // set the value for the file upload field and add new tags (in Pro version) |
|
69 | + foreach ( $values as $field_id => $meta_value ) { |
|
70 | + // set the value for the file upload field and add new tags (in Pro version) |
|
71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); |
72 | 72 | |
73 | 73 | if ( $prev_values && in_array($field_id, $prev_values) ) { |
@@ -85,39 +85,39 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( empty($prev_values) ) { |
|
89 | - return; |
|
90 | - } |
|
88 | + if ( empty($prev_values) ) { |
|
89 | + return; |
|
90 | + } |
|
91 | 91 | |
92 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
92 | + $prev_values = array_diff($prev_values, array_keys($values)); |
|
93 | 93 | |
94 | - if ( empty($prev_values) ) { |
|
95 | - return; |
|
96 | - } |
|
94 | + if ( empty($prev_values) ) { |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | // prepare the query |
99 | 99 | $where = array( 'item_id' => $entry_id, 'field_id' => $prev_values ); |
100 | 100 | FrmDb::get_where_clause_and_values( $where ); |
101 | 101 | |
102 | - // Delete any leftovers |
|
103 | - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
102 | + // Delete any leftovers |
|
103 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values'] ) ); |
|
104 | 104 | self::clear_cache(); |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
108 | - $metas = self::get_entry_meta_info($old_id); |
|
109 | - foreach ( $metas as $meta ) { |
|
110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | - unset($meta); |
|
112 | - } |
|
108 | + $metas = self::get_entry_meta_info($old_id); |
|
109 | + foreach ( $metas as $meta ) { |
|
110 | + self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | + unset($meta); |
|
112 | + } |
|
113 | 113 | self::clear_cache(); |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | 116 | public static function delete_entry_meta( $entry_id, $field_id ) { |
117 | - global $wpdb; |
|
117 | + global $wpdb; |
|
118 | 118 | self::clear_cache(); |
119 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
120 | - } |
|
119 | + return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Clear entry meta caching |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | public static function get_entry_meta_by_field( $entry_id, $field_id ) { |
145 | - global $wpdb; |
|
145 | + global $wpdb; |
|
146 | 146 | |
147 | 147 | if ( is_object( $entry_id ) ) { |
148 | 148 | $entry = $entry_id; |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | |
156 | 156 | if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
157 | 157 | $result = $cached->metas[ $field_id ]; |
158 | - return stripslashes_deep($result); |
|
159 | - } |
|
158 | + return stripslashes_deep($result); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | $get_table = $wpdb->prefix . 'frm_item_metas'; |
162 | 162 | $query = array( 'item_id' => $entry_id ); |
163 | - if ( is_numeric($field_id) ) { |
|
163 | + if ( is_numeric($field_id) ) { |
|
164 | 164 | $query['field_id'] = $field_id; |
165 | - } else { |
|
165 | + } else { |
|
166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
167 | 167 | $query['fi.field_key'] = $field_id; |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
171 | - $result = maybe_unserialize($result); |
|
172 | - $result = stripslashes_deep($result); |
|
171 | + $result = maybe_unserialize($result); |
|
172 | + $result = stripslashes_deep($result); |
|
173 | 173 | |
174 | - return $result; |
|
175 | - } |
|
174 | + return $result; |
|
175 | + } |
|
176 | 176 | |
177 | 177 | public static function get_entry_meta( $entry_id, $field_id ) { |
178 | 178 | _deprecated_function( __FUNCTION__, '2.0', 'FrmEntryMeta::get_entry_meta_by_field' ); |
@@ -180,117 +180,117 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public static function get_entry_metas( $entry_id ) { |
183 | - _deprecated_function( __FUNCTION__, '1.07.10'); |
|
183 | + _deprecated_function( __FUNCTION__, '1.07.10'); |
|
184 | 184 | |
185 | - global $wpdb; |
|
185 | + global $wpdb; |
|
186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
189 | + public static function get_entry_metas_for_field( $field_id, $order = '', $limit = '', $args = array() ) { |
|
190 | 190 | $defaults = array( 'value' => false, 'unique' => false, 'stripslashes' => true, 'is_draft' => false ); |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args( $args, $defaults ); |
|
192 | 192 | |
193 | - $query = array(); |
|
194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | - $query = implode(' ', $query); |
|
193 | + $query = array(); |
|
194 | + self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | + $query = implode(' ', $query); |
|
196 | 196 | |
197 | 197 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); |
198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
198 | + $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
199 | 199 | |
200 | - if ( ! $args['stripslashes'] ) { |
|
201 | - return $values; |
|
202 | - } |
|
200 | + if ( ! $args['stripslashes'] ) { |
|
201 | + return $values; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | foreach ( $values as $k => $v ) { |
205 | 205 | $values[ $k ] = maybe_unserialize( $v ); |
206 | - unset($k, $v); |
|
207 | - } |
|
206 | + unset($k, $v); |
|
207 | + } |
|
208 | 208 | |
209 | - return stripslashes_deep($values); |
|
210 | - } |
|
209 | + return stripslashes_deep($values); |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param string $order |
|
214 | - * @param string $limit |
|
215 | - */ |
|
212 | + /** |
|
213 | + * @param string $order |
|
214 | + * @param string $limit |
|
215 | + */ |
|
216 | 216 | private static function meta_field_query( $field_id, $order, $limit, $args, array &$query ) { |
217 | - global $wpdb; |
|
218 | - $query[] = 'SELECT'; |
|
219 | - $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
217 | + global $wpdb; |
|
218 | + $query[] = 'SELECT'; |
|
219 | + $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
220 | 220 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em '; |
221 | 221 | |
222 | - if ( ! $args['is_draft'] ) { |
|
222 | + if ( ! $args['is_draft'] ) { |
|
223 | 223 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; |
224 | - } |
|
224 | + } |
|
225 | 225 | |
226 | - if ( is_numeric($field_id) ) { |
|
227 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | - } else { |
|
226 | + if ( is_numeric($field_id) ) { |
|
227 | + $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | + } else { |
|
229 | 229 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - if ( ! $args['is_draft'] ) { |
|
233 | - $query[] = 'AND e.is_draft=0'; |
|
234 | - } |
|
232 | + if ( ! $args['is_draft'] ) { |
|
233 | + $query[] = 'AND e.is_draft=0'; |
|
234 | + } |
|
235 | 235 | |
236 | - if ( $args['value'] ) { |
|
237 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
238 | - } |
|
239 | - $query[] = $order . $limit; |
|
240 | - } |
|
236 | + if ( $args['value'] ) { |
|
237 | + $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
238 | + } |
|
239 | + $query[] = $order . $limit; |
|
240 | + } |
|
241 | 241 | |
242 | 242 | public static function get_entry_meta_info( $entry_id ) { |
243 | 243 | return FrmDb::get_results( 'frm_item_metas', array( 'item_id' => $entry_id ) ); |
244 | - } |
|
244 | + } |
|
245 | 245 | |
246 | 246 | public static function getAll( $where = array(), $order_by = '', $limit = '', $stripslashes = false ) { |
247 | - global $wpdb; |
|
248 | - $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
247 | + global $wpdb; |
|
248 | + $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
|
249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
250 | 250 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . |
251 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
251 | + FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
252 | 252 | |
253 | 253 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; |
254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
254 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
255 | 255 | |
256 | - if ( ! $results || ! $stripslashes ) { |
|
257 | - return $results; |
|
258 | - } |
|
256 | + if ( ! $results || ! $stripslashes ) { |
|
257 | + return $results; |
|
258 | + } |
|
259 | 259 | |
260 | - foreach ( $results as $k => $result ) { |
|
260 | + foreach ( $results as $k => $result ) { |
|
261 | 261 | $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
262 | - unset($k, $result); |
|
263 | - } |
|
262 | + unset($k, $result); |
|
263 | + } |
|
264 | 264 | |
265 | - return $results; |
|
266 | - } |
|
265 | + return $results; |
|
266 | + } |
|
267 | 267 | |
268 | - public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
268 | + public static function getEntryIds( $where = array(), $order_by = '', $limit = '', $unique = true, $args = array() ) { |
|
269 | 269 | $defaults = array( |
270 | 270 | 'is_draft' => false, |
271 | 271 | 'user_id' => '', |
272 | 272 | 'group_by' => '', |
273 | 273 | ); |
274 | - $args = wp_parse_args($args, $defaults); |
|
274 | + $args = wp_parse_args($args, $defaults); |
|
275 | 275 | |
276 | - $query = array(); |
|
277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | - $query = implode(' ', $query); |
|
276 | + $query = array(); |
|
277 | + self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | + $query = implode(' ', $query); |
|
279 | 279 | |
280 | 280 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l'. $limit . 'u'. $unique . maybe_serialize( $args ); |
281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
281 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
282 | 282 | |
283 | - return $results; |
|
284 | - } |
|
283 | + return $results; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * @param string|array $where |
|
288 | - * @param string $order_by |
|
289 | - * @param string $limit |
|
290 | - */ |
|
286 | + /** |
|
287 | + * @param string|array $where |
|
288 | + * @param string $order_by |
|
289 | + * @param string $limit |
|
290 | + */ |
|
291 | 291 | private static function get_ids_query( $where, $order_by, $limit, $unique, $args, array &$query ) { |
292 | - global $wpdb; |
|
293 | - $query[] = 'SELECT'; |
|
292 | + global $wpdb; |
|
293 | + $query[] = 'SELECT'; |
|
294 | 294 | |
295 | 295 | $defaults = array( 'return_parent_id' => false ); |
296 | 296 | $args = array_merge( $defaults, $args ); |
@@ -304,88 +304,88 @@ discard block |
||
304 | 304 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
305 | 305 | |
306 | 306 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
307 | - if ( is_array($where) ) { |
|
308 | - if ( ! $args['is_draft'] ) { |
|
309 | - $where['e.is_draft'] = 0; |
|
310 | - } else if ( $args['is_draft'] == 1 ) { |
|
311 | - $where['e.is_draft'] = 1; |
|
312 | - } |
|
313 | - |
|
314 | - if ( ! empty($args['user_id']) ) { |
|
315 | - $where['e.user_id'] = $args['user_id']; |
|
316 | - } |
|
317 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
307 | + if ( is_array($where) ) { |
|
308 | + if ( ! $args['is_draft'] ) { |
|
309 | + $where['e.is_draft'] = 0; |
|
310 | + } else if ( $args['is_draft'] == 1 ) { |
|
311 | + $where['e.is_draft'] = 1; |
|
312 | + } |
|
313 | + |
|
314 | + if ( ! empty($args['user_id']) ) { |
|
315 | + $where['e.user_id'] = $args['user_id']; |
|
316 | + } |
|
317 | + $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
318 | 318 | |
319 | 319 | if ( $args['group_by'] ) { |
320 | 320 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
321 | 321 | } |
322 | - return; |
|
323 | - } |
|
322 | + return; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | $draft_where = $user_where = ''; |
326 | - if ( ! $args['is_draft'] ) { |
|
326 | + if ( ! $args['is_draft'] ) { |
|
327 | 327 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 0 ); |
328 | - } else if ( $args['is_draft'] == 1 ) { |
|
328 | + } else if ( $args['is_draft'] == 1 ) { |
|
329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
330 | - } |
|
330 | + } |
|
331 | 331 | |
332 | - if ( ! empty($args['user_id']) ) { |
|
333 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | - } |
|
332 | + if ( ! empty($args['user_id']) ) { |
|
333 | + $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | + } |
|
335 | 335 | |
336 | - if ( strpos($where, ' GROUP BY ') ) { |
|
337 | - // don't inject WHERE filtering after GROUP BY |
|
338 | - $parts = explode(' GROUP BY ', $where); |
|
339 | - $where = $parts[0]; |
|
340 | - $where .= $draft_where . $user_where; |
|
336 | + if ( strpos($where, ' GROUP BY ') ) { |
|
337 | + // don't inject WHERE filtering after GROUP BY |
|
338 | + $parts = explode(' GROUP BY ', $where); |
|
339 | + $where = $parts[0]; |
|
340 | + $where .= $draft_where . $user_where; |
|
341 | 341 | $where .= ' GROUP BY ' . $parts[1]; |
342 | - } else { |
|
343 | - $where .= $draft_where . $user_where; |
|
344 | - } |
|
342 | + } else { |
|
343 | + $where .= $draft_where . $user_where; |
|
344 | + } |
|
345 | 345 | |
346 | 346 | // The query has already been prepared |
347 | 347 | $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | - public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
350 | + public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
351 | 351 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
352 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
353 | - if ( false !== $results ) { |
|
354 | - return $results; |
|
355 | - } |
|
352 | + $results = wp_cache_get($cache_key, 'frm_entry'); |
|
353 | + if ( false !== $results ) { |
|
354 | + return $results; |
|
355 | + } |
|
356 | 356 | |
357 | - global $wpdb; |
|
357 | + global $wpdb; |
|
358 | 358 | if ( is_array( $search ) ) { |
359 | - $where = ''; |
|
359 | + $where = ''; |
|
360 | 360 | foreach ( $search as $field => $value ) { |
361 | 361 | if ( $value <= 0 || ! in_array( $field, array( 'year', 'month', 'day' ) ) ) { |
362 | - continue; |
|
363 | - } |
|
362 | + continue; |
|
363 | + } |
|
364 | 364 | |
365 | - switch ( $field ) { |
|
366 | - case 'year': |
|
365 | + switch ( $field ) { |
|
366 | + case 'year': |
|
367 | 367 | $value = '%' . $value; |
368 | - break; |
|
369 | - case 'month': |
|
370 | - $value .= '%'; |
|
371 | - break; |
|
372 | - case 'day': |
|
368 | + break; |
|
369 | + case 'month': |
|
370 | + $value .= '%'; |
|
371 | + break; |
|
372 | + case 'day': |
|
373 | 373 | $value = '%' . $value . '%'; |
374 | - } |
|
374 | + } |
|
375 | 375 | $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); |
376 | - } |
|
377 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
376 | + } |
|
377 | + $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | 378 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
379 | - } else { |
|
379 | + } else { |
|
380 | 380 | if ( $operator == 'LIKE' ) { |
381 | - $search = '%' . $search . '%'; |
|
381 | + $search = '%' . $search . '%'; |
|
382 | 382 | } |
383 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
384 | - } |
|
383 | + $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
384 | + } |
|
385 | 385 | |
386 | - $results = $wpdb->get_col($query, 0); |
|
387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
386 | + $results = $wpdb->get_col($query, 0); |
|
387 | + wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
388 | 388 | |
389 | - return $results; |
|
390 | - } |
|
389 | + return $results; |
|
390 | + } |
|
391 | 391 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | 3 | die( 'You are not allowed to call this page directly.' ); |
4 | 4 | } |
5 | 5 | |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
21 | 21 | 'item_id' => $entry_id, |
22 | 22 | 'field_id' => $field_id, |
23 | - 'created_at' => current_time('mysql', 1), |
|
23 | + 'created_at' => current_time( 'mysql', 1 ), |
|
24 | 24 | ); |
25 | 25 | |
26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
26 | + $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); |
|
27 | 27 | |
28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
29 | 29 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | |
50 | 50 | $values = $where_values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
51 | 51 | $values['meta_value'] = $meta_value; |
52 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
53 | - if ( is_array($values['meta_value']) ) { |
|
52 | + $values = apply_filters( 'frm_update_entry_meta', $values ); |
|
53 | + if ( is_array( $values['meta_value'] ) ) { |
|
54 | 54 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
55 | 55 | } |
56 | - $meta_value = maybe_serialize($values['meta_value']); |
|
56 | + $meta_value = maybe_serialize( $values['meta_value'] ); |
|
57 | 57 | |
58 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
58 | + wp_cache_delete( $entry_id, 'frm_entry' ); |
|
59 | 59 | self::clear_cache(); |
60 | 60 | |
61 | 61 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | // set the value for the file upload field and add new tags (in Pro version) |
71 | 71 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id ); |
72 | 72 | |
73 | - if ( $prev_values && in_array($field_id, $prev_values) ) { |
|
73 | + if ( $prev_values && in_array( $field_id, $prev_values ) ) { |
|
74 | 74 | |
75 | 75 | if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) { |
76 | 76 | // remove blank fields |
77 | - unset( $values[ $field_id ] ); |
|
77 | + unset( $values[$field_id] ); |
|
78 | 78 | } else { |
79 | 79 | // if value exists, then update it |
80 | 80 | self::update_entry_meta( $entry_id, $field_id, '', $meta_value ); |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( empty($prev_values) ) { |
|
88 | + if ( empty( $prev_values ) ) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
92 | + $prev_values = array_diff( $prev_values, array_keys( $values ) ); |
|
93 | 93 | |
94 | - if ( empty($prev_values) ) { |
|
94 | + if ( empty( $prev_values ) ) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
108 | - $metas = self::get_entry_meta_info($old_id); |
|
108 | + $metas = self::get_entry_meta_info( $old_id ); |
|
109 | 109 | foreach ( $metas as $meta ) { |
110 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
111 | - unset($meta); |
|
110 | + self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value ); |
|
111 | + unset( $meta ); |
|
112 | 112 | } |
113 | 113 | self::clear_cache(); |
114 | 114 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | public static function delete_entry_meta( $entry_id, $field_id ) { |
117 | 117 | global $wpdb; |
118 | 118 | self::clear_cache(); |
119 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
119 | + return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function get_meta_value( $entry, $field_id ) { |
137 | 137 | if ( isset( $entry->metas ) ) { |
138 | - return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false; |
|
138 | + return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false; |
|
139 | 139 | } else { |
140 | 140 | return self::get_entry_meta_by_field( $entry->id, $field_id ); |
141 | 141 | } |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | $cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' ); |
154 | 154 | } |
155 | 155 | |
156 | - if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
|
157 | - $result = $cached->metas[ $field_id ]; |
|
158 | - return stripslashes_deep($result); |
|
156 | + if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) { |
|
157 | + $result = $cached->metas[$field_id]; |
|
158 | + return stripslashes_deep( $result ); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | $get_table = $wpdb->prefix . 'frm_item_metas'; |
162 | 162 | $query = array( 'item_id' => $entry_id ); |
163 | - if ( is_numeric($field_id) ) { |
|
163 | + if ( is_numeric( $field_id ) ) { |
|
164 | 164 | $query['field_id'] = $field_id; |
165 | 165 | } else { |
166 | 166 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
171 | - $result = maybe_unserialize($result); |
|
172 | - $result = stripslashes_deep($result); |
|
171 | + $result = maybe_unserialize( $result ); |
|
172 | + $result = stripslashes_deep( $result ); |
|
173 | 173 | |
174 | 174 | return $result; |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | public static function get_entry_metas( $entry_id ) { |
183 | - _deprecated_function( __FUNCTION__, '1.07.10'); |
|
183 | + _deprecated_function( __FUNCTION__, '1.07.10' ); |
|
184 | 184 | |
185 | 185 | global $wpdb; |
186 | 186 | return FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id ), 'meta_value' ); |
@@ -191,22 +191,22 @@ discard block |
||
191 | 191 | $args = wp_parse_args( $args, $defaults ); |
192 | 192 | |
193 | 193 | $query = array(); |
194 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
195 | - $query = implode(' ', $query); |
|
194 | + self::meta_field_query( $field_id, $order, $limit, $args, $query ); |
|
195 | + $query = implode( ' ', $query ); |
|
196 | 196 | |
197 | 197 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); |
198 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
198 | + $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' ); |
|
199 | 199 | |
200 | 200 | if ( ! $args['stripslashes'] ) { |
201 | 201 | return $values; |
202 | 202 | } |
203 | 203 | |
204 | 204 | foreach ( $values as $k => $v ) { |
205 | - $values[ $k ] = maybe_unserialize( $v ); |
|
206 | - unset($k, $v); |
|
205 | + $values[$k] = maybe_unserialize( $v ); |
|
206 | + unset( $k, $v ); |
|
207 | 207 | } |
208 | 208 | |
209 | - return stripslashes_deep($values); |
|
209 | + return stripslashes_deep( $values ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; |
224 | 224 | } |
225 | 225 | |
226 | - if ( is_numeric($field_id) ) { |
|
227 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
226 | + if ( is_numeric( $field_id ) ) { |
|
227 | + $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id ); |
|
228 | 228 | } else { |
229 | 229 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); |
230 | 230 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | if ( $args['value'] ) { |
237 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
237 | + $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] ); |
|
238 | 238 | } |
239 | 239 | $query[] = $order . $limit; |
240 | 240 | } |
@@ -248,18 +248,18 @@ discard block |
||
248 | 248 | $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
249 | 249 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
250 | 250 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . |
251 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
251 | + FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
252 | 252 | |
253 | 253 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; |
254 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
254 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) ); |
|
255 | 255 | |
256 | 256 | if ( ! $results || ! $stripslashes ) { |
257 | 257 | return $results; |
258 | 258 | } |
259 | 259 | |
260 | 260 | foreach ( $results as $k => $result ) { |
261 | - $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
262 | - unset($k, $result); |
|
261 | + $results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
262 | + unset( $k, $result ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return $results; |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | 'user_id' => '', |
272 | 272 | 'group_by' => '', |
273 | 273 | ); |
274 | - $args = wp_parse_args($args, $defaults); |
|
274 | + $args = wp_parse_args( $args, $defaults ); |
|
275 | 275 | |
276 | 276 | $query = array(); |
277 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
278 | - $query = implode(' ', $query); |
|
277 | + self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); |
|
278 | + $query = implode( ' ', $query ); |
|
279 | 279 | |
280 | 280 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args ); |
281 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
281 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) ); |
|
282 | 282 | |
283 | 283 | return $results; |
284 | 284 | } |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
305 | 305 | |
306 | 306 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
307 | - if ( is_array($where) ) { |
|
307 | + if ( is_array( $where ) ) { |
|
308 | 308 | if ( ! $args['is_draft'] ) { |
309 | 309 | $where['e.is_draft'] = 0; |
310 | 310 | } else if ( $args['is_draft'] == 1 ) { |
311 | 311 | $where['e.is_draft'] = 1; |
312 | 312 | } |
313 | 313 | |
314 | - if ( ! empty($args['user_id']) ) { |
|
314 | + if ( ! empty( $args['user_id'] ) ) { |
|
315 | 315 | $where['e.user_id'] = $args['user_id']; |
316 | 316 | } |
317 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
317 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
318 | 318 | |
319 | 319 | if ( $args['group_by'] ) { |
320 | 320 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty($args['user_id']) ) { |
|
333 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
332 | + if ( ! empty( $args['user_id'] ) ) { |
|
333 | + $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] ); |
|
334 | 334 | } |
335 | 335 | |
336 | - if ( strpos($where, ' GROUP BY ') ) { |
|
336 | + if ( strpos( $where, ' GROUP BY ' ) ) { |
|
337 | 337 | // don't inject WHERE filtering after GROUP BY |
338 | - $parts = explode(' GROUP BY ', $where); |
|
338 | + $parts = explode( ' GROUP BY ', $where ); |
|
339 | 339 | $where = $parts[0]; |
340 | 340 | $where .= $draft_where . $user_where; |
341 | 341 | $where .= ' GROUP BY ' . $parts[1]; |
@@ -344,12 +344,12 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // The query has already been prepared |
347 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
347 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | public static function search_entry_metas( $search, $field_id = '', $operator ) { |
351 | 351 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
352 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
352 | + $results = wp_cache_get( $cache_key, 'frm_entry' ); |
|
353 | 353 | if ( false !== $results ) { |
354 | 354 | return $results; |
355 | 355 | } |
@@ -372,19 +372,19 @@ discard block |
||
372 | 372 | case 'day': |
373 | 373 | $value = '%' . $value . '%'; |
374 | 374 | } |
375 | - $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); |
|
375 | + $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value ); |
|
376 | 376 | } |
377 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
377 | + $where .= $wpdb->prepare( ' field_id=%d', $field_id ); |
|
378 | 378 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
379 | 379 | } else { |
380 | 380 | if ( $operator == 'LIKE' ) { |
381 | 381 | $search = '%' . $search . '%'; |
382 | 382 | } |
383 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
383 | + $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); |
|
384 | 384 | } |
385 | 385 | |
386 | - $results = $wpdb->get_col($query, 0); |
|
387 | - wp_cache_set($cache_key, $results, 'frm_entry', 300); |
|
386 | + $results = $wpdb->get_col( $query, 0 ); |
|
387 | + wp_cache_set( $cache_key, $results, 'frm_entry', 300 ); |
|
388 | 388 | |
389 | 389 | return $results; |
390 | 390 | } |
@@ -143,8 +143,8 @@ |
||
143 | 143 | add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
144 | 144 | |
145 | 145 | // Addons Controller |
146 | - add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | - add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
146 | + add_action( 'wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
|
147 | + add_action( 'wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
|
148 | 148 | |
149 | 149 | // Fields Controller |
150 | 150 | add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
@@ -1,91 +1,91 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmHooksController { |
4 | - /** |
|
5 | - * Trigger plugin-wide hook loading |
|
6 | - */ |
|
7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | - |
|
10 | - $trigger_hooks = $hooks; |
|
11 | - $hooks = (array) $hooks; |
|
12 | - |
|
13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | - if ( is_admin() ) { |
|
15 | - $hooks[] = 'load_admin_hooks'; |
|
16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
17 | - $hooks[] = 'load_ajax_hooks'; |
|
18 | - $hooks[] = 'load_form_hooks'; |
|
19 | - } |
|
20 | - } |
|
21 | - |
|
22 | - if ( is_multisite() ) { |
|
23 | - $hooks[] = 'load_multisite_hooks'; |
|
24 | - } |
|
25 | - } else { |
|
26 | - // Make sure the hooks are only triggered once |
|
27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | - } |
|
29 | - unset( $trigger_hooks ); |
|
30 | - |
|
31 | - // Instansiate Controllers |
|
32 | - foreach ( $controllers as $c ) { |
|
33 | - foreach ( $hooks as $hook ) { |
|
4 | + /** |
|
5 | + * Trigger plugin-wide hook loading |
|
6 | + */ |
|
7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
9 | + |
|
10 | + $trigger_hooks = $hooks; |
|
11 | + $hooks = (array) $hooks; |
|
12 | + |
|
13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
14 | + if ( is_admin() ) { |
|
15 | + $hooks[] = 'load_admin_hooks'; |
|
16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
17 | + $hooks[] = 'load_ajax_hooks'; |
|
18 | + $hooks[] = 'load_form_hooks'; |
|
19 | + } |
|
20 | + } |
|
21 | + |
|
22 | + if ( is_multisite() ) { |
|
23 | + $hooks[] = 'load_multisite_hooks'; |
|
24 | + } |
|
25 | + } else { |
|
26 | + // Make sure the hooks are only triggered once |
|
27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
28 | + } |
|
29 | + unset( $trigger_hooks ); |
|
30 | + |
|
31 | + // Instansiate Controllers |
|
32 | + foreach ( $controllers as $c ) { |
|
33 | + foreach ( $hooks as $hook ) { |
|
34 | 34 | call_user_func( array( $c, $hook ) ); |
35 | 35 | unset( $hook ); |
36 | - } |
|
36 | + } |
|
37 | 37 | unset( $c ); |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - public static function trigger_load_form_hooks() { |
|
43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | - } |
|
42 | + public static function trigger_load_form_hooks() { |
|
43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | public static function load_hooks() { |
47 | - if ( ! is_admin() ) { |
|
48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | - } |
|
50 | - |
|
51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | - |
|
54 | - // Entries controller |
|
55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
60 | - |
|
61 | - // Form Actions Controller |
|
62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
47 | + if ( ! is_admin() ) { |
|
48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
49 | + } |
|
50 | + |
|
51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
53 | + |
|
54 | + // Entries controller |
|
55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
60 | + |
|
61 | + // Form Actions Controller |
|
62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
64 | 64 | |
65 | - // Forms Controller |
|
66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
65 | + // Forms Controller |
|
66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); |
68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
72 | 72 | |
73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
74 | 74 | |
75 | - // Form Shortcodes |
|
76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
75 | + // Form Shortcodes |
|
76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
77 | 77 | |
78 | - // Styles Controller |
|
79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
83 | - } |
|
78 | + // Styles Controller |
|
79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
83 | + } |
|
84 | 84 | |
85 | 85 | public static function load_admin_hooks() { |
86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); |
91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
@@ -94,122 +94,122 @@ discard block |
||
94 | 94 | // Addons Controller |
95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
96 | 96 | |
97 | - // Entries Controller |
|
98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
97 | + // Entries Controller |
|
98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
103 | 103 | |
104 | - // Fields Controller |
|
105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
104 | + // Fields Controller |
|
105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
106 | 106 | |
107 | - // Form Actions Controller |
|
108 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
110 | - } |
|
111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
107 | + // Form Actions Controller |
|
108 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
110 | + } |
|
111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
112 | 112 | |
113 | - // Forms Controller |
|
114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
113 | + // Forms Controller |
|
114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
116 | 116 | |
117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
120 | 120 | |
121 | - // Forms Model |
|
122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
121 | + // Forms Model |
|
122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
123 | 123 | |
124 | - // Settings Controller |
|
125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
124 | + // Settings Controller |
|
125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
127 | 127 | |
128 | - // Styles Controller |
|
129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
128 | + // Styles Controller |
|
129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
131 | 131 | |
132 | - // XML Controller |
|
133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
134 | - } |
|
132 | + // XML Controller |
|
133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
134 | + } |
|
135 | 135 | |
136 | 136 | public static function load_ajax_hooks() { |
137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
142 | 142 | |
143 | 143 | // Addons |
144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
146 | 146 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
147 | 147 | |
148 | - // Fields Controller |
|
149 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
150 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
161 | - |
|
162 | - // Form Actions Controller |
|
163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
165 | - |
|
166 | - // Forms Controller |
|
148 | + // Fields Controller |
|
149 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
150 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
161 | + |
|
162 | + // Form Actions Controller |
|
163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
165 | + |
|
166 | + // Forms Controller |
|
167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
175 | - |
|
176 | - // Styles Controller |
|
177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
175 | + |
|
176 | + // Styles Controller |
|
177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
183 | 183 | |
184 | - // XML Controller |
|
184 | + // XML Controller |
|
185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
188 | - } |
|
187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public static function load_form_hooks() { |
191 | - // Fields Controller |
|
192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
191 | + // Fields Controller |
|
192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
196 | 196 | |
197 | 197 | // Forms Controller |
198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
199 | 199 | |
200 | - // Styles Controller |
|
201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
202 | - } |
|
200 | + // Styles Controller |
|
201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | public static function load_view_hooks() { |
205 | - // Hooks go here when a view is loaded |
|
206 | - } |
|
205 | + // Hooks go here when a view is loaded |
|
206 | + } |
|
207 | 207 | |
208 | 208 | public static function load_multisite_hooks() { |
209 | 209 | add_action( 'init', 'FrmAppController::front_head' ); |
210 | 210 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
211 | 211 | |
212 | - // drop tables when mu site is deleted |
|
213 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
214 | - } |
|
212 | + // drop tables when mu site is deleted |
|
213 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
214 | + } |
|
215 | 215 | } |
@@ -2,78 +2,78 @@ |
||
2 | 2 | |
3 | 3 | class FrmSettingsController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | // Make sure admins can see the menu items |
7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
8 | 8 | |
9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
10 | - } |
|
9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
10 | + } |
|
11 | 11 | |
12 | - public static function license_box() { |
|
12 | + public static function license_box() { |
|
13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
15 | - } |
|
14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
15 | + } |
|
16 | 16 | |
17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
18 | - global $frm_vars; |
|
17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
18 | + global $frm_vars; |
|
19 | 19 | |
20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
22 | 22 | |
23 | - $uploads = wp_upload_dir(); |
|
24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
23 | + $uploads = wp_upload_dir(); |
|
24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
25 | 25 | |
26 | 26 | $sections = array(); |
27 | 27 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
28 | 28 | $sections['licenses'] = array( 'class' => 'FrmAddonsController', 'function' => 'show_addons' ); |
29 | 29 | } |
30 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
30 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
31 | 31 | |
32 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
32 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
33 | 33 | |
34 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
35 | - } |
|
34 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function process_form( $stop_load = false ) { |
|
38 | - global $frm_vars; |
|
37 | + public static function process_form( $stop_load = false ) { |
|
38 | + global $frm_vars; |
|
39 | 39 | |
40 | - $frm_settings = FrmAppHelper::get_settings(); |
|
40 | + $frm_settings = FrmAppHelper::get_settings(); |
|
41 | 41 | |
42 | 42 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
43 | 43 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
44 | - wp_die( $frm_settings->admin_permission ); |
|
45 | - } |
|
44 | + wp_die( $frm_settings->admin_permission ); |
|
45 | + } |
|
46 | 46 | |
47 | - $errors = array(); |
|
48 | - $message = ''; |
|
47 | + $errors = array(); |
|
48 | + $message = ''; |
|
49 | 49 | |
50 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
51 | - //$errors = $frm_settings->validate($_POST,array()); |
|
52 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
50 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
51 | + //$errors = $frm_settings->validate($_POST,array()); |
|
52 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
53 | 53 | |
54 | - if ( empty( $errors ) ) { |
|
55 | - $frm_settings->store(); |
|
56 | - $message = __( 'Settings Saved', 'formidable' ); |
|
57 | - } |
|
58 | - } else { |
|
59 | - $message = __( 'Settings Saved', 'formidable' ); |
|
60 | - } |
|
54 | + if ( empty( $errors ) ) { |
|
55 | + $frm_settings->store(); |
|
56 | + $message = __( 'Settings Saved', 'formidable' ); |
|
57 | + } |
|
58 | + } else { |
|
59 | + $message = __( 'Settings Saved', 'formidable' ); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | if ( $stop_load == 'stop_load' ) { |
63 | - $frm_vars['settings_routed'] = true; |
|
64 | - return; |
|
65 | - } |
|
63 | + $frm_vars['settings_routed'] = true; |
|
64 | + return; |
|
65 | + } |
|
66 | 66 | |
67 | - self::display_form( $errors, $message ); |
|
68 | - } |
|
67 | + self::display_form( $errors, $message ); |
|
68 | + } |
|
69 | 69 | |
70 | - public static function route( $stop_load = false ) { |
|
71 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
70 | + public static function route( $stop_load = false ) { |
|
71 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
72 | 72 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
73 | - if ( $action == 'process-form' ) { |
|
74 | - return self::process_form( $stop_load ); |
|
75 | - } else if ( $stop_load != 'stop_load' ) { |
|
76 | - return self::display_form(); |
|
77 | - } |
|
78 | - } |
|
73 | + if ( $action == 'process-form' ) { |
|
74 | + return self::process_form( $stop_load ); |
|
75 | + } else if ( $stop_load != 'stop_load' ) { |
|
76 | + return self::display_form(); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
@@ -126,19 +126,19 @@ |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
129 | - * Flatten multi-dimensional array for multi-file upload fields |
|
130 | - * @since 2.0.9 |
|
131 | - */ |
|
129 | + * Flatten multi-dimensional array for multi-file upload fields |
|
130 | + * @since 2.0.9 |
|
131 | + */ |
|
132 | 132 | public static function flatten_multi_file_upload( $field, &$val ) { |
133 | 133 | if ( $field->type == 'file' && FrmField::is_option_true( $field, 'multiple' ) ) { |
134 | 134 | $val = FrmAppHelper::array_flatten( $val ); |
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | - /** |
|
139 | - * Replace returns with HTML line breaks for display |
|
140 | - * @since 2.0.9 |
|
141 | - */ |
|
138 | + /** |
|
139 | + * Replace returns with HTML line breaks for display |
|
140 | + * @since 2.0.9 |
|
141 | + */ |
|
142 | 142 | public static function textarea_display_value( $type, $plain_text, &$value ) { |
143 | 143 | if ( $type == 'textarea' && ! $plain_text ) { |
144 | 144 | $value = str_replace( array( "\r\n", "\r", "\n" ), ' <br/>', $value ); |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | $atts['id'] = $atts['entry']->id; |
38 | 38 | } |
39 | 39 | |
40 | - if ( ! $atts['fields'] || ! is_array($atts['fields']) ) { |
|
40 | + if ( ! $atts['fields'] || ! is_array( $atts['fields'] ) ) { |
|
41 | 41 | $atts['fields'] = FrmField::get_all_for_form( $atts['form_id'], '', 'include' ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $values = array(); |
45 | 45 | foreach ( $atts['fields'] as $f ) { |
46 | 46 | self::fill_entry_values( $atts, $f, $values ); |
47 | - unset($f); |
|
47 | + unset( $f ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | self::fill_entry_user_info( $atts, $values ); |
51 | 51 | |
52 | 52 | if ( $atts['format'] == 'json' ) { |
53 | - return json_encode($values); |
|
53 | + return json_encode( $values ); |
|
54 | 54 | } else if ( $atts['format'] == 'array' ) { |
55 | 55 | return $values; |
56 | 56 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | self::convert_entry_to_content( $values, $atts, $content ); |
60 | 60 | |
61 | 61 | if ( 'text' == $atts['format'] ) { |
62 | - $content = implode('', $content); |
|
62 | + $content = implode( '', $content ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | if ( $atts['clickable'] ) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | 'val' => '[' . $f->id . ']' |
83 | 83 | ); |
84 | 84 | |
85 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
85 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public static function fill_entry_values( $atts, $f, array &$values ) { |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $f->id ] ) ) { |
|
98 | + if ( $atts['entry'] && ! isset( $atts['entry']->metas[$f->id] ) ) { |
|
99 | 99 | // In case include_blank is set |
100 | - $atts['entry']->metas[ $f->id ] = ''; |
|
100 | + $atts['entry']->metas[$f->id] = ''; |
|
101 | 101 | |
102 | 102 | if ( FrmAppHelper::pro_is_installed() ) { |
103 | 103 | FrmProEntryMeta::add_post_value_to_entry( $f, $atts['entry'] ); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $val = ''; |
109 | 109 | if ( $atts['entry'] ) { |
110 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
110 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
111 | 111 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); |
112 | 112 | |
113 | 113 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | self::maybe_strip_html( $atts['plain_text'], $val ); |
133 | 133 | |
134 | 134 | if ( $atts['format'] != 'text' ) { |
135 | - $values[ $f->field_key ] = $val; |
|
135 | + $values[$f->field_key] = $val; |
|
136 | 136 | if ( isset( $prev_val ) && $prev_val != $val && $f->type != 'textarea' ) { |
137 | - $values[ $f->field_key . '-value' ] = $prev_val; |
|
137 | + $values[$f->field_key . '-value'] = $prev_val; |
|
138 | 138 | } |
139 | 139 | } else { |
140 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val ); |
|
140 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val ); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - $data = self::get_entry_description_data( $atts ); |
|
186 | + $data = self::get_entry_description_data( $atts ); |
|
187 | 187 | |
188 | 188 | if ( $atts['default_email'] ) { |
189 | 189 | $atts['entry']->ip = '[ip]'; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
271 | 271 | |
272 | 272 | // see how many we have |
273 | - $i = count($matches['browser']); |
|
273 | + $i = count( $matches['browser'] ); |
|
274 | 274 | if ( $i != 1 ) { |
275 | 275 | //we will have two since we are not using 'other' argument yet |
276 | 276 | //see if version is before or after the name |
@@ -307,15 +307,15 @@ discard block |
||
307 | 307 | |
308 | 308 | // merge defaults, global settings, and shortcode options |
309 | 309 | foreach ( $default_settings as $key => $setting ) { |
310 | - if ( $atts[ $key ] != '' ) { |
|
310 | + if ( $atts[$key] != '' ) { |
|
311 | 311 | continue; |
312 | 312 | } |
313 | 313 | |
314 | - $atts[ $key ] = $setting; |
|
314 | + $atts[$key] = $setting; |
|
315 | 315 | unset( $key, $setting ); |
316 | 316 | } |
317 | 317 | |
318 | - unset($default_settings); |
|
318 | + unset( $default_settings ); |
|
319 | 319 | |
320 | 320 | $content[] = '<table cellspacing="0" style="font-size:' . $atts['font_size'] . ';line-height:135%; border-bottom:' . $atts['border_width'] . ' solid #' . $atts['border_color'] . ';"><tbody>' . "\r\n"; |
321 | 321 | $atts['bg_color'] = ' style="background-color:#' . $atts['bg_color'] . ';"'; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | continue; |
339 | 339 | } |
340 | 340 | |
341 | - if ( $atts['default_email'] && is_numeric($id) ) { |
|
341 | + if ( $atts['default_email'] && is_numeric( $id ) ) { |
|
342 | 342 | $content[] = '[if ' . $id . ']<tr style="[frm-alt-color]">'; |
343 | 343 | } else { |
344 | 344 | $content[] = '<tr' . ( $odd ? $atts['bg_color'] : $bg_color_alt ) . '>'; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmSettings{ |
|
3 | +class FrmSettings { |
|
4 | 4 | public $option_name = 'frm_options'; |
5 | 5 | public $menu; |
6 | 6 | public $mu_menu; |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | public $re_msg; |
29 | 29 | |
30 | 30 | public function __construct() { |
31 | - if ( ! defined('ABSPATH') ) { |
|
32 | - die('You are not allowed to call this page directly.'); |
|
31 | + if ( ! defined( 'ABSPATH' ) ) { |
|
32 | + die( 'You are not allowed to call this page directly.' ); |
|
33 | 33 | } |
34 | 34 | |
35 | - $settings = get_transient($this->option_name); |
|
35 | + $settings = get_transient( $this->option_name ); |
|
36 | 36 | |
37 | - if ( ! is_object($settings) ) { |
|
38 | - $settings = $this->translate_settings($settings); |
|
37 | + if ( ! is_object( $settings ) ) { |
|
38 | + $settings = $this->translate_settings( $settings ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | foreach ( $settings as $setting_name => $setting ) { |
42 | 42 | $this->{$setting_name} = $setting; |
43 | - unset($setting_name, $setting); |
|
43 | + unset( $setting_name, $setting ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $this->set_default_options(); |
@@ -48,24 +48,24 @@ discard block |
||
48 | 48 | |
49 | 49 | private function translate_settings( $settings ) { |
50 | 50 | if ( $settings ) { //workaround for W3 total cache conflict |
51 | - return unserialize(serialize($settings)); |
|
51 | + return unserialize( serialize( $settings ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | - $settings = get_option($this->option_name); |
|
55 | - if ( is_object($settings) ) { |
|
56 | - set_transient($this->option_name, $settings); |
|
54 | + $settings = get_option( $this->option_name ); |
|
55 | + if ( is_object( $settings ) ) { |
|
56 | + set_transient( $this->option_name, $settings ); |
|
57 | 57 | return $settings; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // If unserializing didn't work |
61 | 61 | if ( $settings ) { //workaround for W3 total cache conflict |
62 | - $settings = unserialize(serialize($settings)); |
|
62 | + $settings = unserialize( serialize( $settings ) ); |
|
63 | 63 | } else { |
64 | 64 | $settings = $this; |
65 | 65 | } |
66 | 66 | |
67 | - update_option($this->option_name, $settings); |
|
68 | - set_transient($this->option_name, $settings); |
|
67 | + update_option( $this->option_name, $settings ); |
|
68 | + set_transient( $this->option_name, $settings ); |
|
69 | 69 | |
70 | 70 | return $settings; |
71 | 71 | } |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | private function set_default_options() { |
99 | 99 | $this->fill_recaptcha_settings(); |
100 | 100 | |
101 | - if ( ! isset($this->load_style) ) { |
|
102 | - if ( ! isset($this->custom_style) ) { |
|
101 | + if ( ! isset( $this->load_style ) ) { |
|
102 | + if ( ! isset( $this->custom_style ) ) { |
|
103 | 103 | $this->custom_style = true; |
104 | 104 | } |
105 | 105 | |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | $this->fill_with_defaults(); |
110 | 110 | |
111 | 111 | if ( is_multisite() && is_admin() ) { |
112 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
113 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
112 | + $mu_menu = get_site_option( 'frm_admin_menu_name' ); |
|
113 | + if ( $mu_menu && ! empty( $mu_menu ) ) { |
|
114 | 114 | $this->menu = $mu_menu; |
115 | 115 | $this->mu_menu = 1; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
119 | + $frm_roles = FrmAppHelper::frm_capabilities( 'pro' ); |
|
120 | 120 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
121 | - if ( ! isset($this->$frm_role) ) { |
|
121 | + if ( ! isset( $this->$frm_role ) ) { |
|
122 | 122 | $this->$frm_role = 'administrator'; |
123 | 123 | } |
124 | 124 | } |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | $settings = $this->default_options(); |
129 | 129 | |
130 | 130 | foreach ( $settings as $setting => $default ) { |
131 | - if ( isset( $params[ 'frm_' . $setting ] ) ) { |
|
132 | - $this->{$setting} = $params[ 'frm_' . $setting ]; |
|
133 | - } else if ( ! isset($this->{$setting}) ) { |
|
131 | + if ( isset( $params['frm_' . $setting] ) ) { |
|
132 | + $this->{$setting} = $params['frm_' . $setting]; |
|
133 | + } else if ( ! isset( $this->{$setting}) ) { |
|
134 | 134 | $this->{$setting} = $default; |
135 | 135 | } |
136 | - unset($setting, $default); |
|
136 | + unset( $setting, $default ); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | $privkey = ''; |
142 | 142 | $re_lang = 'en'; |
143 | 143 | |
144 | - if ( ! isset($this->pubkey) ) { |
|
144 | + if ( ! isset( $this->pubkey ) ) { |
|
145 | 145 | // get the options from the database |
146 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
147 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
146 | + $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
|
147 | + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
|
148 | + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey; |
|
149 | + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
152 | + if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
|
153 | 153 | $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
154 | 154 | } |
155 | 155 | |
156 | - if ( ! isset($this->privkey) ) { |
|
156 | + if ( ! isset( $this->privkey ) ) { |
|
157 | 157 | $this->privkey = $privkey; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! isset($this->re_lang) ) { |
|
160 | + if ( ! isset( $this->re_lang ) ) { |
|
161 | 161 | $this->re_lang = $re_lang; |
162 | 162 | } |
163 | 163 | } |
@@ -168,31 +168,31 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | public function update( $params ) { |
171 | - $this->fill_with_defaults($params); |
|
172 | - $this->update_settings($params); |
|
171 | + $this->fill_with_defaults( $params ); |
|
172 | + $this->update_settings( $params ); |
|
173 | 173 | |
174 | 174 | if ( $this->mu_menu ) { |
175 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
176 | - } else if ( current_user_can('administrator') ) { |
|
177 | - update_site_option('frm_admin_menu_name', false); |
|
175 | + update_site_option( 'frm_admin_menu_name', $this->menu ); |
|
176 | + } else if ( current_user_can( 'administrator' ) ) { |
|
177 | + update_site_option( 'frm_admin_menu_name', false ); |
|
178 | 178 | } |
179 | 179 | |
180 | - $this->update_roles($params); |
|
180 | + $this->update_roles( $params ); |
|
181 | 181 | |
182 | 182 | do_action( 'frm_update_settings', $params ); |
183 | 183 | } |
184 | 184 | |
185 | 185 | private function update_settings( $params ) { |
186 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
186 | + $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0; |
|
187 | 187 | |
188 | - $this->pubkey = trim($params['frm_pubkey']); |
|
188 | + $this->pubkey = trim( $params['frm_pubkey'] ); |
|
189 | 189 | $this->privkey = $params['frm_privkey']; |
190 | 190 | $this->re_lang = $params['frm_re_lang']; |
191 | 191 | |
192 | 192 | $this->load_style = $params['frm_load_style']; |
193 | 193 | $this->preview_page_id = (int) $params['frm-preview-page-id']; |
194 | 194 | |
195 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
195 | + $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0; |
|
196 | 196 | //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
197 | 197 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
198 | 198 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
@@ -205,30 +205,30 @@ discard block |
||
205 | 205 | $frm_roles = FrmAppHelper::frm_capabilities(); |
206 | 206 | $roles = get_editable_roles(); |
207 | 207 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
208 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
208 | + $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' ); |
|
209 | 209 | |
210 | - if ( count($this->$frm_role) === 1 ) { |
|
211 | - $set_role = reset($this->$frm_role); |
|
210 | + if ( count( $this->$frm_role ) === 1 ) { |
|
211 | + $set_role = reset( $this->$frm_role ); |
|
212 | 212 | switch ( $set_role ) { |
213 | 213 | case 'subscriber': |
214 | - array_push($this->$frm_role, 'contributor'); |
|
214 | + array_push( $this->$frm_role, 'contributor' ); |
|
215 | 215 | case 'contributor': |
216 | - array_push($this->$frm_role, 'author'); |
|
216 | + array_push( $this->$frm_role, 'author' ); |
|
217 | 217 | case 'author': |
218 | - array_push($this->$frm_role, 'editor'); |
|
218 | + array_push( $this->$frm_role, 'editor' ); |
|
219 | 219 | case 'editor': |
220 | - array_push($this->$frm_role, 'administrator'); |
|
220 | + array_push( $this->$frm_role, 'administrator' ); |
|
221 | 221 | } |
222 | - unset($set_role); |
|
222 | + unset( $set_role ); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | foreach ( $roles as $role => $details ) { |
226 | - if ( in_array($role, $this->$frm_role) ) { |
|
226 | + if ( in_array( $role, $this->$frm_role ) ) { |
|
227 | 227 | $wp_roles->add_cap( $role, $frm_role ); |
228 | 228 | } else { |
229 | 229 | $wp_roles->remove_cap( $role, $frm_role ); |
230 | 230 | } |
231 | - unset($role, $details); |
|
231 | + unset( $role, $details ); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | public function store() { |
237 | 237 | // Save the posted value in the database |
238 | 238 | |
239 | - update_option('frm_options', $this); |
|
239 | + update_option( 'frm_options', $this ); |
|
240 | 240 | |
241 | - delete_transient('frm_options'); |
|
242 | - set_transient('frm_options', $this); |
|
241 | + delete_transient( 'frm_options' ); |
|
242 | + set_transient( 'frm_options', $this ); |
|
243 | 243 | |
244 | 244 | do_action( 'frm_store_settings' ); |
245 | 245 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class FrmSettings{ |
|
3 | +class FrmSettings { |
|
4 | 4 | public $option_name = 'frm_options'; |
5 | 5 | public $menu; |
6 | 6 | public $mu_menu; |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | private function translate_settings( $settings ) { |
50 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
50 | + if ( $settings ) { |
|
51 | +//workaround for W3 total cache conflict |
|
51 | 52 | return unserialize(serialize($settings)); |
52 | 53 | } |
53 | 54 | |
@@ -58,7 +59,8 @@ discard block |
||
58 | 59 | } |
59 | 60 | |
60 | 61 | // If unserializing didn't work |
61 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
62 | + if ( $settings ) { |
|
63 | +//workaround for W3 total cache conflict |
|
62 | 64 | $settings = unserialize(serialize($settings)); |
63 | 65 | } else { |
64 | 66 | $settings = $this; |
@@ -1,254 +1,254 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmSettings{ |
4 | - public $option_name = 'frm_options'; |
|
5 | - public $menu; |
|
6 | - public $mu_menu; |
|
7 | - public $preview_page_id; |
|
8 | - public $use_html; |
|
9 | - public $jquery_css; |
|
10 | - public $accordion_js; |
|
11 | - |
|
12 | - public $success_msg; |
|
13 | - public $blank_msg; |
|
14 | - public $unique_msg; |
|
15 | - public $invalid_msg; |
|
16 | - public $failed_msg; |
|
17 | - public $submit_value; |
|
18 | - public $login_msg; |
|
19 | - public $admin_permission; |
|
20 | - |
|
21 | - public $email_to; |
|
22 | - public $load_style; |
|
23 | - public $custom_style; |
|
24 | - |
|
25 | - public $pubkey; |
|
26 | - public $privkey; |
|
27 | - public $re_lang; |
|
28 | - public $re_msg; |
|
4 | + public $option_name = 'frm_options'; |
|
5 | + public $menu; |
|
6 | + public $mu_menu; |
|
7 | + public $preview_page_id; |
|
8 | + public $use_html; |
|
9 | + public $jquery_css; |
|
10 | + public $accordion_js; |
|
11 | + |
|
12 | + public $success_msg; |
|
13 | + public $blank_msg; |
|
14 | + public $unique_msg; |
|
15 | + public $invalid_msg; |
|
16 | + public $failed_msg; |
|
17 | + public $submit_value; |
|
18 | + public $login_msg; |
|
19 | + public $admin_permission; |
|
20 | + |
|
21 | + public $email_to; |
|
22 | + public $load_style; |
|
23 | + public $custom_style; |
|
24 | + |
|
25 | + public $pubkey; |
|
26 | + public $privkey; |
|
27 | + public $re_lang; |
|
28 | + public $re_msg; |
|
29 | 29 | public $re_multi; |
30 | 30 | |
31 | - public function __construct() { |
|
32 | - if ( ! defined('ABSPATH') ) { |
|
33 | - die('You are not allowed to call this page directly.'); |
|
34 | - } |
|
31 | + public function __construct() { |
|
32 | + if ( ! defined('ABSPATH') ) { |
|
33 | + die('You are not allowed to call this page directly.'); |
|
34 | + } |
|
35 | 35 | |
36 | - $settings = get_transient($this->option_name); |
|
36 | + $settings = get_transient($this->option_name); |
|
37 | 37 | |
38 | - if ( ! is_object($settings) ) { |
|
39 | - $settings = $this->translate_settings($settings); |
|
40 | - } |
|
38 | + if ( ! is_object($settings) ) { |
|
39 | + $settings = $this->translate_settings($settings); |
|
40 | + } |
|
41 | 41 | |
42 | - foreach ( $settings as $setting_name => $setting ) { |
|
43 | - $this->{$setting_name} = $setting; |
|
44 | - unset($setting_name, $setting); |
|
45 | - } |
|
42 | + foreach ( $settings as $setting_name => $setting ) { |
|
43 | + $this->{$setting_name} = $setting; |
|
44 | + unset($setting_name, $setting); |
|
45 | + } |
|
46 | 46 | |
47 | - $this->set_default_options(); |
|
48 | - } |
|
47 | + $this->set_default_options(); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | private function translate_settings( $settings ) { |
51 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
52 | - return unserialize(serialize($settings)); |
|
53 | - } |
|
54 | - |
|
55 | - $settings = get_option($this->option_name); |
|
56 | - if ( is_object($settings) ) { |
|
57 | - set_transient($this->option_name, $settings); |
|
58 | - return $settings; |
|
59 | - } |
|
60 | - |
|
61 | - // If unserializing didn't work |
|
62 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
63 | - $settings = unserialize(serialize($settings)); |
|
64 | - } else { |
|
65 | - $settings = $this; |
|
66 | - } |
|
67 | - |
|
68 | - update_option($this->option_name, $settings); |
|
69 | - set_transient($this->option_name, $settings); |
|
70 | - |
|
71 | - return $settings; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @return array |
|
76 | - */ |
|
51 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
52 | + return unserialize(serialize($settings)); |
|
53 | + } |
|
54 | + |
|
55 | + $settings = get_option($this->option_name); |
|
56 | + if ( is_object($settings) ) { |
|
57 | + set_transient($this->option_name, $settings); |
|
58 | + return $settings; |
|
59 | + } |
|
60 | + |
|
61 | + // If unserializing didn't work |
|
62 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
63 | + $settings = unserialize(serialize($settings)); |
|
64 | + } else { |
|
65 | + $settings = $this; |
|
66 | + } |
|
67 | + |
|
68 | + update_option($this->option_name, $settings); |
|
69 | + set_transient($this->option_name, $settings); |
|
70 | + |
|
71 | + return $settings; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @return array |
|
76 | + */ |
|
77 | 77 | public function default_options() { |
78 | - return array( |
|
79 | - 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
80 | - 'mu_menu' => 0, |
|
81 | - 'preview_page_id' => 0, |
|
82 | - 'use_html' => true, |
|
83 | - 'jquery_css' => false, |
|
84 | - 'accordion_js' => false, |
|
78 | + return array( |
|
79 | + 'menu' => apply_filters( 'frm_default_menu', __( 'Forms', 'formidable' ) ), |
|
80 | + 'mu_menu' => 0, |
|
81 | + 'preview_page_id' => 0, |
|
82 | + 'use_html' => true, |
|
83 | + 'jquery_css' => false, |
|
84 | + 'accordion_js' => false, |
|
85 | 85 | |
86 | 86 | 're_multi' => 0, |
87 | 87 | |
88 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
89 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
90 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
91 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
92 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
93 | - 'submit_value' => __( 'Submit', 'formidable' ), |
|
94 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
95 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
88 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
89 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
90 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
91 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
92 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
93 | + 'submit_value' => __( 'Submit', 'formidable' ), |
|
94 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
95 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
96 | 96 | |
97 | - 'email_to' => '[admin_email]', |
|
98 | - ); |
|
99 | - } |
|
97 | + 'email_to' => '[admin_email]', |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | private function set_default_options() { |
102 | - $this->fill_recaptcha_settings(); |
|
103 | - |
|
104 | - if ( ! isset($this->load_style) ) { |
|
105 | - if ( ! isset($this->custom_style) ) { |
|
106 | - $this->custom_style = true; |
|
107 | - } |
|
108 | - |
|
109 | - $this->load_style = 'all'; |
|
110 | - } |
|
111 | - |
|
112 | - $this->fill_with_defaults(); |
|
113 | - |
|
114 | - if ( is_multisite() && is_admin() ) { |
|
115 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
116 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
117 | - $this->menu = $mu_menu; |
|
118 | - $this->mu_menu = 1; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
123 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
124 | - if ( ! isset($this->$frm_role) ) { |
|
125 | - $this->$frm_role = 'administrator'; |
|
126 | - } |
|
127 | - } |
|
128 | - } |
|
102 | + $this->fill_recaptcha_settings(); |
|
103 | + |
|
104 | + if ( ! isset($this->load_style) ) { |
|
105 | + if ( ! isset($this->custom_style) ) { |
|
106 | + $this->custom_style = true; |
|
107 | + } |
|
108 | + |
|
109 | + $this->load_style = 'all'; |
|
110 | + } |
|
111 | + |
|
112 | + $this->fill_with_defaults(); |
|
113 | + |
|
114 | + if ( is_multisite() && is_admin() ) { |
|
115 | + $mu_menu = get_site_option('frm_admin_menu_name'); |
|
116 | + if ( $mu_menu && ! empty($mu_menu) ) { |
|
117 | + $this->menu = $mu_menu; |
|
118 | + $this->mu_menu = 1; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
123 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
124 | + if ( ! isset($this->$frm_role) ) { |
|
125 | + $this->$frm_role = 'administrator'; |
|
126 | + } |
|
127 | + } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | public function fill_with_defaults( $params = array() ) { |
131 | - $settings = $this->default_options(); |
|
131 | + $settings = $this->default_options(); |
|
132 | 132 | |
133 | - foreach ( $settings as $setting => $default ) { |
|
133 | + foreach ( $settings as $setting => $default ) { |
|
134 | 134 | if ( isset( $params[ 'frm_' . $setting ] ) ) { |
135 | 135 | $this->{$setting} = $params[ 'frm_' . $setting ]; |
136 | - } else if ( ! isset($this->{$setting}) ) { |
|
137 | - $this->{$setting} = $default; |
|
138 | - } |
|
136 | + } else if ( ! isset($this->{$setting}) ) { |
|
137 | + $this->{$setting} = $default; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | if ( $setting == 'menu' && empty( $this->{$setting} ) ) { |
141 | 141 | $this->{$setting} = $default; |
142 | 142 | } |
143 | 143 | |
144 | - unset($setting, $default); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - private function fill_recaptcha_settings() { |
|
149 | - $privkey = ''; |
|
150 | - $re_lang = 'en'; |
|
151 | - |
|
152 | - if ( ! isset($this->pubkey) ) { |
|
153 | - // get the options from the database |
|
154 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
155 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
156 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
157 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
158 | - } |
|
144 | + unset($setting, $default); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + private function fill_recaptcha_settings() { |
|
149 | + $privkey = ''; |
|
150 | + $re_lang = 'en'; |
|
151 | + |
|
152 | + if ( ! isset($this->pubkey) ) { |
|
153 | + // get the options from the database |
|
154 | + $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
155 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
156 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
157 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
158 | + } |
|
159 | 159 | |
160 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
161 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
162 | - } |
|
160 | + if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
161 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
162 | + } |
|
163 | 163 | |
164 | - if ( ! isset($this->privkey) ) { |
|
165 | - $this->privkey = $privkey; |
|
166 | - } |
|
164 | + if ( ! isset($this->privkey) ) { |
|
165 | + $this->privkey = $privkey; |
|
166 | + } |
|
167 | 167 | |
168 | - if ( ! isset($this->re_lang) ) { |
|
169 | - $this->re_lang = $re_lang; |
|
170 | - } |
|
171 | - } |
|
168 | + if ( ! isset($this->re_lang) ) { |
|
169 | + $this->re_lang = $re_lang; |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | - public function validate( $params, $errors ) { |
|
174 | - $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
175 | - return $errors; |
|
176 | - } |
|
173 | + public function validate( $params, $errors ) { |
|
174 | + $errors = apply_filters( 'frm_validate_settings', $errors, $params ); |
|
175 | + return $errors; |
|
176 | + } |
|
177 | 177 | |
178 | 178 | public function update( $params ) { |
179 | - $this->fill_with_defaults($params); |
|
180 | - $this->update_settings($params); |
|
179 | + $this->fill_with_defaults($params); |
|
180 | + $this->update_settings($params); |
|
181 | 181 | |
182 | - if ( $this->mu_menu ) { |
|
183 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
184 | - } else if ( current_user_can('administrator') ) { |
|
185 | - update_site_option('frm_admin_menu_name', false); |
|
186 | - } |
|
182 | + if ( $this->mu_menu ) { |
|
183 | + update_site_option('frm_admin_menu_name', $this->menu); |
|
184 | + } else if ( current_user_can('administrator') ) { |
|
185 | + update_site_option('frm_admin_menu_name', false); |
|
186 | + } |
|
187 | 187 | |
188 | - $this->update_roles($params); |
|
188 | + $this->update_roles($params); |
|
189 | 189 | |
190 | - do_action( 'frm_update_settings', $params ); |
|
191 | - } |
|
190 | + do_action( 'frm_update_settings', $params ); |
|
191 | + } |
|
192 | 192 | |
193 | 193 | private function update_settings( $params ) { |
194 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
194 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
195 | 195 | |
196 | - $this->pubkey = trim($params['frm_pubkey']); |
|
197 | - $this->privkey = $params['frm_privkey']; |
|
198 | - $this->re_lang = $params['frm_re_lang']; |
|
196 | + $this->pubkey = trim($params['frm_pubkey']); |
|
197 | + $this->privkey = $params['frm_privkey']; |
|
198 | + $this->re_lang = $params['frm_re_lang']; |
|
199 | 199 | |
200 | - $this->load_style = $params['frm_load_style']; |
|
201 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
200 | + $this->load_style = $params['frm_load_style']; |
|
201 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
202 | 202 | |
203 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
204 | - //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
203 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
204 | + //$this->custom_style = isset($params['frm_custom_style']) ? $params['frm_custom_style'] : 0; |
|
205 | 205 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
206 | 206 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | 209 | private function update_roles( $params ) { |
210 | - //update roles |
|
211 | - global $wp_roles; |
|
212 | - |
|
213 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
214 | - $roles = get_editable_roles(); |
|
215 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
216 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
217 | - |
|
218 | - if ( count($this->$frm_role) === 1 ) { |
|
219 | - $set_role = reset($this->$frm_role); |
|
220 | - switch ( $set_role ) { |
|
221 | - case 'subscriber': |
|
222 | - array_push($this->$frm_role, 'contributor'); |
|
223 | - case 'contributor': |
|
224 | - array_push($this->$frm_role, 'author'); |
|
225 | - case 'author': |
|
226 | - array_push($this->$frm_role, 'editor'); |
|
227 | - case 'editor': |
|
228 | - array_push($this->$frm_role, 'administrator'); |
|
229 | - } |
|
230 | - unset($set_role); |
|
231 | - } |
|
232 | - |
|
233 | - foreach ( $roles as $role => $details ) { |
|
234 | - if ( in_array($role, $this->$frm_role) ) { |
|
235 | - $wp_roles->add_cap( $role, $frm_role ); |
|
236 | - } else { |
|
237 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
238 | - } |
|
239 | - unset($role, $details); |
|
240 | - } |
|
241 | - } |
|
242 | - } |
|
210 | + //update roles |
|
211 | + global $wp_roles; |
|
212 | + |
|
213 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
214 | + $roles = get_editable_roles(); |
|
215 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
216 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
217 | + |
|
218 | + if ( count($this->$frm_role) === 1 ) { |
|
219 | + $set_role = reset($this->$frm_role); |
|
220 | + switch ( $set_role ) { |
|
221 | + case 'subscriber': |
|
222 | + array_push($this->$frm_role, 'contributor'); |
|
223 | + case 'contributor': |
|
224 | + array_push($this->$frm_role, 'author'); |
|
225 | + case 'author': |
|
226 | + array_push($this->$frm_role, 'editor'); |
|
227 | + case 'editor': |
|
228 | + array_push($this->$frm_role, 'administrator'); |
|
229 | + } |
|
230 | + unset($set_role); |
|
231 | + } |
|
232 | + |
|
233 | + foreach ( $roles as $role => $details ) { |
|
234 | + if ( in_array($role, $this->$frm_role) ) { |
|
235 | + $wp_roles->add_cap( $role, $frm_role ); |
|
236 | + } else { |
|
237 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
238 | + } |
|
239 | + unset($role, $details); |
|
240 | + } |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | 244 | public function store() { |
245 | - // Save the posted value in the database |
|
245 | + // Save the posted value in the database |
|
246 | 246 | |
247 | - update_option('frm_options', $this); |
|
247 | + update_option('frm_options', $this); |
|
248 | 248 | |
249 | - delete_transient('frm_options'); |
|
250 | - set_transient('frm_options', $this); |
|
249 | + delete_transient('frm_options'); |
|
250 | + set_transient('frm_options', $this); |
|
251 | 251 | |
252 | - do_action( 'frm_store_settings' ); |
|
253 | - } |
|
252 | + do_action( 'frm_store_settings' ); |
|
253 | + } |
|
254 | 254 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! isset( $entry) ) { |
3 | - $entry = $record; |
|
3 | + $entry = $record; |
|
4 | 4 | } ?> |
5 | 5 | |
6 | 6 | <div class="misc-pub-section curtime misc-pub-curtime"> |
7 | 7 | <span id="timestamp"> |
8 | 8 | <?php |
9 | - $date_format = __( 'M j, Y @ G:i' ); |
|
9 | + $date_format = __( 'M j, Y @ G:i' ); |
|
10 | 10 | printf( __( 'Published on: <b>%1$s</b>' ), FrmAppHelper::get_localized_date( $date_format, $entry->created_at ) ); ?> |
11 | 11 | </span> |
12 | 12 | </div> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! isset( $entry) ) { |
|
2 | +if ( ! isset( $entry ) ) { |
|
3 | 3 | $entry = $record; |
4 | 4 | } ?> |
5 | 5 | |
@@ -18,4 +18,4 @@ discard block |
||
18 | 18 | </div> |
19 | 19 | <?php } ?> |
20 | 20 | |
21 | -<?php do_action('frm_entry_shared_sidebar', $entry); ?> |
|
21 | +<?php do_action( 'frm_entry_shared_sidebar', $entry ); ?> |
@@ -4,30 +4,30 @@ |
||
4 | 4 | <?php |
5 | 5 | } |
6 | 6 | if ( isset( $message ) && $message != '' ) { |
7 | - if ( FrmAppHelper::is_admin() ) { |
|
7 | + if ( FrmAppHelper::is_admin() ) { |
|
8 | 8 | ?><div id="message" class="frm_message updated frm_msg_padding"><?php echo wp_kses_post( $message ) ?></div><?php |
9 | 9 | } else { |
10 | - FrmFormsHelper::get_scroll_js($form->id); |
|
10 | + FrmFormsHelper::get_scroll_js($form->id); |
|
11 | 11 | |
12 | 12 | // we need to allow scripts here for javascript in the success message |
13 | 13 | echo $message; |
14 | - } |
|
14 | + } |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) { |
18 | 18 | |
19 | 19 | if ( isset( $form ) && is_object( $form ) ) { |
20 | - FrmFormsHelper::get_scroll_js( $form->id ); |
|
20 | + FrmFormsHelper::get_scroll_js( $form->id ); |
|
21 | 21 | } ?> |
22 | 22 | <div class="frm_error_style"> |
23 | 23 | <?php |
24 | 24 | $img = ''; |
25 | 25 | if ( ! FrmAppHelper::is_admin() ) { |
26 | - $img = apply_filters('frm_error_icon', $img); |
|
27 | - if ( $img && ! empty($img) ) { |
|
28 | - ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
|
26 | + $img = apply_filters('frm_error_icon', $img); |
|
27 | + if ( $img && ! empty($img) ) { |
|
28 | + ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
|
29 | 29 | <?php |
30 | - } |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | FrmFormsHelper::show_errors( compact( 'img', 'errors' ) ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( isset($include_extra_container) ) { ?> |
|
2 | +if ( isset( $include_extra_container ) ) { ?> |
|
3 | 3 | <div class="<?php echo esc_attr( $include_extra_container ) ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
4 | 4 | <?php |
5 | 5 | } |
@@ -7,14 +7,14 @@ discard block |
||
7 | 7 | if ( FrmAppHelper::is_admin() ) { |
8 | 8 | ?><div id="message" class="frm_message updated frm_msg_padding"><?php echo wp_kses_post( $message ) ?></div><?php |
9 | 9 | } else { |
10 | - FrmFormsHelper::get_scroll_js($form->id); |
|
10 | + FrmFormsHelper::get_scroll_js( $form->id ); |
|
11 | 11 | |
12 | 12 | // we need to allow scripts here for javascript in the success message |
13 | 13 | echo $message; |
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | -if ( isset($errors) && is_array( $errors ) && ! empty( $errors ) ) { |
|
17 | +if ( isset( $errors ) && is_array( $errors ) && ! empty( $errors ) ) { |
|
18 | 18 | |
19 | 19 | if ( isset( $form ) && is_object( $form ) ) { |
20 | 20 | FrmFormsHelper::get_scroll_js( $form->id ); |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | <?php |
24 | 24 | $img = ''; |
25 | 25 | if ( ! FrmAppHelper::is_admin() ) { |
26 | - $img = apply_filters('frm_error_icon', $img); |
|
27 | - if ( $img && ! empty($img) ) { |
|
26 | + $img = apply_filters( 'frm_error_icon', $img ); |
|
27 | + if ( $img && ! empty( $img ) ) { |
|
28 | 28 | ?><img src="<?php echo esc_attr( $img ) ?>" alt="" /> |
29 | 29 | <?php |
30 | 30 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <?php |
38 | 38 | } |
39 | 39 | |
40 | -if ( isset($include_extra_container) ) { ?> |
|
40 | +if ( isset( $include_extra_container ) ) { ?> |
|
41 | 41 | </div> |
42 | 42 | <?php |
43 | 43 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | </div> |
6 | 6 | </div> |
7 | 7 | <?php |
8 | - return; |
|
8 | + return; |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | global $frm_vars; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } else { |
39 | 39 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
40 | 40 | } |
41 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
41 | + do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | |
64 | 64 | // close open collapsible toggle div |
65 | 65 | if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
66 | - echo "</div>\n"; |
|
67 | - unset($frm_vars['collapse_div']); |
|
66 | + echo "</div>\n"; |
|
67 | + unset($frm_vars['collapse_div']); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | if ( FrmForm::show_submit( $form ) ) { |
80 | - unset($values['fields']); |
|
81 | - FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
80 | + unset($values['fields']); |
|
81 | + FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
82 | 82 | } |
83 | 83 | ?> |
84 | 84 | </fieldset> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?> |
|
3 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
2 | +if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?> |
|
3 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
4 | 4 | <div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?> |
5 | 5 | </div> |
6 | 6 | </div> |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>"> |
19 | 19 | <fieldset> |
20 | 20 | <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?> |
21 | -<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" /> |
|
22 | -<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" /> |
|
23 | -<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" /> |
|
24 | -<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" /> |
|
21 | +<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
22 | +<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" /> |
|
23 | +<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" /> |
|
24 | +<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" /> |
|
25 | 25 | <input type="hidden" name="item_meta[0]" value="" /> |
26 | 26 | <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?> |
27 | 27 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } else { |
35 | 35 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
36 | 36 | } |
37 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
37 | + do_action( 'frm_get_field_scripts', $field, $form, $form->id ); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | if ( FrmAppHelper::is_admin() ) { ?> |
43 | 43 | <div class="frm_form_field form-field"> |
44 | 44 | <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label> |
45 | -<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
45 | +<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
46 | 46 | </div> |
47 | 47 | <?php } else { ?> |
48 | -<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
48 | +<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
49 | 49 | <?php } |
50 | 50 | |
51 | -do_action('frm_entry_form', $form, $form_action, $errors); |
|
51 | +do_action( 'frm_entry_form', $form, $form_action, $errors ); |
|
52 | 52 | |
53 | 53 | global $frm_vars; |
54 | 54 | // close open section div |
@@ -58,23 +58,23 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | // close open collapsible toggle div |
61 | -if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
|
61 | +if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) { |
|
62 | 62 | echo "</div>\n"; |
63 | - unset($frm_vars['collapse_div']); |
|
63 | + unset( $frm_vars['collapse_div'] ); |
|
64 | 64 | } |
65 | 65 | |
66 | -echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
|
66 | +echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ); |
|
67 | 67 | |
68 | 68 | |
69 | -if ( has_action('frm_entries_footer_scripts') ) { ?> |
|
69 | +if ( has_action( 'frm_entries_footer_scripts' ) ) { ?> |
|
70 | 70 | <script type="text/javascript"> |
71 | -<?php do_action('frm_entries_footer_scripts', $values['fields'], $form); ?> |
|
71 | +<?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?> |
|
72 | 72 | </script><?php |
73 | 73 | } |
74 | 74 | |
75 | 75 | if ( FrmForm::show_submit( $form ) ) { |
76 | - unset($values['fields']); |
|
77 | - FrmFormsHelper::get_custom_submit($values['submit_html'], $form, $submit, $form_action, $values); |
|
76 | + unset( $values['fields'] ); |
|
77 | + FrmFormsHelper::get_custom_submit( $values['submit_html'], $form, $submit, $form_action, $values ); |
|
78 | 78 | } |
79 | 79 | ?> |
80 | 80 | </fieldset> |