@@ -159,6 +159,9 @@ discard block |
||
159 | 159 | wp_die(); |
160 | 160 | } |
161 | 161 | |
162 | + /** |
|
163 | + * @param string $field |
|
164 | + */ |
|
162 | 165 | private static function edit_in_place_value( $field ) { |
163 | 166 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
164 | 167 | FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
@@ -203,6 +206,9 @@ discard block |
||
203 | 206 | } |
204 | 207 | } |
205 | 208 | |
209 | + /** |
|
210 | + * @return string |
|
211 | + */ |
|
206 | 212 | public static function bulk_create_template( $ids ) { |
207 | 213 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
208 | 214 | |
@@ -698,6 +704,7 @@ discard block |
||
698 | 704 | /** |
699 | 705 | * Get an array of the helper shortcodes to display in the customization panel |
700 | 706 | * @since 2.0.6 |
707 | + * @param boolean $settings_tab |
|
701 | 708 | */ |
702 | 709 | private static function get_shortcode_helpers( $settings_tab ) { |
703 | 710 | $entry_shortcodes = array( |
@@ -771,6 +778,9 @@ discard block |
||
771 | 778 | return $content; |
772 | 779 | } |
773 | 780 | |
781 | + /** |
|
782 | + * @param boolean $entry |
|
783 | + */ |
|
774 | 784 | private static function get_entry_by_param( &$entry ) { |
775 | 785 | if ( ! $entry || ! is_object( $entry ) ) { |
776 | 786 | if ( ! $entry || ! is_numeric( $entry ) ) { |
@@ -1237,6 +1247,7 @@ discard block |
||
1237 | 1247 | |
1238 | 1248 | /** |
1239 | 1249 | * @since 2.0.8 |
1250 | + * @param string $content |
|
1240 | 1251 | */ |
1241 | 1252 | private static function maybe_minimize_form( $atts, &$content ) { |
1242 | 1253 | // check if minimizing is turned on |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFormsController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | $menu_label = __( 'Forms', 'formidable' ); |
7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
8 | 8 | $menu_label .= ' (Lite)'; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
11 | 11 | |
12 | 12 | self::maybe_load_listing_hooks(); |
13 | - } |
|
13 | + } |
|
14 | 14 | |
15 | 15 | public static function maybe_load_listing_hooks() { |
16 | 16 | $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
@@ -24,128 +24,128 @@ discard block |
||
24 | 24 | add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
25 | 25 | } |
26 | 26 | |
27 | - public static function head() { |
|
28 | - wp_enqueue_script('formidable-editinplace'); |
|
27 | + public static function head() { |
|
28 | + wp_enqueue_script('formidable-editinplace'); |
|
29 | 29 | |
30 | - if ( wp_is_mobile() ) { |
|
31 | - wp_enqueue_script( 'jquery-touch-punch' ); |
|
32 | - } |
|
33 | - } |
|
30 | + if ( wp_is_mobile() ) { |
|
31 | + wp_enqueue_script( 'jquery-touch-punch' ); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - public static function register_widgets() { |
|
36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
37 | - register_widget('FrmShowForm'); |
|
38 | - } |
|
35 | + public static function register_widgets() { |
|
36 | + require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
37 | + register_widget('FrmShowForm'); |
|
38 | + } |
|
39 | 39 | |
40 | - public static function list_form() { |
|
41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
40 | + public static function list_form() { |
|
41 | + FrmAppHelper::permission_check('frm_view_forms'); |
|
42 | 42 | |
43 | 43 | $params = FrmForm::list_page_params(); |
44 | - $errors = self::process_bulk_form_actions( array()); |
|
45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
44 | + $errors = self::process_bulk_form_actions( array()); |
|
45 | + $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
46 | 46 | |
47 | 47 | return self::display_forms_list( $params, '', $errors ); |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | 50 | public static function new_form( $values = array() ) { |
51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
51 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
52 | 52 | |
53 | - global $frm_vars; |
|
53 | + global $frm_vars; |
|
54 | 54 | |
55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
55 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
56 | 56 | $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
57 | 57 | |
58 | 58 | if ( $action == 'create' ) { |
59 | - return self::create($values); |
|
59 | + return self::create($values); |
|
60 | 60 | } else if ( $action == 'new' ) { |
61 | 61 | $frm_field_selection = FrmField::field_selection(); |
62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
63 | - $id = FrmForm::create( $values ); |
|
64 | - $form = FrmForm::getOne($id); |
|
62 | + $values = FrmFormsHelper::setup_new_vars($values); |
|
63 | + $id = FrmForm::create( $values ); |
|
64 | + $form = FrmForm::getOne($id); |
|
65 | 65 | |
66 | - // add default email notification |
|
67 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
68 | - $action_control->create($form->id); |
|
66 | + // add default email notification |
|
67 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
68 | + $action_control->create($form->id); |
|
69 | 69 | |
70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
71 | 71 | |
72 | - $values['id'] = $id; |
|
72 | + $values['id'] = $id; |
|
73 | 73 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
74 | - } |
|
75 | - } |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | public static function create( $values = array() ) { |
78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
78 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
79 | 79 | |
80 | - global $frm_vars; |
|
81 | - if ( empty( $values ) ) { |
|
82 | - $values = $_POST; |
|
83 | - } |
|
80 | + global $frm_vars; |
|
81 | + if ( empty( $values ) ) { |
|
82 | + $values = $_POST; |
|
83 | + } |
|
84 | 84 | |
85 | - //Set radio button and checkbox meta equal to "other" value |
|
86 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
87 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
88 | - } |
|
85 | + //Set radio button and checkbox meta equal to "other" value |
|
86 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
87 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
91 | 91 | |
92 | - if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
93 | - $frm_settings = FrmAppHelper::get_settings(); |
|
94 | - $errors = array( 'form' => $frm_settings->admin_permission ); |
|
95 | - } else { |
|
96 | - $errors = FrmForm::validate($values); |
|
97 | - } |
|
92 | + if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
|
93 | + $frm_settings = FrmAppHelper::get_settings(); |
|
94 | + $errors = array( 'form' => $frm_settings->admin_permission ); |
|
95 | + } else { |
|
96 | + $errors = FrmForm::validate($values); |
|
97 | + } |
|
98 | 98 | |
99 | - if ( count($errors) > 0 ) { |
|
100 | - $hide_preview = true; |
|
99 | + if ( count($errors) > 0 ) { |
|
100 | + $hide_preview = true; |
|
101 | 101 | $frm_field_selection = FrmField::field_selection(); |
102 | - $form = FrmForm::getOne( $id ); |
|
103 | - $fields = FrmField::get_all_for_form($id); |
|
102 | + $form = FrmForm::getOne( $id ); |
|
103 | + $fields = FrmField::get_all_for_form($id); |
|
104 | 104 | |
105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
105 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
107 | 107 | |
108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
109 | - } else { |
|
110 | - FrmForm::update( $id, $values, true ); |
|
109 | + } else { |
|
110 | + FrmForm::update( $id, $values, true ); |
|
111 | 111 | $url = admin_url( 'admin.php?page=formidable&frm_action=settings&id=' . $id ); |
112 | 112 | die( FrmAppHelper::js_redirect( $url ) ); |
113 | - } |
|
114 | - } |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - public static function edit( $values = false ) { |
|
117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
116 | + public static function edit( $values = false ) { |
|
117 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
118 | 118 | |
119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
120 | - return self::get_edit_vars($id); |
|
121 | - } |
|
120 | + return self::get_edit_vars($id); |
|
121 | + } |
|
122 | 122 | |
123 | - public static function settings( $id = false, $message = '' ) { |
|
124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
123 | + public static function settings( $id = false, $message = '' ) { |
|
124 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
125 | 125 | |
126 | - if ( ! $id || ! is_numeric($id) ) { |
|
126 | + if ( ! $id || ! is_numeric($id) ) { |
|
127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
128 | - } |
|
128 | + } |
|
129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | - public static function update_settings() { |
|
133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
132 | + public static function update_settings() { |
|
133 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
134 | 134 | |
135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
136 | 136 | |
137 | - $errors = FrmForm::validate($_POST); |
|
138 | - if ( count($errors) > 0 ) { |
|
139 | - return self::get_settings_vars($id, $errors); |
|
140 | - } |
|
137 | + $errors = FrmForm::validate($_POST); |
|
138 | + if ( count($errors) > 0 ) { |
|
139 | + return self::get_settings_vars($id, $errors); |
|
140 | + } |
|
141 | 141 | |
142 | - do_action('frm_before_update_form_settings', $id); |
|
142 | + do_action('frm_before_update_form_settings', $id); |
|
143 | 143 | |
144 | 144 | FrmForm::update( $id, $_POST ); |
145 | 145 | |
146 | - $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
146 | + $message = __( 'Settings Successfully Updated', 'formidable' ); |
|
147 | 147 | return self::get_settings_vars( $id, array(), $message ); |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | public static function edit_key() { |
151 | 151 | $values = self::edit_in_place_value( 'form_key' ); |
@@ -175,43 +175,43 @@ discard block |
||
175 | 175 | |
176 | 176 | public static function update( $values = array() ) { |
177 | 177 | if ( empty( $values ) ) { |
178 | - $values = $_POST; |
|
179 | - } |
|
178 | + $values = $_POST; |
|
179 | + } |
|
180 | 180 | |
181 | - //Set radio button and checkbox meta equal to "other" value |
|
182 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
183 | - $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
184 | - } |
|
181 | + //Set radio button and checkbox meta equal to "other" value |
|
182 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
183 | + $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
|
184 | + } |
|
185 | 185 | |
186 | - $errors = FrmForm::validate( $values ); |
|
187 | - $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
188 | - if ( $permission_error !== false ) { |
|
189 | - $errors['form'] = $permission_error; |
|
190 | - } |
|
186 | + $errors = FrmForm::validate( $values ); |
|
187 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' ); |
|
188 | + if ( $permission_error !== false ) { |
|
189 | + $errors['form'] = $permission_error; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
193 | 193 | |
194 | 194 | if ( count( $errors ) > 0 ) { |
195 | - return self::get_edit_vars( $id, $errors ); |
|
195 | + return self::get_edit_vars( $id, $errors ); |
|
196 | 196 | } else { |
197 | - FrmForm::update( $id, $values ); |
|
198 | - $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
199 | - if ( defined( 'DOING_AJAX' ) ) { |
|
197 | + FrmForm::update( $id, $values ); |
|
198 | + $message = __( 'Form was Successfully Updated', 'formidable' ); |
|
199 | + if ( defined( 'DOING_AJAX' ) ) { |
|
200 | 200 | wp_die( $message ); |
201 | - } |
|
201 | + } |
|
202 | 202 | return self::get_edit_vars( $id, array(), $message ); |
203 | - } |
|
204 | - } |
|
203 | + } |
|
204 | + } |
|
205 | 205 | |
206 | - public static function bulk_create_template( $ids ) { |
|
207 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
206 | + public static function bulk_create_template( $ids ) { |
|
207 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
208 | 208 | |
209 | - foreach ( $ids as $id ) { |
|
210 | - FrmForm::duplicate( $id, true, true ); |
|
211 | - } |
|
209 | + foreach ( $ids as $id ) { |
|
210 | + FrmForm::duplicate( $id, true, true ); |
|
211 | + } |
|
212 | 212 | |
213 | - return __( 'Form template was Successfully Created', 'formidable' ); |
|
214 | - } |
|
213 | + return __( 'Form template was Successfully Created', 'formidable' ); |
|
214 | + } |
|
215 | 215 | |
216 | 216 | /** |
217 | 217 | * Redirect to the url for creating from a template |
@@ -233,45 +233,45 @@ discard block |
||
233 | 233 | wp_die(); |
234 | 234 | } |
235 | 235 | |
236 | - public static function duplicate() { |
|
237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
236 | + public static function duplicate() { |
|
237 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
238 | 238 | |
239 | 239 | $params = FrmForm::list_page_params(); |
240 | - $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
242 | - if ( $form ) { |
|
240 | + $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
|
241 | + $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
242 | + if ( $form ) { |
|
243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
244 | - } else { |
|
245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
246 | - } |
|
247 | - } |
|
244 | + } else { |
|
245 | + return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - public static function page_preview() { |
|
249 | + public static function page_preview() { |
|
250 | 250 | $params = FrmForm::list_page_params(); |
251 | - if ( ! $params['form'] ) { |
|
252 | - return; |
|
253 | - } |
|
254 | - |
|
255 | - $form = FrmForm::getOne( $params['form'] ); |
|
256 | - if ( ! $form ) { |
|
257 | - return; |
|
258 | - } |
|
259 | - return self::show_form( $form->id, '', true, true ); |
|
260 | - } |
|
261 | - |
|
262 | - public static function preview() { |
|
263 | - do_action( 'frm_wp' ); |
|
264 | - |
|
265 | - global $frm_vars; |
|
266 | - $frm_vars['preview'] = true; |
|
267 | - |
|
268 | - if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
269 | - global $wp; |
|
270 | - $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
251 | + if ( ! $params['form'] ) { |
|
252 | + return; |
|
253 | + } |
|
254 | + |
|
255 | + $form = FrmForm::getOne( $params['form'] ); |
|
256 | + if ( ! $form ) { |
|
257 | + return; |
|
258 | + } |
|
259 | + return self::show_form( $form->id, '', true, true ); |
|
260 | + } |
|
261 | + |
|
262 | + public static function preview() { |
|
263 | + do_action( 'frm_wp' ); |
|
264 | + |
|
265 | + global $frm_vars; |
|
266 | + $frm_vars['preview'] = true; |
|
267 | + |
|
268 | + if ( ! defined( 'ABSPATH' ) && ! defined( 'XMLRPC_REQUEST' ) ) { |
|
269 | + global $wp; |
|
270 | + $root = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ); |
|
271 | 271 | include_once( $root . '/wp-config.php' ); |
272 | - $wp->init(); |
|
273 | - $wp->register_globals(); |
|
274 | - } |
|
272 | + $wp->init(); |
|
273 | + $wp->register_globals(); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | self::register_pro_scripts(); |
277 | 277 | |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 ); |
286 | 286 | if ( empty( $form ) ) { |
287 | 287 | $form = FrmForm::getAll( array(), '', 1 ); |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | 290 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php' ); |
291 | - wp_die(); |
|
292 | - } |
|
291 | + wp_die(); |
|
292 | + } |
|
293 | 293 | |
294 | 294 | public static function register_pro_scripts() { |
295 | 295 | if ( FrmAppHelper::pro_is_installed() ) { |
@@ -300,22 +300,22 @@ discard block |
||
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | - public static function untrash() { |
|
303 | + public static function untrash() { |
|
304 | 304 | self::change_form_status( 'untrash' ); |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | 307 | public static function bulk_untrash( $ids ) { |
308 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
308 | + FrmAppHelper::permission_check('frm_edit_forms'); |
|
309 | 309 | |
310 | - $count = FrmForm::set_status( $ids, 'published' ); |
|
310 | + $count = FrmForm::set_status( $ids, 'published' ); |
|
311 | 311 | |
312 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
313 | - return $message; |
|
314 | - } |
|
312 | + $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
313 | + return $message; |
|
314 | + } |
|
315 | 315 | |
316 | - public static function trash() { |
|
316 | + public static function trash() { |
|
317 | 317 | self::change_form_status( 'trash' ); |
318 | - } |
|
318 | + } |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * @param string $status |
@@ -353,68 +353,68 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | public static function bulk_trash( $ids ) { |
356 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
356 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
357 | 357 | |
358 | - $count = 0; |
|
359 | - foreach ( $ids as $id ) { |
|
360 | - if ( FrmForm::trash( $id ) ) { |
|
361 | - $count++; |
|
362 | - } |
|
363 | - } |
|
358 | + $count = 0; |
|
359 | + foreach ( $ids as $id ) { |
|
360 | + if ( FrmForm::trash( $id ) ) { |
|
361 | + $count++; |
|
362 | + } |
|
363 | + } |
|
364 | 364 | |
365 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
365 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
366 | 366 | $message = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=list&action=bulk_untrash&form_type=' . $current_page . '&item-action=' . implode( ',', $ids ), 'bulk-toplevel_page_formidable' ) ) . '">', '</a>' ); |
367 | 367 | |
368 | - return $message; |
|
369 | - } |
|
368 | + return $message; |
|
369 | + } |
|
370 | 370 | |
371 | - public static function destroy() { |
|
372 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
371 | + public static function destroy() { |
|
372 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
373 | 373 | |
374 | 374 | $params = FrmForm::list_page_params(); |
375 | 375 | |
376 | - //check nonce url |
|
377 | - check_admin_referer('destroy_form_' . $params['id']); |
|
376 | + //check nonce url |
|
377 | + check_admin_referer('destroy_form_' . $params['id']); |
|
378 | 378 | |
379 | - $count = 0; |
|
380 | - if ( FrmForm::destroy( $params['id'] ) ) { |
|
381 | - $count++; |
|
382 | - } |
|
379 | + $count = 0; |
|
380 | + if ( FrmForm::destroy( $params['id'] ) ) { |
|
381 | + $count++; |
|
382 | + } |
|
383 | 383 | |
384 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
384 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
385 | 385 | |
386 | 386 | self::display_forms_list( $params, $message ); |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | 389 | public static function bulk_destroy( $ids ) { |
390 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
390 | + FrmAppHelper::permission_check('frm_delete_forms'); |
|
391 | 391 | |
392 | - $count = 0; |
|
393 | - foreach ( $ids as $id ) { |
|
394 | - $d = FrmForm::destroy( $id ); |
|
395 | - if ( $d ) { |
|
396 | - $count++; |
|
397 | - } |
|
398 | - } |
|
392 | + $count = 0; |
|
393 | + foreach ( $ids as $id ) { |
|
394 | + $d = FrmForm::destroy( $id ); |
|
395 | + if ( $d ) { |
|
396 | + $count++; |
|
397 | + } |
|
398 | + } |
|
399 | 399 | |
400 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
400 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
401 | 401 | |
402 | - return $message; |
|
403 | - } |
|
402 | + return $message; |
|
403 | + } |
|
404 | 404 | |
405 | - private static function delete_all() { |
|
406 | - //check nonce url |
|
407 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
408 | - if ( $permission_error !== false ) { |
|
405 | + private static function delete_all() { |
|
406 | + //check nonce url |
|
407 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
408 | + if ( $permission_error !== false ) { |
|
409 | 409 | self::display_forms_list( array(), '', array( $permission_error ) ); |
410 | - return; |
|
411 | - } |
|
410 | + return; |
|
411 | + } |
|
412 | 412 | |
413 | 413 | $count = FrmForm::scheduled_delete( time() ); |
414 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
414 | + $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
415 | 415 | |
416 | 416 | self::display_forms_list( array(), $message ); |
417 | - } |
|
417 | + } |
|
418 | 418 | |
419 | 419 | public static function scheduled_delete( $delete_timestamp = '' ) { |
420 | 420 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::scheduled_delete' ); |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
425 | - * Inserts Formidable button |
|
426 | - * Hook exists since 2.5.0 |
|
427 | - * |
|
428 | - * @since 2.0.15 |
|
429 | - */ |
|
425 | + * Inserts Formidable button |
|
426 | + * Hook exists since 2.5.0 |
|
427 | + * |
|
428 | + * @since 2.0.15 |
|
429 | + */ |
|
430 | 430 | public static function insert_form_button() { |
431 | 431 | if ( current_user_can('frm_view_forms') ) { |
432 | 432 | $menu_name = FrmAppHelper::get_menu_name(); |
@@ -437,49 +437,49 @@ discard block |
||
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | - public static function insert_form_popup() { |
|
440 | + public static function insert_form_popup() { |
|
441 | 441 | $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) ); |
442 | 442 | if ( ! in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ) ) ) { |
443 | - return; |
|
444 | - } |
|
443 | + return; |
|
444 | + } |
|
445 | 445 | |
446 | - FrmAppHelper::load_admin_wide_js(); |
|
446 | + FrmAppHelper::load_admin_wide_js(); |
|
447 | 447 | |
448 | - $shortcodes = array( |
|
448 | + $shortcodes = array( |
|
449 | 449 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
450 | - ); |
|
450 | + ); |
|
451 | 451 | |
452 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
452 | + $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
453 | 453 | |
454 | 454 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
455 | - } |
|
455 | + } |
|
456 | 456 | |
457 | - public static function get_shortcode_opts() { |
|
457 | + public static function get_shortcode_opts() { |
|
458 | 458 | FrmAppHelper::permission_check('frm_view_forms'); |
459 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
459 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
460 | 460 | |
461 | 461 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
462 | - if ( empty($shortcode) ) { |
|
463 | - wp_die(); |
|
464 | - } |
|
462 | + if ( empty($shortcode) ) { |
|
463 | + wp_die(); |
|
464 | + } |
|
465 | 465 | |
466 | 466 | echo '<div id="sc-opts-' . esc_attr( $shortcode ) . '" class="frm_shortcode_option">'; |
467 | 467 | echo '<input type="radio" name="frmsc" value="' . esc_attr( $shortcode ) . '" id="sc-' . esc_attr( $shortcode ) . '" class="frm_hidden" />'; |
468 | 468 | |
469 | - $form_id = ''; |
|
470 | - $opts = array(); |
|
469 | + $form_id = ''; |
|
470 | + $opts = array(); |
|
471 | 471 | switch ( $shortcode ) { |
472 | - case 'formidable': |
|
473 | - $opts = array( |
|
472 | + case 'formidable': |
|
473 | + $opts = array( |
|
474 | 474 | 'form_id' => 'id', |
475 | - //'key' => ', |
|
475 | + //'key' => ', |
|
476 | 476 | 'title' => array( 'val' => 1, 'label' => __( 'Display form title', 'formidable' ) ), |
477 | 477 | 'description' => array( 'val' => 1, 'label' => __( 'Display form description', 'formidable' ) ), |
478 | 478 | 'minimize' => array( 'val' => 1, 'label' => __( 'Minimize form HTML', 'formidable' ) ), |
479 | - ); |
|
480 | - break; |
|
481 | - } |
|
482 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
479 | + ); |
|
480 | + break; |
|
481 | + } |
|
482 | + $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
483 | 483 | |
484 | 484 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
485 | 485 | // allow other shortcodes to use the required form id option |
@@ -489,61 +489,61 @@ discard block |
||
489 | 489 | |
490 | 490 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/shortcode_opts.php' ); |
491 | 491 | |
492 | - echo '</div>'; |
|
492 | + echo '</div>'; |
|
493 | 493 | |
494 | - wp_die(); |
|
495 | - } |
|
494 | + wp_die(); |
|
495 | + } |
|
496 | 496 | |
497 | 497 | public static function display_forms_list( $params = array(), $message = '', $errors = array(), $deprecated_errors = array() ) { |
498 | - FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
498 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
499 | 499 | if ( ! empty( $deprecated_errors ) ) { |
500 | 500 | $errors = $deprecated_errors; |
501 | 501 | _deprecated_argument( 'errors', '2.0.8' ); |
502 | 502 | } |
503 | 503 | |
504 | - global $wpdb, $frm_vars; |
|
504 | + global $wpdb, $frm_vars; |
|
505 | 505 | |
506 | 506 | if ( empty( $params ) ) { |
507 | 507 | $params = FrmForm::list_page_params(); |
508 | - } |
|
508 | + } |
|
509 | 509 | |
510 | - $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
510 | + $wp_list_table = new FrmFormsListHelper( compact( 'params' ) ); |
|
511 | 511 | |
512 | - $pagenum = $wp_list_table->get_pagenum(); |
|
512 | + $pagenum = $wp_list_table->get_pagenum(); |
|
513 | 513 | |
514 | - $wp_list_table->prepare_items(); |
|
514 | + $wp_list_table->prepare_items(); |
|
515 | 515 | |
516 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
517 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
516 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
517 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
518 | 518 | wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) ); |
519 | - die(); |
|
520 | - } |
|
519 | + die(); |
|
520 | + } |
|
521 | 521 | |
522 | 522 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php' ); |
523 | - } |
|
523 | + } |
|
524 | 524 | |
525 | 525 | public static function get_columns( $columns ) { |
526 | - $columns['cb'] = '<input type="checkbox" />'; |
|
527 | - $columns['id'] = 'ID'; |
|
526 | + $columns['cb'] = '<input type="checkbox" />'; |
|
527 | + $columns['id'] = 'ID'; |
|
528 | 528 | |
529 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
529 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : 'published'; |
|
530 | 530 | |
531 | - if ( 'template' == $type ) { |
|
532 | - $columns['name'] = __( 'Template Name', 'formidable' ); |
|
533 | - $columns['type'] = __( 'Type', 'formidable' ); |
|
534 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
535 | - } else { |
|
536 | - $columns['name'] = __( 'Form Title', 'formidable' ); |
|
537 | - $columns['entries'] = __( 'Entries', 'formidable' ); |
|
538 | - $columns['form_key'] = __( 'Key', 'formidable' ); |
|
539 | - $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
540 | - } |
|
531 | + if ( 'template' == $type ) { |
|
532 | + $columns['name'] = __( 'Template Name', 'formidable' ); |
|
533 | + $columns['type'] = __( 'Type', 'formidable' ); |
|
534 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
535 | + } else { |
|
536 | + $columns['name'] = __( 'Form Title', 'formidable' ); |
|
537 | + $columns['entries'] = __( 'Entries', 'formidable' ); |
|
538 | + $columns['form_key'] = __( 'Key', 'formidable' ); |
|
539 | + $columns['shortcode'] = __( 'Shortcodes', 'formidable' ); |
|
540 | + } |
|
541 | 541 | |
542 | - $columns['created_at'] = __( 'Date', 'formidable' ); |
|
542 | + $columns['created_at'] = __( 'Date', 'formidable' ); |
|
543 | 543 | |
544 | 544 | add_screen_option( 'per_page', array( 'label' => __( 'Forms', 'formidable' ), 'default' => 20, 'option' => 'formidable_page_formidable_per_page' ) ); |
545 | 545 | |
546 | - return $columns; |
|
546 | + return $columns; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | public static function get_sortable_columns() { |
@@ -557,111 +557,111 @@ discard block |
||
557 | 557 | } |
558 | 558 | |
559 | 559 | public static function hidden_columns( $result ) { |
560 | - $return = false; |
|
561 | - foreach ( (array) $result as $r ) { |
|
562 | - if ( ! empty( $r ) ) { |
|
563 | - $return = true; |
|
564 | - break; |
|
565 | - } |
|
566 | - } |
|
560 | + $return = false; |
|
561 | + foreach ( (array) $result as $r ) { |
|
562 | + if ( ! empty( $r ) ) { |
|
563 | + $return = true; |
|
564 | + break; |
|
565 | + } |
|
566 | + } |
|
567 | 567 | |
568 | - if ( $return ) { |
|
569 | - return $result; |
|
568 | + if ( $return ) { |
|
569 | + return $result; |
|
570 | 570 | } |
571 | 571 | |
572 | - $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
572 | + $type = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
573 | 573 | |
574 | - $result[] = 'created_at'; |
|
575 | - if ( $type == 'template' ) { |
|
576 | - $result[] = 'id'; |
|
577 | - $result[] = 'form_key'; |
|
578 | - } |
|
574 | + $result[] = 'created_at'; |
|
575 | + if ( $type == 'template' ) { |
|
576 | + $result[] = 'id'; |
|
577 | + $result[] = 'form_key'; |
|
578 | + } |
|
579 | 579 | |
580 | - return $result; |
|
581 | - } |
|
580 | + return $result; |
|
581 | + } |
|
582 | 582 | |
583 | 583 | public static function save_per_page( $save, $option, $value ) { |
584 | - if ( $option == 'formidable_page_formidable_per_page' ) { |
|
585 | - $save = (int) $value; |
|
586 | - } |
|
587 | - return $save; |
|
588 | - } |
|
584 | + if ( $option == 'formidable_page_formidable_per_page' ) { |
|
585 | + $save = (int) $value; |
|
586 | + } |
|
587 | + return $save; |
|
588 | + } |
|
589 | 589 | |
590 | 590 | private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { |
591 | - global $frm_vars; |
|
591 | + global $frm_vars; |
|
592 | 592 | |
593 | - $form = FrmForm::getOne( $id ); |
|
594 | - if ( ! $form ) { |
|
595 | - wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
596 | - } |
|
593 | + $form = FrmForm::getOne( $id ); |
|
594 | + if ( ! $form ) { |
|
595 | + wp_die( __( 'You are trying to edit a form that does not exist.', 'formidable' ) ); |
|
596 | + } |
|
597 | 597 | |
598 | - if ( $form->parent_form_id ) { |
|
598 | + if ( $form->parent_form_id ) { |
|
599 | 599 | wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' )); |
600 | - } |
|
600 | + } |
|
601 | 601 | |
602 | 602 | $frm_field_selection = FrmField::field_selection(); |
603 | - $fields = FrmField::get_all_for_form($form->id); |
|
603 | + $fields = FrmField::get_all_for_form($form->id); |
|
604 | 604 | |
605 | - // Automatically add end section fields if they don't exist (2.0 migration) |
|
606 | - $reset_fields = false; |
|
607 | - FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
605 | + // Automatically add end section fields if they don't exist (2.0 migration) |
|
606 | + $reset_fields = false; |
|
607 | + FrmFormsHelper::auto_add_end_section_fields( $form, $fields, $reset_fields ); |
|
608 | 608 | |
609 | - if ( $reset_fields ) { |
|
610 | - $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
611 | - } |
|
609 | + if ( $reset_fields ) { |
|
610 | + $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
|
611 | + } |
|
612 | 612 | |
613 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
613 | + unset($end_section_values, $last_order, $open, $reset_fields); |
|
614 | 614 | |
615 | 615 | $args = array( 'parent_form_id' => $form->id ); |
616 | - $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
616 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
|
617 | 617 | |
618 | - $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
619 | - if ( $form->is_template && $message == $edit_message ) { |
|
620 | - $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
621 | - } |
|
618 | + $edit_message = __( 'Form was Successfully Updated', 'formidable' ); |
|
619 | + if ( $form->is_template && $message == $edit_message ) { |
|
620 | + $message = __( 'Template was Successfully Updated', 'formidable' ); |
|
621 | + } |
|
622 | 622 | |
623 | 623 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
624 | 624 | |
625 | - if ( $form->default_template ) { |
|
626 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
627 | - } else if ( defined('DOING_AJAX') ) { |
|
628 | - wp_die(); |
|
629 | - } else if ( $create_link ) { |
|
625 | + if ( $form->default_template ) { |
|
626 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
627 | + } else if ( defined('DOING_AJAX') ) { |
|
628 | + wp_die(); |
|
629 | + } else if ( $create_link ) { |
|
630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
631 | - } else { |
|
631 | + } else { |
|
632 | 632 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php' ); |
633 | - } |
|
634 | - } |
|
633 | + } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | public static function get_settings_vars( $id, $errors = array(), $message = '' ) { |
637 | 637 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
638 | 638 | |
639 | - global $frm_vars; |
|
639 | + global $frm_vars; |
|
640 | 640 | |
641 | - $form = FrmForm::getOne( $id ); |
|
641 | + $form = FrmForm::getOne( $id ); |
|
642 | 642 | |
643 | - $fields = FrmField::get_all_for_form($id); |
|
644 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
643 | + $fields = FrmField::get_all_for_form($id); |
|
644 | + $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
645 | 645 | |
646 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
647 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
648 | - } |
|
646 | + if ( isset($values['default_template']) && $values['default_template'] ) { |
|
647 | + wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
648 | + } |
|
649 | 649 | |
650 | - $action_controls = FrmFormActionsController::get_form_actions(); |
|
650 | + $action_controls = FrmFormActionsController::get_form_actions(); |
|
651 | 651 | |
652 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
653 | - $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
652 | + $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
653 | + $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
|
654 | 654 | |
655 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
655 | + $styles = apply_filters('frm_get_style_opts', array()); |
|
656 | 656 | |
657 | 657 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
658 | - } |
|
658 | + } |
|
659 | 659 | |
660 | - public static function mb_tags_box( $form_id, $class = '' ) { |
|
661 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
662 | - $linked_forms = array(); |
|
663 | - $col = 'one'; |
|
664 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
660 | + public static function mb_tags_box( $form_id, $class = '' ) { |
|
661 | + $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
662 | + $linked_forms = array(); |
|
663 | + $col = 'one'; |
|
664 | + $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
665 | 665 | |
666 | 666 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
667 | 667 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | $entry_shortcodes = self::get_shortcode_helpers( $settings_tab ); |
670 | 670 | |
671 | 671 | include( FrmAppHelper::plugin_path() . '/classes/views/shared/mb_adv_info.php' ); |
672 | - } |
|
672 | + } |
|
673 | 673 | |
674 | 674 | /** |
675 | 675 | * Get an array of the options to display in the advanced tab |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | '' => '', |
711 | 711 | 'siteurl' => __( 'Site URL', 'formidable' ), |
712 | 712 | 'sitename' => __( 'Site Name', 'formidable' ), |
713 | - ); |
|
713 | + ); |
|
714 | 714 | |
715 | 715 | if ( ! FrmAppHelper::pro_is_installed() ) { |
716 | 716 | unset( $entry_shortcodes['post_id'] ); |
@@ -737,39 +737,39 @@ discard block |
||
737 | 737 | return $entry_shortcodes; |
738 | 738 | } |
739 | 739 | |
740 | - // Insert the form class setting into the form |
|
740 | + // Insert the form class setting into the form |
|
741 | 741 | public static function form_classes( $form ) { |
742 | - if ( isset($form->options['form_class']) ) { |
|
742 | + if ( isset($form->options['form_class']) ) { |
|
743 | 743 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
744 | - } |
|
745 | - } |
|
744 | + } |
|
745 | + } |
|
746 | 746 | |
747 | - public static function get_email_html() { |
|
747 | + public static function get_email_html() { |
|
748 | 748 | FrmAppHelper::permission_check('frm_view_forms'); |
749 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
749 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
750 | 750 | echo FrmEntryFormat::show_entry( array( |
751 | 751 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
752 | - 'default_email' => true, |
|
752 | + 'default_email' => true, |
|
753 | 753 | 'plain_text' => FrmAppHelper::get_post_param( 'plain_text', '', 'absint' ), |
754 | - ) ); |
|
755 | - wp_die(); |
|
754 | + ) ); |
|
755 | + wp_die(); |
|
756 | 756 | } |
757 | 757 | |
758 | - public static function filter_content( $content, $form, $entry = false ) { |
|
758 | + public static function filter_content( $content, $form, $entry = false ) { |
|
759 | 759 | self::get_entry_by_param( $entry ); |
760 | - if ( ! $entry ) { |
|
761 | - return $content; |
|
762 | - } |
|
760 | + if ( ! $entry ) { |
|
761 | + return $content; |
|
762 | + } |
|
763 | 763 | |
764 | - if ( is_object( $form ) ) { |
|
765 | - $form = $form->id; |
|
766 | - } |
|
764 | + if ( is_object( $form ) ) { |
|
765 | + $form = $form->id; |
|
766 | + } |
|
767 | 767 | |
768 | - $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
769 | - $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
768 | + $shortcodes = FrmFieldsHelper::get_shortcodes( $content, $form ); |
|
769 | + $content = apply_filters( 'frm_replace_content_shortcodes', $content, $entry, $shortcodes ); |
|
770 | 770 | |
771 | - return $content; |
|
772 | - } |
|
771 | + return $content; |
|
772 | + } |
|
773 | 773 | |
774 | 774 | private static function get_entry_by_param( &$entry ) { |
775 | 775 | if ( ! $entry || ! is_object( $entry ) ) { |
@@ -781,287 +781,287 @@ discard block |
||
781 | 781 | } |
782 | 782 | } |
783 | 783 | |
784 | - public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
785 | - return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
786 | - } |
|
784 | + public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
|
785 | + return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes ); |
|
786 | + } |
|
787 | 787 | |
788 | - public static function process_bulk_form_actions( $errors ) { |
|
789 | - if ( ! $_REQUEST ) { |
|
790 | - return $errors; |
|
791 | - } |
|
788 | + public static function process_bulk_form_actions( $errors ) { |
|
789 | + if ( ! $_REQUEST ) { |
|
790 | + return $errors; |
|
791 | + } |
|
792 | 792 | |
793 | 793 | $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
794 | - if ( $bulkaction == -1 ) { |
|
794 | + if ( $bulkaction == -1 ) { |
|
795 | 795 | $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
796 | - } |
|
797 | - |
|
798 | - if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
799 | - FrmAppHelper::remove_get_action(); |
|
800 | - |
|
801 | - $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
802 | - } |
|
803 | - |
|
804 | - $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
805 | - if ( empty( $ids ) ) { |
|
806 | - $errors[] = __( 'No forms were specified', 'formidable' ); |
|
807 | - return $errors; |
|
808 | - } |
|
809 | - |
|
810 | - $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
811 | - if ( $permission_error !== false ) { |
|
812 | - $errors[] = $permission_error; |
|
813 | - return $errors; |
|
814 | - } |
|
815 | - |
|
816 | - if ( ! is_array( $ids ) ) { |
|
817 | - $ids = explode( ',', $ids ); |
|
818 | - } |
|
819 | - |
|
820 | - switch ( $bulkaction ) { |
|
821 | - case 'delete': |
|
822 | - $message = self::bulk_destroy( $ids ); |
|
823 | - break; |
|
824 | - case 'trash': |
|
825 | - $message = self::bulk_trash( $ids ); |
|
826 | - break; |
|
827 | - case 'untrash': |
|
828 | - $message = self::bulk_untrash( $ids ); |
|
829 | - break; |
|
830 | - case 'create_template': |
|
831 | - $message = self::bulk_create_template( $ids ); |
|
832 | - break; |
|
833 | - } |
|
834 | - |
|
835 | - if ( isset( $message ) && ! empty( $message ) ) { |
|
796 | + } |
|
797 | + |
|
798 | + if ( ! empty( $bulkaction ) && strpos( $bulkaction, 'bulk_' ) === 0 ) { |
|
799 | + FrmAppHelper::remove_get_action(); |
|
800 | + |
|
801 | + $bulkaction = str_replace( 'bulk_', '', $bulkaction ); |
|
802 | + } |
|
803 | + |
|
804 | + $ids = FrmAppHelper::get_param( 'item-action', '' ); |
|
805 | + if ( empty( $ids ) ) { |
|
806 | + $errors[] = __( 'No forms were specified', 'formidable' ); |
|
807 | + return $errors; |
|
808 | + } |
|
809 | + |
|
810 | + $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
811 | + if ( $permission_error !== false ) { |
|
812 | + $errors[] = $permission_error; |
|
813 | + return $errors; |
|
814 | + } |
|
815 | + |
|
816 | + if ( ! is_array( $ids ) ) { |
|
817 | + $ids = explode( ',', $ids ); |
|
818 | + } |
|
819 | + |
|
820 | + switch ( $bulkaction ) { |
|
821 | + case 'delete': |
|
822 | + $message = self::bulk_destroy( $ids ); |
|
823 | + break; |
|
824 | + case 'trash': |
|
825 | + $message = self::bulk_trash( $ids ); |
|
826 | + break; |
|
827 | + case 'untrash': |
|
828 | + $message = self::bulk_untrash( $ids ); |
|
829 | + break; |
|
830 | + case 'create_template': |
|
831 | + $message = self::bulk_create_template( $ids ); |
|
832 | + break; |
|
833 | + } |
|
834 | + |
|
835 | + if ( isset( $message ) && ! empty( $message ) ) { |
|
836 | 836 | echo '<div id="message" class="updated frm_msg_padding">' . FrmAppHelper::kses( $message, array( 'a' ) ) . '</div>'; |
837 | - } |
|
837 | + } |
|
838 | 838 | |
839 | - return $errors; |
|
840 | - } |
|
839 | + return $errors; |
|
840 | + } |
|
841 | 841 | |
842 | - public static function add_default_templates( $path, $default = true, $template = true ) { |
|
843 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
842 | + public static function add_default_templates( $path, $default = true, $template = true ) { |
|
843 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
|
844 | 844 | |
845 | - $path = untrailingslashit(trim($path)); |
|
845 | + $path = untrailingslashit(trim($path)); |
|
846 | 846 | $templates = glob( $path . '/*.php' ); |
847 | 847 | |
848 | 848 | for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
849 | 849 | $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
850 | 850 | $template_query = array( 'form_key' => $filename ); |
851 | - if ( $template ) { |
|
852 | - $template_query['is_template'] = 1; |
|
853 | - } |
|
854 | - if ( $default ) { |
|
855 | - $template_query['default_template'] = 1; |
|
856 | - } |
|
851 | + if ( $template ) { |
|
852 | + $template_query['is_template'] = 1; |
|
853 | + } |
|
854 | + if ( $default ) { |
|
855 | + $template_query['default_template'] = 1; |
|
856 | + } |
|
857 | 857 | $form = FrmForm::getAll( $template_query, '', 1 ); |
858 | 858 | |
859 | - $values = FrmFormsHelper::setup_new_vars(); |
|
860 | - $values['form_key'] = $filename; |
|
861 | - $values['is_template'] = $template; |
|
862 | - $values['status'] = 'published'; |
|
863 | - if ( $default ) { |
|
864 | - $values['default_template'] = 1; |
|
865 | - } |
|
866 | - |
|
867 | - include( $templates[ $i ] ); |
|
868 | - |
|
869 | - //get updated form |
|
870 | - if ( isset($form) && ! empty($form) ) { |
|
871 | - $old_id = $form->id; |
|
872 | - $form = FrmForm::getOne($form->id); |
|
873 | - } else { |
|
874 | - $old_id = false; |
|
859 | + $values = FrmFormsHelper::setup_new_vars(); |
|
860 | + $values['form_key'] = $filename; |
|
861 | + $values['is_template'] = $template; |
|
862 | + $values['status'] = 'published'; |
|
863 | + if ( $default ) { |
|
864 | + $values['default_template'] = 1; |
|
865 | + } |
|
866 | + |
|
867 | + include( $templates[ $i ] ); |
|
868 | + |
|
869 | + //get updated form |
|
870 | + if ( isset($form) && ! empty($form) ) { |
|
871 | + $old_id = $form->id; |
|
872 | + $form = FrmForm::getOne($form->id); |
|
873 | + } else { |
|
874 | + $old_id = false; |
|
875 | 875 | $form = FrmForm::getAll( $template_query, '', 1 ); |
876 | - } |
|
876 | + } |
|
877 | 877 | |
878 | - if ( $form ) { |
|
878 | + if ( $form ) { |
|
879 | 879 | do_action( 'frm_after_duplicate_form', $form->id, (array) $form, array( 'old_id' => $old_id ) ); |
880 | - } |
|
881 | - } |
|
882 | - } |
|
880 | + } |
|
881 | + } |
|
882 | + } |
|
883 | 883 | |
884 | - public static function route() { |
|
885 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
886 | - $vars = array(); |
|
884 | + public static function route() { |
|
885 | + $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
886 | + $vars = array(); |
|
887 | 887 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
888 | 888 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
889 | 889 | |
890 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
891 | - $json_vars = json_decode($json_vars, true); |
|
892 | - if ( empty($json_vars) ) { |
|
893 | - // json decoding failed so we should return an error message |
|
890 | + $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
891 | + $json_vars = json_decode($json_vars, true); |
|
892 | + if ( empty($json_vars) ) { |
|
893 | + // json decoding failed so we should return an error message |
|
894 | 894 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
895 | - if ( 'edit' == $action ) { |
|
896 | - $action = 'update'; |
|
897 | - } |
|
898 | - |
|
899 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
900 | - } else { |
|
901 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
902 | - $action = $vars[ $action ]; |
|
895 | + if ( 'edit' == $action ) { |
|
896 | + $action = 'update'; |
|
897 | + } |
|
898 | + |
|
899 | + add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
900 | + } else { |
|
901 | + $vars = FrmAppHelper::json_to_array($json_vars); |
|
902 | + $action = $vars[ $action ]; |
|
903 | 903 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
904 | 904 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
905 | 905 | $_POST = array_merge( $_POST, $_REQUEST ); |
906 | - } |
|
907 | - } else { |
|
906 | + } |
|
907 | + } else { |
|
908 | 908 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
909 | - if ( isset( $_REQUEST['delete_all'] ) ) { |
|
910 | - // override the action for this page |
|
911 | - $action = 'delete_all'; |
|
912 | - } |
|
913 | - } |
|
909 | + if ( isset( $_REQUEST['delete_all'] ) ) { |
|
910 | + // override the action for this page |
|
911 | + $action = 'delete_all'; |
|
912 | + } |
|
913 | + } |
|
914 | 914 | |
915 | 915 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
916 | - FrmAppHelper::trigger_hook_load( 'form' ); |
|
917 | - |
|
918 | - switch ( $action ) { |
|
919 | - case 'new': |
|
920 | - return self::new_form($vars); |
|
921 | - case 'create': |
|
922 | - case 'edit': |
|
923 | - case 'update': |
|
924 | - case 'duplicate': |
|
925 | - case 'trash': |
|
926 | - case 'untrash': |
|
927 | - case 'destroy': |
|
928 | - case 'delete_all': |
|
929 | - case 'settings': |
|
930 | - case 'update_settings': |
|
916 | + FrmAppHelper::trigger_hook_load( 'form' ); |
|
917 | + |
|
918 | + switch ( $action ) { |
|
919 | + case 'new': |
|
920 | + return self::new_form($vars); |
|
921 | + case 'create': |
|
922 | + case 'edit': |
|
923 | + case 'update': |
|
924 | + case 'duplicate': |
|
925 | + case 'trash': |
|
926 | + case 'untrash': |
|
927 | + case 'destroy': |
|
928 | + case 'delete_all': |
|
929 | + case 'settings': |
|
930 | + case 'update_settings': |
|
931 | 931 | return self::$action( $vars ); |
932 | - default: |
|
932 | + default: |
|
933 | 933 | do_action( 'frm_form_action_' . $action ); |
934 | 934 | if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) { |
935 | - return; |
|
936 | - } |
|
935 | + return; |
|
936 | + } |
|
937 | 937 | |
938 | 938 | $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' ); |
939 | - if ( $action == -1 ) { |
|
939 | + if ( $action == -1 ) { |
|
940 | 940 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
941 | - } |
|
941 | + } |
|
942 | 942 | |
943 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
944 | - FrmAppHelper::remove_get_action(); |
|
945 | - return self::list_form(); |
|
946 | - } |
|
943 | + if ( strpos($action, 'bulk_') === 0 ) { |
|
944 | + FrmAppHelper::remove_get_action(); |
|
945 | + return self::list_form(); |
|
946 | + } |
|
947 | 947 | |
948 | - return self::display_forms_list(); |
|
949 | - } |
|
950 | - } |
|
948 | + return self::display_forms_list(); |
|
949 | + } |
|
950 | + } |
|
951 | 951 | |
952 | - public static function json_error( $errors ) { |
|
953 | - $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
954 | - return $errors; |
|
955 | - } |
|
952 | + public static function json_error( $errors ) { |
|
953 | + $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
|
954 | + return $errors; |
|
955 | + } |
|
956 | 956 | |
957 | 957 | |
958 | - /* FRONT-END FORMS */ |
|
959 | - public static function admin_bar_css() { |
|
958 | + /* FRONT-END FORMS */ |
|
959 | + public static function admin_bar_css() { |
|
960 | 960 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
961 | - return; |
|
962 | - } |
|
961 | + return; |
|
962 | + } |
|
963 | 963 | |
964 | 964 | add_action( 'wp_before_admin_bar_render', 'FrmFormsController::admin_bar_configure' ); |
965 | 965 | FrmAppHelper::load_font_style(); |
966 | 966 | } |
967 | 967 | |
968 | 968 | public static function admin_bar_configure() { |
969 | - global $frm_vars; |
|
970 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
971 | - return; |
|
972 | - } |
|
973 | - |
|
974 | - $actions = array(); |
|
975 | - foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
976 | - if ( is_object($form) ) { |
|
977 | - $actions[ $form->id ] = $form->name; |
|
978 | - } |
|
979 | - unset($form); |
|
980 | - } |
|
981 | - |
|
982 | - if ( empty($actions) ) { |
|
983 | - return; |
|
984 | - } |
|
985 | - |
|
986 | - asort($actions); |
|
987 | - |
|
988 | - global $wp_admin_bar; |
|
989 | - |
|
990 | - if ( count($actions) == 1 ) { |
|
991 | - $wp_admin_bar->add_menu( array( |
|
992 | - 'title' => 'Edit Form', |
|
969 | + global $frm_vars; |
|
970 | + if ( empty($frm_vars['forms_loaded']) ) { |
|
971 | + return; |
|
972 | + } |
|
973 | + |
|
974 | + $actions = array(); |
|
975 | + foreach ( $frm_vars['forms_loaded'] as $form ) { |
|
976 | + if ( is_object($form) ) { |
|
977 | + $actions[ $form->id ] = $form->name; |
|
978 | + } |
|
979 | + unset($form); |
|
980 | + } |
|
981 | + |
|
982 | + if ( empty($actions) ) { |
|
983 | + return; |
|
984 | + } |
|
985 | + |
|
986 | + asort($actions); |
|
987 | + |
|
988 | + global $wp_admin_bar; |
|
989 | + |
|
990 | + if ( count($actions) == 1 ) { |
|
991 | + $wp_admin_bar->add_menu( array( |
|
992 | + 'title' => 'Edit Form', |
|
993 | 993 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
994 | - 'id' => 'frm-forms', |
|
995 | - ) ); |
|
996 | - } else { |
|
997 | - $wp_admin_bar->add_menu( array( |
|
998 | - 'id' => 'frm-forms', |
|
999 | - 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
994 | + 'id' => 'frm-forms', |
|
995 | + ) ); |
|
996 | + } else { |
|
997 | + $wp_admin_bar->add_menu( array( |
|
998 | + 'id' => 'frm-forms', |
|
999 | + 'title' => '<span class="ab-icon"></span><span class="ab-label">' . __( 'Edit Forms', 'formidable' ) . '</span>', |
|
1000 | 1000 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
1001 | - 'meta' => array( |
|
1001 | + 'meta' => array( |
|
1002 | 1002 | 'title' => __( 'Edit Forms', 'formidable' ), |
1003 | - ), |
|
1004 | - ) ); |
|
1003 | + ), |
|
1004 | + ) ); |
|
1005 | 1005 | |
1006 | - foreach ( $actions as $form_id => $name ) { |
|
1006 | + foreach ( $actions as $form_id => $name ) { |
|
1007 | 1007 | |
1008 | - $wp_admin_bar->add_menu( array( |
|
1009 | - 'parent' => 'frm-forms', |
|
1008 | + $wp_admin_bar->add_menu( array( |
|
1009 | + 'parent' => 'frm-forms', |
|
1010 | 1010 | 'id' => 'edit_form_' . $form_id, |
1011 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
1011 | + 'title' => empty($name) ? __( '(no title)') : $name, |
|
1012 | 1012 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
1013 | - ) ); |
|
1014 | - } |
|
1015 | - } |
|
1016 | - } |
|
1013 | + ) ); |
|
1014 | + } |
|
1015 | + } |
|
1016 | + } |
|
1017 | 1017 | |
1018 | - //formidable shortcode |
|
1018 | + //formidable shortcode |
|
1019 | 1019 | public static function get_form_shortcode( $atts ) { |
1020 | - global $frm_vars; |
|
1021 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
1022 | - $sc = '[formidable'; |
|
1020 | + global $frm_vars; |
|
1021 | + if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
1022 | + $sc = '[formidable'; |
|
1023 | 1023 | if ( ! empty( $atts ) ) { |
1024 | 1024 | foreach ( $atts as $k => $v ) { |
1025 | 1025 | $sc .= ' ' . $k . '="' . esc_attr( $v ) . '"'; |
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | return $sc . ']'; |
1029 | - } |
|
1030 | - |
|
1031 | - $shortcode_atts = shortcode_atts( array( |
|
1032 | - 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
1033 | - 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
1034 | - 'exclude_fields' => array(), 'minimize' => false, |
|
1035 | - ), $atts); |
|
1036 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
1037 | - |
|
1038 | - return self::show_form( |
|
1039 | - $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
1040 | - $shortcode_atts['description'], $atts |
|
1041 | - ); |
|
1042 | - } |
|
1043 | - |
|
1044 | - public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
1045 | - if ( empty( $id ) ) { |
|
1046 | - $id = $key; |
|
1047 | - } |
|
1048 | - |
|
1049 | - // no form id or key set |
|
1050 | - if ( empty( $id ) ) { |
|
1051 | - return __( 'Please select a valid form', 'formidable' ); |
|
1052 | - } |
|
1053 | - |
|
1054 | - $form = FrmForm::getOne( $id ); |
|
1055 | - if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) { |
|
1056 | - return __( 'Please select a valid form', 'formidable' ); |
|
1057 | - } |
|
1029 | + } |
|
1030 | + |
|
1031 | + $shortcode_atts = shortcode_atts( array( |
|
1032 | + 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
|
1033 | + 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
|
1034 | + 'exclude_fields' => array(), 'minimize' => false, |
|
1035 | + ), $atts); |
|
1036 | + do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
1037 | + |
|
1038 | + return self::show_form( |
|
1039 | + $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
|
1040 | + $shortcode_atts['description'], $atts |
|
1041 | + ); |
|
1042 | + } |
|
1043 | + |
|
1044 | + public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) { |
|
1045 | + if ( empty( $id ) ) { |
|
1046 | + $id = $key; |
|
1047 | + } |
|
1048 | + |
|
1049 | + // no form id or key set |
|
1050 | + if ( empty( $id ) ) { |
|
1051 | + return __( 'Please select a valid form', 'formidable' ); |
|
1052 | + } |
|
1053 | + |
|
1054 | + $form = FrmForm::getOne( $id ); |
|
1055 | + if ( ! $form || $form->parent_form_id || $form->status == 'trash' ) { |
|
1056 | + return __( 'Please select a valid form', 'formidable' ); |
|
1057 | + } |
|
1058 | 1058 | |
1059 | 1059 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
1060 | - FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
1060 | + FrmAppHelper::trigger_hook_load( 'form', $form ); |
|
1061 | 1061 | |
1062 | - $form = apply_filters( 'frm_pre_display_form', $form ); |
|
1062 | + $form = apply_filters( 'frm_pre_display_form', $form ); |
|
1063 | 1063 | |
1064 | - $frm_settings = FrmAppHelper::get_settings(); |
|
1064 | + $frm_settings = FrmAppHelper::get_settings(); |
|
1065 | 1065 | |
1066 | 1066 | if ( self::is_viewable_draft_form( $form ) ) { |
1067 | 1067 | // don't show a draft form on a page |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | return $form; |
1085 | - } |
|
1085 | + } |
|
1086 | 1086 | |
1087 | 1087 | private static function is_viewable_draft_form( $form ) { |
1088 | 1088 | global $post; |
@@ -1098,98 +1098,98 @@ discard block |
||
1098 | 1098 | return $form->logged_in && get_current_user_id() && isset( $form->options['logged_in_role'] ) && $form->options['logged_in_role'] != '' && ! FrmAppHelper::user_has_permission( $form->options['logged_in_role'] ); |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - public static function get_form( $form, $title, $description, $atts = array() ) { |
|
1102 | - ob_start(); |
|
1101 | + public static function get_form( $form, $title, $description, $atts = array() ) { |
|
1102 | + ob_start(); |
|
1103 | 1103 | |
1104 | - self::get_form_contents( $form, $title, $description, $atts ); |
|
1104 | + self::get_form_contents( $form, $title, $description, $atts ); |
|
1105 | 1105 | self::enqueue_scripts( FrmForm::get_params( $form ) ); |
1106 | 1106 | |
1107 | - $contents = ob_get_contents(); |
|
1108 | - ob_end_clean(); |
|
1107 | + $contents = ob_get_contents(); |
|
1108 | + ob_end_clean(); |
|
1109 | 1109 | |
1110 | 1110 | self::maybe_minimize_form( $atts, $contents ); |
1111 | 1111 | |
1112 | - return $contents; |
|
1113 | - } |
|
1112 | + return $contents; |
|
1113 | + } |
|
1114 | 1114 | |
1115 | 1115 | public static function enqueue_scripts( $params ) { |
1116 | 1116 | do_action( 'frm_enqueue_form_scripts', $params ); |
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | public static function get_form_contents( $form, $title, $description, $atts ) { |
1120 | - global $frm_vars; |
|
1120 | + global $frm_vars; |
|
1121 | 1121 | |
1122 | - $frm_settings = FrmAppHelper::get_settings(); |
|
1122 | + $frm_settings = FrmAppHelper::get_settings(); |
|
1123 | 1123 | |
1124 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1124 | + $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1125 | 1125 | |
1126 | - $user_ID = get_current_user_id(); |
|
1126 | + $user_ID = get_current_user_id(); |
|
1127 | 1127 | $params = FrmForm::get_params( $form ); |
1128 | - $message = $errors = ''; |
|
1128 | + $message = $errors = ''; |
|
1129 | 1129 | |
1130 | - if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
1131 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
1132 | - } |
|
1130 | + if ( $params['posted_form_id'] == $form->id && $_POST ) { |
|
1131 | + $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
1132 | + } |
|
1133 | 1133 | |
1134 | 1134 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
1135 | - $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
1135 | + $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
|
1136 | 1136 | |
1137 | - if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
1138 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
1139 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
1140 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
1137 | + if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
|
1138 | + do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
1139 | + if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
1140 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
1141 | 1141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1142 | - } |
|
1143 | - return; |
|
1144 | - } |
|
1142 | + } |
|
1143 | + return; |
|
1144 | + } |
|
1145 | 1145 | |
1146 | - if ( ! empty($errors) ) { |
|
1147 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
1146 | + if ( ! empty($errors) ) { |
|
1147 | + $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
1148 | 1148 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1149 | - return; |
|
1150 | - } |
|
1149 | + return; |
|
1150 | + } |
|
1151 | 1151 | |
1152 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
1153 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
1154 | - return; |
|
1155 | - } |
|
1152 | + do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
1153 | + if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
1154 | + return; |
|
1155 | + } |
|
1156 | 1156 | |
1157 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
1158 | - $created = self::just_created_entry( $form->id ); |
|
1159 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create'); |
|
1157 | + $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
1158 | + $created = self::just_created_entry( $form->id ); |
|
1159 | + $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create'); |
|
1160 | 1160 | |
1161 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
1162 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
1161 | + if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
1162 | + do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
1163 | 1163 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
1164 | - return; |
|
1165 | - } |
|
1164 | + return; |
|
1165 | + } |
|
1166 | 1166 | |
1167 | - if ( $created && is_numeric($created) ) { |
|
1168 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1169 | - $class = 'frm_message'; |
|
1170 | - } else { |
|
1171 | - $message = $frm_settings->failed_msg; |
|
1172 | - $class = 'frm_error_style'; |
|
1173 | - } |
|
1167 | + if ( $created && is_numeric($created) ) { |
|
1168 | + $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1169 | + $class = 'frm_message'; |
|
1170 | + } else { |
|
1171 | + $message = $frm_settings->failed_msg; |
|
1172 | + $class = 'frm_error_style'; |
|
1173 | + } |
|
1174 | 1174 | |
1175 | 1175 | $message = FrmFormsHelper::get_success_message( array( |
1176 | 1176 | 'message' => $message, 'form' => $form, |
1177 | 1177 | 'entry_id' => $created, 'class' => $class, |
1178 | 1178 | ) ); |
1179 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
1179 | + $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
1180 | 1180 | |
1181 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
1181 | + if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
1182 | 1182 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1183 | - } else { |
|
1184 | - global $frm_vars; |
|
1183 | + } else { |
|
1184 | + global $frm_vars; |
|
1185 | 1185 | self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] ); |
1186 | 1186 | |
1187 | 1187 | $include_extra_container = 'frm_forms' . FrmFormsHelper::get_form_style_class( $values ); |
1188 | 1188 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php' ); |
1189 | - } |
|
1189 | + } |
|
1190 | 1190 | |
1191 | 1191 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
1192 | - } |
|
1192 | + } |
|
1193 | 1193 | |
1194 | 1194 | /** |
1195 | 1195 | * @since 2.2.7 |
@@ -1226,10 +1226,10 @@ discard block |
||
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | public static function defer_script_loading( $tag, $handle ) { |
1229 | - if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
1230 | - $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
1229 | + if ( 'recaptcha-api' == $handle && ! strpos( $tag, 'defer' ) ) { |
|
1230 | + $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag ); |
|
1231 | 1231 | } |
1232 | - return $tag; |
|
1232 | + return $tag; |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | public static function footer_js( $location = 'footer' ) { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | if ( ! FrmAppHelper::pro_is_installed() ) { |
8 | 8 | $menu_label .= ' (Lite)'; |
9 | 9 | } |
10 | - add_submenu_page('formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
10 | + add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' ); |
|
11 | 11 | |
12 | 12 | self::maybe_load_listing_hooks(); |
13 | 13 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | return; |
19 | 19 | } |
20 | 20 | |
21 | - add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
21 | + add_filter( 'get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' ); |
|
22 | 22 | |
23 | - add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
24 | - add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
23 | + add_filter( 'manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 ); |
|
24 | + add_filter( 'manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns' ); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function head() { |
28 | - wp_enqueue_script('formidable-editinplace'); |
|
28 | + wp_enqueue_script( 'formidable-editinplace' ); |
|
29 | 29 | |
30 | 30 | if ( wp_is_mobile() ) { |
31 | 31 | wp_enqueue_script( 'jquery-touch-punch' ); |
@@ -33,39 +33,39 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | public static function register_widgets() { |
36 | - require_once(FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php'); |
|
37 | - register_widget('FrmShowForm'); |
|
36 | + require_once( FrmAppHelper::plugin_path() . '/classes/widgets/FrmShowForm.php' ); |
|
37 | + register_widget( 'FrmShowForm' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | public static function list_form() { |
41 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
41 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
42 | 42 | |
43 | 43 | $params = FrmForm::list_page_params(); |
44 | - $errors = self::process_bulk_form_actions( array()); |
|
45 | - $errors = apply_filters('frm_admin_list_form_action', $errors); |
|
44 | + $errors = self::process_bulk_form_actions( array() ); |
|
45 | + $errors = apply_filters( 'frm_admin_list_form_action', $errors ); |
|
46 | 46 | |
47 | 47 | return self::display_forms_list( $params, '', $errors ); |
48 | 48 | } |
49 | 49 | |
50 | 50 | public static function new_form( $values = array() ) { |
51 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
51 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
52 | 52 | |
53 | 53 | global $frm_vars; |
54 | 54 | |
55 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
56 | - $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[ $action ]; |
|
55 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
56 | + $action = empty( $values ) ? FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ) : $values[$action]; |
|
57 | 57 | |
58 | 58 | if ( $action == 'create' ) { |
59 | - return self::create($values); |
|
59 | + return self::create( $values ); |
|
60 | 60 | } else if ( $action == 'new' ) { |
61 | 61 | $frm_field_selection = FrmField::field_selection(); |
62 | - $values = FrmFormsHelper::setup_new_vars($values); |
|
62 | + $values = FrmFormsHelper::setup_new_vars( $values ); |
|
63 | 63 | $id = FrmForm::create( $values ); |
64 | - $form = FrmForm::getOne($id); |
|
64 | + $form = FrmForm::getOne( $id ); |
|
65 | 65 | |
66 | 66 | // add default email notification |
67 | 67 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
68 | - $action_control->create($form->id); |
|
68 | + $action_control->create( $form->id ); |
|
69 | 69 | |
70 | 70 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function create( $values = array() ) { |
78 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
78 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
79 | 79 | |
80 | 80 | global $frm_vars; |
81 | 81 | if ( empty( $values ) ) { |
@@ -87,22 +87,22 @@ discard block |
||
87 | 87 | $values = FrmProEntry::mod_other_vals( $values, 'back' ); |
88 | 88 | } |
89 | 89 | |
90 | - $id = isset($values['id']) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
90 | + $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
|
91 | 91 | |
92 | 92 | if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) { |
93 | 93 | $frm_settings = FrmAppHelper::get_settings(); |
94 | 94 | $errors = array( 'form' => $frm_settings->admin_permission ); |
95 | 95 | } else { |
96 | - $errors = FrmForm::validate($values); |
|
96 | + $errors = FrmForm::validate( $values ); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( count($errors) > 0 ) { |
|
99 | + if ( count( $errors ) > 0 ) { |
|
100 | 100 | $hide_preview = true; |
101 | 101 | $frm_field_selection = FrmField::field_selection(); |
102 | 102 | $form = FrmForm::getOne( $id ); |
103 | - $fields = FrmField::get_all_for_form($id); |
|
103 | + $fields = FrmField::get_all_for_form( $id ); |
|
104 | 104 | |
105 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
105 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
106 | 106 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
107 | 107 | |
108 | 108 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -114,32 +114,32 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | public static function edit( $values = false ) { |
117 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
117 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
118 | 118 | |
119 | 119 | $id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
120 | - return self::get_edit_vars($id); |
|
120 | + return self::get_edit_vars( $id ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | public static function settings( $id = false, $message = '' ) { |
124 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
124 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
125 | 125 | |
126 | - if ( ! $id || ! is_numeric($id) ) { |
|
126 | + if ( ! $id || ! is_numeric( $id ) ) { |
|
127 | 127 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
128 | 128 | } |
129 | 129 | return self::get_settings_vars( $id, array(), $message ); |
130 | 130 | } |
131 | 131 | |
132 | 132 | public static function update_settings() { |
133 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
133 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
134 | 134 | |
135 | 135 | $id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
136 | 136 | |
137 | - $errors = FrmForm::validate($_POST); |
|
138 | - if ( count($errors) > 0 ) { |
|
139 | - return self::get_settings_vars($id, $errors); |
|
137 | + $errors = FrmForm::validate( $_POST ); |
|
138 | + if ( count( $errors ) > 0 ) { |
|
139 | + return self::get_settings_vars( $id, $errors ); |
|
140 | 140 | } |
141 | 141 | |
142 | - do_action('frm_before_update_form_settings', $id); |
|
142 | + do_action( 'frm_before_update_form_settings', $id ); |
|
143 | 143 | |
144 | 144 | FrmForm::update( $id, $_POST ); |
145 | 145 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | private static function edit_in_place_value( $field ) { |
163 | 163 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
164 | - FrmAppHelper::permission_check('frm_edit_forms', 'hide'); |
|
164 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
165 | 165 | |
166 | 166 | $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); |
167 | 167 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_filter_post_kses' ); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @since 2.0 |
220 | 220 | */ |
221 | 221 | public static function _create_from_template() { |
222 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
222 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
223 | 223 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
224 | 224 | |
225 | 225 | $current_form = FrmAppHelper::get_param( 'this_form', '', 'get', 'absint' ); |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | public static function duplicate() { |
237 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
237 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
238 | 238 | |
239 | 239 | $params = FrmForm::list_page_params(); |
240 | 240 | $form = FrmForm::duplicate( $params['id'], $params['template'], true ); |
241 | - $message = ($params['template']) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
241 | + $message = ( $params['template'] ) ? __( 'Form template was Successfully Created', 'formidable' ) : __( 'Form was Successfully Copied', 'formidable' ); |
|
242 | 242 | if ( $form ) { |
243 | 243 | return self::get_edit_vars( $form, array(), $message, true ); |
244 | 244 | } else { |
245 | - return self::display_forms_list($params, __( 'There was a problem creating the new template.', 'formidable' )); |
|
245 | + return self::display_forms_list( $params, __( 'There was a problem creating the new template.', 'formidable' ) ); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | public static function bulk_untrash( $ids ) { |
308 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
308 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
309 | 309 | |
310 | 310 | $count = FrmForm::set_status( $ids, 'published' ); |
311 | 311 | |
312 | - $message = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
312 | + $message = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), 1 ); |
|
313 | 313 | return $message; |
314 | 314 | } |
315 | 315 | |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | 'trash' => array( 'permission' => 'frm_delete_forms', 'new_status' => 'trash' ), |
329 | 329 | ); |
330 | 330 | |
331 | - if ( ! isset( $available_status[ $status ] ) ) { |
|
331 | + if ( ! isset( $available_status[$status] ) ) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | - FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
|
335 | + FrmAppHelper::permission_check( $available_status[$status]['permission'] ); |
|
336 | 336 | |
337 | 337 | $params = FrmForm::list_page_params(); |
338 | 338 | |
@@ -340,25 +340,25 @@ discard block |
||
340 | 340 | check_admin_referer( $status . '_form_' . $params['id'] ); |
341 | 341 | |
342 | 342 | $count = 0; |
343 | - if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
|
344 | - $count++; |
|
343 | + if ( FrmForm::set_status( $params['id'], $available_status[$status]['new_status'] ) ) { |
|
344 | + $count ++; |
|
345 | 345 | } |
346 | 346 | |
347 | - $available_status['untrash']['message'] = sprintf(_n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
347 | + $available_status['untrash']['message'] = sprintf( _n( '%1$s form restored from the Trash.', '%1$s forms restored from the Trash.', $count, 'formidable' ), $count ); |
|
348 | 348 | $available_status['trash']['message'] = sprintf( _n( '%1$s form moved to the Trash. %2$sUndo%3$s', '%1$s forms moved to the Trash. %2$sUndo%3$s', $count, 'formidable' ), $count, '<a href="' . esc_url( wp_nonce_url( '?page=formidable&frm_action=untrash&form_type=' . ( isset( $_REQUEST['form_type'] ) ? sanitize_title( $_REQUEST['form_type'] ) : '' ) . '&id=' . $params['id'], 'untrash_form_' . $params['id'] ) ) . '">', '</a>' ); |
349 | 349 | |
350 | - $message = $available_status[ $status ]['message']; |
|
350 | + $message = $available_status[$status]['message']; |
|
351 | 351 | |
352 | 352 | self::display_forms_list( $params, $message ); |
353 | 353 | } |
354 | 354 | |
355 | 355 | public static function bulk_trash( $ids ) { |
356 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
356 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
357 | 357 | |
358 | 358 | $count = 0; |
359 | 359 | foreach ( $ids as $id ) { |
360 | 360 | if ( FrmForm::trash( $id ) ) { |
361 | - $count++; |
|
361 | + $count ++; |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
@@ -369,49 +369,49 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | public static function destroy() { |
372 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
372 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
373 | 373 | |
374 | 374 | $params = FrmForm::list_page_params(); |
375 | 375 | |
376 | 376 | //check nonce url |
377 | - check_admin_referer('destroy_form_' . $params['id']); |
|
377 | + check_admin_referer( 'destroy_form_' . $params['id'] ); |
|
378 | 378 | |
379 | 379 | $count = 0; |
380 | 380 | if ( FrmForm::destroy( $params['id'] ) ) { |
381 | - $count++; |
|
381 | + $count ++; |
|
382 | 382 | } |
383 | 383 | |
384 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
384 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
385 | 385 | |
386 | 386 | self::display_forms_list( $params, $message ); |
387 | 387 | } |
388 | 388 | |
389 | 389 | public static function bulk_destroy( $ids ) { |
390 | - FrmAppHelper::permission_check('frm_delete_forms'); |
|
390 | + FrmAppHelper::permission_check( 'frm_delete_forms' ); |
|
391 | 391 | |
392 | 392 | $count = 0; |
393 | 393 | foreach ( $ids as $id ) { |
394 | 394 | $d = FrmForm::destroy( $id ); |
395 | 395 | if ( $d ) { |
396 | - $count++; |
|
396 | + $count ++; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
400 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
400 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
401 | 401 | |
402 | 402 | return $message; |
403 | 403 | } |
404 | 404 | |
405 | 405 | private static function delete_all() { |
406 | 406 | //check nonce url |
407 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable'); |
|
407 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
|
408 | 408 | if ( $permission_error !== false ) { |
409 | 409 | self::display_forms_list( array(), '', array( $permission_error ) ); |
410 | 410 | return; |
411 | 411 | } |
412 | 412 | |
413 | 413 | $count = FrmForm::scheduled_delete( time() ); |
414 | - $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count); |
|
414 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); |
|
415 | 415 | |
416 | 416 | self::display_forms_list( array(), $message ); |
417 | 417 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @since 2.0.15 |
429 | 429 | */ |
430 | 430 | public static function insert_form_button() { |
431 | - if ( current_user_can('frm_view_forms') ) { |
|
431 | + if ( current_user_can( 'frm_view_forms' ) ) { |
|
432 | 432 | $menu_name = FrmAppHelper::get_menu_name(); |
433 | 433 | $content = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '"> |
434 | 434 | <span class="frm-buttons-icon wp-media-buttons-icon"></span> ' . |
@@ -449,17 +449,17 @@ discard block |
||
449 | 449 | 'formidable' => array( 'name' => __( 'Form', 'formidable' ), 'label' => __( 'Insert a Form', 'formidable' ) ), |
450 | 450 | ); |
451 | 451 | |
452 | - $shortcodes = apply_filters('frm_popup_shortcodes', $shortcodes); |
|
452 | + $shortcodes = apply_filters( 'frm_popup_shortcodes', $shortcodes ); |
|
453 | 453 | |
454 | 454 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/insert_form_popup.php' ); |
455 | 455 | } |
456 | 456 | |
457 | 457 | public static function get_shortcode_opts() { |
458 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
458 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
459 | 459 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
460 | 460 | |
461 | 461 | $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' ); |
462 | - if ( empty($shortcode) ) { |
|
462 | + if ( empty( $shortcode ) ) { |
|
463 | 463 | wp_die(); |
464 | 464 | } |
465 | 465 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | ); |
480 | 480 | break; |
481 | 481 | } |
482 | - $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode); |
|
482 | + $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode ); |
|
483 | 483 | |
484 | 484 | if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) { |
485 | 485 | // allow other shortcodes to use the required form id option |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | } |
597 | 597 | |
598 | 598 | if ( $form->parent_form_id ) { |
599 | - wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' )); |
|
599 | + wp_die( sprintf( __( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form->parent_form_id ) ) . '">', '</a>' ) ); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | $frm_field_selection = FrmField::field_selection(); |
603 | - $fields = FrmField::get_all_for_form($form->id); |
|
603 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
604 | 604 | |
605 | 605 | // Automatically add end section fields if they don't exist (2.0 migration) |
606 | 606 | $reset_fields = false; |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $fields = FrmField::get_all_for_form( $form->id, '', 'exclude' ); |
611 | 611 | } |
612 | 612 | |
613 | - unset($end_section_values, $last_order, $open, $reset_fields); |
|
613 | + unset( $end_section_values, $last_order, $open, $reset_fields ); |
|
614 | 614 | |
615 | 615 | $args = array( 'parent_form_id' => $form->id ); |
616 | 616 | $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true, array(), $args ); |
@@ -623,8 +623,8 @@ discard block |
||
623 | 623 | $all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' ); |
624 | 624 | |
625 | 625 | if ( $form->default_template ) { |
626 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
627 | - } else if ( defined('DOING_AJAX') ) { |
|
626 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
627 | + } else if ( defined( 'DOING_AJAX' ) ) { |
|
628 | 628 | wp_die(); |
629 | 629 | } else if ( $create_link ) { |
630 | 630 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' ); |
@@ -640,28 +640,28 @@ discard block |
||
640 | 640 | |
641 | 641 | $form = FrmForm::getOne( $id ); |
642 | 642 | |
643 | - $fields = FrmField::get_all_for_form($id); |
|
644 | - $values = FrmAppHelper::setup_edit_vars($form, 'forms', $fields, true); |
|
643 | + $fields = FrmField::get_all_for_form( $id ); |
|
644 | + $values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true ); |
|
645 | 645 | |
646 | - if ( isset($values['default_template']) && $values['default_template'] ) { |
|
647 | - wp_die(__( 'That template cannot be edited', 'formidable' )); |
|
646 | + if ( isset( $values['default_template'] ) && $values['default_template'] ) { |
|
647 | + wp_die( __( 'That template cannot be edited', 'formidable' ) ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | $action_controls = FrmFormActionsController::get_form_actions(); |
651 | 651 | |
652 | - $sections = apply_filters('frm_add_form_settings_section', array(), $values); |
|
652 | + $sections = apply_filters( 'frm_add_form_settings_section', array(), $values ); |
|
653 | 653 | $pro_feature = FrmAppHelper::pro_is_installed() ? '' : ' class="pro_feature"'; |
654 | 654 | |
655 | - $styles = apply_filters('frm_get_style_opts', array()); |
|
655 | + $styles = apply_filters( 'frm_get_style_opts', array() ); |
|
656 | 656 | |
657 | 657 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings.php' ); |
658 | 658 | } |
659 | 659 | |
660 | 660 | public static function mb_tags_box( $form_id, $class = '' ) { |
661 | - $fields = FrmField::get_all_for_form($form_id, '', 'include'); |
|
661 | + $fields = FrmField::get_all_for_form( $form_id, '', 'include' ); |
|
662 | 662 | $linked_forms = array(); |
663 | 663 | $col = 'one'; |
664 | - $settings_tab = FrmAppHelper::is_admin_page('formidable' ) ? true : false; |
|
664 | + $settings_tab = FrmAppHelper::is_admin_page( 'formidable' ) ? true : false; |
|
665 | 665 | |
666 | 666 | $cond_shortcodes = apply_filters( 'frm_conditional_shortcodes', array() ); |
667 | 667 | $adv_shortcodes = self::get_advanced_shortcodes(); |
@@ -739,13 +739,13 @@ discard block |
||
739 | 739 | |
740 | 740 | // Insert the form class setting into the form |
741 | 741 | public static function form_classes( $form ) { |
742 | - if ( isset($form->options['form_class']) ) { |
|
742 | + if ( isset( $form->options['form_class'] ) ) { |
|
743 | 743 | echo esc_attr( sanitize_text_field( $form->options['form_class'] ) ); |
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
747 | 747 | public static function get_email_html() { |
748 | - FrmAppHelper::permission_check('frm_view_forms'); |
|
748 | + FrmAppHelper::permission_check( 'frm_view_forms' ); |
|
749 | 749 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
750 | 750 | echo FrmEntryFormat::show_entry( array( |
751 | 751 | 'form_id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ), |
@@ -842,11 +842,11 @@ discard block |
||
842 | 842 | public static function add_default_templates( $path, $default = true, $template = true ) { |
843 | 843 | _deprecated_function( __FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()' ); |
844 | 844 | |
845 | - $path = untrailingslashit(trim($path)); |
|
845 | + $path = untrailingslashit( trim( $path ) ); |
|
846 | 846 | $templates = glob( $path . '/*.php' ); |
847 | 847 | |
848 | - for ( $i = count( $templates ) - 1; $i >= 0; $i-- ) { |
|
849 | - $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[ $i ] ) ); |
|
848 | + for ( $i = count( $templates ) - 1; $i >= 0; $i -- ) { |
|
849 | + $filename = str_replace( '.php', '', str_replace( $path . '/', '', $templates[$i] ) ); |
|
850 | 850 | $template_query = array( 'form_key' => $filename ); |
851 | 851 | if ( $template ) { |
852 | 852 | $template_query['is_template'] = 1; |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | $values['default_template'] = 1; |
865 | 865 | } |
866 | 866 | |
867 | - include( $templates[ $i ] ); |
|
867 | + include( $templates[$i] ); |
|
868 | 868 | |
869 | 869 | //get updated form |
870 | - if ( isset($form) && ! empty($form) ) { |
|
870 | + if ( isset( $form ) && ! empty( $form ) ) { |
|
871 | 871 | $old_id = $form->id; |
872 | - $form = FrmForm::getOne($form->id); |
|
872 | + $form = FrmForm::getOne( $form->id ); |
|
873 | 873 | } else { |
874 | 874 | $old_id = false; |
875 | 875 | $form = FrmForm::getAll( $template_query, '', 1 ); |
@@ -882,24 +882,24 @@ discard block |
||
882 | 882 | } |
883 | 883 | |
884 | 884 | public static function route() { |
885 | - $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
885 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
886 | 886 | $vars = array(); |
887 | 887 | if ( isset( $_POST['frm_compact_fields'] ) ) { |
888 | 888 | FrmAppHelper::permission_check( 'frm_edit_forms' ); |
889 | 889 | |
890 | - $json_vars = htmlspecialchars_decode(nl2br(stripslashes(str_replace('"', '\\\"', $_POST['frm_compact_fields'] )))); |
|
891 | - $json_vars = json_decode($json_vars, true); |
|
892 | - if ( empty($json_vars) ) { |
|
890 | + $json_vars = htmlspecialchars_decode( nl2br( stripslashes( str_replace( '"', '\\\"', $_POST['frm_compact_fields'] ) ) ) ); |
|
891 | + $json_vars = json_decode( $json_vars, true ); |
|
892 | + if ( empty( $json_vars ) ) { |
|
893 | 893 | // json decoding failed so we should return an error message |
894 | 894 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
895 | 895 | if ( 'edit' == $action ) { |
896 | 896 | $action = 'update'; |
897 | 897 | } |
898 | 898 | |
899 | - add_filter('frm_validate_form', 'FrmFormsController::json_error'); |
|
899 | + add_filter( 'frm_validate_form', 'FrmFormsController::json_error' ); |
|
900 | 900 | } else { |
901 | - $vars = FrmAppHelper::json_to_array($json_vars); |
|
902 | - $action = $vars[ $action ]; |
|
901 | + $vars = FrmAppHelper::json_to_array( $json_vars ); |
|
902 | + $action = $vars[$action]; |
|
903 | 903 | unset( $_REQUEST['frm_compact_fields'], $_POST['frm_compact_fields'] ); |
904 | 904 | $_REQUEST = array_merge( $_REQUEST, $vars ); |
905 | 905 | $_POST = array_merge( $_POST, $_REQUEST ); |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | |
918 | 918 | switch ( $action ) { |
919 | 919 | case 'new': |
920 | - return self::new_form($vars); |
|
920 | + return self::new_form( $vars ); |
|
921 | 921 | case 'create': |
922 | 922 | case 'edit': |
923 | 923 | case 'update': |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' ); |
941 | 941 | } |
942 | 942 | |
943 | - if ( strpos($action, 'bulk_') === 0 ) { |
|
943 | + if ( strpos( $action, 'bulk_' ) === 0 ) { |
|
944 | 944 | FrmAppHelper::remove_get_action(); |
945 | 945 | return self::list_form(); |
946 | 946 | } |
@@ -967,27 +967,27 @@ discard block |
||
967 | 967 | |
968 | 968 | public static function admin_bar_configure() { |
969 | 969 | global $frm_vars; |
970 | - if ( empty($frm_vars['forms_loaded']) ) { |
|
970 | + if ( empty( $frm_vars['forms_loaded'] ) ) { |
|
971 | 971 | return; |
972 | 972 | } |
973 | 973 | |
974 | 974 | $actions = array(); |
975 | 975 | foreach ( $frm_vars['forms_loaded'] as $form ) { |
976 | - if ( is_object($form) ) { |
|
977 | - $actions[ $form->id ] = $form->name; |
|
976 | + if ( is_object( $form ) ) { |
|
977 | + $actions[$form->id] = $form->name; |
|
978 | 978 | } |
979 | - unset($form); |
|
979 | + unset( $form ); |
|
980 | 980 | } |
981 | 981 | |
982 | - if ( empty($actions) ) { |
|
982 | + if ( empty( $actions ) ) { |
|
983 | 983 | return; |
984 | 984 | } |
985 | 985 | |
986 | - asort($actions); |
|
986 | + asort( $actions ); |
|
987 | 987 | |
988 | 988 | global $wp_admin_bar; |
989 | 989 | |
990 | - if ( count($actions) == 1 ) { |
|
990 | + if ( count( $actions ) == 1 ) { |
|
991 | 991 | $wp_admin_bar->add_menu( array( |
992 | 992 | 'title' => 'Edit Form', |
993 | 993 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . current( array_keys( $actions ) ) ), |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $wp_admin_bar->add_menu( array( |
1009 | 1009 | 'parent' => 'frm-forms', |
1010 | 1010 | 'id' => 'edit_form_' . $form_id, |
1011 | - 'title' => empty($name) ? __( '(no title)') : $name, |
|
1011 | + 'title' => empty( $name ) ? __( '(no title)' ) : $name, |
|
1012 | 1012 | 'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ), |
1013 | 1013 | ) ); |
1014 | 1014 | } |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | //formidable shortcode |
1019 | 1019 | public static function get_form_shortcode( $atts ) { |
1020 | 1020 | global $frm_vars; |
1021 | - if ( isset($frm_vars['skip_shortcode']) && $frm_vars['skip_shortcode'] ) { |
|
1021 | + if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) { |
|
1022 | 1022 | $sc = '[formidable'; |
1023 | 1023 | if ( ! empty( $atts ) ) { |
1024 | 1024 | foreach ( $atts as $k => $v ) { |
@@ -1032,8 +1032,8 @@ discard block |
||
1032 | 1032 | 'id' => '', 'key' => '', 'title' => false, 'description' => false, |
1033 | 1033 | 'readonly' => false, 'entry_id' => false, 'fields' => array(), |
1034 | 1034 | 'exclude_fields' => array(), 'minimize' => false, |
1035 | - ), $atts); |
|
1036 | - do_action('formidable_shortcode_atts', $shortcode_atts, $atts); |
|
1035 | + ), $atts ); |
|
1036 | + do_action( 'formidable_shortcode_atts', $shortcode_atts, $atts ); |
|
1037 | 1037 | |
1038 | 1038 | return self::show_form( |
1039 | 1039 | $shortcode_atts['id'], $shortcode_atts['key'], $shortcode_atts['title'], |
@@ -1121,51 +1121,51 @@ discard block |
||
1121 | 1121 | |
1122 | 1122 | $frm_settings = FrmAppHelper::get_settings(); |
1123 | 1123 | |
1124 | - $submit = isset($form->options['submit_value']) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1124 | + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value; |
|
1125 | 1125 | |
1126 | 1126 | $user_ID = get_current_user_id(); |
1127 | 1127 | $params = FrmForm::get_params( $form ); |
1128 | 1128 | $message = $errors = ''; |
1129 | 1129 | |
1130 | 1130 | if ( $params['posted_form_id'] == $form->id && $_POST ) { |
1131 | - $errors = isset( $frm_vars['created_entries'][ $form->id ] ) ? $frm_vars['created_entries'][ $form->id ]['errors'] : array(); |
|
1131 | + $errors = isset( $frm_vars['created_entries'][$form->id] ) ? $frm_vars['created_entries'][$form->id]['errors'] : array(); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form ); |
1135 | 1135 | $fields = FrmFieldsHelper::get_form_fields( $form->id, ( isset( $errors ) && ! empty( $errors ) ) ); |
1136 | 1136 | |
1137 | 1137 | if ( $params['action'] != 'create' || $params['posted_form_id'] != $form->id || ! $_POST ) { |
1138 | - do_action('frm_display_form_action', $params, $fields, $form, $title, $description); |
|
1139 | - if ( apply_filters('frm_continue_to_new', true, $form->id, $params['action']) ) { |
|
1140 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form); |
|
1138 | + do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description ); |
|
1139 | + if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) { |
|
1140 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form ); |
|
1141 | 1141 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1142 | 1142 | } |
1143 | 1143 | return; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - if ( ! empty($errors) ) { |
|
1147 | - $values = $fields ? FrmEntriesHelper::setup_new_vars($fields, $form) : array(); |
|
1146 | + if ( ! empty( $errors ) ) { |
|
1147 | + $values = $fields ? FrmEntriesHelper::setup_new_vars( $fields, $form ) : array(); |
|
1148 | 1148 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1149 | 1149 | return; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | - do_action('frm_validate_form_creation', $params, $fields, $form, $title, $description); |
|
1153 | - if ( ! apply_filters('frm_continue_to_create', true, $form->id) ) { |
|
1152 | + do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description ); |
|
1153 | + if ( ! apply_filters( 'frm_continue_to_create', true, $form->id ) ) { |
|
1154 | 1154 | return; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | - $values = FrmEntriesHelper::setup_new_vars($fields, $form, true); |
|
1157 | + $values = FrmEntriesHelper::setup_new_vars( $fields, $form, true ); |
|
1158 | 1158 | $created = self::just_created_entry( $form->id ); |
1159 | - $conf_method = apply_filters('frm_success_filter', 'message', $form, 'create'); |
|
1159 | + $conf_method = apply_filters( 'frm_success_filter', 'message', $form, 'create' ); |
|
1160 | 1160 | |
1161 | - if ( $created && is_numeric($created) && $conf_method != 'message' ) { |
|
1162 | - do_action('frm_success_action', $conf_method, $form, $form->options, $created); |
|
1161 | + if ( $created && is_numeric( $created ) && $conf_method != 'message' ) { |
|
1162 | + do_action( 'frm_success_action', $conf_method, $form, $form->options, $created ); |
|
1163 | 1163 | do_action( 'frm_after_entry_processed', array( 'entry_id' => $created, 'form' => $form ) ); |
1164 | 1164 | return; |
1165 | 1165 | } |
1166 | 1166 | |
1167 | - if ( $created && is_numeric($created) ) { |
|
1168 | - $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1167 | + if ( $created && is_numeric( $created ) ) { |
|
1168 | + $message = isset( $form->options['success_msg'] ) ? $form->options['success_msg'] : $frm_settings->success_msg; |
|
1169 | 1169 | $class = 'frm_message'; |
1170 | 1170 | } else { |
1171 | 1171 | $message = $frm_settings->failed_msg; |
@@ -1176,9 +1176,9 @@ discard block |
||
1176 | 1176 | 'message' => $message, 'form' => $form, |
1177 | 1177 | 'entry_id' => $created, 'class' => $class, |
1178 | 1178 | ) ); |
1179 | - $message = apply_filters('frm_main_feedback', $message, $form, $created); |
|
1179 | + $message = apply_filters( 'frm_main_feedback', $message, $form, $created ); |
|
1180 | 1180 | |
1181 | - if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) { |
|
1181 | + if ( ! isset( $form->options['show_form'] ) || $form->options['show_form'] ) { |
|
1182 | 1182 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php' ); |
1183 | 1183 | } else { |
1184 | 1184 | global $frm_vars; |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | */ |
1197 | 1197 | public static function just_created_entry( $form_id ) { |
1198 | 1198 | global $frm_vars; |
1199 | - return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][ $form_id ] ) && isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) ? $frm_vars['created_entries'][ $form_id ]['entry_id'] : 0; |
|
1199 | + return ( isset( $frm_vars['created_entries'] ) && isset( $frm_vars['created_entries'][$form_id] ) && isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) ? $frm_vars['created_entries'][$form_id]['entry_id'] : 0; |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | public static function front_head() { |
@@ -2,160 +2,160 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmNotification { |
4 | 4 | public function __construct() { |
5 | - if ( ! defined('ABSPATH') ) { |
|
6 | - die('You are not allowed to call this page directly.'); |
|
7 | - } |
|
8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
9 | - } |
|
5 | + if ( ! defined('ABSPATH') ) { |
|
6 | + die('You are not allowed to call this page directly.'); |
|
7 | + } |
|
8 | + add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
9 | + } |
|
10 | 10 | |
11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
12 | - $notification = $action->post_content; |
|
13 | - $email_key = $action->ID; |
|
14 | - |
|
15 | - // Set the subject |
|
16 | - if ( empty($notification['email_subject']) ) { |
|
17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
18 | - } |
|
19 | - |
|
20 | - $plain_text = $notification['plain_text'] ? true : false; |
|
21 | - |
|
22 | - //Filter these fields |
|
23 | - $filter_fields = array( |
|
24 | - 'email_to', 'cc', 'bcc', |
|
25 | - 'reply_to', 'from', |
|
26 | - 'email_subject', 'email_message', |
|
27 | - ); |
|
28 | - |
|
29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
30 | - |
|
31 | - //Get all values in entry in order to get User ID field ID |
|
32 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
33 | - $user_id_field = $user_id_key = ''; |
|
34 | - foreach ( $values as $value ) { |
|
35 | - if ( $value->field_type == 'user_id' ) { |
|
36 | - $user_id_field = $value->field_id; |
|
37 | - $user_id_key = $value->field_key; |
|
38 | - break; |
|
39 | - } |
|
40 | - unset($value); |
|
41 | - } |
|
42 | - |
|
43 | - //Filter and prepare the email fields |
|
44 | - foreach ( $filter_fields as $f ) { |
|
45 | - //Don't allow empty From |
|
12 | + $notification = $action->post_content; |
|
13 | + $email_key = $action->ID; |
|
14 | + |
|
15 | + // Set the subject |
|
16 | + if ( empty($notification['email_subject']) ) { |
|
17 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
18 | + } |
|
19 | + |
|
20 | + $plain_text = $notification['plain_text'] ? true : false; |
|
21 | + |
|
22 | + //Filter these fields |
|
23 | + $filter_fields = array( |
|
24 | + 'email_to', 'cc', 'bcc', |
|
25 | + 'reply_to', 'from', |
|
26 | + 'email_subject', 'email_message', |
|
27 | + ); |
|
28 | + |
|
29 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
30 | + |
|
31 | + //Get all values in entry in order to get User ID field ID |
|
32 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
33 | + $user_id_field = $user_id_key = ''; |
|
34 | + foreach ( $values as $value ) { |
|
35 | + if ( $value->field_type == 'user_id' ) { |
|
36 | + $user_id_field = $value->field_id; |
|
37 | + $user_id_key = $value->field_key; |
|
38 | + break; |
|
39 | + } |
|
40 | + unset($value); |
|
41 | + } |
|
42 | + |
|
43 | + //Filter and prepare the email fields |
|
44 | + foreach ( $filter_fields as $f ) { |
|
45 | + //Don't allow empty From |
|
46 | 46 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
47 | 47 | $notification[ $f ] = '[admin_email]'; |
48 | 48 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
49 | 49 | //Remove brackets |
50 | - //Add a space in case there isn't one |
|
50 | + //Add a space in case there isn't one |
|
51 | 51 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
52 | 52 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
53 | 53 | |
54 | - //Switch userID shortcode to email address |
|
54 | + //Switch userID shortcode to email address |
|
55 | 55 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
56 | 56 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
57 | - $user_email = $user_data->user_email; |
|
57 | + $user_email = $user_data->user_email; |
|
58 | 58 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
59 | - } |
|
60 | - } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
65 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
66 | 66 | $to_emails = self::explode_emails( $notification['email_to'] ); |
67 | 67 | $cc = self::explode_emails( $notification['cc'] ); |
68 | 68 | $bcc = self::explode_emails( $notification['bcc'] ); |
69 | 69 | |
70 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
70 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
71 | 71 | |
72 | - // Stop now if there aren't any recipients |
|
73 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
74 | - return; |
|
75 | - } |
|
72 | + // Stop now if there aren't any recipients |
|
73 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
74 | + return; |
|
75 | + } |
|
76 | 76 | |
77 | - $to_emails = array_unique( (array) $to_emails ); |
|
77 | + $to_emails = array_unique( (array) $to_emails ); |
|
78 | 78 | |
79 | - $prev_mail_body = $mail_body = $notification['email_message']; |
|
80 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
81 | - 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
82 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
83 | - ) ); |
|
79 | + $prev_mail_body = $mail_body = $notification['email_message']; |
|
80 | + $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
81 | + 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
82 | + 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
83 | + ) ); |
|
84 | 84 | |
85 | - // Add the user info if it isn't already included |
|
86 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
87 | - $data = maybe_unserialize($entry->description); |
|
85 | + // Add the user info if it isn't already included |
|
86 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
87 | + $data = maybe_unserialize($entry->description); |
|
88 | 88 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
89 | 89 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
90 | 90 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
91 | 91 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
92 | - } |
|
93 | - unset($prev_mail_body); |
|
94 | - |
|
95 | - // Add attachments |
|
96 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
97 | - |
|
98 | - if ( ! empty($notification['email_subject']) ) { |
|
99 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
100 | - } |
|
101 | - |
|
102 | - // check for a phone number |
|
103 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
104 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
105 | - $e = explode(' ', $e); |
|
106 | - |
|
107 | - //If to_email has name <[email protected]> format |
|
108 | - if ( is_email(end($e)) ) { |
|
109 | - continue; |
|
110 | - } |
|
111 | - |
|
112 | - do_action('frm_send_to_not_email', array( |
|
113 | - 'e' => $e, |
|
114 | - 'subject' => $notification['email_subject'], |
|
115 | - 'mail_body' => $mail_body, |
|
116 | - 'reply_to' => $notification['reply_to'], |
|
117 | - 'from' => $notification['from'], |
|
118 | - 'plain_text' => $plain_text, |
|
119 | - 'attachments' => $attachments, |
|
120 | - 'form' => $form, |
|
121 | - 'email_key' => $email_key, |
|
122 | - ) ); |
|
92 | + } |
|
93 | + unset($prev_mail_body); |
|
94 | + |
|
95 | + // Add attachments |
|
96 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
97 | + |
|
98 | + if ( ! empty($notification['email_subject']) ) { |
|
99 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
100 | + } |
|
101 | + |
|
102 | + // check for a phone number |
|
103 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
104 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
105 | + $e = explode(' ', $e); |
|
106 | + |
|
107 | + //If to_email has name <[email protected]> format |
|
108 | + if ( is_email(end($e)) ) { |
|
109 | + continue; |
|
110 | + } |
|
111 | + |
|
112 | + do_action('frm_send_to_not_email', array( |
|
113 | + 'e' => $e, |
|
114 | + 'subject' => $notification['email_subject'], |
|
115 | + 'mail_body' => $mail_body, |
|
116 | + 'reply_to' => $notification['reply_to'], |
|
117 | + 'from' => $notification['from'], |
|
118 | + 'plain_text' => $plain_text, |
|
119 | + 'attachments' => $attachments, |
|
120 | + 'form' => $form, |
|
121 | + 'email_key' => $email_key, |
|
122 | + ) ); |
|
123 | 123 | |
124 | 124 | unset( $to_emails[ $email_key ] ); |
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - // Send the email now |
|
129 | - $sent_to = self::send_email( array( |
|
130 | - 'to_email' => $to_emails, |
|
131 | - 'subject' => $notification['email_subject'], |
|
132 | - 'message' => $mail_body, |
|
133 | - 'from' => $notification['from'], |
|
134 | - 'plain_text' => $plain_text, |
|
135 | - 'reply_to' => $notification['reply_to'], |
|
136 | - 'attachments' => $attachments, |
|
137 | - 'cc' => $cc, |
|
138 | - 'bcc' => $bcc, |
|
139 | - ) ); |
|
140 | - |
|
141 | - return $sent_to; |
|
142 | - } |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + // Send the email now |
|
129 | + $sent_to = self::send_email( array( |
|
130 | + 'to_email' => $to_emails, |
|
131 | + 'subject' => $notification['email_subject'], |
|
132 | + 'message' => $mail_body, |
|
133 | + 'from' => $notification['from'], |
|
134 | + 'plain_text' => $plain_text, |
|
135 | + 'reply_to' => $notification['reply_to'], |
|
136 | + 'attachments' => $attachments, |
|
137 | + 'cc' => $cc, |
|
138 | + 'bcc' => $bcc, |
|
139 | + ) ); |
|
140 | + |
|
141 | + return $sent_to; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | public function entry_created( $entry_id, $form_id ) { |
145 | 145 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
146 | 146 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
147 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
148 | - } |
|
147 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
151 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
151 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
152 | 152 | |
153 | - return self::send_email(compact( |
|
154 | - 'to_email', 'subject', 'message', |
|
155 | - 'from', 'from_name', 'plain_text', |
|
156 | - 'attachments', 'reply_to' |
|
157 | - )); |
|
158 | - } |
|
153 | + return self::send_email(compact( |
|
154 | + 'to_email', 'subject', 'message', |
|
155 | + 'from', 'from_name', 'plain_text', |
|
156 | + 'attachments', 'reply_to' |
|
157 | + )); |
|
158 | + } |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -173,53 +173,53 @@ discard block |
||
173 | 173 | return $emails; |
174 | 174 | } |
175 | 175 | |
176 | - /** |
|
177 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
178 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
179 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
180 | - * "First Last" <[email protected]> |
|
181 | - * |
|
182 | - * Things that won't work: First Last (with no email entered) |
|
183 | - * @since 2.0 |
|
184 | - * @param array $atts array of email fields, pass by reference |
|
185 | - * @param $admin_email |
|
186 | - */ |
|
187 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
188 | - |
|
189 | - // If from is empty or is set to admin_email, set it now |
|
190 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
191 | - |
|
192 | - // Filter values in these fields |
|
176 | + /** |
|
177 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
178 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
179 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
180 | + * "First Last" <[email protected]> |
|
181 | + * |
|
182 | + * Things that won't work: First Last (with no email entered) |
|
183 | + * @since 2.0 |
|
184 | + * @param array $atts array of email fields, pass by reference |
|
185 | + * @param $admin_email |
|
186 | + */ |
|
187 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
188 | + |
|
189 | + // If from is empty or is set to admin_email, set it now |
|
190 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
191 | + |
|
192 | + // Filter values in these fields |
|
193 | 193 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
194 | 194 | |
195 | - foreach ( $filter_fields as $f ) { |
|
196 | - // If empty, just skip it |
|
195 | + foreach ( $filter_fields as $f ) { |
|
196 | + // If empty, just skip it |
|
197 | 197 | if ( empty( $atts[ $f ] ) ) { |
198 | - continue; |
|
199 | - } |
|
198 | + continue; |
|
199 | + } |
|
200 | 200 | |
201 | - // to_email, cc, and bcc can be an array |
|
201 | + // to_email, cc, and bcc can be an array |
|
202 | 202 | if ( is_array( $atts[ $f ] ) ) { |
203 | 203 | foreach ( $atts[ $f ] as $key => $val ) { |
204 | - self::format_single_field( $atts, $f, $val, $key ); |
|
205 | - unset( $key, $val ); |
|
206 | - } |
|
207 | - unset($f); |
|
208 | - continue; |
|
209 | - } |
|
204 | + self::format_single_field( $atts, $f, $val, $key ); |
|
205 | + unset( $key, $val ); |
|
206 | + } |
|
207 | + unset($f); |
|
208 | + continue; |
|
209 | + } |
|
210 | 210 | |
211 | 211 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - // If reply-to isn't set, make it match the from settings |
|
215 | - if ( empty( $atts['reply_to'] ) ) { |
|
216 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
217 | - } |
|
214 | + // If reply-to isn't set, make it match the from settings |
|
215 | + if ( empty( $atts['reply_to'] ) ) { |
|
216 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
217 | + } |
|
218 | 218 | |
219 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
220 | - $atts['to_email'] = $admin_email; |
|
221 | - } |
|
222 | - } |
|
219 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
220 | + $atts['to_email'] = $admin_email; |
|
221 | + } |
|
222 | + } |
|
223 | 223 | |
224 | 224 | private static function get_email_from_formatted_string( $value ) { |
225 | 225 | if ( strpos( $value, '<' ) !== false ) { |
@@ -229,48 +229,48 @@ discard block |
||
229 | 229 | return $value; |
230 | 230 | } |
231 | 231 | |
232 | - /** |
|
233 | - * Format individual email fields |
|
234 | - * |
|
235 | - * @since 2.0 |
|
236 | - * @param array $atts pass by reference |
|
237 | - * @param string $f (to, from, reply_to, etc) |
|
238 | - * @param string $val value saved in field |
|
239 | - * @param int $key if in array, this will be set |
|
240 | - */ |
|
241 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
242 | - $val = trim($val); |
|
243 | - |
|
244 | - // If just a plain email is used |
|
245 | - if ( is_email($val) ) { |
|
246 | - // add sender's name if not included in $from |
|
247 | - if ( $f == 'from' ) { |
|
232 | + /** |
|
233 | + * Format individual email fields |
|
234 | + * |
|
235 | + * @since 2.0 |
|
236 | + * @param array $atts pass by reference |
|
237 | + * @param string $f (to, from, reply_to, etc) |
|
238 | + * @param string $val value saved in field |
|
239 | + * @param int $key if in array, this will be set |
|
240 | + */ |
|
241 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
242 | + $val = trim($val); |
|
243 | + |
|
244 | + // If just a plain email is used |
|
245 | + if ( is_email($val) ) { |
|
246 | + // add sender's name if not included in $from |
|
247 | + if ( $f == 'from' ) { |
|
248 | 248 | $part_2 = $atts[ $f ]; |
249 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
250 | - } else { |
|
251 | - return; |
|
252 | - } |
|
253 | - } else { |
|
254 | - $parts = explode(' ', $val); |
|
255 | - $part_2 = end($parts); |
|
256 | - |
|
257 | - // If inputted correcly, $part_2 should be an email |
|
258 | - if ( is_email( $part_2 ) ) { |
|
259 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
260 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
249 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
250 | + } else { |
|
251 | + return; |
|
252 | + } |
|
253 | + } else { |
|
254 | + $parts = explode(' ', $val); |
|
255 | + $part_2 = end($parts); |
|
256 | + |
|
257 | + // If inputted correcly, $part_2 should be an email |
|
258 | + if ( is_email( $part_2 ) ) { |
|
259 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
260 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
261 | 261 | // In case someone just puts a name in the From or Reply To field |
262 | 262 | $part_1 = $val; |
263 | - $part_2 = get_option('admin_email'); |
|
264 | - } else { |
|
263 | + $part_2 = get_option('admin_email'); |
|
264 | + } else { |
|
265 | 265 | // In case someone just puts a name in any other email field |
266 | - if ( false !== $key ) { |
|
266 | + if ( false !== $key ) { |
|
267 | 267 | unset( $atts[ $f ][ $key ] ); |
268 | - return; |
|
269 | - } |
|
268 | + return; |
|
269 | + } |
|
270 | 270 | $atts[ $f ] = ''; |
271 | - return; |
|
272 | - } |
|
273 | - } |
|
271 | + return; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | 275 | // if sending the email from a yahoo address, change it to the WordPress default |
276 | 276 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -283,110 +283,110 @@ discard block |
||
283 | 283 | $part_2 = 'wordpress@' . $sitename; |
284 | 284 | } |
285 | 285 | |
286 | - // Set up formatted value |
|
286 | + // Set up formatted value |
|
287 | 287 | $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
288 | 288 | |
289 | - // If value is an array |
|
290 | - if ( false !== $key ) { |
|
289 | + // If value is an array |
|
290 | + if ( false !== $key ) { |
|
291 | 291 | $atts[ $f ][ $key ] = $final_val; |
292 | - return; |
|
293 | - } |
|
292 | + return; |
|
293 | + } |
|
294 | 294 | $atts[ $f ] = $final_val; |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | 297 | public static function send_email( $atts ) { |
298 | - $admin_email = get_option('admin_email'); |
|
299 | - $defaults = array( |
|
300 | - 'to_email' => $admin_email, |
|
301 | - 'subject' => '', |
|
302 | - 'message' => '', |
|
303 | - 'from' => $admin_email, |
|
304 | - 'from_name' => '', |
|
305 | - 'cc' => '', |
|
306 | - 'bcc' => '', |
|
307 | - 'plain_text' => true, |
|
308 | - 'reply_to' => $admin_email, |
|
309 | - 'attachments' => array(), |
|
310 | - ); |
|
311 | - $atts = wp_parse_args($atts, $defaults); |
|
312 | - |
|
313 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
314 | - self::format_email_fields( $atts, $admin_email ); |
|
315 | - |
|
316 | - $recipient = $atts['to_email']; //recipient |
|
317 | - $header = array(); |
|
318 | - $header[] = 'From: ' . $atts['from']; |
|
319 | - |
|
320 | - //Allow for cc and bcc arrays |
|
298 | + $admin_email = get_option('admin_email'); |
|
299 | + $defaults = array( |
|
300 | + 'to_email' => $admin_email, |
|
301 | + 'subject' => '', |
|
302 | + 'message' => '', |
|
303 | + 'from' => $admin_email, |
|
304 | + 'from_name' => '', |
|
305 | + 'cc' => '', |
|
306 | + 'bcc' => '', |
|
307 | + 'plain_text' => true, |
|
308 | + 'reply_to' => $admin_email, |
|
309 | + 'attachments' => array(), |
|
310 | + ); |
|
311 | + $atts = wp_parse_args($atts, $defaults); |
|
312 | + |
|
313 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
314 | + self::format_email_fields( $atts, $admin_email ); |
|
315 | + |
|
316 | + $recipient = $atts['to_email']; //recipient |
|
317 | + $header = array(); |
|
318 | + $header[] = 'From: ' . $atts['from']; |
|
319 | + |
|
320 | + //Allow for cc and bcc arrays |
|
321 | 321 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
322 | 322 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
323 | - foreach ( $array_fields as $key => $a_field ) { |
|
324 | - if ( empty($a_field) ) { |
|
325 | - continue; |
|
326 | - } |
|
323 | + foreach ( $array_fields as $key => $a_field ) { |
|
324 | + if ( empty($a_field) ) { |
|
325 | + continue; |
|
326 | + } |
|
327 | 327 | |
328 | 328 | foreach ( (array) $a_field as $email ) { |
329 | 329 | $cc[ $key ][] = $email; |
330 | - } |
|
331 | - unset($key, $a_field); |
|
332 | - } |
|
330 | + } |
|
331 | + unset($key, $a_field); |
|
332 | + } |
|
333 | 333 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
334 | 334 | |
335 | 335 | foreach ( $cc as $k => $v ) { |
336 | 336 | $header[] = $k . ': ' . implode( ',', $v ); |
337 | 337 | } |
338 | 338 | |
339 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
340 | - $charset = get_option('blog_charset'); |
|
339 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
340 | + $charset = get_option('blog_charset'); |
|
341 | 341 | |
342 | 342 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
343 | 343 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
344 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
344 | + $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
345 | 345 | |
346 | - $message = do_shortcode($atts['message']); |
|
346 | + $message = do_shortcode($atts['message']); |
|
347 | 347 | |
348 | - if ( $atts['plain_text'] ) { |
|
349 | - //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
350 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
351 | - } else { |
|
348 | + if ( $atts['plain_text'] ) { |
|
349 | + //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
350 | + $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
351 | + } else { |
|
352 | 352 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
353 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
354 | - } |
|
353 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
354 | + } |
|
355 | 355 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
356 | 356 | |
357 | - $header = apply_filters('frm_email_header', $header, array( |
|
357 | + $header = apply_filters('frm_email_header', $header, array( |
|
358 | 358 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
359 | 359 | ) ); |
360 | 360 | |
361 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
361 | + if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
362 | 362 | $atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?='; |
363 | - } |
|
363 | + } |
|
364 | 364 | |
365 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
366 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
365 | + remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
366 | + remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
367 | 367 | |
368 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
369 | - if ( ! $sent ) { |
|
368 | + $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
369 | + if ( ! $sent ) { |
|
370 | 370 | $header = 'From: ' . $atts['from'] . "\r\n"; |
371 | - $recipient = implode(',', (array) $recipient); |
|
372 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
373 | - } |
|
371 | + $recipient = implode(',', (array) $recipient); |
|
372 | + $sent = mail($recipient, $atts['subject'], $message, $header); |
|
373 | + } |
|
374 | 374 | |
375 | 375 | // remove the filter now so other emails can still use it |
376 | 376 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
377 | 377 | |
378 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
378 | + do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
379 | 379 | |
380 | - if ( $sent ) { |
|
380 | + if ( $sent ) { |
|
381 | 381 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
382 | - $sent_to = array_filter( $sent_to ); |
|
383 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
384 | - $temp = str_replace('<', '<', $sent_to); |
|
382 | + $sent_to = array_filter( $sent_to ); |
|
383 | + if ( apply_filters('frm_echo_emails', false) ) { |
|
384 | + $temp = str_replace('<', '<', $sent_to); |
|
385 | 385 | echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
386 | - } |
|
387 | - return $sent_to; |
|
388 | - } |
|
389 | - } |
|
386 | + } |
|
387 | + return $sent_to; |
|
388 | + } |
|
389 | + } |
|
390 | 390 | |
391 | 391 | /** |
392 | 392 | * This function should only be fired when Mandrill is sending an HTML email |
@@ -2,10 +2,10 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmNotification { |
4 | 4 | public function __construct() { |
5 | - if ( ! defined('ABSPATH') ) { |
|
6 | - die('You are not allowed to call this page directly.'); |
|
5 | + if ( ! defined( 'ABSPATH' ) ) { |
|
6 | + die( 'You are not allowed to call this page directly.' ); |
|
7 | 7 | } |
8 | - add_action('frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3); |
|
8 | + add_action( 'frm_trigger_email_action', 'FrmNotification::trigger_email', 10, 3 ); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | public static function trigger_email( $action, $entry, $form ) { |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | $email_key = $action->ID; |
14 | 14 | |
15 | 15 | // Set the subject |
16 | - if ( empty($notification['email_subject']) ) { |
|
17 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
16 | + if ( empty( $notification['email_subject'] ) ) { |
|
17 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'email_subject', 'email_message', |
27 | 27 | ); |
28 | 28 | |
29 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
29 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
30 | 30 | |
31 | 31 | //Get all values in entry in order to get User ID field ID |
32 | 32 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -37,29 +37,29 @@ discard block |
||
37 | 37 | $user_id_key = $value->field_key; |
38 | 38 | break; |
39 | 39 | } |
40 | - unset($value); |
|
40 | + unset( $value ); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | //Filter and prepare the email fields |
44 | 44 | foreach ( $filter_fields as $f ) { |
45 | 45 | //Don't allow empty From |
46 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
47 | - $notification[ $f ] = '[admin_email]'; |
|
46 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
47 | + $notification[$f] = '[admin_email]'; |
|
48 | 48 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
49 | 49 | //Remove brackets |
50 | 50 | //Add a space in case there isn't one |
51 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
52 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
51 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
52 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
53 | 53 | |
54 | 54 | //Switch userID shortcode to email address |
55 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
56 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
55 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
56 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
57 | 57 | $user_email = $user_data->user_email; |
58 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
58 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
62 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $cc = self::explode_emails( $notification['cc'] ); |
68 | 68 | $bcc = self::explode_emails( $notification['bcc'] ); |
69 | 69 | |
70 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
70 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
71 | 71 | |
72 | 72 | // Stop now if there aren't any recipients |
73 | 73 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -77,39 +77,39 @@ discard block |
||
77 | 77 | $to_emails = array_unique( (array) $to_emails ); |
78 | 78 | |
79 | 79 | $prev_mail_body = $mail_body = $notification['email_message']; |
80 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
80 | + $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array( |
|
81 | 81 | 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
82 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
82 | + 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
|
83 | 83 | ) ); |
84 | 84 | |
85 | 85 | // Add the user info if it isn't already included |
86 | 86 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
87 | - $data = maybe_unserialize($entry->description); |
|
87 | + $data = maybe_unserialize( $entry->description ); |
|
88 | 88 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
89 | 89 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
90 | 90 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
91 | 91 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
92 | 92 | } |
93 | - unset($prev_mail_body); |
|
93 | + unset( $prev_mail_body ); |
|
94 | 94 | |
95 | 95 | // Add attachments |
96 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
96 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
97 | 97 | |
98 | - if ( ! empty($notification['email_subject']) ) { |
|
99 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
98 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
99 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | // check for a phone number |
103 | 103 | foreach ( (array) $to_emails as $email_key => $e ) { |
104 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
105 | - $e = explode(' ', $e); |
|
104 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
105 | + $e = explode( ' ', $e ); |
|
106 | 106 | |
107 | 107 | //If to_email has name <[email protected]> format |
108 | - if ( is_email(end($e)) ) { |
|
108 | + if ( is_email( end( $e ) ) ) { |
|
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - do_action('frm_send_to_not_email', array( |
|
112 | + do_action( 'frm_send_to_not_email', array( |
|
113 | 113 | 'e' => $e, |
114 | 114 | 'subject' => $notification['email_subject'], |
115 | 115 | 'mail_body' => $mail_body, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'email_key' => $email_key, |
122 | 122 | ) ); |
123 | 123 | |
124 | - unset( $to_emails[ $email_key ] ); |
|
124 | + unset( $to_emails[$email_key] ); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
@@ -144,17 +144,17 @@ discard block |
||
144 | 144 | public function entry_created( $entry_id, $form_id ) { |
145 | 145 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
146 | 146 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
147 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
147 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
151 | 151 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
152 | 152 | |
153 | - return self::send_email(compact( |
|
153 | + return self::send_email( compact( |
|
154 | 154 | 'to_email', 'subject', 'message', |
155 | 155 | 'from', 'from_name', 'plain_text', |
156 | 156 | 'attachments', 'reply_to' |
157 | - )); |
|
157 | + ) ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -187,28 +187,28 @@ discard block |
||
187 | 187 | private static function format_email_fields( &$atts, $admin_email ) { |
188 | 188 | |
189 | 189 | // If from is empty or is set to admin_email, set it now |
190 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
190 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
191 | 191 | |
192 | 192 | // Filter values in these fields |
193 | 193 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
194 | 194 | |
195 | 195 | foreach ( $filter_fields as $f ) { |
196 | 196 | // If empty, just skip it |
197 | - if ( empty( $atts[ $f ] ) ) { |
|
197 | + if ( empty( $atts[$f] ) ) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // to_email, cc, and bcc can be an array |
202 | - if ( is_array( $atts[ $f ] ) ) { |
|
203 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
202 | + if ( is_array( $atts[$f] ) ) { |
|
203 | + foreach ( $atts[$f] as $key => $val ) { |
|
204 | 204 | self::format_single_field( $atts, $f, $val, $key ); |
205 | 205 | unset( $key, $val ); |
206 | 206 | } |
207 | - unset($f); |
|
207 | + unset( $f ); |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
211 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // If reply-to isn't set, make it match the from settings |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
217 | 217 | } |
218 | 218 | |
219 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
219 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
220 | 220 | $atts['to_email'] = $admin_email; |
221 | 221 | } |
222 | 222 | } |
@@ -239,20 +239,20 @@ discard block |
||
239 | 239 | * @param int $key if in array, this will be set |
240 | 240 | */ |
241 | 241 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
242 | - $val = trim($val); |
|
242 | + $val = trim( $val ); |
|
243 | 243 | |
244 | 244 | // If just a plain email is used |
245 | - if ( is_email($val) ) { |
|
245 | + if ( is_email( $val ) ) { |
|
246 | 246 | // add sender's name if not included in $from |
247 | 247 | if ( $f == 'from' ) { |
248 | - $part_2 = $atts[ $f ]; |
|
249 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
248 | + $part_2 = $atts[$f]; |
|
249 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
250 | 250 | } else { |
251 | 251 | return; |
252 | 252 | } |
253 | 253 | } else { |
254 | - $parts = explode(' ', $val); |
|
255 | - $part_2 = end($parts); |
|
254 | + $parts = explode( ' ', $val ); |
|
255 | + $part_2 = end( $parts ); |
|
256 | 256 | |
257 | 257 | // If inputted correcly, $part_2 should be an email |
258 | 258 | if ( is_email( $part_2 ) ) { |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
261 | 261 | // In case someone just puts a name in the From or Reply To field |
262 | 262 | $part_1 = $val; |
263 | - $part_2 = get_option('admin_email'); |
|
263 | + $part_2 = get_option( 'admin_email' ); |
|
264 | 264 | } else { |
265 | 265 | // In case someone just puts a name in any other email field |
266 | 266 | if ( false !== $key ) { |
267 | - unset( $atts[ $f ][ $key ] ); |
|
267 | + unset( $atts[$f][$key] ); |
|
268 | 268 | return; |
269 | 269 | } |
270 | - $atts[ $f ] = ''; |
|
270 | + $atts[$f] = ''; |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | } |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | |
289 | 289 | // If value is an array |
290 | 290 | if ( false !== $key ) { |
291 | - $atts[ $f ][ $key ] = $final_val; |
|
291 | + $atts[$f][$key] = $final_val; |
|
292 | 292 | return; |
293 | 293 | } |
294 | - $atts[ $f ] = $final_val; |
|
294 | + $atts[$f] = $final_val; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | public static function send_email( $atts ) { |
298 | - $admin_email = get_option('admin_email'); |
|
298 | + $admin_email = get_option( 'admin_email' ); |
|
299 | 299 | $defaults = array( |
300 | 300 | 'to_email' => $admin_email, |
301 | 301 | 'subject' => '', |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | 'reply_to' => $admin_email, |
309 | 309 | 'attachments' => array(), |
310 | 310 | ); |
311 | - $atts = wp_parse_args($atts, $defaults); |
|
311 | + $atts = wp_parse_args( $atts, $defaults ); |
|
312 | 312 | |
313 | 313 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
314 | 314 | self::format_email_fields( $atts, $admin_email ); |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
322 | 322 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
323 | 323 | foreach ( $array_fields as $key => $a_field ) { |
324 | - if ( empty($a_field) ) { |
|
324 | + if ( empty( $a_field ) ) { |
|
325 | 325 | continue; |
326 | 326 | } |
327 | 327 | |
328 | 328 | foreach ( (array) $a_field as $email ) { |
329 | - $cc[ $key ][] = $email; |
|
329 | + $cc[$key][] = $email; |
|
330 | 330 | } |
331 | - unset($key, $a_field); |
|
331 | + unset( $key, $a_field ); |
|
332 | 332 | } |
333 | 333 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
334 | 334 | |
@@ -337,52 +337,52 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
340 | - $charset = get_option('blog_charset'); |
|
340 | + $charset = get_option( 'blog_charset' ); |
|
341 | 341 | |
342 | 342 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
343 | 343 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
344 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
344 | + $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES ); |
|
345 | 345 | |
346 | - $message = do_shortcode($atts['message']); |
|
346 | + $message = do_shortcode( $atts['message'] ); |
|
347 | 347 | |
348 | 348 | if ( $atts['plain_text'] ) { |
349 | 349 | //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
350 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
350 | + $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES ); |
|
351 | 351 | } else { |
352 | 352 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
353 | 353 | add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
354 | 354 | } |
355 | 355 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
356 | 356 | |
357 | - $header = apply_filters('frm_email_header', $header, array( |
|
357 | + $header = apply_filters( 'frm_email_header', $header, array( |
|
358 | 358 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
359 | 359 | ) ); |
360 | 360 | |
361 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
361 | + if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) { |
|
362 | 362 | $atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?='; |
363 | 363 | } |
364 | 364 | |
365 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
366 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
365 | + remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
366 | + remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); |
|
367 | 367 | |
368 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
368 | + $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] ); |
|
369 | 369 | if ( ! $sent ) { |
370 | 370 | $header = 'From: ' . $atts['from'] . "\r\n"; |
371 | - $recipient = implode(',', (array) $recipient); |
|
372 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
371 | + $recipient = implode( ',', (array) $recipient ); |
|
372 | + $sent = mail( $recipient, $atts['subject'], $message, $header ); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // remove the filter now so other emails can still use it |
376 | 376 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
377 | 377 | |
378 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
378 | + do_action( 'frm_notification', $recipient, $atts['subject'], $message ); |
|
379 | 379 | |
380 | 380 | if ( $sent ) { |
381 | 381 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
382 | 382 | $sent_to = array_filter( $sent_to ); |
383 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
384 | - $temp = str_replace('<', '<', $sent_to); |
|
385 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
383 | + if ( apply_filters( 'frm_echo_emails', false ) ) { |
|
384 | + $temp = str_replace( '<', '<', $sent_to ); |
|
385 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
386 | 386 | } |
387 | 387 | return $sent_to; |
388 | 388 | } |
@@ -2,109 +2,109 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmXMLController { |
4 | 4 | |
5 | - public static function menu() { |
|
5 | + public static function menu() { |
|
6 | 6 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' ); |
7 | - } |
|
7 | + } |
|
8 | 8 | |
9 | - public static function add_default_templates() { |
|
9 | + public static function add_default_templates() { |
|
10 | 10 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
11 | - // XML import is not enabled on your server |
|
12 | - return; |
|
13 | - } |
|
11 | + // XML import is not enabled on your server |
|
12 | + return; |
|
13 | + } |
|
14 | 14 | |
15 | - $set_err = libxml_use_internal_errors(true); |
|
16 | - $loader = libxml_disable_entity_loader( true ); |
|
15 | + $set_err = libxml_use_internal_errors(true); |
|
16 | + $loader = libxml_disable_entity_loader( true ); |
|
17 | 17 | |
18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
19 | 19 | |
20 | - foreach ( (array) $files as $file ) { |
|
21 | - FrmXMLHelper::import_xml($file); |
|
22 | - unset($file); |
|
23 | - } |
|
24 | - /* |
|
20 | + foreach ( (array) $files as $file ) { |
|
21 | + FrmXMLHelper::import_xml($file); |
|
22 | + unset($file); |
|
23 | + } |
|
24 | + /* |
|
25 | 25 | if(is_wp_error($result)) |
26 | 26 | $errors[] = $result->get_error_message(); |
27 | 27 | else if($result) |
28 | 28 | $message = $result; |
29 | 29 | */ |
30 | 30 | |
31 | - unset( $files ); |
|
31 | + unset( $files ); |
|
32 | 32 | |
33 | - libxml_use_internal_errors( $set_err ); |
|
34 | - libxml_disable_entity_loader( $loader ); |
|
35 | - } |
|
33 | + libxml_use_internal_errors( $set_err ); |
|
34 | + libxml_disable_entity_loader( $loader ); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function route() { |
|
38 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
37 | + public static function route() { |
|
38 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
39 | 39 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
40 | 40 | if ( $action == 'import_xml' ) { |
41 | - return self::import_xml(); |
|
41 | + return self::import_xml(); |
|
42 | 42 | } else if ( $action == 'export_xml' ) { |
43 | - return self::export_xml(); |
|
44 | - } else { |
|
45 | - if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
46 | - return self::form(); |
|
47 | - } |
|
48 | - } |
|
49 | - } |
|
50 | - |
|
51 | - public static function form( $errors = array(), $message = '' ) { |
|
43 | + return self::export_xml(); |
|
44 | + } else { |
|
45 | + if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
46 | + return self::form(); |
|
47 | + } |
|
48 | + } |
|
49 | + } |
|
50 | + |
|
51 | + public static function form( $errors = array(), $message = '' ) { |
|
52 | 52 | $where = array( |
53 | 53 | 'status' => array( null, '', 'published' ), |
54 | 54 | ); |
55 | 55 | $forms = FrmForm::getAll( $where, 'name' ); |
56 | 56 | |
57 | - $export_types = apply_filters( 'frm_xml_export_types', |
|
58 | - array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
59 | - ); |
|
57 | + $export_types = apply_filters( 'frm_xml_export_types', |
|
58 | + array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
59 | + ); |
|
60 | 60 | |
61 | - $export_format = apply_filters( 'frm_export_formats', array( |
|
62 | - 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
61 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
62 | + 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
63 | 63 | 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ), |
64 | - ) ); |
|
64 | + ) ); |
|
65 | 65 | |
66 | 66 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' ); |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - public static function import_xml() { |
|
70 | - $errors = array(); |
|
71 | - $message = ''; |
|
69 | + public static function import_xml() { |
|
70 | + $errors = array(); |
|
71 | + $message = ''; |
|
72 | 72 | |
73 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
74 | - if ( $permission_error !== false ) { |
|
75 | - $errors[] = $permission_error; |
|
76 | - self::form($errors); |
|
77 | - return; |
|
78 | - } |
|
73 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
74 | + if ( $permission_error !== false ) { |
|
75 | + $errors[] = $permission_error; |
|
76 | + self::form($errors); |
|
77 | + return; |
|
78 | + } |
|
79 | 79 | |
80 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
81 | - $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
82 | - self::form($errors); |
|
83 | - return; |
|
84 | - } |
|
80 | + if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
81 | + $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
82 | + self::form($errors); |
|
83 | + return; |
|
84 | + } |
|
85 | 85 | |
86 | - $file = $_FILES['frm_import_file']['tmp_name']; |
|
86 | + $file = $_FILES['frm_import_file']['tmp_name']; |
|
87 | 87 | |
88 | - if ( ! is_uploaded_file( $file ) ) { |
|
89 | - unset($file); |
|
90 | - $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
91 | - self::form($errors); |
|
92 | - return; |
|
93 | - } |
|
88 | + if ( ! is_uploaded_file( $file ) ) { |
|
89 | + unset($file); |
|
90 | + $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
91 | + self::form($errors); |
|
92 | + return; |
|
93 | + } |
|
94 | 94 | |
95 | - //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
95 | + //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
96 | 96 | |
97 | - $export_format = apply_filters('frm_export_formats', array( |
|
97 | + $export_format = apply_filters('frm_export_formats', array( |
|
98 | 98 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
99 | 99 | ) ); |
100 | 100 | |
101 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
102 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
103 | - // allow other file types to be imported |
|
101 | + $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
102 | + if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
103 | + // allow other file types to be imported |
|
104 | 104 | do_action( 'frm_before_import_' . $file_type ); |
105 | - return; |
|
106 | - } |
|
107 | - unset($file_type); |
|
105 | + return; |
|
106 | + } |
|
107 | + unset($file_type); |
|
108 | 108 | |
109 | 109 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
110 | 110 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -123,145 +123,145 @@ discard block |
||
123 | 123 | libxml_use_internal_errors( $set_err ); |
124 | 124 | libxml_disable_entity_loader( $loader ); |
125 | 125 | |
126 | - self::form($errors, $message); |
|
127 | - } |
|
126 | + self::form($errors, $message); |
|
127 | + } |
|
128 | 128 | |
129 | - public static function export_xml() { |
|
130 | - $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
131 | - if ( ! empty($error) ) { |
|
132 | - wp_die( $error ); |
|
133 | - } |
|
129 | + public static function export_xml() { |
|
130 | + $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
131 | + if ( ! empty($error) ) { |
|
132 | + wp_die( $error ); |
|
133 | + } |
|
134 | 134 | |
135 | 135 | $ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() ); |
136 | 136 | $type = FrmAppHelper::get_post_param( 'type', array() ); |
137 | 137 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
138 | 138 | |
139 | - if ( ! headers_sent() && ! $type ) { |
|
140 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
141 | - die(); |
|
142 | - } |
|
139 | + if ( ! headers_sent() && ! $type ) { |
|
140 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
141 | + die(); |
|
142 | + } |
|
143 | 143 | |
144 | - if ( $format == 'xml' ) { |
|
145 | - self::generate_xml($type, compact('ids')); |
|
144 | + if ( $format == 'xml' ) { |
|
145 | + self::generate_xml($type, compact('ids')); |
|
146 | 146 | } if ( $format == 'csv' ) { |
147 | 147 | self::generate_csv( compact('ids') ); |
148 | - } else { |
|
148 | + } else { |
|
149 | 149 | do_action( 'frm_export_format_' . $format, compact('ids') ); |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | - wp_die(); |
|
153 | - } |
|
152 | + wp_die(); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | public static function generate_xml( $type, $args = array() ) { |
156 | - global $wpdb; |
|
156 | + global $wpdb; |
|
157 | 157 | |
158 | - self::prepare_types_array( $type ); |
|
158 | + self::prepare_types_array( $type ); |
|
159 | 159 | |
160 | - $tables = array( |
|
160 | + $tables = array( |
|
161 | 161 | 'items' => $wpdb->prefix . 'frm_items', |
162 | 162 | 'forms' => $wpdb->prefix . 'frm_forms', |
163 | - 'posts' => $wpdb->posts, |
|
164 | - 'styles' => $wpdb->posts, |
|
165 | - 'actions' => $wpdb->posts, |
|
166 | - ); |
|
163 | + 'posts' => $wpdb->posts, |
|
164 | + 'styles' => $wpdb->posts, |
|
165 | + 'actions' => $wpdb->posts, |
|
166 | + ); |
|
167 | 167 | |
168 | 168 | $defaults = array( 'ids' => false ); |
169 | - $args = wp_parse_args( $args, $defaults ); |
|
169 | + $args = wp_parse_args( $args, $defaults ); |
|
170 | 170 | |
171 | - $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
171 | + $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
172 | 172 | |
173 | - if ( ! empty( $sitename ) ) { |
|
173 | + if ( ! empty( $sitename ) ) { |
|
174 | 174 | $sitename .= '.'; |
175 | 175 | } |
176 | - $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
176 | + $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
177 | 177 | |
178 | - header( 'Content-Description: File Transfer' ); |
|
179 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
180 | - header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
178 | + header( 'Content-Description: File Transfer' ); |
|
179 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
180 | + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
181 | 181 | |
182 | - //make sure ids are numeric |
|
183 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
184 | - $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
185 | - } |
|
182 | + //make sure ids are numeric |
|
183 | + if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
184 | + $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
185 | + } |
|
186 | 186 | |
187 | - $records = array(); |
|
187 | + $records = array(); |
|
188 | 188 | |
189 | 189 | foreach ( $type as $tb_type ) { |
190 | - $where = array(); |
|
190 | + $where = array(); |
|
191 | 191 | $join = ''; |
192 | - $table = $tables[ $tb_type ]; |
|
192 | + $table = $tables[ $tb_type ]; |
|
193 | 193 | |
194 | 194 | $select = $table . '.id'; |
195 | - $query_vars = array(); |
|
195 | + $query_vars = array(); |
|
196 | 196 | |
197 | - switch ( $tb_type ) { |
|
198 | - case 'forms': |
|
199 | - //add forms |
|
200 | - if ( $args['ids'] ) { |
|
197 | + switch ( $tb_type ) { |
|
198 | + case 'forms': |
|
199 | + //add forms |
|
200 | + if ( $args['ids'] ) { |
|
201 | 201 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
202 | - } else { |
|
202 | + } else { |
|
203 | 203 | $where[ $table . '.status !' ] = 'draft'; |
204 | - } |
|
205 | - break; |
|
206 | - case 'actions': |
|
204 | + } |
|
205 | + break; |
|
206 | + case 'actions': |
|
207 | 207 | $select = $table . '.ID'; |
208 | 208 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
209 | - if ( ! empty($args['ids']) ) { |
|
209 | + if ( ! empty($args['ids']) ) { |
|
210 | 210 | $where['menu_order'] = $args['ids']; |
211 | - } |
|
212 | - break; |
|
213 | - case 'items': |
|
214 | - //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
215 | - if ( $args['ids'] ) { |
|
211 | + } |
|
212 | + break; |
|
213 | + case 'items': |
|
214 | + //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
215 | + if ( $args['ids'] ) { |
|
216 | 216 | $where[ $table . '.form_id' ] = $args['ids']; |
217 | - } |
|
218 | - break; |
|
219 | - case 'styles': |
|
220 | - // Loop through all exported forms and get their selected style IDs |
|
217 | + } |
|
218 | + break; |
|
219 | + case 'styles': |
|
220 | + // Loop through all exported forms and get their selected style IDs |
|
221 | 221 | $frm_style = new FrmStyle(); |
222 | 222 | $default_style = $frm_style->get_default_style(); |
223 | - $form_ids = $args['ids']; |
|
224 | - $style_ids = array(); |
|
225 | - foreach ( $form_ids as $form_id ) { |
|
226 | - $form_data = FrmForm::getOne( $form_id ); |
|
227 | - // For forms that have not been updated while running 2.0, check if custom_style is set |
|
228 | - if ( isset( $form_data->options['custom_style'] ) ) { |
|
223 | + $form_ids = $args['ids']; |
|
224 | + $style_ids = array(); |
|
225 | + foreach ( $form_ids as $form_id ) { |
|
226 | + $form_data = FrmForm::getOne( $form_id ); |
|
227 | + // For forms that have not been updated while running 2.0, check if custom_style is set |
|
228 | + if ( isset( $form_data->options['custom_style'] ) ) { |
|
229 | 229 | if ( $form_data->options['custom_style'] == 1 ) { |
230 | 230 | $style_ids[] = $default_style->ID; |
231 | 231 | } else { |
232 | 232 | $style_ids[] = $form_data->options['custom_style']; |
233 | 233 | } |
234 | - } |
|
235 | - unset( $form_id, $form_data ); |
|
236 | - } |
|
234 | + } |
|
235 | + unset( $form_id, $form_data ); |
|
236 | + } |
|
237 | 237 | $select = $table . '.ID'; |
238 | - $where['post_type'] = 'frm_styles'; |
|
239 | - |
|
240 | - // Only export selected styles |
|
241 | - if ( ! empty( $style_ids ) ) { |
|
242 | - $where['ID'] = $style_ids; |
|
243 | - } |
|
244 | - break; |
|
245 | - default: |
|
238 | + $where['post_type'] = 'frm_styles'; |
|
239 | + |
|
240 | + // Only export selected styles |
|
241 | + if ( ! empty( $style_ids ) ) { |
|
242 | + $where['ID'] = $style_ids; |
|
243 | + } |
|
244 | + break; |
|
245 | + default: |
|
246 | 246 | $select = $table . '.ID'; |
247 | - $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
248 | - $where['pm.meta_key'] = 'frm_form_id'; |
|
249 | - |
|
250 | - if ( empty($args['ids']) ) { |
|
251 | - $where['pm.meta_value >'] = 1; |
|
252 | - } else { |
|
253 | - $where['pm.meta_value'] = $args['ids']; |
|
254 | - } |
|
255 | - break; |
|
256 | - } |
|
247 | + $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
248 | + $where['pm.meta_key'] = 'frm_form_id'; |
|
249 | + |
|
250 | + if ( empty($args['ids']) ) { |
|
251 | + $where['pm.meta_value >'] = 1; |
|
252 | + } else { |
|
253 | + $where['pm.meta_value'] = $args['ids']; |
|
254 | + } |
|
255 | + break; |
|
256 | + } |
|
257 | 257 | |
258 | 258 | $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
259 | - unset($tb_type); |
|
260 | - } |
|
259 | + unset($tb_type); |
|
260 | + } |
|
261 | 261 | |
262 | 262 | echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
263 | 263 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
264 | - } |
|
264 | + } |
|
265 | 265 | |
266 | 266 | private static function prepare_types_array( &$type ) { |
267 | 267 | $type = (array) $type; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
345 | - * Get the fields that should be included in the CSV export |
|
346 | - * |
|
347 | - * @since 2.0.19 |
|
348 | - * |
|
349 | - * @param int $form_id |
|
350 | - * @param object $form |
|
351 | - * @return array $csv_fields |
|
352 | - */ |
|
345 | + * Get the fields that should be included in the CSV export |
|
346 | + * |
|
347 | + * @since 2.0.19 |
|
348 | + * |
|
349 | + * @param int $form_id |
|
350 | + * @param object $form |
|
351 | + * @return array $csv_fields |
|
352 | + */ |
|
353 | 353 | private static function get_fields_for_csv_export( $form_id, $form ) { |
354 | 354 | // Phase frm_csv_field_ids out by 2.01.05 |
355 | 355 | $csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) ); |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | } |
380 | 380 | |
381 | 381 | public static function allow_mime( $mimes ) { |
382 | - if ( ! isset( $mimes['csv'] ) ) { |
|
383 | - // allow csv files |
|
384 | - $mimes['csv'] = 'text/csv'; |
|
385 | - } |
|
386 | - |
|
387 | - if ( ! isset( $mimes['xml'] ) ) { |
|
388 | - // allow xml |
|
389 | - $mimes['xml'] = 'text/xml'; |
|
390 | - } |
|
391 | - |
|
392 | - return $mimes; |
|
393 | - } |
|
382 | + if ( ! isset( $mimes['csv'] ) ) { |
|
383 | + // allow csv files |
|
384 | + $mimes['csv'] = 'text/csv'; |
|
385 | + } |
|
386 | + |
|
387 | + if ( ! isset( $mimes['xml'] ) ) { |
|
388 | + // allow xml |
|
389 | + $mimes['xml'] = 'text/xml'; |
|
390 | + } |
|
391 | + |
|
392 | + return $mimes; |
|
393 | + } |
|
394 | 394 | } |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | return; |
13 | 13 | } |
14 | 14 | |
15 | - $set_err = libxml_use_internal_errors(true); |
|
15 | + $set_err = libxml_use_internal_errors( true ); |
|
16 | 16 | $loader = libxml_disable_entity_loader( true ); |
17 | 17 | |
18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
19 | 19 | |
20 | 20 | foreach ( (array) $files as $file ) { |
21 | - FrmXMLHelper::import_xml($file); |
|
22 | - unset($file); |
|
21 | + FrmXMLHelper::import_xml( $file ); |
|
22 | + unset( $file ); |
|
23 | 23 | } |
24 | 24 | /* |
25 | 25 | if(is_wp_error($result)) |
@@ -70,41 +70,41 @@ discard block |
||
70 | 70 | $errors = array(); |
71 | 71 | $message = ''; |
72 | 72 | |
73 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
73 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); |
|
74 | 74 | if ( $permission_error !== false ) { |
75 | 75 | $errors[] = $permission_error; |
76 | - self::form($errors); |
|
76 | + self::form( $errors ); |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
80 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
80 | + if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
81 | 81 | $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
82 | - self::form($errors); |
|
82 | + self::form( $errors ); |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | $file = $_FILES['frm_import_file']['tmp_name']; |
87 | 87 | |
88 | 88 | if ( ! is_uploaded_file( $file ) ) { |
89 | - unset($file); |
|
89 | + unset( $file ); |
|
90 | 90 | $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
91 | - self::form($errors); |
|
91 | + self::form( $errors ); |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
96 | 96 | |
97 | - $export_format = apply_filters('frm_export_formats', array( |
|
97 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
98 | 98 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
99 | 99 | ) ); |
100 | 100 | |
101 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
102 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
101 | + $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
|
102 | + if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) { |
|
103 | 103 | // allow other file types to be imported |
104 | 104 | do_action( 'frm_before_import_' . $file_type ); |
105 | 105 | return; |
106 | 106 | } |
107 | - unset($file_type); |
|
107 | + unset( $file_type ); |
|
108 | 108 | |
109 | 109 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
110 | 110 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | libxml_use_internal_errors( $set_err ); |
124 | 124 | libxml_disable_entity_loader( $loader ); |
125 | 125 | |
126 | - self::form($errors, $message); |
|
126 | + self::form( $errors, $message ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | public static function export_xml() { |
130 | 130 | $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
131 | - if ( ! empty($error) ) { |
|
131 | + if ( ! empty( $error ) ) { |
|
132 | 132 | wp_die( $error ); |
133 | 133 | } |
134 | 134 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | if ( $format == 'xml' ) { |
145 | - self::generate_xml($type, compact('ids')); |
|
145 | + self::generate_xml( $type, compact( 'ids' ) ); |
|
146 | 146 | } if ( $format == 'csv' ) { |
147 | - self::generate_csv( compact('ids') ); |
|
147 | + self::generate_csv( compact( 'ids' ) ); |
|
148 | 148 | } else { |
149 | - do_action( 'frm_export_format_' . $format, compact('ids') ); |
|
149 | + do_action( 'frm_export_format_' . $format, compact( 'ids' ) ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | wp_die(); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | foreach ( $type as $tb_type ) { |
190 | 190 | $where = array(); |
191 | 191 | $join = ''; |
192 | - $table = $tables[ $tb_type ]; |
|
192 | + $table = $tables[$tb_type]; |
|
193 | 193 | |
194 | 194 | $select = $table . '.id'; |
195 | 195 | $query_vars = array(); |
@@ -200,20 +200,20 @@ discard block |
||
200 | 200 | if ( $args['ids'] ) { |
201 | 201 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
202 | 202 | } else { |
203 | - $where[ $table . '.status !' ] = 'draft'; |
|
203 | + $where[$table . '.status !'] = 'draft'; |
|
204 | 204 | } |
205 | 205 | break; |
206 | 206 | case 'actions': |
207 | 207 | $select = $table . '.ID'; |
208 | 208 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
209 | - if ( ! empty($args['ids']) ) { |
|
209 | + if ( ! empty( $args['ids'] ) ) { |
|
210 | 210 | $where['menu_order'] = $args['ids']; |
211 | 211 | } |
212 | 212 | break; |
213 | 213 | case 'items': |
214 | 214 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
215 | 215 | if ( $args['ids'] ) { |
216 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
216 | + $where[$table . '.form_id'] = $args['ids']; |
|
217 | 217 | } |
218 | 218 | break; |
219 | 219 | case 'styles': |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
248 | 248 | $where['pm.meta_key'] = 'frm_form_id'; |
249 | 249 | |
250 | - if ( empty($args['ids']) ) { |
|
250 | + if ( empty( $args['ids'] ) ) { |
|
251 | 251 | $where['pm.meta_value >'] = 1; |
252 | 252 | } else { |
253 | 253 | $where['pm.meta_value'] = $args['ids']; |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | break; |
256 | 256 | } |
257 | 257 | |
258 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
259 | - unset($tb_type); |
|
258 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
259 | + unset( $tb_type ); |
|
260 | 260 | } |
261 | 261 | |
262 | - echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
|
262 | + echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n"; |
|
263 | 263 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
264 | 264 | } |
265 | 265 | |
@@ -297,10 +297,10 @@ discard block |
||
297 | 297 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
298 | 298 | } |
299 | 299 | |
300 | - set_time_limit(0); //Remove time limit to execute this function |
|
301 | - $mem_limit = str_replace('M', '', ini_get('memory_limit')); |
|
300 | + set_time_limit( 0 ); //Remove time limit to execute this function |
|
301 | + $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) ); |
|
302 | 302 | if ( (int) $mem_limit < 256 ) { |
303 | - ini_set('memory_limit', '256M'); |
|
303 | + ini_set( 'memory_limit', '256M' ); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | global $wpdb; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $no_export_fields = FrmField::no_save_fields(); |
371 | 371 | foreach ( $csv_fields as $k => $f ) { |
372 | 372 | if ( in_array( $f->type, $no_export_fields ) ) { |
373 | - unset( $csv_fields[ $k ] ); |
|
373 | + unset( $csv_fields[$k] ); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
@@ -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 | |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
9 | 9 | |
10 | - if ( strpos($type, '|') ) { |
|
11 | - list($type, $setting) = explode('|', $type); |
|
10 | + if ( strpos( $type, '|' ) ) { |
|
11 | + list( $type, $setting ) = explode( '|', $type ); |
|
12 | 12 | } |
13 | 13 | |
14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
16 | 16 | |
17 | 17 | $values = array(); |
18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | if ( $var == 'field_options' ) { |
21 | 21 | $values['field_options'] = array(); |
22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
24 | - unset($opt_var, $opt_default); |
|
23 | + $values['field_options'][$opt_var] = $opt_default; |
|
24 | + unset( $opt_var, $opt_default ); |
|
25 | 25 | } |
26 | 26 | } else { |
27 | - $values[ $var ] = $default; |
|
27 | + $values[$var] = $default; |
|
28 | 28 | } |
29 | - unset($var, $default); |
|
29 | + unset( $var, $default ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
34 | 34 | $values['field_options']['data_type'] = $setting; |
35 | 35 | } else { |
36 | - $values['field_options'][ $setting ] = 1; |
|
36 | + $values['field_options'][$setting] = 1; |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | $fields = FrmField::field_selection(); |
59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
59 | + $fields = array_merge( $fields, FrmField::pro_field_selection() ); |
|
60 | 60 | |
61 | - if ( isset( $fields[ $type ] ) ) { |
|
62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
61 | + if ( isset( $fields[$type] ) ) { |
|
62 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
63 | 63 | } |
64 | 64 | |
65 | - unset($fields); |
|
65 | + unset( $fields ); |
|
66 | 66 | |
67 | 67 | return $values; |
68 | 68 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $values['form_name'] = ''; |
89 | 89 | } else { |
90 | 90 | foreach ( $defaults as $var => $default ) { |
91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | - unset($var, $default); |
|
91 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | + unset( $var, $default ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $values['options'] = $record->options; |
101 | 101 | $values['field_options'] = $record->field_options; |
102 | 102 | |
103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
103 | + $defaults = self::get_default_field_opts( $values['type'], $record, true ); |
|
104 | 104 | |
105 | 105 | if ( $values['type'] == 'captcha' ) { |
106 | 106 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | foreach ( $defaults as $opt => $default ) { |
111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
112 | - unset($opt, $default); |
|
111 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
112 | + unset( $opt, $default ); |
|
113 | 113 | } |
114 | 114 | |
115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
115 | + $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
|
116 | 116 | |
117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
118 | 118 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | global $wpdb; |
133 | 133 | |
134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
134 | + $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id; |
|
135 | 135 | |
136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
137 | 137 | |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | |
154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
155 | 155 | $values['form_id'] = $form_id; |
156 | - $values['options'] = maybe_serialize($field->options); |
|
157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
156 | + $values['options'] = maybe_serialize( $field->options ); |
|
157 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
158 | 158 | |
159 | 159 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
160 | - $values[ $col ] = $field->{$col}; |
|
160 | + $values[$col] = $field->{$col}; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -171,21 +171,21 @@ discard block |
||
171 | 171 | |
172 | 172 | $conf_msg = __( 'The entered values do not match', 'formidable' ); |
173 | 173 | $defaults = array( |
174 | - 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ), |
|
175 | - 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ), |
|
174 | + 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ), |
|
175 | + 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ), |
|
176 | 176 | 'blank' => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ), |
177 | 177 | 'conf_msg' => array( 'full' => $conf_msg, 'part' => $conf_msg ), |
178 | 178 | ); |
179 | 179 | |
180 | 180 | $msg = FrmField::get_option( $field, $error ); |
181 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
181 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
182 | 182 | $msg = do_shortcode( $msg ); |
183 | 183 | return $msg; |
184 | 184 | } |
185 | 185 | |
186 | 186 | public static function get_form_fields( $form_id, $error = false ) { |
187 | - $fields = FrmField::get_all_for_form($form_id); |
|
188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
187 | + $fields = FrmField::get_all_for_form( $form_id ); |
|
188 | + $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error ); |
|
189 | 189 | return $fields; |
190 | 190 | } |
191 | 191 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | </div> |
209 | 209 | DEFAULT_HTML; |
210 | 210 | } else { |
211 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
211 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
214 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
218 | + $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form ); |
|
219 | 219 | |
220 | 220 | $defaults = array( |
221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -223,42 +223,42 @@ discard block |
||
223 | 223 | 'field_plus_id' => '', |
224 | 224 | 'section_id' => '', |
225 | 225 | ); |
226 | - $args = wp_parse_args($args, $defaults); |
|
226 | + $args = wp_parse_args( $args, $defaults ); |
|
227 | 227 | $field_name = $args['field_name']; |
228 | 228 | $field_id = $args['field_id']; |
229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
229 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
230 | 230 | |
231 | - if ( FrmField::is_multiple_select($field) ) { |
|
231 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
232 | 232 | $field_name .= '[]'; |
233 | 233 | } |
234 | 234 | |
235 | 235 | //replace [id] |
236 | - $html = str_replace('[id]', $field_id, $html); |
|
236 | + $html = str_replace( '[id]', $field_id, $html ); |
|
237 | 237 | |
238 | 238 | // Remove the for attribute for captcha |
239 | 239 | if ( $field['type'] == 'captcha' ) { |
240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
240 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | // set the label for |
244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
244 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
245 | 245 | |
246 | 246 | //replace [key] |
247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
247 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
248 | 248 | |
249 | 249 | //replace [description] and [required_label] and [error] |
250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
251 | 251 | if ( ! is_array( $errors ) ) { |
252 | 252 | $errors = array(); |
253 | 253 | } |
254 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
254 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
255 | 255 | |
256 | 256 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
257 | 257 | if ( $field['type'] == 'divider' ) { |
258 | 258 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
259 | 259 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
260 | 260 | } else { |
261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
261 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
@@ -268,41 +268,41 @@ discard block |
||
268 | 268 | |
269 | 269 | //replace [required_class] |
270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
271 | + $html = str_replace( '[required_class]', $required_class, $html ); |
|
272 | 272 | |
273 | 273 | //replace [label_position] |
274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
274 | + $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form ); |
|
275 | 275 | $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
277 | 277 | |
278 | 278 | //replace [field_name] |
279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
279 | + $html = str_replace( '[field_name]', $field['name'], $html ); |
|
280 | 280 | |
281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
282 | 282 | |
283 | 283 | //replace [entry_key] |
284 | 284 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
285 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
286 | 286 | |
287 | 287 | //replace [input] |
288 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
288 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
289 | 289 | global $frm_vars; |
290 | 290 | $frm_settings = FrmAppHelper::get_settings(); |
291 | 291 | |
292 | 292 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
293 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
293 | + $atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
294 | 294 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
295 | 295 | |
296 | 296 | $replace_with = ''; |
297 | 297 | |
298 | 298 | if ( $tag == 'input' ) { |
299 | - if ( isset($atts['opt']) ) { |
|
300 | - $atts['opt']--; |
|
299 | + if ( isset( $atts['opt'] ) ) { |
|
300 | + $atts['opt'] --; |
|
301 | 301 | } |
302 | 302 | |
303 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
304 | - if ( isset($atts['class']) ) { |
|
305 | - unset($atts['class']); |
|
303 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
304 | + if ( isset( $atts['class'] ) ) { |
|
305 | + unset( $atts['class'] ); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | $field['shortcodes'] = $atts; |
@@ -311,33 +311,33 @@ discard block |
||
311 | 311 | $replace_with = ob_get_contents(); |
312 | 312 | ob_end_clean(); |
313 | 313 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
314 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
314 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
315 | 315 | } |
316 | 316 | |
317 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
317 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | if ( $form ) { |
321 | 321 | $form = (array) $form; |
322 | 322 | |
323 | 323 | //replace [form_key] |
324 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
324 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
325 | 325 | |
326 | 326 | //replace [form_name] |
327 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
327 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
328 | 328 | } |
329 | 329 | $html .= "\n"; |
330 | 330 | |
331 | 331 | //Return html if conf_field to prevent loop |
332 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
332 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
333 | 333 | return $html; |
334 | 334 | } |
335 | 335 | |
336 | 336 | //If field is in repeating section |
337 | 337 | if ( $args['section_id'] ) { |
338 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
338 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) ); |
|
339 | 339 | } else { |
340 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
340 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) ); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | self::remove_collapse_shortcode( $html ); |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | */ |
383 | 383 | private static function get_field_div_classes( $field_id, $field, $errors, $html ) { |
384 | 384 | // Add error class |
385 | - $classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
385 | + $classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
386 | 386 | |
387 | 387 | // Add label position class |
388 | 388 | $classes .= ' frm_' . $field['label'] . '_container'; |
389 | 389 | |
390 | 390 | // Add CSS layout classes |
391 | 391 | if ( ! empty( $field['classes'] ) ) { |
392 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
392 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
393 | 393 | $classes .= ' frm_form_field'; |
394 | 394 | } |
395 | 395 | $classes .= ' ' . $field['classes']; |
@@ -428,15 +428,15 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | $with_tags = $args['conditional_check'] ? 3 : 2; |
431 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
432 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
433 | - $tag = str_replace(']', '', $tag); |
|
434 | - $tags = explode(' ', $tag); |
|
435 | - if ( is_array($tags) ) { |
|
431 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
432 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
433 | + $tag = str_replace( ']', '', $tag ); |
|
434 | + $tags = explode( ' ', $tag ); |
|
435 | + if ( is_array( $tags ) ) { |
|
436 | 436 | $tag = $tags[0]; |
437 | 437 | } |
438 | 438 | } else { |
439 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
439 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | return $tag; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | |
481 | 481 | public static function show_single_option( $field ) { |
482 | 482 | $field_name = $field['name']; |
483 | - $html_id = self::get_html_id($field); |
|
483 | + $html_id = self::get_html_id( $field ); |
|
484 | 484 | foreach ( $field['options'] as $opt_key => $opt ) { |
485 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
486 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
485 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
486 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
487 | 487 | |
488 | 488 | // If this is an "Other" option, get the HTML for it |
489 | 489 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | public static function get_term_link( $tax_id ) { |
500 | - $tax = get_taxonomy($tax_id); |
|
500 | + $tax = get_taxonomy( $tax_id ); |
|
501 | 501 | if ( ! $tax ) { |
502 | 502 | return; |
503 | 503 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
507 | 507 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
508 | 508 | ); |
509 | - unset($tax); |
|
509 | + unset( $tax ); |
|
510 | 510 | |
511 | 511 | return $link; |
512 | 512 | } |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | $observed_value = wp_kses_post( $observed_value ); |
521 | 521 | $hide_opt = wp_kses_post( $hide_opt ); |
522 | 522 | |
523 | - if ( is_array($observed_value) ) { |
|
524 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
523 | + if ( is_array( $observed_value ) ) { |
|
524 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | $m = false; |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | } else if ( $cond == '<' ) { |
535 | 535 | $m = $observed_value < $hide_opt; |
536 | 536 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
537 | - $m = stripos($observed_value, $hide_opt); |
|
537 | + $m = stripos( $observed_value, $hide_opt ); |
|
538 | 538 | if ( $cond == 'not LIKE' ) { |
539 | 539 | $m = ( $m === false ) ? true : false; |
540 | 540 | } else { |
@@ -547,23 +547,23 @@ discard block |
||
547 | 547 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
548 | 548 | $m = false; |
549 | 549 | if ( $cond == '==' ) { |
550 | - if ( is_array($hide_opt) ) { |
|
551 | - $m = array_intersect($hide_opt, $observed_value); |
|
552 | - $m = empty($m) ? false : true; |
|
550 | + if ( is_array( $hide_opt ) ) { |
|
551 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
552 | + $m = empty( $m ) ? false : true; |
|
553 | 553 | } else { |
554 | - $m = in_array($hide_opt, $observed_value); |
|
554 | + $m = in_array( $hide_opt, $observed_value ); |
|
555 | 555 | } |
556 | 556 | } else if ( $cond == '!=' ) { |
557 | - $m = ! in_array($hide_opt, $observed_value); |
|
557 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
558 | 558 | } else if ( $cond == '>' ) { |
559 | - $min = min($observed_value); |
|
559 | + $min = min( $observed_value ); |
|
560 | 560 | $m = $min > $hide_opt; |
561 | 561 | } else if ( $cond == '<' ) { |
562 | - $max = max($observed_value); |
|
562 | + $max = max( $observed_value ); |
|
563 | 563 | $m = $max < $hide_opt; |
564 | 564 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
565 | 565 | foreach ( $observed_value as $ob ) { |
566 | - $m = strpos($ob, $hide_opt); |
|
566 | + $m = strpos( $ob, $hide_opt ); |
|
567 | 567 | if ( $m !== false ) { |
568 | 568 | $m = true; |
569 | 569 | break; |
@@ -584,27 +584,27 @@ discard block |
||
584 | 584 | * @return string |
585 | 585 | */ |
586 | 586 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
587 | - if ( strpos($value, '[sitename]') !== false ) { |
|
587 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
588 | 588 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
589 | - $value = str_replace('[sitename]', $new_value, $value); |
|
589 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
590 | 590 | } |
591 | 591 | |
592 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
593 | - $value = do_shortcode($value); |
|
592 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
593 | + $value = do_shortcode( $value ); |
|
594 | 594 | |
595 | 595 | return $value; |
596 | 596 | } |
597 | 597 | |
598 | 598 | public static function get_shortcodes( $content, $form_id ) { |
599 | 599 | if ( FrmAppHelper::pro_is_installed() ) { |
600 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
600 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
604 | 604 | |
605 | - $tagregexp = self::allowed_shortcodes($fields); |
|
605 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
606 | 606 | |
607 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
607 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
608 | 608 | |
609 | 609 | return $matches; |
610 | 610 | } |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | $tagregexp[] = $field->field_key; |
623 | 623 | } |
624 | 624 | |
625 | - $tagregexp = implode('|', $tagregexp); |
|
625 | + $tagregexp = implode( '|', $tagregexp ); |
|
626 | 626 | return $tagregexp; |
627 | 627 | } |
628 | 628 | |
@@ -634,28 +634,28 @@ discard block |
||
634 | 634 | ); |
635 | 635 | |
636 | 636 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
637 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
637 | + $atts = shortcode_parse_atts( $shortcodes[3][$short_key] ); |
|
638 | 638 | |
639 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
640 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
641 | - $tags = explode(' ', $tag); |
|
642 | - if ( is_array($tags) ) { |
|
639 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
640 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
641 | + $tags = explode( ' ', $tag ); |
|
642 | + if ( is_array( $tags ) ) { |
|
643 | 643 | $tag = $tags[0]; |
644 | 644 | } |
645 | 645 | } else { |
646 | - $tag = $shortcodes[2][ $short_key ]; |
|
646 | + $tag = $shortcodes[2][$short_key]; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | switch ( $tag ) { |
650 | 650 | case 'id': |
651 | 651 | case 'key': |
652 | 652 | case 'ip': |
653 | - $replace_with = $shortcode_values[ $tag ]; |
|
653 | + $replace_with = $shortcode_values[$tag]; |
|
654 | 654 | break; |
655 | 655 | |
656 | 656 | case 'user_agent': |
657 | 657 | case 'user-agent': |
658 | - $entry->description = maybe_unserialize($entry->description); |
|
658 | + $entry->description = maybe_unserialize( $entry->description ); |
|
659 | 659 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
660 | 660 | break; |
661 | 661 | |
@@ -663,25 +663,25 @@ discard block |
||
663 | 663 | case 'created-at': |
664 | 664 | case 'updated_at': |
665 | 665 | case 'updated-at': |
666 | - if ( isset($atts['format']) ) { |
|
666 | + if ( isset( $atts['format'] ) ) { |
|
667 | 667 | $time_format = ' '; |
668 | 668 | } else { |
669 | - $atts['format'] = get_option('date_format'); |
|
669 | + $atts['format'] = get_option( 'date_format' ); |
|
670 | 670 | $time_format = ''; |
671 | 671 | } |
672 | 672 | |
673 | - $this_tag = str_replace('-', '_', $tag); |
|
674 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
675 | - unset($this_tag); |
|
673 | + $this_tag = str_replace( '-', '_', $tag ); |
|
674 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
675 | + unset( $this_tag ); |
|
676 | 676 | break; |
677 | 677 | |
678 | 678 | case 'created_by': |
679 | 679 | case 'created-by': |
680 | 680 | case 'updated_by': |
681 | 681 | case 'updated-by': |
682 | - $this_tag = str_replace('-', '_', $tag); |
|
682 | + $this_tag = str_replace( '-', '_', $tag ); |
|
683 | 683 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
684 | - unset($this_tag); |
|
684 | + unset( $this_tag ); |
|
685 | 685 | break; |
686 | 686 | |
687 | 687 | case 'admin_email': |
@@ -698,16 +698,16 @@ discard block |
||
698 | 698 | break; |
699 | 699 | } |
700 | 700 | |
701 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
701 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
702 | 702 | |
703 | 703 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
704 | 704 | |
705 | 705 | $atts['entry_id'] = $entry->id; |
706 | 706 | $atts['entry_key'] = $entry->item_key; |
707 | 707 | |
708 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
708 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
709 | 709 | $replace_with = $field->name; |
710 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
710 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
711 | 711 | $replace_with = $field->description; |
712 | 712 | } else { |
713 | 713 | $string_value = $replace_with; |
@@ -722,15 +722,15 @@ discard block |
||
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | - unset($field); |
|
725 | + unset( $field ); |
|
726 | 726 | break; |
727 | 727 | } |
728 | 728 | |
729 | - if ( isset($replace_with) ) { |
|
730 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
729 | + if ( isset( $replace_with ) ) { |
|
730 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
731 | 731 | } |
732 | 732 | |
733 | - unset($atts, $conditional, $replace_with); |
|
733 | + unset( $atts, $conditional, $replace_with ); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | return $content; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $new_value = ''; |
747 | 747 | switch ( $tag ) { |
748 | 748 | case 'admin_email': |
749 | - $new_value = get_option('admin_email'); |
|
749 | + $new_value = get_option( 'admin_email' ); |
|
750 | 750 | break; |
751 | 751 | case 'siteurl': |
752 | 752 | $new_value = FrmAppHelper::site_url(); |
@@ -772,28 +772,28 @@ discard block |
||
772 | 772 | * @return string|array |
773 | 773 | */ |
774 | 774 | public static function process_get_shortcode( $atts, $return_array = false ) { |
775 | - if ( ! isset($atts['param']) ) { |
|
775 | + if ( ! isset( $atts['param'] ) ) { |
|
776 | 776 | return ''; |
777 | 777 | } |
778 | 778 | |
779 | - if ( strpos($atts['param'], '[') ) { |
|
780 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
781 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
779 | + if ( strpos( $atts['param'], '[' ) ) { |
|
780 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
781 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
782 | 782 | } |
783 | 783 | |
784 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
784 | + $new_value = FrmAppHelper::get_param( $atts['param'], '' ); |
|
785 | 785 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
786 | 786 | |
787 | 787 | if ( $new_value == '' ) { |
788 | - if ( ! isset($atts['prev_val']) ) { |
|
788 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
789 | 789 | $atts['prev_val'] = ''; |
790 | 790 | } |
791 | 791 | |
792 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
792 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
793 | 793 | } |
794 | 794 | |
795 | - if ( is_array($new_value) && ! $return_array ) { |
|
796 | - $new_value = implode(', ', $new_value); |
|
795 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
796 | + $new_value = implode( ', ', $new_value ); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | return $new_value; |
@@ -806,12 +806,12 @@ discard block |
||
806 | 806 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
807 | 807 | |
808 | 808 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
809 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
810 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
811 | - if ( is_array($replace_with) ) { |
|
812 | - $replace_with = implode("\n", $replace_with); |
|
809 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
810 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
811 | + if ( is_array( $replace_with ) ) { |
|
812 | + $replace_with = implode( "\n", $replace_with ); |
|
813 | 813 | } |
814 | - $replace_with = wpautop($replace_with); |
|
814 | + $replace_with = wpautop( $replace_with ); |
|
815 | 815 | } |
816 | 816 | unset( $autop ); |
817 | 817 | } else if ( is_array( $replace_with ) ) { |
@@ -833,14 +833,14 @@ discard block |
||
833 | 833 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
834 | 834 | |
835 | 835 | $field_types = array(); |
836 | - if ( in_array($type, $single_input) ) { |
|
836 | + if ( in_array( $type, $single_input ) ) { |
|
837 | 837 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
838 | - } else if ( in_array($type, $multiple_input) ) { |
|
838 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
839 | 839 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
840 | - } else if ( in_array($type, $other_type) ) { |
|
840 | + } else if ( in_array( $type, $other_type ) ) { |
|
841 | 841 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
842 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
843 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
842 | + } else if ( isset( $field_selection[$type] ) ) { |
|
843 | + $field_types[$type] = $field_selection[$type]; |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | |
850 | 850 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
851 | 851 | foreach ( $inputs as $input ) { |
852 | - $field_types[ $input ] = $fields[ $input ]; |
|
853 | - unset($input); |
|
852 | + $field_types[$input] = $fields[$input]; |
|
853 | + unset( $input ); |
|
854 | 854 | } |
855 | 855 | } |
856 | 856 | |
@@ -895,21 +895,21 @@ discard block |
||
895 | 895 | // Check posted vals before checking saved values |
896 | 896 | |
897 | 897 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
898 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
898 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
899 | 899 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
900 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
900 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
901 | 901 | } else { |
902 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
902 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
903 | 903 | } |
904 | 904 | return $other_val; |
905 | 905 | |
906 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
906 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
907 | 907 | // For normal fields |
908 | 908 | |
909 | 909 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
910 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
910 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
911 | 911 | } else { |
912 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
912 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
913 | 913 | } |
914 | 914 | return $other_val; |
915 | 915 | } |
@@ -918,8 +918,8 @@ discard block |
||
918 | 918 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
919 | 919 | // Check if there is an "other" val in saved value and make sure the |
920 | 920 | // "other" val is not equal to the Other checkbox option |
921 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
922 | - $other_val = $field['value'][ $opt_key ]; |
|
921 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
922 | + $other_val = $field['value'][$opt_key]; |
|
923 | 923 | } |
924 | 924 | } else { |
925 | 925 | /** |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | // Multi-select dropdowns - key is not preserved |
932 | 932 | if ( is_array( $field['value'] ) ) { |
933 | 933 | $o_key = array_search( $temp_val, $field['value'] ); |
934 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
935 | - unset( $field['value'][ $o_key ], $o_key ); |
|
934 | + if ( isset( $field['value'][$o_key] ) ) { |
|
935 | + unset( $field['value'][$o_key], $o_key ); |
|
936 | 936 | } |
937 | 937 | } else if ( $temp_val == $field['value'] ) { |
938 | 938 | // For radio and regular dropdowns |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | private static function set_other_name( $args, &$other_args ) { |
990 | 990 | //Set up name for other field |
991 | 991 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
992 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
992 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
993 | 993 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
994 | 994 | |
995 | 995 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | // Count should only be greater than 3 if inside of a repeating section |
1016 | 1016 | if ( count( $temp_array ) > 3 ) { |
1017 | 1017 | $parent = str_replace( ']', '', $temp_array[1] ); |
1018 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
1018 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | // Get text for "other" text field |
@@ -1134,15 +1134,15 @@ discard block |
||
1134 | 1134 | $replace_with[] = '[' . $new . ']'; |
1135 | 1135 | $replace[] = '[' . $old . ' '; |
1136 | 1136 | $replace_with[] = '[' . $new . ' '; |
1137 | - unset($old, $new); |
|
1137 | + unset( $old, $new ); |
|
1138 | 1138 | } |
1139 | 1139 | if ( is_array( $val ) ) { |
1140 | 1140 | foreach ( $val as $k => $v ) { |
1141 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
1142 | - unset($k, $v); |
|
1141 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
1142 | + unset( $k, $v ); |
|
1143 | 1143 | } |
1144 | 1144 | } else { |
1145 | - $val = str_replace($replace, $replace_with, $val); |
|
1145 | + $val = str_replace( $replace, $replace_with, $val ); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | return $val; |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | 'DC' => 'District of Columbia', |
1156 | 1156 | 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
1157 | 1157 | 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
1158 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
1158 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', |
|
1159 | 1159 | 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
1160 | 1160 | 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
1161 | 1161 | 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
@@ -1246,35 +1246,35 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
1249 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
1249 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
1250 | 1250 | |
1251 | 1251 | $states = FrmFieldsHelper::get_us_states(); |
1252 | - $state_abv = array_keys($states); |
|
1253 | - sort($state_abv); |
|
1254 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
1252 | + $state_abv = array_keys( $states ); |
|
1253 | + sort( $state_abv ); |
|
1254 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
1255 | 1255 | |
1256 | - $states = array_values($states); |
|
1257 | - sort($states); |
|
1258 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
1259 | - unset($state_abv, $states); |
|
1256 | + $states = array_values( $states ); |
|
1257 | + sort( $states ); |
|
1258 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
1259 | + unset( $state_abv, $states ); |
|
1260 | 1260 | |
1261 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
1261 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
1262 | 1262 | __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
1263 | 1263 | __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
1264 | 1264 | __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
1265 | 1265 | ); |
1266 | 1266 | |
1267 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
1267 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
1268 | 1268 | __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
1269 | 1269 | __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
1270 | 1270 | ); |
1271 | 1271 | |
1272 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
1272 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
1273 | 1273 | __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
1274 | 1274 | __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
1275 | 1275 | ); |
1276 | 1276 | |
1277 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
1277 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
1278 | 1278 | __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
1279 | 1279 | __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
1280 | 1280 | ); |
@@ -7,71 +7,71 @@ discard block |
||
7 | 7 | |
8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
9 | 9 | |
10 | - if ( strpos($type, '|') ) { |
|
11 | - list($type, $setting) = explode('|', $type); |
|
12 | - } |
|
13 | - |
|
14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
16 | - |
|
17 | - $values = array(); |
|
18 | - |
|
19 | - foreach ( $defaults as $var => $default ) { |
|
20 | - if ( $var == 'field_options' ) { |
|
21 | - $values['field_options'] = array(); |
|
22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
24 | - unset($opt_var, $opt_default); |
|
25 | - } |
|
26 | - } else { |
|
27 | - $values[ $var ] = $default; |
|
28 | - } |
|
29 | - unset($var, $default); |
|
30 | - } |
|
31 | - |
|
32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
34 | - $values['field_options']['data_type'] = $setting; |
|
35 | - } else { |
|
36 | - $values['field_options'][ $setting ] = 1; |
|
37 | - } |
|
38 | - } |
|
39 | - |
|
40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
41 | - $values['options'] = serialize( array( |
|
42 | - __( 'Option 1', 'formidable' ), |
|
43 | - __( 'Option 2', 'formidable' ), |
|
44 | - ) ); |
|
45 | - } else if ( $type == 'select' ) { |
|
46 | - $values['options'] = serialize( array( |
|
47 | - '', __( 'Option 1', 'formidable' ), |
|
48 | - ) ); |
|
49 | - } else if ( $type == 'textarea' ) { |
|
50 | - $values['field_options']['max'] = '5'; |
|
51 | - } else if ( $type == 'captcha' ) { |
|
52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
53 | - $values['invalid'] = $frm_settings->re_msg; |
|
54 | - } else if ( 'url' == $type ) { |
|
55 | - $values['name'] = __( 'Website', 'formidable' ); |
|
56 | - } |
|
10 | + if ( strpos($type, '|') ) { |
|
11 | + list($type, $setting) = explode('|', $type); |
|
12 | + } |
|
13 | + |
|
14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
16 | + |
|
17 | + $values = array(); |
|
18 | + |
|
19 | + foreach ( $defaults as $var => $default ) { |
|
20 | + if ( $var == 'field_options' ) { |
|
21 | + $values['field_options'] = array(); |
|
22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
24 | + unset($opt_var, $opt_default); |
|
25 | + } |
|
26 | + } else { |
|
27 | + $values[ $var ] = $default; |
|
28 | + } |
|
29 | + unset($var, $default); |
|
30 | + } |
|
31 | + |
|
32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
34 | + $values['field_options']['data_type'] = $setting; |
|
35 | + } else { |
|
36 | + $values['field_options'][ $setting ] = 1; |
|
37 | + } |
|
38 | + } |
|
39 | + |
|
40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
41 | + $values['options'] = serialize( array( |
|
42 | + __( 'Option 1', 'formidable' ), |
|
43 | + __( 'Option 2', 'formidable' ), |
|
44 | + ) ); |
|
45 | + } else if ( $type == 'select' ) { |
|
46 | + $values['options'] = serialize( array( |
|
47 | + '', __( 'Option 1', 'formidable' ), |
|
48 | + ) ); |
|
49 | + } else if ( $type == 'textarea' ) { |
|
50 | + $values['field_options']['max'] = '5'; |
|
51 | + } else if ( $type == 'captcha' ) { |
|
52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
53 | + $values['invalid'] = $frm_settings->re_msg; |
|
54 | + } else if ( 'url' == $type ) { |
|
55 | + $values['name'] = __( 'Website', 'formidable' ); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | $fields = FrmField::field_selection(); |
59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
59 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
60 | 60 | |
61 | - if ( isset( $fields[ $type ] ) ) { |
|
62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
63 | - } |
|
61 | + if ( isset( $fields[ $type ] ) ) { |
|
62 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
63 | + } |
|
64 | 64 | |
65 | - unset($fields); |
|
65 | + unset($fields); |
|
66 | 66 | |
67 | - return $values; |
|
68 | - } |
|
67 | + return $values; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | public static function get_html_id( $field, $plus = '' ) { |
71 | 71 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
74 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
75 | 75 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
76 | 76 | $defaults = array( |
77 | 77 | 'name' => $record->name, |
@@ -84,86 +84,86 @@ discard block |
||
84 | 84 | ); |
85 | 85 | |
86 | 86 | if ( $doing_ajax ) { |
87 | - $values = $values + $defaults; |
|
88 | - $values['form_name'] = ''; |
|
87 | + $values = $values + $defaults; |
|
88 | + $values['form_name'] = ''; |
|
89 | 89 | } else { |
90 | 90 | foreach ( $defaults as $var => $default ) { |
91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | - unset($var, $default); |
|
93 | - } |
|
91 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
92 | + unset($var, $default); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | 98 | unset( $defaults ); |
99 | 99 | |
100 | - $values['options'] = $record->options; |
|
101 | - $values['field_options'] = $record->field_options; |
|
100 | + $values['options'] = $record->options; |
|
101 | + $values['field_options'] = $record->field_options; |
|
102 | 102 | |
103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
103 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
104 | 104 | |
105 | 105 | if ( $values['type'] == 'captcha' ) { |
106 | - $frm_settings = FrmAppHelper::get_settings(); |
|
107 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
108 | - } |
|
106 | + $frm_settings = FrmAppHelper::get_settings(); |
|
107 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | foreach ( $defaults as $opt => $default ) { |
111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
112 | - unset($opt, $default); |
|
113 | - } |
|
111 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
112 | + unset($opt, $default); |
|
113 | + } |
|
114 | 114 | |
115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
115 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
116 | 116 | |
117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
121 | - $field_options = array( |
|
122 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
123 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
124 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
120 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
121 | + $field_options = array( |
|
122 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
123 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
124 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
125 | 125 | 'custom_html' => '', 'captcha_size' => 'default', 'captcha_theme' => 'light', |
126 | - ); |
|
126 | + ); |
|
127 | 127 | |
128 | 128 | if ( $limit ) { |
129 | - return $field_options; |
|
129 | + return $field_options; |
|
130 | 130 | } |
131 | 131 | |
132 | - global $wpdb; |
|
132 | + global $wpdb; |
|
133 | 133 | |
134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
134 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
135 | 135 | |
136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
137 | 137 | |
138 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
138 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
139 | 139 | |
140 | - $frm_settings = FrmAppHelper::get_settings(); |
|
141 | - return array( |
|
142 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
140 | + $frm_settings = FrmAppHelper::get_settings(); |
|
141 | + return array( |
|
142 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
143 | 143 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
144 | 144 | 'field_order' => $field_count + 1, 'required' => false, |
145 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
146 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
145 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
146 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
147 | 147 | 'field_options' => $field_options, |
148 | - ); |
|
149 | - } |
|
148 | + ); |
|
149 | + } |
|
150 | 150 | |
151 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
152 | - global $wpdb; |
|
151 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
152 | + global $wpdb; |
|
153 | 153 | |
154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
155 | - $values['form_id'] = $form_id; |
|
156 | - $values['options'] = maybe_serialize($field->options); |
|
157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
158 | - |
|
159 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
160 | - $values[ $col ] = $field->{$col}; |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * @since 2.0 |
|
166 | - */ |
|
155 | + $values['form_id'] = $form_id; |
|
156 | + $values['options'] = maybe_serialize($field->options); |
|
157 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
158 | + |
|
159 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
160 | + $values[ $col ] = $field->{$col}; |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * @since 2.0 |
|
166 | + */ |
|
167 | 167 | public static function get_error_msg( $field, $error ) { |
168 | 168 | $frm_settings = FrmAppHelper::get_settings(); |
169 | 169 | $default_settings = $frm_settings->default_options(); |
@@ -183,21 +183,21 @@ discard block |
||
183 | 183 | return $msg; |
184 | 184 | } |
185 | 185 | |
186 | - public static function get_form_fields( $form_id, $error = false ) { |
|
187 | - $fields = FrmField::get_all_for_form($form_id); |
|
188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
189 | - return $fields; |
|
190 | - } |
|
186 | + public static function get_form_fields( $form_id, $error = false ) { |
|
187 | + $fields = FrmField::get_all_for_form($form_id); |
|
188 | + $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
189 | + return $fields; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | public static function get_default_html( $type = 'text' ) { |
193 | 193 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
194 | 194 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
195 | - $for = ''; |
|
195 | + $for = ''; |
|
196 | 196 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
197 | - $for = 'for="field_[key]"'; |
|
198 | - } |
|
197 | + $for = 'for="field_[key]"'; |
|
198 | + } |
|
199 | 199 | |
200 | - $default_html = <<<DEFAULT_HTML |
|
200 | + $default_html = <<<DEFAULT_HTML |
|
201 | 201 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
202 | 202 | <label $for class="frm_primary_label">[field_name] |
203 | 203 | <span class="frm_required">[required_label]</span> |
@@ -207,138 +207,138 @@ discard block |
||
207 | 207 | [if error]<div class="frm_error">[error]</div>[/if error] |
208 | 208 | </div> |
209 | 209 | DEFAULT_HTML; |
210 | - } else { |
|
210 | + } else { |
|
211 | 211 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
212 | - } |
|
212 | + } |
|
213 | 213 | |
214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
215 | - } |
|
214 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
218 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
219 | 219 | |
220 | - $defaults = array( |
|
220 | + $defaults = array( |
|
221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
222 | 222 | 'field_id' => $field['id'], |
223 | - 'field_plus_id' => '', |
|
224 | - 'section_id' => '', |
|
225 | - ); |
|
226 | - $args = wp_parse_args($args, $defaults); |
|
227 | - $field_name = $args['field_name']; |
|
228 | - $field_id = $args['field_id']; |
|
229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
223 | + 'field_plus_id' => '', |
|
224 | + 'section_id' => '', |
|
225 | + ); |
|
226 | + $args = wp_parse_args($args, $defaults); |
|
227 | + $field_name = $args['field_name']; |
|
228 | + $field_id = $args['field_id']; |
|
229 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
230 | 230 | |
231 | - if ( FrmField::is_multiple_select($field) ) { |
|
232 | - $field_name .= '[]'; |
|
233 | - } |
|
231 | + if ( FrmField::is_multiple_select($field) ) { |
|
232 | + $field_name .= '[]'; |
|
233 | + } |
|
234 | 234 | |
235 | - //replace [id] |
|
236 | - $html = str_replace('[id]', $field_id, $html); |
|
235 | + //replace [id] |
|
236 | + $html = str_replace('[id]', $field_id, $html); |
|
237 | 237 | |
238 | - // Remove the for attribute for captcha |
|
239 | - if ( $field['type'] == 'captcha' ) { |
|
240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
241 | - } |
|
238 | + // Remove the for attribute for captcha |
|
239 | + if ( $field['type'] == 'captcha' ) { |
|
240 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
241 | + } |
|
242 | 242 | |
243 | - // set the label for |
|
244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
243 | + // set the label for |
|
244 | + $html = str_replace('field_[key]', $html_id, $html); |
|
245 | 245 | |
246 | - //replace [key] |
|
247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
246 | + //replace [key] |
|
247 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
248 | 248 | |
249 | - //replace [description] and [required_label] and [error] |
|
249 | + //replace [description] and [required_label] and [error] |
|
250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
251 | - if ( ! is_array( $errors ) ) { |
|
252 | - $errors = array(); |
|
253 | - } |
|
251 | + if ( ! is_array( $errors ) ) { |
|
252 | + $errors = array(); |
|
253 | + } |
|
254 | 254 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
255 | 255 | |
256 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
257 | - if ( $field['type'] == 'divider' ) { |
|
258 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
259 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
260 | - } else { |
|
261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
262 | - } |
|
263 | - } |
|
256 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
257 | + if ( $field['type'] == 'divider' ) { |
|
258 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
259 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
260 | + } else { |
|
261 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
262 | + } |
|
263 | + } |
|
264 | 264 | |
265 | 265 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
266 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
267 | - } |
|
266 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
267 | + } |
|
268 | 268 | |
269 | - //replace [required_class] |
|
269 | + //replace [required_class] |
|
270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
271 | + $html = str_replace('[required_class]', $required_class, $html); |
|
272 | 272 | |
273 | - //replace [label_position] |
|
274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
275 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
273 | + //replace [label_position] |
|
274 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
275 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
277 | 277 | |
278 | - //replace [field_name] |
|
279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
278 | + //replace [field_name] |
|
279 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
280 | 280 | |
281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
282 | 282 | |
283 | - //replace [entry_key] |
|
284 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
283 | + //replace [entry_key] |
|
284 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
285 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
286 | 286 | |
287 | - //replace [input] |
|
288 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
289 | - global $frm_vars; |
|
290 | - $frm_settings = FrmAppHelper::get_settings(); |
|
287 | + //replace [input] |
|
288 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
289 | + global $frm_vars; |
|
290 | + $frm_settings = FrmAppHelper::get_settings(); |
|
291 | 291 | |
292 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
293 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
292 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
293 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
294 | 294 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
295 | 295 | |
296 | - $replace_with = ''; |
|
296 | + $replace_with = ''; |
|
297 | 297 | |
298 | - if ( $tag == 'input' ) { |
|
299 | - if ( isset($atts['opt']) ) { |
|
300 | - $atts['opt']--; |
|
301 | - } |
|
298 | + if ( $tag == 'input' ) { |
|
299 | + if ( isset($atts['opt']) ) { |
|
300 | + $atts['opt']--; |
|
301 | + } |
|
302 | 302 | |
303 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
304 | - if ( isset($atts['class']) ) { |
|
305 | - unset($atts['class']); |
|
306 | - } |
|
303 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
304 | + if ( isset($atts['class']) ) { |
|
305 | + unset($atts['class']); |
|
306 | + } |
|
307 | 307 | |
308 | - $field['shortcodes'] = $atts; |
|
309 | - ob_start(); |
|
308 | + $field['shortcodes'] = $atts; |
|
309 | + ob_start(); |
|
310 | 310 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
311 | - $replace_with = ob_get_contents(); |
|
312 | - ob_end_clean(); |
|
313 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
314 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
315 | - } |
|
311 | + $replace_with = ob_get_contents(); |
|
312 | + ob_end_clean(); |
|
313 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
314 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
315 | + } |
|
316 | 316 | |
317 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
318 | - } |
|
317 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
318 | + } |
|
319 | 319 | |
320 | 320 | if ( $form ) { |
321 | - $form = (array) $form; |
|
321 | + $form = (array) $form; |
|
322 | 322 | |
323 | - //replace [form_key] |
|
324 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
323 | + //replace [form_key] |
|
324 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
325 | 325 | |
326 | - //replace [form_name] |
|
327 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
328 | - } |
|
329 | - $html .= "\n"; |
|
326 | + //replace [form_name] |
|
327 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
328 | + } |
|
329 | + $html .= "\n"; |
|
330 | 330 | |
331 | - //Return html if conf_field to prevent loop |
|
332 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
333 | - return $html; |
|
334 | - } |
|
331 | + //Return html if conf_field to prevent loop |
|
332 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
333 | + return $html; |
|
334 | + } |
|
335 | 335 | |
336 | - //If field is in repeating section |
|
337 | - if ( $args['section_id'] ) { |
|
338 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
339 | - } else { |
|
340 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
341 | - } |
|
336 | + //If field is in repeating section |
|
337 | + if ( $args['section_id'] ) { |
|
338 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
339 | + } else { |
|
340 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | self::remove_collapse_shortcode( $html ); |
344 | 344 | |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | $html = do_shortcode( $html ); |
347 | 347 | } |
348 | 348 | |
349 | - return $html; |
|
350 | - } |
|
349 | + return $html; |
|
350 | + } |
|
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Add classes to a field div |
@@ -401,46 +401,46 @@ discard block |
||
401 | 401 | return $classes; |
402 | 402 | } |
403 | 403 | |
404 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
405 | - if ( $no_vars ) { |
|
404 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
405 | + if ( $no_vars ) { |
|
406 | 406 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
407 | 407 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
408 | - } else { |
|
408 | + } else { |
|
409 | 409 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
410 | - } |
|
410 | + } |
|
411 | 411 | |
412 | 412 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | 415 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
416 | 416 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
417 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
418 | - $args['conditional_check'] = true; |
|
419 | - } |
|
420 | - |
|
421 | - $prefix = ''; |
|
422 | - if ( $args['conditional_check'] ) { |
|
423 | - if ( $args['conditional'] ) { |
|
424 | - $prefix = 'if '; |
|
425 | - } else if ( $args['foreach'] ) { |
|
426 | - $prefix = 'foreach '; |
|
427 | - } |
|
428 | - } |
|
429 | - |
|
430 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
431 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
432 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
433 | - $tag = str_replace(']', '', $tag); |
|
434 | - $tags = explode(' ', $tag); |
|
435 | - if ( is_array($tags) ) { |
|
436 | - $tag = $tags[0]; |
|
437 | - } |
|
438 | - } else { |
|
439 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
440 | - } |
|
441 | - |
|
442 | - return $tag; |
|
443 | - } |
|
417 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
418 | + $args['conditional_check'] = true; |
|
419 | + } |
|
420 | + |
|
421 | + $prefix = ''; |
|
422 | + if ( $args['conditional_check'] ) { |
|
423 | + if ( $args['conditional'] ) { |
|
424 | + $prefix = 'if '; |
|
425 | + } else if ( $args['foreach'] ) { |
|
426 | + $prefix = 'foreach '; |
|
427 | + } |
|
428 | + } |
|
429 | + |
|
430 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
431 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
432 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
433 | + $tag = str_replace(']', '', $tag); |
|
434 | + $tags = explode(' ', $tag); |
|
435 | + if ( is_array($tags) ) { |
|
436 | + $tag = $tags[0]; |
|
437 | + } |
|
438 | + } else { |
|
439 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
440 | + } |
|
441 | + |
|
442 | + return $tag; |
|
443 | + } |
|
444 | 444 | |
445 | 445 | /** |
446 | 446 | * Remove [collapse_this] if it's still included after all processing |
@@ -478,46 +478,46 @@ discard block |
||
478 | 478 | } |
479 | 479 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
480 | 480 | |
481 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
482 | - wp_enqueue_script( 'recaptcha-api' ); |
|
481 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
482 | + wp_enqueue_script( 'recaptcha-api' ); |
|
483 | 483 | |
484 | 484 | ?> |
485 | 485 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div> |
486 | 486 | <?php |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | 489 | public static function show_single_option( $field ) { |
490 | - $field_name = $field['name']; |
|
491 | - $html_id = self::get_html_id($field); |
|
492 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
493 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
494 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
490 | + $field_name = $field['name']; |
|
491 | + $html_id = self::get_html_id($field); |
|
492 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
493 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
494 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
495 | 495 | |
496 | - // If this is an "Other" option, get the HTML for it |
|
496 | + // If this is an "Other" option, get the HTML for it |
|
497 | 497 | if ( self::is_other_opt( $opt_key ) ) { |
498 | - // Get string for Other text field, if needed |
|
498 | + // Get string for Other text field, if needed |
|
499 | 499 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
500 | 500 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
501 | - } else { |
|
501 | + } else { |
|
502 | 502 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
503 | - } |
|
504 | - } |
|
505 | - } |
|
503 | + } |
|
504 | + } |
|
505 | + } |
|
506 | 506 | |
507 | 507 | public static function get_term_link( $tax_id ) { |
508 | - $tax = get_taxonomy($tax_id); |
|
509 | - if ( ! $tax ) { |
|
510 | - return; |
|
511 | - } |
|
508 | + $tax = get_taxonomy($tax_id); |
|
509 | + if ( ! $tax ) { |
|
510 | + return; |
|
511 | + } |
|
512 | 512 | |
513 | - $link = sprintf( |
|
514 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
513 | + $link = sprintf( |
|
514 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
515 | 515 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
516 | - ); |
|
517 | - unset($tax); |
|
516 | + ); |
|
517 | + unset($tax); |
|
518 | 518 | |
519 | - return $link; |
|
520 | - } |
|
519 | + return $link; |
|
520 | + } |
|
521 | 521 | |
522 | 522 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
523 | 523 | // Remove white space from hide_opt |
@@ -528,195 +528,195 @@ discard block |
||
528 | 528 | $observed_value = wp_kses_post( $observed_value ); |
529 | 529 | $hide_opt = wp_kses_post( $hide_opt ); |
530 | 530 | |
531 | - if ( is_array($observed_value) ) { |
|
532 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
533 | - } |
|
534 | - |
|
535 | - $m = false; |
|
536 | - if ( $cond == '==' ) { |
|
537 | - $m = $observed_value == $hide_opt; |
|
538 | - } else if ( $cond == '!=' ) { |
|
539 | - $m = $observed_value != $hide_opt; |
|
540 | - } else if ( $cond == '>' ) { |
|
541 | - $m = $observed_value > $hide_opt; |
|
542 | - } else if ( $cond == '<' ) { |
|
543 | - $m = $observed_value < $hide_opt; |
|
544 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
545 | - $m = stripos($observed_value, $hide_opt); |
|
546 | - if ( $cond == 'not LIKE' ) { |
|
547 | - $m = ( $m === false ) ? true : false; |
|
548 | - } else { |
|
549 | - $m = ( $m === false ) ? false : true; |
|
550 | - } |
|
551 | - } |
|
552 | - return $m; |
|
553 | - } |
|
531 | + if ( is_array($observed_value) ) { |
|
532 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
533 | + } |
|
534 | + |
|
535 | + $m = false; |
|
536 | + if ( $cond == '==' ) { |
|
537 | + $m = $observed_value == $hide_opt; |
|
538 | + } else if ( $cond == '!=' ) { |
|
539 | + $m = $observed_value != $hide_opt; |
|
540 | + } else if ( $cond == '>' ) { |
|
541 | + $m = $observed_value > $hide_opt; |
|
542 | + } else if ( $cond == '<' ) { |
|
543 | + $m = $observed_value < $hide_opt; |
|
544 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
545 | + $m = stripos($observed_value, $hide_opt); |
|
546 | + if ( $cond == 'not LIKE' ) { |
|
547 | + $m = ( $m === false ) ? true : false; |
|
548 | + } else { |
|
549 | + $m = ( $m === false ) ? false : true; |
|
550 | + } |
|
551 | + } |
|
552 | + return $m; |
|
553 | + } |
|
554 | 554 | |
555 | 555 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
556 | - $m = false; |
|
557 | - if ( $cond == '==' ) { |
|
558 | - if ( is_array($hide_opt) ) { |
|
559 | - $m = array_intersect($hide_opt, $observed_value); |
|
560 | - $m = empty($m) ? false : true; |
|
561 | - } else { |
|
562 | - $m = in_array($hide_opt, $observed_value); |
|
563 | - } |
|
564 | - } else if ( $cond == '!=' ) { |
|
565 | - $m = ! in_array($hide_opt, $observed_value); |
|
566 | - } else if ( $cond == '>' ) { |
|
567 | - $min = min($observed_value); |
|
568 | - $m = $min > $hide_opt; |
|
569 | - } else if ( $cond == '<' ) { |
|
570 | - $max = max($observed_value); |
|
571 | - $m = $max < $hide_opt; |
|
572 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
573 | - foreach ( $observed_value as $ob ) { |
|
574 | - $m = strpos($ob, $hide_opt); |
|
575 | - if ( $m !== false ) { |
|
576 | - $m = true; |
|
577 | - break; |
|
578 | - } |
|
579 | - } |
|
580 | - |
|
581 | - if ( $cond == 'not LIKE' ) { |
|
582 | - $m = ( $m === false ) ? true : false; |
|
583 | - } |
|
584 | - } |
|
585 | - |
|
586 | - return $m; |
|
587 | - } |
|
588 | - |
|
589 | - /** |
|
590 | - * Replace a few basic shortcodes and field ids |
|
591 | - * @since 2.0 |
|
592 | - * @return string |
|
593 | - */ |
|
556 | + $m = false; |
|
557 | + if ( $cond == '==' ) { |
|
558 | + if ( is_array($hide_opt) ) { |
|
559 | + $m = array_intersect($hide_opt, $observed_value); |
|
560 | + $m = empty($m) ? false : true; |
|
561 | + } else { |
|
562 | + $m = in_array($hide_opt, $observed_value); |
|
563 | + } |
|
564 | + } else if ( $cond == '!=' ) { |
|
565 | + $m = ! in_array($hide_opt, $observed_value); |
|
566 | + } else if ( $cond == '>' ) { |
|
567 | + $min = min($observed_value); |
|
568 | + $m = $min > $hide_opt; |
|
569 | + } else if ( $cond == '<' ) { |
|
570 | + $max = max($observed_value); |
|
571 | + $m = $max < $hide_opt; |
|
572 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
573 | + foreach ( $observed_value as $ob ) { |
|
574 | + $m = strpos($ob, $hide_opt); |
|
575 | + if ( $m !== false ) { |
|
576 | + $m = true; |
|
577 | + break; |
|
578 | + } |
|
579 | + } |
|
580 | + |
|
581 | + if ( $cond == 'not LIKE' ) { |
|
582 | + $m = ( $m === false ) ? true : false; |
|
583 | + } |
|
584 | + } |
|
585 | + |
|
586 | + return $m; |
|
587 | + } |
|
588 | + |
|
589 | + /** |
|
590 | + * Replace a few basic shortcodes and field ids |
|
591 | + * @since 2.0 |
|
592 | + * @return string |
|
593 | + */ |
|
594 | 594 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
595 | - if ( strpos($value, '[sitename]') !== false ) { |
|
596 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
597 | - $value = str_replace('[sitename]', $new_value, $value); |
|
598 | - } |
|
595 | + if ( strpos($value, '[sitename]') !== false ) { |
|
596 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
597 | + $value = str_replace('[sitename]', $new_value, $value); |
|
598 | + } |
|
599 | 599 | |
600 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
601 | - $value = do_shortcode($value); |
|
600 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
601 | + $value = do_shortcode($value); |
|
602 | 602 | |
603 | - return $value; |
|
604 | - } |
|
603 | + return $value; |
|
604 | + } |
|
605 | 605 | |
606 | 606 | public static function get_shortcodes( $content, $form_id ) { |
607 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
608 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
609 | - } |
|
607 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
608 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
609 | + } |
|
610 | 610 | |
611 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
611 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
612 | 612 | |
613 | - $tagregexp = self::allowed_shortcodes($fields); |
|
613 | + $tagregexp = self::allowed_shortcodes($fields); |
|
614 | 614 | |
615 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
615 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
616 | 616 | |
617 | - return $matches; |
|
618 | - } |
|
617 | + return $matches; |
|
618 | + } |
|
619 | 619 | |
620 | 620 | public static function allowed_shortcodes( $fields = array() ) { |
621 | - $tagregexp = array( |
|
622 | - 'editlink', 'id', 'key', 'ip', |
|
623 | - 'siteurl', 'sitename', 'admin_email', |
|
624 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
621 | + $tagregexp = array( |
|
622 | + 'editlink', 'id', 'key', 'ip', |
|
623 | + 'siteurl', 'sitename', 'admin_email', |
|
624 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
625 | 625 | 'parent[-|_]id', |
626 | - ); |
|
626 | + ); |
|
627 | 627 | |
628 | - foreach ( $fields as $field ) { |
|
629 | - $tagregexp[] = $field->id; |
|
630 | - $tagregexp[] = $field->field_key; |
|
631 | - } |
|
628 | + foreach ( $fields as $field ) { |
|
629 | + $tagregexp[] = $field->id; |
|
630 | + $tagregexp[] = $field->field_key; |
|
631 | + } |
|
632 | 632 | |
633 | - $tagregexp = implode('|', $tagregexp); |
|
634 | - return $tagregexp; |
|
635 | - } |
|
633 | + $tagregexp = implode('|', $tagregexp); |
|
634 | + return $tagregexp; |
|
635 | + } |
|
636 | 636 | |
637 | 637 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
638 | - $shortcode_values = array( |
|
639 | - 'id' => $entry->id, |
|
640 | - 'key' => $entry->item_key, |
|
641 | - 'ip' => $entry->ip, |
|
642 | - ); |
|
638 | + $shortcode_values = array( |
|
639 | + 'id' => $entry->id, |
|
640 | + 'key' => $entry->item_key, |
|
641 | + 'ip' => $entry->ip, |
|
642 | + ); |
|
643 | 643 | |
644 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
645 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
644 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
645 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
646 | 646 | |
647 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
647 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
648 | 648 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
649 | - $tags = explode(' ', $tag); |
|
650 | - if ( is_array($tags) ) { |
|
651 | - $tag = $tags[0]; |
|
652 | - } |
|
653 | - } else { |
|
654 | - $tag = $shortcodes[2][ $short_key ]; |
|
655 | - } |
|
656 | - |
|
657 | - switch ( $tag ) { |
|
658 | - case 'id': |
|
659 | - case 'key': |
|
660 | - case 'ip': |
|
661 | - $replace_with = $shortcode_values[ $tag ]; |
|
662 | - break; |
|
663 | - |
|
664 | - case 'user_agent': |
|
665 | - case 'user-agent': |
|
666 | - $entry->description = maybe_unserialize($entry->description); |
|
649 | + $tags = explode(' ', $tag); |
|
650 | + if ( is_array($tags) ) { |
|
651 | + $tag = $tags[0]; |
|
652 | + } |
|
653 | + } else { |
|
654 | + $tag = $shortcodes[2][ $short_key ]; |
|
655 | + } |
|
656 | + |
|
657 | + switch ( $tag ) { |
|
658 | + case 'id': |
|
659 | + case 'key': |
|
660 | + case 'ip': |
|
661 | + $replace_with = $shortcode_values[ $tag ]; |
|
662 | + break; |
|
663 | + |
|
664 | + case 'user_agent': |
|
665 | + case 'user-agent': |
|
666 | + $entry->description = maybe_unserialize($entry->description); |
|
667 | 667 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
668 | - break; |
|
669 | - |
|
670 | - case 'created_at': |
|
671 | - case 'created-at': |
|
672 | - case 'updated_at': |
|
673 | - case 'updated-at': |
|
674 | - if ( isset($atts['format']) ) { |
|
675 | - $time_format = ' '; |
|
676 | - } else { |
|
677 | - $atts['format'] = get_option('date_format'); |
|
678 | - $time_format = ''; |
|
679 | - } |
|
680 | - |
|
681 | - $this_tag = str_replace('-', '_', $tag); |
|
682 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
683 | - unset($this_tag); |
|
684 | - break; |
|
685 | - |
|
686 | - case 'created_by': |
|
687 | - case 'created-by': |
|
688 | - case 'updated_by': |
|
689 | - case 'updated-by': |
|
690 | - $this_tag = str_replace('-', '_', $tag); |
|
668 | + break; |
|
669 | + |
|
670 | + case 'created_at': |
|
671 | + case 'created-at': |
|
672 | + case 'updated_at': |
|
673 | + case 'updated-at': |
|
674 | + if ( isset($atts['format']) ) { |
|
675 | + $time_format = ' '; |
|
676 | + } else { |
|
677 | + $atts['format'] = get_option('date_format'); |
|
678 | + $time_format = ''; |
|
679 | + } |
|
680 | + |
|
681 | + $this_tag = str_replace('-', '_', $tag); |
|
682 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
683 | + unset($this_tag); |
|
684 | + break; |
|
685 | + |
|
686 | + case 'created_by': |
|
687 | + case 'created-by': |
|
688 | + case 'updated_by': |
|
689 | + case 'updated-by': |
|
690 | + $this_tag = str_replace('-', '_', $tag); |
|
691 | 691 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
692 | - unset($this_tag); |
|
693 | - break; |
|
694 | - |
|
695 | - case 'admin_email': |
|
696 | - case 'siteurl': |
|
697 | - case 'frmurl': |
|
698 | - case 'sitename': |
|
699 | - case 'get': |
|
700 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
701 | - break; |
|
702 | - |
|
703 | - default: |
|
704 | - $field = FrmField::getOne( $tag ); |
|
705 | - if ( ! $field ) { |
|
706 | - break; |
|
707 | - } |
|
708 | - |
|
709 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
710 | - |
|
711 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
712 | - |
|
713 | - $atts['entry_id'] = $entry->id; |
|
714 | - $atts['entry_key'] = $entry->item_key; |
|
715 | - |
|
716 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
717 | - $replace_with = $field->name; |
|
718 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
719 | - $replace_with = $field->description; |
|
692 | + unset($this_tag); |
|
693 | + break; |
|
694 | + |
|
695 | + case 'admin_email': |
|
696 | + case 'siteurl': |
|
697 | + case 'frmurl': |
|
698 | + case 'sitename': |
|
699 | + case 'get': |
|
700 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
701 | + break; |
|
702 | + |
|
703 | + default: |
|
704 | + $field = FrmField::getOne( $tag ); |
|
705 | + if ( ! $field ) { |
|
706 | + break; |
|
707 | + } |
|
708 | + |
|
709 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
710 | + |
|
711 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
712 | + |
|
713 | + $atts['entry_id'] = $entry->id; |
|
714 | + $atts['entry_key'] = $entry->item_key; |
|
715 | + |
|
716 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
717 | + $replace_with = $field->name; |
|
718 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
719 | + $replace_with = $field->description; |
|
720 | 720 | } else { |
721 | 721 | $string_value = $replace_with; |
722 | 722 | if ( is_array( $replace_with ) ) { |
@@ -730,82 +730,82 @@ discard block |
||
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
733 | - unset($field); |
|
734 | - break; |
|
735 | - } |
|
733 | + unset($field); |
|
734 | + break; |
|
735 | + } |
|
736 | 736 | |
737 | - if ( isset($replace_with) ) { |
|
738 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
739 | - } |
|
737 | + if ( isset($replace_with) ) { |
|
738 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
739 | + } |
|
740 | 740 | |
741 | - unset($atts, $conditional, $replace_with); |
|
741 | + unset($atts, $conditional, $replace_with); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | return $content; |
745 | - } |
|
746 | - |
|
747 | - /** |
|
748 | - * Get the value to replace a few standard shortcodes |
|
749 | - * |
|
750 | - * @since 2.0 |
|
751 | - * @return string |
|
752 | - */ |
|
753 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
754 | - $new_value = ''; |
|
755 | - switch ( $tag ) { |
|
756 | - case 'admin_email': |
|
757 | - $new_value = get_option('admin_email'); |
|
758 | - break; |
|
759 | - case 'siteurl': |
|
760 | - $new_value = FrmAppHelper::site_url(); |
|
761 | - break; |
|
762 | - case 'frmurl': |
|
763 | - $new_value = FrmAppHelper::plugin_url(); |
|
764 | - break; |
|
765 | - case 'sitename': |
|
766 | - $new_value = FrmAppHelper::site_name(); |
|
767 | - break; |
|
768 | - case 'get': |
|
769 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
770 | - break; |
|
771 | - } |
|
772 | - |
|
773 | - return $new_value; |
|
774 | - } |
|
775 | - |
|
776 | - /** |
|
777 | - * Process the [get] shortcode |
|
778 | - * |
|
779 | - * @since 2.0 |
|
780 | - * @return string|array |
|
781 | - */ |
|
782 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
783 | - if ( ! isset($atts['param']) ) { |
|
784 | - return ''; |
|
785 | - } |
|
786 | - |
|
787 | - if ( strpos($atts['param'], '[') ) { |
|
788 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
789 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
790 | - } |
|
791 | - |
|
792 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
793 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
794 | - |
|
795 | - if ( $new_value == '' ) { |
|
796 | - if ( ! isset($atts['prev_val']) ) { |
|
797 | - $atts['prev_val'] = ''; |
|
798 | - } |
|
799 | - |
|
800 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
801 | - } |
|
802 | - |
|
803 | - if ( is_array($new_value) && ! $return_array ) { |
|
804 | - $new_value = implode(', ', $new_value); |
|
805 | - } |
|
806 | - |
|
807 | - return $new_value; |
|
808 | - } |
|
745 | + } |
|
746 | + |
|
747 | + /** |
|
748 | + * Get the value to replace a few standard shortcodes |
|
749 | + * |
|
750 | + * @since 2.0 |
|
751 | + * @return string |
|
752 | + */ |
|
753 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
754 | + $new_value = ''; |
|
755 | + switch ( $tag ) { |
|
756 | + case 'admin_email': |
|
757 | + $new_value = get_option('admin_email'); |
|
758 | + break; |
|
759 | + case 'siteurl': |
|
760 | + $new_value = FrmAppHelper::site_url(); |
|
761 | + break; |
|
762 | + case 'frmurl': |
|
763 | + $new_value = FrmAppHelper::plugin_url(); |
|
764 | + break; |
|
765 | + case 'sitename': |
|
766 | + $new_value = FrmAppHelper::site_name(); |
|
767 | + break; |
|
768 | + case 'get': |
|
769 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
770 | + break; |
|
771 | + } |
|
772 | + |
|
773 | + return $new_value; |
|
774 | + } |
|
775 | + |
|
776 | + /** |
|
777 | + * Process the [get] shortcode |
|
778 | + * |
|
779 | + * @since 2.0 |
|
780 | + * @return string|array |
|
781 | + */ |
|
782 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
783 | + if ( ! isset($atts['param']) ) { |
|
784 | + return ''; |
|
785 | + } |
|
786 | + |
|
787 | + if ( strpos($atts['param'], '[') ) { |
|
788 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
789 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
790 | + } |
|
791 | + |
|
792 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
793 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
794 | + |
|
795 | + if ( $new_value == '' ) { |
|
796 | + if ( ! isset($atts['prev_val']) ) { |
|
797 | + $atts['prev_val'] = ''; |
|
798 | + } |
|
799 | + |
|
800 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
801 | + } |
|
802 | + |
|
803 | + if ( is_array($new_value) && ! $return_array ) { |
|
804 | + $new_value = implode(', ', $new_value); |
|
805 | + } |
|
806 | + |
|
807 | + return $new_value; |
|
808 | + } |
|
809 | 809 | |
810 | 810 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
811 | 811 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
814 | 814 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
815 | 815 | |
816 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
817 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
818 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
819 | - if ( is_array($replace_with) ) { |
|
820 | - $replace_with = implode("\n", $replace_with); |
|
821 | - } |
|
822 | - $replace_with = wpautop($replace_with); |
|
823 | - } |
|
816 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
817 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
818 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
819 | + if ( is_array($replace_with) ) { |
|
820 | + $replace_with = implode("\n", $replace_with); |
|
821 | + } |
|
822 | + $replace_with = wpautop($replace_with); |
|
823 | + } |
|
824 | 824 | unset( $autop ); |
825 | 825 | } else if ( is_array( $replace_with ) ) { |
826 | 826 | $replace_with = implode( $sep, $replace_with ); |
@@ -830,58 +830,58 @@ discard block |
||
830 | 830 | } |
831 | 831 | |
832 | 832 | public static function get_field_types( $type ) { |
833 | - $single_input = array( |
|
834 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
835 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
836 | - 'user_id', 'tag', 'password', |
|
837 | - ); |
|
833 | + $single_input = array( |
|
834 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
835 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
836 | + 'user_id', 'tag', 'password', |
|
837 | + ); |
|
838 | 838 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
839 | 839 | $other_type = array( 'html', 'break' ); |
840 | 840 | |
841 | 841 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
842 | 842 | |
843 | - $field_types = array(); |
|
844 | - if ( in_array($type, $single_input) ) { |
|
845 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
846 | - } else if ( in_array($type, $multiple_input) ) { |
|
847 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
848 | - } else if ( in_array($type, $other_type) ) { |
|
849 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
843 | + $field_types = array(); |
|
844 | + if ( in_array($type, $single_input) ) { |
|
845 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
846 | + } else if ( in_array($type, $multiple_input) ) { |
|
847 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
848 | + } else if ( in_array($type, $other_type) ) { |
|
849 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
850 | 850 | } else if ( isset( $field_selection[ $type ] ) ) { |
851 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
852 | - } |
|
851 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
852 | + } |
|
853 | 853 | |
854 | 854 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
855 | - return $field_types; |
|
856 | - } |
|
857 | - |
|
858 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
859 | - foreach ( $inputs as $input ) { |
|
860 | - $field_types[ $input ] = $fields[ $input ]; |
|
861 | - unset($input); |
|
862 | - } |
|
863 | - } |
|
864 | - |
|
865 | - /** |
|
866 | - * Check if current field option is an "other" option |
|
867 | - * |
|
868 | - * @since 2.0.6 |
|
869 | - * |
|
870 | - * @param string $opt_key |
|
871 | - * @return boolean Returns true if current field option is an "Other" option |
|
872 | - */ |
|
873 | - public static function is_other_opt( $opt_key ) { |
|
874 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
875 | - } |
|
876 | - |
|
877 | - /** |
|
878 | - * Get value that belongs in "Other" text box |
|
879 | - * |
|
880 | - * @since 2.0.6 |
|
881 | - * |
|
882 | - * @param array $args |
|
883 | - */ |
|
884 | - public static function get_other_val( $args ) { |
|
855 | + return $field_types; |
|
856 | + } |
|
857 | + |
|
858 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
859 | + foreach ( $inputs as $input ) { |
|
860 | + $field_types[ $input ] = $fields[ $input ]; |
|
861 | + unset($input); |
|
862 | + } |
|
863 | + } |
|
864 | + |
|
865 | + /** |
|
866 | + * Check if current field option is an "other" option |
|
867 | + * |
|
868 | + * @since 2.0.6 |
|
869 | + * |
|
870 | + * @param string $opt_key |
|
871 | + * @return boolean Returns true if current field option is an "Other" option |
|
872 | + */ |
|
873 | + public static function is_other_opt( $opt_key ) { |
|
874 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
875 | + } |
|
876 | + |
|
877 | + /** |
|
878 | + * Get value that belongs in "Other" text box |
|
879 | + * |
|
880 | + * @since 2.0.6 |
|
881 | + * |
|
882 | + * @param array $args |
|
883 | + */ |
|
884 | + public static function get_other_val( $args ) { |
|
885 | 885 | $defaults = array( |
886 | 886 | 'opt_key' => 0, 'field' => array(), |
887 | 887 | 'parent' => false, 'pointer' => false, |
@@ -957,20 +957,20 @@ discard block |
||
957 | 957 | } |
958 | 958 | |
959 | 959 | return $other_val; |
960 | - } |
|
961 | - |
|
962 | - /** |
|
963 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
964 | - * Intended for front-end use |
|
965 | - * |
|
966 | - * @since 2.0.6 |
|
967 | - * |
|
968 | - * @param array $args should include field, opt_key and field name |
|
969 | - * @param boolean $other_opt |
|
970 | - * @param string $checked |
|
971 | - * @return string $other_val |
|
972 | - */ |
|
973 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
960 | + } |
|
961 | + |
|
962 | + /** |
|
963 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
964 | + * Intended for front-end use |
|
965 | + * |
|
966 | + * @since 2.0.6 |
|
967 | + * |
|
968 | + * @param array $args should include field, opt_key and field name |
|
969 | + * @param boolean $other_opt |
|
970 | + * @param string $checked |
|
971 | + * @return string $other_val |
|
972 | + */ |
|
973 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
974 | 974 | //Check if this is an "Other" option |
975 | 975 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
976 | 976 | return; |
@@ -986,8 +986,8 @@ discard block |
||
986 | 986 | $checked = 'checked="checked" '; |
987 | 987 | } |
988 | 988 | |
989 | - return $other_args; |
|
990 | - } |
|
989 | + return $other_args; |
|
990 | + } |
|
991 | 991 | |
992 | 992 | /** |
993 | 993 | * @param array $args |
@@ -1036,8 +1036,8 @@ discard block |
||
1036 | 1036 | * @since 2.0.6 |
1037 | 1037 | */ |
1038 | 1038 | public static function include_other_input( $args ) { |
1039 | - if ( ! $args['other_opt'] ) { |
|
1040 | - return; |
|
1039 | + if ( ! $args['other_opt'] ) { |
|
1040 | + return; |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | $classes = array( 'frm_other_input' ); |
@@ -1058,15 +1058,15 @@ discard block |
||
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | /** |
1061 | - * Get the HTML id for an "Other" text field |
|
1062 | - * Note: This does not affect fields in repeating sections |
|
1063 | - * |
|
1064 | - * @since 2.0.08 |
|
1065 | - * @param string $type - field type |
|
1066 | - * @param string $html_id |
|
1067 | - * @param string|boolean $opt_key |
|
1068 | - * @return string $other_id |
|
1069 | - */ |
|
1061 | + * Get the HTML id for an "Other" text field |
|
1062 | + * Note: This does not affect fields in repeating sections |
|
1063 | + * |
|
1064 | + * @since 2.0.08 |
|
1065 | + * @param string $type - field type |
|
1066 | + * @param string $html_id |
|
1067 | + * @param string|boolean $opt_key |
|
1068 | + * @return string $other_id |
|
1069 | + */ |
|
1070 | 1070 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
1071 | 1071 | $other_id = $html_id; |
1072 | 1072 | |
@@ -1124,10 +1124,10 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | public static function switch_field_ids( $val ) { |
1127 | - global $frm_duplicate_ids; |
|
1128 | - $replace = array(); |
|
1129 | - $replace_with = array(); |
|
1130 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
1127 | + global $frm_duplicate_ids; |
|
1128 | + $replace = array(); |
|
1129 | + $replace_with = array(); |
|
1130 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
1131 | 1131 | $replace[] = '[if ' . $old . ']'; |
1132 | 1132 | $replace_with[] = '[if ' . $new . ']'; |
1133 | 1133 | $replace[] = '[if ' . $old . ' '; |
@@ -1142,153 +1142,153 @@ discard block |
||
1142 | 1142 | $replace_with[] = '[' . $new . ']'; |
1143 | 1143 | $replace[] = '[' . $old . ' '; |
1144 | 1144 | $replace_with[] = '[' . $new . ' '; |
1145 | - unset($old, $new); |
|
1146 | - } |
|
1145 | + unset($old, $new); |
|
1146 | + } |
|
1147 | 1147 | if ( is_array( $val ) ) { |
1148 | 1148 | foreach ( $val as $k => $v ) { |
1149 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
1150 | - unset($k, $v); |
|
1151 | - } |
|
1152 | - } else { |
|
1153 | - $val = str_replace($replace, $replace_with, $val); |
|
1154 | - } |
|
1155 | - |
|
1156 | - return $val; |
|
1157 | - } |
|
1158 | - |
|
1159 | - public static function get_us_states() { |
|
1160 | - return apply_filters( 'frm_us_states', array( |
|
1161 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
1162 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
1163 | - 'DC' => 'District of Columbia', |
|
1164 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
1165 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
1166 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
1167 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
1168 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
1169 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
1170 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
1171 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
1172 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
1173 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
1174 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
1175 | - ) ); |
|
1176 | - } |
|
1177 | - |
|
1178 | - public static function get_countries() { |
|
1179 | - return apply_filters( 'frm_countries', array( |
|
1180 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
1181 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
1182 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
1183 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
1184 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
1185 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
1186 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
1187 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
1188 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
1189 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
1190 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
1191 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
1192 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
1193 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
1194 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
1195 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
1196 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
1197 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
1198 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
1199 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
1200 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
1201 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
1202 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
1203 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
1204 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
1205 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
1206 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
1207 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
1208 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
1209 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
1210 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
1211 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
1212 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
1213 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
1214 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
1215 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
1216 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
1217 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
1218 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
1219 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
1220 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
1221 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
1222 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
1223 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
1224 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
1225 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
1226 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
1227 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
1228 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
1229 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
1230 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
1231 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
1232 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
1233 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
1234 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
1235 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
1236 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
1237 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
1238 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
1239 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
1240 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
1241 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
1242 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
1243 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
1244 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
1245 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
1246 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
1247 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
1248 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
1249 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
1250 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
1251 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
1252 | - __( 'Zimbabwe', 'formidable' ), |
|
1253 | - ) ); |
|
1254 | - } |
|
1149 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
1150 | + unset($k, $v); |
|
1151 | + } |
|
1152 | + } else { |
|
1153 | + $val = str_replace($replace, $replace_with, $val); |
|
1154 | + } |
|
1155 | + |
|
1156 | + return $val; |
|
1157 | + } |
|
1158 | + |
|
1159 | + public static function get_us_states() { |
|
1160 | + return apply_filters( 'frm_us_states', array( |
|
1161 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
1162 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
1163 | + 'DC' => 'District of Columbia', |
|
1164 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
1165 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
1166 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
1167 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
1168 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
1169 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
1170 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
1171 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
1172 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
1173 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
1174 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
1175 | + ) ); |
|
1176 | + } |
|
1177 | + |
|
1178 | + public static function get_countries() { |
|
1179 | + return apply_filters( 'frm_countries', array( |
|
1180 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
1181 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
1182 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
1183 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
1184 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
1185 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
1186 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
1187 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
1188 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
1189 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
1190 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
1191 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
1192 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
1193 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
1194 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
1195 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
1196 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
1197 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
1198 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
1199 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
1200 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
1201 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
1202 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
1203 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
1204 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
1205 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
1206 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
1207 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
1208 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
1209 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
1210 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
1211 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
1212 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
1213 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
1214 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
1215 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
1216 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
1217 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
1218 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
1219 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
1220 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
1221 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
1222 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
1223 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
1224 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
1225 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
1226 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
1227 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
1228 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
1229 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
1230 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
1231 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
1232 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
1233 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
1234 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
1235 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
1236 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
1237 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
1238 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
1239 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
1240 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
1241 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
1242 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
1243 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
1244 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
1245 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
1246 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
1247 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
1248 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
1249 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
1250 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
1251 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
1252 | + __( 'Zimbabwe', 'formidable' ), |
|
1253 | + ) ); |
|
1254 | + } |
|
1255 | 1255 | |
1256 | 1256 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
1257 | 1257 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
1258 | 1258 | |
1259 | - $states = FrmFieldsHelper::get_us_states(); |
|
1260 | - $state_abv = array_keys($states); |
|
1261 | - sort($state_abv); |
|
1259 | + $states = FrmFieldsHelper::get_us_states(); |
|
1260 | + $state_abv = array_keys($states); |
|
1261 | + sort($state_abv); |
|
1262 | 1262 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
1263 | 1263 | |
1264 | - $states = array_values($states); |
|
1265 | - sort($states); |
|
1264 | + $states = array_values($states); |
|
1265 | + sort($states); |
|
1266 | 1266 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
1267 | - unset($state_abv, $states); |
|
1267 | + unset($state_abv, $states); |
|
1268 | 1268 | |
1269 | 1269 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
1270 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
1271 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
1272 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
1273 | - ); |
|
1270 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
1271 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
1272 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
1273 | + ); |
|
1274 | 1274 | |
1275 | 1275 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
1276 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1277 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1278 | - ); |
|
1276 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1277 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1278 | + ); |
|
1279 | 1279 | |
1280 | 1280 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
1281 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1282 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1283 | - ); |
|
1281 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1282 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1283 | + ); |
|
1284 | 1284 | |
1285 | 1285 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
1286 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1287 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1288 | - ); |
|
1286 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
1287 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
1288 | + ); |
|
1289 | 1289 | |
1290 | 1290 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
1291 | - } |
|
1291 | + } |
|
1292 | 1292 | |
1293 | 1293 | public static function field_selection() { |
1294 | 1294 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1325,10 +1325,10 @@ discard block |
||
1325 | 1325 | return FrmField::is_required( $field ); |
1326 | 1326 | } |
1327 | 1327 | |
1328 | - public static function maybe_get_field( &$field ) { |
|
1328 | + public static function maybe_get_field( &$field ) { |
|
1329 | 1329 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
1330 | 1330 | FrmField::maybe_get_field( $field ); |
1331 | - } |
|
1331 | + } |
|
1332 | 1332 | |
1333 | 1333 | public static function dropdown_categories( $args ) { |
1334 | 1334 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |
@@ -10,41 +10,41 @@ discard block |
||
10 | 10 | <?php |
11 | 11 | |
12 | 12 | } else if ( $field['type'] == 'radio' ) { |
13 | - $read_only = false; |
|
13 | + $read_only = false; |
|
14 | 14 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
15 | - $read_only = true; ?> |
|
15 | + $read_only = true; ?> |
|
16 | 16 | <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" /> |
17 | 17 | <?php |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
20 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
22 | - } else if ( is_array($field['options']) ) { |
|
23 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
22 | + } else if ( is_array($field['options']) ) { |
|
23 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
25 | - continue; |
|
26 | - } |
|
25 | + continue; |
|
26 | + } |
|
27 | 27 | |
28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
28 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
29 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
31 | 31 | |
32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
34 | - } |
|
35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
34 | + } |
|
35 | + $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
36 | 36 | |
37 | - $other_opt = false; |
|
38 | - $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
39 | - ?> |
|
37 | + $other_opt = false; |
|
38 | + $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
39 | + ?> |
|
40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
41 | - echo $checked; |
|
42 | - do_action('frm_field_input_html', $field); |
|
41 | + echo $checked; |
|
42 | + do_action('frm_field_input_html', $field); |
|
43 | 43 | ?>/><?php |
44 | 44 | |
45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
46 | 46 | echo ' ' . $opt . '</label>'; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | FrmFieldsHelper::include_other_input( array( |
50 | 50 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -53,58 +53,58 @@ discard block |
||
53 | 53 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
54 | 54 | ) ); |
55 | 55 | |
56 | - unset( $other_opt, $other_args ); |
|
56 | + unset( $other_opt, $other_args ); |
|
57 | 57 | ?></div> |
58 | 58 | <?php |
59 | - } |
|
60 | - } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | } else if ( $field['type'] == 'select' ) { |
62 | 62 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' ); |
63 | 63 | } else if ( $field['type'] == 'checkbox' ) { |
64 | - $checked_values = $field['value']; |
|
65 | - $read_only = false; |
|
64 | + $checked_values = $field['value']; |
|
65 | + $read_only = false; |
|
66 | 66 | |
67 | 67 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
68 | - $read_only = true; |
|
69 | - if ( $checked_values ) { |
|
70 | - foreach ( (array) $checked_values as $checked_value ) { ?> |
|
68 | + $read_only = true; |
|
69 | + if ( $checked_values ) { |
|
70 | + foreach ( (array) $checked_values as $checked_value ) { ?> |
|
71 | 71 | <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
72 | 72 | <?php |
73 | - } |
|
74 | - } else { ?> |
|
73 | + } |
|
74 | + } else { ?> |
|
75 | 75 | <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
76 | 76 | <?php |
77 | - } |
|
78 | - } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
80 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
82 | - } else if ( $field['options'] ) { |
|
83 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
85 | - continue; |
|
86 | - } |
|
87 | - |
|
88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
91 | - |
|
92 | - // Check if other opt, and get values for other field if needed |
|
93 | - $other_opt = false; |
|
82 | + } else if ( $field['options'] ) { |
|
83 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
84 | + if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + |
|
88 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
89 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
90 | + $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
91 | + |
|
92 | + // Check if other opt, and get values for other field if needed |
|
93 | + $other_opt = false; |
|
94 | 94 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked ); |
95 | 95 | |
96 | - ?> |
|
96 | + ?> |
|
97 | 97 | <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="frm_checkbox_<?php echo esc_attr( $field['id'] ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
98 | 98 | |
99 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
100 | - ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
101 | - } |
|
99 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
100 | + ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
101 | + } |
|
102 | 102 | |
103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
104 | 104 | |
105 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
105 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
106 | 106 | echo ' ' . $opt . '</label>'; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | 109 | FrmFieldsHelper::include_other_input( array( |
110 | 110 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
114 | 114 | ) ); |
115 | 115 | |
116 | - unset( $other_opt, $other_args, $checked ); |
|
116 | + unset( $other_opt, $other_args, $checked ); |
|
117 | 117 | |
118 | - ?></div> |
|
118 | + ?></div> |
|
119 | 119 | <?php |
120 | - } |
|
121 | - } |
|
120 | + } |
|
121 | + } |
|
122 | 122 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
123 | - $frm_settings = FrmAppHelper::get_settings(); |
|
124 | - if ( ! empty($frm_settings->pubkey) ) { |
|
125 | - FrmFieldsHelper::display_recaptcha($field); |
|
126 | - } |
|
123 | + $frm_settings = FrmAppHelper::get_settings(); |
|
124 | + if ( ! empty($frm_settings->pubkey) ) { |
|
125 | + FrmFieldsHelper::display_recaptcha($field); |
|
126 | + } |
|
127 | 127 | } else { |
128 | 128 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
129 | 129 | do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?> |
2 | -<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/> |
|
2 | +<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/> |
|
3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php |
5 | 5 | if ( $field['max'] ) { |
6 | 6 | echo 'rows="' . esc_attr( $field['max'] ) . '" '; |
7 | 7 | } |
8 | -do_action('frm_field_input_html', $field); |
|
9 | -?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea> |
|
8 | +do_action( 'frm_field_input_html', $field ); |
|
9 | +?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea> |
|
10 | 10 | <?php |
11 | 11 | |
12 | 12 | } else if ( $field['type'] == 'radio' ) { |
@@ -17,29 +17,29 @@ discard block |
||
17 | 17 | <?php |
18 | 18 | } |
19 | 19 | |
20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
20 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
22 | - } else if ( is_array($field['options']) ) { |
|
22 | + } else if ( is_array( $field['options'] ) ) { |
|
23 | 23 | foreach ( $field['options'] as $opt_key => $opt ) { |
24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
25 | 25 | continue; |
26 | 26 | } |
27 | 27 | |
28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
28 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
29 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?> |
|
30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
31 | 31 | |
32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
34 | 34 | } |
35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
35 | + $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' '; |
|
36 | 36 | |
37 | 37 | $other_opt = false; |
38 | 38 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
39 | 39 | ?> |
40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
41 | 41 | echo $checked; |
42 | - do_action('frm_field_input_html', $field); |
|
42 | + do_action( 'frm_field_input_html', $field ); |
|
43 | 43 | ?>/><?php |
44 | 44 | |
45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
80 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
82 | 82 | } else if ( $field['options'] ) { |
83 | 83 | foreach ( $field['options'] as $opt_key => $opt ) { |
84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] != $opt_key) ) { |
|
84 | + if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
|
85 | 85 | continue; |
86 | 86 | } |
87 | 87 | |
88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
88 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
89 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
90 | + $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : ''; |
|
91 | 91 | |
92 | 92 | // Check if other opt, and get values for other field if needed |
93 | 93 | $other_opt = false; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
101 | 101 | } |
102 | 102 | |
103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php |
|
104 | 104 | |
105 | 105 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
106 | 106 | echo ' ' . $opt . '</label>'; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | } |
122 | 122 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
123 | 123 | $frm_settings = FrmAppHelper::get_settings(); |
124 | - if ( ! empty($frm_settings->pubkey) ) { |
|
125 | - FrmFieldsHelper::display_recaptcha($field); |
|
124 | + if ( ! empty( $frm_settings->pubkey ) ) { |
|
125 | + FrmFieldsHelper::display_recaptcha( $field ); |
|
126 | 126 | } |
127 | 127 | } else { |
128 | 128 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $read_only = false; |
4 | -if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) { |
|
4 | +if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) { |
|
5 | 5 | echo FrmProPost::get_category_dropdown( $field, array( 'location' => 'front', 'name' => $field_name, 'id' => $html_id ) ); |
6 | 6 | } else { |
7 | 7 | if ( FrmAppHelper::pro_is_installed() && FrmField::is_read_only( $field ) ) { |
8 | 8 | $read_only = true; |
9 | 9 | |
10 | 10 | echo FrmProDropdownFieldsController::get_hidden_fields_with_readonly_values( $field, $field_name, $html_id ); ?> |
11 | - <select <?php do_action('frm_field_input_html', $field) ?>> <?php |
|
11 | + <select <?php do_action( 'frm_field_input_html', $field ) ?>> <?php |
|
12 | 12 | |
13 | 13 | } else { ?> |
14 | - <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action('frm_field_input_html', $field) ?>> |
|
14 | + <select name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>> |
|
15 | 15 | <?php } |
16 | 16 | |
17 | 17 | $other_opt = $other_checked = false; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | } |
27 | 27 | } |
28 | 28 | ?> |
29 | - <option value="<?php echo esc_attr($field_val) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : '';?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option> |
|
29 | + <option value="<?php echo esc_attr( $field_val ) ?>" <?php echo $selected ? ' selected="selected"' : ''; ?><?php echo ( FrmFieldsHelper::is_other_opt( $opt_key ) ) ? ' class="frm_other_trigger"' : ''; ?>><?php echo esc_html( $opt == '' ? ' ' : $opt ); ?></option> |
|
30 | 30 | <?php |
31 | 31 | } ?> |
32 | 32 | </select> |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( isset($field['post_field']) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) { |
|
3 | +if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' && FrmAppHelper::pro_is_installed() ) { |
|
4 | 4 | echo FrmProPost::get_category_dropdown( $field, array( 'name' => $field_name, 'id' => 'placeholder_id', 'location' => 'form_builder' ) ); |
5 | 5 | } else { ?> |
6 | 6 | <select name="<?php echo esc_attr( $field_name ) . ( FrmField::is_option_true( $field, 'multiple' ) ? '[]' : '' ); ?>" <?php |
7 | 7 | echo FrmField::is_option_true( $field, 'size' ) ? 'class="auto_width"' : ''; |
8 | 8 | echo FrmField::is_option_true( $field, 'multiple' ) ? ' multiple="multiple"' : ''; ?> > |
9 | 9 | <?php foreach ( $field['options'] as $opt_key => $opt ) { |
10 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
11 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
10 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
11 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
12 | 12 | $selected = ( $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val( array( 'opt_key', 'field' ) ) ) ? ' selected="selected"' : ''; ?> |
13 | 13 | <option value="<?php echo esc_attr( $field_val ) ?>"<?php echo $selected ?>><?php echo esc_html( $opt ) ?> </option> |
14 | 14 | <?php } ?> |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | <?php |
27 | 27 | |
28 | 28 | if ( ! isset( $field['post_field'] ) || ! in_array( $field['post_field'], array( 'post_category' ) ) ) { ?> |
29 | - <?php do_action('frm_add_multiple_opts_labels', $field); ?> |
|
30 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count($field['options']) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
31 | - <?php FrmFieldsHelper::show_single_option($field); ?> |
|
29 | + <?php do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
30 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
31 | + <?php FrmFieldsHelper::show_single_option( $field ); ?> |
|
32 | 32 | </ul> |
33 | 33 | <?php |
34 | 34 | } ?> |
@@ -3,32 +3,32 @@ |
||
3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
7 | 7 | |
8 | 8 | <?php |
9 | 9 | |
10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
11 | + $field['default_value'] = maybe_unserialize($field['default_value']); |
|
12 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
14 | - } else { |
|
15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
14 | + } else { |
|
15 | + do_action('frm_add_multiple_opts_labels', $field); ?> |
|
16 | 16 | <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
18 | 18 | </ul> |
19 | 19 | <?php |
20 | - } |
|
20 | + } |
|
21 | 21 | } else if ( $field['type'] == 'select' ) { |
22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' ); |
23 | 23 | } else if ( $field['type'] == 'captcha' ) { |
24 | 24 | if ( empty($frm_settings->pubkey) ) { ?> |
25 | 25 | <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
26 | 26 | <?php |
27 | - } ?> |
|
27 | + } ?> |
|
28 | 28 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
29 | 29 | <input type="hidden" name="<?php echo esc_attr( $field_name ) ?>" value="1" /> |
30 | 30 | <?php |
31 | 31 | } else { |
32 | - do_action( 'frm_display_added_fields', $field ); |
|
32 | + do_action( 'frm_display_added_fields', $field ); |
|
33 | 33 | do_action( 'frm_display_added_' . $field['type'] . '_field', $field ); |
34 | 34 | } |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" <?php |
5 | 5 | echo ( FrmField::is_option_true( $field, 'size' ) ) ? esc_attr( 'style="width:' . $field['size'] . ( is_numeric( $field['size'] ) ? 'px' : '' ) . ';"' ) : ''; |
6 | - ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea(force_balance_tags($field['default_value'])); ?></textarea> |
|
6 | + ?> rows="<?php echo esc_attr( $field['max'] ); ?>" id="<?php echo esc_attr( $html_id ) ?>" class="dyn_default_value"><?php echo FrmAppHelper::esc_textarea( force_balance_tags( $field['default_value'] ) ); ?></textarea> |
|
7 | 7 | |
8 | 8 | <?php |
9 | 9 | |
10 | 10 | } else if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
11 | - $field['default_value'] = maybe_unserialize($field['default_value']); |
|
12 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
11 | + $field['default_value'] = maybe_unserialize( $field['default_value'] ); |
|
12 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
13 | 13 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
14 | 14 | } else { |
15 | - do_action('frm_add_multiple_opts_labels', $field); ?> |
|
16 | - <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo (count($field['options']) > 10) ? ' frm_field_opts_list' : ''; ?>"> |
|
15 | + do_action( 'frm_add_multiple_opts_labels', $field ); ?> |
|
16 | + <ul id="frm_field_<?php echo esc_attr( $field['id'] ) ?>_opts" class="frm_sortable_field_opts frm_clear<?php echo ( count( $field['options'] ) > 10 ) ? ' frm_field_opts_list' : ''; ?>"> |
|
17 | 17 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); ?> |
18 | 18 | </ul> |
19 | 19 | <?php |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | } else if ( $field['type'] == 'select' ) { |
22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/dropdown-field.php' ); |
23 | 23 | } else if ( $field['type'] == 'captcha' ) { |
24 | - if ( empty($frm_settings->pubkey) ) { ?> |
|
25 | - <div class="howto frm_no_captcha_text"><?php printf(__( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>') ?></div> |
|
24 | + if ( empty( $frm_settings->pubkey ) ) { ?> |
|
25 | + <div class="howto frm_no_captcha_text"><?php printf( __( 'Your captcha will not appear on your form until you %1$sset up%2$s the Site and Secret Keys', 'formidable' ), '<a href="?page=formidable-settings">', '</a>' ) ?></div> |
|
26 | 26 | <?php |
27 | 27 | } ?> |
28 | 28 | <img src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/recaptcha.png' ) ?>" class="recaptcha_placeholder" alt="reCaptcha"/> |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmEntryValidate { |
4 | - public static function validate( $values, $exclude = false ) { |
|
5 | - global $wpdb; |
|
4 | + public static function validate( $values, $exclude = false ) { |
|
5 | + global $wpdb; |
|
6 | 6 | |
7 | - FrmEntry::sanitize_entry_post( $values ); |
|
8 | - $errors = array(); |
|
7 | + FrmEntry::sanitize_entry_post( $values ); |
|
8 | + $errors = array(); |
|
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | - return $errors; |
|
13 | - } |
|
10 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
11 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
12 | + return $errors; |
|
13 | + } |
|
14 | 14 | |
15 | 15 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
16 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | - } |
|
16 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
17 | + } |
|
18 | 18 | |
19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
19 | + if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,42 +28,42 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll($where, 'field_order'); |
|
32 | 32 | |
33 | - // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | - $args = array( 'exclude' => $exclude ); |
|
33 | + // Pass exclude value to validate_field function so it can be used for repeating sections |
|
34 | + $args = array( 'exclude' => $exclude ); |
|
35 | 35 | |
36 | - foreach ( $posted_fields as $posted_field ) { |
|
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
39 | - } |
|
36 | + foreach ( $posted_fields as $posted_field ) { |
|
37 | + self::validate_field($posted_field, $errors, $values, $args); |
|
38 | + unset($posted_field); |
|
39 | + } |
|
40 | 40 | |
41 | - // check for spam |
|
42 | - self::spam_check( $exclude, $values, $errors ); |
|
41 | + // check for spam |
|
42 | + self::spam_check( $exclude, $values, $errors ); |
|
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
45 | 45 | |
46 | - return $errors; |
|
47 | - } |
|
46 | + return $errors; |
|
47 | + } |
|
48 | 48 | |
49 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | - $defaults = array( |
|
51 | - 'id' => $posted_field->id, |
|
52 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | - 'key_pointer' => '', // the pointer in the posted array |
|
54 | - 'exclude' => array(), // exclude these field types from validation |
|
55 | - ); |
|
56 | - $args = wp_parse_args( $args, $defaults ); |
|
49 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
50 | + $defaults = array( |
|
51 | + 'id' => $posted_field->id, |
|
52 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
53 | + 'key_pointer' => '', // the pointer in the posted array |
|
54 | + 'exclude' => array(), // exclude these field types from validation |
|
55 | + ); |
|
56 | + $args = wp_parse_args( $args, $defaults ); |
|
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
58 | + if ( empty($args['parent_field_id']) ) { |
|
59 | 59 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
60 | - } else { |
|
61 | - // value is from a nested form |
|
62 | - $value = $values; |
|
63 | - } |
|
60 | + } else { |
|
61 | + // value is from a nested form |
|
62 | + $value = $values; |
|
63 | + } |
|
64 | 64 | |
65 | - // Check for values in "Other" fields |
|
66 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
65 | + // Check for values in "Other" fields |
|
66 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
67 | 67 | |
68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
69 | 69 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | $value = reset($value); |
73 | 73 | } |
74 | 74 | |
75 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
75 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
76 | 76 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
77 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
78 | - $_POST['item_name'] = $value; |
|
79 | - } |
|
77 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
78 | + $_POST['item_name'] = $value; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | if ( $value != '' ) { |
82 | 82 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
86 | 86 | } |
87 | 87 | |
88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
88 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
89 | 89 | |
90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
90 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
91 | 91 | |
92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
97 | 97 | if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) { |
@@ -101,32 +101,32 @@ discard block |
||
101 | 101 | |
102 | 102 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
103 | 103 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
104 | - return; |
|
105 | - } |
|
104 | + return; |
|
105 | + } |
|
106 | 106 | |
107 | - if ( trim($value) == 'http://' ) { |
|
108 | - $value = ''; |
|
109 | - } else { |
|
110 | - $value = esc_url_raw( $value ); |
|
107 | + if ( trim($value) == 'http://' ) { |
|
108 | + $value = ''; |
|
109 | + } else { |
|
110 | + $value = esc_url_raw( $value ); |
|
111 | 111 | $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | - // validate the url format |
|
114 | + // validate the url format |
|
115 | 115 | if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
116 | 116 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
117 | 117 | } |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | 120 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
121 | - if ( $value == '' || $field->type != 'email' ) { |
|
122 | - return; |
|
123 | - } |
|
121 | + if ( $value == '' || $field->type != 'email' ) { |
|
122 | + return; |
|
123 | + } |
|
124 | 124 | |
125 | - //validate the email format |
|
126 | - if ( ! is_email($value) ) { |
|
125 | + //validate the email format |
|
126 | + if ( ! is_email($value) ) { |
|
127 | 127 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
128 | - } |
|
129 | - } |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | 131 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
132 | 132 | //validate the number format |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | public static function validate_recaptcha( &$errors, $field, $args ) { |
223 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
224 | - return; |
|
225 | - } |
|
223 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
224 | + return; |
|
225 | + } |
|
226 | 226 | |
227 | 227 | $frm_settings = FrmAppHelper::get_settings(); |
228 | 228 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -230,57 +230,57 @@ discard block |
||
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
234 | - // If captcha is missing, check if it was already verified |
|
233 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
234 | + // If captcha is missing, check if it was already verified |
|
235 | 235 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
236 | - // There was no captcha submitted |
|
236 | + // There was no captcha submitted |
|
237 | 237 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
238 | - } |
|
239 | - return; |
|
240 | - } |
|
238 | + } |
|
239 | + return; |
|
240 | + } |
|
241 | 241 | |
242 | - $arg_array = array( |
|
243 | - 'body' => array( |
|
242 | + $arg_array = array( |
|
243 | + 'body' => array( |
|
244 | 244 | 'secret' => $frm_settings->privkey, |
245 | 245 | 'response' => $_POST['g-recaptcha-response'], |
246 | 246 | 'remoteip' => FrmAppHelper::get_ip_address(), |
247 | 247 | ), |
248 | 248 | ); |
249 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
250 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
249 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
250 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
251 | 251 | |
252 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
253 | - // What happens when the CAPTCHA was entered incorrectly |
|
252 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
253 | + // What happens when the CAPTCHA was entered incorrectly |
|
254 | 254 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
255 | - } else if ( is_wp_error( $resp ) ) { |
|
255 | + } else if ( is_wp_error( $resp ) ) { |
|
256 | 256 | $error_string = $resp->get_error_message(); |
257 | 257 | $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
258 | 258 | $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * check for spam |
|
264 | - * @param boolean $exclude |
|
265 | - * @param array $values |
|
266 | - * @param array $errors by reference |
|
267 | - */ |
|
268 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
269 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
270 | - // only check spam if there are no other errors |
|
271 | - return; |
|
272 | - } |
|
273 | - |
|
274 | - if ( self::is_akismet_spam( $values ) ) { |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * check for spam |
|
264 | + * @param boolean $exclude |
|
265 | + * @param array $values |
|
266 | + * @param array $errors by reference |
|
267 | + */ |
|
268 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
269 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
270 | + // only check spam if there are no other errors |
|
271 | + return; |
|
272 | + } |
|
273 | + |
|
274 | + if ( self::is_akismet_spam( $values ) ) { |
|
275 | 275 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
276 | 276 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
277 | 277 | } |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | - if ( self::blacklist_check( $values ) ) { |
|
281 | - $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
282 | - } |
|
283 | - } |
|
280 | + if ( self::blacklist_check( $values ) ) { |
|
281 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
|
282 | + } |
|
283 | + } |
|
284 | 284 | |
285 | 285 | private static function is_akismet_spam( $values ) { |
286 | 286 | global $wpcom_api_key; |
@@ -292,54 +292,54 @@ discard block |
||
292 | 292 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
293 | 293 | } |
294 | 294 | |
295 | - public static function blacklist_check( $values ) { |
|
296 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
297 | - return false; |
|
298 | - } |
|
295 | + public static function blacklist_check( $values ) { |
|
296 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
297 | + return false; |
|
298 | + } |
|
299 | 299 | |
300 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
300 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
301 | 301 | |
302 | - if ( empty( $mod_keys ) ) { |
|
303 | - return false; |
|
304 | - } |
|
302 | + if ( empty( $mod_keys ) ) { |
|
303 | + return false; |
|
304 | + } |
|
305 | 305 | |
306 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
306 | + $content = FrmEntriesHelper::entry_array_to_string($values); |
|
307 | 307 | |
308 | 308 | if ( empty($content) ) { |
309 | - return false; |
|
309 | + return false; |
|
310 | 310 | } |
311 | 311 | |
312 | - $words = explode( "\n", $mod_keys ); |
|
312 | + $words = explode( "\n", $mod_keys ); |
|
313 | 313 | |
314 | - foreach ( (array) $words as $word ) { |
|
315 | - $word = trim( $word ); |
|
314 | + foreach ( (array) $words as $word ) { |
|
315 | + $word = trim( $word ); |
|
316 | 316 | |
317 | - if ( empty($word) ) { |
|
318 | - continue; |
|
319 | - } |
|
317 | + if ( empty($word) ) { |
|
318 | + continue; |
|
319 | + } |
|
320 | 320 | |
321 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
322 | - return true; |
|
323 | - } |
|
324 | - } |
|
321 | + if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
322 | + return true; |
|
323 | + } |
|
324 | + } |
|
325 | 325 | |
326 | - return false; |
|
327 | - } |
|
326 | + return false; |
|
327 | + } |
|
328 | 328 | |
329 | - /** |
|
330 | - * Check entries for spam |
|
331 | - * |
|
332 | - * @return boolean true if is spam |
|
333 | - */ |
|
334 | - public static function akismet( $values ) { |
|
335 | - $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
329 | + /** |
|
330 | + * Check entries for spam |
|
331 | + * |
|
332 | + * @return boolean true if is spam |
|
333 | + */ |
|
334 | + public static function akismet( $values ) { |
|
335 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
336 | 336 | |
337 | 337 | if ( empty( $content ) ) { |
338 | - return false; |
|
338 | + return false; |
|
339 | 339 | } |
340 | 340 | |
341 | - $datas = array(); |
|
342 | - self::parse_akismet_array( $datas, $content ); |
|
341 | + $datas = array(); |
|
342 | + self::parse_akismet_array( $datas, $content ); |
|
343 | 343 | |
344 | 344 | $query_string = ''; |
345 | 345 | foreach ( $datas as $key => $data ) { |
@@ -347,35 +347,35 @@ discard block |
||
347 | 347 | unset( $key, $data ); |
348 | 348 | } |
349 | 349 | |
350 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
350 | + $response = Akismet::http_post($query_string, 'comment-check'); |
|
351 | 351 | |
352 | 352 | return ( is_array( $response ) && $response[1] == 'true' ); |
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * @since 2.0 |
|
357 | - * @param string $content |
|
358 | - */ |
|
359 | - private static function parse_akismet_array( &$datas, $content ) { |
|
360 | - $datas['blog'] = FrmAppHelper::site_url(); |
|
361 | - $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * @since 2.0 |
|
357 | + * @param string $content |
|
358 | + */ |
|
359 | + private static function parse_akismet_array( &$datas, $content ) { |
|
360 | + $datas['blog'] = FrmAppHelper::site_url(); |
|
361 | + $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
|
362 | 362 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
363 | 363 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
364 | - $datas['comment_type'] = 'formidable'; |
|
365 | - $datas['comment_content'] = $content; |
|
364 | + $datas['comment_type'] = 'formidable'; |
|
365 | + $datas['comment_content'] = $content; |
|
366 | 366 | |
367 | - if ( $permalink = get_permalink() ) { |
|
368 | - $datas['permalink'] = $permalink; |
|
369 | - } |
|
367 | + if ( $permalink = get_permalink() ) { |
|
368 | + $datas['permalink'] = $permalink; |
|
369 | + } |
|
370 | 370 | |
371 | - foreach ( $_SERVER as $key => $value ) { |
|
371 | + foreach ( $_SERVER as $key => $value ) { |
|
372 | 372 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
373 | 373 | $datas[ $key ] = wp_strip_all_tags( $value ); |
374 | - } else { |
|
374 | + } else { |
|
375 | 375 | $datas[ $key ] = ''; |
376 | - } |
|
376 | + } |
|
377 | 377 | |
378 | - unset($key, $value); |
|
379 | - } |
|
380 | - } |
|
378 | + unset($key, $value); |
|
379 | + } |
|
380 | + } |
|
381 | 381 | } |
@@ -7,20 +7,20 @@ discard block |
||
7 | 7 | FrmEntry::sanitize_entry_post( $values ); |
8 | 8 | $errors = array(); |
9 | 9 | |
10 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
10 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
11 | 11 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
12 | 12 | return $errors; |
13 | 13 | } |
14 | 14 | |
15 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
15 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
16 | 16 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
17 | 17 | } |
18 | 18 | |
19 | - if ( ! isset($values['item_key']) || $values['item_key'] == '' ) { |
|
19 | + if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
|
20 | 20 | $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
21 | 21 | } |
22 | 22 | |
23 | - $where = apply_filters('frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
23 | + $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
|
24 | 24 | // Don't get subfields |
25 | 25 | $where['fr.parent_form_id'] = array( null, 0 ); |
26 | 26 | // Don't get excluded fields (like file upload fields in the ajax validation) |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $where['fi.type not'] = $exclude; |
29 | 29 | } |
30 | 30 | |
31 | - $posted_fields = FrmField::getAll($where, 'field_order'); |
|
31 | + $posted_fields = FrmField::getAll( $where, 'field_order' ); |
|
32 | 32 | |
33 | 33 | // Pass exclude value to validate_field function so it can be used for repeating sections |
34 | 34 | $args = array( 'exclude' => $exclude ); |
35 | 35 | |
36 | 36 | foreach ( $posted_fields as $posted_field ) { |
37 | - self::validate_field($posted_field, $errors, $values, $args); |
|
38 | - unset($posted_field); |
|
37 | + self::validate_field( $posted_field, $errors, $values, $args ); |
|
38 | + unset( $posted_field ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | // check for spam |
42 | 42 | self::spam_check( $exclude, $values, $errors ); |
43 | 43 | |
44 | - $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact('exclude') ); |
|
44 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude' ) ); |
|
45 | 45 | |
46 | 46 | return $errors; |
47 | 47 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | ); |
56 | 56 | $args = wp_parse_args( $args, $defaults ); |
57 | 57 | |
58 | - if ( empty($args['parent_field_id']) ) { |
|
59 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
58 | + if ( empty( $args['parent_field_id'] ) ) { |
|
59 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
60 | 60 | } else { |
61 | 61 | // value is from a nested form |
62 | 62 | $value = $values; |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
69 | 69 | |
70 | 70 | // Reset arrays with only one value if it's not a field where array keys need to be preserved |
71 | - if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
72 | - $value = reset($value); |
|
71 | + if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
72 | + $value = reset( $value ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
76 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
76 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
77 | 77 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
78 | 78 | $_POST['item_name'] = $value; |
79 | 79 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
86 | 86 | } |
87 | 87 | |
88 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
88 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
89 | 89 | |
90 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
90 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
91 | 91 | |
92 | 92 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
93 | 93 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - if ( trim($value) == 'http://' ) { |
|
107 | + if ( trim( $value ) == 'http://' ) { |
|
108 | 108 | $value = ''; |
109 | 109 | } else { |
110 | 110 | $value = esc_url_raw( $value ); |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | // validate the url format |
115 | - if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
|
116 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
115 | + if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) { |
|
116 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | //validate the email format |
126 | - if ( ! is_email($value) ) { |
|
127 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
126 | + if ( ! is_email( $value ) ) { |
|
127 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | return; |
135 | 135 | } |
136 | 136 | |
137 | - if ( ! is_numeric( $value) ) { |
|
138 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
137 | + if ( ! is_numeric( $value ) ) { |
|
138 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // validate number settings |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
146 | 146 | //minnum maxnum |
147 | 147 | if ( (float) $value < $field->field_options['minnum'] ) { |
148 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
148 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
149 | 149 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
150 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
150 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $pattern = self::phone_format( $field ); |
160 | 160 | |
161 | 161 | if ( ! preg_match( $pattern, $value ) ) { |
162 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
162 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
233 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
234 | 234 | // If captcha is missing, check if it was already verified |
235 | 235 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
236 | 236 | // There was no captcha submitted |
237 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
237 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
238 | 238 | } |
239 | 239 | return; |
240 | 240 | } |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | ), |
248 | 248 | ); |
249 | 249 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
250 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
250 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
251 | 251 | |
252 | 252 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
253 | 253 | // What happens when the CAPTCHA was entered incorrectly |
254 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
254 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
255 | 255 | } else if ( is_wp_error( $resp ) ) { |
256 | 256 | $error_string = $resp->get_error_message(); |
257 | - $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
258 | - $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
|
257 | + $errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
258 | + $errors['field' . $args['id']] .= ' ' . $error_string; |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | private static function is_akismet_spam( $values ) { |
286 | 286 | global $wpcom_api_key; |
287 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
287 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | public static function blacklist_check( $values ) { |
296 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
296 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
297 | 297 | return false; |
298 | 298 | } |
299 | 299 | |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | return false; |
304 | 304 | } |
305 | 305 | |
306 | - $content = FrmEntriesHelper::entry_array_to_string($values); |
|
306 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); |
|
307 | 307 | |
308 | - if ( empty($content) ) { |
|
308 | + if ( empty( $content ) ) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | foreach ( (array) $words as $word ) { |
315 | 315 | $word = trim( $word ); |
316 | 316 | |
317 | - if ( empty($word) ) { |
|
317 | + if ( empty( $word ) ) { |
|
318 | 318 | continue; |
319 | 319 | } |
320 | 320 | |
321 | - if ( preg_match('#' . preg_quote( $word, '#' ) . '#', $content) ) { |
|
321 | + if ( preg_match( '#' . preg_quote( $word, '#' ) . '#', $content ) ) { |
|
322 | 322 | return true; |
323 | 323 | } |
324 | 324 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | unset( $key, $data ); |
348 | 348 | } |
349 | 349 | |
350 | - $response = Akismet::http_post($query_string, 'comment-check'); |
|
350 | + $response = Akismet::http_post( $query_string, 'comment-check' ); |
|
351 | 351 | |
352 | 352 | return ( is_array( $response ) && $response[1] == 'true' ); |
353 | 353 | } |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | |
371 | 371 | foreach ( $_SERVER as $key => $value ) { |
372 | 372 | if ( ! in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ) ) && is_string( $value ) ) { |
373 | - $datas[ $key ] = wp_strip_all_tags( $value ); |
|
373 | + $datas[$key] = wp_strip_all_tags( $value ); |
|
374 | 374 | } else { |
375 | - $datas[ $key ] = ''; |
|
375 | + $datas[$key] = ''; |
|
376 | 376 | } |
377 | 377 | |
378 | - unset($key, $value); |
|
378 | + unset( $key, $value ); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | } |