@@ -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.0.23b1'; |
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 |
|
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
36 | - } |
|
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 | + return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
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,21 +75,21 @@ 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(); |
@@ -97,62 +97,62 @@ discard block |
||
97 | 97 | return empty( $menu_name ) ? __( 'Forms', 'formidable' ) : $menu_name; |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Show a message in place of pro features |
|
102 | - * |
|
103 | - * @since 2.0 |
|
104 | - */ |
|
100 | + /** |
|
101 | + * Show a message in place of pro features |
|
102 | + * |
|
103 | + * @since 2.0 |
|
104 | + */ |
|
105 | 105 | public static function update_message( $features, $class = '' ) { |
106 | 106 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
107 | - } |
|
108 | - |
|
109 | - public static function pro_is_installed() { |
|
110 | - return apply_filters('frm_pro_installed', false); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Check for certain page in Formidable settings |
|
115 | - * |
|
116 | - * @since 2.0 |
|
117 | - * |
|
118 | - * @param string $page The name of the page to check |
|
119 | - * @return boolean |
|
120 | - */ |
|
107 | + } |
|
108 | + |
|
109 | + public static function pro_is_installed() { |
|
110 | + return apply_filters('frm_pro_installed', false); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Check for certain page in Formidable settings |
|
115 | + * |
|
116 | + * @since 2.0 |
|
117 | + * |
|
118 | + * @param string $page The name of the page to check |
|
119 | + * @return boolean |
|
120 | + */ |
|
121 | 121 | public static function is_admin_page( $page = 'formidable' ) { |
122 | - global $pagenow; |
|
122 | + global $pagenow; |
|
123 | 123 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
124 | - if ( $pagenow ) { |
|
124 | + if ( $pagenow ) { |
|
125 | 125 | return $pagenow == 'admin.php' && $get_page == $page; |
126 | - } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | return is_admin() && $get_page == $page; |
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Check for the form preview page |
|
133 | - * |
|
134 | - * @since 2.0 |
|
135 | - * |
|
136 | - * @param None |
|
137 | - * @return boolean |
|
138 | - */ |
|
139 | - public static function is_preview_page() { |
|
140 | - global $pagenow; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Check for the form preview page |
|
133 | + * |
|
134 | + * @since 2.0 |
|
135 | + * |
|
136 | + * @param None |
|
137 | + * @return boolean |
|
138 | + */ |
|
139 | + public static function is_preview_page() { |
|
140 | + global $pagenow; |
|
141 | 141 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
142 | 142 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Check for ajax except the form preview page |
|
147 | - * |
|
148 | - * @since 2.0 |
|
149 | - * |
|
150 | - * @param None |
|
151 | - * @return boolean |
|
152 | - */ |
|
153 | - public static function doing_ajax() { |
|
154 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
155 | - } |
|
145 | + /** |
|
146 | + * Check for ajax except the form preview page |
|
147 | + * |
|
148 | + * @since 2.0 |
|
149 | + * |
|
150 | + * @param None |
|
151 | + * @return boolean |
|
152 | + */ |
|
153 | + public static function doing_ajax() { |
|
154 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
155 | + } |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * @since 2.0.8 |
@@ -162,101 +162,101 @@ discard block |
||
162 | 162 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
163 | 163 | } |
164 | 164 | |
165 | - /** |
|
166 | - * Check if on an admin page |
|
167 | - * |
|
168 | - * @since 2.0 |
|
169 | - * |
|
170 | - * @param None |
|
171 | - * @return boolean |
|
172 | - */ |
|
173 | - public static function is_admin() { |
|
174 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Check if value contains blank value or empty array |
|
179 | - * |
|
180 | - * @since 2.0 |
|
181 | - * @param $value - value to check |
|
182 | - * @return boolean |
|
183 | - */ |
|
184 | - public static function is_empty_value( $value, $empty = '' ) { |
|
185 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
186 | - } |
|
187 | - |
|
188 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
189 | - return ! self::is_empty_value( $value, $empty ); |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Get any value from the $_SERVER |
|
194 | - * |
|
195 | - * @since 2.0 |
|
196 | - * @param string $value |
|
197 | - * @return string |
|
198 | - */ |
|
165 | + /** |
|
166 | + * Check if on an admin page |
|
167 | + * |
|
168 | + * @since 2.0 |
|
169 | + * |
|
170 | + * @param None |
|
171 | + * @return boolean |
|
172 | + */ |
|
173 | + public static function is_admin() { |
|
174 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Check if value contains blank value or empty array |
|
179 | + * |
|
180 | + * @since 2.0 |
|
181 | + * @param $value - value to check |
|
182 | + * @return boolean |
|
183 | + */ |
|
184 | + public static function is_empty_value( $value, $empty = '' ) { |
|
185 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
186 | + } |
|
187 | + |
|
188 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
189 | + return ! self::is_empty_value( $value, $empty ); |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Get any value from the $_SERVER |
|
194 | + * |
|
195 | + * @since 2.0 |
|
196 | + * @param string $value |
|
197 | + * @return string |
|
198 | + */ |
|
199 | 199 | public static function get_server_value( $value ) { |
200 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Check for the IP address in several places |
|
205 | - * Used by [ip] shortcode |
|
206 | - * |
|
207 | - * @return string The IP address of the current user |
|
208 | - */ |
|
209 | - public static function get_ip_address() { |
|
200 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Check for the IP address in several places |
|
205 | + * Used by [ip] shortcode |
|
206 | + * |
|
207 | + * @return string The IP address of the current user |
|
208 | + */ |
|
209 | + public static function get_ip_address() { |
|
210 | 210 | $ip = ''; |
211 | - foreach ( array( |
|
212 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
213 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
214 | - ) as $key ) { |
|
215 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
216 | - continue; |
|
217 | - } |
|
218 | - |
|
219 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
220 | - $ip = trim($ip); // just to be safe |
|
221 | - |
|
222 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
223 | - return $ip; |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
211 | + foreach ( array( |
|
212 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
213 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
214 | + ) as $key ) { |
|
215 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
216 | + continue; |
|
217 | + } |
|
218 | + |
|
219 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
220 | + $ip = trim($ip); // just to be safe |
|
221 | + |
|
222 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
223 | + return $ip; |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | 227 | |
228 | 228 | return sanitize_text_field( $ip ); |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
232 | - if ( strpos($param, '[') ) { |
|
233 | - $params = explode('[', $param); |
|
234 | - $param = $params[0]; |
|
235 | - } |
|
231 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
232 | + if ( strpos($param, '[') ) { |
|
233 | + $params = explode('[', $param); |
|
234 | + $param = $params[0]; |
|
235 | + } |
|
236 | 236 | |
237 | 237 | if ( $src == 'get' ) { |
238 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
239 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
240 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
241 | - } |
|
238 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
239 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
240 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
241 | + } |
|
242 | 242 | self::sanitize_value( $sanitize, $value ); |
243 | 243 | } else { |
244 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
245 | - } |
|
244 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
245 | + } |
|
246 | 246 | |
247 | 247 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
248 | - foreach ( $params as $k => $p ) { |
|
249 | - if ( ! $k || ! is_array($value) ) { |
|
250 | - continue; |
|
251 | - } |
|
248 | + foreach ( $params as $k => $p ) { |
|
249 | + if ( ! $k || ! is_array($value) ) { |
|
250 | + continue; |
|
251 | + } |
|
252 | 252 | |
253 | - $p = trim($p, ']'); |
|
254 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
255 | - } |
|
256 | - } |
|
253 | + $p = trim($p, ']'); |
|
254 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
255 | + } |
|
256 | + } |
|
257 | 257 | |
258 | - return $value; |
|
259 | - } |
|
258 | + return $value; |
|
259 | + } |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
279 | 279 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | 282 | /** |
283 | 283 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
314 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
315 | - * |
|
316 | - * @since 2.0.8 |
|
317 | - * @param string $value |
|
318 | - * @return string $value |
|
319 | - */ |
|
314 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
315 | + * |
|
316 | + * @since 2.0.8 |
|
317 | + * @param string $value |
|
318 | + * @return string $value |
|
319 | + */ |
|
320 | 320 | public static function preserve_backslashes( $value ) { |
321 | 321 | // If backslashes have already been added, don't add them again |
322 | 322 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
339 | - $temp_values = $values; |
|
340 | - foreach ( $temp_values as $k => $val ) { |
|
341 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
338 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
339 | + $temp_values = $values; |
|
340 | + foreach ( $temp_values as $k => $val ) { |
|
341 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
342 | 342 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
343 | - } |
|
344 | - } |
|
345 | - } |
|
343 | + } |
|
344 | + } |
|
345 | + } |
|
346 | 346 | |
347 | 347 | public static function sanitize_array( &$values ) { |
348 | 348 | $temp_values = $values; |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | */ |
358 | 358 | public static function kses( $value, $allowed = array() ) { |
359 | 359 | $html = array( |
360 | - 'a' => array( |
|
360 | + 'a' => array( |
|
361 | 361 | 'href' => array(), |
362 | 362 | 'title' => array(), |
363 | 363 | 'id' => array(), |
364 | 364 | 'class' => array(), |
365 | - ), |
|
365 | + ), |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | $allowed_html = array(); |
@@ -373,176 +373,176 @@ discard block |
||
373 | 373 | return wp_kses( $value, $allowed_html ); |
374 | 374 | } |
375 | 375 | |
376 | - /** |
|
377 | - * Used when switching the action for a bulk action |
|
378 | - * @since 2.0 |
|
379 | - */ |
|
380 | - public static function remove_get_action() { |
|
381 | - if ( ! isset($_GET) ) { |
|
382 | - return; |
|
383 | - } |
|
376 | + /** |
|
377 | + * Used when switching the action for a bulk action |
|
378 | + * @since 2.0 |
|
379 | + */ |
|
380 | + public static function remove_get_action() { |
|
381 | + if ( ! isset($_GET) ) { |
|
382 | + return; |
|
383 | + } |
|
384 | 384 | |
385 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
386 | - if ( ! empty( $new_action ) ) { |
|
385 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
386 | + if ( ! empty( $new_action ) ) { |
|
387 | 387 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Check the WP query for a parameter |
|
393 | - * |
|
394 | - * @since 2.0 |
|
395 | - * @return string|array |
|
396 | - */ |
|
397 | - public static function get_query_var( $value, $param ) { |
|
398 | - if ( $value != '' ) { |
|
399 | - return $value; |
|
400 | - } |
|
401 | - |
|
402 | - global $wp_query; |
|
403 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
404 | - $value = $wp_query->query_vars[ $param ]; |
|
405 | - } |
|
406 | - |
|
407 | - return $value; |
|
408 | - } |
|
409 | - |
|
410 | - /** |
|
411 | - * @param string $type |
|
412 | - */ |
|
413 | - public static function trigger_hook_load( $type, $object = null ) { |
|
414 | - // only load the form hooks once |
|
415 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
416 | - if ( ! $hooks_loaded ) { |
|
417 | - do_action('frm_load_'. $type .'_hooks'); |
|
418 | - } |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * Check cache before fetching values and saving to cache |
|
423 | - * |
|
424 | - * @since 2.0 |
|
425 | - * |
|
426 | - * @param string $cache_key The unique name for this cache |
|
427 | - * @param string $group The name of the cache group |
|
428 | - * @param string $query If blank, don't run a db call |
|
429 | - * @param string $type The wpdb function to use with this query |
|
430 | - * @return mixed $results The cache or query results |
|
431 | - */ |
|
432 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
433 | - $results = wp_cache_get($cache_key, $group); |
|
434 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
435 | - return $results; |
|
436 | - } |
|
437 | - |
|
438 | - if ( 'get_posts' == $type ) { |
|
439 | - $results = get_posts($query); |
|
440 | - } else { |
|
441 | - global $wpdb; |
|
442 | - $results = $wpdb->{$type}($query); |
|
443 | - } |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Check the WP query for a parameter |
|
393 | + * |
|
394 | + * @since 2.0 |
|
395 | + * @return string|array |
|
396 | + */ |
|
397 | + public static function get_query_var( $value, $param ) { |
|
398 | + if ( $value != '' ) { |
|
399 | + return $value; |
|
400 | + } |
|
401 | + |
|
402 | + global $wp_query; |
|
403 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
404 | + $value = $wp_query->query_vars[ $param ]; |
|
405 | + } |
|
406 | + |
|
407 | + return $value; |
|
408 | + } |
|
409 | + |
|
410 | + /** |
|
411 | + * @param string $type |
|
412 | + */ |
|
413 | + public static function trigger_hook_load( $type, $object = null ) { |
|
414 | + // only load the form hooks once |
|
415 | + $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
416 | + if ( ! $hooks_loaded ) { |
|
417 | + do_action('frm_load_'. $type .'_hooks'); |
|
418 | + } |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * Check cache before fetching values and saving to cache |
|
423 | + * |
|
424 | + * @since 2.0 |
|
425 | + * |
|
426 | + * @param string $cache_key The unique name for this cache |
|
427 | + * @param string $group The name of the cache group |
|
428 | + * @param string $query If blank, don't run a db call |
|
429 | + * @param string $type The wpdb function to use with this query |
|
430 | + * @return mixed $results The cache or query results |
|
431 | + */ |
|
432 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
433 | + $results = wp_cache_get($cache_key, $group); |
|
434 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
435 | + return $results; |
|
436 | + } |
|
437 | + |
|
438 | + if ( 'get_posts' == $type ) { |
|
439 | + $results = get_posts($query); |
|
440 | + } else { |
|
441 | + global $wpdb; |
|
442 | + $results = $wpdb->{$type}($query); |
|
443 | + } |
|
444 | 444 | |
445 | 445 | if ( ! self::prevent_caching() ) { |
446 | 446 | wp_cache_set( $cache_key, $results, $group, $time ); |
447 | 447 | } |
448 | 448 | |
449 | - return $results; |
|
450 | - } |
|
449 | + return $results; |
|
450 | + } |
|
451 | 451 | |
452 | - /** |
|
453 | - * Data that should be stored for a long time can be stored in a transient. |
|
454 | - * First check the cache, then check the transient |
|
455 | - * @since 2.0 |
|
456 | - * @return mixed The cached value or false |
|
457 | - */ |
|
452 | + /** |
|
453 | + * Data that should be stored for a long time can be stored in a transient. |
|
454 | + * First check the cache, then check the transient |
|
455 | + * @since 2.0 |
|
456 | + * @return mixed The cached value or false |
|
457 | + */ |
|
458 | 458 | public static function check_cache_and_transient( $cache_key ) { |
459 | - // check caching layer first |
|
460 | - $results = self::check_cache( $cache_key ); |
|
461 | - if ( $results ) { |
|
462 | - return $results; |
|
463 | - } |
|
464 | - |
|
465 | - // then check the transient |
|
466 | - $results = get_transient($cache_key); |
|
467 | - if ( $results ) { |
|
468 | - wp_cache_set($cache_key, $results); |
|
469 | - } |
|
470 | - |
|
471 | - return $results; |
|
472 | - } |
|
473 | - |
|
474 | - /** |
|
475 | - * @since 2.0 |
|
476 | - * @param string $cache_key |
|
477 | - */ |
|
459 | + // check caching layer first |
|
460 | + $results = self::check_cache( $cache_key ); |
|
461 | + if ( $results ) { |
|
462 | + return $results; |
|
463 | + } |
|
464 | + |
|
465 | + // then check the transient |
|
466 | + $results = get_transient($cache_key); |
|
467 | + if ( $results ) { |
|
468 | + wp_cache_set($cache_key, $results); |
|
469 | + } |
|
470 | + |
|
471 | + return $results; |
|
472 | + } |
|
473 | + |
|
474 | + /** |
|
475 | + * @since 2.0 |
|
476 | + * @param string $cache_key |
|
477 | + */ |
|
478 | 478 | public static function delete_cache_and_transient( $cache_key ) { |
479 | - delete_transient($cache_key); |
|
480 | - wp_cache_delete($cache_key); |
|
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Delete all caching in a single group |
|
485 | - * |
|
486 | - * @since 2.0 |
|
487 | - * |
|
488 | - * @param string $group The name of the cache group |
|
489 | - * @return boolean True or False |
|
490 | - */ |
|
479 | + delete_transient($cache_key); |
|
480 | + wp_cache_delete($cache_key); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Delete all caching in a single group |
|
485 | + * |
|
486 | + * @since 2.0 |
|
487 | + * |
|
488 | + * @param string $group The name of the cache group |
|
489 | + * @return boolean True or False |
|
490 | + */ |
|
491 | 491 | public static function cache_delete_group( $group ) { |
492 | - global $wp_object_cache; |
|
493 | - |
|
494 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
495 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
496 | - wp_cache_delete($k, $group); |
|
497 | - } |
|
498 | - return true; |
|
499 | - } |
|
500 | - |
|
501 | - return false; |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
505 | - * Check a value from a shortcode to see if true or false. |
|
506 | - * True when value is 1, true, 'true', 'yes' |
|
507 | - * |
|
508 | - * @since 1.07.10 |
|
509 | - * |
|
510 | - * @param string $value The value to compare |
|
511 | - * @return boolean True or False |
|
512 | - */ |
|
492 | + global $wp_object_cache; |
|
493 | + |
|
494 | + if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
495 | + foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
496 | + wp_cache_delete($k, $group); |
|
497 | + } |
|
498 | + return true; |
|
499 | + } |
|
500 | + |
|
501 | + return false; |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * Check a value from a shortcode to see if true or false. |
|
506 | + * True when value is 1, true, 'true', 'yes' |
|
507 | + * |
|
508 | + * @since 1.07.10 |
|
509 | + * |
|
510 | + * @param string $value The value to compare |
|
511 | + * @return boolean True or False |
|
512 | + */ |
|
513 | 513 | public static function is_true( $value ) { |
514 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
515 | - } |
|
514 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
515 | + } |
|
516 | 516 | |
517 | - /** |
|
518 | - * Used to filter shortcode in text widgets |
|
519 | - */ |
|
520 | - public static function widget_text_filter_callback( $matches ) { |
|
521 | - return do_shortcode( $matches[0] ); |
|
522 | - } |
|
517 | + /** |
|
518 | + * Used to filter shortcode in text widgets |
|
519 | + */ |
|
520 | + public static function widget_text_filter_callback( $matches ) { |
|
521 | + return do_shortcode( $matches[0] ); |
|
522 | + } |
|
523 | 523 | |
524 | 524 | public static function load_scripts( $scripts ) { |
525 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
526 | - foreach ( (array) $scripts as $s ) { |
|
527 | - wp_enqueue_script($s); |
|
528 | - } |
|
529 | - } |
|
525 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
526 | + foreach ( (array) $scripts as $s ) { |
|
527 | + wp_enqueue_script($s); |
|
528 | + } |
|
529 | + } |
|
530 | 530 | |
531 | 531 | public static function load_styles( $styles ) { |
532 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
533 | - foreach ( (array) $styles as $s ) { |
|
534 | - wp_enqueue_style($s); |
|
535 | - } |
|
536 | - } |
|
532 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
533 | + foreach ( (array) $styles as $s ) { |
|
534 | + wp_enqueue_style($s); |
|
535 | + } |
|
536 | + } |
|
537 | 537 | |
538 | - public static function get_pages() { |
|
538 | + public static function get_pages() { |
|
539 | 539 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
540 | - } |
|
540 | + } |
|
541 | 541 | |
542 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
543 | - $pages = self::get_pages(); |
|
542 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
543 | + $pages = self::get_pages(); |
|
544 | 544 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
545 | - ?> |
|
545 | + ?> |
|
546 | 546 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
547 | 547 | <option value=""> </option> |
548 | 548 | <?php foreach ( $pages as $page ) { ?> |
@@ -552,107 +552,107 @@ discard block |
||
552 | 552 | <?php } ?> |
553 | 553 | </select> |
554 | 554 | <?php |
555 | - } |
|
555 | + } |
|
556 | 556 | |
557 | 557 | public static function post_edit_link( $post_id ) { |
558 | - $post = get_post($post_id); |
|
559 | - if ( $post ) { |
|
558 | + $post = get_post($post_id); |
|
559 | + if ( $post ) { |
|
560 | 560 | return '<a href="'. esc_url( admin_url('post.php?post='. $post_id .'&action=edit') ) .'">'. self::truncate( $post->post_title, 50 ) .'</a>'; |
561 | - } |
|
562 | - return ''; |
|
563 | - } |
|
561 | + } |
|
562 | + return ''; |
|
563 | + } |
|
564 | 564 | |
565 | 565 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
566 | - ?> |
|
566 | + ?> |
|
567 | 567 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
568 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
569 | - ?> class="frm_multiselect"> |
|
568 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
569 | + ?> class="frm_multiselect"> |
|
570 | 570 | <?php self::roles_options($capability); ?> |
571 | 571 | </select> |
572 | 572 | <?php |
573 | - } |
|
573 | + } |
|
574 | 574 | |
575 | 575 | public static function roles_options( $capability ) { |
576 | - global $frm_vars; |
|
577 | - if ( isset($frm_vars['editable_roles']) ) { |
|
578 | - $editable_roles = $frm_vars['editable_roles']; |
|
579 | - } else { |
|
580 | - $editable_roles = get_editable_roles(); |
|
581 | - $frm_vars['editable_roles'] = $editable_roles; |
|
582 | - } |
|
583 | - |
|
584 | - foreach ( $editable_roles as $role => $details ) { |
|
585 | - $name = translate_user_role($details['name'] ); ?> |
|
576 | + global $frm_vars; |
|
577 | + if ( isset($frm_vars['editable_roles']) ) { |
|
578 | + $editable_roles = $frm_vars['editable_roles']; |
|
579 | + } else { |
|
580 | + $editable_roles = get_editable_roles(); |
|
581 | + $frm_vars['editable_roles'] = $editable_roles; |
|
582 | + } |
|
583 | + |
|
584 | + foreach ( $editable_roles as $role => $details ) { |
|
585 | + $name = translate_user_role($details['name'] ); ?> |
|
586 | 586 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
587 | 587 | <?php |
588 | - unset($role, $details); |
|
589 | - } |
|
590 | - } |
|
588 | + unset($role, $details); |
|
589 | + } |
|
590 | + } |
|
591 | 591 | |
592 | 592 | public static function frm_capabilities( $type = 'auto' ) { |
593 | - $cap = array( |
|
594 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
595 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
596 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
597 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
598 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
599 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
600 | - ); |
|
593 | + $cap = array( |
|
594 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
595 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
596 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
597 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
598 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
599 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
600 | + ); |
|
601 | 601 | |
602 | 602 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
603 | - return $cap; |
|
604 | - } |
|
603 | + return $cap; |
|
604 | + } |
|
605 | 605 | |
606 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
607 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
608 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
609 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
606 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
607 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
608 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
609 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
610 | 610 | |
611 | - return $cap; |
|
612 | - } |
|
611 | + return $cap; |
|
612 | + } |
|
613 | 613 | |
614 | 614 | public static function user_has_permission( $needed_role ) { |
615 | - if ( $needed_role == '-1' ) { |
|
616 | - return false; |
|
615 | + if ( $needed_role == '-1' ) { |
|
616 | + return false; |
|
617 | 617 | } |
618 | 618 | |
619 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
620 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
621 | - return true; |
|
622 | - } |
|
619 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
620 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
621 | + return true; |
|
622 | + } |
|
623 | 623 | |
624 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
625 | - foreach ( $roles as $role ) { |
|
624 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
625 | + foreach ( $roles as $role ) { |
|
626 | 626 | if ( current_user_can( $role ) ) { |
627 | - return true; |
|
627 | + return true; |
|
628 | 628 | } |
629 | - if ( $role == $needed_role ) { |
|
630 | - break; |
|
629 | + if ( $role == $needed_role ) { |
|
630 | + break; |
|
631 | 631 | } |
632 | - } |
|
633 | - return false; |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Make sure administrators can see Formidable menu |
|
638 | - * |
|
639 | - * @since 2.0 |
|
640 | - */ |
|
641 | - public static function maybe_add_permissions() { |
|
632 | + } |
|
633 | + return false; |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * Make sure administrators can see Formidable menu |
|
638 | + * |
|
639 | + * @since 2.0 |
|
640 | + */ |
|
641 | + public static function maybe_add_permissions() { |
|
642 | 642 | self::force_capability( 'frm_view_entries' ); |
643 | 643 | |
644 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
645 | - return; |
|
646 | - } |
|
644 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
645 | + return; |
|
646 | + } |
|
647 | 647 | |
648 | 648 | $user_id = get_current_user_id(); |
649 | 649 | $user = new WP_User( $user_id ); |
650 | - $frm_roles = self::frm_capabilities(); |
|
651 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
650 | + $frm_roles = self::frm_capabilities(); |
|
651 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
652 | 652 | $user->add_cap( $frm_role ); |
653 | - unset($frm_role, $frm_role_description); |
|
654 | - } |
|
655 | - } |
|
653 | + unset($frm_role, $frm_role_description); |
|
654 | + } |
|
655 | + } |
|
656 | 656 | |
657 | 657 | /** |
658 | 658 | * Make sure admins have permission to see the menu items |
@@ -668,28 +668,28 @@ discard block |
||
668 | 668 | } |
669 | 669 | } |
670 | 670 | |
671 | - /** |
|
672 | - * Check if the user has permision for action. |
|
673 | - * Return permission message and stop the action if no permission |
|
674 | - * @since 2.0 |
|
675 | - * @param string $permission |
|
676 | - */ |
|
671 | + /** |
|
672 | + * Check if the user has permision for action. |
|
673 | + * Return permission message and stop the action if no permission |
|
674 | + * @since 2.0 |
|
675 | + * @param string $permission |
|
676 | + */ |
|
677 | 677 | public static function permission_check( $permission, $show_message = 'show' ) { |
678 | - $permission_error = self::permission_nonce_error($permission); |
|
679 | - if ( $permission_error !== false ) { |
|
680 | - if ( 'hide' == $show_message ) { |
|
681 | - $permission_error = ''; |
|
682 | - } |
|
683 | - wp_die($permission_error); |
|
684 | - } |
|
685 | - } |
|
686 | - |
|
687 | - /** |
|
688 | - * Check user permission and nonce |
|
689 | - * @since 2.0 |
|
690 | - * @param string $permission |
|
691 | - * @return false|string The permission message or false if allowed |
|
692 | - */ |
|
678 | + $permission_error = self::permission_nonce_error($permission); |
|
679 | + if ( $permission_error !== false ) { |
|
680 | + if ( 'hide' == $show_message ) { |
|
681 | + $permission_error = ''; |
|
682 | + } |
|
683 | + wp_die($permission_error); |
|
684 | + } |
|
685 | + } |
|
686 | + |
|
687 | + /** |
|
688 | + * Check user permission and nonce |
|
689 | + * @since 2.0 |
|
690 | + * @param string $permission |
|
691 | + * @return false|string The permission message or false if allowed |
|
692 | + */ |
|
693 | 693 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
694 | 694 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
695 | 695 | $frm_settings = self::get_settings(); |
@@ -697,23 +697,23 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | $error = false; |
700 | - if ( empty($nonce_name) ) { |
|
701 | - return $error; |
|
702 | - } |
|
700 | + if ( empty($nonce_name) ) { |
|
701 | + return $error; |
|
702 | + } |
|
703 | 703 | |
704 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
705 | - $frm_settings = self::get_settings(); |
|
706 | - $error = $frm_settings->admin_permission; |
|
707 | - } |
|
704 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
705 | + $frm_settings = self::get_settings(); |
|
706 | + $error = $frm_settings->admin_permission; |
|
707 | + } |
|
708 | 708 | |
709 | - return $error; |
|
710 | - } |
|
709 | + return $error; |
|
710 | + } |
|
711 | 711 | |
712 | - public static function checked( $values, $current ) { |
|
712 | + public static function checked( $values, $current ) { |
|
713 | 713 | if ( self::check_selected( $values, $current ) ) { |
714 | - echo ' checked="checked"'; |
|
714 | + echo ' checked="checked"'; |
|
715 | 715 | } |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | 718 | public static function check_selected( $values, $current ) { |
719 | 719 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -723,50 +723,50 @@ discard block |
||
723 | 723 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
724 | 724 | } |
725 | 725 | |
726 | - /** |
|
727 | - * Check if current field option is an "other" option |
|
728 | - * |
|
729 | - * @since 2.0 |
|
730 | - * |
|
731 | - * @param string $opt_key |
|
732 | - * @return boolean Returns true if current field option is an "Other" option |
|
733 | - */ |
|
734 | - public static function is_other_opt( $opt_key ) { |
|
735 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
736 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
737 | - } |
|
738 | - |
|
739 | - /** |
|
740 | - * Get value that belongs in "Other" text box |
|
741 | - * |
|
742 | - * @since 2.0 |
|
743 | - * |
|
744 | - * @param string $opt_key |
|
745 | - * @param array $field |
|
746 | - * @return string $other_val |
|
747 | - */ |
|
748 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
726 | + /** |
|
727 | + * Check if current field option is an "other" option |
|
728 | + * |
|
729 | + * @since 2.0 |
|
730 | + * |
|
731 | + * @param string $opt_key |
|
732 | + * @return boolean Returns true if current field option is an "Other" option |
|
733 | + */ |
|
734 | + public static function is_other_opt( $opt_key ) { |
|
735 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
736 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
737 | + } |
|
738 | + |
|
739 | + /** |
|
740 | + * Get value that belongs in "Other" text box |
|
741 | + * |
|
742 | + * @since 2.0 |
|
743 | + * |
|
744 | + * @param string $opt_key |
|
745 | + * @param array $field |
|
746 | + * @return string $other_val |
|
747 | + */ |
|
748 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
749 | 749 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
750 | 750 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
751 | - } |
|
752 | - |
|
753 | - /** |
|
754 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
755 | - * Intended for front-end use |
|
756 | - * |
|
757 | - * @since 2.0 |
|
758 | - * |
|
759 | - * @param array $field |
|
760 | - * @param boolean $other_opt |
|
761 | - * @param string $checked |
|
762 | - * @param array $args should include opt_key and field name |
|
763 | - * @return string $other_val |
|
764 | - */ |
|
765 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
751 | + } |
|
752 | + |
|
753 | + /** |
|
754 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
755 | + * Intended for front-end use |
|
756 | + * |
|
757 | + * @since 2.0 |
|
758 | + * |
|
759 | + * @param array $field |
|
760 | + * @param boolean $other_opt |
|
761 | + * @param string $checked |
|
762 | + * @param array $args should include opt_key and field name |
|
763 | + * @return string $other_val |
|
764 | + */ |
|
765 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
766 | 766 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
767 | 767 | $args['field'] = $field; |
768 | 768 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
769 | - } |
|
769 | + } |
|
770 | 770 | |
771 | 771 | public static function recursive_function_map( $value, $function ) { |
772 | 772 | if ( is_array( $value ) ) { |
@@ -796,331 +796,331 @@ discard block |
||
796 | 796 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
797 | 797 | } |
798 | 798 | |
799 | - /** |
|
800 | - * Flatten a multi-dimensional array |
|
801 | - */ |
|
799 | + /** |
|
800 | + * Flatten a multi-dimensional array |
|
801 | + */ |
|
802 | 802 | public static function array_flatten( $array, $keys = 'keep' ) { |
803 | - $return = array(); |
|
804 | - foreach ( $array as $key => $value ) { |
|
805 | - if ( is_array($value) ) { |
|
803 | + $return = array(); |
|
804 | + foreach ( $array as $key => $value ) { |
|
805 | + if ( is_array($value) ) { |
|
806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
807 | - } else { |
|
807 | + } else { |
|
808 | 808 | if ( $keys == 'keep' ) { |
809 | 809 | $return[ $key ] = $value; |
810 | 810 | } else { |
811 | 811 | $return[] = $value; |
812 | 812 | } |
813 | - } |
|
814 | - } |
|
815 | - return $return; |
|
816 | - } |
|
817 | - |
|
818 | - public static function esc_textarea( $text ) { |
|
819 | - $safe_text = str_replace('"', '"', $text); |
|
820 | - $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
821 | - return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
822 | - } |
|
823 | - |
|
824 | - /** |
|
825 | - * Add auto paragraphs to text areas |
|
826 | - * @since 2.0 |
|
827 | - */ |
|
813 | + } |
|
814 | + } |
|
815 | + return $return; |
|
816 | + } |
|
817 | + |
|
818 | + public static function esc_textarea( $text ) { |
|
819 | + $safe_text = str_replace('"', '"', $text); |
|
820 | + $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
821 | + return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
822 | + } |
|
823 | + |
|
824 | + /** |
|
825 | + * Add auto paragraphs to text areas |
|
826 | + * @since 2.0 |
|
827 | + */ |
|
828 | 828 | public static function use_wpautop( $content ) { |
829 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
830 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
831 | - } |
|
832 | - return $content; |
|
833 | - } |
|
829 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
830 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
831 | + } |
|
832 | + return $content; |
|
833 | + } |
|
834 | 834 | |
835 | 835 | public static function replace_quotes( $val ) { |
836 | - //Replace double quotes |
|
836 | + //Replace double quotes |
|
837 | 837 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
838 | - //Replace single quotes |
|
839 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
840 | - return $val; |
|
841 | - } |
|
842 | - |
|
843 | - /** |
|
844 | - * @since 2.0 |
|
845 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
846 | - */ |
|
847 | - public static function jquery_ui_base_url() { |
|
848 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
849 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
850 | - return $url; |
|
851 | - } |
|
852 | - |
|
853 | - /** |
|
854 | - * @param string $handle |
|
855 | - */ |
|
838 | + //Replace single quotes |
|
839 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
840 | + return $val; |
|
841 | + } |
|
842 | + |
|
843 | + /** |
|
844 | + * @since 2.0 |
|
845 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
846 | + */ |
|
847 | + public static function jquery_ui_base_url() { |
|
848 | + $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
849 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
850 | + return $url; |
|
851 | + } |
|
852 | + |
|
853 | + /** |
|
854 | + * @param string $handle |
|
855 | + */ |
|
856 | 856 | public static function script_version( $handle ) { |
857 | - global $wp_scripts; |
|
858 | - if ( ! $wp_scripts ) { |
|
859 | - return false; |
|
860 | - } |
|
857 | + global $wp_scripts; |
|
858 | + if ( ! $wp_scripts ) { |
|
859 | + return false; |
|
860 | + } |
|
861 | 861 | |
862 | - $ver = 0; |
|
862 | + $ver = 0; |
|
863 | 863 | |
864 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
865 | - return $ver; |
|
866 | - } |
|
864 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
865 | + return $ver; |
|
866 | + } |
|
867 | 867 | |
868 | - $query = $wp_scripts->registered[ $handle ]; |
|
869 | - if ( is_object( $query ) ) { |
|
870 | - $ver = $query->ver; |
|
871 | - } |
|
868 | + $query = $wp_scripts->registered[ $handle ]; |
|
869 | + if ( is_object( $query ) ) { |
|
870 | + $ver = $query->ver; |
|
871 | + } |
|
872 | 872 | |
873 | - return $ver; |
|
874 | - } |
|
873 | + return $ver; |
|
874 | + } |
|
875 | 875 | |
876 | 876 | public static function js_redirect( $url ) { |
877 | 877 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
878 | - } |
|
878 | + } |
|
879 | 879 | |
880 | 880 | public static function get_user_id_param( $user_id ) { |
881 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
882 | - return $user_id; |
|
883 | - } |
|
881 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
882 | + return $user_id; |
|
883 | + } |
|
884 | 884 | |
885 | 885 | if ( $user_id == 'current' ) { |
886 | 886 | $user_id = get_current_user_id(); |
887 | 887 | } else { |
888 | - if ( is_email($user_id) ) { |
|
889 | - $user = get_user_by('email', $user_id); |
|
890 | - } else { |
|
891 | - $user = get_user_by('login', $user_id); |
|
892 | - } |
|
888 | + if ( is_email($user_id) ) { |
|
889 | + $user = get_user_by('email', $user_id); |
|
890 | + } else { |
|
891 | + $user = get_user_by('login', $user_id); |
|
892 | + } |
|
893 | 893 | |
894 | - if ( $user ) { |
|
895 | - $user_id = $user->ID; |
|
896 | - } |
|
897 | - unset($user); |
|
898 | - } |
|
894 | + if ( $user ) { |
|
895 | + $user_id = $user->ID; |
|
896 | + } |
|
897 | + unset($user); |
|
898 | + } |
|
899 | 899 | |
900 | - return $user_id; |
|
901 | - } |
|
900 | + return $user_id; |
|
901 | + } |
|
902 | 902 | |
903 | 903 | public static function get_file_contents( $filename, $atts = array() ) { |
904 | - if ( ! is_file($filename) ) { |
|
905 | - return false; |
|
906 | - } |
|
907 | - |
|
908 | - extract($atts); |
|
909 | - ob_start(); |
|
910 | - include($filename); |
|
911 | - $contents = ob_get_contents(); |
|
912 | - ob_end_clean(); |
|
913 | - return $contents; |
|
914 | - } |
|
915 | - |
|
916 | - /** |
|
917 | - * @param string $table_name |
|
918 | - * @param string $column |
|
904 | + if ( ! is_file($filename) ) { |
|
905 | + return false; |
|
906 | + } |
|
907 | + |
|
908 | + extract($atts); |
|
909 | + ob_start(); |
|
910 | + include($filename); |
|
911 | + $contents = ob_get_contents(); |
|
912 | + ob_end_clean(); |
|
913 | + return $contents; |
|
914 | + } |
|
915 | + |
|
916 | + /** |
|
917 | + * @param string $table_name |
|
918 | + * @param string $column |
|
919 | 919 | * @param int $id |
920 | 920 | * @param int $num_chars |
921 | - */ |
|
922 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
923 | - $key = ''; |
|
921 | + */ |
|
922 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
923 | + $key = ''; |
|
924 | 924 | |
925 | - if ( ! empty( $name ) ) { |
|
926 | - $key = sanitize_key($name); |
|
927 | - } |
|
925 | + if ( ! empty( $name ) ) { |
|
926 | + $key = sanitize_key($name); |
|
927 | + } |
|
928 | 928 | |
929 | 929 | if ( empty( $key ) ) { |
930 | - $max_slug_value = pow(36, $num_chars); |
|
931 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
932 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
933 | - } |
|
930 | + $max_slug_value = pow(36, $num_chars); |
|
931 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
932 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
933 | + } |
|
934 | 934 | |
935 | 935 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
936 | - $key = $key .'a'; |
|
937 | - } |
|
936 | + $key = $key .'a'; |
|
937 | + } |
|
938 | 938 | |
939 | 939 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
940 | 940 | |
941 | - if ( $key_check || is_numeric($key_check) ) { |
|
942 | - $suffix = 2; |
|
941 | + if ( $key_check || is_numeric($key_check) ) { |
|
942 | + $suffix = 2; |
|
943 | 943 | do { |
944 | 944 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
945 | 945 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
946 | 946 | $suffix++; |
947 | 947 | } while ($key_check || is_numeric($key_check)); |
948 | 948 | $key = $alt_post_name; |
949 | - } |
|
950 | - return $key; |
|
951 | - } |
|
952 | - |
|
953 | - /** |
|
954 | - * Editing a Form or Entry |
|
955 | - * @param string $table |
|
956 | - * @return bool|array |
|
957 | - */ |
|
958 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
959 | - if ( ! $record ) { |
|
960 | - return false; |
|
961 | - } |
|
962 | - |
|
963 | - if ( empty($post_values) ) { |
|
964 | - $post_values = stripslashes_deep($_POST); |
|
965 | - } |
|
949 | + } |
|
950 | + return $key; |
|
951 | + } |
|
952 | + |
|
953 | + /** |
|
954 | + * Editing a Form or Entry |
|
955 | + * @param string $table |
|
956 | + * @return bool|array |
|
957 | + */ |
|
958 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
959 | + if ( ! $record ) { |
|
960 | + return false; |
|
961 | + } |
|
962 | + |
|
963 | + if ( empty($post_values) ) { |
|
964 | + $post_values = stripslashes_deep($_POST); |
|
965 | + } |
|
966 | 966 | |
967 | 967 | $values = array( 'id' => $record->id, 'fields' => array() ); |
968 | 968 | |
969 | 969 | foreach ( array( 'name', 'description' ) as $var ) { |
970 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
971 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
972 | - unset($var, $default_val); |
|
973 | - } |
|
974 | - |
|
975 | - $values['description'] = self::use_wpautop($values['description']); |
|
976 | - $frm_settings = self::get_settings(); |
|
977 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
978 | - |
|
979 | - foreach ( (array) $fields as $field ) { |
|
980 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
981 | - if ( ! $is_form_builder ) { |
|
982 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
983 | - } |
|
970 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
971 | + $values[ $var ] = self::get_param( $var, $default_val ); |
|
972 | + unset($var, $default_val); |
|
973 | + } |
|
974 | + |
|
975 | + $values['description'] = self::use_wpautop($values['description']); |
|
976 | + $frm_settings = self::get_settings(); |
|
977 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
978 | + |
|
979 | + foreach ( (array) $fields as $field ) { |
|
980 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
981 | + if ( ! $is_form_builder ) { |
|
982 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
983 | + } |
|
984 | 984 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
985 | 985 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
986 | - } |
|
986 | + } |
|
987 | 987 | |
988 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
988 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
989 | 989 | |
990 | - if ( $table == 'entries' ) { |
|
991 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
992 | - } else if ( $table == 'forms' ) { |
|
993 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
994 | - } |
|
990 | + if ( $table == 'entries' ) { |
|
991 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
992 | + } else if ( $table == 'forms' ) { |
|
993 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
994 | + } |
|
995 | 995 | |
996 | - return $values; |
|
997 | - } |
|
996 | + return $values; |
|
997 | + } |
|
998 | 998 | |
999 | 999 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
1000 | - $post_values = $args['post_values']; |
|
1001 | - |
|
1002 | - if ( $args['default'] ) { |
|
1003 | - $meta_value = $field->default_value; |
|
1004 | - } else { |
|
1005 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1006 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1007 | - $field->field_options['custom_field'] = ''; |
|
1008 | - } |
|
1000 | + $post_values = $args['post_values']; |
|
1001 | + |
|
1002 | + if ( $args['default'] ) { |
|
1003 | + $meta_value = $field->default_value; |
|
1004 | + } else { |
|
1005 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1006 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
1007 | + $field->field_options['custom_field'] = ''; |
|
1008 | + } |
|
1009 | 1009 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
1010 | - } else { |
|
1010 | + } else { |
|
1011 | 1011 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1016 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1017 | - |
|
1018 | - $field_array = array( |
|
1019 | - 'id' => $field->id, |
|
1020 | - 'value' => $new_value, |
|
1021 | - 'default_value' => $field->default_value, |
|
1022 | - 'name' => $field->name, |
|
1023 | - 'description' => $field->description, |
|
1024 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1025 | - 'options' => $field->options, |
|
1026 | - 'required' => $field->required, |
|
1027 | - 'field_key' => $field->field_key, |
|
1028 | - 'field_order' => $field->field_order, |
|
1029 | - 'form_id' => $field->form_id, |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1016 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1017 | + |
|
1018 | + $field_array = array( |
|
1019 | + 'id' => $field->id, |
|
1020 | + 'value' => $new_value, |
|
1021 | + 'default_value' => $field->default_value, |
|
1022 | + 'name' => $field->name, |
|
1023 | + 'description' => $field->description, |
|
1024 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1025 | + 'options' => $field->options, |
|
1026 | + 'required' => $field->required, |
|
1027 | + 'field_key' => $field->field_key, |
|
1028 | + 'field_order' => $field->field_order, |
|
1029 | + 'form_id' => $field->form_id, |
|
1030 | 1030 | 'parent_form_id' => $args['parent_form_id'], |
1031 | - ); |
|
1031 | + ); |
|
1032 | 1032 | |
1033 | - $args['field_type'] = $field_type; |
|
1034 | - self::fill_field_opts($field, $field_array, $args); |
|
1033 | + $args['field_type'] = $field_type; |
|
1034 | + self::fill_field_opts($field, $field_array, $args); |
|
1035 | 1035 | |
1036 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1036 | + $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1037 | 1037 | |
1038 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1039 | - $field_array['unique_msg'] = ''; |
|
1040 | - } |
|
1038 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1039 | + $field_array['unique_msg'] = ''; |
|
1040 | + } |
|
1041 | 1041 | |
1042 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
1042 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
1043 | 1043 | |
1044 | - $values['fields'][ $field->id ] = $field_array; |
|
1045 | - } |
|
1044 | + $values['fields'][ $field->id ] = $field_array; |
|
1045 | + } |
|
1046 | 1046 | |
1047 | 1047 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1048 | - $post_values = $args['post_values']; |
|
1049 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1050 | - |
|
1051 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1052 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1053 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1054 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1055 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1056 | - if ( $args['field_type'] == 'captcha' ) { |
|
1057 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1058 | - } else { |
|
1059 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1060 | - } |
|
1061 | - } |
|
1062 | - } |
|
1063 | - |
|
1064 | - if ( $field_array['custom_html'] == '' ) { |
|
1065 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1066 | - } |
|
1067 | - } |
|
1068 | - |
|
1069 | - /** |
|
1070 | - * @param string $table |
|
1071 | - */ |
|
1048 | + $post_values = $args['post_values']; |
|
1049 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1050 | + |
|
1051 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
1052 | + $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1053 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1054 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1055 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1056 | + if ( $args['field_type'] == 'captcha' ) { |
|
1057 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1058 | + } else { |
|
1059 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1060 | + } |
|
1061 | + } |
|
1062 | + } |
|
1063 | + |
|
1064 | + if ( $field_array['custom_html'] == '' ) { |
|
1065 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1066 | + } |
|
1067 | + } |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * @param string $table |
|
1071 | + */ |
|
1072 | 1072 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
1073 | - if ( $table == 'entries' ) { |
|
1074 | - $form = $record->form_id; |
|
1073 | + if ( $table == 'entries' ) { |
|
1074 | + $form = $record->form_id; |
|
1075 | 1075 | FrmForm::maybe_get_form( $form ); |
1076 | - } else { |
|
1077 | - $form = $record; |
|
1078 | - } |
|
1076 | + } else { |
|
1077 | + $form = $record; |
|
1078 | + } |
|
1079 | 1079 | |
1080 | - if ( ! $form ) { |
|
1081 | - return; |
|
1082 | - } |
|
1080 | + if ( ! $form ) { |
|
1081 | + return; |
|
1082 | + } |
|
1083 | 1083 | |
1084 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1084 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1085 | 1085 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1086 | 1086 | |
1087 | - if ( ! is_array($form->options) ) { |
|
1088 | - return; |
|
1089 | - } |
|
1087 | + if ( ! is_array($form->options) ) { |
|
1088 | + return; |
|
1089 | + } |
|
1090 | 1090 | |
1091 | - foreach ( $form->options as $opt => $value ) { |
|
1092 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1093 | - } |
|
1091 | + foreach ( $form->options as $opt => $value ) { |
|
1092 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1093 | + } |
|
1094 | 1094 | |
1095 | - self::fill_form_defaults($post_values, $values); |
|
1096 | - } |
|
1095 | + self::fill_form_defaults($post_values, $values); |
|
1096 | + } |
|
1097 | 1097 | |
1098 | - /** |
|
1099 | - * Set to POST value or default |
|
1100 | - */ |
|
1098 | + /** |
|
1099 | + * Set to POST value or default |
|
1100 | + */ |
|
1101 | 1101 | private static function fill_form_defaults( $post_values, array &$values ) { |
1102 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1102 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
1103 | 1103 | |
1104 | - foreach ( $form_defaults as $opt => $default ) { |
|
1105 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1104 | + foreach ( $form_defaults as $opt => $default ) { |
|
1105 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1106 | 1106 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
1107 | - } |
|
1107 | + } |
|
1108 | 1108 | |
1109 | - unset($opt, $defaut); |
|
1110 | - } |
|
1109 | + unset($opt, $defaut); |
|
1110 | + } |
|
1111 | 1111 | |
1112 | - if ( ! isset($values['custom_style']) ) { |
|
1113 | - $frm_settings = self::get_settings(); |
|
1112 | + if ( ! isset($values['custom_style']) ) { |
|
1113 | + $frm_settings = self::get_settings(); |
|
1114 | 1114 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1115 | - } |
|
1115 | + } |
|
1116 | 1116 | |
1117 | 1117 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1118 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1119 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1120 | - } |
|
1121 | - unset($h); |
|
1122 | - } |
|
1123 | - } |
|
1118 | + if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1119 | + $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1120 | + } |
|
1121 | + unset($h); |
|
1122 | + } |
|
1123 | + } |
|
1124 | 1124 | |
1125 | 1125 | public static function get_meta_value( $field_id, $entry ) { |
1126 | 1126 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1128,69 +1128,69 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | public static function insert_opt_html( $args ) { |
1131 | - $class = ''; |
|
1132 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1133 | - $class .= 'show_frm_not_email_to'; |
|
1134 | - } |
|
1135 | - ?> |
|
1131 | + $class = ''; |
|
1132 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
1133 | + $class .= 'show_frm_not_email_to'; |
|
1134 | + } |
|
1135 | + ?> |
|
1136 | 1136 | <li> |
1137 | 1137 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
1138 | 1138 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
1139 | 1139 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
1140 | 1140 | </li> |
1141 | 1141 | <?php |
1142 | - } |
|
1142 | + } |
|
1143 | 1143 | |
1144 | - public static function get_us_states() { |
|
1145 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1146 | - return FrmFieldsHelper::get_us_states(); |
|
1147 | - } |
|
1144 | + public static function get_us_states() { |
|
1145 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
1146 | + return FrmFieldsHelper::get_us_states(); |
|
1147 | + } |
|
1148 | 1148 | |
1149 | - public static function get_countries() { |
|
1150 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1151 | - return FrmFieldsHelper::get_countries(); |
|
1152 | - } |
|
1149 | + public static function get_countries() { |
|
1150 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
1151 | + return FrmFieldsHelper::get_countries(); |
|
1152 | + } |
|
1153 | 1153 | |
1154 | 1154 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
1155 | - if ( is_array( $str ) ) { |
|
1156 | - return; |
|
1155 | + if ( is_array( $str ) ) { |
|
1156 | + return; |
|
1157 | 1157 | } |
1158 | 1158 | |
1159 | - $length = (int) $length; |
|
1159 | + $length = (int) $length; |
|
1160 | 1160 | $str = wp_strip_all_tags( $str ); |
1161 | 1161 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
1162 | 1162 | |
1163 | 1163 | if ( $length == 0 ) { |
1164 | - return ''; |
|
1165 | - } else if ( $length <= 10 ) { |
|
1164 | + return ''; |
|
1165 | + } else if ( $length <= 10 ) { |
|
1166 | 1166 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1167 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1168 | - } |
|
1167 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
1168 | + } |
|
1169 | 1169 | |
1170 | - $sub = ''; |
|
1171 | - $len = 0; |
|
1170 | + $sub = ''; |
|
1171 | + $len = 0; |
|
1172 | 1172 | |
1173 | 1173 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1174 | 1174 | |
1175 | 1175 | foreach ( $words as $word ) { |
1176 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1176 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
1177 | 1177 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1178 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1179 | - break; |
|
1180 | - } |
|
1178 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
1179 | + break; |
|
1180 | + } |
|
1181 | 1181 | |
1182 | - $sub .= $part; |
|
1182 | + $sub .= $part; |
|
1183 | 1183 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1184 | 1184 | |
1185 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1186 | - break; |
|
1187 | - } |
|
1185 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1186 | + break; |
|
1187 | + } |
|
1188 | 1188 | |
1189 | - unset($total_len, $word); |
|
1190 | - } |
|
1189 | + unset($total_len, $word); |
|
1190 | + } |
|
1191 | 1191 | |
1192 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1193 | - } |
|
1192 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
1193 | + } |
|
1194 | 1194 | |
1195 | 1195 | public static function mb_function( $function_names, $args ) { |
1196 | 1196 | $mb_function_name = $function_names[0]; |
@@ -1202,18 +1202,18 @@ discard block |
||
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1205 | - if ( empty($date) ) { |
|
1206 | - return $date; |
|
1207 | - } |
|
1205 | + if ( empty($date) ) { |
|
1206 | + return $date; |
|
1207 | + } |
|
1208 | 1208 | |
1209 | - if ( empty($date_format) ) { |
|
1210 | - $date_format = get_option('date_format'); |
|
1211 | - } |
|
1209 | + if ( empty($date_format) ) { |
|
1210 | + $date_format = get_option('date_format'); |
|
1211 | + } |
|
1212 | 1212 | |
1213 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1214 | - $frmpro_settings = new FrmProSettings(); |
|
1215 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1216 | - } |
|
1213 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1214 | + $frmpro_settings = new FrmProSettings(); |
|
1215 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1216 | + } |
|
1217 | 1217 | |
1218 | 1218 | $formatted = self::get_localized_date( $date_format, $date ); |
1219 | 1219 | |
@@ -1222,8 +1222,8 @@ discard block |
||
1222 | 1222 | $formatted .= self::add_time_to_date( $time_format, $date ); |
1223 | 1223 | } |
1224 | 1224 | |
1225 | - return $formatted; |
|
1226 | - } |
|
1225 | + return $formatted; |
|
1226 | + } |
|
1227 | 1227 | |
1228 | 1228 | private static function add_time_to_date( $time_format, $date ) { |
1229 | 1229 | if ( empty( $time_format ) ) { |
@@ -1304,61 +1304,61 @@ discard block |
||
1304 | 1304 | ); |
1305 | 1305 | } |
1306 | 1306 | |
1307 | - /** |
|
1308 | - * Added for < WP 4.0 compatability |
|
1309 | - * |
|
1310 | - * @since 1.07.10 |
|
1311 | - * |
|
1312 | - * @param string $term The value to escape |
|
1313 | - * @return string The escaped value |
|
1314 | - */ |
|
1307 | + /** |
|
1308 | + * Added for < WP 4.0 compatability |
|
1309 | + * |
|
1310 | + * @since 1.07.10 |
|
1311 | + * |
|
1312 | + * @param string $term The value to escape |
|
1313 | + * @return string The escaped value |
|
1314 | + */ |
|
1315 | 1315 | public static function esc_like( $term ) { |
1316 | - global $wpdb; |
|
1317 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1316 | + global $wpdb; |
|
1317 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
1318 | 1318 | // WP 4.0 |
1319 | - $term = $wpdb->esc_like( $term ); |
|
1320 | - } else { |
|
1321 | - $term = like_escape( $term ); |
|
1322 | - } |
|
1319 | + $term = $wpdb->esc_like( $term ); |
|
1320 | + } else { |
|
1321 | + $term = like_escape( $term ); |
|
1322 | + } |
|
1323 | 1323 | |
1324 | - return $term; |
|
1325 | - } |
|
1324 | + return $term; |
|
1325 | + } |
|
1326 | 1326 | |
1327 | - /** |
|
1328 | - * @param string $order_query |
|
1329 | - */ |
|
1327 | + /** |
|
1328 | + * @param string $order_query |
|
1329 | + */ |
|
1330 | 1330 | public static function esc_order( $order_query ) { |
1331 | - if ( empty($order_query) ) { |
|
1332 | - return ''; |
|
1333 | - } |
|
1334 | - |
|
1335 | - // remove ORDER BY before santizing |
|
1336 | - $order_query = strtolower($order_query); |
|
1337 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1338 | - $order_query = str_replace('order by', '', $order_query); |
|
1339 | - } |
|
1340 | - |
|
1341 | - $order_query = explode(' ', trim($order_query)); |
|
1342 | - |
|
1343 | - $order_fields = array( |
|
1344 | - 'id', 'form_key', 'name', 'description', |
|
1345 | - 'parent_form_id', 'logged_in', 'is_template', |
|
1346 | - 'default_template', 'status', 'created_at', |
|
1347 | - ); |
|
1348 | - |
|
1349 | - $order = trim(trim(reset($order_query), ',')); |
|
1350 | - if ( ! in_array($order, $order_fields) ) { |
|
1351 | - return ''; |
|
1352 | - } |
|
1353 | - |
|
1354 | - $order_by = ''; |
|
1355 | - if ( count($order_query) > 1 ) { |
|
1331 | + if ( empty($order_query) ) { |
|
1332 | + return ''; |
|
1333 | + } |
|
1334 | + |
|
1335 | + // remove ORDER BY before santizing |
|
1336 | + $order_query = strtolower($order_query); |
|
1337 | + if ( strpos($order_query, 'order by') !== false ) { |
|
1338 | + $order_query = str_replace('order by', '', $order_query); |
|
1339 | + } |
|
1340 | + |
|
1341 | + $order_query = explode(' ', trim($order_query)); |
|
1342 | + |
|
1343 | + $order_fields = array( |
|
1344 | + 'id', 'form_key', 'name', 'description', |
|
1345 | + 'parent_form_id', 'logged_in', 'is_template', |
|
1346 | + 'default_template', 'status', 'created_at', |
|
1347 | + ); |
|
1348 | + |
|
1349 | + $order = trim(trim(reset($order_query), ',')); |
|
1350 | + if ( ! in_array($order, $order_fields) ) { |
|
1351 | + return ''; |
|
1352 | + } |
|
1353 | + |
|
1354 | + $order_by = ''; |
|
1355 | + if ( count($order_query) > 1 ) { |
|
1356 | 1356 | $order_by = end( $order_query ); |
1357 | 1357 | self::esc_order_by( $order_by ); |
1358 | - } |
|
1358 | + } |
|
1359 | 1359 | |
1360 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1361 | - } |
|
1360 | + return ' ORDER BY '. $order . ' '. $order_by; |
|
1361 | + } |
|
1362 | 1362 | |
1363 | 1363 | /** |
1364 | 1364 | * Make sure this is ordering by either ASC or DESC |
@@ -1370,183 +1370,183 @@ discard block |
||
1370 | 1370 | } |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - /** |
|
1374 | - * @param string $limit |
|
1375 | - */ |
|
1373 | + /** |
|
1374 | + * @param string $limit |
|
1375 | + */ |
|
1376 | 1376 | public static function esc_limit( $limit ) { |
1377 | - if ( empty($limit) ) { |
|
1378 | - return ''; |
|
1379 | - } |
|
1380 | - |
|
1381 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1382 | - if ( is_numeric($limit) ) { |
|
1383 | - return ' LIMIT '. $limit; |
|
1384 | - } |
|
1385 | - |
|
1386 | - $limit = explode(',', trim($limit)); |
|
1387 | - foreach ( $limit as $k => $l ) { |
|
1388 | - if ( is_numeric( $l ) ) { |
|
1389 | - $limit[ $k ] = $l; |
|
1390 | - } |
|
1391 | - } |
|
1392 | - |
|
1393 | - $limit = implode(',', $limit); |
|
1394 | - return ' LIMIT '. $limit; |
|
1395 | - } |
|
1396 | - |
|
1397 | - /** |
|
1398 | - * Get an array of values ready to go through $wpdb->prepare |
|
1399 | - * @since 2.0 |
|
1400 | - */ |
|
1401 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
1402 | - $placeholders = array_fill(0, count($array), $type); |
|
1403 | - return implode(', ', $placeholders); |
|
1404 | - } |
|
1405 | - |
|
1406 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1407 | - if ( empty($where) ) { |
|
1408 | - return ''; |
|
1409 | - } |
|
1377 | + if ( empty($limit) ) { |
|
1378 | + return ''; |
|
1379 | + } |
|
1380 | + |
|
1381 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1382 | + if ( is_numeric($limit) ) { |
|
1383 | + return ' LIMIT '. $limit; |
|
1384 | + } |
|
1385 | + |
|
1386 | + $limit = explode(',', trim($limit)); |
|
1387 | + foreach ( $limit as $k => $l ) { |
|
1388 | + if ( is_numeric( $l ) ) { |
|
1389 | + $limit[ $k ] = $l; |
|
1390 | + } |
|
1391 | + } |
|
1392 | + |
|
1393 | + $limit = implode(',', $limit); |
|
1394 | + return ' LIMIT '. $limit; |
|
1395 | + } |
|
1396 | + |
|
1397 | + /** |
|
1398 | + * Get an array of values ready to go through $wpdb->prepare |
|
1399 | + * @since 2.0 |
|
1400 | + */ |
|
1401 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
1402 | + $placeholders = array_fill(0, count($array), $type); |
|
1403 | + return implode(', ', $placeholders); |
|
1404 | + } |
|
1405 | + |
|
1406 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
1407 | + if ( empty($where) ) { |
|
1408 | + return ''; |
|
1409 | + } |
|
1410 | 1410 | |
1411 | 1411 | if ( is_array( $where ) ) { |
1412 | - global $wpdb; |
|
1413 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1412 | + global $wpdb; |
|
1413 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
1414 | 1414 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
1415 | 1415 | } else { |
1416 | - $where = $starts_with . $where; |
|
1417 | - } |
|
1416 | + $where = $starts_with . $where; |
|
1417 | + } |
|
1418 | 1418 | |
1419 | - return $where; |
|
1420 | - } |
|
1419 | + return $where; |
|
1420 | + } |
|
1421 | 1421 | |
1422 | - // Pagination Methods |
|
1422 | + // Pagination Methods |
|
1423 | 1423 | |
1424 | - /** |
|
1425 | - * @param integer $current_p |
|
1426 | - */ |
|
1424 | + /** |
|
1425 | + * @param integer $current_p |
|
1426 | + */ |
|
1427 | 1427 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
1428 | 1428 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
1429 | 1429 | } |
1430 | 1430 | |
1431 | - /** |
|
1432 | - * @param integer $current_p |
|
1433 | - */ |
|
1434 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1435 | - if ( $current_p == 1 ) { |
|
1436 | - return 1; |
|
1437 | - } else { |
|
1438 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1439 | - } |
|
1440 | - } |
|
1441 | - |
|
1442 | - /** |
|
1443 | - * @param string $table_name |
|
1444 | - */ |
|
1445 | - public static function &getRecordCount( $where = '', $table_name ) { |
|
1446 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1447 | - $count = FrmDb::get_count( $table_name, $where ); |
|
1448 | - return $count; |
|
1449 | - } |
|
1450 | - |
|
1451 | - public static function get_referer_info() { |
|
1452 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1453 | - return self::get_server_value('HTTP_REFERER'); |
|
1454 | - } |
|
1431 | + /** |
|
1432 | + * @param integer $current_p |
|
1433 | + */ |
|
1434 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
1435 | + if ( $current_p == 1 ) { |
|
1436 | + return 1; |
|
1437 | + } else { |
|
1438 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
1439 | + } |
|
1440 | + } |
|
1441 | + |
|
1442 | + /** |
|
1443 | + * @param string $table_name |
|
1444 | + */ |
|
1445 | + public static function &getRecordCount( $where = '', $table_name ) { |
|
1446 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
1447 | + $count = FrmDb::get_count( $table_name, $where ); |
|
1448 | + return $count; |
|
1449 | + } |
|
1450 | + |
|
1451 | + public static function get_referer_info() { |
|
1452 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
1453 | + return self::get_server_value('HTTP_REFERER'); |
|
1454 | + } |
|
1455 | 1455 | |
1456 | 1456 | /** |
1457 | 1457 | * @return array |
1458 | 1458 | */ |
1459 | 1459 | public static function json_to_array( $json_vars ) { |
1460 | - $vars = array(); |
|
1461 | - foreach ( $json_vars as $jv ) { |
|
1462 | - $jv_name = explode('[', $jv['name']); |
|
1463 | - $last = count($jv_name) - 1; |
|
1464 | - foreach ( $jv_name as $p => $n ) { |
|
1465 | - $name = trim($n, ']'); |
|
1466 | - if ( ! isset($l1) ) { |
|
1467 | - $l1 = $name; |
|
1468 | - } |
|
1469 | - |
|
1470 | - if ( ! isset($l2) ) { |
|
1471 | - $l2 = $name; |
|
1472 | - } |
|
1473 | - |
|
1474 | - if ( ! isset($l3) ) { |
|
1475 | - $l3 = $name; |
|
1476 | - } |
|
1477 | - |
|
1478 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1479 | - |
|
1480 | - switch ( $p ) { |
|
1481 | - case 0: |
|
1482 | - $l1 = $name; |
|
1483 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1484 | - break; |
|
1485 | - |
|
1486 | - case 1: |
|
1487 | - $l2 = $name; |
|
1488 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1489 | - break; |
|
1490 | - |
|
1491 | - case 2: |
|
1492 | - $l3 = $name; |
|
1493 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1494 | - break; |
|
1495 | - |
|
1496 | - case 3: |
|
1497 | - $l4 = $name; |
|
1498 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1499 | - break; |
|
1500 | - } |
|
1501 | - |
|
1502 | - unset($this_val, $n); |
|
1503 | - } |
|
1504 | - |
|
1505 | - unset($last, $jv); |
|
1506 | - } |
|
1507 | - |
|
1508 | - return $vars; |
|
1509 | - } |
|
1510 | - |
|
1511 | - /** |
|
1512 | - * @param string $name |
|
1513 | - * @param string $l1 |
|
1514 | - */ |
|
1515 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1516 | - if ( $name == '' ) { |
|
1517 | - $vars[] = $val; |
|
1518 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1519 | - $vars[ $l1 ] = $val; |
|
1520 | - } |
|
1521 | - } |
|
1460 | + $vars = array(); |
|
1461 | + foreach ( $json_vars as $jv ) { |
|
1462 | + $jv_name = explode('[', $jv['name']); |
|
1463 | + $last = count($jv_name) - 1; |
|
1464 | + foreach ( $jv_name as $p => $n ) { |
|
1465 | + $name = trim($n, ']'); |
|
1466 | + if ( ! isset($l1) ) { |
|
1467 | + $l1 = $name; |
|
1468 | + } |
|
1469 | + |
|
1470 | + if ( ! isset($l2) ) { |
|
1471 | + $l2 = $name; |
|
1472 | + } |
|
1473 | + |
|
1474 | + if ( ! isset($l3) ) { |
|
1475 | + $l3 = $name; |
|
1476 | + } |
|
1477 | + |
|
1478 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
1479 | + |
|
1480 | + switch ( $p ) { |
|
1481 | + case 0: |
|
1482 | + $l1 = $name; |
|
1483 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
1484 | + break; |
|
1485 | + |
|
1486 | + case 1: |
|
1487 | + $l2 = $name; |
|
1488 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1489 | + break; |
|
1490 | + |
|
1491 | + case 2: |
|
1492 | + $l3 = $name; |
|
1493 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1494 | + break; |
|
1495 | + |
|
1496 | + case 3: |
|
1497 | + $l4 = $name; |
|
1498 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1499 | + break; |
|
1500 | + } |
|
1501 | + |
|
1502 | + unset($this_val, $n); |
|
1503 | + } |
|
1504 | + |
|
1505 | + unset($last, $jv); |
|
1506 | + } |
|
1507 | + |
|
1508 | + return $vars; |
|
1509 | + } |
|
1510 | + |
|
1511 | + /** |
|
1512 | + * @param string $name |
|
1513 | + * @param string $l1 |
|
1514 | + */ |
|
1515 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
1516 | + if ( $name == '' ) { |
|
1517 | + $vars[] = $val; |
|
1518 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1519 | + $vars[ $l1 ] = $val; |
|
1520 | + } |
|
1521 | + } |
|
1522 | 1522 | |
1523 | 1523 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
1524 | - $tooltips = array( |
|
1525 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1526 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1527 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1528 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1529 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1530 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1531 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1532 | - ); |
|
1533 | - |
|
1534 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1535 | - return; |
|
1536 | - } |
|
1537 | - |
|
1538 | - if ( 'open' == $class ) { |
|
1539 | - echo ' frm_help"'; |
|
1540 | - } else { |
|
1541 | - echo ' class="frm_help"'; |
|
1542 | - } |
|
1543 | - |
|
1544 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1545 | - |
|
1546 | - if ( 'open' != $class ) { |
|
1547 | - echo '"'; |
|
1548 | - } |
|
1549 | - } |
|
1524 | + $tooltips = array( |
|
1525 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
1526 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
1527 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1528 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1529 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
1530 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
1531 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
1532 | + ); |
|
1533 | + |
|
1534 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
1535 | + return; |
|
1536 | + } |
|
1537 | + |
|
1538 | + if ( 'open' == $class ) { |
|
1539 | + echo ' frm_help"'; |
|
1540 | + } else { |
|
1541 | + echo ' class="frm_help"'; |
|
1542 | + } |
|
1543 | + |
|
1544 | + echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1545 | + |
|
1546 | + if ( 'open' != $class ) { |
|
1547 | + echo '"'; |
|
1548 | + } |
|
1549 | + } |
|
1550 | 1550 | |
1551 | 1551 | /** |
1552 | 1552 | * Add the current_page class to that page in the form nav |
@@ -1562,35 +1562,35 @@ discard block |
||
1562 | 1562 | } |
1563 | 1563 | } |
1564 | 1564 | |
1565 | - /** |
|
1566 | - * Prepare and json_encode post content |
|
1567 | - * |
|
1568 | - * @since 2.0 |
|
1569 | - * |
|
1570 | - * @param array $post_content |
|
1571 | - * @return string $post_content ( json encoded array ) |
|
1572 | - */ |
|
1573 | - public static function prepare_and_encode( $post_content ) { |
|
1574 | - //Loop through array to strip slashes and add only the needed ones |
|
1565 | + /** |
|
1566 | + * Prepare and json_encode post content |
|
1567 | + * |
|
1568 | + * @since 2.0 |
|
1569 | + * |
|
1570 | + * @param array $post_content |
|
1571 | + * @return string $post_content ( json encoded array ) |
|
1572 | + */ |
|
1573 | + public static function prepare_and_encode( $post_content ) { |
|
1574 | + //Loop through array to strip slashes and add only the needed ones |
|
1575 | 1575 | foreach ( $post_content as $key => $val ) { |
1576 | 1576 | // Replace problematic characters (like ") |
1577 | 1577 | $val = str_replace( '"', '"', $val ); |
1578 | 1578 | |
1579 | 1579 | self::prepare_action_slashes( $val, $key, $post_content ); |
1580 | - unset( $key, $val ); |
|
1581 | - } |
|
1580 | + unset( $key, $val ); |
|
1581 | + } |
|
1582 | 1582 | |
1583 | - // json_encode the array |
|
1584 | - $post_content = json_encode( $post_content ); |
|
1583 | + // json_encode the array |
|
1584 | + $post_content = json_encode( $post_content ); |
|
1585 | 1585 | |
1586 | - // add extra slashes for \r\n since WP strips them |
|
1586 | + // add extra slashes for \r\n since WP strips them |
|
1587 | 1587 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
1588 | 1588 | |
1589 | - // allow for " |
|
1590 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
1589 | + // allow for " |
|
1590 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
1591 | 1591 | |
1592 | - return $post_content; |
|
1593 | - } |
|
1592 | + return $post_content; |
|
1593 | + } |
|
1594 | 1594 | |
1595 | 1595 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1596 | 1596 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1658,64 +1658,64 @@ discard block |
||
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | public static function maybe_json_decode( $string ) { |
1661 | - if ( is_array($string) ) { |
|
1662 | - return $string; |
|
1663 | - } |
|
1661 | + if ( is_array($string) ) { |
|
1662 | + return $string; |
|
1663 | + } |
|
1664 | 1664 | |
1665 | - $new_string = json_decode($string, true); |
|
1666 | - if ( function_exists('json_last_error') ) { |
|
1665 | + $new_string = json_decode($string, true); |
|
1666 | + if ( function_exists('json_last_error') ) { |
|
1667 | 1667 | // php 5.3+ |
1668 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1669 | - $string = $new_string; |
|
1670 | - } |
|
1671 | - } else if ( isset($new_string) ) { |
|
1668 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
1669 | + $string = $new_string; |
|
1670 | + } |
|
1671 | + } else if ( isset($new_string) ) { |
|
1672 | 1672 | // php < 5.3 fallback |
1673 | - $string = $new_string; |
|
1674 | - } |
|
1675 | - return $string; |
|
1676 | - } |
|
1677 | - |
|
1678 | - /** |
|
1679 | - * @since 1.07.10 |
|
1680 | - * |
|
1681 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
1682 | - * @return echo The javascript to open and highlight the Formidable menu |
|
1683 | - */ |
|
1673 | + $string = $new_string; |
|
1674 | + } |
|
1675 | + return $string; |
|
1676 | + } |
|
1677 | + |
|
1678 | + /** |
|
1679 | + * @since 1.07.10 |
|
1680 | + * |
|
1681 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
1682 | + * @return echo The javascript to open and highlight the Formidable menu |
|
1683 | + */ |
|
1684 | 1684 | public static function maybe_highlight_menu( $post_type ) { |
1685 | - global $post, $pagenow; |
|
1685 | + global $post, $pagenow; |
|
1686 | 1686 | |
1687 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1688 | - return; |
|
1689 | - } |
|
1687 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1688 | + return; |
|
1689 | + } |
|
1690 | 1690 | |
1691 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1692 | - return; |
|
1693 | - } |
|
1691 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
1692 | + return; |
|
1693 | + } |
|
1694 | 1694 | |
1695 | - self::load_admin_wide_js(); |
|
1696 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1697 | - } |
|
1695 | + self::load_admin_wide_js(); |
|
1696 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
1697 | + } |
|
1698 | 1698 | |
1699 | - /** |
|
1700 | - * Load the JS file on non-Formidable pages in the admin area |
|
1701 | - * @since 2.0 |
|
1702 | - */ |
|
1699 | + /** |
|
1700 | + * Load the JS file on non-Formidable pages in the admin area |
|
1701 | + * @since 2.0 |
|
1702 | + */ |
|
1703 | 1703 | public static function load_admin_wide_js( $load = true ) { |
1704 | - $version = FrmAppHelper::plugin_version(); |
|
1704 | + $version = FrmAppHelper::plugin_version(); |
|
1705 | 1705 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
1706 | 1706 | |
1707 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1707 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
1708 | 1708 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
1709 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1709 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
1710 | 1710 | 'url' => FrmAppHelper::plugin_url(), |
1711 | 1711 | 'loading' => __( 'Loading…' ), |
1712 | 1712 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
1713 | - ) ); |
|
1713 | + ) ); |
|
1714 | 1714 | |
1715 | 1715 | if ( $load ) { |
1716 | 1716 | wp_enqueue_script( 'formidable_admin_global' ); |
1717 | 1717 | } |
1718 | - } |
|
1718 | + } |
|
1719 | 1719 | |
1720 | 1720 | /** |
1721 | 1721 | * @since 2.0.9 |
@@ -1724,9 +1724,9 @@ discard block |
||
1724 | 1724 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
1725 | 1725 | } |
1726 | 1726 | |
1727 | - /** |
|
1728 | - * @param string $location |
|
1729 | - */ |
|
1727 | + /** |
|
1728 | + * @param string $location |
|
1729 | + */ |
|
1730 | 1730 | public static function localize_script( $location ) { |
1731 | 1731 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
1732 | 1732 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1776,81 +1776,81 @@ discard block |
||
1776 | 1776 | } |
1777 | 1777 | } |
1778 | 1778 | |
1779 | - /** |
|
1779 | + /** |
|
1780 | 1780 | * echo the message on the plugins listing page |
1781 | - * @since 1.07.10 |
|
1782 | - * |
|
1783 | - * @param float $min_version The version the add-on requires |
|
1784 | - */ |
|
1781 | + * @since 1.07.10 |
|
1782 | + * |
|
1783 | + * @param float $min_version The version the add-on requires |
|
1784 | + */ |
|
1785 | 1785 | public static function min_version_notice( $min_version ) { |
1786 | - $frm_version = self::plugin_version(); |
|
1786 | + $frm_version = self::plugin_version(); |
|
1787 | 1787 | |
1788 | - // check if Formidable meets minimum requirements |
|
1789 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1790 | - return; |
|
1791 | - } |
|
1788 | + // check if Formidable meets minimum requirements |
|
1789 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1790 | + return; |
|
1791 | + } |
|
1792 | 1792 | |
1793 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1793 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1794 | 1794 | 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">' . |
1795 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1796 | - '</div></td></tr>'; |
|
1797 | - } |
|
1798 | - |
|
1799 | - public static function locales( $type = 'date' ) { |
|
1800 | - $locales = array( |
|
1801 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1802 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1803 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1804 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1805 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1806 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1807 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1808 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1809 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1810 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1811 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1812 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1813 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1814 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1815 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1816 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1817 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1818 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1819 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1820 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1821 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1822 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1823 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1824 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1825 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1826 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1827 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1828 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1829 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1830 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1831 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1832 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1833 | - ); |
|
1834 | - |
|
1835 | - if ( $type == 'captcha' ) { |
|
1836 | - // remove the languages unavailable for the captcha |
|
1837 | - $unset = array( |
|
1838 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1839 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1840 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1841 | - ); |
|
1842 | - } else { |
|
1843 | - // remove the languages unavailable for the datepicker |
|
1844 | - $unset = array( |
|
1845 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1846 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1847 | - 'es-419', 'tr', |
|
1848 | - ); |
|
1849 | - } |
|
1850 | - |
|
1851 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1852 | - $locales = apply_filters('frm_locales', $locales); |
|
1853 | - |
|
1854 | - return $locales; |
|
1855 | - } |
|
1795 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
1796 | + '</div></td></tr>'; |
|
1797 | + } |
|
1798 | + |
|
1799 | + public static function locales( $type = 'date' ) { |
|
1800 | + $locales = array( |
|
1801 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1802 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1803 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1804 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
1805 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1806 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1807 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
1808 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1809 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1810 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
1811 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1812 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
1813 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1814 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
1815 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1816 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
1817 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1818 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1819 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1820 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1821 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1822 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
1823 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1824 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
1825 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
1826 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1827 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
1828 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1829 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
1830 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1831 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1832 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1833 | + ); |
|
1834 | + |
|
1835 | + if ( $type == 'captcha' ) { |
|
1836 | + // remove the languages unavailable for the captcha |
|
1837 | + $unset = array( |
|
1838 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
1839 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
1840 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
1841 | + ); |
|
1842 | + } else { |
|
1843 | + // remove the languages unavailable for the datepicker |
|
1844 | + $unset = array( |
|
1845 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
1846 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
1847 | + 'es-419', 'tr', |
|
1848 | + ); |
|
1849 | + } |
|
1850 | + |
|
1851 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
1852 | + $locales = apply_filters('frm_locales', $locales); |
|
1853 | + |
|
1854 | + return $locales; |
|
1855 | + } |
|
1856 | 1856 | } |
@@ -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,16 +23,16 @@ 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() { |
34 | 34 | //prevously FRM_URL constant |
35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
35 | + return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public static function relative_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; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | public static function pro_is_installed() { |
110 | - return apply_filters('frm_pro_installed', false); |
|
110 | + return apply_filters( 'frm_pro_installed', false ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return boolean |
152 | 152 | */ |
153 | 153 | public static function doing_ajax() { |
154 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
154 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @return boolean |
172 | 172 | */ |
173 | 173 | public static function is_admin() { |
174 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
174 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @return string |
198 | 198 | */ |
199 | 199 | public static function get_server_value( $value ) { |
200 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
200 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
213 | 213 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
214 | 214 | ) as $key ) { |
215 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
215 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
216 | 216 | continue; |
217 | 217 | } |
218 | 218 | |
219 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
220 | - $ip = trim($ip); // just to be safe |
|
219 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
220 | + $ip = trim( $ip ); // just to be safe |
|
221 | 221 | |
222 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
222 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
223 | 223 | return $ip; |
224 | 224 | } |
225 | 225 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
232 | - if ( strpos($param, '[') ) { |
|
233 | - $params = explode('[', $param); |
|
232 | + if ( strpos( $param, '[' ) ) { |
|
233 | + $params = explode( '[', $param ); |
|
234 | 234 | $param = $params[0]; |
235 | 235 | } |
236 | 236 | |
237 | 237 | if ( $src == 'get' ) { |
238 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
239 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
240 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
238 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
239 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
240 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
241 | 241 | } |
242 | 242 | self::sanitize_value( $sanitize, $value ); |
243 | 243 | } else { |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | |
247 | 247 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
248 | 248 | foreach ( $params as $k => $p ) { |
249 | - if ( ! $k || ! is_array($value) ) { |
|
249 | + if ( ! $k || ! is_array( $value ) ) { |
|
250 | 250 | continue; |
251 | 251 | } |
252 | 252 | |
253 | - $p = trim($p, ']'); |
|
254 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
253 | + $p = trim( $p, ']' ); |
|
254 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -293,16 +293,16 @@ discard block |
||
293 | 293 | |
294 | 294 | $value = $args['default']; |
295 | 295 | if ( $args['type'] == 'get' ) { |
296 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
297 | - $value = $_GET[ $args['param'] ]; |
|
296 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
297 | + $value = $_GET[$args['param']]; |
|
298 | 298 | } |
299 | 299 | } else if ( $args['type'] == 'post' ) { |
300 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
301 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
300 | + if ( isset( $_POST[$args['param']] ) ) { |
|
301 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
302 | 302 | } |
303 | 303 | } else { |
304 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
305 | - $value = $_REQUEST[ $args['param'] ]; |
|
304 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
305 | + $value = $_REQUEST[$args['param']]; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | public static function sanitize_request( $sanitize_method, &$values ) { |
339 | 339 | $temp_values = $values; |
340 | 340 | foreach ( $temp_values as $k => $val ) { |
341 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
342 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
341 | + if ( isset( $sanitize_method[$k] ) ) { |
|
342 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | public static function sanitize_array( &$values ) { |
348 | 348 | $temp_values = $values; |
349 | 349 | foreach ( $temp_values as $k => $val ) { |
350 | - $values[ $k ] = wp_kses_post( $val ); |
|
350 | + $values[$k] = wp_kses_post( $val ); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | |
368 | 368 | $allowed_html = array(); |
369 | 369 | foreach ( $allowed as $a ) { |
370 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
370 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | return wp_kses( $value, $allowed_html ); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @since 2.0 |
379 | 379 | */ |
380 | 380 | public static function remove_get_action() { |
381 | - if ( ! isset($_GET) ) { |
|
381 | + if ( ! isset( $_GET ) ) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | } |
401 | 401 | |
402 | 402 | global $wp_query; |
403 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
404 | - $value = $wp_query->query_vars[ $param ]; |
|
403 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
404 | + $value = $wp_query->query_vars[$param]; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | return $value; |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | */ |
413 | 413 | public static function trigger_hook_load( $type, $object = null ) { |
414 | 414 | // only load the form hooks once |
415 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
415 | + $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
|
416 | 416 | if ( ! $hooks_loaded ) { |
417 | - do_action('frm_load_'. $type .'_hooks'); |
|
417 | + do_action( 'frm_load_' . $type . '_hooks' ); |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
@@ -430,16 +430,16 @@ discard block |
||
430 | 430 | * @return mixed $results The cache or query results |
431 | 431 | */ |
432 | 432 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
433 | - $results = wp_cache_get($cache_key, $group); |
|
434 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
433 | + $results = wp_cache_get( $cache_key, $group ); |
|
434 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
435 | 435 | return $results; |
436 | 436 | } |
437 | 437 | |
438 | 438 | if ( 'get_posts' == $type ) { |
439 | - $results = get_posts($query); |
|
439 | + $results = get_posts( $query ); |
|
440 | 440 | } else { |
441 | 441 | global $wpdb; |
442 | - $results = $wpdb->{$type}($query); |
|
442 | + $results = $wpdb->{$type}( $query ); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | if ( ! self::prevent_caching() ) { |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | } |
464 | 464 | |
465 | 465 | // then check the transient |
466 | - $results = get_transient($cache_key); |
|
466 | + $results = get_transient( $cache_key ); |
|
467 | 467 | if ( $results ) { |
468 | - wp_cache_set($cache_key, $results); |
|
468 | + wp_cache_set( $cache_key, $results ); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | return $results; |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | * @param string $cache_key |
477 | 477 | */ |
478 | 478 | public static function delete_cache_and_transient( $cache_key ) { |
479 | - delete_transient($cache_key); |
|
480 | - wp_cache_delete($cache_key); |
|
479 | + delete_transient( $cache_key ); |
|
480 | + wp_cache_delete( $cache_key ); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -491,9 +491,9 @@ discard block |
||
491 | 491 | public static function cache_delete_group( $group ) { |
492 | 492 | global $wp_object_cache; |
493 | 493 | |
494 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
495 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
496 | - wp_cache_delete($k, $group); |
|
494 | + if ( isset( $wp_object_cache->cache[$group] ) ) { |
|
495 | + foreach ( $wp_object_cache->cache[$group] as $k => $v ) { |
|
496 | + wp_cache_delete( $k, $group ); |
|
497 | 497 | } |
498 | 498 | return true; |
499 | 499 | } |
@@ -524,29 +524,29 @@ discard block |
||
524 | 524 | public static function load_scripts( $scripts ) { |
525 | 525 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
526 | 526 | foreach ( (array) $scripts as $s ) { |
527 | - wp_enqueue_script($s); |
|
527 | + wp_enqueue_script( $s ); |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | 531 | public static function load_styles( $styles ) { |
532 | 532 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
533 | 533 | foreach ( (array) $styles as $s ) { |
534 | - wp_enqueue_style($s); |
|
534 | + wp_enqueue_style( $s ); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 | |
538 | 538 | public static function get_pages() { |
539 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
539 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
543 | 543 | $pages = self::get_pages(); |
544 | 544 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
545 | 545 | ?> |
546 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
546 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
547 | 547 | <option value=""> </option> |
548 | 548 | <?php foreach ( $pages as $page ) { ?> |
549 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
549 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
550 | 550 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
551 | 551 | </option> |
552 | 552 | <?php } ?> |
@@ -555,26 +555,26 @@ discard block |
||
555 | 555 | } |
556 | 556 | |
557 | 557 | public static function post_edit_link( $post_id ) { |
558 | - $post = get_post($post_id); |
|
558 | + $post = get_post( $post_id ); |
|
559 | 559 | if ( $post ) { |
560 | - return '<a href="'. esc_url( admin_url('post.php?post='. $post_id .'&action=edit') ) .'">'. self::truncate( $post->post_title, 50 ) .'</a>'; |
|
560 | + return '<a href="' . esc_url( admin_url( 'post.php?post=' . $post_id . '&action=edit' ) ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
|
561 | 561 | } |
562 | 562 | return ''; |
563 | 563 | } |
564 | 564 | |
565 | 565 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
566 | 566 | ?> |
567 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
567 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
568 | 568 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
569 | 569 | ?> class="frm_multiselect"> |
570 | - <?php self::roles_options($capability); ?> |
|
570 | + <?php self::roles_options( $capability ); ?> |
|
571 | 571 | </select> |
572 | 572 | <?php |
573 | 573 | } |
574 | 574 | |
575 | 575 | public static function roles_options( $capability ) { |
576 | 576 | global $frm_vars; |
577 | - if ( isset($frm_vars['editable_roles']) ) { |
|
577 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
578 | 578 | $editable_roles = $frm_vars['editable_roles']; |
579 | 579 | } else { |
580 | 580 | $editable_roles = get_editable_roles(); |
@@ -582,10 +582,10 @@ discard block |
||
582 | 582 | } |
583 | 583 | |
584 | 584 | foreach ( $editable_roles as $role => $details ) { |
585 | - $name = translate_user_role($details['name'] ); ?> |
|
586 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
585 | + $name = translate_user_role( $details['name'] ); ?> |
|
586 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
587 | 587 | <?php |
588 | - unset($role, $details); |
|
588 | + unset( $role, $details ); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | public static function maybe_add_permissions() { |
642 | 642 | self::force_capability( 'frm_view_entries' ); |
643 | 643 | |
644 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
644 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | $frm_roles = self::frm_capabilities(); |
651 | 651 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
652 | 652 | $user->add_cap( $frm_role ); |
653 | - unset($frm_role, $frm_role_description); |
|
653 | + unset( $frm_role, $frm_role_description ); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
@@ -675,12 +675,12 @@ discard block |
||
675 | 675 | * @param string $permission |
676 | 676 | */ |
677 | 677 | public static function permission_check( $permission, $show_message = 'show' ) { |
678 | - $permission_error = self::permission_nonce_error($permission); |
|
678 | + $permission_error = self::permission_nonce_error( $permission ); |
|
679 | 679 | if ( $permission_error !== false ) { |
680 | 680 | if ( 'hide' == $show_message ) { |
681 | 681 | $permission_error = ''; |
682 | 682 | } |
683 | - wp_die($permission_error); |
|
683 | + wp_die( $permission_error ); |
|
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | $error = false; |
700 | - if ( empty($nonce_name) ) { |
|
700 | + if ( empty( $nonce_name ) ) { |
|
701 | 701 | return $error; |
702 | 702 | } |
703 | 703 | |
704 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
704 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
705 | 705 | $frm_settings = self::get_settings(); |
706 | 706 | $error = $frm_settings->admin_permission; |
707 | 707 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | } else { |
782 | 782 | foreach ( $value as $k => $v ) { |
783 | 783 | if ( ! is_array( $v ) ) { |
784 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
784 | + $value[$k] = call_user_func( $original_function, $v ); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | } |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | public static function array_flatten( $array, $keys = 'keep' ) { |
803 | 803 | $return = array(); |
804 | 804 | foreach ( $array as $key => $value ) { |
805 | - if ( is_array($value) ) { |
|
805 | + if ( is_array( $value ) ) { |
|
806 | 806 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
807 | 807 | } else { |
808 | 808 | if ( $keys == 'keep' ) { |
809 | - $return[ $key ] = $value; |
|
809 | + $return[$key] = $value; |
|
810 | 810 | } else { |
811 | 811 | $return[] = $value; |
812 | 812 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | } |
817 | 817 | |
818 | 818 | public static function esc_textarea( $text ) { |
819 | - $safe_text = str_replace('"', '"', $text); |
|
819 | + $safe_text = str_replace( '"', '"', $text ); |
|
820 | 820 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
821 | 821 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
822 | 822 | } |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | * @since 2.0 |
827 | 827 | */ |
828 | 828 | public static function use_wpautop( $content ) { |
829 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
830 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
829 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
830 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
831 | 831 | } |
832 | 832 | return $content; |
833 | 833 | } |
@@ -845,8 +845,8 @@ discard block |
||
845 | 845 | * @return string The base Google APIS url for the current version of jQuery UI |
846 | 846 | */ |
847 | 847 | public static function jquery_ui_base_url() { |
848 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
849 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
848 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
849 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
850 | 850 | return $url; |
851 | 851 | } |
852 | 852 | |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | |
862 | 862 | $ver = 0; |
863 | 863 | |
864 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
864 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
865 | 865 | return $ver; |
866 | 866 | } |
867 | 867 | |
868 | - $query = $wp_scripts->registered[ $handle ]; |
|
868 | + $query = $wp_scripts->registered[$handle]; |
|
869 | 869 | if ( is_object( $query ) ) { |
870 | 870 | $ver = $query->ver; |
871 | 871 | } |
@@ -878,36 +878,36 @@ discard block |
||
878 | 878 | } |
879 | 879 | |
880 | 880 | public static function get_user_id_param( $user_id ) { |
881 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
881 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
882 | 882 | return $user_id; |
883 | 883 | } |
884 | 884 | |
885 | 885 | if ( $user_id == 'current' ) { |
886 | 886 | $user_id = get_current_user_id(); |
887 | 887 | } else { |
888 | - if ( is_email($user_id) ) { |
|
889 | - $user = get_user_by('email', $user_id); |
|
888 | + if ( is_email( $user_id ) ) { |
|
889 | + $user = get_user_by( 'email', $user_id ); |
|
890 | 890 | } else { |
891 | - $user = get_user_by('login', $user_id); |
|
891 | + $user = get_user_by( 'login', $user_id ); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | if ( $user ) { |
895 | 895 | $user_id = $user->ID; |
896 | 896 | } |
897 | - unset($user); |
|
897 | + unset( $user ); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | return $user_id; |
901 | 901 | } |
902 | 902 | |
903 | 903 | public static function get_file_contents( $filename, $atts = array() ) { |
904 | - if ( ! is_file($filename) ) { |
|
904 | + if ( ! is_file( $filename ) ) { |
|
905 | 905 | return false; |
906 | 906 | } |
907 | 907 | |
908 | - extract($atts); |
|
908 | + extract( $atts ); |
|
909 | 909 | ob_start(); |
910 | - include($filename); |
|
910 | + include( $filename ); |
|
911 | 911 | $contents = ob_get_contents(); |
912 | 912 | ob_end_clean(); |
913 | 913 | return $contents; |
@@ -923,28 +923,28 @@ discard block |
||
923 | 923 | $key = ''; |
924 | 924 | |
925 | 925 | if ( ! empty( $name ) ) { |
926 | - $key = sanitize_key($name); |
|
926 | + $key = sanitize_key( $name ); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | if ( empty( $key ) ) { |
930 | - $max_slug_value = pow(36, $num_chars); |
|
930 | + $max_slug_value = pow( 36, $num_chars ); |
|
931 | 931 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
932 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
932 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
933 | 933 | } |
934 | 934 | |
935 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
936 | - $key = $key .'a'; |
|
935 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
936 | + $key = $key . 'a'; |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
940 | 940 | |
941 | - if ( $key_check || is_numeric($key_check) ) { |
|
941 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
942 | 942 | $suffix = 2; |
943 | 943 | do { |
944 | 944 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
945 | 945 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
946 | - $suffix++; |
|
947 | - } while ($key_check || is_numeric($key_check)); |
|
946 | + $suffix ++; |
|
947 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
948 | 948 | $key = $alt_post_name; |
949 | 949 | } |
950 | 950 | return $key; |
@@ -960,32 +960,32 @@ discard block |
||
960 | 960 | return false; |
961 | 961 | } |
962 | 962 | |
963 | - if ( empty($post_values) ) { |
|
964 | - $post_values = stripslashes_deep($_POST); |
|
963 | + if ( empty( $post_values ) ) { |
|
964 | + $post_values = stripslashes_deep( $_POST ); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | $values = array( 'id' => $record->id, 'fields' => array() ); |
968 | 968 | |
969 | 969 | foreach ( array( 'name', 'description' ) as $var ) { |
970 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
971 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
972 | - unset($var, $default_val); |
|
970 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
971 | + $values[$var] = self::get_param( $var, $default_val ); |
|
972 | + unset( $var, $default_val ); |
|
973 | 973 | } |
974 | 974 | |
975 | - $values['description'] = self::use_wpautop($values['description']); |
|
975 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
976 | 976 | $frm_settings = self::get_settings(); |
977 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
977 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
978 | 978 | |
979 | 979 | foreach ( (array) $fields as $field ) { |
980 | 980 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
981 | 981 | if ( ! $is_form_builder ) { |
982 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
982 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
983 | 983 | } |
984 | 984 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
985 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
985 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
986 | 986 | } |
987 | 987 | |
988 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
988 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
989 | 989 | |
990 | 990 | if ( $table == 'entries' ) { |
991 | 991 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1002,8 +1002,8 @@ discard block |
||
1002 | 1002 | if ( $args['default'] ) { |
1003 | 1003 | $meta_value = $field->default_value; |
1004 | 1004 | } else { |
1005 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
1006 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
1005 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
1006 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
1007 | 1007 | $field->field_options['custom_field'] = ''; |
1008 | 1008 | } |
1009 | 1009 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
1016 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
1015 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
1016 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
1017 | 1017 | |
1018 | 1018 | $field_array = array( |
1019 | 1019 | 'id' => $field->id, |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | 'default_value' => $field->default_value, |
1022 | 1022 | 'name' => $field->name, |
1023 | 1023 | 'description' => $field->description, |
1024 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
1024 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
1025 | 1025 | 'options' => $field->options, |
1026 | 1026 | 'required' => $field->required, |
1027 | 1027 | 'field_key' => $field->field_key, |
@@ -1031,38 +1031,38 @@ discard block |
||
1031 | 1031 | ); |
1032 | 1032 | |
1033 | 1033 | $args['field_type'] = $field_type; |
1034 | - self::fill_field_opts($field, $field_array, $args); |
|
1034 | + self::fill_field_opts( $field, $field_array, $args ); |
|
1035 | 1035 | |
1036 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
1036 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] ); |
|
1037 | 1037 | |
1038 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
1038 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
1039 | 1039 | $field_array['unique_msg'] = ''; |
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | $field_array = array_merge( $field->field_options, $field_array ); |
1043 | 1043 | |
1044 | - $values['fields'][ $field->id ] = $field_array; |
|
1044 | + $values['fields'][$field->id] = $field_array; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
1048 | 1048 | $post_values = $args['post_values']; |
1049 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
1049 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
1050 | 1050 | |
1051 | 1051 | foreach ( $opt_defaults as $opt => $default_opt ) { |
1052 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
1053 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
1054 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
1055 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
1052 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
1053 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
1054 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
1055 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
1056 | 1056 | if ( $args['field_type'] == 'captcha' ) { |
1057 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
1057 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
1058 | 1058 | } else { |
1059 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1059 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
1060 | 1060 | } |
1061 | 1061 | } |
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | if ( $field_array['custom_html'] == '' ) { |
1065 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
1065 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | |
@@ -1081,18 +1081,18 @@ discard block |
||
1081 | 1081 | return; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
1084 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
1085 | 1085 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
1086 | 1086 | |
1087 | - if ( ! is_array($form->options) ) { |
|
1087 | + if ( ! is_array( $form->options ) ) { |
|
1088 | 1088 | return; |
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | foreach ( $form->options as $opt => $value ) { |
1092 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
1092 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | - self::fill_form_defaults($post_values, $values); |
|
1095 | + self::fill_form_defaults( $post_values, $values ); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | /** |
@@ -1102,23 +1102,23 @@ discard block |
||
1102 | 1102 | $form_defaults = FrmFormsHelper::get_default_opts(); |
1103 | 1103 | |
1104 | 1104 | foreach ( $form_defaults as $opt => $default ) { |
1105 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
1106 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
1105 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
1106 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | - unset($opt, $defaut); |
|
1109 | + unset( $opt, $defaut ); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | - if ( ! isset($values['custom_style']) ) { |
|
1112 | + if ( ! isset( $values['custom_style'] ) ) { |
|
1113 | 1113 | $frm_settings = self::get_settings(); |
1114 | 1114 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
1118 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
1119 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
1118 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
1119 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
1120 | 1120 | } |
1121 | - unset($h); |
|
1121 | + unset( $h ); |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
@@ -1134,9 +1134,9 @@ discard block |
||
1134 | 1134 | } |
1135 | 1135 | ?> |
1136 | 1136 | <li> |
1137 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1138 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
1139 | - <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> |
|
1137 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
1138 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
1139 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
1140 | 1140 | </li> |
1141 | 1141 | <?php |
1142 | 1142 | } |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | return ''; |
1165 | 1165 | } else if ( $length <= 10 ) { |
1166 | 1166 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
1167 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
1167 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | $sub = ''; |
@@ -1173,23 +1173,23 @@ discard block |
||
1173 | 1173 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
1174 | 1174 | |
1175 | 1175 | foreach ( $words as $word ) { |
1176 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
1176 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
1177 | 1177 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
1178 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
1178 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
1179 | 1179 | break; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | $sub .= $part; |
1183 | 1183 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
1184 | 1184 | |
1185 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
1185 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
1186 | 1186 | break; |
1187 | 1187 | } |
1188 | 1188 | |
1189 | - unset($total_len, $word); |
|
1189 | + unset( $total_len, $word ); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
1192 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | public static function mb_function( $function_names, $args ) { |
@@ -1202,17 +1202,17 @@ discard block |
||
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
1205 | - if ( empty($date) ) { |
|
1205 | + if ( empty( $date ) ) { |
|
1206 | 1206 | return $date; |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - if ( empty($date_format) ) { |
|
1210 | - $date_format = get_option('date_format'); |
|
1209 | + if ( empty( $date_format ) ) { |
|
1210 | + $date_format = get_option( 'date_format' ); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
1213 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
1214 | 1214 | $frmpro_settings = new FrmProSettings(); |
1215 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
1215 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1227,7 +1227,7 @@ discard block |
||
1227 | 1227 | |
1228 | 1228 | private static function add_time_to_date( $time_format, $date ) { |
1229 | 1229 | if ( empty( $time_format ) ) { |
1230 | - $time_format = get_option('time_format'); |
|
1230 | + $time_format = get_option( 'time_format' ); |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | $trimmed_format = trim( $time_format ); |
@@ -1273,10 +1273,10 @@ discard block |
||
1273 | 1273 | $time_strings = self::get_time_strings(); |
1274 | 1274 | |
1275 | 1275 | foreach ( $time_strings as $k => $v ) { |
1276 | - if ( $diff[ $k ] ) { |
|
1277 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
1276 | + if ( $diff[$k] ) { |
|
1277 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
1278 | 1278 | } else { |
1279 | - unset( $time_strings[ $k ] ); |
|
1279 | + unset( $time_strings[$k] ); |
|
1280 | 1280 | } |
1281 | 1281 | } |
1282 | 1282 | |
@@ -1314,7 +1314,7 @@ discard block |
||
1314 | 1314 | */ |
1315 | 1315 | public static function esc_like( $term ) { |
1316 | 1316 | global $wpdb; |
1317 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
1317 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
1318 | 1318 | // WP 4.0 |
1319 | 1319 | $term = $wpdb->esc_like( $term ); |
1320 | 1320 | } else { |
@@ -1328,17 +1328,17 @@ discard block |
||
1328 | 1328 | * @param string $order_query |
1329 | 1329 | */ |
1330 | 1330 | public static function esc_order( $order_query ) { |
1331 | - if ( empty($order_query) ) { |
|
1331 | + if ( empty( $order_query ) ) { |
|
1332 | 1332 | return ''; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | // remove ORDER BY before santizing |
1336 | - $order_query = strtolower($order_query); |
|
1337 | - if ( strpos($order_query, 'order by') !== false ) { |
|
1338 | - $order_query = str_replace('order by', '', $order_query); |
|
1336 | + $order_query = strtolower( $order_query ); |
|
1337 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
1338 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $order_query = explode(' ', trim($order_query)); |
|
1341 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
1342 | 1342 | |
1343 | 1343 | $order_fields = array( |
1344 | 1344 | 'id', 'form_key', 'name', 'description', |
@@ -1346,18 +1346,18 @@ discard block |
||
1346 | 1346 | 'default_template', 'status', 'created_at', |
1347 | 1347 | ); |
1348 | 1348 | |
1349 | - $order = trim(trim(reset($order_query), ',')); |
|
1350 | - if ( ! in_array($order, $order_fields) ) { |
|
1349 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
1350 | + if ( ! in_array( $order, $order_fields ) ) { |
|
1351 | 1351 | return ''; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | $order_by = ''; |
1355 | - if ( count($order_query) > 1 ) { |
|
1355 | + if ( count( $order_query ) > 1 ) { |
|
1356 | 1356 | $order_by = end( $order_query ); |
1357 | 1357 | self::esc_order_by( $order_by ); |
1358 | 1358 | } |
1359 | 1359 | |
1360 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
1360 | + return ' ORDER BY ' . $order . ' ' . $order_by; |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | /** |
@@ -1374,24 +1374,24 @@ discard block |
||
1374 | 1374 | * @param string $limit |
1375 | 1375 | */ |
1376 | 1376 | public static function esc_limit( $limit ) { |
1377 | - if ( empty($limit) ) { |
|
1377 | + if ( empty( $limit ) ) { |
|
1378 | 1378 | return ''; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
1382 | - if ( is_numeric($limit) ) { |
|
1383 | - return ' LIMIT '. $limit; |
|
1381 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
1382 | + if ( is_numeric( $limit ) ) { |
|
1383 | + return ' LIMIT ' . $limit; |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | - $limit = explode(',', trim($limit)); |
|
1386 | + $limit = explode( ',', trim( $limit ) ); |
|
1387 | 1387 | foreach ( $limit as $k => $l ) { |
1388 | 1388 | if ( is_numeric( $l ) ) { |
1389 | - $limit[ $k ] = $l; |
|
1389 | + $limit[$k] = $l; |
|
1390 | 1390 | } |
1391 | 1391 | } |
1392 | 1392 | |
1393 | - $limit = implode(',', $limit); |
|
1394 | - return ' LIMIT '. $limit; |
|
1393 | + $limit = implode( ',', $limit ); |
|
1394 | + return ' LIMIT ' . $limit; |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | /** |
@@ -1399,12 +1399,12 @@ discard block |
||
1399 | 1399 | * @since 2.0 |
1400 | 1400 | */ |
1401 | 1401 | public static function prepare_array_values( $array, $type = '%s' ) { |
1402 | - $placeholders = array_fill(0, count($array), $type); |
|
1403 | - return implode(', ', $placeholders); |
|
1402 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
1403 | + return implode( ', ', $placeholders ); |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
1407 | - if ( empty($where) ) { |
|
1407 | + if ( empty( $where ) ) { |
|
1408 | 1408 | return ''; |
1409 | 1409 | } |
1410 | 1410 | |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | |
1451 | 1451 | public static function get_referer_info() { |
1452 | 1452 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
1453 | - return self::get_server_value('HTTP_REFERER'); |
|
1453 | + return self::get_server_value( 'HTTP_REFERER' ); |
|
1454 | 1454 | } |
1455 | 1455 | |
1456 | 1456 | /** |
@@ -1459,19 +1459,19 @@ discard block |
||
1459 | 1459 | public static function json_to_array( $json_vars ) { |
1460 | 1460 | $vars = array(); |
1461 | 1461 | foreach ( $json_vars as $jv ) { |
1462 | - $jv_name = explode('[', $jv['name']); |
|
1463 | - $last = count($jv_name) - 1; |
|
1462 | + $jv_name = explode( '[', $jv['name'] ); |
|
1463 | + $last = count( $jv_name ) - 1; |
|
1464 | 1464 | foreach ( $jv_name as $p => $n ) { |
1465 | - $name = trim($n, ']'); |
|
1466 | - if ( ! isset($l1) ) { |
|
1465 | + $name = trim( $n, ']' ); |
|
1466 | + if ( ! isset( $l1 ) ) { |
|
1467 | 1467 | $l1 = $name; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | - if ( ! isset($l2) ) { |
|
1470 | + if ( ! isset( $l2 ) ) { |
|
1471 | 1471 | $l2 = $name; |
1472 | 1472 | } |
1473 | 1473 | |
1474 | - if ( ! isset($l3) ) { |
|
1474 | + if ( ! isset( $l3 ) ) { |
|
1475 | 1475 | $l3 = $name; |
1476 | 1476 | } |
1477 | 1477 | |
@@ -1485,24 +1485,24 @@ discard block |
||
1485 | 1485 | |
1486 | 1486 | case 1: |
1487 | 1487 | $l2 = $name; |
1488 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
1488 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
1489 | 1489 | break; |
1490 | 1490 | |
1491 | 1491 | case 2: |
1492 | 1492 | $l3 = $name; |
1493 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
1493 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
1494 | 1494 | break; |
1495 | 1495 | |
1496 | 1496 | case 3: |
1497 | 1497 | $l4 = $name; |
1498 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
1498 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
1499 | 1499 | break; |
1500 | 1500 | } |
1501 | 1501 | |
1502 | - unset($this_val, $n); |
|
1502 | + unset( $this_val, $n ); |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | - unset($last, $jv); |
|
1505 | + unset( $last, $jv ); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | return $vars; |
@@ -1515,8 +1515,8 @@ discard block |
||
1515 | 1515 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
1516 | 1516 | if ( $name == '' ) { |
1517 | 1517 | $vars[] = $val; |
1518 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
1519 | - $vars[ $l1 ] = $val; |
|
1518 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
1519 | + $vars[$l1] = $val; |
|
1520 | 1520 | } |
1521 | 1521 | } |
1522 | 1522 | |
@@ -1531,7 +1531,7 @@ discard block |
||
1531 | 1531 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
1532 | 1532 | ); |
1533 | 1533 | |
1534 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
1534 | + if ( ! isset( $tooltips[$name] ) ) { |
|
1535 | 1535 | return; |
1536 | 1536 | } |
1537 | 1537 | |
@@ -1541,7 +1541,7 @@ discard block |
||
1541 | 1541 | echo ' class="frm_help"'; |
1542 | 1542 | } |
1543 | 1543 | |
1544 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
1544 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
1545 | 1545 | |
1546 | 1546 | if ( 'open' != $class ) { |
1547 | 1547 | echo '"'; |
@@ -1593,13 +1593,13 @@ discard block |
||
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
1596 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
1596 | + if ( ! isset( $post_content[$key] ) ) { |
|
1597 | 1597 | return; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | if ( is_array( $val ) ) { |
1601 | 1601 | foreach ( $val as $k1 => $v1 ) { |
1602 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
1602 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
1603 | 1603 | unset( $k1, $v1 ); |
1604 | 1604 | } |
1605 | 1605 | } else { |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | $val = stripslashes( $val ); |
1608 | 1608 | |
1609 | 1609 | // Add backslashes before double quotes and forward slashes only |
1610 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
1610 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
1611 | 1611 | } |
1612 | 1612 | } |
1613 | 1613 | |
@@ -1624,7 +1624,7 @@ discard block |
||
1624 | 1624 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
1625 | 1625 | |
1626 | 1626 | if ( empty( $settings['ID'] ) ) { |
1627 | - unset( $settings['ID']); |
|
1627 | + unset( $settings['ID'] ); |
|
1628 | 1628 | } |
1629 | 1629 | |
1630 | 1630 | // delete all caches for this group |
@@ -1658,17 +1658,17 @@ discard block |
||
1658 | 1658 | } |
1659 | 1659 | |
1660 | 1660 | public static function maybe_json_decode( $string ) { |
1661 | - if ( is_array($string) ) { |
|
1661 | + if ( is_array( $string ) ) { |
|
1662 | 1662 | return $string; |
1663 | 1663 | } |
1664 | 1664 | |
1665 | - $new_string = json_decode($string, true); |
|
1666 | - if ( function_exists('json_last_error') ) { |
|
1665 | + $new_string = json_decode( $string, true ); |
|
1666 | + if ( function_exists( 'json_last_error' ) ) { |
|
1667 | 1667 | // php 5.3+ |
1668 | 1668 | if ( json_last_error() == JSON_ERROR_NONE ) { |
1669 | 1669 | $string = $new_string; |
1670 | 1670 | } |
1671 | - } else if ( isset($new_string) ) { |
|
1671 | + } else if ( isset( $new_string ) ) { |
|
1672 | 1672 | // php < 5.3 fallback |
1673 | 1673 | $string = $new_string; |
1674 | 1674 | } |
@@ -1684,11 +1684,11 @@ discard block |
||
1684 | 1684 | public static function maybe_highlight_menu( $post_type ) { |
1685 | 1685 | global $post, $pagenow; |
1686 | 1686 | |
1687 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
1687 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
1688 | 1688 | return; |
1689 | 1689 | } |
1690 | 1690 | |
1691 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
1691 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
1692 | 1692 | return; |
1693 | 1693 | } |
1694 | 1694 | |
@@ -1786,11 +1786,11 @@ discard block |
||
1786 | 1786 | $frm_version = self::plugin_version(); |
1787 | 1787 | |
1788 | 1788 | // check if Formidable meets minimum requirements |
1789 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
1789 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
1790 | 1790 | return; |
1791 | 1791 | } |
1792 | 1792 | |
1793 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
1793 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
1794 | 1794 | 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">' . |
1795 | 1795 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
1796 | 1796 | '</div></td></tr>'; |
@@ -1798,38 +1798,38 @@ discard block |
||
1798 | 1798 | |
1799 | 1799 | public static function locales( $type = 'date' ) { |
1800 | 1800 | $locales = array( |
1801 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1802 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1803 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1801 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
1802 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
1803 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
1804 | 1804 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
1805 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1806 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1805 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
1806 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
1807 | 1807 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
1808 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1809 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1808 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
1809 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
1810 | 1810 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
1811 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1811 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
1812 | 1812 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
1813 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1813 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
1814 | 1814 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
1815 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1815 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
1816 | 1816 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
1817 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1818 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1819 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1820 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1821 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1817 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
1818 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
1819 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
1820 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
1821 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
1822 | 1822 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
1823 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1823 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
1824 | 1824 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
1825 | 1825 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
1826 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1826 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
1827 | 1827 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
1828 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1828 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
1829 | 1829 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
1830 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1831 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1832 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1830 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
1831 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
1832 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
1833 | 1833 | ); |
1834 | 1834 | |
1835 | 1835 | if ( $type == 'captcha' ) { |
@@ -1848,8 +1848,8 @@ discard block |
||
1848 | 1848 | ); |
1849 | 1849 | } |
1850 | 1850 | |
1851 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
1852 | - $locales = apply_filters('frm_locales', $locales); |
|
1851 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
1852 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
1853 | 1853 | |
1854 | 1854 | return $locales; |
1855 | 1855 | } |
@@ -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,27 +5,27 @@ 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 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
28 | + $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
29 | 29 | |
30 | 30 | if ( $query_results ) { |
31 | 31 | self::clear_cache(); |
@@ -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 | - return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
62 | - } |
|
61 | + return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
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 | - $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'); |
|
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'); |
|
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'; |
|
220 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
221 | - |
|
222 | - if ( ! $args['is_draft'] ) { |
|
223 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
224 | - } |
|
225 | - |
|
226 | - if ( is_numeric($field_id) ) { |
|
227 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | - } else { |
|
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 | - } |
|
231 | - |
|
232 | - if ( ! $args['is_draft'] ) { |
|
233 | - $query[] = 'AND e.is_draft=0'; |
|
234 | - } |
|
235 | - |
|
236 | - if ( $args['value'] ) { |
|
237 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
238 | - } |
|
239 | - $query[] = $order . $limit; |
|
240 | - } |
|
217 | + global $wpdb; |
|
218 | + $query[] = 'SELECT'; |
|
219 | + $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
|
220 | + $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
221 | + |
|
222 | + if ( ! $args['is_draft'] ) { |
|
223 | + $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
224 | + } |
|
225 | + |
|
226 | + if ( is_numeric($field_id) ) { |
|
227 | + $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
228 | + } else { |
|
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 | + } |
|
231 | + |
|
232 | + if ( ! $args['is_draft'] ) { |
|
233 | + $query[] = 'AND e.is_draft=0'; |
|
234 | + } |
|
235 | + |
|
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 | - $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')); |
|
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')); |
|
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 | - $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')); |
|
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')); |
|
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 ); |
@@ -301,91 +301,91 @@ discard block |
||
301 | 301 | $query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id'; |
302 | 302 | } |
303 | 303 | |
304 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id'; |
|
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 | - $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 | - } |
|
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 | 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; |
|
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 | - } |
|
331 | - |
|
332 | - if ( ! empty($args['user_id']) ) { |
|
333 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | - } |
|
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; |
|
341 | - $where .= ' GROUP BY '. $parts[1]; |
|
342 | - } else { |
|
343 | - $where .= $draft_where . $user_where; |
|
344 | - } |
|
330 | + } |
|
331 | + |
|
332 | + if ( ! empty($args['user_id']) ) { |
|
333 | + $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
334 | + } |
|
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; |
|
341 | + $where .= ' GROUP BY '. $parts[1]; |
|
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 ) { |
|
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 | - } |
|
350 | + public static function search_entry_metas( $search, $field_id = '', $operator ) { |
|
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 | + } |
|
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 | - } |
|
364 | - |
|
365 | - switch ( $field ) { |
|
366 | - case 'year': |
|
367 | - $value = '%'. $value; |
|
368 | - break; |
|
369 | - case 'month': |
|
370 | - $value .= '%'; |
|
371 | - break; |
|
372 | - case 'day': |
|
373 | - $value = '%'. $value .'%'; |
|
374 | - } |
|
375 | - $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value); |
|
376 | - } |
|
377 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | - $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
379 | - } else { |
|
362 | + continue; |
|
363 | + } |
|
364 | + |
|
365 | + switch ( $field ) { |
|
366 | + case 'year': |
|
367 | + $value = '%'. $value; |
|
368 | + break; |
|
369 | + case 'month': |
|
370 | + $value .= '%'; |
|
371 | + break; |
|
372 | + case 'day': |
|
373 | + $value = '%'. $value .'%'; |
|
374 | + } |
|
375 | + $where .= $wpdb->prepare(' meta_value '. $operator .' %s and', $value); |
|
376 | + } |
|
377 | + $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
378 | + $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
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,12 +20,12 @@ 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 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_item_metas', $new_values ); |
|
28 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
|
29 | 29 | |
30 | 30 | if ( $query_results ) { |
31 | 31 | self::clear_cache(); |
@@ -49,32 +49,32 @@ 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 | - return $wpdb->update( $wpdb->prefix .'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
|
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 | 65 | global $wpdb; |
66 | 66 | |
67 | - $prev_values = FrmDb::get_col( $wpdb->prefix .'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
|
67 | + $prev_values = FrmDb::get_col( $wpdb->prefix . 'frm_item_metas', array( 'item_id' => $entry_id, 'field_id !' => 0 ), 'field_id' ); |
|
68 | 68 | |
69 | 69 | foreach ( $values as $field_id => $meta_value ) { |
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 | - $get_table = $wpdb->prefix .'frm_item_metas'; |
|
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 | - $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'); |
|
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' ); |
|
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 | /** |
@@ -217,16 +217,16 @@ discard block |
||
217 | 217 | global $wpdb; |
218 | 218 | $query[] = 'SELECT'; |
219 | 219 | $query[] = $args['unique'] ? 'DISTINCT(em.meta_value)' : 'em.meta_value'; |
220 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas em '; |
|
220 | + $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas em '; |
|
221 | 221 | |
222 | 222 | if ( ! $args['is_draft'] ) { |
223 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=em.item_id)'; |
|
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 | - $query[] = $wpdb->prepare('LEFT JOIN '. $wpdb->prefix .'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id); |
|
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 | 232 | if ( ! $args['is_draft'] ) { |
@@ -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 | } |
@@ -247,19 +247,19 @@ discard block |
||
247 | 247 | global $wpdb; |
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 | - 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; |
|
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; |
|
252 | 252 | |
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')); |
|
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' ) ); |
|
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 | - $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')); |
|
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' ) ); |
|
282 | 282 | |
283 | 283 | return $results; |
284 | 284 | } |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | $query[] = $unique ? 'DISTINCT(it.item_id)' : 'it.item_id'; |
302 | 302 | } |
303 | 303 | |
304 | - $query[] = 'FROM '. $wpdb->prefix .'frm_item_metas it LEFT OUTER JOIN '. $wpdb->prefix .'frm_fields fi ON it.field_id=fi.id'; |
|
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 | - $query[] = 'INNER JOIN '. $wpdb->prefix .'frm_items e ON (e.id=it.item_id)'; |
|
307 | - if ( is_array($where) ) { |
|
306 | + $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
|
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 | - $query[] = ' GROUP BY '. sanitize_text_field( $args['group_by'] ); |
|
320 | + $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
|
321 | 321 | } |
322 | 322 | return; |
323 | 323 | } |
@@ -329,27 +329,27 @@ 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 | - $where .= ' GROUP BY '. $parts[1]; |
|
341 | + $where .= ' GROUP BY ' . $parts[1]; |
|
342 | 342 | } else { |
343 | 343 | $where .= $draft_where . $user_where; |
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 | - $cache_key = 'search_'. maybe_serialize($search) . $field_id . $operator; |
|
352 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
351 | + $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
|
352 | + $results = wp_cache_get( $cache_key, 'frm_entry' ); |
|
353 | 353 | if ( false !== $results ) { |
354 | 354 | return $results; |
355 | 355 | } |
@@ -364,27 +364,27 @@ discard block |
||
364 | 364 | |
365 | 365 | switch ( $field ) { |
366 | 366 | case 'year': |
367 | - $value = '%'. $value; |
|
367 | + $value = '%' . $value; |
|
368 | 368 | break; |
369 | 369 | case 'month': |
370 | 370 | $value .= '%'; |
371 | 371 | break; |
372 | 372 | case 'day': |
373 | - $value = '%'. $value .'%'; |
|
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); |
|
378 | - $query = "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas". FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
377 | + $where .= $wpdb->prepare( ' field_id=%d', $field_id ); |
|
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 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
7 | - * @param int|string $id The id of the stylsheet or 'default' |
|
7 | + * @param integer $id The id of the stylsheet or 'default' |
|
8 | 8 | */ |
9 | 9 | public function __construct( $id = 0 ) { |
10 | 10 | $this->id = $id; |
@@ -1,52 +1,52 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStyle { |
3 | - public $number = false; // Unique ID number of the current instance. |
|
3 | + public $number = false; // Unique ID number of the current instance. |
|
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * @param int|string $id The id of the stylsheet or 'default' |
8 | 8 | */ |
9 | 9 | public function __construct( $id = 0 ) { |
10 | - $this->id = $id; |
|
11 | - } |
|
10 | + $this->id = $id; |
|
11 | + } |
|
12 | 12 | |
13 | - public function get_new() { |
|
13 | + public function get_new() { |
|
14 | 14 | $this->id = 0; |
15 | 15 | |
16 | - $max_slug_value = pow(36, 6); |
|
17 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
19 | - |
|
20 | - $style = array( |
|
21 | - 'post_type' => FrmStylesController::$post_type, |
|
22 | - 'ID' => '', |
|
23 | - 'post_title' => __( 'New Style', 'formidable' ), |
|
24 | - 'post_name' => $key, |
|
25 | - 'post_content' => $this->get_defaults(), |
|
26 | - 'menu_order' => '', |
|
27 | - 'post_status' => 'publish', |
|
28 | - ); |
|
16 | + $max_slug_value = pow(36, 6); |
|
17 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
18 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
19 | + |
|
20 | + $style = array( |
|
21 | + 'post_type' => FrmStylesController::$post_type, |
|
22 | + 'ID' => '', |
|
23 | + 'post_title' => __( 'New Style', 'formidable' ), |
|
24 | + 'post_name' => $key, |
|
25 | + 'post_content' => $this->get_defaults(), |
|
26 | + 'menu_order' => '', |
|
27 | + 'post_status' => 'publish', |
|
28 | + ); |
|
29 | 29 | |
30 | - return (object) $style; |
|
31 | - } |
|
30 | + return (object) $style; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | public function save( $settings ) { |
34 | 34 | return FrmAppHelper::save_settings( $settings, 'frm_styles' ); |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | 37 | public function duplicate( $id ) { |
38 | - // duplicating is a pro feature |
|
39 | - } |
|
38 | + // duplicating is a pro feature |
|
39 | + } |
|
40 | 40 | |
41 | - public function update( $id = 'default' ) { |
|
41 | + public function update( $id = 'default' ) { |
|
42 | 42 | $all_instances = $this->get_all(); |
43 | 43 | |
44 | 44 | if ( empty($id) ) { |
45 | - $new_style = (array) $this->get_new(); |
|
46 | - $all_instances[] = $new_style; |
|
45 | + $new_style = (array) $this->get_new(); |
|
46 | + $all_instances[] = $new_style; |
|
47 | 47 | } |
48 | 48 | |
49 | - $action_ids = array(); |
|
49 | + $action_ids = array(); |
|
50 | 50 | |
51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
52 | 52 | $new_instance = stripslashes_deep( (array) $new_instance); |
@@ -54,40 +54,40 @@ discard block |
||
54 | 54 | if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
55 | 55 | $all_instances[ $number ] = $new_instance; |
56 | 56 | |
57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
58 | - // this style was set to default, so remove default setting on previous default style |
|
59 | - $new_instance['menu_order'] = 0; |
|
60 | - $action_ids[] = $this->save($new_instance); |
|
61 | - } |
|
57 | + if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
58 | + // this style was set to default, so remove default setting on previous default style |
|
59 | + $new_instance['menu_order'] = 0; |
|
60 | + $action_ids[] = $this->save($new_instance); |
|
61 | + } |
|
62 | 62 | |
63 | - // don't continue if not saving this style |
|
64 | - continue; |
|
63 | + // don't continue if not saving this style |
|
64 | + continue; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
70 | - $new_instance['post_status'] = 'publish'; |
|
70 | + $new_instance['post_status'] = 'publish'; |
|
71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
72 | 72 | |
73 | - if ( empty($id) ) { |
|
74 | - $new_instance['post_name'] = $new_instance['post_title']; |
|
75 | - } |
|
73 | + if ( empty($id) ) { |
|
74 | + $new_instance['post_name'] = $new_instance['post_title']; |
|
75 | + } |
|
76 | 76 | |
77 | - $default_settings = $this->get_defaults(); |
|
77 | + $default_settings = $this->get_defaults(); |
|
78 | 78 | |
79 | - foreach ( $default_settings as $setting => $default ) { |
|
79 | + foreach ( $default_settings as $setting => $default ) { |
|
80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
81 | - //if is a color |
|
81 | + //if is a color |
|
82 | 82 | $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
83 | 83 | } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
84 | 84 | $new_instance['post_content'][ $setting ] = 0; |
85 | - } |
|
86 | - } |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $all_instances[ $number ] = $new_instance; |
89 | 89 | |
90 | - $action_ids[] = $this->save($new_instance); |
|
90 | + $action_ids[] = $this->save($new_instance); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -96,74 +96,74 @@ discard block |
||
96 | 96 | return $action_ids; |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Create static css file |
|
101 | - */ |
|
99 | + /** |
|
100 | + * Create static css file |
|
101 | + */ |
|
102 | 102 | public function save_settings( $styles ) { |
103 | - $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
103 | + $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
104 | 104 | |
105 | - if ( ! is_file($filename) ) { |
|
106 | - return; |
|
107 | - } |
|
105 | + if ( ! is_file($filename) ) { |
|
106 | + return; |
|
107 | + } |
|
108 | 108 | |
109 | - $defaults = $this->get_defaults(); |
|
110 | - $uploads = wp_upload_dir(); |
|
111 | - $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | - $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | - $dirs_exist = true; |
|
109 | + $defaults = $this->get_defaults(); |
|
110 | + $uploads = wp_upload_dir(); |
|
111 | + $target_path = $uploads['basedir'] .'/formidable'; |
|
112 | + $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
113 | + $dirs_exist = true; |
|
114 | 114 | |
115 | - $saving = true; |
|
116 | - $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
115 | + $saving = true; |
|
116 | + $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
117 | 117 | |
118 | - ob_start(); |
|
119 | - $frm_style = $this; |
|
120 | - include($filename); |
|
118 | + ob_start(); |
|
119 | + $frm_style = $this; |
|
120 | + include($filename); |
|
121 | 121 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
122 | - ob_end_clean(); |
|
122 | + ob_end_clean(); |
|
123 | 123 | |
124 | - $access_type = get_filesystem_method(); |
|
125 | - if ( $access_type === 'direct' ) { |
|
126 | - $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
124 | + $access_type = get_filesystem_method(); |
|
125 | + if ( $access_type === 'direct' ) { |
|
126 | + $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
127 | 127 | } else { |
128 | 128 | $creds = $this->get_ftp_creds( $access_type ); |
129 | 129 | } |
130 | 130 | |
131 | 131 | if ( ! empty( $creds ) ) { |
132 | - // initialize the API |
|
133 | - if ( ! WP_Filesystem( $creds ) ) { |
|
134 | - // any problems and we exit |
|
135 | - $dirs_exist = false; |
|
132 | + // initialize the API |
|
133 | + if ( ! WP_Filesystem( $creds ) ) { |
|
134 | + // any problems and we exit |
|
135 | + $dirs_exist = false; |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( $dirs_exist ) { |
|
139 | - global $wp_filesystem; |
|
138 | + if ( $dirs_exist ) { |
|
139 | + global $wp_filesystem; |
|
140 | 140 | |
141 | - $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | - $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
141 | + $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
142 | + $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
143 | 143 | |
144 | - // Create the directories if need be: |
|
145 | - foreach ( $needed_dirs as $_dir ) { |
|
146 | - // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | - if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | - $dirs_exist = false; |
|
149 | - } |
|
150 | - } |
|
144 | + // Create the directories if need be: |
|
145 | + foreach ( $needed_dirs as $_dir ) { |
|
146 | + // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
|
147 | + if ( ! $wp_filesystem->mkdir( $_dir, $chmod_dir ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
148 | + $dirs_exist = false; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - $index_path = $target_path .'/index.php'; |
|
153 | - $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
152 | + $index_path = $target_path .'/index.php'; |
|
153 | + $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
|
154 | 154 | |
155 | - // only write the file if the folders exist |
|
156 | - if ( $dirs_exist ) { |
|
157 | - $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | - $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
155 | + // only write the file if the folders exist |
|
156 | + if ( $dirs_exist ) { |
|
157 | + $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | + $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | 162 | |
163 | - update_option('frmpro_css', $css); |
|
163 | + update_option('frmpro_css', $css); |
|
164 | 164 | |
165 | - delete_transient('frmpro_css'); |
|
166 | - set_transient('frmpro_css', $css); |
|
165 | + delete_transient('frmpro_css'); |
|
166 | + set_transient('frmpro_css', $css); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | private function get_ftp_creds( $type ) { |
@@ -217,271 +217,271 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | public function destroy( $id ) { |
220 | - return wp_delete_post($id); |
|
221 | - } |
|
220 | + return wp_delete_post($id); |
|
221 | + } |
|
222 | 222 | |
223 | - public function get_one() { |
|
224 | - if ( 'default' == $this->id ) { |
|
225 | - $style = $this->get_default_style(); |
|
226 | - if ( $style ) { |
|
227 | - $this->id = $style->ID; |
|
228 | - } else { |
|
229 | - $this->id = 0; |
|
230 | - } |
|
231 | - return $style; |
|
232 | - } |
|
223 | + public function get_one() { |
|
224 | + if ( 'default' == $this->id ) { |
|
225 | + $style = $this->get_default_style(); |
|
226 | + if ( $style ) { |
|
227 | + $this->id = $style->ID; |
|
228 | + } else { |
|
229 | + $this->id = 0; |
|
230 | + } |
|
231 | + return $style; |
|
232 | + } |
|
233 | 233 | |
234 | - $style = get_post($this->id); |
|
234 | + $style = get_post($this->id); |
|
235 | 235 | |
236 | - if ( ! $style ) { |
|
237 | - return $style; |
|
238 | - } |
|
236 | + if ( ! $style ) { |
|
237 | + return $style; |
|
238 | + } |
|
239 | 239 | |
240 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
240 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
241 | 241 | |
242 | - $default_values = $this->get_defaults(); |
|
242 | + $default_values = $this->get_defaults(); |
|
243 | 243 | |
244 | - // fill default values |
|
245 | - $style->post_content = $this->override_defaults($style->post_content); |
|
246 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
244 | + // fill default values |
|
245 | + $style->post_content = $this->override_defaults($style->post_content); |
|
246 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
247 | 247 | |
248 | - return $style; |
|
249 | - } |
|
248 | + return $style; |
|
249 | + } |
|
250 | 250 | |
251 | - public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | - $post_atts = array( |
|
251 | + public function get_all( $orderby = 'title', $order = 'ASC', $limit = 99 ) { |
|
252 | + $post_atts = array( |
|
253 | 253 | 'post_type' => FrmStylesController::$post_type, |
254 | 254 | 'post_status' => 'publish', |
255 | 255 | 'numberposts' => $limit, |
256 | 256 | 'orderby' => $orderby, |
257 | 257 | 'order' => $order, |
258 | - ); |
|
259 | - |
|
260 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | - |
|
262 | - if ( empty($temp_styles) ) { |
|
263 | - global $wpdb; |
|
264 | - // make sure there wasn't a conflict with the query |
|
265 | - $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
266 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | - |
|
268 | - if ( empty($temp_styles) ) { |
|
269 | - // create a new style if there are none |
|
270 | - $new = $this->get_new(); |
|
271 | - $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | - $new->menu_order = 1; |
|
273 | - $new = $this->save( (array) $new); |
|
274 | - $this->update('default'); |
|
275 | - |
|
276 | - $post_atts['include'] = $new; |
|
277 | - |
|
278 | - $temp_styles = get_posts( $post_atts ); |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - $default_values = $this->get_defaults(); |
|
283 | - $default_style = false; |
|
284 | - |
|
285 | - $styles = array(); |
|
286 | - foreach ( $temp_styles as $style ) { |
|
287 | - $this->id = $style->ID; |
|
288 | - if ( $style->menu_order ) { |
|
289 | - if ( $default_style ) { |
|
290 | - // only return one default |
|
291 | - $style->menu_order = 0; |
|
292 | - } else { |
|
293 | - // check for a default style |
|
294 | - $default_style = $style->ID; |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | - |
|
300 | - // fill default values |
|
301 | - $style->post_content = $this->override_defaults($style->post_content); |
|
302 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
258 | + ); |
|
259 | + |
|
260 | + $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | + |
|
262 | + if ( empty($temp_styles) ) { |
|
263 | + global $wpdb; |
|
264 | + // make sure there wasn't a conflict with the query |
|
265 | + $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
266 | + $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
267 | + |
|
268 | + if ( empty($temp_styles) ) { |
|
269 | + // create a new style if there are none |
|
270 | + $new = $this->get_new(); |
|
271 | + $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
|
272 | + $new->menu_order = 1; |
|
273 | + $new = $this->save( (array) $new); |
|
274 | + $this->update('default'); |
|
275 | + |
|
276 | + $post_atts['include'] = $new; |
|
277 | + |
|
278 | + $temp_styles = get_posts( $post_atts ); |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + $default_values = $this->get_defaults(); |
|
283 | + $default_style = false; |
|
284 | + |
|
285 | + $styles = array(); |
|
286 | + foreach ( $temp_styles as $style ) { |
|
287 | + $this->id = $style->ID; |
|
288 | + if ( $style->menu_order ) { |
|
289 | + if ( $default_style ) { |
|
290 | + // only return one default |
|
291 | + $style->menu_order = 0; |
|
292 | + } else { |
|
293 | + // check for a default style |
|
294 | + $default_style = $style->ID; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | + |
|
300 | + // fill default values |
|
301 | + $style->post_content = $this->override_defaults($style->post_content); |
|
302 | + $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
303 | 303 | |
304 | 304 | $styles[ $style->ID ] = $style; |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - if ( ! $default_style ) { |
|
308 | - $default_style = reset($styles); |
|
307 | + if ( ! $default_style ) { |
|
308 | + $default_style = reset($styles); |
|
309 | 309 | $styles[ $default_style->ID ]->menu_order = 1; |
310 | - } |
|
310 | + } |
|
311 | 311 | |
312 | - return $styles; |
|
313 | - } |
|
312 | + return $styles; |
|
313 | + } |
|
314 | 314 | |
315 | 315 | public function get_default_style( $styles = null ) { |
316 | - if ( ! isset($styles) ) { |
|
316 | + if ( ! isset($styles) ) { |
|
317 | 317 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
318 | - } |
|
318 | + } |
|
319 | 319 | |
320 | - foreach ( $styles as $style ) { |
|
321 | - if ( $style->menu_order ) { |
|
322 | - return $style; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
320 | + foreach ( $styles as $style ) { |
|
321 | + if ( $style->menu_order ) { |
|
322 | + return $style; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | public function override_defaults( $settings ) { |
328 | - if ( ! is_array($settings) ) { |
|
329 | - return $settings; |
|
330 | - } |
|
331 | - |
|
332 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | - |
|
334 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | - $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | - $settings['form_desc_color'] = $settings['description_color']; |
|
337 | - $settings['title_color'] = $settings['label_color']; |
|
338 | - } |
|
339 | - |
|
340 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | - $settings['section_color'] = $settings['label_color']; |
|
342 | - $settings['section_border_color'] = $settings['border_color']; |
|
343 | - } |
|
344 | - |
|
345 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | - $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | - $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | - $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | - |
|
350 | - $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | - $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | - $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | - } |
|
354 | - |
|
355 | - return $settings; |
|
328 | + if ( ! is_array($settings) ) { |
|
329 | + return $settings; |
|
330 | + } |
|
331 | + |
|
332 | + $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | + |
|
334 | + if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | + $settings['form_desc_size'] = $settings['description_font_size']; |
|
336 | + $settings['form_desc_color'] = $settings['description_color']; |
|
337 | + $settings['title_color'] = $settings['label_color']; |
|
338 | + } |
|
339 | + |
|
340 | + if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | + $settings['section_color'] = $settings['label_color']; |
|
342 | + $settings['section_border_color'] = $settings['border_color']; |
|
343 | + } |
|
344 | + |
|
345 | + if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | + $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
|
347 | + $settings['submit_hover_color'] = $settings['submit_text_color']; |
|
348 | + $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
|
349 | + |
|
350 | + $settings['submit_active_bg_color'] = $settings['submit_bg_color']; |
|
351 | + $settings['submit_active_color'] = $settings['submit_text_color']; |
|
352 | + $settings['submit_active_border_color'] = $settings['submit_border_color']; |
|
353 | + } |
|
354 | + |
|
355 | + return $settings; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | public function get_defaults() { |
359 | - return array( |
|
360 | - 'theme_css' => 'ui-lightness', |
|
361 | - 'theme_name' => 'UI Lightness', |
|
359 | + return array( |
|
360 | + 'theme_css' => 'ui-lightness', |
|
361 | + 'theme_name' => 'UI Lightness', |
|
362 | 362 | |
363 | 363 | 'center_form' => '', |
364 | - 'form_width' => '100%', |
|
365 | - 'form_align' => 'left', |
|
366 | - 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | - 'fieldset' => '0px', |
|
368 | - 'fieldset_color' => '000000', |
|
369 | - 'fieldset_padding' => '0 0 15px 0', |
|
370 | - 'fieldset_bg_color' => '', |
|
371 | - |
|
372 | - 'title_size' => '20px', |
|
373 | - 'title_color' => '444444', |
|
364 | + 'form_width' => '100%', |
|
365 | + 'form_align' => 'left', |
|
366 | + 'direction' => is_rtl() ? 'rtl' : 'ltr', |
|
367 | + 'fieldset' => '0px', |
|
368 | + 'fieldset_color' => '000000', |
|
369 | + 'fieldset_padding' => '0 0 15px 0', |
|
370 | + 'fieldset_bg_color' => '', |
|
371 | + |
|
372 | + 'title_size' => '20px', |
|
373 | + 'title_color' => '444444', |
|
374 | 374 | 'title_margin_top' => '10px', |
375 | 375 | 'title_margin_bottom' => '10px', |
376 | - 'form_desc_size' => '14px', |
|
377 | - 'form_desc_color' => '666666', |
|
376 | + 'form_desc_size' => '14px', |
|
377 | + 'form_desc_color' => '666666', |
|
378 | 378 | 'form_desc_margin_top' => '10px', |
379 | 379 | 'form_desc_margin_bottom' => '25px', |
380 | 380 | |
381 | - 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | - 'font_size' => '14px', |
|
383 | - 'label_color' => '444444', |
|
384 | - 'weight' => 'bold', |
|
385 | - 'position' => 'none', |
|
386 | - 'align' => 'left', |
|
387 | - 'width' => '150px', |
|
388 | - 'required_color' => 'B94A48', |
|
389 | - 'required_weight' => 'bold', |
|
390 | - 'label_padding' => '0 0 3px 0', |
|
391 | - |
|
392 | - 'description_font_size' => '12px', |
|
393 | - 'description_color' => '666666', |
|
394 | - 'description_weight' => 'normal', |
|
395 | - 'description_style' => 'normal', |
|
396 | - 'description_align' => 'left', |
|
397 | - |
|
398 | - 'field_font_size' => '14px', |
|
399 | - 'field_height' => '32px', |
|
400 | - 'line_height' => 'normal', |
|
401 | - 'field_width' => '100%', |
|
402 | - 'auto_width' => false, |
|
403 | - 'field_pad' => '6px 10px', |
|
404 | - 'field_margin' => '20px', |
|
381 | + 'font' => '"Lucida Grande","Lucida Sans Unicode",Tahoma,sans-serif', |
|
382 | + 'font_size' => '14px', |
|
383 | + 'label_color' => '444444', |
|
384 | + 'weight' => 'bold', |
|
385 | + 'position' => 'none', |
|
386 | + 'align' => 'left', |
|
387 | + 'width' => '150px', |
|
388 | + 'required_color' => 'B94A48', |
|
389 | + 'required_weight' => 'bold', |
|
390 | + 'label_padding' => '0 0 3px 0', |
|
391 | + |
|
392 | + 'description_font_size' => '12px', |
|
393 | + 'description_color' => '666666', |
|
394 | + 'description_weight' => 'normal', |
|
395 | + 'description_style' => 'normal', |
|
396 | + 'description_align' => 'left', |
|
397 | + |
|
398 | + 'field_font_size' => '14px', |
|
399 | + 'field_height' => '32px', |
|
400 | + 'line_height' => 'normal', |
|
401 | + 'field_width' => '100%', |
|
402 | + 'auto_width' => false, |
|
403 | + 'field_pad' => '6px 10px', |
|
404 | + 'field_margin' => '20px', |
|
405 | 405 | 'field_weight' => 'normal', |
406 | - 'text_color' => '555555', |
|
407 | - //'border_color_hv' => 'cccccc', |
|
408 | - 'border_color' => 'cccccc', |
|
409 | - 'field_border_width' => '1px', |
|
410 | - 'field_border_style' => 'solid', |
|
411 | - |
|
412 | - 'bg_color' => 'ffffff', |
|
413 | - //'bg_color_hv' => 'ffffff', |
|
406 | + 'text_color' => '555555', |
|
407 | + //'border_color_hv' => 'cccccc', |
|
408 | + 'border_color' => 'cccccc', |
|
409 | + 'field_border_width' => '1px', |
|
410 | + 'field_border_style' => 'solid', |
|
411 | + |
|
412 | + 'bg_color' => 'ffffff', |
|
413 | + //'bg_color_hv' => 'ffffff', |
|
414 | 414 | 'remove_box_shadow' => '', |
415 | - 'bg_color_active' => 'ffffff', |
|
415 | + 'bg_color_active' => 'ffffff', |
|
416 | 416 | 'border_color_active' => '66afe9', |
417 | 417 | 'remove_box_shadow_active' => '', |
418 | - 'text_color_error' => '444444', |
|
419 | - 'bg_color_error' => 'ffffff', |
|
418 | + 'text_color_error' => '444444', |
|
419 | + 'bg_color_error' => 'ffffff', |
|
420 | 420 | 'border_color_error' => 'B94A48', |
421 | 421 | 'border_width_error' => '1px', |
422 | 422 | 'border_style_error' => 'solid', |
423 | - 'bg_color_disabled' => 'ffffff', |
|
424 | - 'border_color_disabled' => 'E5E5E5', |
|
425 | - 'text_color_disabled' => 'A1A1A1', |
|
426 | - |
|
427 | - 'radio_align' => 'block', |
|
428 | - 'check_align' => 'block', |
|
429 | - 'check_font_size' => '13px', |
|
430 | - 'check_label_color' => '444444', |
|
431 | - 'check_weight' => 'normal', |
|
432 | - |
|
433 | - 'section_font_size' => '18px', |
|
434 | - 'section_color' => '444444', |
|
435 | - 'section_weight' => 'bold', |
|
436 | - 'section_pad' => '15px 0 3px 0', |
|
437 | - 'section_mar_top' => '15px', |
|
423 | + 'bg_color_disabled' => 'ffffff', |
|
424 | + 'border_color_disabled' => 'E5E5E5', |
|
425 | + 'text_color_disabled' => 'A1A1A1', |
|
426 | + |
|
427 | + 'radio_align' => 'block', |
|
428 | + 'check_align' => 'block', |
|
429 | + 'check_font_size' => '13px', |
|
430 | + 'check_label_color' => '444444', |
|
431 | + 'check_weight' => 'normal', |
|
432 | + |
|
433 | + 'section_font_size' => '18px', |
|
434 | + 'section_color' => '444444', |
|
435 | + 'section_weight' => 'bold', |
|
436 | + 'section_pad' => '15px 0 3px 0', |
|
437 | + 'section_mar_top' => '15px', |
|
438 | 438 | 'section_mar_bottom' => '12px', |
439 | - 'section_bg_color' => '', |
|
440 | - 'section_border_color' => 'e8e8e8', |
|
441 | - 'section_border_width' => '2px', |
|
442 | - 'section_border_style' => 'solid', |
|
443 | - 'section_border_loc' => '-top', |
|
444 | - 'collapse_icon' => '6', |
|
445 | - 'collapse_pos' => 'after', |
|
446 | - 'repeat_icon' => '1', |
|
447 | - |
|
448 | - 'submit_style' => false, |
|
449 | - 'submit_font_size' => '14px', |
|
450 | - 'submit_width' => 'auto', |
|
451 | - 'submit_height' => 'auto', |
|
452 | - 'submit_bg_color' => 'ffffff', |
|
453 | - 'submit_border_color' => 'cccccc', |
|
454 | - 'submit_border_width' => '1px', |
|
455 | - 'submit_text_color' => '444444', |
|
456 | - 'submit_weight' => 'normal', |
|
457 | - 'submit_border_radius' => '4px', |
|
458 | - 'submit_bg_img' => '', |
|
459 | - 'submit_margin' => '10px', |
|
460 | - 'submit_padding' => '6px 11px', |
|
461 | - 'submit_shadow_color' => 'eeeeee', |
|
462 | - 'submit_hover_bg_color' => 'efefef', |
|
463 | - 'submit_hover_color' => '444444', |
|
464 | - 'submit_hover_border_color' => 'cccccc', |
|
465 | - 'submit_active_bg_color' => 'efefef', |
|
466 | - 'submit_active_color' => '444444', |
|
467 | - 'submit_active_border_color' => 'cccccc', |
|
468 | - |
|
469 | - 'border_radius' => '4px', |
|
470 | - 'error_bg' => 'F2DEDE', |
|
471 | - 'error_border' => 'EBCCD1', |
|
472 | - 'error_text' => 'B94A48', |
|
473 | - 'error_font_size' => '14px', |
|
474 | - |
|
475 | - 'success_bg_color' => 'DFF0D8', |
|
476 | - 'success_border_color' => 'D6E9C6', |
|
477 | - 'success_text_color' => '468847', |
|
478 | - 'success_font_size' => '14px', |
|
479 | - |
|
480 | - 'important_style' => false, |
|
481 | - |
|
482 | - 'custom_css' => '', |
|
483 | - ); |
|
484 | - } |
|
439 | + 'section_bg_color' => '', |
|
440 | + 'section_border_color' => 'e8e8e8', |
|
441 | + 'section_border_width' => '2px', |
|
442 | + 'section_border_style' => 'solid', |
|
443 | + 'section_border_loc' => '-top', |
|
444 | + 'collapse_icon' => '6', |
|
445 | + 'collapse_pos' => 'after', |
|
446 | + 'repeat_icon' => '1', |
|
447 | + |
|
448 | + 'submit_style' => false, |
|
449 | + 'submit_font_size' => '14px', |
|
450 | + 'submit_width' => 'auto', |
|
451 | + 'submit_height' => 'auto', |
|
452 | + 'submit_bg_color' => 'ffffff', |
|
453 | + 'submit_border_color' => 'cccccc', |
|
454 | + 'submit_border_width' => '1px', |
|
455 | + 'submit_text_color' => '444444', |
|
456 | + 'submit_weight' => 'normal', |
|
457 | + 'submit_border_radius' => '4px', |
|
458 | + 'submit_bg_img' => '', |
|
459 | + 'submit_margin' => '10px', |
|
460 | + 'submit_padding' => '6px 11px', |
|
461 | + 'submit_shadow_color' => 'eeeeee', |
|
462 | + 'submit_hover_bg_color' => 'efefef', |
|
463 | + 'submit_hover_color' => '444444', |
|
464 | + 'submit_hover_border_color' => 'cccccc', |
|
465 | + 'submit_active_bg_color' => 'efefef', |
|
466 | + 'submit_active_color' => '444444', |
|
467 | + 'submit_active_border_color' => 'cccccc', |
|
468 | + |
|
469 | + 'border_radius' => '4px', |
|
470 | + 'error_bg' => 'F2DEDE', |
|
471 | + 'error_border' => 'EBCCD1', |
|
472 | + 'error_text' => 'B94A48', |
|
473 | + 'error_font_size' => '14px', |
|
474 | + |
|
475 | + 'success_bg_color' => 'DFF0D8', |
|
476 | + 'success_border_color' => 'D6E9C6', |
|
477 | + 'success_text_color' => '468847', |
|
478 | + 'success_font_size' => '14px', |
|
479 | + |
|
480 | + 'important_style' => false, |
|
481 | + |
|
482 | + 'custom_css' => '', |
|
483 | + ); |
|
484 | + } |
|
485 | 485 | |
486 | 486 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
487 | 487 | return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStyle { |
3 | - public $number = false; // Unique ID number of the current instance. |
|
3 | + public $number = false; // Unique ID number of the current instance. |
|
4 | 4 | public $id = 0; // the id of the post |
5 | 5 | |
6 | 6 | /** |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | public function get_new() { |
14 | 14 | $this->id = 0; |
15 | 15 | |
16 | - $max_slug_value = pow(36, 6); |
|
16 | + $max_slug_value = pow( 36, 6 ); |
|
17 | 17 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
18 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
18 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
19 | 19 | |
20 | 20 | $style = array( |
21 | 21 | 'post_type' => FrmStylesController::$post_type, |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function update( $id = 'default' ) { |
42 | 42 | $all_instances = $this->get_all(); |
43 | 43 | |
44 | - if ( empty($id) ) { |
|
44 | + if ( empty( $id ) ) { |
|
45 | 45 | $new_style = (array) $this->get_new(); |
46 | 46 | $all_instances[] = $new_style; |
47 | 47 | } |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | $action_ids = array(); |
50 | 50 | |
51 | 51 | foreach ( $all_instances as $number => $new_instance ) { |
52 | - $new_instance = stripslashes_deep( (array) $new_instance); |
|
52 | + $new_instance = stripslashes_deep( (array) $new_instance ); |
|
53 | 53 | $this->id = $new_instance['ID']; |
54 | - if ( $id != $this->id || ! $_POST || ! isset($_POST['frm_style_setting']) ) { |
|
55 | - $all_instances[ $number ] = $new_instance; |
|
54 | + if ( $id != $this->id || ! $_POST || ! isset( $_POST['frm_style_setting'] ) ) { |
|
55 | + $all_instances[$number] = $new_instance; |
|
56 | 56 | |
57 | - if ( $new_instance['menu_order'] && $_POST && empty($_POST['prev_menu_order']) && isset($_POST['frm_style_setting']['menu_order']) ) { |
|
57 | + if ( $new_instance['menu_order'] && $_POST && empty( $_POST['prev_menu_order'] ) && isset( $_POST['frm_style_setting']['menu_order'] ) ) { |
|
58 | 58 | // this style was set to default, so remove default setting on previous default style |
59 | 59 | $new_instance['menu_order'] = 0; |
60 | - $action_ids[] = $this->save($new_instance); |
|
60 | + $action_ids[] = $this->save( $new_instance ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // don't continue if not saving this style |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | $new_instance['post_title'] = sanitize_text_field( $_POST['frm_style_setting']['post_title'] ); |
68 | 68 | $new_instance['post_content'] = $_POST['frm_style_setting']['post_content']; |
69 | 69 | $new_instance['post_type'] = FrmStylesController::$post_type; |
70 | - $new_instance['post_status'] = 'publish'; |
|
70 | + $new_instance['post_status'] = 'publish'; |
|
71 | 71 | $new_instance['menu_order'] = isset( $_POST['frm_style_setting']['menu_order'] ) ? absint( $_POST['frm_style_setting']['menu_order'] ) : 0; |
72 | 72 | |
73 | - if ( empty($id) ) { |
|
73 | + if ( empty( $id ) ) { |
|
74 | 74 | $new_instance['post_name'] = $new_instance['post_title']; |
75 | 75 | } |
76 | 76 | |
@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | foreach ( $default_settings as $setting => $default ) { |
80 | 80 | if ( strpos( $setting, 'color' ) !== false || in_array( $setting, array( 'error_bg', 'error_border', 'error_text' ) ) ) { |
81 | 81 | //if is a color |
82 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $new_instance['post_content'][ $setting ] ); |
|
83 | - } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
84 | - $new_instance['post_content'][ $setting ] = 0; |
|
82 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $new_instance['post_content'][$setting] ); |
|
83 | + } else if ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ) ) && ! isset( $new_instance['post_content'][$setting] ) ) { |
|
84 | + $new_instance['post_content'][$setting] = 0; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - $all_instances[ $number ] = $new_instance; |
|
88 | + $all_instances[$number] = $new_instance; |
|
89 | 89 | |
90 | - $action_ids[] = $this->save($new_instance); |
|
90 | + $action_ids[] = $this->save( $new_instance ); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - $this->save_settings($all_instances); |
|
94 | + $this->save_settings( $all_instances ); |
|
95 | 95 | |
96 | 96 | return $action_ids; |
97 | 97 | } |
@@ -100,31 +100,31 @@ discard block |
||
100 | 100 | * Create static css file |
101 | 101 | */ |
102 | 102 | public function save_settings( $styles ) { |
103 | - $filename = FrmAppHelper::plugin_path() .'/css/custom_theme.css.php'; |
|
104 | - update_option( 'frm_last_style_update', date('njGi') ); |
|
103 | + $filename = FrmAppHelper::plugin_path() . '/css/custom_theme.css.php'; |
|
104 | + update_option( 'frm_last_style_update', date( 'njGi' ) ); |
|
105 | 105 | |
106 | - if ( ! is_file($filename) ) { |
|
106 | + if ( ! is_file( $filename ) ) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $defaults = $this->get_defaults(); |
111 | 111 | $uploads = wp_upload_dir(); |
112 | - $target_path = $uploads['basedir'] .'/formidable'; |
|
113 | - $needed_dirs = array( $target_path, $target_path .'/css' ); |
|
112 | + $target_path = $uploads['basedir'] . '/formidable'; |
|
113 | + $needed_dirs = array( $target_path, $target_path . '/css' ); |
|
114 | 114 | $dirs_exist = true; |
115 | 115 | |
116 | 116 | $saving = true; |
117 | - $css = '/* '. __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) .' */'. "\n"; |
|
117 | + $css = '/* ' . __( 'WARNING: Any changes made to this file will be lost when your Formidable settings are updated', 'formidable' ) . ' */' . "\n"; |
|
118 | 118 | |
119 | 119 | ob_start(); |
120 | 120 | $frm_style = $this; |
121 | - include($filename); |
|
121 | + include( $filename ); |
|
122 | 122 | $css .= preg_replace( '/\/\*(.|\s)*?\*\//', '', str_replace( array( "\r\n", "\r", "\n", "\t", ' ' ), '', ob_get_contents() ) ); |
123 | 123 | ob_end_clean(); |
124 | 124 | |
125 | 125 | $access_type = get_filesystem_method(); |
126 | 126 | if ( $access_type === 'direct' ) { |
127 | - $creds = request_filesystem_credentials( site_url() .'/wp-admin/', '', false, false, array() ); |
|
127 | + $creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() ); |
|
128 | 128 | } else { |
129 | 129 | $creds = $this->get_ftp_creds( $access_type ); |
130 | 130 | } |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | if ( $dirs_exist ) { |
140 | 140 | global $wp_filesystem; |
141 | 141 | |
142 | - $chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
143 | - $chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
142 | + $chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
143 | + $chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
144 | 144 | |
145 | 145 | // Create the directories if need be: |
146 | 146 | foreach ( $needed_dirs as $_dir ) { |
@@ -150,33 +150,33 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - $index_path = $target_path .'/index.php'; |
|
153 | + $index_path = $target_path . '/index.php'; |
|
154 | 154 | $wp_filesystem->put_contents( $index_path, "<?php\n// Silence is golden.\n?>", $chmod_file ); |
155 | 155 | |
156 | 156 | // only write the file if the folders exist |
157 | 157 | if ( $dirs_exist ) { |
158 | - $css_file = $target_path .'/css/formidablepro.css'; |
|
158 | + $css_file = $target_path . '/css/formidablepro.css'; |
|
159 | 159 | $wp_filesystem->put_contents( $css_file, $css, $chmod_file ); |
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - update_option('frmpro_css', $css); |
|
164 | + update_option( 'frmpro_css', $css ); |
|
165 | 165 | |
166 | - delete_transient('frmpro_css'); |
|
167 | - set_transient('frmpro_css', $css); |
|
166 | + delete_transient( 'frmpro_css' ); |
|
167 | + set_transient( 'frmpro_css', $css ); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | private function get_ftp_creds( $type ) { |
171 | 171 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
172 | 172 | |
173 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
174 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
175 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
173 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
174 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
175 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
176 | 176 | |
177 | 177 | // Check to see if we are setting the public/private keys for ssh |
178 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
179 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
178 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
179 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
180 | 180 | |
181 | 181 | // Sanitize the hostname, Some people might pass in odd-data: |
182 | 182 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | public function destroy( $id ) { |
221 | - return wp_delete_post($id); |
|
221 | + return wp_delete_post( $id ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | public function get_one() { |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | return $style; |
233 | 233 | } |
234 | 234 | |
235 | - $style = get_post($this->id); |
|
235 | + $style = get_post( $this->id ); |
|
236 | 236 | |
237 | 237 | if ( ! $style ) { |
238 | 238 | return $style; |
239 | 239 | } |
240 | 240 | |
241 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
241 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
242 | 242 | |
243 | 243 | $default_values = $this->get_defaults(); |
244 | 244 | |
245 | 245 | // fill default values |
246 | - $style->post_content = $this->override_defaults($style->post_content); |
|
247 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
246 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
247 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
248 | 248 | |
249 | 249 | return $style; |
250 | 250 | } |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | 'order' => $order, |
259 | 259 | ); |
260 | 260 | |
261 | - $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts'); |
|
261 | + $temp_styles = FrmAppHelper::check_cache( serialize( $post_atts ), 'frm_styles', $post_atts, 'get_posts' ); |
|
262 | 262 | |
263 | - if ( empty($temp_styles) ) { |
|
263 | + if ( empty( $temp_styles ) ) { |
|
264 | 264 | global $wpdb; |
265 | 265 | // make sure there wasn't a conflict with the query |
266 | - $query = $wpdb->prepare('SELECT * FROM '. $wpdb->posts .' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish'); |
|
267 | - $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results'); |
|
266 | + $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish' ); |
|
267 | + $temp_styles = FrmAppHelper::check_cache( 'frm_backup_style_check', 'frm_styles', $query, 'get_results' ); |
|
268 | 268 | |
269 | - if ( empty($temp_styles) ) { |
|
269 | + if ( empty( $temp_styles ) ) { |
|
270 | 270 | // create a new style if there are none |
271 | 271 | $new = $this->get_new(); |
272 | 272 | $new->post_title = $new->post_name = __( 'Formidable Style', 'formidable' ); |
273 | 273 | $new->menu_order = 1; |
274 | - $new = $this->save( (array) $new); |
|
275 | - $this->update('default'); |
|
274 | + $new = $this->save( (array) $new ); |
|
275 | + $this->update( 'default' ); |
|
276 | 276 | |
277 | 277 | $post_atts['include'] = $new; |
278 | 278 | |
@@ -296,25 +296,25 @@ discard block |
||
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | - $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content); |
|
299 | + $style->post_content = FrmAppHelper::maybe_json_decode( $style->post_content ); |
|
300 | 300 | |
301 | 301 | // fill default values |
302 | - $style->post_content = $this->override_defaults($style->post_content); |
|
303 | - $style->post_content = wp_parse_args( $style->post_content, $default_values); |
|
302 | + $style->post_content = $this->override_defaults( $style->post_content ); |
|
303 | + $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
|
304 | 304 | |
305 | - $styles[ $style->ID ] = $style; |
|
305 | + $styles[$style->ID] = $style; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | if ( ! $default_style ) { |
309 | - $default_style = reset($styles); |
|
310 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
309 | + $default_style = reset( $styles ); |
|
310 | + $styles[$default_style->ID]->menu_order = 1; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | return $styles; |
314 | 314 | } |
315 | 315 | |
316 | 316 | public function get_default_style( $styles = null ) { |
317 | - if ( ! isset($styles) ) { |
|
317 | + if ( ! isset( $styles ) ) { |
|
318 | 318 | $styles = $this->get_all( 'menu_order', 'DESC', 1 ); |
319 | 319 | } |
320 | 320 | |
@@ -326,24 +326,24 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | public function override_defaults( $settings ) { |
329 | - if ( ! is_array($settings) ) { |
|
329 | + if ( ! is_array( $settings ) ) { |
|
330 | 330 | return $settings; |
331 | 331 | } |
332 | 332 | |
333 | - $settings['line_height'] = ( ! isset($settings['field_height']) || $settings['field_height'] == '' || $settings['field_height'] == 'auto') ? 'normal' : $settings['field_height']; |
|
333 | + $settings['line_height'] = ( ! isset( $settings['field_height'] ) || $settings['field_height'] == '' || $settings['field_height'] == 'auto' ) ? 'normal' : $settings['field_height']; |
|
334 | 334 | |
335 | - if ( ! isset($settings['form_desc_size']) && isset($settings['description_font_size']) ) { |
|
335 | + if ( ! isset( $settings['form_desc_size'] ) && isset( $settings['description_font_size'] ) ) { |
|
336 | 336 | $settings['form_desc_size'] = $settings['description_font_size']; |
337 | 337 | $settings['form_desc_color'] = $settings['description_color']; |
338 | 338 | $settings['title_color'] = $settings['label_color']; |
339 | 339 | } |
340 | 340 | |
341 | - if ( ! isset($settings['section_color']) && isset($settings['label_color']) ) { |
|
341 | + if ( ! isset( $settings['section_color'] ) && isset( $settings['label_color'] ) ) { |
|
342 | 342 | $settings['section_color'] = $settings['label_color']; |
343 | 343 | $settings['section_border_color'] = $settings['border_color']; |
344 | 344 | } |
345 | 345 | |
346 | - if ( ! isset($settings['submit_hover_bg_color']) && isset($settings['submit_bg_color']) ) { |
|
346 | + if ( ! isset( $settings['submit_hover_bg_color'] ) && isset( $settings['submit_bg_color'] ) ) { |
|
347 | 347 | $settings['submit_hover_bg_color'] = $settings['submit_bg_color']; |
348 | 348 | $settings['submit_hover_color'] = $settings['submit_text_color']; |
349 | 349 | $settings['submit_hover_border_color'] = $settings['submit_border_color']; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | } |
486 | 486 | |
487 | 487 | public function get_field_name( $field_name, $post_field = 'post_content' ) { |
488 | - return 'frm_style_setting'. ( empty($post_field) ? '' : '['. $post_field .']' ) .'[' . $field_name . ']'; |
|
488 | + return 'frm_style_setting' . ( empty( $post_field ) ? '' : '[' . $post_field . ']' ) . '[' . $field_name . ']'; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | public static function get_bold_options() { |
@@ -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 Controller |
144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
146 | 146 | |
147 | - // Fields Controller |
|
148 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
149 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
150 | - add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
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 |
|
147 | + // Fields Controller |
|
148 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
149 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
150 | + add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
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 | } |
@@ -5,68 +5,68 @@ discard block |
||
5 | 5 | |
6 | 6 | class FrmEntriesHelper { |
7 | 7 | |
8 | - public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | - global $frm_vars; |
|
10 | - $values = array(); |
|
8 | + public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) { |
|
9 | + global $frm_vars; |
|
10 | + $values = array(); |
|
11 | 11 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | - } |
|
14 | - |
|
15 | - $values['fields'] = array(); |
|
16 | - if ( empty($fields) ) { |
|
17 | - return apply_filters('frm_setup_new_entry', $values); |
|
18 | - } |
|
19 | - |
|
20 | - foreach ( (array) $fields as $field ) { |
|
21 | - $new_value = self::get_field_value_for_new_entry( $field, $reset ); |
|
22 | - |
|
23 | - $field_array = array( |
|
24 | - 'id' => $field->id, |
|
25 | - 'value' => $new_value, |
|
26 | - 'default_value' => $field->default_value, |
|
27 | - 'name' => $field->name, |
|
28 | - 'description' => $field->description, |
|
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | - 'options' => $field->options, |
|
31 | - 'required' => $field->required, |
|
32 | - 'field_key' => $field->field_key, |
|
33 | - 'field_order' => $field->field_order, |
|
34 | - 'form_id' => $field->form_id, |
|
12 | + $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | + } |
|
14 | + |
|
15 | + $values['fields'] = array(); |
|
16 | + if ( empty($fields) ) { |
|
17 | + return apply_filters('frm_setup_new_entry', $values); |
|
18 | + } |
|
19 | + |
|
20 | + foreach ( (array) $fields as $field ) { |
|
21 | + $new_value = self::get_field_value_for_new_entry( $field, $reset ); |
|
22 | + |
|
23 | + $field_array = array( |
|
24 | + 'id' => $field->id, |
|
25 | + 'value' => $new_value, |
|
26 | + 'default_value' => $field->default_value, |
|
27 | + 'name' => $field->name, |
|
28 | + 'description' => $field->description, |
|
29 | + 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
30 | + 'options' => $field->options, |
|
31 | + 'required' => $field->required, |
|
32 | + 'field_key' => $field->field_key, |
|
33 | + 'field_order' => $field->field_order, |
|
34 | + 'form_id' => $field->form_id, |
|
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | - ); |
|
36 | + ); |
|
37 | 37 | |
38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
39 | - $opt_defaults['required_indicator'] = ''; |
|
38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
39 | + $opt_defaults['required_indicator'] = ''; |
|
40 | 40 | $opt_defaults['original_type'] = $field->type; |
41 | 41 | |
42 | 42 | foreach ( $opt_defaults as $opt => $default_opt ) { |
43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | - unset($opt, $default_opt); |
|
45 | - } |
|
43 | + $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | + unset($opt, $default_opt); |
|
45 | + } |
|
46 | 46 | |
47 | - unset($opt_defaults); |
|
47 | + unset($opt_defaults); |
|
48 | 48 | |
49 | - if ( $field_array['custom_html'] == '' ) { |
|
50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
51 | - } |
|
49 | + if ( $field_array['custom_html'] == '' ) { |
|
50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
51 | + } |
|
52 | 52 | |
53 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
54 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
53 | + $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
54 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
55 | 55 | |
56 | - $values['fields'][] = $field_array; |
|
56 | + $values['fields'][] = $field_array; |
|
57 | 57 | |
58 | - if ( ! $form || ! isset($form->id) ) { |
|
59 | - $form = FrmForm::getOne($field->form_id); |
|
60 | - } |
|
61 | - } |
|
58 | + if ( ! $form || ! isset($form->id) ) { |
|
59 | + $form = FrmForm::getOne($field->form_id); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - $form->options = maybe_unserialize($form->options); |
|
64 | - if ( is_array($form->options) ) { |
|
65 | - foreach ( $form->options as $opt => $value ) { |
|
66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | - unset($opt, $value); |
|
68 | - } |
|
69 | - } |
|
63 | + $form->options = maybe_unserialize($form->options); |
|
64 | + if ( is_array($form->options) ) { |
|
65 | + foreach ( $form->options as $opt => $value ) { |
|
66 | + $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | + unset($opt, $value); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
72 | 72 | |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | $values = array_merge( $form_defaults, $values ); |
77 | 77 | |
78 | 78 | return apply_filters( 'frm_setup_new_entry', $values ); |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | /** |
82 | - * Set the value for each field |
|
83 | - * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
84 | - * |
|
85 | - * @since 2.0.13 |
|
86 | - * |
|
87 | - * @param object $field - this is passed by reference since it is an object |
|
88 | - * @param boolean $reset |
|
89 | - * @return string|array $new_value |
|
90 | - */ |
|
82 | + * Set the value for each field |
|
83 | + * This function is used when the form is first loaded and on all page turns *for a new entry* |
|
84 | + * |
|
85 | + * @since 2.0.13 |
|
86 | + * |
|
87 | + * @param object $field - this is passed by reference since it is an object |
|
88 | + * @param boolean $reset |
|
89 | + * @return string|array $new_value |
|
90 | + */ |
|
91 | 91 | private static function get_field_value_for_new_entry( $field, $reset ) { |
92 | 92 | //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array |
93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | |
119 | 119 | public static function setup_edit_vars( $values, $record ) { |
120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
121 | - $values['form_id'] = $record->form_id; |
|
122 | - $values['is_draft'] = $record->is_draft; |
|
123 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
124 | - } |
|
121 | + $values['form_id'] = $record->form_id; |
|
122 | + $values['is_draft'] = $record->is_draft; |
|
123 | + return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
124 | + } |
|
125 | 125 | |
126 | - public static function get_admin_params( $form = null ) { |
|
126 | + public static function get_admin_params( $form = null ) { |
|
127 | 127 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_admin_params' ); |
128 | 128 | return FrmForm::set_current_form( $form ); |
129 | - } |
|
129 | + } |
|
130 | 130 | |
131 | 131 | public static function set_current_form( $form_id ) { |
132 | 132 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::set_current_form' ); |
@@ -138,280 +138,280 @@ discard block |
||
138 | 138 | return FrmForm::get_current_form( $form_id ); |
139 | 139 | } |
140 | 140 | |
141 | - public static function get_current_form_id() { |
|
141 | + public static function get_current_form_id() { |
|
142 | 142 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::get_current_form_id' ); |
143 | 143 | return FrmForm::get_current_form_id(); |
144 | - } |
|
144 | + } |
|
145 | 145 | |
146 | - public static function maybe_get_entry( &$entry ) { |
|
146 | + public static function maybe_get_entry( &$entry ) { |
|
147 | 147 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntry::maybe_get_entry' ); |
148 | 148 | FrmEntry::maybe_get_entry( $entry ); |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | 151 | public static function replace_default_message( $message, $atts ) { |
152 | - if ( strpos($message, '[default-message') === false && |
|
153 | - strpos($message, '[default_message') === false && |
|
154 | - ! empty( $message ) ) { |
|
155 | - return $message; |
|
156 | - } |
|
157 | - |
|
158 | - if ( empty($message) ) { |
|
159 | - $message = '[default-message]'; |
|
160 | - } |
|
161 | - |
|
162 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
163 | - |
|
164 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
166 | - if ( $add_atts ) { |
|
167 | - $this_atts = array_merge($atts, $add_atts); |
|
168 | - } else { |
|
169 | - $this_atts = $atts; |
|
170 | - } |
|
152 | + if ( strpos($message, '[default-message') === false && |
|
153 | + strpos($message, '[default_message') === false && |
|
154 | + ! empty( $message ) ) { |
|
155 | + return $message; |
|
156 | + } |
|
157 | + |
|
158 | + if ( empty($message) ) { |
|
159 | + $message = '[default-message]'; |
|
160 | + } |
|
161 | + |
|
162 | + preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
163 | + |
|
164 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
166 | + if ( $add_atts ) { |
|
167 | + $this_atts = array_merge($atts, $add_atts); |
|
168 | + } else { |
|
169 | + $this_atts = $atts; |
|
170 | + } |
|
171 | 171 | |
172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); |
173 | 173 | |
174 | - // Add the default message |
|
175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
176 | - } |
|
174 | + // Add the default message |
|
175 | + $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
176 | + } |
|
177 | 177 | |
178 | - return $message; |
|
179 | - } |
|
178 | + return $message; |
|
179 | + } |
|
180 | 180 | |
181 | 181 | public static function prepare_display_value( $entry, $field, $atts ) { |
182 | 182 | $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
183 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
183 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | - return self::display_value($field_value, $field, $atts); |
|
189 | - } |
|
187 | + if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | + return self::display_value($field_value, $field, $atts); |
|
189 | + } |
|
190 | 190 | |
191 | - // this is an embeded form |
|
192 | - $val = ''; |
|
191 | + // this is an embeded form |
|
192 | + $val = ''; |
|
193 | 193 | |
194 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
195 | - //this is a repeating section |
|
194 | + if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
195 | + //this is a repeating section |
|
196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
197 | - } else { |
|
198 | - // get all values for this field |
|
199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
197 | + } else { |
|
198 | + // get all values for this field |
|
199 | + $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
200 | 200 | |
201 | - if ( $child_values ) { |
|
202 | - $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
203 | - } |
|
204 | - } |
|
201 | + if ( $child_values ) { |
|
202 | + $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
|
203 | + } |
|
204 | + } |
|
205 | 205 | |
206 | - $field_value = array(); |
|
206 | + $field_value = array(); |
|
207 | 207 | |
208 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | - return $val; |
|
210 | - } |
|
208 | + if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | + return $val; |
|
210 | + } |
|
211 | 211 | |
212 | - foreach ( $child_entries as $child_entry ) { |
|
213 | - $atts['item_id'] = $child_entry->id; |
|
214 | - $atts['post_id'] = $child_entry->post_id; |
|
212 | + foreach ( $child_entries as $child_entry ) { |
|
213 | + $atts['item_id'] = $child_entry->id; |
|
214 | + $atts['post_id'] = $child_entry->post_id; |
|
215 | 215 | |
216 | - // get the value for this field -- check for post values as well |
|
217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
216 | + // get the value for this field -- check for post values as well |
|
217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
218 | 218 | |
219 | - if ( $entry_val ) { |
|
220 | - // foreach entry get display_value |
|
221 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
222 | - } |
|
219 | + if ( $entry_val ) { |
|
220 | + // foreach entry get display_value |
|
221 | + $field_value[] = self::display_value($entry_val, $field, $atts); |
|
222 | + } |
|
223 | 223 | |
224 | - unset($child_entry); |
|
225 | - } |
|
224 | + unset($child_entry); |
|
225 | + } |
|
226 | 226 | |
227 | - $val = implode(', ', (array) $field_value ); |
|
227 | + $val = implode(', ', (array) $field_value ); |
|
228 | 228 | $val = wp_kses_post( $val ); |
229 | 229 | |
230 | - return $val; |
|
231 | - } |
|
230 | + return $val; |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * Prepare the saved value for display |
|
235 | - * @return string |
|
236 | - */ |
|
233 | + /** |
|
234 | + * Prepare the saved value for display |
|
235 | + * @return string |
|
236 | + */ |
|
237 | 237 | public static function display_value( $value, $field, $atts = array() ) { |
238 | 238 | |
239 | - $defaults = array( |
|
240 | - 'type' => '', 'html' => false, 'show_filename' => true, |
|
241 | - 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
242 | - 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
239 | + $defaults = array( |
|
240 | + 'type' => '', 'html' => false, 'show_filename' => true, |
|
241 | + 'truncate' => false, 'sep' => ', ', 'post_id' => 0, |
|
242 | + 'form_id' => $field->form_id, 'field' => $field, 'keepjs' => 0, |
|
243 | 243 | 'return_array' => false, |
244 | - ); |
|
244 | + ); |
|
245 | 245 | |
246 | - $atts = wp_parse_args( $atts, $defaults ); |
|
247 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
246 | + $atts = wp_parse_args( $atts, $defaults ); |
|
247 | + $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
248 | 248 | |
249 | - if ( ! isset($field->field_options['post_field']) ) { |
|
250 | - $field->field_options['post_field'] = ''; |
|
251 | - } |
|
249 | + if ( ! isset($field->field_options['post_field']) ) { |
|
250 | + $field->field_options['post_field'] = ''; |
|
251 | + } |
|
252 | 252 | |
253 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
254 | - $field->field_options['custom_field'] = ''; |
|
255 | - } |
|
253 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
254 | + $field->field_options['custom_field'] = ''; |
|
255 | + } |
|
256 | 256 | |
257 | - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
258 | - $atts['pre_truncate'] = $atts['truncate']; |
|
259 | - $atts['truncate'] = true; |
|
260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
257 | + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
|
258 | + $atts['pre_truncate'] = $atts['truncate']; |
|
259 | + $atts['truncate'] = true; |
|
260 | + $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
261 | 261 | |
262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
263 | - $atts['truncate'] = $atts['pre_truncate']; |
|
264 | - } |
|
262 | + $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
263 | + $atts['truncate'] = $atts['pre_truncate']; |
|
264 | + } |
|
265 | 265 | |
266 | - if ( $value == '' ) { |
|
267 | - return $value; |
|
268 | - } |
|
266 | + if ( $value == '' ) { |
|
267 | + return $value; |
|
268 | + } |
|
269 | 269 | |
270 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
270 | + $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
271 | 271 | |
272 | - $new_value = ''; |
|
272 | + $new_value = ''; |
|
273 | 273 | |
274 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
275 | - foreach ( $value as $val ) { |
|
276 | - if ( is_array($val) ) { |
|
274 | + if ( is_array($value) && $atts['type'] != 'file' ) { |
|
275 | + foreach ( $value as $val ) { |
|
276 | + if ( is_array($val) ) { |
|
277 | 277 | //TODO: add options for display (li or ,) |
278 | - $new_value .= implode($atts['sep'], $val); |
|
279 | - if ( $atts['type'] != 'data' ) { |
|
280 | - $new_value .= '<br/>'; |
|
281 | - } |
|
282 | - } |
|
283 | - unset($val); |
|
284 | - } |
|
285 | - } |
|
286 | - |
|
287 | - if ( ! empty($new_value) ) { |
|
288 | - $value = $new_value; |
|
289 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | - $value = implode($atts['sep'], $value); |
|
291 | - } |
|
292 | - |
|
293 | - if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
294 | - $value = FrmAppHelper::truncate($value, 50); |
|
295 | - } |
|
278 | + $new_value .= implode($atts['sep'], $val); |
|
279 | + if ( $atts['type'] != 'data' ) { |
|
280 | + $new_value .= '<br/>'; |
|
281 | + } |
|
282 | + } |
|
283 | + unset($val); |
|
284 | + } |
|
285 | + } |
|
286 | + |
|
287 | + if ( ! empty($new_value) ) { |
|
288 | + $value = $new_value; |
|
289 | + } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | + $value = implode($atts['sep'], $value); |
|
291 | + } |
|
292 | + |
|
293 | + if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
|
294 | + $value = FrmAppHelper::truncate($value, 50); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
298 | 298 | $value = wp_kses_post( $value ); |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
302 | - } |
|
301 | + return apply_filters('frm_display_value', $value, $field, $atts); |
|
302 | + } |
|
303 | 303 | |
304 | 304 | public static function set_posted_value( $field, $value, $args ) { |
305 | - // If validating a field with "other" opt, set back to prev value now |
|
306 | - if ( isset( $args['other'] ) && $args['other'] ) { |
|
307 | - $value = $args['temp_value']; |
|
308 | - } |
|
309 | - if ( empty($args['parent_field_id']) ) { |
|
310 | - $_POST['item_meta'][ $field->id ] = $value; |
|
311 | - } else { |
|
312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
313 | - } |
|
314 | - } |
|
305 | + // If validating a field with "other" opt, set back to prev value now |
|
306 | + if ( isset( $args['other'] ) && $args['other'] ) { |
|
307 | + $value = $args['temp_value']; |
|
308 | + } |
|
309 | + if ( empty($args['parent_field_id']) ) { |
|
310 | + $_POST['item_meta'][ $field->id ] = $value; |
|
311 | + } else { |
|
312 | + $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
313 | + } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | public static function get_posted_value( $field, &$value, $args ) { |
317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; |
318 | 318 | |
319 | - if ( empty($args['parent_field_id']) ) { |
|
320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
321 | - } else { |
|
322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
323 | - } |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Check if field has an "Other" option and if any other values are posted |
|
328 | - * |
|
329 | - * @since 2.0 |
|
330 | - * |
|
331 | - * @param object $field |
|
332 | - * @param string|array $value |
|
333 | - * @param array $args |
|
334 | - */ |
|
335 | - public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
336 | - $args['other'] = false; |
|
337 | - if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
338 | - return; |
|
339 | - } |
|
340 | - |
|
341 | - // Get other value for fields in repeating section |
|
342 | - self::set_other_repeating_vals( $field, $value, $args ); |
|
343 | - |
|
344 | - // Check if there are any posted "Other" values |
|
319 | + if ( empty($args['parent_field_id']) ) { |
|
320 | + $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
321 | + } else { |
|
322 | + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
323 | + } |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Check if field has an "Other" option and if any other values are posted |
|
328 | + * |
|
329 | + * @since 2.0 |
|
330 | + * |
|
331 | + * @param object $field |
|
332 | + * @param string|array $value |
|
333 | + * @param array $args |
|
334 | + */ |
|
335 | + public static function maybe_set_other_validation( $field, &$value, &$args ) { |
|
336 | + $args['other'] = false; |
|
337 | + if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) { |
|
338 | + return; |
|
339 | + } |
|
340 | + |
|
341 | + // Get other value for fields in repeating section |
|
342 | + self::set_other_repeating_vals( $field, $value, $args ); |
|
343 | + |
|
344 | + // Check if there are any posted "Other" values |
|
345 | 345 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
346 | 346 | |
347 | - // Save original value |
|
348 | - $args['temp_value'] = $value; |
|
349 | - $args['other'] = true; |
|
350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
351 | - |
|
352 | - // Set the validation value now |
|
353 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
359 | - * |
|
360 | - * @since 2.0 |
|
361 | - * |
|
362 | - * @param object $field |
|
363 | - * @param string|array $value |
|
364 | - * @param array $args |
|
365 | - */ |
|
366 | - public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
367 | - if ( ! $args['parent_field_id'] ) { |
|
368 | - return; |
|
369 | - } |
|
370 | - |
|
371 | - // Check if there are any other posted "other" values for this field |
|
347 | + // Save original value |
|
348 | + $args['temp_value'] = $value; |
|
349 | + $args['other'] = true; |
|
350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
351 | + |
|
352 | + // Set the validation value now |
|
353 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS |
|
359 | + * |
|
360 | + * @since 2.0 |
|
361 | + * |
|
362 | + * @param object $field |
|
363 | + * @param string|array $value |
|
364 | + * @param array $args |
|
365 | + */ |
|
366 | + public static function set_other_repeating_vals( $field, &$value, &$args ) { |
|
367 | + if ( ! $args['parent_field_id'] ) { |
|
368 | + return; |
|
369 | + } |
|
370 | + |
|
371 | + // Check if there are any other posted "other" values for this field |
|
372 | 372 | if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
373 | - // Save original value |
|
374 | - $args['temp_value'] = $value; |
|
375 | - $args['other'] = true; |
|
376 | - |
|
377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
378 | - |
|
379 | - // Set the validation value now |
|
380 | - self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Modify value used for validation |
|
386 | - * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
387 | - * It also adds any text from the free text fields to the value |
|
388 | - * |
|
389 | - * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
390 | - * |
|
391 | - * @since 2.0 |
|
392 | - * |
|
393 | - * @param string|array $value |
|
394 | - * @param string|array $other_vals (usually of posted values) |
|
395 | - * @param object $field |
|
396 | - * @param array $args |
|
397 | - */ |
|
398 | - public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
399 | - // Checkboxes and multi-select dropdowns |
|
400 | - if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
401 | - // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
402 | - $value = array_merge( $value, $other_vals ); |
|
403 | - $value = array_filter( $value ); |
|
404 | - if ( count( $value ) == 0 ) { |
|
405 | - $value = ''; |
|
406 | - } |
|
407 | - } else { |
|
373 | + // Save original value |
|
374 | + $args['temp_value'] = $value; |
|
375 | + $args['other'] = true; |
|
376 | + |
|
377 | + $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
378 | + |
|
379 | + // Set the validation value now |
|
380 | + self::set_other_validation_val( $value, $other_vals, $field, $args ); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Modify value used for validation |
|
386 | + * This function essentially removes the "Other" radio or checkbox value from the $value being validated. |
|
387 | + * It also adds any text from the free text fields to the value |
|
388 | + * |
|
389 | + * Needs to accommodate for times when other opt is selected, but no other free text is entered |
|
390 | + * |
|
391 | + * @since 2.0 |
|
392 | + * |
|
393 | + * @param string|array $value |
|
394 | + * @param string|array $other_vals (usually of posted values) |
|
395 | + * @param object $field |
|
396 | + * @param array $args |
|
397 | + */ |
|
398 | + public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) { |
|
399 | + // Checkboxes and multi-select dropdowns |
|
400 | + if ( is_array( $value ) && $field->type == 'checkbox' ) { |
|
401 | + // Combine "Other" values with checked values. "Other" values will override checked box values. |
|
402 | + $value = array_merge( $value, $other_vals ); |
|
403 | + $value = array_filter( $value ); |
|
404 | + if ( count( $value ) == 0 ) { |
|
405 | + $value = ''; |
|
406 | + } |
|
407 | + } else { |
|
408 | 408 | // Radio and dropdowns |
409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
410 | - $other_key = reset( $other_key ); |
|
409 | + $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
410 | + $other_key = reset( $other_key ); |
|
411 | 411 | |
412 | - // Multi-select dropdown |
|
413 | - if ( is_array( $value ) ) { |
|
414 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
412 | + // Multi-select dropdown |
|
413 | + if ( is_array( $value ) ) { |
|
414 | + $o_key = array_search( $field->options[ $other_key ], $value ); |
|
415 | 415 | |
416 | 416 | if ( $o_key !== false ) { |
417 | 417 | // Modify the original value so other key will be preserved |
@@ -426,20 +426,20 @@ discard block |
||
426 | 426 | $args['temp_value'] = $value; |
427 | 427 | $value[ $other_key ] = reset( $other_vals ); |
428 | 428 | } |
429 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
430 | - $value = $other_vals; |
|
431 | - } |
|
432 | - } |
|
433 | - } |
|
429 | + } else if ( $field->options[ $other_key ] == $value ) { |
|
430 | + $value = $other_vals; |
|
431 | + } |
|
432 | + } |
|
433 | + } |
|
434 | 434 | |
435 | 435 | public static function enqueue_scripts( $params ) { |
436 | 436 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmFormsController::enqueue_scripts' ); |
437 | 437 | return FrmFormsController::enqueue_scripts( $params ); |
438 | 438 | } |
439 | 439 | |
440 | - // Add submitted values to a string for spam checking |
|
440 | + // Add submitted values to a string for spam checking |
|
441 | 441 | public static function entry_array_to_string( $values ) { |
442 | - $content = ''; |
|
442 | + $content = ''; |
|
443 | 443 | foreach ( $values['item_meta'] as $val ) { |
444 | 444 | if ( $content != '' ) { |
445 | 445 | $content .= "\n\n"; |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | |
448 | 448 | if ( is_array($val) ) { |
449 | 449 | $val = FrmAppHelper::array_flatten( $val ); |
450 | - $val = implode(',', $val); |
|
450 | + $val = implode(',', $val); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $content .= $val; |
454 | 454 | } |
455 | 455 | |
456 | 456 | return $content; |
457 | - } |
|
457 | + } |
|
458 | 458 | |
459 | 459 | public static function fill_entry_values( $atts, $f, array &$values ) { |
460 | 460 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryFormat::fill_entry_values' ); |
@@ -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 | |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | global $frm_vars; |
10 | 10 | $values = array(); |
11 | 11 | foreach ( array( 'name' => '', 'description' => '', 'item_key' => '' ) as $var => $default ) { |
12 | - $values[ $var ] = FrmAppHelper::get_post_param( $var, $default ); |
|
12 | + $values[$var] = FrmAppHelper::get_post_param( $var, $default ); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | $values['fields'] = array(); |
16 | - if ( empty($fields) ) { |
|
17 | - return apply_filters('frm_setup_new_entry', $values); |
|
16 | + if ( empty( $fields ) ) { |
|
17 | + return apply_filters( 'frm_setup_new_entry', $values ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | foreach ( (array) $fields as $field ) { |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'default_value' => $field->default_value, |
27 | 27 | 'name' => $field->name, |
28 | 28 | 'description' => $field->description, |
29 | - 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), |
|
29 | + 'type' => apply_filters( 'frm_field_type', $field->type, $field, $new_value ), |
|
30 | 30 | 'options' => $field->options, |
31 | 31 | 'required' => $field->required, |
32 | 32 | 'field_key' => $field->field_key, |
@@ -35,43 +35,43 @@ discard block |
||
35 | 35 | 'parent_form_id' => isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id, |
36 | 36 | ); |
37 | 37 | |
38 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
38 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
39 | 39 | $opt_defaults['required_indicator'] = ''; |
40 | 40 | $opt_defaults['original_type'] = $field->type; |
41 | 41 | |
42 | 42 | foreach ( $opt_defaults as $opt => $default_opt ) { |
43 | - $field_array[ $opt ] = ( isset( $field->field_options[ $opt ] ) && $field->field_options[ $opt ] != '' ) ? $field->field_options[ $opt ] : $default_opt; |
|
44 | - unset($opt, $default_opt); |
|
43 | + $field_array[$opt] = ( isset( $field->field_options[$opt] ) && $field->field_options[$opt] != '' ) ? $field->field_options[$opt] : $default_opt; |
|
44 | + unset( $opt, $default_opt ); |
|
45 | 45 | } |
46 | 46 | |
47 | - unset($opt_defaults); |
|
47 | + unset( $opt_defaults ); |
|
48 | 48 | |
49 | 49 | if ( $field_array['custom_html'] == '' ) { |
50 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type); |
|
50 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $field->type ); |
|
51 | 51 | } |
52 | 52 | |
53 | - $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field); |
|
53 | + $field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field ); |
|
54 | 54 | $field_array = array_merge( $field->field_options, $field_array ); |
55 | 55 | |
56 | 56 | $values['fields'][] = $field_array; |
57 | 57 | |
58 | - if ( ! $form || ! isset($form->id) ) { |
|
59 | - $form = FrmForm::getOne($field->form_id); |
|
58 | + if ( ! $form || ! isset( $form->id ) ) { |
|
59 | + $form = FrmForm::getOne( $field->form_id ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | - $form->options = maybe_unserialize($form->options); |
|
64 | - if ( is_array($form->options) ) { |
|
63 | + $form->options = maybe_unserialize( $form->options ); |
|
64 | + if ( is_array( $form->options ) ) { |
|
65 | 65 | foreach ( $form->options as $opt => $value ) { |
66 | - $values[ $opt ] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | - unset($opt, $value); |
|
66 | + $values[$opt] = FrmAppHelper::get_post_param( $opt, $value ); |
|
67 | + unset( $opt, $value ); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | $form_defaults = FrmFormsHelper::get_default_opts(); |
72 | 72 | |
73 | 73 | $frm_settings = FrmAppHelper::get_settings(); |
74 | - $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
74 | + $form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
75 | 75 | |
76 | 76 | $values = array_merge( $form_defaults, $values ); |
77 | 77 | |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | $return_array = FrmField::is_field_with_multiple_values( $field ); |
94 | 94 | |
95 | 95 | // Do any shortcodes in default value and allow customization of default value |
96 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array); |
|
96 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true, $return_array ); |
|
97 | 97 | // Calls FrmProFieldsHelper::get_default_value |
98 | 98 | |
99 | 99 | $new_value = $field->default_value; |
100 | 100 | |
101 | - if ( ! $reset && $_POST && isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
101 | + if ( ! $reset && $_POST && isset( $_POST['item_meta'][$field->id] ) ) { |
|
102 | 102 | // If value was posted, get it |
103 | 103 | |
104 | - $new_value = stripslashes_deep( $_POST['item_meta'][ $field->id ] ); |
|
104 | + $new_value = stripslashes_deep( $_POST['item_meta'][$field->id] ); |
|
105 | 105 | |
106 | 106 | } else if ( FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
107 | 107 | // If clear on focus is selected, the value should be blank (unless it was posted, of course) |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | if ( ! is_array( $new_value ) ) { |
113 | - $new_value = str_replace('"', '"', $new_value); |
|
113 | + $new_value = str_replace( '"', '"', $new_value ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $new_value; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' ); |
121 | 121 | $values['form_id'] = $record->form_id; |
122 | 122 | $values['is_draft'] = $record->is_draft; |
123 | - return apply_filters('frm_setup_edit_entry_vars', $values, $record); |
|
123 | + return apply_filters( 'frm_setup_edit_entry_vars', $values, $record ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | public static function get_admin_params( $form = null ) { |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | public static function replace_default_message( $message, $atts ) { |
152 | - if ( strpos($message, '[default-message') === false && |
|
153 | - strpos($message, '[default_message') === false && |
|
152 | + if ( strpos( $message, '[default-message' ) === false && |
|
153 | + strpos( $message, '[default_message' ) === false && |
|
154 | 154 | ! empty( $message ) ) { |
155 | 155 | return $message; |
156 | 156 | } |
157 | 157 | |
158 | - if ( empty($message) ) { |
|
158 | + if ( empty( $message ) ) { |
|
159 | 159 | $message = '[default-message]'; |
160 | 160 | } |
161 | 161 | |
162 | - preg_match_all("/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER); |
|
162 | + preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
|
163 | 163 | |
164 | 164 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
165 | - $add_atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
165 | + $add_atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
166 | 166 | if ( $add_atts ) { |
167 | - $this_atts = array_merge($atts, $add_atts); |
|
167 | + $this_atts = array_merge( $atts, $add_atts ); |
|
168 | 168 | } else { |
169 | 169 | $this_atts = $atts; |
170 | 170 | } |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | $default = FrmEntryFormat::show_entry( $this_atts ); |
173 | 173 | |
174 | 174 | // Add the default message |
175 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
175 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return $message; |
179 | 179 | } |
180 | 180 | |
181 | 181 | public static function prepare_display_value( $entry, $field, $atts ) { |
182 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
182 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
183 | 183 | if ( FrmAppHelper::pro_is_installed() ) { |
184 | 184 | FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( $field->form_id == $entry->form_id || empty($atts['embedded_field_id']) ) { |
|
188 | - return self::display_value($field_value, $field, $atts); |
|
187 | + if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) { |
|
188 | + return self::display_value( $field_value, $field, $atts ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // this is an embeded form |
192 | 192 | $val = ''; |
193 | 193 | |
194 | - if ( strpos($atts['embedded_field_id'], 'form') === 0 ) { |
|
194 | + if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) { |
|
195 | 195 | //this is a repeating section |
196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
197 | 197 | } else { |
198 | 198 | // get all values for this field |
199 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
199 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
200 | 200 | |
201 | 201 | if ( $child_values ) { |
202 | 202 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $field_value = array(); |
207 | 207 | |
208 | - if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
208 | + if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) { |
|
209 | 209 | return $val; |
210 | 210 | } |
211 | 211 | |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | $atts['post_id'] = $child_entry->post_id; |
215 | 215 | |
216 | 216 | // get the value for this field -- check for post values as well |
217 | - $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field); |
|
217 | + $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field ); |
|
218 | 218 | |
219 | 219 | if ( $entry_val ) { |
220 | 220 | // foreach entry get display_value |
221 | - $field_value[] = self::display_value($entry_val, $field, $atts); |
|
221 | + $field_value[] = self::display_value( $entry_val, $field, $atts ); |
|
222 | 222 | } |
223 | 223 | |
224 | - unset($child_entry); |
|
224 | + unset( $child_entry ); |
|
225 | 225 | } |
226 | 226 | |
227 | - $val = implode(', ', (array) $field_value ); |
|
227 | + $val = implode( ', ', (array) $field_value ); |
|
228 | 228 | $val = wp_kses_post( $val ); |
229 | 229 | |
230 | 230 | return $val; |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | ); |
245 | 245 | |
246 | 246 | $atts = wp_parse_args( $atts, $defaults ); |
247 | - $atts = apply_filters('frm_display_value_atts', $atts, $field, $value); |
|
247 | + $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value ); |
|
248 | 248 | |
249 | - if ( ! isset($field->field_options['post_field']) ) { |
|
249 | + if ( ! isset( $field->field_options['post_field'] ) ) { |
|
250 | 250 | $field->field_options['post_field'] = ''; |
251 | 251 | } |
252 | 252 | |
253 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
253 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
254 | 254 | $field->field_options['custom_field'] = ''; |
255 | 255 | } |
256 | 256 | |
257 | 257 | if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) { |
258 | 258 | $atts['pre_truncate'] = $atts['truncate']; |
259 | 259 | $atts['truncate'] = true; |
260 | - $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0; |
|
260 | + $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0; |
|
261 | 261 | |
262 | - $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts); |
|
262 | + $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts ); |
|
263 | 263 | $atts['truncate'] = $atts['pre_truncate']; |
264 | 264 | } |
265 | 265 | |
@@ -267,38 +267,38 @@ discard block |
||
267 | 267 | return $value; |
268 | 268 | } |
269 | 269 | |
270 | - $value = apply_filters('frm_display_value_custom', maybe_unserialize($value), $field, $atts); |
|
270 | + $value = apply_filters( 'frm_display_value_custom', maybe_unserialize( $value ), $field, $atts ); |
|
271 | 271 | |
272 | 272 | $new_value = ''; |
273 | 273 | |
274 | - if ( is_array($value) && $atts['type'] != 'file' ) { |
|
274 | + if ( is_array( $value ) && $atts['type'] != 'file' ) { |
|
275 | 275 | foreach ( $value as $val ) { |
276 | - if ( is_array($val) ) { |
|
276 | + if ( is_array( $val ) ) { |
|
277 | 277 | //TODO: add options for display (li or ,) |
278 | - $new_value .= implode($atts['sep'], $val); |
|
278 | + $new_value .= implode( $atts['sep'], $val ); |
|
279 | 279 | if ( $atts['type'] != 'data' ) { |
280 | 280 | $new_value .= '<br/>'; |
281 | 281 | } |
282 | 282 | } |
283 | - unset($val); |
|
283 | + unset( $val ); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
287 | - if ( ! empty($new_value) ) { |
|
287 | + if ( ! empty( $new_value ) ) { |
|
288 | 288 | $value = $new_value; |
289 | - } else if ( is_array($value) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | - $value = implode($atts['sep'], $value); |
|
289 | + } else if ( is_array( $value ) && $atts['type'] != 'file' && ! $atts['return_array'] ) { |
|
290 | + $value = implode( $atts['sep'], $value ); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if ( $atts['truncate'] && $atts['type'] != 'image' ) { |
294 | - $value = FrmAppHelper::truncate($value, 50); |
|
294 | + $value = FrmAppHelper::truncate( $value, 50 ); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if ( ! $atts['keepjs'] && ! is_array( $value ) ) { |
298 | 298 | $value = wp_kses_post( $value ); |
299 | 299 | } |
300 | 300 | |
301 | - return apply_filters('frm_display_value', $value, $field, $atts); |
|
301 | + return apply_filters( 'frm_display_value', $value, $field, $atts ); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | public static function set_posted_value( $field, $value, $args ) { |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | if ( isset( $args['other'] ) && $args['other'] ) { |
307 | 307 | $value = $args['temp_value']; |
308 | 308 | } |
309 | - if ( empty($args['parent_field_id']) ) { |
|
310 | - $_POST['item_meta'][ $field->id ] = $value; |
|
309 | + if ( empty( $args['parent_field_id'] ) ) { |
|
310 | + $_POST['item_meta'][$field->id] = $value; |
|
311 | 311 | } else { |
312 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
312 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | |
316 | 316 | public static function get_posted_value( $field, &$value, $args ) { |
317 | 317 | $field_id = is_object( $field ) ? $field->id : $field; |
318 | 318 | |
319 | - if ( empty($args['parent_field_id']) ) { |
|
320 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : ''; |
|
319 | + if ( empty( $args['parent_field_id'] ) ) { |
|
320 | + $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : ''; |
|
321 | 321 | } else { |
322 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : ''; |
|
322 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : ''; |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | self::set_other_repeating_vals( $field, $value, $args ); |
343 | 343 | |
344 | 344 | // Check if there are any posted "Other" values |
345 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
345 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
346 | 346 | |
347 | 347 | // Save original value |
348 | 348 | $args['temp_value'] = $value; |
349 | 349 | $args['other'] = true; |
350 | - $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] ); |
|
350 | + $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] ); |
|
351 | 351 | |
352 | 352 | // Set the validation value now |
353 | 353 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | // Check if there are any other posted "other" values for this field |
372 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
372 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
373 | 373 | // Save original value |
374 | 374 | $args['temp_value'] = $value; |
375 | 375 | $args['other'] = true; |
376 | 376 | |
377 | - $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ]; |
|
377 | + $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id]; |
|
378 | 378 | |
379 | 379 | // Set the validation value now |
380 | 380 | self::set_other_validation_val( $value, $other_vals, $field, $args ); |
@@ -406,27 +406,27 @@ discard block |
||
406 | 406 | } |
407 | 407 | } else { |
408 | 408 | // Radio and dropdowns |
409 | - $other_key = array_filter( array_keys($field->options), 'is_string'); |
|
409 | + $other_key = array_filter( array_keys( $field->options ), 'is_string' ); |
|
410 | 410 | $other_key = reset( $other_key ); |
411 | 411 | |
412 | 412 | // Multi-select dropdown |
413 | 413 | if ( is_array( $value ) ) { |
414 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
414 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
415 | 415 | |
416 | 416 | if ( $o_key !== false ) { |
417 | 417 | // Modify the original value so other key will be preserved |
418 | - $value[ $other_key ] = $value[ $o_key ]; |
|
418 | + $value[$other_key] = $value[$o_key]; |
|
419 | 419 | |
420 | 420 | // By default, the array keys will be numeric for multi-select dropdowns |
421 | 421 | // If going backwards and forwards between pages, the array key will match the other key |
422 | 422 | if ( $o_key != $other_key ) { |
423 | - unset( $value[ $o_key ] ); |
|
423 | + unset( $value[$o_key] ); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $args['temp_value'] = $value; |
427 | - $value[ $other_key ] = reset( $other_vals ); |
|
427 | + $value[$other_key] = reset( $other_vals ); |
|
428 | 428 | } |
429 | - } else if ( $field->options[ $other_key ] == $value ) { |
|
429 | + } else if ( $field->options[$other_key] == $value ) { |
|
430 | 430 | $value = $other_vals; |
431 | 431 | } |
432 | 432 | } |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | $content .= "\n\n"; |
446 | 446 | } |
447 | 447 | |
448 | - if ( is_array($val) ) { |
|
448 | + if ( is_array( $val ) ) { |
|
449 | 449 | $val = FrmAppHelper::array_flatten( $val ); |
450 | - $val = implode(',', $val); |
|
450 | + $val = implode( ',', $val ); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | $content .= $val; |
@@ -492,6 +492,6 @@ discard block |
||
492 | 492 | } |
493 | 493 | |
494 | 494 | public static function entries_dropdown() { |
495 | - _deprecated_function( __FUNCTION__, '1.07.09'); |
|
495 | + _deprecated_function( __FUNCTION__, '1.07.09' ); |
|
496 | 496 | } |
497 | 497 | } |
@@ -6,46 +6,46 @@ discard block |
||
6 | 6 | protected $field; |
7 | 7 | |
8 | 8 | public function prepare_items() { |
9 | - global $wpdb, $per_page; |
|
9 | + global $wpdb, $per_page; |
|
10 | 10 | |
11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
12 | 12 | |
13 | - $form_id = $this->params['form']; |
|
14 | - if ( ! $form_id ) { |
|
15 | - $this->items = array(); |
|
16 | - $this->set_pagination_args( array( |
|
17 | - 'total_items' => 0, |
|
13 | + $form_id = $this->params['form']; |
|
14 | + if ( ! $form_id ) { |
|
15 | + $this->items = array(); |
|
16 | + $this->set_pagination_args( array( |
|
17 | + 'total_items' => 0, |
|
18 | 18 | 'per_page' => $per_page, |
19 | - ) ); |
|
20 | - return; |
|
21 | - } |
|
19 | + ) ); |
|
20 | + return; |
|
21 | + } |
|
22 | 22 | |
23 | 23 | $default_orderby = 'id'; |
24 | 24 | $default_order = 'DESC'; |
25 | 25 | |
26 | - $s_query = array( 'it.form_id' => $form_id ); |
|
26 | + $s_query = array( 'it.form_id' => $form_id ); |
|
27 | 27 | |
28 | 28 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
29 | 29 | |
30 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | - } |
|
30 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | + } |
|
34 | 34 | |
35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
43 | 43 | |
44 | - $page = $this->get_pagenum(); |
|
44 | + $page = $this->get_pagenum(); |
|
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | - $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
47 | + $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -54,19 +54,19 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function no_items() { |
57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | - if ( ! empty($s) ) { |
|
59 | - _e( 'No Entries Found', 'formidable' ); |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - $form_id = $form = $this->params['form']; |
|
64 | - if ( $form_id ) { |
|
65 | - $form = FrmForm::getOne($form_id); |
|
66 | - } |
|
67 | - $colspan = $this->get_column_count(); |
|
68 | - |
|
69 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | + if ( ! empty($s) ) { |
|
59 | + _e( 'No Entries Found', 'formidable' ); |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + $form_id = $form = $this->params['form']; |
|
64 | + if ( $form_id ) { |
|
65 | + $form = FrmForm::getOne($form_id); |
|
66 | + } |
|
67 | + $colspan = $this->get_column_count(); |
|
68 | + |
|
69 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function search_box( $text, $input_id ) { |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Gets the name of the primary column in the Entries screen |
|
78 | - * |
|
79 | - * @since 2.0.14 |
|
80 | - * |
|
81 | - * @return string $primary_column |
|
82 | - */ |
|
77 | + * Gets the name of the primary column in the Entries screen |
|
78 | + * |
|
79 | + * @since 2.0.14 |
|
80 | + * |
|
81 | + * @return string $primary_column |
|
82 | + */ |
|
83 | 83 | protected function get_primary_column_name() { |
84 | 84 | $columns = get_column_headers( $this->screen ); |
85 | 85 | $hidden = get_hidden_columns( $this->screen ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
106 | - $action_links = $this->row_actions( $actions ); |
|
106 | + $action_links = $this->row_actions( $actions ); |
|
107 | 107 | |
108 | 108 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
109 | 109 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | 113 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
114 | - $action_col = false; |
|
114 | + $action_col = false; |
|
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | 117 | $class = $column_name .' column-'. $column_name; |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | if ( in_array( $column_name, $hidden ) ) { |
124 | 124 | $class .= ' frm_hidden'; |
125 | 125 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
126 | - $action_col = $column_name; |
|
127 | - } |
|
126 | + $action_col = $column_name; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | 130 | unset($class); |
131 | 131 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
132 | 132 | |
133 | - $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
133 | + $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
134 | 134 | $this->column_name = $col_name; |
135 | 135 | |
136 | 136 | switch ( $col_name ) { |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | case 'ip': |
141 | 141 | case 'id': |
142 | 142 | case 'item_key': |
143 | - $val = $item->{$col_name}; |
|
144 | - break; |
|
143 | + $val = $item->{$col_name}; |
|
144 | + break; |
|
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | - break; |
|
147 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | + break; |
|
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | - break; |
|
155 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | + break; |
|
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | - break; |
|
158 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | + break; |
|
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | - break; |
|
161 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | + break; |
|
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
165 | - $val = $user->user_login; |
|
166 | - break; |
|
164 | + $user = get_userdata($item->user_id); |
|
165 | + $val = $user->user_login; |
|
166 | + break; |
|
167 | 167 | default: |
168 | 168 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
169 | 169 | if ( $val === false ) { |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | if ( isset( $val ) ) { |
176 | - $r .= "<td $attributes>"; |
|
176 | + $r .= "<td $attributes>"; |
|
177 | 177 | if ( $column_name == $action_col ) { |
178 | 178 | $edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id; |
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | - $r .= $action_links; |
|
180 | + $r .= $action_links; |
|
181 | 181 | } else { |
182 | - $r .= $val; |
|
183 | - } |
|
184 | - $r .= '</td>'; |
|
182 | + $r .= $val; |
|
183 | + } |
|
184 | + $r .= '</td>'; |
|
185 | 185 | } |
186 | 186 | unset($val); |
187 | 187 | } |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | return $r; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * @param string $view_link |
|
195 | - */ |
|
196 | - private function get_actions( &$actions, $item, $view_link ) { |
|
193 | + /** |
|
194 | + * @param string $view_link |
|
195 | + */ |
|
196 | + private function get_actions( &$actions, $item, $view_link ) { |
|
197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>'; |
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
200 | - $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
199 | + if ( current_user_can('frm_delete_entries') ) { |
|
200 | + $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | - } |
|
204 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | + } |
|
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
208 | 208 | $col_name = $this->column_name; |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | |
26 | 26 | $s_query = array( 'it.form_id' => $form_id ); |
27 | 27 | |
28 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
28 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
29 | 29 | |
30 | 30 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
31 | 31 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | 39 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | $page = $this->get_pagenum(); |
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | - $this->items = FrmEntry::getAll($s_query, $order, ' LIMIT '. $start .','. $per_page, true, false); |
|
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
47 | + $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
|
48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | |
56 | 56 | public function no_items() { |
57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
58 | - if ( ! empty($s) ) { |
|
58 | + if ( ! empty( $s ) ) { |
|
59 | 59 | _e( 'No Entries Found', 'formidable' ); |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $form_id = $form = $this->params['form']; |
64 | 64 | if ( $form_id ) { |
65 | - $form = FrmForm::getOne($form_id); |
|
65 | + $form = FrmForm::getOne( $form_id ); |
|
66 | 66 | } |
67 | 67 | $colspan = $this->get_column_count(); |
68 | 68 | |
69 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/no_entries.php'); |
|
69 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public function search_box( $text, $input_id ) { |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | public function single_row( $item, $style = '' ) { |
100 | 100 | // Set up the hover actions for this user |
101 | 101 | $actions = array(); |
102 | - $view_link = '?page=formidable-entries&frm_action=show&id='. $item->id; |
|
102 | + $view_link = '?page=formidable-entries&frm_action=show&id=' . $item->id; |
|
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | |
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
113 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
114 | 114 | $action_col = false; |
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | - $class = $column_name .' column-'. $column_name; |
|
117 | + $class = $column_name . ' column-' . $column_name; |
|
118 | 118 | |
119 | 119 | if ( $column_name === $primary ) { |
120 | 120 | $class .= ' column-primary'; |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | - unset($class); |
|
131 | - $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
130 | + unset( $class ); |
|
131 | + $attributes .= ' data-colname="' . $column_display_name . '"'; |
|
132 | 132 | |
133 | - $col_name = preg_replace('/^('. $this->params['form'] .'_)/', '', $column_name); |
|
133 | + $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
|
134 | 134 | $this->column_name = $col_name; |
135 | 135 | |
136 | 136 | switch ( $col_name ) { |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | break; |
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
147 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
148 | 148 | break; |
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
155 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
156 | 156 | break; |
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
158 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
159 | 159 | break; |
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
161 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
162 | 162 | break; |
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
164 | + $user = get_userdata( $item->user_id ); |
|
165 | 165 | $val = $user->user_login; |
166 | 166 | break; |
167 | 167 | default: |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | if ( isset( $val ) ) { |
176 | 176 | $r .= "<td $attributes>"; |
177 | 177 | if ( $column_name == $action_col ) { |
178 | - $edit_link = '?page=formidable-entries&frm_action=edit&id='. $item->id; |
|
178 | + $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
|
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | 180 | $r .= $action_links; |
181 | 181 | } else { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | $r .= '</td>'; |
185 | 185 | } |
186 | - unset($val); |
|
186 | + unset( $val ); |
|
187 | 187 | } |
188 | 188 | $r .= '</tr>'; |
189 | 189 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * @param string $view_link |
195 | 195 | */ |
196 | 196 | private function get_actions( &$actions, $item, $view_link ) { |
197 | - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">'. __( 'View', 'formidable' ) .'</a>'; |
|
197 | + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
|
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
200 | - $delete_link = '?page=formidable-entries&frm_action=destroy&id='. $item->id .'&form='. $this->params['form']; |
|
199 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
200 | + $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
|
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | 202 | } |
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
204 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
@@ -1,67 +1,67 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStylesHelper { |
3 | 3 | |
4 | - public static function jquery_themes() { |
|
5 | - $themes = array( |
|
6 | - 'ui-lightness' => 'UI Lightness', |
|
7 | - 'ui-darkness' => 'UI Darkness', |
|
8 | - 'smoothness' => 'Smoothness', |
|
9 | - 'start' => 'Start', |
|
10 | - 'redmond' => 'Redmond', |
|
11 | - 'sunny' => 'Sunny', |
|
12 | - 'overcast' => 'Overcast', |
|
13 | - 'le-frog' => 'Le Frog', |
|
14 | - 'flick' => 'Flick', |
|
4 | + public static function jquery_themes() { |
|
5 | + $themes = array( |
|
6 | + 'ui-lightness' => 'UI Lightness', |
|
7 | + 'ui-darkness' => 'UI Darkness', |
|
8 | + 'smoothness' => 'Smoothness', |
|
9 | + 'start' => 'Start', |
|
10 | + 'redmond' => 'Redmond', |
|
11 | + 'sunny' => 'Sunny', |
|
12 | + 'overcast' => 'Overcast', |
|
13 | + 'le-frog' => 'Le Frog', |
|
14 | + 'flick' => 'Flick', |
|
15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
16 | - 'eggplant' => 'Eggplant', |
|
17 | - 'dark-hive' => 'Dark Hive', |
|
18 | - 'cupertino' => 'Cupertino', |
|
19 | - 'south-street' => 'South Street', |
|
20 | - 'blitzer' => 'Blitzer', |
|
21 | - 'humanity' => 'Humanity', |
|
22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
23 | - 'excite-bike' => 'Excite Bike', |
|
24 | - 'vader' => 'Vader', |
|
25 | - 'dot-luv' => 'Dot Luv', |
|
26 | - 'mint-choc' => 'Mint Choc', |
|
27 | - 'black-tie' => 'Black Tie', |
|
28 | - 'trontastic' => 'Trontastic', |
|
29 | - 'swanky-purse' => 'Swanky Purse', |
|
30 | - ); |
|
31 | - |
|
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | - return $themes; |
|
34 | - } |
|
16 | + 'eggplant' => 'Eggplant', |
|
17 | + 'dark-hive' => 'Dark Hive', |
|
18 | + 'cupertino' => 'Cupertino', |
|
19 | + 'south-street' => 'South Street', |
|
20 | + 'blitzer' => 'Blitzer', |
|
21 | + 'humanity' => 'Humanity', |
|
22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
23 | + 'excite-bike' => 'Excite Bike', |
|
24 | + 'vader' => 'Vader', |
|
25 | + 'dot-luv' => 'Dot Luv', |
|
26 | + 'mint-choc' => 'Mint Choc', |
|
27 | + 'black-tie' => 'Black Tie', |
|
28 | + 'trontastic' => 'Trontastic', |
|
29 | + 'swanky-purse' => 'Swanky Purse', |
|
30 | + ); |
|
31 | + |
|
32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | + return $themes; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public static function jquery_css_url( $theme_css ) { |
37 | - if ( $theme_css == -1 ) { |
|
38 | - return; |
|
39 | - } |
|
40 | - |
|
41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | - $css_file = $theme_css; |
|
45 | - } else { |
|
46 | - $uploads = self::get_upload_base(); |
|
47 | - $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css'; |
|
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
50 | - } else { |
|
51 | - $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css'; |
|
52 | - } |
|
53 | - } |
|
54 | - |
|
55 | - return $css_file; |
|
56 | - } |
|
57 | - |
|
58 | - public static function enqueue_jquery_css() { |
|
37 | + if ( $theme_css == -1 ) { |
|
38 | + return; |
|
39 | + } |
|
40 | + |
|
41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | + $css_file = $theme_css; |
|
45 | + } else { |
|
46 | + $uploads = self::get_upload_base(); |
|
47 | + $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css'; |
|
48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
50 | + } else { |
|
51 | + $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css'; |
|
52 | + } |
|
53 | + } |
|
54 | + |
|
55 | + return $css_file; |
|
56 | + } |
|
57 | + |
|
58 | + public static function enqueue_jquery_css() { |
|
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | - if ( $theme_css != -1 ) { |
|
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | - } |
|
64 | - } |
|
61 | + if ( $theme_css != -1 ) { |
|
62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function get_form_for_page() { |
67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | return $form_id; |
78 | 78 | } |
79 | 79 | |
80 | - public static function get_upload_base() { |
|
81 | - $uploads = wp_upload_dir(); |
|
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | - } |
|
80 | + public static function get_upload_base() { |
|
81 | + $uploads = wp_upload_dir(); |
|
82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | + } |
|
85 | 85 | |
86 | - return $uploads; |
|
87 | - } |
|
86 | + return $uploads; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | public static function style_menu( $active = '' ) { |
90 | 90 | ?> |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
95 | 95 | </h2> |
96 | 96 | <?php |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - public static function minus_icons() { |
|
100 | - return array( |
|
99 | + public static function minus_icons() { |
|
100 | + return array( |
|
101 | 101 | 0 => array( '-' => '62e', '+' => '62f' ), |
102 | 102 | 1 => array( '-' => '600', '+' => '602' ), |
103 | 103 | 2 => array( '-' => '604', '+' => '603' ), |
104 | 104 | 3 => array( '-' => '633', '+' => '632' ), |
105 | 105 | 4 => array( '-' => '613', '+' => '60f' ), |
106 | - ); |
|
107 | - } |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - public static function arrow_icons() { |
|
110 | - $minus_icons = self::minus_icons(); |
|
109 | + public static function arrow_icons() { |
|
110 | + $minus_icons = self::minus_icons(); |
|
111 | 111 | |
112 | - return array( |
|
112 | + return array( |
|
113 | 113 | 6 => array( '-' => '62d', '+' => '62a' ), |
114 | 114 | 0 => array( '-' => '60d', '+' => '609' ), |
115 | 115 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | 3 => array( '-' => '62b', '+' => '628' ), |
118 | 118 | 4 => array( '-' => '62c', '+' => '629' ), |
119 | 119 | 5 => array( '-' => '635', '+' => '634' ), |
120 | - 'p0' => $minus_icons[0], |
|
121 | - 'p1' => $minus_icons[1], |
|
122 | - 'p2' => $minus_icons[2], |
|
123 | - 'p3' => $minus_icons[3], |
|
124 | - 'p4' => $minus_icons[4], |
|
125 | - ); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @since 2.0 |
|
130 | - * @return The class for this icon |
|
131 | - */ |
|
120 | + 'p0' => $minus_icons[0], |
|
121 | + 'p1' => $minus_icons[1], |
|
122 | + 'p2' => $minus_icons[2], |
|
123 | + 'p3' => $minus_icons[3], |
|
124 | + 'p4' => $minus_icons[4], |
|
125 | + ); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @since 2.0 |
|
130 | + * @return The class for this icon |
|
131 | + */ |
|
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | - //frm_arrowup6_icon |
|
133 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | + //frm_arrowup6_icon |
|
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | 136 | $class = 'frm_arrow' . $arrow[ $icon ]; |
137 | - } else { |
|
138 | - //frm_minus1_icon |
|
139 | - $key = str_replace('p', '', $key); |
|
137 | + } else { |
|
138 | + //frm_minus1_icon |
|
139 | + $key = str_replace('p', '', $key); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | 141 | $class = 'frm_' . $plus[ $icon ]; |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - if ( $key ) { |
|
145 | - $class .= $key; |
|
146 | - } |
|
147 | - $class .= '_icon'; |
|
144 | + if ( $key ) { |
|
145 | + $class .= $key; |
|
146 | + } |
|
147 | + $class .= '_icon'; |
|
148 | 148 | |
149 | - return $class; |
|
150 | - } |
|
149 | + return $class; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
153 | 153 | $function_name = $type . '_icons'; |
154 | 154 | $icons = self::$function_name(); |
155 | 155 | unset( $function_name ); |
156 | 156 | |
157 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
157 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
158 | 158 | ?> |
159 | 159 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | </ul> |
188 | 188 | </div> |
189 | 189 | <?php |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
194 | - |
|
195 | - if ( strlen($hex) == 3 ) { |
|
196 | - $r = hexdec( substr($hex,0,1).substr($hex,0,1) ); |
|
197 | - $g = hexdec( substr($hex,1,1).substr($hex,1,1) ); |
|
198 | - $b = hexdec( substr($hex,2,1).substr($hex,2,1) ); |
|
199 | - } else { |
|
200 | - $r = hexdec( substr($hex,0,2) ); |
|
201 | - $g = hexdec( substr($hex,2,2) ); |
|
202 | - $b = hexdec( substr($hex,4,2) ); |
|
203 | - } |
|
193 | + $hex = str_replace('#', '', $hex); |
|
194 | + |
|
195 | + if ( strlen($hex) == 3 ) { |
|
196 | + $r = hexdec( substr($hex,0,1).substr($hex,0,1) ); |
|
197 | + $g = hexdec( substr($hex,1,1).substr($hex,1,1) ); |
|
198 | + $b = hexdec( substr($hex,2,1).substr($hex,2,1) ); |
|
199 | + } else { |
|
200 | + $r = hexdec( substr($hex,0,2) ); |
|
201 | + $g = hexdec( substr($hex,2,2) ); |
|
202 | + $b = hexdec( substr($hex,4,2) ); |
|
203 | + } |
|
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | - //return $rgb; // returns an array with the rgb values |
|
207 | - } |
|
205 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | + //return $rgb; // returns an array with the rgb values |
|
207 | + } |
|
208 | 208 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | 'swanky-purse' => 'Swanky Purse', |
30 | 30 | ); |
31 | 31 | |
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
33 | 33 | return $themes; |
34 | 34 | } |
35 | 35 | |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
44 | 44 | $css_file = $theme_css; |
45 | 45 | } else { |
46 | 46 | $uploads = self::get_upload_base(); |
47 | - $file_path = '/formidable/css/'. $theme_css . '/jquery-ui.css'; |
|
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
47 | + $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
|
48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
50 | 50 | } else { |
51 | - $css_file = FrmAppHelper::jquery_ui_base_url() .'/themes/'. $theme_css . '/jquery-ui.min.css'; |
|
51 | + $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | 61 | if ( $theme_css != -1 ) { |
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | public static function get_upload_base() { |
81 | 81 | $uploads = wp_upload_dir(); |
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | <h2 class="nav-tab-wrapper"> |
92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
95 | 95 | </h2> |
96 | 96 | <?php |
97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @return The class for this icon |
131 | 131 | */ |
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
134 | 134 | //frm_arrowup6_icon |
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
137 | 137 | } else { |
138 | 138 | //frm_minus1_icon |
139 | - $key = str_replace('p', '', $key); |
|
139 | + $key = str_replace( 'p', '', $key ); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | - $class = 'frm_' . $plus[ $icon ]; |
|
141 | + $class = 'frm_' . $plus[$icon]; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | if ( $key ) { |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | |
157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
158 | 158 | ?> |
159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
162 | - <?php echo ''. $icon['+'] .'; '. $icon['-'] .';'; ?> |
|
161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
162 | + <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
|
163 | 163 | </option> |
164 | 164 | <?php } ?> |
165 | 165 | </select> |
166 | 166 | |
167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
171 | 171 | <b class="caret"></b> |
172 | 172 | </button> |
173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace( '#', '', $hex ); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
196 | - $r = hexdec( substr($hex,0,1).substr($hex,0,1) ); |
|
197 | - $g = hexdec( substr($hex,1,1).substr($hex,1,1) ); |
|
198 | - $b = hexdec( substr($hex,2,1).substr($hex,2,1) ); |
|
195 | + if ( strlen( $hex ) == 3 ) { |
|
196 | + $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
|
197 | + $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
|
198 | + $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
|
199 | 199 | } else { |
200 | - $r = hexdec( substr($hex,0,2) ); |
|
201 | - $g = hexdec( substr($hex,2,2) ); |
|
202 | - $b = hexdec( substr($hex,4,2) ); |
|
200 | + $r = hexdec( substr( $hex, 0, 2 ) ); |
|
201 | + $g = hexdec( substr( $hex, 2, 2 ) ); |
|
202 | + $b = hexdec( substr( $hex, 4, 2 ) ); |
|
203 | 203 | } |
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
206 | 206 | //return $rgb; // returns an array with the rgb values |
207 | 207 | } |
208 | 208 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | echo "\n" . $padding; |
12 | 12 | $tag = ( is_numeric( $ok ) ? 'key:' : '' ) . $ok; |
13 | 13 | echo '<' . $tag . '>'; |
14 | - self::get_xml_values( $ov, $padding .' ' ); |
|
14 | + self::get_xml_values( $ov, $padding . ' ' ); |
|
15 | 15 | if ( is_array( $ov ) ) { |
16 | 16 | echo "\n" . $padding; |
17 | 17 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | 'terms' => array(), |
37 | 37 | ); |
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset( $defaults ); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
42 | + define( 'WP_IMPORTING', true ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
57 | 57 | } |
58 | 58 | |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | 69 | // grab cats, tags, and terms, or forms or posts |
70 | - if ( isset($xml->{$item_type} ) ) { |
|
70 | + if ( isset( $xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | 79 | return $return; |
80 | 80 | } |
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | 83 | foreach ( $terms as $t ) { |
84 | - if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) { |
|
84 | + if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | 'description' => (string) $t->term_description, |
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | 94 | 'slug' => (string) $t->term_slug, |
95 | - )); |
|
95 | + ) ); |
|
96 | 96 | |
97 | 97 | if ( $term && is_array( $term ) ) { |
98 | - $imported['imported']['terms']++; |
|
99 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
98 | + $imported['imported']['terms'] ++; |
|
99 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | unset( $term, $t ); |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | 'default_template' => (int) $item->default_template, |
140 | 140 | 'editable' => (int) $item->editable, |
141 | 141 | 'status' => (string) $item->status, |
142 | - 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
143 | - 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
142 | + 'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0, |
|
143 | + 'created_at' => date( 'Y-m-d H:i:s', strtotime( (string) $item->created_at ) ), |
|
144 | 144 | ); |
145 | 145 | |
146 | - $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
146 | + $form['options'] = FrmAppHelper::maybe_json_decode( $form['options'] ); |
|
147 | 147 | |
148 | 148 | // if template, allow to edit if form keys match, otherwise, creation date must also match |
149 | 149 | $edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] ); |
@@ -151,35 +151,35 @@ discard block |
||
151 | 151 | $edit_query['created_at'] = $form['created_at']; |
152 | 152 | } |
153 | 153 | |
154 | - $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
154 | + $edit_query = apply_filters( 'frm_match_xml_form', $edit_query, $form ); |
|
155 | 155 | |
156 | - $this_form = FrmForm::getAll($edit_query, '', 1); |
|
157 | - unset($edit_query); |
|
156 | + $this_form = FrmForm::getAll( $edit_query, '', 1 ); |
|
157 | + unset( $edit_query ); |
|
158 | 158 | |
159 | 159 | if ( ! empty( $this_form ) ) { |
160 | 160 | $old_id = $form_id = $this_form->id; |
161 | - FrmForm::update($form_id, $form ); |
|
162 | - $imported['updated']['forms']++; |
|
161 | + FrmForm::update( $form_id, $form ); |
|
162 | + $imported['updated']['forms'] ++; |
|
163 | 163 | // Keep track of whether this specific form was updated or not |
164 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
164 | + $imported['form_status'][$form_id] = 'updated'; |
|
165 | 165 | |
166 | 166 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
167 | 167 | $old_fields = array(); |
168 | 168 | foreach ( $form_fields as $f ) { |
169 | - $old_fields[ $f->id ] = $f; |
|
170 | - $old_fields[ $f->field_key ] = $f->id; |
|
171 | - unset($f); |
|
169 | + $old_fields[$f->id] = $f; |
|
170 | + $old_fields[$f->field_key] = $f->id; |
|
171 | + unset( $f ); |
|
172 | 172 | } |
173 | 173 | $form_fields = $old_fields; |
174 | - unset($old_fields); |
|
174 | + unset( $old_fields ); |
|
175 | 175 | } else { |
176 | 176 | $old_id = false; |
177 | 177 | //form does not exist, so create it |
178 | 178 | $form_id = FrmForm::create( $form ); |
179 | 179 | if ( $form_id ) { |
180 | - $imported['imported']['forms']++; |
|
180 | + $imported['imported']['forms'] ++; |
|
181 | 181 | // Keep track of whether this specific form was updated or not |
182 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
182 | + $imported['form_status'][$form_id] = 'imported'; |
|
183 | 183 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
184 | 184 | } |
185 | 185 | } |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | // Delete any fields attached to this form that were not included in the template |
190 | 190 | if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
191 | 191 | foreach ( $form_fields as $field ) { |
192 | - if ( is_object($field) ) { |
|
193 | - FrmField::destroy($field->id); |
|
192 | + if ( is_object( $field ) ) { |
|
193 | + FrmField::destroy( $field->id ); |
|
194 | 194 | } |
195 | - unset($field); |
|
195 | + unset( $field ); |
|
196 | 196 | } |
197 | - unset($form_fields); |
|
197 | + unset( $form_fields ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // Update field ids/keys to new ones |
201 | 201 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
202 | 202 | |
203 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
203 | + $imported['forms'][(int) $item->id] = $form_id; |
|
204 | 204 | |
205 | 205 | // Send pre 2.0 form options through function that creates actions |
206 | 206 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
207 | 207 | |
208 | - unset($form, $item); |
|
208 | + unset( $form, $item ); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $regular_forms = array(); |
225 | 225 | |
226 | 226 | foreach ( $forms as $form ) { |
227 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
227 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
228 | 228 | |
229 | 229 | if ( $parent_form_id ) { |
230 | 230 | $child_forms[] = $form; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
248 | 248 | if ( $parent_form_id ) { |
249 | - $child_forms[ $form_id ] = $parent_form_id; |
|
249 | + $child_forms[$form_id] = $parent_form_id; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
262 | 262 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
263 | 263 | |
264 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
264 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
265 | 265 | // Update all children with this old parent_form_id |
266 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
266 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
267 | 267 | |
268 | 268 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
269 | 269 | } |
@@ -284,51 +284,51 @@ discard block |
||
284 | 284 | 'name' => (string) $field->name, |
285 | 285 | 'description' => (string) $field->description, |
286 | 286 | 'type' => (string) $field->type, |
287 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
287 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
288 | 288 | 'field_order' => (int) $field->field_order, |
289 | 289 | 'form_id' => (int) $form_id, |
290 | 290 | 'required' => (int) $field->required, |
291 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
291 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
292 | 292 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
293 | 293 | ); |
294 | 294 | |
295 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
295 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
296 | 296 | 'text', 'email', 'url', 'textarea', |
297 | - 'number','phone', 'date', 'time', |
|
297 | + 'number', 'phone', 'date', 'time', |
|
298 | 298 | 'hidden', 'password', 'tag', 'image', |
299 | - )) ) { |
|
300 | - if ( count($f['default_value']) === 1 ) { |
|
301 | - $f['default_value'] = '['. reset($f['default_value']) .']'; |
|
299 | + ) ) ) { |
|
300 | + if ( count( $f['default_value'] ) === 1 ) { |
|
301 | + $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
|
302 | 302 | } else { |
303 | - $f['default_value'] = reset($f['default_value']); |
|
303 | + $f['default_value'] = reset( $f['default_value'] ); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - $f = apply_filters('frm_duplicated_field', $f); |
|
307 | + $f = apply_filters( 'frm_duplicated_field', $f ); |
|
308 | 308 | |
309 | 309 | self::maybe_update_form_select( $f, $imported ); |
310 | 310 | |
311 | - if ( ! empty($this_form) ) { |
|
311 | + if ( ! empty( $this_form ) ) { |
|
312 | 312 | // check for field to edit by field id |
313 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
313 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
314 | 314 | FrmField::update( $f['id'], $f ); |
315 | - $imported['updated']['fields']++; |
|
315 | + $imported['updated']['fields'] ++; |
|
316 | 316 | |
317 | - unset( $form_fields[ $f['id'] ] ); |
|
317 | + unset( $form_fields[$f['id']] ); |
|
318 | 318 | |
319 | 319 | //unset old field key |
320 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
321 | - unset( $form_fields[ $f['field_key'] ] ); |
|
320 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
321 | + unset( $form_fields[$f['field_key']] ); |
|
322 | 322 | } |
323 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
323 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
324 | 324 | // check for field to edit by field key |
325 | - unset($f['id']); |
|
325 | + unset( $f['id'] ); |
|
326 | 326 | |
327 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
328 | - $imported['updated']['fields']++; |
|
327 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
328 | + $imported['updated']['fields'] ++; |
|
329 | 329 | |
330 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
331 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
330 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
331 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
332 | 332 | } else { |
333 | 333 | $new_id = FrmField::create( $f ); |
334 | 334 | if ( $new_id == false ) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | // if no matching field id or key in this form, create the field |
339 | - $imported['imported']['fields']++; |
|
339 | + $imported['imported']['fields'] ++; |
|
340 | 340 | } |
341 | 341 | } else { |
342 | 342 | $new_id = FrmField::create( $f ); |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | continue; |
345 | 345 | } |
346 | 346 | |
347 | - $imported['imported']['fields']++; |
|
347 | + $imported['imported']['fields'] ++; |
|
348 | 348 | } |
349 | 349 | |
350 | - unset($field, $new_id); |
|
350 | + unset( $field, $new_id ); |
|
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
367 | 367 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
368 | 368 | $form_select = $f['field_options']['form_select']; |
369 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
370 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
369 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
370 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | 'post_id' => (int) $item->post_id, |
396 | 396 | 'post_parent' => (int) $item->post_parent, |
397 | 397 | 'menu_order' => (int) $item->menu_order, |
398 | - 'post_content' => FrmFieldsHelper::switch_field_ids((string) $item->content), |
|
399 | - 'post_excerpt' => FrmFieldsHelper::switch_field_ids((string) $item->excerpt), |
|
398 | + 'post_content' => FrmFieldsHelper::switch_field_ids( (string) $item->content ), |
|
399 | + 'post_excerpt' => FrmFieldsHelper::switch_field_ids( (string) $item->excerpt ), |
|
400 | 400 | 'is_sticky' => (string) $item->is_sticky, |
401 | 401 | 'comment_status' => (string) $item->comment_status, |
402 | 402 | 'post_date' => (string) $item->post_date, |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | ); |
408 | 408 | |
409 | 409 | $old_id = $post['post_id']; |
410 | - self::populate_post($post, $item, $imported); |
|
410 | + self::populate_post( $post, $item, $imported ); |
|
411 | 411 | |
412 | - unset($item); |
|
412 | + unset( $item ); |
|
413 | 413 | |
414 | 414 | $post_id = false; |
415 | 415 | if ( $post['post_type'] == $form_action_type ) { |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | if ( $action_control ) { |
418 | 418 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
419 | 419 | } |
420 | - unset($action_control); |
|
420 | + unset( $action_control ); |
|
421 | 421 | } else if ( $post['post_type'] == 'frm_styles' ) { |
422 | 422 | // Properly encode post content before inserting the post |
423 | 423 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -430,26 +430,26 @@ discard block |
||
430 | 430 | $post_id = wp_insert_post( $post ); |
431 | 431 | } |
432 | 432 | |
433 | - if ( ! is_numeric($post_id) ) { |
|
433 | + if ( ! is_numeric( $post_id ) ) { |
|
434 | 434 | continue; |
435 | 435 | } |
436 | 436 | |
437 | - self::update_postmeta($post, $post_id); |
|
437 | + self::update_postmeta( $post, $post_id ); |
|
438 | 438 | |
439 | 439 | $this_type = 'posts'; |
440 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
441 | - $this_type = $post_types[ $post['post_type'] ]; |
|
440 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
441 | + $this_type = $post_types[$post['post_type']]; |
|
442 | 442 | } |
443 | 443 | |
444 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
445 | - $imported['updated'][ $this_type ]++; |
|
444 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
445 | + $imported['updated'][$this_type] ++; |
|
446 | 446 | } else { |
447 | - $imported['imported'][ $this_type ]++; |
|
447 | + $imported['imported'][$this_type] ++; |
|
448 | 448 | } |
449 | 449 | |
450 | - unset($post); |
|
450 | + unset( $post ); |
|
451 | 451 | |
452 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
452 | + $imported['posts'][(int) $old_id] = $post_id; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | self::maybe_update_stylesheet( $imported ); |
@@ -458,23 +458,23 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | private static function populate_post( &$post, $item, $imported ) { |
461 | - if ( isset($item->attachment_url) ) { |
|
461 | + if ( isset( $item->attachment_url ) ) { |
|
462 | 462 | $post['attachment_url'] = (string) $item->attachment_url; |
463 | 463 | } |
464 | 464 | |
465 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
465 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
466 | 466 | // update to new form id |
467 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
467 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | foreach ( $item->postmeta as $meta ) { |
471 | - self::populate_postmeta($post, $meta, $imported); |
|
472 | - unset($meta); |
|
471 | + self::populate_postmeta( $post, $meta, $imported ); |
|
472 | + unset( $meta ); |
|
473 | 473 | } |
474 | 474 | |
475 | - self::populate_taxonomies($post, $item); |
|
475 | + self::populate_taxonomies( $post, $item ); |
|
476 | 476 | |
477 | - self::maybe_editing_post($post); |
|
477 | + self::maybe_editing_post( $post ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -486,27 +486,27 @@ discard block |
||
486 | 486 | ); |
487 | 487 | |
488 | 488 | //switch old form and field ids to new ones |
489 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
490 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
489 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
490 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
491 | 491 | } else { |
492 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
492 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
493 | 493 | |
494 | - if ( ! empty($frm_duplicate_ids) ) { |
|
494 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
495 | 495 | |
496 | 496 | if ( $m['key'] == 'frm_dyncontent' ) { |
497 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
497 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
498 | 498 | } else if ( $m['key'] == 'frm_options' ) { |
499 | 499 | |
500 | 500 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
501 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
502 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
501 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
502 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | $check_dup_array = array(); |
507 | 507 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
508 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
509 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
508 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
509 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
510 | 510 | } else if ( is_array( $m['value']['order_by'] ) ) { |
511 | 511 | $check_dup_array[] = 'order_by'; |
512 | 512 | } |
@@ -517,22 +517,22 @@ discard block |
||
517 | 517 | } |
518 | 518 | |
519 | 519 | foreach ( $check_dup_array as $check_k ) { |
520 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
521 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
522 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
520 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
521 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
522 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
523 | 523 | } |
524 | - unset($mk, $mv); |
|
524 | + unset( $mk, $mv ); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | } |
528 | 528 | } |
529 | 529 | } |
530 | 530 | |
531 | - if ( ! is_array($m['value']) ) { |
|
532 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
531 | + if ( ! is_array( $m['value'] ) ) { |
|
532 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
533 | 533 | } |
534 | 534 | |
535 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
535 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -548,23 +548,23 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | $taxonomy = (string) $att['domain']; |
551 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
551 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
552 | 552 | $name = (string) $att['nicename']; |
553 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
553 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
554 | 554 | if ( $h_term ) { |
555 | 555 | $name = $h_term->term_id; |
556 | 556 | } |
557 | - unset($h_term); |
|
557 | + unset( $h_term ); |
|
558 | 558 | } else { |
559 | 559 | $name = (string) $c; |
560 | 560 | } |
561 | 561 | |
562 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
563 | - $post['tax_input'][ $taxonomy ] = array(); |
|
562 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
563 | + $post['tax_input'][$taxonomy] = array(); |
|
564 | 564 | } |
565 | 565 | |
566 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
567 | - unset($name); |
|
566 | + $post['tax_input'][$taxonomy][] = $name; |
|
567 | + unset( $name ); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
@@ -581,29 +581,29 @@ discard block |
||
581 | 581 | |
582 | 582 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
583 | 583 | $match_by['include'] = $post['post_id']; |
584 | - unset($match_by['name']); |
|
584 | + unset( $match_by['name'] ); |
|
585 | 585 | } |
586 | 586 | |
587 | - $editing = get_posts($match_by); |
|
587 | + $editing = get_posts( $match_by ); |
|
588 | 588 | |
589 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
589 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
590 | 590 | // set the id of the post to edit |
591 | - $post['ID'] = current($editing)->ID; |
|
591 | + $post['ID'] = current( $editing )->ID; |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | private static function update_postmeta( &$post, $post_id ) { |
596 | 596 | foreach ( $post['postmeta'] as $k => $v ) { |
597 | 597 | if ( '_edit_last' == $k ) { |
598 | - $v = FrmAppHelper::get_user_id_param($v); |
|
598 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
599 | 599 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
600 | 600 | //change the attachment ID |
601 | - $v = FrmProXMLHelper::get_file_id($v); |
|
601 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
602 | 602 | } |
603 | 603 | |
604 | - update_post_meta($post_id, $k, $v); |
|
604 | + update_post_meta( $post_id, $k, $v ); |
|
605 | 605 | |
606 | - unset($k, $v); |
|
606 | + unset( $k, $v ); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | * @param string $message |
621 | 621 | */ |
622 | 622 | public static function parse_message( $result, &$message, &$errors ) { |
623 | - if ( is_wp_error($result) ) { |
|
623 | + if ( is_wp_error( $result ) ) { |
|
624 | 624 | $errors[] = $result->get_error_message(); |
625 | 625 | } else if ( ! $result ) { |
626 | 626 | return; |
627 | 627 | } |
628 | 628 | |
629 | - if ( ! is_array($result) ) { |
|
629 | + if ( ! is_array( $result ) ) { |
|
630 | 630 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
631 | 631 | return; |
632 | 632 | } |
@@ -638,20 +638,20 @@ discard block |
||
638 | 638 | |
639 | 639 | $message = '<ul>'; |
640 | 640 | foreach ( $result as $type => $results ) { |
641 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
641 | + if ( ! isset( $t_strings[$type] ) ) { |
|
642 | 642 | // only print imported and updated |
643 | 643 | continue; |
644 | 644 | } |
645 | 645 | |
646 | 646 | $s_message = array(); |
647 | 647 | foreach ( $results as $k => $m ) { |
648 | - self::item_count_message($m, $k, $s_message); |
|
649 | - unset($k, $m); |
|
648 | + self::item_count_message( $m, $k, $s_message ); |
|
649 | + unset( $k, $m ); |
|
650 | 650 | } |
651 | 651 | |
652 | - if ( ! empty($s_message) ) { |
|
653 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
654 | - $message .= implode(', ', $s_message); |
|
652 | + if ( ! empty( $s_message ) ) { |
|
653 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
654 | + $message .= implode( ', ', $s_message ); |
|
655 | 655 | $message .= '</li>'; |
656 | 656 | } |
657 | 657 | } |
@@ -680,18 +680,18 @@ discard block |
||
680 | 680 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
681 | 681 | ); |
682 | 682 | |
683 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
683 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | public static function cdata( $str ) { |
687 | - $str = maybe_unserialize($str); |
|
688 | - if ( is_array($str) ) { |
|
689 | - $str = json_encode($str); |
|
687 | + $str = maybe_unserialize( $str ); |
|
688 | + if ( is_array( $str ) ) { |
|
689 | + $str = json_encode( $str ); |
|
690 | 690 | } else if ( seems_utf8( $str ) == false ) { |
691 | 691 | $str = utf8_encode( $str ); |
692 | 692 | } |
693 | 693 | |
694 | - if ( is_numeric($str) ) { |
|
694 | + if ( is_numeric( $str ) ) { |
|
695 | 695 | return $str; |
696 | 696 | } |
697 | 697 | |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * @param string $post_type |
724 | 724 | */ |
725 | 725 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
726 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
726 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
727 | 727 | return; |
728 | 728 | } |
729 | 729 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | 'menu_order' => $form_id, |
735 | 735 | 'post_status' => 'publish', |
736 | 736 | 'post_content' => array(), |
737 | - 'post_name' => $form_id .'_wppost_1', |
|
737 | + 'post_name' => $form_id . '_wppost_1', |
|
738 | 738 | ); |
739 | 739 | |
740 | 740 | $post_settings = array( |
@@ -744,10 +744,10 @@ discard block |
||
744 | 744 | ); |
745 | 745 | |
746 | 746 | foreach ( $post_settings as $post_setting ) { |
747 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
748 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
747 | + if ( isset( $form_options[$post_setting] ) ) { |
|
748 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
749 | 749 | } |
750 | - unset($post_setting); |
|
750 | + unset( $post_setting ); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | $new_action['event'] = array( 'create', 'update' ); |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | |
762 | 762 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
763 | 763 | } |
764 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
764 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
765 | 765 | |
766 | 766 | $exists = get_posts( array( |
767 | 767 | 'name' => $new_action['post_name'], |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | if ( ! $exists ) { |
774 | 774 | // this isn't an email, but we need to use a class that will always be included |
775 | 775 | FrmAppHelper::save_json_post( $new_action ); |
776 | - $imported['imported']['actions']++; |
|
776 | + $imported['imported']['actions'] ++; |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
@@ -805,11 +805,11 @@ discard block |
||
805 | 805 | foreach ( $post_content as $key => $setting ) { |
806 | 806 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
807 | 807 | // Replace old IDs with new IDs |
808 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
808 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
809 | 809 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
810 | 810 | foreach ( $setting as $k => $val ) { |
811 | 811 | // Replace old IDs with new IDs |
812 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
812 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | unset( $key, $setting ); |
@@ -832,14 +832,14 @@ discard block |
||
832 | 832 | // Migrate autoresponders |
833 | 833 | self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
834 | 834 | |
835 | - if ( empty( $notifications ) ) { |
|
835 | + if ( empty( $notifications ) ) { |
|
836 | 836 | return; |
837 | 837 | } |
838 | 838 | |
839 | 839 | foreach ( $notifications as $new_notification ) { |
840 | 840 | $new_notification['post_type'] = $post_type; |
841 | 841 | $new_notification['post_excerpt'] = 'email'; |
842 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
842 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
843 | 843 | $new_notification['menu_order'] = $form_id; |
844 | 844 | $new_notification['post_status'] = 'publish'; |
845 | 845 | |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | // Switch all other field IDs in email |
853 | 853 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
854 | 854 | } |
855 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
855 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
856 | 856 | |
857 | 857 | $exists = get_posts( array( |
858 | 858 | 'name' => $new_notification['post_name'], |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | 'numberposts' => 1, |
862 | 862 | ) ); |
863 | 863 | |
864 | - if ( empty($exists) ) { |
|
864 | + if ( empty( $exists ) ) { |
|
865 | 865 | FrmAppHelper::save_json_post( $new_notification ); |
866 | - $imported['imported']['actions']++; |
|
866 | + $imported['imported']['actions'] ++; |
|
867 | 867 | } |
868 | - unset($new_notification); |
|
868 | + unset( $new_notification ); |
|
869 | 869 | } |
870 | 870 | } |
871 | 871 | |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
879 | 879 | } |
880 | 880 | |
881 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
881 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
882 | 882 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
883 | 883 | |
884 | 884 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | // Format the reply to email and name |
907 | 907 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
908 | 908 | foreach ( $reply_fields as $f => $val ) { |
909 | - if ( isset( $notification[ $f ] ) ) { |
|
910 | - $atts[ $f ] = $notification[ $f ]; |
|
911 | - if ( 'custom' == $notification[ $f ] ) { |
|
912 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
913 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
914 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
909 | + if ( isset( $notification[$f] ) ) { |
|
910 | + $atts[$f] = $notification[$f]; |
|
911 | + if ( 'custom' == $notification[$f] ) { |
|
912 | + $atts[$f] = $notification['cust_' . $f]; |
|
913 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
914 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
915 | 915 | } |
916 | 916 | } |
917 | 917 | unset( $f, $val ); |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | $atts['event'] = array( 'create' ); |
922 | 922 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
923 | 923 | $atts['event'][] = 'update'; |
924 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
924 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
925 | 925 | $atts['event'] = array( 'update' ); |
926 | 926 | } |
927 | 927 | } |
@@ -942,18 +942,18 @@ discard block |
||
942 | 942 | foreach ( $atts['email_to'] as $key => $email_field ) { |
943 | 943 | |
944 | 944 | if ( is_numeric( $email_field ) ) { |
945 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
945 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
946 | 946 | } |
947 | 947 | |
948 | - if ( strpos( $email_field, '|') ) { |
|
948 | + if ( strpos( $email_field, '|' ) ) { |
|
949 | 949 | $email_opt = explode( '|', $email_field ); |
950 | 950 | if ( isset( $email_opt[0] ) ) { |
951 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
951 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
952 | 952 | } |
953 | 953 | unset( $email_opt ); |
954 | 954 | } |
955 | 955 | } |
956 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
956 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -963,18 +963,18 @@ discard block |
||
963 | 963 | 'email_to' => $atts['email_to'], |
964 | 964 | 'event' => $atts['event'], |
965 | 965 | ), |
966 | - 'post_name' => $atts['form_id'] .'_email_'. $atts['email_key'], |
|
966 | + 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
|
967 | 967 | ); |
968 | 968 | |
969 | 969 | // Add more fields to the new notification |
970 | 970 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
971 | 971 | foreach ( $add_fields as $add_field ) { |
972 | - if ( isset( $notification[ $add_field ] ) ) { |
|
973 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
972 | + if ( isset( $notification[$add_field] ) ) { |
|
973 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
974 | 974 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
975 | - $new_notification['post_content'][ $add_field ] = 0; |
|
975 | + $new_notification['post_content'][$add_field] = 0; |
|
976 | 976 | } else { |
977 | - $new_notification['post_content'][ $add_field ] = ''; |
|
977 | + $new_notification['post_content'][$add_field] = ''; |
|
978 | 978 | } |
979 | 979 | unset( $add_field ); |
980 | 980 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | |
985 | 985 | // Set from |
986 | 986 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
987 | - $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>'; |
|
987 | + $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
@@ -998,50 +998,50 @@ discard block |
||
998 | 998 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
999 | 999 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
1000 | 1000 | if ( is_numeric( $email_key ) ) { |
1001 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1001 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
1002 | 1002 | } |
1003 | - unset( $email_key, $val); |
|
1003 | + unset( $email_key, $val ); |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
1009 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1009 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
1010 | 1010 | // migrate autoresponder |
1011 | 1011 | |
1012 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1013 | - if ( strpos($email_field, '|') ) { |
|
1012 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
1013 | + if ( strpos( $email_field, '|' ) ) { |
|
1014 | 1014 | // data from entries field |
1015 | - $email_field = explode('|', $email_field); |
|
1016 | - if ( isset($email_field[1]) ) { |
|
1015 | + $email_field = explode( '|', $email_field ); |
|
1016 | + if ( isset( $email_field[1] ) ) { |
|
1017 | 1017 | $email_field = $email_field[1]; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1021 | - $email_field = '['. $email_field .']'; |
|
1020 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
1021 | + $email_field = '[' . $email_field . ']'; |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | $notification = $form_options; |
1025 | 1025 | $new_notification2 = array( |
1026 | 1026 | 'post_content' => array( |
1027 | 1027 | 'email_message' => $notification['ar_email_message'], |
1028 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1028 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
1029 | 1029 | 'email_to' => $email_field, |
1030 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1030 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
1031 | 1031 | 'inc_user_info' => 0, |
1032 | 1032 | ), |
1033 | - 'post_name' => $form_id .'_email_'. count( $notifications ), |
|
1033 | + 'post_name' => $form_id . '_email_' . count( $notifications ), |
|
1034 | 1034 | ); |
1035 | 1035 | |
1036 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1037 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1036 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
1037 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
1038 | 1038 | |
1039 | 1039 | if ( ! empty( $reply_to ) ) { |
1040 | 1040 | $new_notification2['post_content']['reply_to'] = $reply_to; |
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) { |
1044 | - $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>'; |
|
1044 | + $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | $notifications[] = $new_notification2; |
@@ -23,30 +23,30 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function import_xml( $file ) { |
26 | - $defaults = array( |
|
27 | - 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | - 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | - 'styles' => 0, |
|
30 | - ); |
|
31 | - |
|
32 | - $imported = array( |
|
33 | - 'imported' => $defaults, |
|
26 | + $defaults = array( |
|
27 | + 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
28 | + 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
29 | + 'styles' => 0, |
|
30 | + ); |
|
31 | + |
|
32 | + $imported = array( |
|
33 | + 'imported' => $defaults, |
|
34 | 34 | 'updated' => $defaults, |
35 | 35 | 'forms' => array(), |
36 | 36 | 'terms' => array(), |
37 | - ); |
|
37 | + ); |
|
38 | 38 | |
39 | - unset($defaults); |
|
39 | + unset($defaults); |
|
40 | 40 | |
41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
42 | - define('WP_IMPORTING', true); |
|
43 | - } |
|
42 | + define('WP_IMPORTING', true); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
46 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | - } |
|
46 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
47 | + } |
|
48 | 48 | |
49 | - $dom = new DOMDocument; |
|
49 | + $dom = new DOMDocument; |
|
50 | 50 | $success = $dom->loadXML( file_get_contents( $file ) ); |
51 | 51 | if ( ! $success ) { |
52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -64,45 +64,45 @@ discard block |
||
64 | 64 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
65 | 65 | } |
66 | 66 | |
67 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
67 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
69 | - // grab cats, tags, and terms, or forms or posts |
|
70 | - if ( isset($xml->{$item_type} ) ) { |
|
69 | + // grab cats, tags, and terms, or forms or posts |
|
70 | + if ( isset($xml->{$item_type} ) ) { |
|
71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
73 | 73 | unset( $function_name, $xml->{$item_type} ); |
74 | - } |
|
75 | - } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
77 | + $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
78 | 78 | |
79 | - return $return; |
|
80 | - } |
|
79 | + return $return; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
83 | - foreach ( $terms as $t ) { |
|
83 | + foreach ( $terms as $t ) { |
|
84 | 84 | if ( term_exists((string) $t->term_slug, (string) $t->term_taxonomy) ) { |
85 | - continue; |
|
85 | + continue; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $parent = self::get_term_parent_id( $t ); |
89 | 89 | |
90 | 90 | $term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array( |
91 | - 'slug' => (string) $t->term_slug, |
|
92 | - 'description' => (string) $t->term_description, |
|
91 | + 'slug' => (string) $t->term_slug, |
|
92 | + 'description' => (string) $t->term_description, |
|
93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
94 | - )); |
|
94 | + )); |
|
95 | 95 | |
96 | 96 | if ( $term && is_array( $term ) ) { |
97 | - $imported['imported']['terms']++; |
|
97 | + $imported['imported']['terms']++; |
|
98 | 98 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | unset( $term, $t ); |
102 | 102 | } |
103 | 103 | |
104 | 104 | return $imported; |
105 | - } |
|
105 | + } |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * @since 2.0.8 |
@@ -127,99 +127,99 @@ discard block |
||
127 | 127 | self::put_child_forms_first( $forms ); |
128 | 128 | |
129 | 129 | foreach ( $forms as $item ) { |
130 | - $form = array( |
|
131 | - 'id' => (int) $item->id, |
|
132 | - 'form_key' => (string) $item->form_key, |
|
133 | - 'name' => (string) $item->name, |
|
134 | - 'description' => (string) $item->description, |
|
135 | - 'options' => (string) $item->options, |
|
136 | - 'logged_in' => (int) $item->logged_in, |
|
137 | - 'is_template' => (int) $item->is_template, |
|
138 | - 'default_template' => (int) $item->default_template, |
|
139 | - 'editable' => (int) $item->editable, |
|
140 | - 'status' => (string) $item->status, |
|
141 | - 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
142 | - 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
143 | - ); |
|
144 | - |
|
145 | - $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
130 | + $form = array( |
|
131 | + 'id' => (int) $item->id, |
|
132 | + 'form_key' => (string) $item->form_key, |
|
133 | + 'name' => (string) $item->name, |
|
134 | + 'description' => (string) $item->description, |
|
135 | + 'options' => (string) $item->options, |
|
136 | + 'logged_in' => (int) $item->logged_in, |
|
137 | + 'is_template' => (int) $item->is_template, |
|
138 | + 'default_template' => (int) $item->default_template, |
|
139 | + 'editable' => (int) $item->editable, |
|
140 | + 'status' => (string) $item->status, |
|
141 | + 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, |
|
142 | + 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)), |
|
143 | + ); |
|
144 | + |
|
145 | + $form['options'] = FrmAppHelper::maybe_json_decode($form['options']); |
|
146 | 146 | |
147 | 147 | self::update_custom_style_setting_on_import( $form ); |
148 | 148 | |
149 | - // if template, allow to edit if form keys match, otherwise, creation date must also match |
|
149 | + // if template, allow to edit if form keys match, otherwise, creation date must also match |
|
150 | 150 | $edit_query = array( 'form_key' => $form['form_key'], 'is_template' => $form['is_template'] ); |
151 | - if ( ! $form['is_template'] ) { |
|
152 | - $edit_query['created_at'] = $form['created_at']; |
|
153 | - } |
|
151 | + if ( ! $form['is_template'] ) { |
|
152 | + $edit_query['created_at'] = $form['created_at']; |
|
153 | + } |
|
154 | 154 | |
155 | - $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
155 | + $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form); |
|
156 | 156 | |
157 | - $this_form = FrmForm::getAll($edit_query, '', 1); |
|
158 | - unset($edit_query); |
|
157 | + $this_form = FrmForm::getAll($edit_query, '', 1); |
|
158 | + unset($edit_query); |
|
159 | 159 | |
160 | - if ( ! empty( $this_form ) ) { |
|
161 | - $old_id = $form_id = $this_form->id; |
|
162 | - FrmForm::update($form_id, $form ); |
|
163 | - $imported['updated']['forms']++; |
|
164 | - // Keep track of whether this specific form was updated or not |
|
160 | + if ( ! empty( $this_form ) ) { |
|
161 | + $old_id = $form_id = $this_form->id; |
|
162 | + FrmForm::update($form_id, $form ); |
|
163 | + $imported['updated']['forms']++; |
|
164 | + // Keep track of whether this specific form was updated or not |
|
165 | 165 | $imported['form_status'][ $form_id ] = 'updated'; |
166 | 166 | |
167 | 167 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
168 | - $old_fields = array(); |
|
169 | - foreach ( $form_fields as $f ) { |
|
168 | + $old_fields = array(); |
|
169 | + foreach ( $form_fields as $f ) { |
|
170 | 170 | $old_fields[ $f->id ] = $f; |
171 | 171 | $old_fields[ $f->field_key ] = $f->id; |
172 | - unset($f); |
|
173 | - } |
|
174 | - $form_fields = $old_fields; |
|
175 | - unset($old_fields); |
|
176 | - } else { |
|
177 | - $old_id = false; |
|
178 | - //form does not exist, so create it |
|
172 | + unset($f); |
|
173 | + } |
|
174 | + $form_fields = $old_fields; |
|
175 | + unset($old_fields); |
|
176 | + } else { |
|
177 | + $old_id = false; |
|
178 | + //form does not exist, so create it |
|
179 | 179 | $form_id = FrmForm::create( $form ); |
180 | - if ( $form_id ) { |
|
181 | - $imported['imported']['forms']++; |
|
182 | - // Keep track of whether this specific form was updated or not |
|
180 | + if ( $form_id ) { |
|
181 | + $imported['imported']['forms']++; |
|
182 | + // Keep track of whether this specific form was updated or not |
|
183 | 183 | $imported['form_status'][ $form_id ] = 'imported'; |
184 | 184 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
185 | - } |
|
186 | - } |
|
185 | + } |
|
186 | + } |
|
187 | 187 | |
188 | - self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
|
188 | + self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
|
189 | 189 | |
190 | - // Delete any fields attached to this form that were not included in the template |
|
191 | - if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
|
190 | + // Delete any fields attached to this form that were not included in the template |
|
191 | + if ( isset( $form_fields ) && ! empty( $form_fields ) ) { |
|
192 | 192 | foreach ( $form_fields as $field ) { |
193 | - if ( is_object($field) ) { |
|
194 | - FrmField::destroy($field->id); |
|
195 | - } |
|
196 | - unset($field); |
|
197 | - } |
|
198 | - unset($form_fields); |
|
199 | - } |
|
200 | - |
|
201 | - // Update field ids/keys to new ones |
|
193 | + if ( is_object($field) ) { |
|
194 | + FrmField::destroy($field->id); |
|
195 | + } |
|
196 | + unset($field); |
|
197 | + } |
|
198 | + unset($form_fields); |
|
199 | + } |
|
200 | + |
|
201 | + // Update field ids/keys to new ones |
|
202 | 202 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
203 | 203 | |
204 | 204 | $imported['forms'][ (int) $item->id ] = $form_id; |
205 | 205 | |
206 | - // Send pre 2.0 form options through function that creates actions |
|
207 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
|
206 | + // Send pre 2.0 form options through function that creates actions |
|
207 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, $switch = true ); |
|
208 | 208 | |
209 | - unset($form, $item); |
|
209 | + unset($form, $item); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
213 | 213 | |
214 | 214 | return $imported; |
215 | - } |
|
215 | + } |
|
216 | 216 | |
217 | 217 | /** |
218 | - * Put child forms first so they will be imported before parents |
|
219 | - * |
|
220 | - * @since 2.0.16 |
|
221 | - * @param array $forms |
|
222 | - */ |
|
218 | + * Put child forms first so they will be imported before parents |
|
219 | + * |
|
220 | + * @since 2.0.16 |
|
221 | + * @param array $forms |
|
222 | + */ |
|
223 | 223 | private static function put_child_forms_first( &$forms ) { |
224 | 224 | $child_forms = array(); |
225 | 225 | $regular_forms = array(); |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | - * Keep track of all imported child forms |
|
242 | - * |
|
243 | - * @since 2.0.16 |
|
244 | - * @param int $form_id |
|
245 | - * @param int $parent_form_id |
|
246 | - * @param array $child_forms |
|
247 | - */ |
|
241 | + * Keep track of all imported child forms |
|
242 | + * |
|
243 | + * @since 2.0.16 |
|
244 | + * @param int $form_id |
|
245 | + * @param int $parent_form_id |
|
246 | + * @param array $child_forms |
|
247 | + */ |
|
248 | 248 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
249 | 249 | if ( $parent_form_id ) { |
250 | 250 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * Update the parent_form_id on imported child forms |
|
256 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
257 | - * |
|
258 | - * @since 2.0.6 |
|
259 | - * @param array $imported_forms |
|
260 | - * @param array $child_forms |
|
261 | - */ |
|
255 | + * Update the parent_form_id on imported child forms |
|
256 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
257 | + * |
|
258 | + * @since 2.0.6 |
|
259 | + * @param array $imported_forms |
|
260 | + * @param array $child_forms |
|
261 | + */ |
|
262 | 262 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
263 | 263 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
264 | 264 | |
@@ -272,61 +272,61 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Import all fields for a form |
|
276 | - * @since 2.0.13 |
|
277 | - * |
|
278 | - * TODO: Cut down on params |
|
279 | - */ |
|
275 | + * Import all fields for a form |
|
276 | + * @since 2.0.13 |
|
277 | + * |
|
278 | + * TODO: Cut down on params |
|
279 | + */ |
|
280 | 280 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
281 | 281 | foreach ( $xml_fields as $field ) { |
282 | - $f = array( |
|
283 | - 'id' => (int) $field->id, |
|
284 | - 'field_key' => (string) $field->field_key, |
|
285 | - 'name' => (string) $field->name, |
|
286 | - 'description' => (string) $field->description, |
|
287 | - 'type' => (string) $field->type, |
|
288 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
289 | - 'field_order' => (int) $field->field_order, |
|
290 | - 'form_id' => (int) $form_id, |
|
291 | - 'required' => (int) $field->required, |
|
292 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
282 | + $f = array( |
|
283 | + 'id' => (int) $field->id, |
|
284 | + 'field_key' => (string) $field->field_key, |
|
285 | + 'name' => (string) $field->name, |
|
286 | + 'description' => (string) $field->description, |
|
287 | + 'type' => (string) $field->type, |
|
288 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
289 | + 'field_order' => (int) $field->field_order, |
|
290 | + 'form_id' => (int) $form_id, |
|
291 | + 'required' => (int) $field->required, |
|
292 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
293 | 293 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
294 | - ); |
|
295 | - |
|
296 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
297 | - 'text', 'email', 'url', 'textarea', |
|
298 | - 'number','phone', 'date', 'time', |
|
299 | - 'hidden', 'password', 'tag', 'image', |
|
300 | - )) ) { |
|
301 | - if ( count($f['default_value']) === 1 ) { |
|
302 | - $f['default_value'] = '['. reset($f['default_value']) .']'; |
|
303 | - } else { |
|
304 | - $f['default_value'] = reset($f['default_value']); |
|
305 | - } |
|
306 | - } |
|
307 | - |
|
308 | - $f = apply_filters('frm_duplicated_field', $f); |
|
294 | + ); |
|
295 | + |
|
296 | + if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
297 | + 'text', 'email', 'url', 'textarea', |
|
298 | + 'number','phone', 'date', 'time', |
|
299 | + 'hidden', 'password', 'tag', 'image', |
|
300 | + )) ) { |
|
301 | + if ( count($f['default_value']) === 1 ) { |
|
302 | + $f['default_value'] = '['. reset($f['default_value']) .']'; |
|
303 | + } else { |
|
304 | + $f['default_value'] = reset($f['default_value']); |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + $f = apply_filters('frm_duplicated_field', $f); |
|
309 | 309 | |
310 | 310 | self::maybe_update_form_select( $f, $imported ); |
311 | 311 | |
312 | - if ( ! empty($this_form) ) { |
|
313 | - // check for field to edit by field id |
|
312 | + if ( ! empty($this_form) ) { |
|
313 | + // check for field to edit by field id |
|
314 | 314 | if ( isset( $form_fields[ $f['id'] ] ) ) { |
315 | - FrmField::update( $f['id'], $f ); |
|
316 | - $imported['updated']['fields']++; |
|
315 | + FrmField::update( $f['id'], $f ); |
|
316 | + $imported['updated']['fields']++; |
|
317 | 317 | |
318 | 318 | unset( $form_fields[ $f['id'] ] ); |
319 | 319 | |
320 | - //unset old field key |
|
320 | + //unset old field key |
|
321 | 321 | if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
322 | 322 | unset( $form_fields[ $f['field_key'] ] ); |
323 | 323 | } |
324 | 324 | } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
325 | - // check for field to edit by field key |
|
326 | - unset($f['id']); |
|
325 | + // check for field to edit by field key |
|
326 | + unset($f['id']); |
|
327 | 327 | |
328 | 328 | FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
329 | - $imported['updated']['fields']++; |
|
329 | + $imported['updated']['fields']++; |
|
330 | 330 | |
331 | 331 | unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
332 | 332 | unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
@@ -336,29 +336,29 @@ discard block |
||
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | |
339 | - // if no matching field id or key in this form, create the field |
|
340 | - $imported['imported']['fields']++; |
|
341 | - } |
|
339 | + // if no matching field id or key in this form, create the field |
|
340 | + $imported['imported']['fields']++; |
|
341 | + } |
|
342 | 342 | } else { |
343 | 343 | $new_id = FrmField::create( $f ); |
344 | 344 | if ( $new_id == false ) { |
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
348 | - $imported['imported']['fields']++; |
|
349 | - } |
|
348 | + $imported['imported']['fields']++; |
|
349 | + } |
|
350 | 350 | |
351 | 351 | unset($field, $new_id); |
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
356 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
357 | - * |
|
358 | - * @since 2.0.16 |
|
359 | - * @param array $f |
|
360 | - * @param array $imported |
|
361 | - */ |
|
356 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
357 | + * |
|
358 | + * @since 2.0.16 |
|
359 | + * @param array $f |
|
360 | + * @param array $imported |
|
361 | + */ |
|
362 | 362 | private static function maybe_update_form_select( &$f, $imported ) { |
363 | 363 | if ( ! isset( $imported['forms'] ) ) { |
364 | 364 | return; |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
378 | - * Updates the custom style setting on import |
|
379 | - * |
|
380 | - * @since 2.0.19 |
|
381 | - * @param array $form |
|
382 | - * |
|
383 | - */ |
|
378 | + * Updates the custom style setting on import |
|
379 | + * |
|
380 | + * @since 2.0.19 |
|
381 | + * @param array $form |
|
382 | + * |
|
383 | + */ |
|
384 | 384 | private static function update_custom_style_setting_on_import( &$form ) { |
385 | 385 | if ( is_numeric( $form['options']['custom_style'] ) ) { |
386 | 386 | // Set to default |
@@ -407,16 +407,16 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | public static function import_xml_views( $views, $imported ) { |
410 | - $imported['posts'] = array(); |
|
411 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
410 | + $imported['posts'] = array(); |
|
411 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
412 | 412 | |
413 | - $post_types = array( |
|
414 | - 'frm_display' => 'views', |
|
415 | - $form_action_type => 'actions', |
|
416 | - 'frm_styles' => 'styles', |
|
417 | - ); |
|
413 | + $post_types = array( |
|
414 | + 'frm_display' => 'views', |
|
415 | + $form_action_type => 'actions', |
|
416 | + 'frm_styles' => 'styles', |
|
417 | + ); |
|
418 | 418 | |
419 | - foreach ( $views as $item ) { |
|
419 | + foreach ( $views as $item ) { |
|
420 | 420 | $post = array( |
421 | 421 | 'post_title' => (string) $item->title, |
422 | 422 | 'post_name' => (string) $item->post_name, |
@@ -435,52 +435,52 @@ discard block |
||
435 | 435 | 'post_date' => (string) $item->post_date, |
436 | 436 | 'post_date_gmt' => (string) $item->post_date_gmt, |
437 | 437 | 'ping_status' => (string) $item->ping_status, |
438 | - 'postmeta' => array(), |
|
439 | - 'tax_input' => array(), |
|
438 | + 'postmeta' => array(), |
|
439 | + 'tax_input' => array(), |
|
440 | 440 | ); |
441 | 441 | |
442 | - $old_id = $post['post_id']; |
|
443 | - self::populate_post($post, $item, $imported); |
|
442 | + $old_id = $post['post_id']; |
|
443 | + self::populate_post($post, $item, $imported); |
|
444 | 444 | |
445 | 445 | unset($item); |
446 | 446 | |
447 | 447 | $post_id = false; |
448 | - if ( $post['post_type'] == $form_action_type ) { |
|
449 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
448 | + if ( $post['post_type'] == $form_action_type ) { |
|
449 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
450 | 450 | if ( $action_control ) { |
451 | 451 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
452 | 452 | } |
453 | - unset($action_control); |
|
454 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
455 | - // Properly encode post content before inserting the post |
|
456 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
457 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
458 | - |
|
459 | - // Create/update post now |
|
460 | - $post_id = wp_insert_post( $post ); |
|
461 | - } else { |
|
462 | - // Create/update post now |
|
463 | - $post_id = wp_insert_post( $post ); |
|
464 | - } |
|
465 | - |
|
466 | - if ( ! is_numeric($post_id) ) { |
|
467 | - continue; |
|
468 | - } |
|
469 | - |
|
470 | - self::update_postmeta($post, $post_id); |
|
471 | - |
|
472 | - $this_type = 'posts'; |
|
453 | + unset($action_control); |
|
454 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
455 | + // Properly encode post content before inserting the post |
|
456 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
457 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
458 | + |
|
459 | + // Create/update post now |
|
460 | + $post_id = wp_insert_post( $post ); |
|
461 | + } else { |
|
462 | + // Create/update post now |
|
463 | + $post_id = wp_insert_post( $post ); |
|
464 | + } |
|
465 | + |
|
466 | + if ( ! is_numeric($post_id) ) { |
|
467 | + continue; |
|
468 | + } |
|
469 | + |
|
470 | + self::update_postmeta($post, $post_id); |
|
471 | + |
|
472 | + $this_type = 'posts'; |
|
473 | 473 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
474 | 474 | $this_type = $post_types[ $post['post_type'] ]; |
475 | - } |
|
475 | + } |
|
476 | 476 | |
477 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
478 | - $imported['updated'][ $this_type ]++; |
|
479 | - } else { |
|
480 | - $imported['imported'][ $this_type ]++; |
|
481 | - } |
|
477 | + if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
478 | + $imported['updated'][ $this_type ]++; |
|
479 | + } else { |
|
480 | + $imported['imported'][ $this_type ]++; |
|
481 | + } |
|
482 | 482 | |
483 | - unset($post); |
|
483 | + unset($post); |
|
484 | 484 | |
485 | 485 | $imported['posts'][ (int) $old_id ] = $post_id; |
486 | 486 | } |
@@ -488,157 +488,157 @@ discard block |
||
488 | 488 | self::maybe_update_stylesheet( $imported ); |
489 | 489 | |
490 | 490 | return $imported; |
491 | - } |
|
491 | + } |
|
492 | 492 | |
493 | - private static function populate_post( &$post, $item, $imported ) { |
|
493 | + private static function populate_post( &$post, $item, $imported ) { |
|
494 | 494 | if ( isset($item->attachment_url) ) { |
495 | 495 | $post['attachment_url'] = (string) $item->attachment_url; |
496 | 496 | } |
497 | 497 | |
498 | 498 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
499 | - // update to new form id |
|
500 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
499 | + // update to new form id |
|
500 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | foreach ( $item->postmeta as $meta ) { |
504 | - self::populate_postmeta($post, $meta, $imported); |
|
504 | + self::populate_postmeta($post, $meta, $imported); |
|
505 | 505 | unset($meta); |
506 | 506 | } |
507 | 507 | |
508 | - self::populate_taxonomies($post, $item); |
|
508 | + self::populate_taxonomies($post, $item); |
|
509 | 509 | |
510 | - self::maybe_editing_post($post); |
|
511 | - } |
|
510 | + self::maybe_editing_post($post); |
|
511 | + } |
|
512 | 512 | |
513 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
514 | - global $frm_duplicate_ids; |
|
513 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
514 | + global $frm_duplicate_ids; |
|
515 | 515 | |
516 | - $m = array( |
|
516 | + $m = array( |
|
517 | 517 | 'key' => (string) $meta->meta_key, |
518 | 518 | 'value' => (string) $meta->meta_value, |
519 | 519 | ); |
520 | 520 | |
521 | 521 | //switch old form and field ids to new ones |
522 | 522 | if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
523 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
523 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
524 | 524 | } else { |
525 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
525 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
526 | 526 | |
527 | - if ( ! empty($frm_duplicate_ids) ) { |
|
527 | + if ( ! empty($frm_duplicate_ids) ) { |
|
528 | 528 | |
529 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
530 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
531 | - } else if ( $m['key'] == 'frm_options' ) { |
|
529 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
530 | + $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
531 | + } else if ( $m['key'] == 'frm_options' ) { |
|
532 | 532 | |
533 | 533 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
534 | 534 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
535 | 535 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
536 | - } |
|
537 | - } |
|
538 | - |
|
539 | - $check_dup_array = array(); |
|
540 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
541 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
542 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
543 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
544 | - $check_dup_array[] = 'order_by'; |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
549 | - $check_dup_array[] = 'where'; |
|
550 | - } |
|
551 | - |
|
552 | - foreach ( $check_dup_array as $check_k ) { |
|
536 | + } |
|
537 | + } |
|
538 | + |
|
539 | + $check_dup_array = array(); |
|
540 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
541 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
542 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
543 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
544 | + $check_dup_array[] = 'order_by'; |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
549 | + $check_dup_array[] = 'where'; |
|
550 | + } |
|
551 | + |
|
552 | + foreach ( $check_dup_array as $check_k ) { |
|
553 | 553 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
554 | 554 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
555 | 555 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
556 | - } |
|
557 | - unset($mk, $mv); |
|
558 | - } |
|
559 | - } |
|
560 | - } |
|
561 | - } |
|
556 | + } |
|
557 | + unset($mk, $mv); |
|
558 | + } |
|
559 | + } |
|
560 | + } |
|
561 | + } |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | if ( ! is_array($m['value']) ) { |
565 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
565 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
569 | - } |
|
570 | - |
|
571 | - /** |
|
572 | - * Add terms to post |
|
573 | - * @param array $post by reference |
|
574 | - * @param object $item The XML object data |
|
575 | - */ |
|
576 | - private static function populate_taxonomies( &$post, $item ) { |
|
569 | + } |
|
570 | + |
|
571 | + /** |
|
572 | + * Add terms to post |
|
573 | + * @param array $post by reference |
|
574 | + * @param object $item The XML object data |
|
575 | + */ |
|
576 | + private static function populate_taxonomies( &$post, $item ) { |
|
577 | 577 | foreach ( $item->category as $c ) { |
578 | 578 | $att = $c->attributes(); |
579 | 579 | if ( ! isset( $att['nicename'] ) ) { |
580 | - continue; |
|
581 | - } |
|
582 | - |
|
583 | - $taxonomy = (string) $att['domain']; |
|
584 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
585 | - $name = (string) $att['nicename']; |
|
586 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
587 | - if ( $h_term ) { |
|
588 | - $name = $h_term->term_id; |
|
589 | - } |
|
590 | - unset($h_term); |
|
591 | - } else { |
|
592 | - $name = (string) $c; |
|
593 | - } |
|
580 | + continue; |
|
581 | + } |
|
582 | + |
|
583 | + $taxonomy = (string) $att['domain']; |
|
584 | + if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
585 | + $name = (string) $att['nicename']; |
|
586 | + $h_term = get_term_by('slug', $name, $taxonomy); |
|
587 | + if ( $h_term ) { |
|
588 | + $name = $h_term->term_id; |
|
589 | + } |
|
590 | + unset($h_term); |
|
591 | + } else { |
|
592 | + $name = (string) $c; |
|
593 | + } |
|
594 | 594 | |
595 | 595 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
596 | 596 | $post['tax_input'][ $taxonomy ] = array(); |
597 | 597 | } |
598 | 598 | |
599 | 599 | $post['tax_input'][ $taxonomy ][] = $name; |
600 | - unset($name); |
|
600 | + unset($name); |
|
601 | 601 | } |
602 | - } |
|
602 | + } |
|
603 | 603 | |
604 | - /** |
|
605 | - * Edit post if the key and created time match |
|
606 | - */ |
|
607 | - private static function maybe_editing_post( &$post ) { |
|
604 | + /** |
|
605 | + * Edit post if the key and created time match |
|
606 | + */ |
|
607 | + private static function maybe_editing_post( &$post ) { |
|
608 | 608 | $match_by = array( |
609 | - 'post_type' => $post['post_type'], |
|
610 | - 'name' => $post['post_name'], |
|
611 | - 'post_status' => $post['post_status'], |
|
612 | - 'posts_per_page' => 1, |
|
609 | + 'post_type' => $post['post_type'], |
|
610 | + 'name' => $post['post_name'], |
|
611 | + 'post_status' => $post['post_status'], |
|
612 | + 'posts_per_page' => 1, |
|
613 | 613 | ); |
614 | 614 | |
615 | 615 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
616 | - $match_by['include'] = $post['post_id']; |
|
617 | - unset($match_by['name']); |
|
616 | + $match_by['include'] = $post['post_id']; |
|
617 | + unset($match_by['name']); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | $editing = get_posts($match_by); |
621 | 621 | |
622 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
623 | - // set the id of the post to edit |
|
624 | - $post['ID'] = current($editing)->ID; |
|
625 | - } |
|
626 | - } |
|
622 | + if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
623 | + // set the id of the post to edit |
|
624 | + $post['ID'] = current($editing)->ID; |
|
625 | + } |
|
626 | + } |
|
627 | 627 | |
628 | - private static function update_postmeta( &$post, $post_id ) { |
|
629 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
630 | - if ( '_edit_last' == $k ) { |
|
631 | - $v = FrmAppHelper::get_user_id_param($v); |
|
632 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
633 | - //change the attachment ID |
|
634 | - $v = FrmProXMLHelper::get_file_id($v); |
|
635 | - } |
|
628 | + private static function update_postmeta( &$post, $post_id ) { |
|
629 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
630 | + if ( '_edit_last' == $k ) { |
|
631 | + $v = FrmAppHelper::get_user_id_param($v); |
|
632 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
633 | + //change the attachment ID |
|
634 | + $v = FrmProXMLHelper::get_file_id($v); |
|
635 | + } |
|
636 | 636 | |
637 | - update_post_meta($post_id, $k, $v); |
|
637 | + update_post_meta($post_id, $k, $v); |
|
638 | 638 | |
639 | - unset($k, $v); |
|
640 | - } |
|
641 | - } |
|
639 | + unset($k, $v); |
|
640 | + } |
|
641 | + } |
|
642 | 642 | |
643 | 643 | private static function maybe_update_stylesheet( $imported ) { |
644 | 644 | if ( ( isset( $imported['imported']['styles'] ) && ! empty( $imported['imported']['styles'] ) ) || ( isset( $imported['updated']['styles'] ) && ! empty( $imported['updated']['styles'] ) ) ) { |
@@ -649,72 +649,72 @@ discard block |
||
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
652 | - /** |
|
653 | - * @param string $message |
|
654 | - */ |
|
652 | + /** |
|
653 | + * @param string $message |
|
654 | + */ |
|
655 | 655 | public static function parse_message( $result, &$message, &$errors ) { |
656 | - if ( is_wp_error($result) ) { |
|
657 | - $errors[] = $result->get_error_message(); |
|
658 | - } else if ( ! $result ) { |
|
659 | - return; |
|
660 | - } |
|
661 | - |
|
662 | - if ( ! is_array($result) ) { |
|
663 | - $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
664 | - return; |
|
665 | - } |
|
666 | - |
|
667 | - $t_strings = array( |
|
668 | - 'imported' => __( 'Imported', 'formidable' ), |
|
669 | - 'updated' => __( 'Updated', 'formidable' ), |
|
670 | - ); |
|
671 | - |
|
672 | - $message = '<ul>'; |
|
673 | - foreach ( $result as $type => $results ) { |
|
656 | + if ( is_wp_error($result) ) { |
|
657 | + $errors[] = $result->get_error_message(); |
|
658 | + } else if ( ! $result ) { |
|
659 | + return; |
|
660 | + } |
|
661 | + |
|
662 | + if ( ! is_array($result) ) { |
|
663 | + $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
664 | + return; |
|
665 | + } |
|
666 | + |
|
667 | + $t_strings = array( |
|
668 | + 'imported' => __( 'Imported', 'formidable' ), |
|
669 | + 'updated' => __( 'Updated', 'formidable' ), |
|
670 | + ); |
|
671 | + |
|
672 | + $message = '<ul>'; |
|
673 | + foreach ( $result as $type => $results ) { |
|
674 | 674 | if ( ! isset( $t_strings[ $type ] ) ) { |
675 | - // only print imported and updated |
|
676 | - continue; |
|
677 | - } |
|
675 | + // only print imported and updated |
|
676 | + continue; |
|
677 | + } |
|
678 | 678 | |
679 | - $s_message = array(); |
|
680 | - foreach ( $results as $k => $m ) { |
|
681 | - self::item_count_message($m, $k, $s_message); |
|
682 | - unset($k, $m); |
|
683 | - } |
|
679 | + $s_message = array(); |
|
680 | + foreach ( $results as $k => $m ) { |
|
681 | + self::item_count_message($m, $k, $s_message); |
|
682 | + unset($k, $m); |
|
683 | + } |
|
684 | 684 | |
685 | - if ( ! empty($s_message) ) { |
|
685 | + if ( ! empty($s_message) ) { |
|
686 | 686 | $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
687 | - $message .= implode(', ', $s_message); |
|
688 | - $message .= '</li>'; |
|
689 | - } |
|
690 | - } |
|
691 | - |
|
692 | - if ( $message == '<ul>' ) { |
|
693 | - $message = ''; |
|
694 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
695 | - } else { |
|
696 | - $message .= '</ul>'; |
|
697 | - } |
|
698 | - } |
|
687 | + $message .= implode(', ', $s_message); |
|
688 | + $message .= '</li>'; |
|
689 | + } |
|
690 | + } |
|
691 | + |
|
692 | + if ( $message == '<ul>' ) { |
|
693 | + $message = ''; |
|
694 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
695 | + } else { |
|
696 | + $message .= '</ul>'; |
|
697 | + } |
|
698 | + } |
|
699 | 699 | |
700 | 700 | public static function item_count_message( $m, $type, &$s_message ) { |
701 | - if ( ! $m ) { |
|
702 | - return; |
|
703 | - } |
|
704 | - |
|
705 | - $strings = array( |
|
706 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
707 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
708 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
709 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
710 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
711 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
712 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
713 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
714 | - ); |
|
701 | + if ( ! $m ) { |
|
702 | + return; |
|
703 | + } |
|
704 | + |
|
705 | + $strings = array( |
|
706 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
707 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
708 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
709 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
710 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
711 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
712 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
713 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
714 | + ); |
|
715 | 715 | |
716 | 716 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
717 | - } |
|
717 | + } |
|
718 | 718 | |
719 | 719 | /** |
720 | 720 | * Prepare the form options for export |
@@ -745,16 +745,16 @@ discard block |
||
745 | 745 | } |
746 | 746 | |
747 | 747 | public static function cdata( $str ) { |
748 | - $str = maybe_unserialize($str); |
|
749 | - if ( is_array($str) ) { |
|
750 | - $str = json_encode($str); |
|
748 | + $str = maybe_unserialize($str); |
|
749 | + if ( is_array($str) ) { |
|
750 | + $str = json_encode($str); |
|
751 | 751 | } else if ( seems_utf8( $str ) == false ) { |
752 | 752 | $str = utf8_encode( $str ); |
753 | 753 | } |
754 | 754 | |
755 | - if ( is_numeric($str) ) { |
|
756 | - return $str; |
|
757 | - } |
|
755 | + if ( is_numeric($str) ) { |
|
756 | + return $str; |
|
757 | + } |
|
758 | 758 | |
759 | 759 | // $str = ent2ncr(esc_html($str)); |
760 | 760 | $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>'; |
@@ -762,58 +762,58 @@ discard block |
||
762 | 762 | return $str; |
763 | 763 | } |
764 | 764 | |
765 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
766 | - // Get post type |
|
767 | - $post_type = FrmFormActionsController::$action_post_type; |
|
768 | - |
|
769 | - // Set up imported index, if not set up yet |
|
770 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
771 | - $imported['imported']['actions'] = 0; |
|
772 | - } |
|
773 | - |
|
774 | - // Migrate post settings to action |
|
775 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
776 | - |
|
777 | - // Migrate email settings to action |
|
778 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
779 | - } |
|
780 | - |
|
781 | - /** |
|
782 | - * Migrate post settings to form action |
|
783 | - * |
|
784 | - * @param string $post_type |
|
785 | - */ |
|
786 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
787 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
788 | - return; |
|
789 | - } |
|
790 | - |
|
791 | - $new_action = array( |
|
792 | - 'post_type' => $post_type, |
|
793 | - 'post_excerpt' => 'wppost', |
|
765 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
766 | + // Get post type |
|
767 | + $post_type = FrmFormActionsController::$action_post_type; |
|
768 | + |
|
769 | + // Set up imported index, if not set up yet |
|
770 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
771 | + $imported['imported']['actions'] = 0; |
|
772 | + } |
|
773 | + |
|
774 | + // Migrate post settings to action |
|
775 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
776 | + |
|
777 | + // Migrate email settings to action |
|
778 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
779 | + } |
|
780 | + |
|
781 | + /** |
|
782 | + * Migrate post settings to form action |
|
783 | + * |
|
784 | + * @param string $post_type |
|
785 | + */ |
|
786 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
787 | + if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
788 | + return; |
|
789 | + } |
|
790 | + |
|
791 | + $new_action = array( |
|
792 | + 'post_type' => $post_type, |
|
793 | + 'post_excerpt' => 'wppost', |
|
794 | 794 | 'post_title' => __( 'Create Posts', 'formidable' ), |
795 | - 'menu_order' => $form_id, |
|
796 | - 'post_status' => 'publish', |
|
797 | - 'post_content' => array(), |
|
798 | - 'post_name' => $form_id .'_wppost_1', |
|
799 | - ); |
|
800 | - |
|
801 | - $post_settings = array( |
|
802 | - 'post_type', 'post_category', 'post_content', |
|
803 | - 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
795 | + 'menu_order' => $form_id, |
|
796 | + 'post_status' => 'publish', |
|
797 | + 'post_content' => array(), |
|
798 | + 'post_name' => $form_id .'_wppost_1', |
|
799 | + ); |
|
800 | + |
|
801 | + $post_settings = array( |
|
802 | + 'post_type', 'post_category', 'post_content', |
|
803 | + 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
804 | 804 | 'post_status', 'post_custom_fields', 'post_password', |
805 | - ); |
|
805 | + ); |
|
806 | 806 | |
807 | - foreach ( $post_settings as $post_setting ) { |
|
807 | + foreach ( $post_settings as $post_setting ) { |
|
808 | 808 | if ( isset( $form_options[ $post_setting ] ) ) { |
809 | 809 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
810 | - } |
|
811 | - unset($post_setting); |
|
812 | - } |
|
810 | + } |
|
811 | + unset($post_setting); |
|
812 | + } |
|
813 | 813 | |
814 | 814 | $new_action['event'] = array( 'create', 'update' ); |
815 | 815 | |
816 | - if ( $switch ) { |
|
816 | + if ( $switch ) { |
|
817 | 817 | // Fields with string or int saved |
818 | 818 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
819 | 819 | |
@@ -821,22 +821,22 @@ discard block |
||
821 | 821 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
822 | 822 | |
823 | 823 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
824 | - } |
|
825 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
824 | + } |
|
825 | + $new_action['post_content'] = json_encode($new_action['post_content']); |
|
826 | 826 | |
827 | - $exists = get_posts( array( |
|
828 | - 'name' => $new_action['post_name'], |
|
829 | - 'post_type' => $new_action['post_type'], |
|
830 | - 'post_status' => $new_action['post_status'], |
|
831 | - 'numberposts' => 1, |
|
832 | - ) ); |
|
827 | + $exists = get_posts( array( |
|
828 | + 'name' => $new_action['post_name'], |
|
829 | + 'post_type' => $new_action['post_type'], |
|
830 | + 'post_status' => $new_action['post_status'], |
|
831 | + 'numberposts' => 1, |
|
832 | + ) ); |
|
833 | 833 | |
834 | - if ( ! $exists ) { |
|
834 | + if ( ! $exists ) { |
|
835 | 835 | // this isn't an email, but we need to use a class that will always be included |
836 | 836 | FrmAppHelper::save_json_post( $new_action ); |
837 | - $imported['imported']['actions']++; |
|
838 | - } |
|
839 | - } |
|
837 | + $imported['imported']['actions']++; |
|
838 | + } |
|
839 | + } |
|
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Switch old field IDs for new field IDs in emails and post |
@@ -849,211 +849,211 @@ discard block |
||
849 | 849 | * @return string $post_content - new field IDs |
850 | 850 | */ |
851 | 851 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
852 | - global $frm_duplicate_ids; |
|
852 | + global $frm_duplicate_ids; |
|
853 | 853 | |
854 | - // If there aren't IDs that were switched, end now |
|
855 | - if ( ! $frm_duplicate_ids ) { |
|
856 | - return; |
|
857 | - } |
|
854 | + // If there aren't IDs that were switched, end now |
|
855 | + if ( ! $frm_duplicate_ids ) { |
|
856 | + return; |
|
857 | + } |
|
858 | 858 | |
859 | - // Get old IDs |
|
860 | - $old = array_keys( $frm_duplicate_ids ); |
|
859 | + // Get old IDs |
|
860 | + $old = array_keys( $frm_duplicate_ids ); |
|
861 | 861 | |
862 | - // Get new IDs |
|
863 | - $new = array_values( $frm_duplicate_ids ); |
|
862 | + // Get new IDs |
|
863 | + $new = array_values( $frm_duplicate_ids ); |
|
864 | 864 | |
865 | - // Do a str_replace with each item to set the new IDs |
|
866 | - foreach ( $post_content as $key => $setting ) { |
|
867 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
868 | - // Replace old IDs with new IDs |
|
865 | + // Do a str_replace with each item to set the new IDs |
|
866 | + foreach ( $post_content as $key => $setting ) { |
|
867 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
868 | + // Replace old IDs with new IDs |
|
869 | 869 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
870 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
871 | - foreach ( $setting as $k => $val ) { |
|
872 | - // Replace old IDs with new IDs |
|
870 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
871 | + foreach ( $setting as $k => $val ) { |
|
872 | + // Replace old IDs with new IDs |
|
873 | 873 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
874 | - } |
|
875 | - } |
|
876 | - unset( $key, $setting ); |
|
877 | - } |
|
878 | - return $post_content; |
|
879 | - } |
|
880 | - |
|
881 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
882 | - // No old notifications or autoresponders to carry over |
|
874 | + } |
|
875 | + } |
|
876 | + unset( $key, $setting ); |
|
877 | + } |
|
878 | + return $post_content; |
|
879 | + } |
|
880 | + |
|
881 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
882 | + // No old notifications or autoresponders to carry over |
|
883 | 883 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
884 | - return; |
|
885 | - } |
|
884 | + return; |
|
885 | + } |
|
886 | 886 | |
887 | - // Initialize notifications array |
|
888 | - $notifications = array(); |
|
887 | + // Initialize notifications array |
|
888 | + $notifications = array(); |
|
889 | 889 | |
890 | - // Migrate regular notifications |
|
891 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
890 | + // Migrate regular notifications |
|
891 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
892 | 892 | |
893 | - // Migrate autoresponders |
|
894 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
893 | + // Migrate autoresponders |
|
894 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
895 | 895 | |
896 | - if ( empty( $notifications ) ) { |
|
897 | - return; |
|
898 | - } |
|
896 | + if ( empty( $notifications ) ) { |
|
897 | + return; |
|
898 | + } |
|
899 | 899 | |
900 | - foreach ( $notifications as $new_notification ) { |
|
901 | - $new_notification['post_type'] = $post_type; |
|
902 | - $new_notification['post_excerpt'] = 'email'; |
|
900 | + foreach ( $notifications as $new_notification ) { |
|
901 | + $new_notification['post_type'] = $post_type; |
|
902 | + $new_notification['post_excerpt'] = 'email'; |
|
903 | 903 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
904 | - $new_notification['menu_order'] = $form_id; |
|
905 | - $new_notification['post_status'] = 'publish'; |
|
904 | + $new_notification['menu_order'] = $form_id; |
|
905 | + $new_notification['post_status'] = 'publish'; |
|
906 | 906 | |
907 | - // Switch field IDs and keys, if needed |
|
908 | - if ( $switch ) { |
|
907 | + // Switch field IDs and keys, if needed |
|
908 | + if ( $switch ) { |
|
909 | 909 | |
910 | 910 | // Switch field IDs in email conditional logic |
911 | 911 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
912 | 912 | |
913 | 913 | // Switch all other field IDs in email |
914 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
915 | - } |
|
916 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
917 | - |
|
918 | - $exists = get_posts( array( |
|
919 | - 'name' => $new_notification['post_name'], |
|
920 | - 'post_type' => $new_notification['post_type'], |
|
921 | - 'post_status' => $new_notification['post_status'], |
|
922 | - 'numberposts' => 1, |
|
923 | - ) ); |
|
924 | - |
|
925 | - if ( empty($exists) ) { |
|
914 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
915 | + } |
|
916 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
917 | + |
|
918 | + $exists = get_posts( array( |
|
919 | + 'name' => $new_notification['post_name'], |
|
920 | + 'post_type' => $new_notification['post_type'], |
|
921 | + 'post_status' => $new_notification['post_status'], |
|
922 | + 'numberposts' => 1, |
|
923 | + ) ); |
|
924 | + |
|
925 | + if ( empty($exists) ) { |
|
926 | 926 | FrmAppHelper::save_json_post( $new_notification ); |
927 | - $imported['imported']['actions']++; |
|
928 | - } |
|
929 | - unset($new_notification); |
|
930 | - } |
|
931 | - } |
|
932 | - |
|
933 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
934 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
935 | - // add old settings into notification array |
|
927 | + $imported['imported']['actions']++; |
|
928 | + } |
|
929 | + unset($new_notification); |
|
930 | + } |
|
931 | + } |
|
932 | + |
|
933 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
934 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
935 | + // add old settings into notification array |
|
936 | 936 | $form_options['notification'] = array( 0 => $form_options ); |
937 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
938 | - // make sure it's in the correct format |
|
937 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
938 | + // make sure it's in the correct format |
|
939 | 939 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
940 | - } |
|
940 | + } |
|
941 | 941 | |
942 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
943 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
942 | + if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
943 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
944 | 944 | |
945 | - $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
945 | + $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
946 | 946 | |
947 | - // Format the email data |
|
948 | - self::format_email_data( $atts, $notification ); |
|
947 | + // Format the email data |
|
948 | + self::format_email_data( $atts, $notification ); |
|
949 | 949 | |
950 | 950 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
951 | 951 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
952 | 952 | } |
953 | 953 | |
954 | - // Setup the new notification |
|
955 | - $new_notification = array(); |
|
956 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
954 | + // Setup the new notification |
|
955 | + $new_notification = array(); |
|
956 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
957 | 957 | |
958 | - $notifications[] = $new_notification; |
|
959 | - } |
|
960 | - } |
|
961 | - } |
|
958 | + $notifications[] = $new_notification; |
|
959 | + } |
|
960 | + } |
|
961 | + } |
|
962 | 962 | |
963 | - private static function format_email_data( &$atts, $notification ) { |
|
964 | - // Format email_to |
|
965 | - self::format_email_to_data( $atts, $notification ); |
|
963 | + private static function format_email_data( &$atts, $notification ) { |
|
964 | + // Format email_to |
|
965 | + self::format_email_to_data( $atts, $notification ); |
|
966 | 966 | |
967 | - // Format the reply to email and name |
|
968 | - $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
969 | - foreach ( $reply_fields as $f => $val ) { |
|
967 | + // Format the reply to email and name |
|
968 | + $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
969 | + foreach ( $reply_fields as $f => $val ) { |
|
970 | 970 | if ( isset( $notification[ $f ] ) ) { |
971 | 971 | $atts[ $f ] = $notification[ $f ]; |
972 | 972 | if ( 'custom' == $notification[ $f ] ) { |
973 | 973 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
974 | 974 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
975 | 975 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
976 | - } |
|
977 | - } |
|
978 | - unset( $f, $val ); |
|
979 | - } |
|
976 | + } |
|
977 | + } |
|
978 | + unset( $f, $val ); |
|
979 | + } |
|
980 | 980 | |
981 | - // Format event |
|
981 | + // Format event |
|
982 | 982 | $atts['event'] = array( 'create' ); |
983 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
984 | - $atts['event'][] = 'update'; |
|
985 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
983 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
984 | + $atts['event'][] = 'update'; |
|
985 | + } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
986 | 986 | $atts['event'] = array( 'update' ); |
987 | - } |
|
988 | - } |
|
987 | + } |
|
988 | + } |
|
989 | 989 | |
990 | - private static function format_email_to_data( &$atts, $notification ) { |
|
991 | - if ( isset( $notification['email_to'] ) ) { |
|
990 | + private static function format_email_to_data( &$atts, $notification ) { |
|
991 | + if ( isset( $notification['email_to'] ) ) { |
|
992 | 992 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
993 | - } else { |
|
994 | - $atts['email_to'] = array(); |
|
995 | - } |
|
993 | + } else { |
|
994 | + $atts['email_to'] = array(); |
|
995 | + } |
|
996 | 996 | |
997 | - if ( isset( $notification['also_email_to'] ) ) { |
|
998 | - $email_fields = (array) $notification['also_email_to']; |
|
999 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1000 | - unset( $email_fields ); |
|
1001 | - } |
|
997 | + if ( isset( $notification['also_email_to'] ) ) { |
|
998 | + $email_fields = (array) $notification['also_email_to']; |
|
999 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
1000 | + unset( $email_fields ); |
|
1001 | + } |
|
1002 | 1002 | |
1003 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1003 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
1004 | 1004 | |
1005 | - if ( is_numeric( $email_field ) ) { |
|
1005 | + if ( is_numeric( $email_field ) ) { |
|
1006 | 1006 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
1007 | - } |
|
1007 | + } |
|
1008 | 1008 | |
1009 | - if ( strpos( $email_field, '|') ) { |
|
1010 | - $email_opt = explode( '|', $email_field ); |
|
1011 | - if ( isset( $email_opt[0] ) ) { |
|
1009 | + if ( strpos( $email_field, '|') ) { |
|
1010 | + $email_opt = explode( '|', $email_field ); |
|
1011 | + if ( isset( $email_opt[0] ) ) { |
|
1012 | 1012 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
1013 | - } |
|
1014 | - unset( $email_opt ); |
|
1015 | - } |
|
1016 | - } |
|
1017 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1018 | - } |
|
1019 | - |
|
1020 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1021 | - // Set up new notification |
|
1022 | - $new_notification = array( |
|
1023 | - 'post_content' => array( |
|
1024 | - 'email_to' => $atts['email_to'], |
|
1025 | - 'event' => $atts['event'], |
|
1026 | - ), |
|
1027 | - 'post_name' => $atts['form_id'] .'_email_'. $atts['email_key'], |
|
1028 | - ); |
|
1029 | - |
|
1030 | - // Add more fields to the new notification |
|
1031 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1032 | - foreach ( $add_fields as $add_field ) { |
|
1013 | + } |
|
1014 | + unset( $email_opt ); |
|
1015 | + } |
|
1016 | + } |
|
1017 | + $atts['email_to'] = implode(', ', $atts['email_to']); |
|
1018 | + } |
|
1019 | + |
|
1020 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
1021 | + // Set up new notification |
|
1022 | + $new_notification = array( |
|
1023 | + 'post_content' => array( |
|
1024 | + 'email_to' => $atts['email_to'], |
|
1025 | + 'event' => $atts['event'], |
|
1026 | + ), |
|
1027 | + 'post_name' => $atts['form_id'] .'_email_'. $atts['email_key'], |
|
1028 | + ); |
|
1029 | + |
|
1030 | + // Add more fields to the new notification |
|
1031 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
1032 | + foreach ( $add_fields as $add_field ) { |
|
1033 | 1033 | if ( isset( $notification[ $add_field ] ) ) { |
1034 | 1034 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
1035 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1035 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
1036 | 1036 | $new_notification['post_content'][ $add_field ] = 0; |
1037 | - } else { |
|
1037 | + } else { |
|
1038 | 1038 | $new_notification['post_content'][ $add_field ] = ''; |
1039 | - } |
|
1040 | - unset( $add_field ); |
|
1041 | - } |
|
1039 | + } |
|
1040 | + unset( $add_field ); |
|
1041 | + } |
|
1042 | 1042 | |
1043 | 1043 | // Set reply to |
1044 | 1044 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
1045 | 1045 | |
1046 | - // Set from |
|
1046 | + // Set from |
|
1047 | 1047 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
1048 | - $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>'; |
|
1049 | - } |
|
1050 | - } |
|
1048 | + $new_notification['post_content']['from'] = ( empty($atts['reply_to_name']) ? '[sitename]' : $atts['reply_to_name'] ) .' <'. ( empty($atts['reply_to']) ? '[admin_email]' : $atts['reply_to'] ) .'>'; |
|
1049 | + } |
|
1050 | + } |
|
1051 | 1051 | |
1052 | 1052 | /** |
1053 | - * Switch field IDs in pre-2.0 email conditional logic |
|
1054 | - * |
|
1055 | - * @param $post_content array, pass by reference |
|
1056 | - */ |
|
1053 | + * Switch field IDs in pre-2.0 email conditional logic |
|
1054 | + * |
|
1055 | + * @param $post_content array, pass by reference |
|
1056 | + */ |
|
1057 | 1057 | private static function switch_email_contition_field_ids( &$post_content ) { |
1058 | 1058 | // Switch field IDs in conditional logic |
1059 | 1059 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1066,48 +1066,48 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | |
1069 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1070 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1071 | - // migrate autoresponder |
|
1072 | - |
|
1073 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1074 | - if ( strpos($email_field, '|') ) { |
|
1075 | - // data from entries field |
|
1076 | - $email_field = explode('|', $email_field); |
|
1077 | - if ( isset($email_field[1]) ) { |
|
1078 | - $email_field = $email_field[1]; |
|
1079 | - } |
|
1080 | - } |
|
1081 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1082 | - $email_field = '['. $email_field .']'; |
|
1083 | - } |
|
1084 | - |
|
1085 | - $notification = $form_options; |
|
1086 | - $new_notification2 = array( |
|
1087 | - 'post_content' => array( |
|
1088 | - 'email_message' => $notification['ar_email_message'], |
|
1089 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1090 | - 'email_to' => $email_field, |
|
1091 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1092 | - 'inc_user_info' => 0, |
|
1093 | - ), |
|
1094 | - 'post_name' => $form_id .'_email_'. count( $notifications ), |
|
1095 | - ); |
|
1096 | - |
|
1097 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1098 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1069 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
1070 | + if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
1071 | + // migrate autoresponder |
|
1072 | + |
|
1073 | + $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
1074 | + if ( strpos($email_field, '|') ) { |
|
1075 | + // data from entries field |
|
1076 | + $email_field = explode('|', $email_field); |
|
1077 | + if ( isset($email_field[1]) ) { |
|
1078 | + $email_field = $email_field[1]; |
|
1079 | + } |
|
1080 | + } |
|
1081 | + if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
1082 | + $email_field = '['. $email_field .']'; |
|
1083 | + } |
|
1084 | + |
|
1085 | + $notification = $form_options; |
|
1086 | + $new_notification2 = array( |
|
1087 | + 'post_content' => array( |
|
1088 | + 'email_message' => $notification['ar_email_message'], |
|
1089 | + 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
1090 | + 'email_to' => $email_field, |
|
1091 | + 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
1092 | + 'inc_user_info' => 0, |
|
1093 | + ), |
|
1094 | + 'post_name' => $form_id .'_email_'. count( $notifications ), |
|
1095 | + ); |
|
1096 | + |
|
1097 | + $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
1098 | + $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
1099 | 1099 | |
1100 | 1100 | if ( ! empty( $reply_to ) ) { |
1101 | 1101 | $new_notification2['post_content']['reply_to'] = $reply_to; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | if ( ! empty( $reply_to ) || ! empty( $reply_to_name ) ) { |
1105 | - $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>'; |
|
1105 | + $new_notification2['post_content']['from'] = ( empty($reply_to_name) ? '[sitename]' : $reply_to_name ) .' <'. ( empty($reply_to) ? '[admin_email]' : $reply_to ) .'>'; |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | - $notifications[] = $new_notification2; |
|
1109 | - unset( $new_notification2 ); |
|
1110 | - } |
|
1111 | - } |
|
1108 | + $notifications[] = $new_notification2; |
|
1109 | + unset( $new_notification2 ); |
|
1110 | + } |
|
1111 | + } |
|
1112 | 1112 | } |
1113 | 1113 |