@@ -21,15 +21,15 @@ |
||
21 | 21 | </div> |
22 | 22 | <div class="widget-inside frm_hidden"> |
23 | 23 | <?php |
24 | - if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
25 | - // only load settings if they are just added or are open |
|
24 | + if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
25 | + // only load settings if they are just added or are open |
|
26 | 26 | include( dirname( __FILE__ ) . '/_action_inside.php' ); |
27 | - } else { |
|
28 | - // include hidden settings so action won't get lost on update ?> |
|
27 | + } else { |
|
28 | + // include hidden settings so action won't get lost on update ?> |
|
29 | 29 | <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
30 | 30 | <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
31 | 31 | <?php |
32 | - } ?> |
|
32 | + } ?> |
|
33 | 33 | </div> |
34 | 34 | <style type="text/css"> |
35 | 35 | .frm_no_actions{ |
@@ -21,13 +21,13 @@ |
||
21 | 21 | </div> |
22 | 22 | <div class="widget-inside frm_hidden"> |
23 | 23 | <?php |
24 | - if ( defined('DOING_AJAX') || ! $action_control->action_options['ajax_load'] ) { |
|
24 | + if ( defined( 'DOING_AJAX' ) || ! $action_control->action_options['ajax_load'] ) { |
|
25 | 25 | // only load settings if they are just added or are open |
26 | 26 | include( dirname( __FILE__ ) . '/_action_inside.php' ); |
27 | 27 | } else { |
28 | 28 | // include hidden settings so action won't get lost on update ?> |
29 | - <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
30 | - <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
29 | + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
30 | + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
31 | 31 | <?php |
32 | 32 | } ?> |
33 | 33 | </div> |
@@ -4,12 +4,12 @@ discard block |
||
4 | 4 | |
5 | 5 | public function __construct() { |
6 | 6 | $action_ops = array( |
7 | - 'classes' => 'frm_email_icon frm_icon_font', |
|
8 | - 'active' => true, |
|
7 | + 'classes' => 'frm_email_icon frm_icon_font', |
|
8 | + 'active' => true, |
|
9 | 9 | 'event' => array( 'create' ), |
10 | - 'limit' => 99, |
|
11 | - 'priority' => 10, |
|
12 | - 'ajax_load' => false, |
|
10 | + 'limit' => 99, |
|
11 | + 'priority' => 10, |
|
12 | + 'ajax_load' => false, |
|
13 | 13 | ); |
14 | 14 | $action_ops = apply_filters('frm_email_control_settings', $action_ops); |
15 | 15 | |
@@ -17,23 +17,23 @@ discard block |
||
17 | 17 | } |
18 | 18 | |
19 | 19 | public function form( $form_action, $args = array() ) { |
20 | - extract($args); |
|
20 | + extract($args); |
|
21 | 21 | |
22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' ); |
23 | 23 | } |
24 | 24 | |
25 | 25 | public function get_defaults() { |
26 | - return array( |
|
27 | - 'email_to' => '[admin_email]', |
|
28 | - 'cc' => '', |
|
29 | - 'bcc' => '', |
|
30 | - 'from' => '[sitename] <[admin_email]>', |
|
31 | - 'reply_to' => '', |
|
32 | - 'email_subject' => '', |
|
33 | - 'email_message' => '[default-message]', |
|
34 | - 'inc_user_info' => 0, |
|
35 | - 'plain_text' => 0, |
|
26 | + return array( |
|
27 | + 'email_to' => '[admin_email]', |
|
28 | + 'cc' => '', |
|
29 | + 'bcc' => '', |
|
30 | + 'from' => '[sitename] <[admin_email]>', |
|
31 | + 'reply_to' => '', |
|
32 | + 'email_subject' => '', |
|
33 | + 'email_message' => '[default-message]', |
|
34 | + 'inc_user_info' => 0, |
|
35 | + 'plain_text' => 0, |
|
36 | 36 | 'event' => array( 'create' ), |
37 | - ); |
|
37 | + ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -11,13 +11,13 @@ |
||
11 | 11 | 'priority' => 10, |
12 | 12 | 'ajax_load' => false, |
13 | 13 | ); |
14 | - $action_ops = apply_filters('frm_email_control_settings', $action_ops); |
|
14 | + $action_ops = apply_filters( 'frm_email_control_settings', $action_ops ); |
|
15 | 15 | |
16 | - parent::__construct('email', __( 'Email Notification', 'formidable' ), $action_ops); |
|
16 | + parent::__construct( 'email', __( 'Email Notification', 'formidable' ), $action_ops ); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function form( $form_action, $args = array() ) { |
20 | - extract($args); |
|
20 | + extract( $args ); |
|
21 | 21 | |
22 | 22 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_email_settings.php' ); |
23 | 23 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmField { |
7 | - static $use_cache = true; |
|
7 | + static $use_cache = true; |
|
8 | 8 | static $transient_size = 200; |
9 | 9 | |
10 | 10 | public static function field_selection() { |
@@ -50,39 +50,39 @@ discard block |
||
50 | 50 | )); |
51 | 51 | } |
52 | 52 | |
53 | - public static function create( $values, $return = true ) { |
|
54 | - global $wpdb, $frm_duplicate_ids; |
|
53 | + public static function create( $values, $return = true ) { |
|
54 | + global $wpdb, $frm_duplicate_ids; |
|
55 | 55 | |
56 | - $new_values = array(); |
|
57 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
56 | + $new_values = array(); |
|
57 | + $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
58 | 58 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
59 | 59 | |
60 | 60 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
61 | 61 | $new_values[ $col ] = $values[ $col ]; |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - $new_values['options'] = $values['options']; |
|
64 | + $new_values['options'] = $values['options']; |
|
65 | 65 | |
66 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
67 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
68 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
69 | - $new_values['field_options'] = $values['field_options']; |
|
70 | - $new_values['created_at'] = current_time('mysql', 1); |
|
66 | + $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
67 | + $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
68 | + $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
69 | + $new_values['field_options'] = $values['field_options']; |
|
70 | + $new_values['created_at'] = current_time('mysql', 1); |
|
71 | 71 | |
72 | 72 | if ( isset( $values['id'] ) ) { |
73 | 73 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
74 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
75 | - } |
|
74 | + $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | foreach ( $new_values as $k => $v ) { |
78 | - if ( is_array( $v ) ) { |
|
78 | + if ( is_array( $v ) ) { |
|
79 | 79 | $new_values[ $k ] = serialize( $v ); |
80 | 80 | } |
81 | - unset( $k, $v ); |
|
82 | - } |
|
81 | + unset( $k, $v ); |
|
82 | + } |
|
83 | 83 | |
84 | - //if(isset($values['id']) and is_numeric($values['id'])) |
|
85 | - // $new_values['id'] = $values['id']; |
|
84 | + //if(isset($values['id']) and is_numeric($values['id'])) |
|
85 | + // $new_values['id'] = $values['id']; |
|
86 | 86 | |
87 | 87 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
88 | 88 | $new_id = 0; |
@@ -103,22 +103,22 @@ discard block |
||
103 | 103 | } else { |
104 | 104 | return false; |
105 | 105 | } |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
109 | - global $frm_duplicate_ids; |
|
108 | + public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
109 | + global $frm_duplicate_ids; |
|
110 | 110 | |
111 | 111 | $where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) ); |
112 | 112 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
113 | 113 | |
114 | - foreach ( (array) $fields as $field ) { |
|
115 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
116 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
117 | - $new_key = rtrim($new_key, 2); |
|
118 | - } |
|
114 | + foreach ( (array) $fields as $field ) { |
|
115 | + $new_key = ($copy_keys) ? $field->field_key : ''; |
|
116 | + if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
117 | + $new_key = rtrim($new_key, 2); |
|
118 | + } |
|
119 | 119 | |
120 | - $values = array(); |
|
121 | - FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
120 | + $values = array(); |
|
121 | + FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
122 | 122 | |
123 | 123 | // If this is a repeating section, create new form |
124 | 124 | if ( self::is_repeating_field( $field ) ) { |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | $values['form_id'] = $new_repeat_form_id; |
138 | 138 | } |
139 | 139 | |
140 | - $values = apply_filters('frm_duplicated_field', $values); |
|
141 | - $new_id = self::create($values); |
|
142 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
143 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
144 | - unset($field); |
|
145 | - } |
|
146 | - } |
|
140 | + $values = apply_filters('frm_duplicated_field', $values); |
|
141 | + $new_id = self::create($values); |
|
142 | + $frm_duplicate_ids[ $field->id ] = $new_id; |
|
143 | + $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
144 | + unset($field); |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | 148 | public static function update( $id, $values ) { |
149 | - global $wpdb; |
|
149 | + global $wpdb; |
|
150 | 150 | |
151 | 151 | $id = absint( $id ); |
152 | 152 | |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
155 | 155 | } |
156 | 156 | |
157 | - if ( isset($values['required']) ) { |
|
158 | - $values['required'] = (int) $values['required']; |
|
159 | - } |
|
157 | + if ( isset($values['required']) ) { |
|
158 | + $values['required'] = (int) $values['required']; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | self::preserve_phone_format_backslashes( $values ); |
162 | 162 | |
@@ -169,41 +169,41 @@ discard block |
||
169 | 169 | |
170 | 170 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); |
171 | 171 | |
172 | - $form_id = 0; |
|
172 | + $form_id = 0; |
|
173 | 173 | if ( isset( $values['form_id'] ) ) { |
174 | - $form_id = absint( $values['form_id'] ); |
|
174 | + $form_id = absint( $values['form_id'] ); |
|
175 | 175 | } else { |
176 | - $field = self::getOne($id); |
|
177 | - if ( $field ) { |
|
178 | - $form_id = $field->form_id; |
|
179 | - } |
|
180 | - unset($field); |
|
181 | - } |
|
182 | - unset($values); |
|
176 | + $field = self::getOne($id); |
|
177 | + if ( $field ) { |
|
178 | + $form_id = $field->form_id; |
|
179 | + } |
|
180 | + unset($field); |
|
181 | + } |
|
182 | + unset($values); |
|
183 | 183 | |
184 | 184 | if ( $query_results ) { |
185 | - wp_cache_delete( $id, 'frm_field' ); |
|
186 | - if ( $form_id ) { |
|
187 | - self::delete_form_transient($form_id); |
|
188 | - } |
|
189 | - } |
|
185 | + wp_cache_delete( $id, 'frm_field' ); |
|
186 | + if ( $form_id ) { |
|
187 | + self::delete_form_transient($form_id); |
|
188 | + } |
|
189 | + } |
|
190 | 190 | |
191 | - return $query_results; |
|
192 | - } |
|
191 | + return $query_results; |
|
192 | + } |
|
193 | 193 | |
194 | 194 | /** |
195 | - * Keep backslashes in the phone format option |
|
196 | - * |
|
197 | - * @since 2.0.8 |
|
198 | - * @param $values array - pass by reference |
|
199 | - */ |
|
195 | + * Keep backslashes in the phone format option |
|
196 | + * |
|
197 | + * @since 2.0.8 |
|
198 | + * @param $values array - pass by reference |
|
199 | + */ |
|
200 | 200 | private static function preserve_phone_format_backslashes( &$values ) { |
201 | 201 | if ( isset( $values['field_options']['format'] ) ) { |
202 | 202 | $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] ); |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - public static function destroy( $id ) { |
|
206 | + public static function destroy( $id ) { |
|
207 | 207 | global $wpdb; |
208 | 208 | |
209 | 209 | do_action( 'frm_before_destroy_field', $id ); |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) ); |
220 | 220 | return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) ); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | 223 | public static function delete_form_transient( $form_id ) { |
224 | 224 | $form_id = absint( $form_id ); |
@@ -231,16 +231,16 @@ discard block |
||
231 | 231 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) ); |
232 | 232 | |
233 | 233 | $cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb'; |
234 | - wp_cache_delete($cache_key, 'frm_field'); |
|
234 | + wp_cache_delete($cache_key, 'frm_field'); |
|
235 | 235 | |
236 | 236 | // this cache key is autogenerated in FrmDb::get_var |
237 | 237 | wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' ); |
238 | 238 | |
239 | - $form = FrmForm::getOne($form_id); |
|
240 | - if ( $form && $form->parent_form_id ) { |
|
241 | - self::delete_form_transient( $form->parent_form_id ); |
|
242 | - } |
|
243 | - } |
|
239 | + $form = FrmForm::getOne($form_id); |
|
240 | + if ( $form && $form->parent_form_id ) { |
|
241 | + self::delete_form_transient( $form->parent_form_id ); |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * If $field is numeric, get the field object |
@@ -256,131 +256,131 @@ discard block |
||
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | - global $wpdb; |
|
259 | + global $wpdb; |
|
260 | 260 | |
261 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
261 | + $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
262 | 262 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
263 | 263 | |
264 | - $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
264 | + $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
265 | 265 | |
266 | - if ( empty($results) ) { |
|
267 | - return $results; |
|
268 | - } |
|
266 | + if ( empty($results) ) { |
|
267 | + return $results; |
|
268 | + } |
|
269 | 269 | |
270 | - if ( is_numeric($id) ) { |
|
271 | - wp_cache_set( $results->field_key, $results, 'frm_field' ); |
|
272 | - } else if ( $results ) { |
|
273 | - wp_cache_set( $results->id, $results, 'frm_field' ); |
|
274 | - } |
|
270 | + if ( is_numeric($id) ) { |
|
271 | + wp_cache_set( $results->field_key, $results, 'frm_field' ); |
|
272 | + } else if ( $results ) { |
|
273 | + wp_cache_set( $results->id, $results, 'frm_field' ); |
|
274 | + } |
|
275 | 275 | |
276 | 276 | self::prepare_options( $results ); |
277 | 277 | |
278 | - return stripslashes_deep($results); |
|
279 | - } |
|
278 | + return stripslashes_deep($results); |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Get the field type by key or id |
|
283 | - * @param int|string The field id or key |
|
281 | + /** |
|
282 | + * Get the field type by key or id |
|
283 | + * @param int|string The field id or key |
|
284 | 284 | * @param mixed $col The name of the column in the fields database table |
285 | - */ |
|
286 | - public static function &get_type( $id, $col = 'type' ) { |
|
287 | - $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
288 | - if ( $field ) { |
|
289 | - $type = $field->{$col}; |
|
290 | - } else { |
|
291 | - $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
292 | - } |
|
293 | - |
|
294 | - return $type; |
|
295 | - } |
|
285 | + */ |
|
286 | + public static function &get_type( $id, $col = 'type' ) { |
|
287 | + $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
288 | + if ( $field ) { |
|
289 | + $type = $field->{$col}; |
|
290 | + } else { |
|
291 | + $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
292 | + } |
|
293 | + |
|
294 | + return $type; |
|
295 | + } |
|
296 | 296 | |
297 | 297 | public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) { |
298 | - if ( ! $form_id ) { |
|
299 | - return array(); |
|
300 | - } |
|
298 | + if ( ! $form_id ) { |
|
299 | + return array(); |
|
300 | + } |
|
301 | 301 | |
302 | 302 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) ); |
303 | 303 | if ( ! empty( $results ) ) { |
304 | - $fields = array(); |
|
305 | - $count = 0; |
|
306 | - foreach ( $results as $result ) { |
|
307 | - if ( $type != $result->type ) { |
|
308 | - continue; |
|
309 | - } |
|
304 | + $fields = array(); |
|
305 | + $count = 0; |
|
306 | + foreach ( $results as $result ) { |
|
307 | + if ( $type != $result->type ) { |
|
308 | + continue; |
|
309 | + } |
|
310 | 310 | |
311 | 311 | $fields[ $result->id ] = $result; |
312 | - $count++; |
|
313 | - if ( $limit == 1 ) { |
|
314 | - $fields = $result; |
|
315 | - break; |
|
316 | - } |
|
312 | + $count++; |
|
313 | + if ( $limit == 1 ) { |
|
314 | + $fields = $result; |
|
315 | + break; |
|
316 | + } |
|
317 | 317 | |
318 | - if ( ! empty($limit) && $count >= $limit ) { |
|
319 | - break; |
|
320 | - } |
|
318 | + if ( ! empty($limit) && $count >= $limit ) { |
|
319 | + break; |
|
320 | + } |
|
321 | 321 | |
322 | - unset($result); |
|
323 | - } |
|
324 | - return stripslashes_deep($fields); |
|
325 | - } |
|
322 | + unset($result); |
|
323 | + } |
|
324 | + return stripslashes_deep($fields); |
|
325 | + } |
|
326 | 326 | |
327 | - self::$use_cache = false; |
|
327 | + self::$use_cache = false; |
|
328 | 328 | |
329 | 329 | $where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type ); |
330 | 330 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
331 | 331 | $results = self::getAll( $where, 'field_order', $limit ); |
332 | - self::$use_cache = true; |
|
333 | - self::include_sub_fields($results, $inc_sub, $type); |
|
332 | + self::$use_cache = true; |
|
333 | + self::include_sub_fields($results, $inc_sub, $type); |
|
334 | 334 | |
335 | - return $results; |
|
336 | - } |
|
335 | + return $results; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) { |
339 | - if ( ! (int) $form_id ) { |
|
340 | - return array(); |
|
341 | - } |
|
339 | + if ( ! (int) $form_id ) { |
|
340 | + return array(); |
|
341 | + } |
|
342 | 342 | |
343 | 343 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
344 | 344 | if ( ! empty( $results ) ) { |
345 | - if ( empty($limit) ) { |
|
345 | + if ( empty($limit) ) { |
|
346 | 346 | return $results; |
347 | - } |
|
347 | + } |
|
348 | 348 | |
349 | - $fields = array(); |
|
350 | - $count = 0; |
|
351 | - foreach ( $results as $result ) { |
|
349 | + $fields = array(); |
|
350 | + $count = 0; |
|
351 | + foreach ( $results as $result ) { |
|
352 | 352 | $fields[ $result->id ] = $result; |
353 | - if ( ! empty($limit) && $count >= $limit ) { |
|
354 | - break; |
|
355 | - } |
|
356 | - } |
|
353 | + if ( ! empty($limit) && $count >= $limit ) { |
|
354 | + break; |
|
355 | + } |
|
356 | + } |
|
357 | 357 | |
358 | 358 | return $fields; |
359 | - } |
|
359 | + } |
|
360 | 360 | |
361 | - self::$use_cache = false; |
|
361 | + self::$use_cache = false; |
|
362 | 362 | |
363 | 363 | $where = array( 'fi.form_id' => absint( $form_id ) ); |
364 | 364 | self::maybe_include_repeating_fields( $inc_repeat, $where ); |
365 | 365 | $results = self::getAll( $where, 'field_order', $limit ); |
366 | 366 | |
367 | - self::$use_cache = true; |
|
367 | + self::$use_cache = true; |
|
368 | 368 | |
369 | 369 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
370 | 370 | |
371 | - if ( empty($limit) ) { |
|
371 | + if ( empty($limit) ) { |
|
372 | 372 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
373 | - } |
|
373 | + } |
|
374 | 374 | |
375 | 375 | return $results; |
376 | - } |
|
376 | + } |
|
377 | 377 | |
378 | 378 | /** |
379 | - * If repeating fields should be included, adjust $where accordingly |
|
380 | - * |
|
381 | - * @param string $inc_repeat |
|
382 | - * @param array $where - pass by reference |
|
383 | - */ |
|
379 | + * If repeating fields should be included, adjust $where accordingly |
|
380 | + * |
|
381 | + * @param string $inc_repeat |
|
382 | + * @param array $where - pass by reference |
|
383 | + */ |
|
384 | 384 | private static function maybe_include_repeating_fields( $inc_repeat, &$where ) { |
385 | 385 | if ( $inc_repeat == 'include' ) { |
386 | 386 | $form_id = $where['fi.form_id']; |
@@ -391,77 +391,77 @@ discard block |
||
391 | 391 | |
392 | 392 | public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) { |
393 | 393 | if ( 'include' != $inc_embed ) { |
394 | - return; |
|
395 | - } |
|
394 | + return; |
|
395 | + } |
|
396 | 396 | |
397 | - $form_fields = $results; |
|
397 | + $form_fields = $results; |
|
398 | 398 | $index_offset = 1; |
399 | - foreach ( $form_fields as $k => $field ) { |
|
400 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
401 | - continue; |
|
402 | - } |
|
403 | - |
|
404 | - if ( $type == 'all' ) { |
|
405 | - $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
406 | - } else { |
|
407 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
408 | - } |
|
409 | - |
|
410 | - if ( ! empty($sub_fields) ) { |
|
399 | + foreach ( $form_fields as $k => $field ) { |
|
400 | + if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
401 | + continue; |
|
402 | + } |
|
403 | + |
|
404 | + if ( $type == 'all' ) { |
|
405 | + $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
406 | + } else { |
|
407 | + $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
408 | + } |
|
409 | + |
|
410 | + if ( ! empty($sub_fields) ) { |
|
411 | 411 | $index = $k + $index_offset; |
412 | 412 | $index_offset += count( $sub_fields ); |
413 | 413 | array_splice($results, $index, 0, $sub_fields); |
414 | - } |
|
415 | - unset($field, $sub_fields); |
|
416 | - } |
|
417 | - } |
|
414 | + } |
|
415 | + unset($field, $sub_fields); |
|
416 | + } |
|
417 | + } |
|
418 | 418 | |
419 | 419 | public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) { |
420 | 420 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
421 | - if ( self::$use_cache ) { |
|
422 | - // make sure old cache doesn't get saved as a transient |
|
423 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
424 | - if ( false !== $results ) { |
|
425 | - return stripslashes_deep($results); |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - global $wpdb; |
|
430 | - |
|
431 | - if ( $blog_id && is_multisite() ) { |
|
432 | - global $wpmuBaseTablePrefix; |
|
433 | - if ( $wpmuBaseTablePrefix ) { |
|
421 | + if ( self::$use_cache ) { |
|
422 | + // make sure old cache doesn't get saved as a transient |
|
423 | + $results = wp_cache_get($cache_key, 'frm_field'); |
|
424 | + if ( false !== $results ) { |
|
425 | + return stripslashes_deep($results); |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + global $wpdb; |
|
430 | + |
|
431 | + if ( $blog_id && is_multisite() ) { |
|
432 | + global $wpmuBaseTablePrefix; |
|
433 | + if ( $wpmuBaseTablePrefix ) { |
|
434 | 434 | $prefix = $wpmuBaseTablePrefix . $blog_id . '_'; |
435 | - } else { |
|
436 | - $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
437 | - } |
|
435 | + } else { |
|
436 | + $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
437 | + } |
|
438 | 438 | |
439 | 439 | $table_name = $prefix . 'frm_fields'; |
440 | 440 | $form_table_name = $prefix . 'frm_forms'; |
441 | 441 | } else { |
442 | 442 | $table_name = $wpdb->prefix . 'frm_fields'; |
443 | 443 | $form_table_name = $wpdb->prefix . 'frm_forms'; |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | 446 | if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) { |
447 | 447 | $order_by = ' ORDER BY ' . $order_by; |
448 | 448 | } |
449 | 449 | |
450 | - $limit = FrmAppHelper::esc_limit($limit); |
|
450 | + $limit = FrmAppHelper::esc_limit($limit); |
|
451 | 451 | |
452 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
453 | - $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
452 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
453 | + $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
454 | 454 | |
455 | - if ( is_array($where) ) { |
|
456 | - $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
455 | + if ( is_array($where) ) { |
|
456 | + $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
457 | 457 | } else { |
458 | 458 | // if the query is not an array, then it has already been prepared |
459 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
459 | + $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
460 | 460 | |
461 | 461 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
462 | 462 | $results = $wpdb->$function_name( $query ); |
463 | - } |
|
464 | - unset( $where ); |
|
463 | + } |
|
464 | + unset( $where ); |
|
465 | 465 | |
466 | 466 | self::format_field_results( $results ); |
467 | 467 | |
@@ -560,21 +560,21 @@ discard block |
||
560 | 560 | |
561 | 561 | public static function getIds( $where = '', $order_by = '', $limit = '' ) { |
562 | 562 | _deprecated_function( __FUNCTION__, '2.0' ); |
563 | - global $wpdb; |
|
564 | - if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
563 | + global $wpdb; |
|
564 | + if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
565 | 565 | $order_by = ' ORDER BY ' . $order_by; |
566 | - } |
|
566 | + } |
|
567 | 567 | |
568 | 568 | $query = 'SELECT fi.id FROM ' . $wpdb->prefix . 'frm_fields fi ' . |
569 | 569 | 'LEFT OUTER JOIN '. $wpdb->prefix . 'frm_forms fr ON fi.form_id=fr.id' . |
570 | 570 | FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
571 | 571 | |
572 | - $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
|
572 | + $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
|
573 | 573 | $cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit; |
574 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
574 | + $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
575 | 575 | |
576 | - return $results; |
|
577 | - } |
|
576 | + return $results; |
|
577 | + } |
|
578 | 578 | |
579 | 579 | public static function is_no_save_field( $type ) { |
580 | 580 | return in_array( $type, self::no_save_fields() ); |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | - * @since 2.0.09 |
|
705 | - */ |
|
704 | + * @since 2.0.09 |
|
705 | + */ |
|
706 | 706 | public static function is_repeating_field( $field ) { |
707 | 707 | if ( is_array( $field ) ) { |
708 | 708 | $is_repeating_field = ( 'divider' == $field['type'] ); |
@@ -712,12 +712,12 @@ discard block |
||
712 | 712 | return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) ); |
713 | 713 | } |
714 | 714 | |
715 | - /** |
|
716 | - * @param string $key |
|
717 | - * @return int field id |
|
718 | - */ |
|
715 | + /** |
|
716 | + * @param string $key |
|
717 | + * @return int field id |
|
718 | + */ |
|
719 | 719 | public static function get_id_by_key( $key ) { |
720 | - $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
721 | - return $id; |
|
722 | - } |
|
720 | + $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
721 | + return $id; |
|
722 | + } |
|
723 | 723 | } |
@@ -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 | |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | static $transient_size = 200; |
9 | 9 | |
10 | 10 | public static function field_selection() { |
11 | - $fields = apply_filters('frm_available_fields', array( |
|
11 | + $fields = apply_filters( 'frm_available_fields', array( |
|
12 | 12 | 'text' => __( 'Single Line Text', 'formidable' ), |
13 | 13 | 'textarea' => __( 'Paragraph Text', 'formidable' ), |
14 | 14 | 'checkbox' => __( 'Checkboxes', 'formidable' ), |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | 'email' => __( 'Email Address', 'formidable' ), |
18 | 18 | 'url' => __( 'Website/URL', 'formidable' ), |
19 | 19 | 'captcha' => __( 'reCAPTCHA', 'formidable' ), |
20 | - )); |
|
20 | + ) ); |
|
21 | 21 | |
22 | 22 | return $fields; |
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function pro_field_selection() { |
26 | - return apply_filters('frm_pro_available_fields', array( |
|
26 | + return apply_filters( 'frm_pro_available_fields', array( |
|
27 | 27 | 'end_divider' => array( |
28 | 28 | 'name' => __( 'End Section', 'formidable' ), |
29 | 29 | 'switch_from' => 'divider', |
@@ -48,36 +48,36 @@ discard block |
||
48 | 48 | 'tag' => __( 'Tags', 'formidable' ), |
49 | 49 | 'credit_card' => __( 'Credit Card', 'formidable' ), |
50 | 50 | 'address' => __( 'Address', 'formidable' ), |
51 | - )); |
|
51 | + ) ); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public static function create( $values, $return = true ) { |
55 | 55 | global $wpdb, $frm_duplicate_ids; |
56 | 56 | |
57 | 57 | $new_values = array(); |
58 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
58 | + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
|
59 | 59 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
60 | 60 | |
61 | 61 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
62 | - $new_values[ $col ] = $values[ $col ]; |
|
62 | + $new_values[$col] = $values[$col]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $new_values['options'] = $values['options']; |
66 | 66 | |
67 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
68 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
69 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
67 | + $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
|
68 | + $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
|
69 | + $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
|
70 | 70 | $new_values['field_options'] = $values['field_options']; |
71 | - $new_values['created_at'] = current_time('mysql', 1); |
|
71 | + $new_values['created_at'] = current_time( 'mysql', 1 ); |
|
72 | 72 | |
73 | 73 | if ( isset( $values['id'] ) ) { |
74 | - $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
|
75 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
74 | + $frm_duplicate_ids[$values['field_key']] = $new_values['field_key']; |
|
75 | + $new_values = apply_filters( 'frm_duplicated_field', $new_values ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | foreach ( $new_values as $k => $v ) { |
79 | 79 | if ( is_array( $v ) ) { |
80 | - $new_values[ $k ] = serialize( $v ); |
|
80 | + $new_values[$k] = serialize( $v ); |
|
81 | 81 | } |
82 | 82 | unset( $k, $v ); |
83 | 83 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | if ( $query_results ) { |
100 | 100 | if ( isset( $values['id'] ) ) { |
101 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; |
|
101 | + $frm_duplicate_ids[$values['id']] = $new_id; |
|
102 | 102 | } |
103 | 103 | return $new_id; |
104 | 104 | } else { |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
114 | 114 | |
115 | 115 | foreach ( (array) $fields as $field ) { |
116 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
117 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
118 | - $new_key = rtrim($new_key, 2); |
|
116 | + $new_key = ( $copy_keys ) ? $field->field_key : ''; |
|
117 | + if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) { |
|
118 | + $new_key = rtrim( $new_key, 2 ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $values = array(); |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | $values['form_id'] = $new_repeat_form_id; |
139 | 139 | } |
140 | 140 | |
141 | - $values = apply_filters('frm_duplicated_field', $values); |
|
142 | - $new_id = self::create($values); |
|
143 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
144 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
145 | - unset($field); |
|
141 | + $values = apply_filters( 'frm_duplicated_field', $values ); |
|
142 | + $new_id = self::create( $values ); |
|
143 | + $frm_duplicate_ids[$field->id] = $new_id; |
|
144 | + $frm_duplicate_ids[$field->field_key] = $new_id; |
|
145 | + unset( $field ); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
156 | 156 | } |
157 | 157 | |
158 | - if ( isset($values['required']) ) { |
|
158 | + if ( isset( $values['required'] ) ) { |
|
159 | 159 | $values['required'] = (int) $values['required']; |
160 | 160 | } |
161 | 161 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | |
168 | 168 | // serialize array values |
169 | 169 | foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) { |
170 | - if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
|
171 | - $values[ $opt ] = serialize( $values[ $opt ] ); |
|
170 | + if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) { |
|
171 | + $values[$opt] = serialize( $values[$opt] ); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -178,18 +178,18 @@ discard block |
||
178 | 178 | if ( isset( $values['form_id'] ) ) { |
179 | 179 | $form_id = absint( $values['form_id'] ); |
180 | 180 | } else { |
181 | - $field = self::getOne($id); |
|
181 | + $field = self::getOne( $id ); |
|
182 | 182 | if ( $field ) { |
183 | 183 | $form_id = $field->form_id; |
184 | 184 | } |
185 | - unset($field); |
|
185 | + unset( $field ); |
|
186 | 186 | } |
187 | - unset($values); |
|
187 | + unset( $values ); |
|
188 | 188 | |
189 | 189 | if ( $query_results ) { |
190 | 190 | wp_cache_delete( $id, 'frm_field' ); |
191 | 191 | if ( $form_id ) { |
192 | - self::delete_form_transient($form_id); |
|
192 | + self::delete_form_transient( $form_id ); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) ); |
237 | 237 | |
238 | 238 | $cache_key = serialize( array( 'fi.form_id' => $form_id ) ) . 'field_orderlb'; |
239 | - wp_cache_delete($cache_key, 'frm_field'); |
|
239 | + wp_cache_delete( $cache_key, 'frm_field' ); |
|
240 | 240 | |
241 | 241 | // this cache key is autogenerated in FrmDb::get_var |
242 | 242 | wp_cache_delete( '(__fi.form_id=%d_OR_fr.parent_form_id=%d_)__' . $form_id . '_' . $form_id . '_ORDER_BY_field_orderfi.*__fr.name_as_form_name_results', 'frm_field' ); |
243 | 243 | |
244 | - $form = FrmForm::getOne($form_id); |
|
244 | + $form = FrmForm::getOne( $form_id ); |
|
245 | 245 | if ( $form && $form->parent_form_id ) { |
246 | 246 | self::delete_form_transient( $form->parent_form_id ); |
247 | 247 | } |
@@ -263,16 +263,16 @@ discard block |
||
263 | 263 | |
264 | 264 | global $wpdb; |
265 | 265 | |
266 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
266 | + $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s'; |
|
267 | 267 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
268 | 268 | |
269 | 269 | $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
270 | 270 | |
271 | - if ( empty($results) ) { |
|
271 | + if ( empty( $results ) ) { |
|
272 | 272 | return $results; |
273 | 273 | } |
274 | 274 | |
275 | - if ( is_numeric($id) ) { |
|
275 | + if ( is_numeric( $id ) ) { |
|
276 | 276 | wp_cache_set( $results->field_key, $results, 'frm_field' ); |
277 | 277 | } else if ( $results ) { |
278 | 278 | wp_cache_set( $results->id, $results, 'frm_field' ); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | self::prepare_options( $results ); |
282 | 282 | |
283 | - return stripslashes_deep($results); |
|
283 | + return stripslashes_deep( $results ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -313,20 +313,20 @@ discard block |
||
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | |
316 | - $fields[ $result->id ] = $result; |
|
317 | - $count++; |
|
316 | + $fields[$result->id] = $result; |
|
317 | + $count ++; |
|
318 | 318 | if ( $limit == 1 ) { |
319 | 319 | $fields = $result; |
320 | 320 | break; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! empty($limit) && $count >= $limit ) { |
|
323 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
324 | 324 | break; |
325 | 325 | } |
326 | 326 | |
327 | - unset($result); |
|
327 | + unset( $result ); |
|
328 | 328 | } |
329 | - return stripslashes_deep($fields); |
|
329 | + return stripslashes_deep( $fields ); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | self::$use_cache = false; |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
336 | 336 | $results = self::getAll( $where, 'field_order', $limit ); |
337 | 337 | self::$use_cache = true; |
338 | - self::include_sub_fields($results, $inc_sub, $type); |
|
338 | + self::include_sub_fields( $results, $inc_sub, $type ); |
|
339 | 339 | |
340 | 340 | return $results; |
341 | 341 | } |
@@ -347,15 +347,15 @@ discard block |
||
347 | 347 | |
348 | 348 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
349 | 349 | if ( ! empty( $results ) ) { |
350 | - if ( empty($limit) ) { |
|
350 | + if ( empty( $limit ) ) { |
|
351 | 351 | return $results; |
352 | 352 | } |
353 | 353 | |
354 | 354 | $fields = array(); |
355 | 355 | $count = 0; |
356 | 356 | foreach ( $results as $result ) { |
357 | - $fields[ $result->id ] = $result; |
|
358 | - if ( ! empty($limit) && $count >= $limit ) { |
|
357 | + $fields[$result->id] = $result; |
|
358 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
359 | 359 | break; |
360 | 360 | } |
361 | 361 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | |
374 | 374 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
375 | 375 | |
376 | - if ( empty($limit) ) { |
|
376 | + if ( empty( $limit ) ) { |
|
377 | 377 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
378 | 378 | } |
379 | 379 | |
@@ -402,22 +402,22 @@ discard block |
||
402 | 402 | $form_fields = $results; |
403 | 403 | $index_offset = 1; |
404 | 404 | foreach ( $form_fields as $k => $field ) { |
405 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
405 | + if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) { |
|
406 | 406 | continue; |
407 | 407 | } |
408 | 408 | |
409 | 409 | if ( $type == 'all' ) { |
410 | 410 | $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
411 | 411 | } else { |
412 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
412 | + $sub_fields = self::get_all_types_in_form( $field->form_id, $type ); |
|
413 | 413 | } |
414 | 414 | |
415 | - if ( ! empty($sub_fields) ) { |
|
415 | + if ( ! empty( $sub_fields ) ) { |
|
416 | 416 | $index = $k + $index_offset; |
417 | 417 | $index_offset += count( $sub_fields ); |
418 | - array_splice($results, $index, 0, $sub_fields); |
|
418 | + array_splice( $results, $index, 0, $sub_fields ); |
|
419 | 419 | } |
420 | - unset($field, $sub_fields); |
|
420 | + unset( $field, $sub_fields ); |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
426 | 426 | if ( self::$use_cache ) { |
427 | 427 | // make sure old cache doesn't get saved as a transient |
428 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
428 | + $results = wp_cache_get( $cache_key, 'frm_field' ); |
|
429 | 429 | if ( false !== $results ) { |
430 | - return stripslashes_deep($results); |
|
430 | + return stripslashes_deep( $results ); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -452,16 +452,16 @@ discard block |
||
452 | 452 | $order_by = ' ORDER BY ' . $order_by; |
453 | 453 | } |
454 | 454 | |
455 | - $limit = FrmAppHelper::esc_limit($limit); |
|
455 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
456 | 456 | |
457 | 457 | $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
458 | 458 | $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
459 | 459 | |
460 | - if ( is_array($where) ) { |
|
460 | + if ( is_array( $where ) ) { |
|
461 | 461 | $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
462 | 462 | } else { |
463 | 463 | // if the query is not an array, then it has already been prepared |
464 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
464 | + $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
465 | 465 | |
466 | 466 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
467 | 467 | $results = $wpdb->$function_name( $query ); |
@@ -484,9 +484,9 @@ discard block |
||
484 | 484 | wp_cache_set( $result->id, $result, 'frm_field' ); |
485 | 485 | wp_cache_set( $result->field_key, $result, 'frm_field' ); |
486 | 486 | |
487 | - $results[ $r_key ]->field_options = maybe_unserialize( $result->field_options ); |
|
488 | - $results[ $r_key ]->options = maybe_unserialize( $result->options ); |
|
489 | - $results[ $r_key ]->default_value = maybe_unserialize( $result->default_value ); |
|
487 | + $results[$r_key]->field_options = maybe_unserialize( $result->field_options ); |
|
488 | + $results[$r_key]->options = maybe_unserialize( $result->options ); |
|
489 | + $results[$r_key]->default_value = maybe_unserialize( $result->default_value ); |
|
490 | 490 | |
491 | 491 | unset( $r_key, $result ); |
492 | 492 | } |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | private static function prepare_options( &$results ) { |
506 | 506 | $results->field_options = maybe_unserialize( $results->field_options ); |
507 | 507 | |
508 | - $results->options = maybe_unserialize($results->options); |
|
509 | - $results->default_value = maybe_unserialize($results->default_value); |
|
508 | + $results->options = maybe_unserialize( $results->options ); |
|
509 | + $results->default_value = maybe_unserialize( $results->default_value ); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | /** |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | |
534 | 534 | if ( count( $next_fields ) >= self::$transient_size ) { |
535 | 535 | // if this transient is full, check for another |
536 | - $next++; |
|
536 | + $next ++; |
|
537 | 537 | self::get_next_transient( $fields, $base_name, $next ); |
538 | 538 | } |
539 | 539 | } |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | return; |
560 | 560 | } |
561 | 561 | |
562 | - $next++; |
|
562 | + $next ++; |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | 566 | public static function getIds( $where = '', $order_by = '', $limit = '' ) { |
567 | 567 | _deprecated_function( __FUNCTION__, '2.0' ); |
568 | 568 | global $wpdb; |
569 | - if ( ! empty($order_by) && ! strpos($order_by, 'ORDER BY') !== false ) { |
|
569 | + if ( ! empty( $order_by ) && ! strpos( $order_by, 'ORDER BY' ) !== false ) { |
|
570 | 570 | $order_by = ' ORDER BY ' . $order_by; |
571 | 571 | } |
572 | 572 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | |
577 | 577 | $method = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'get_var' : 'get_col'; |
578 | 578 | $cache_key = 'getIds_' . maybe_serialize( $where ) . $order_by . $limit; |
579 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_field', $query, $method); |
|
579 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_field', $query, $method ); |
|
580 | 580 | |
581 | 581 | return $results; |
582 | 582 | } |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | $is_multi_value_field = ( |
608 | 608 | $field['type'] == 'checkbox' || |
609 | 609 | $field['type'] == 'address' || |
610 | - ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
611 | - ( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
610 | + ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
611 | + ( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
612 | 612 | self::is_multiple_select( $field ) |
613 | 613 | ); |
614 | 614 | |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public static function is_multiple_select( $field ) { |
635 | 635 | if ( is_array( $field ) ) { |
636 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) ); |
|
636 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) ); |
|
637 | 637 | } else { |
638 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) ); |
|
638 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) ); |
|
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
@@ -682,23 +682,23 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | public static function is_option_true_in_array( $field, $option ) { |
685 | - return isset( $field[ $option ] ) && $field[ $option ]; |
|
685 | + return isset( $field[$option] ) && $field[$option]; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | public static function is_option_true_in_object( $field, $option ) { |
689 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ]; |
|
689 | + return isset( $field->field_options[$option] ) && $field->field_options[$option]; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | public static function is_option_empty_in_array( $field, $option ) { |
693 | - return ! isset( $field[ $option ] ) || empty( $field[ $option ] ); |
|
693 | + return ! isset( $field[$option] ) || empty( $field[$option] ); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | public static function is_option_empty_in_object( $field, $option ) { |
697 | - return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] ); |
|
697 | + return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] ); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | public static function is_option_value_in_object( $field, $option ) { |
701 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != ''; |
|
701 | + return isset( $field->field_options[$option] ) && $field->field_options[$option] != ''; |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -714,11 +714,11 @@ discard block |
||
714 | 714 | } |
715 | 715 | |
716 | 716 | public static function get_option_in_array( $field, $option ) { |
717 | - return $field[ $option ]; |
|
717 | + return $field[$option]; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | public static function get_option_in_object( $field, $option ) { |
721 | - return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : ''; |
|
721 | + return isset( $field->field_options[$option] ) ? $field->field_options[$option] : ''; |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | public $action_options; // Option array passed to wp_register_sidebar_widget() |
9 | 9 | public $control_options; // Option array passed to wp_register_widget_control() |
10 | 10 | |
11 | - public $form_id; // The ID of the form to evaluate |
|
11 | + public $form_id; // The ID of the form to evaluate |
|
12 | 12 | public $number = false; // Unique ID number of the current instance. |
13 | 13 | public $id = ''; // Unique ID string of the current instance (id_base-number) |
14 | 14 | public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | - * Echo the settings update form |
|
32 | + * Echo the settings update form |
|
33 | 33 | * |
34 | 34 | * @param array $instance Current settings |
35 | 35 | */ |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @return array of the default options |
43 | 43 | */ |
44 | 44 | public function get_defaults() { |
45 | - return array(); |
|
45 | + return array(); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function get_switch_fields() { |
49 | - return array(); |
|
49 | + return array(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public function migrate_values( $action, $form ) { |
53 | - return $action; |
|
53 | + return $action; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | // Functions you'll need to call. |
@@ -69,24 +69,24 @@ discard block |
||
69 | 69 | * - height: currently not used but may be needed in the future |
70 | 70 | */ |
71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
72 | - if ( ! defined('ABSPATH') ) { |
|
73 | - die('You are not allowed to call this page directly.'); |
|
74 | - } |
|
72 | + if ( ! defined('ABSPATH') ) { |
|
73 | + die('You are not allowed to call this page directly.'); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | $this->id_base = strtolower($id_base); |
77 | 77 | $this->name = $name; |
78 | 78 | $this->option_name = 'frm_' . $this->id_base . '_action'; |
79 | 79 | |
80 | - $default_options = array( |
|
81 | - 'classes' => '', |
|
82 | - 'active' => true, |
|
80 | + $default_options = array( |
|
81 | + 'classes' => '', |
|
82 | + 'active' => true, |
|
83 | 83 | 'event' => array( 'create' ), |
84 | - 'limit' => 1, |
|
85 | - 'force_event' => false, |
|
86 | - 'priority' => 20, |
|
87 | - 'ajax_load' => true, |
|
88 | - 'tooltip' => $name, |
|
89 | - ); |
|
84 | + 'limit' => 1, |
|
85 | + 'force_event' => false, |
|
86 | + 'priority' => 20, |
|
87 | + 'ajax_load' => true, |
|
88 | + 'tooltip' => $name, |
|
89 | + ); |
|
90 | 90 | |
91 | 91 | $action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options ); |
92 | 92 | $this->action_options = wp_parse_args( $action_options, $default_options ); |
@@ -135,132 +135,132 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | public function prepare_new( $form_id = false ) { |
138 | - if ( $form_id ) { |
|
139 | - $this->form_id = $form_id; |
|
140 | - } |
|
141 | - |
|
142 | - $post_content = array(); |
|
143 | - $default_values = $this->get_global_defaults(); |
|
144 | - |
|
145 | - // fill default values |
|
146 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
147 | - |
|
148 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
149 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
150 | - } |
|
151 | - |
|
152 | - $form_action = array( |
|
153 | - 'post_title' => $this->name, |
|
154 | - 'post_content' => $post_content, |
|
155 | - 'post_excerpt' => $this->id_base, |
|
156 | - 'ID' => '', |
|
157 | - 'post_status' => 'publish', |
|
158 | - 'post_type' => FrmFormActionsController::$action_post_type, |
|
138 | + if ( $form_id ) { |
|
139 | + $this->form_id = $form_id; |
|
140 | + } |
|
141 | + |
|
142 | + $post_content = array(); |
|
143 | + $default_values = $this->get_global_defaults(); |
|
144 | + |
|
145 | + // fill default values |
|
146 | + $post_content = wp_parse_args( $post_content, $default_values); |
|
147 | + |
|
148 | + if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
149 | + $post_content['event'] = array( reset($this->action_options['event']) ); |
|
150 | + } |
|
151 | + |
|
152 | + $form_action = array( |
|
153 | + 'post_title' => $this->name, |
|
154 | + 'post_content' => $post_content, |
|
155 | + 'post_excerpt' => $this->id_base, |
|
156 | + 'ID' => '', |
|
157 | + 'post_status' => 'publish', |
|
158 | + 'post_type' => FrmFormActionsController::$action_post_type, |
|
159 | 159 | 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
160 | - 'menu_order' => $this->form_id, |
|
161 | - ); |
|
162 | - unset($post_content); |
|
160 | + 'menu_order' => $this->form_id, |
|
161 | + ); |
|
162 | + unset($post_content); |
|
163 | 163 | |
164 | - return (object) $form_action; |
|
165 | - } |
|
164 | + return (object) $form_action; |
|
165 | + } |
|
166 | 166 | |
167 | 167 | public function create( $form_id ) { |
168 | - $this->form_id = $form_id; |
|
168 | + $this->form_id = $form_id; |
|
169 | 169 | |
170 | - $action = $this->prepare_new(); |
|
170 | + $action = $this->prepare_new(); |
|
171 | 171 | |
172 | - return $this->save_settings($action); |
|
173 | - } |
|
172 | + return $this->save_settings($action); |
|
173 | + } |
|
174 | 174 | |
175 | 175 | public function duplicate_form_actions( $form_id, $old_id ) { |
176 | - if ( $form_id == $old_id ) { |
|
177 | - // don't duplicate the actions if this is a template getting updated |
|
178 | - return; |
|
179 | - } |
|
180 | - |
|
181 | - $this->form_id = $old_id; |
|
182 | - $actions = $this->get_all( $old_id ); |
|
183 | - |
|
184 | - $this->form_id = $form_id; |
|
185 | - foreach ( $actions as $action ) { |
|
186 | - $this->duplicate_one($action, $form_id); |
|
187 | - unset($action); |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - /* Check if imported action should be created or updated |
|
176 | + if ( $form_id == $old_id ) { |
|
177 | + // don't duplicate the actions if this is a template getting updated |
|
178 | + return; |
|
179 | + } |
|
180 | + |
|
181 | + $this->form_id = $old_id; |
|
182 | + $actions = $this->get_all( $old_id ); |
|
183 | + |
|
184 | + $this->form_id = $form_id; |
|
185 | + foreach ( $actions as $action ) { |
|
186 | + $this->duplicate_one($action, $form_id); |
|
187 | + unset($action); |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + /* Check if imported action should be created or updated |
|
192 | 192 | * |
193 | 193 | * Since 2.0 |
194 | 194 | * |
195 | 195 | * @param array $action |
196 | 196 | * @return integer $post_id |
197 | 197 | */ |
198 | - public function maybe_create_action( $action, $forms ) { |
|
198 | + public function maybe_create_action( $action, $forms ) { |
|
199 | 199 | if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
200 | - // Update action only |
|
201 | - $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
202 | - $post_id = $this->save_settings( $action ); |
|
203 | - } else { |
|
204 | - // Create action |
|
205 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
206 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
207 | - } |
|
208 | - return $post_id; |
|
209 | - } |
|
200 | + // Update action only |
|
201 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
202 | + $post_id = $this->save_settings( $action ); |
|
203 | + } else { |
|
204 | + // Create action |
|
205 | + $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
206 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
207 | + } |
|
208 | + return $post_id; |
|
209 | + } |
|
210 | 210 | |
211 | 211 | public function duplicate_one( $action, $form_id ) { |
212 | - global $frm_duplicate_ids; |
|
212 | + global $frm_duplicate_ids; |
|
213 | 213 | |
214 | - $action->menu_order = $form_id; |
|
215 | - $switch = $this->get_global_switch_fields(); |
|
216 | - foreach ( (array) $action->post_content as $key => $val ) { |
|
214 | + $action->menu_order = $form_id; |
|
215 | + $switch = $this->get_global_switch_fields(); |
|
216 | + foreach ( (array) $action->post_content as $key => $val ) { |
|
217 | 217 | if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
218 | 218 | $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
219 | - } else if ( ! is_array( $val ) ) { |
|
219 | + } else if ( ! is_array( $val ) ) { |
|
220 | 220 | $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
221 | 221 | } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
222 | - // loop through each value if empty |
|
222 | + // loop through each value if empty |
|
223 | 223 | if ( empty( $switch[ $key ] ) ) { |
224 | 224 | $switch[ $key ] = array_keys( $val ); |
225 | 225 | } |
226 | 226 | |
227 | 227 | foreach ( $switch[ $key ] as $subkey ) { |
228 | 228 | $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
229 | - } |
|
230 | - } |
|
229 | + } |
|
230 | + } |
|
231 | 231 | |
232 | - unset($key, $val); |
|
233 | - } |
|
234 | - unset($action->ID); |
|
232 | + unset($key, $val); |
|
233 | + } |
|
234 | + unset($action->ID); |
|
235 | 235 | |
236 | - return $this->save_settings($action); |
|
237 | - } |
|
236 | + return $this->save_settings($action); |
|
237 | + } |
|
238 | 238 | |
239 | 239 | private function duplicate_array_walk( $action, $subkey, $val ) { |
240 | - global $frm_duplicate_ids; |
|
240 | + global $frm_duplicate_ids; |
|
241 | 241 | |
242 | - if ( is_array($subkey) ) { |
|
243 | - foreach ( $subkey as $subkey2 ) { |
|
244 | - foreach ( (array) $val as $ck => $cv ) { |
|
245 | - if ( is_array($cv) ) { |
|
242 | + if ( is_array($subkey) ) { |
|
243 | + foreach ( $subkey as $subkey2 ) { |
|
244 | + foreach ( (array) $val as $ck => $cv ) { |
|
245 | + if ( is_array($cv) ) { |
|
246 | 246 | $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
247 | 247 | } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
248 | 248 | $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
249 | - } |
|
250 | - } |
|
251 | - } |
|
252 | - } else { |
|
253 | - foreach ( (array) $val as $ck => $cv ) { |
|
254 | - if ( is_array($cv) ) { |
|
249 | + } |
|
250 | + } |
|
251 | + } |
|
252 | + } else { |
|
253 | + foreach ( (array) $val as $ck => $cv ) { |
|
254 | + if ( is_array($cv) ) { |
|
255 | 255 | $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
256 | 256 | } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
257 | 257 | $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
258 | - } |
|
259 | - } |
|
260 | - } |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | 261 | |
262 | - return $action; |
|
263 | - } |
|
262 | + return $action; |
|
263 | + } |
|
264 | 264 | |
265 | 265 | /** |
266 | 266 | * Deal with changed settings. |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | */ |
271 | 271 | public function update_callback( $form_id ) { |
272 | - $this->form_id = $form_id; |
|
272 | + $this->form_id = $form_id; |
|
273 | 273 | |
274 | 274 | $all_instances = $this->get_settings(); |
275 | 275 | |
@@ -284,25 +284,25 @@ discard block |
||
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - $action_ids = array(); |
|
287 | + $action_ids = array(); |
|
288 | 288 | |
289 | 289 | foreach ( $settings as $number => $new_instance ) { |
290 | 290 | $this->_set($number); |
291 | 291 | |
292 | 292 | if ( ! isset($new_instance['post_title']) ) { |
293 | - // settings were never opened, so don't update |
|
294 | - $action_ids[] = $new_instance['ID']; |
|
295 | - $this->updated = true; |
|
296 | - continue; |
|
293 | + // settings were never opened, so don't update |
|
294 | + $action_ids[] = $new_instance['ID']; |
|
295 | + $this->updated = true; |
|
296 | + continue; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
300 | 300 | |
301 | 301 | $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
302 | 302 | $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
303 | - $new_instance['menu_order'] = $this->form_id; |
|
304 | - $new_instance['post_status'] = 'publish'; |
|
305 | - $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
|
303 | + $new_instance['menu_order'] = $this->form_id; |
|
304 | + $new_instance['post_status'] = 'publish'; |
|
305 | + $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
|
306 | 306 | |
307 | 307 | $instance = $this->update( $new_instance, $old_instance ); |
308 | 308 | |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | $all_instances[ $number ] = $instance; |
329 | 329 | } |
330 | 330 | |
331 | - $action_ids[] = $this->save_settings($instance); |
|
331 | + $action_ids[] = $this->save_settings($instance); |
|
332 | 332 | |
333 | - $this->updated = true; |
|
333 | + $this->updated = true; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return $action_ids; |
@@ -342,100 +342,100 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | public function get_single_action( $id ) { |
345 | - $action = get_post($id); |
|
345 | + $action = get_post($id); |
|
346 | 346 | if ( $action ) { |
347 | 347 | $action = $this->prepare_action( $action ); |
348 | 348 | $this->_set( $id ); |
349 | 349 | } |
350 | - return $action; |
|
350 | + return $action; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | public function get_one( $form_id ) { |
354 | - return $this->get_all($form_id, 1); |
|
354 | + return $this->get_all($form_id, 1); |
|
355 | 355 | } |
356 | 356 | |
357 | - public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
|
358 | - $action_controls = FrmFormActionsController::get_form_actions( $type ); |
|
359 | - if ( empty($action_controls) ) { |
|
360 | - // don't continue if there are no available actions |
|
361 | - return array(); |
|
362 | - } |
|
357 | + public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
|
358 | + $action_controls = FrmFormActionsController::get_form_actions( $type ); |
|
359 | + if ( empty($action_controls) ) { |
|
360 | + // don't continue if there are no available actions |
|
361 | + return array(); |
|
362 | + } |
|
363 | 363 | |
364 | - if ( 'all' != $type ) { |
|
365 | - return $action_controls->get_all( $form_id, $limit ); |
|
366 | - } |
|
364 | + if ( 'all' != $type ) { |
|
365 | + return $action_controls->get_all( $form_id, $limit ); |
|
366 | + } |
|
367 | 367 | |
368 | 368 | $args = self::action_args( $form_id, $limit ); |
369 | 369 | $actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' ); |
370 | 370 | |
371 | - if ( ! $actions ) { |
|
372 | - return array(); |
|
373 | - } |
|
371 | + if ( ! $actions ) { |
|
372 | + return array(); |
|
373 | + } |
|
374 | 374 | |
375 | - $settings = array(); |
|
376 | - foreach ( $actions as $action ) { |
|
375 | + $settings = array(); |
|
376 | + foreach ( $actions as $action ) { |
|
377 | 377 | // some plugins/themes are formatting the post_excerpt |
378 | 378 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
379 | 379 | |
380 | 380 | if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
381 | - continue; |
|
382 | - } |
|
381 | + continue; |
|
382 | + } |
|
383 | 383 | |
384 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
384 | + $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
385 | 385 | $settings[ $action->ID ] = $action; |
386 | 386 | |
387 | 387 | if ( count( $settings ) >= $limit ) { |
388 | 388 | break; |
389 | 389 | } |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - if ( 1 === $limit ) { |
|
393 | - $settings = reset($settings); |
|
394 | - } |
|
392 | + if ( 1 === $limit ) { |
|
393 | + $settings = reset($settings); |
|
394 | + } |
|
395 | 395 | |
396 | - return $settings; |
|
397 | - } |
|
396 | + return $settings; |
|
397 | + } |
|
398 | 398 | |
399 | 399 | public function get_all( $form_id = false, $limit = 99 ) { |
400 | - if ( $form_id ) { |
|
401 | - $this->form_id = $form_id; |
|
402 | - } |
|
400 | + if ( $form_id ) { |
|
401 | + $this->form_id = $form_id; |
|
402 | + } |
|
403 | 403 | |
404 | - $type = $this->id_base; |
|
404 | + $type = $this->id_base; |
|
405 | 405 | |
406 | - global $frm_vars; |
|
407 | - $frm_vars['action_type'] = $type; |
|
406 | + global $frm_vars; |
|
407 | + $frm_vars['action_type'] = $type; |
|
408 | 408 | |
409 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
409 | + add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
410 | 410 | $query = self::action_args( $form_id, $limit ); |
411 | - $query['post_status'] = 'any'; |
|
412 | - $query['suppress_filters'] = false; |
|
411 | + $query['post_status'] = 'any'; |
|
412 | + $query['suppress_filters'] = false; |
|
413 | 413 | |
414 | 414 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
415 | - unset($query); |
|
415 | + unset($query); |
|
416 | 416 | |
417 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
417 | + remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
418 | 418 | |
419 | - if ( empty($actions) ) { |
|
420 | - return array(); |
|
421 | - } |
|
419 | + if ( empty($actions) ) { |
|
420 | + return array(); |
|
421 | + } |
|
422 | 422 | |
423 | - $settings = array(); |
|
424 | - foreach ( $actions as $action ) { |
|
425 | - if ( count($settings) >= $limit ) { |
|
426 | - continue; |
|
427 | - } |
|
423 | + $settings = array(); |
|
424 | + foreach ( $actions as $action ) { |
|
425 | + if ( count($settings) >= $limit ) { |
|
426 | + continue; |
|
427 | + } |
|
428 | 428 | |
429 | - $action = $this->prepare_action($action); |
|
429 | + $action = $this->prepare_action($action); |
|
430 | 430 | |
431 | 431 | $settings[ $action->ID ] = $action; |
432 | - } |
|
432 | + } |
|
433 | 433 | |
434 | - if ( 1 === $limit ) { |
|
435 | - $settings = reset($settings); |
|
436 | - } |
|
434 | + if ( 1 === $limit ) { |
|
435 | + $settings = reset($settings); |
|
436 | + } |
|
437 | 437 | |
438 | - return $settings; |
|
438 | + return $settings; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | public static function action_args( $form_id = 0, $limit = 99 ) { |
@@ -458,45 +458,45 @@ discard block |
||
458 | 458 | $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
459 | 459 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
460 | 460 | |
461 | - $default_values = $this->get_global_defaults(); |
|
461 | + $default_values = $this->get_global_defaults(); |
|
462 | 462 | |
463 | - // fill default values |
|
464 | - $action->post_content += $default_values; |
|
463 | + // fill default values |
|
464 | + $action->post_content += $default_values; |
|
465 | 465 | |
466 | - foreach ( $default_values as $k => $vals ) { |
|
467 | - if ( is_array($vals) && ! empty($vals) ) { |
|
466 | + foreach ( $default_values as $k => $vals ) { |
|
467 | + if ( is_array($vals) && ! empty($vals) ) { |
|
468 | 468 | if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
469 | - continue; |
|
470 | - } |
|
469 | + continue; |
|
470 | + } |
|
471 | 471 | $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
472 | - } |
|
473 | - } |
|
472 | + } |
|
473 | + } |
|
474 | 474 | |
475 | - if ( ! is_array($action->post_content['event']) ) { |
|
476 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
477 | - } |
|
475 | + if ( ! is_array($action->post_content['event']) ) { |
|
476 | + $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
477 | + } |
|
478 | 478 | |
479 | - return $action; |
|
479 | + return $action; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | public function destroy( $form_id = false, $type = 'default' ) { |
483 | - global $wpdb; |
|
483 | + global $wpdb; |
|
484 | 484 | |
485 | - $this->form_id = $form_id; |
|
485 | + $this->form_id = $form_id; |
|
486 | 486 | |
487 | - $query = array( 'post_type' => FrmFormActionsController::$action_post_type ); |
|
488 | - if ( $form_id ) { |
|
489 | - $query['menu_order'] = $form_id; |
|
490 | - } |
|
491 | - if ( 'all' != $type ) { |
|
492 | - $query['post_excerpt'] = $this->id_base; |
|
493 | - } |
|
487 | + $query = array( 'post_type' => FrmFormActionsController::$action_post_type ); |
|
488 | + if ( $form_id ) { |
|
489 | + $query['menu_order'] = $form_id; |
|
490 | + } |
|
491 | + if ( 'all' != $type ) { |
|
492 | + $query['post_excerpt'] = $this->id_base; |
|
493 | + } |
|
494 | 494 | |
495 | - $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
|
495 | + $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
|
496 | 496 | |
497 | - foreach ( $post_ids as $id ) { |
|
498 | - wp_delete_post($id); |
|
499 | - } |
|
497 | + foreach ( $post_ids as $id ) { |
|
498 | + wp_delete_post($id); |
|
499 | + } |
|
500 | 500 | self::clear_cache(); |
501 | 501 | } |
502 | 502 | |
@@ -514,69 +514,69 @@ discard block |
||
514 | 514 | } |
515 | 515 | |
516 | 516 | public function get_global_defaults() { |
517 | - $defaults = $this->get_defaults(); |
|
517 | + $defaults = $this->get_defaults(); |
|
518 | 518 | |
519 | - if ( ! isset($defaults['event']) ) { |
|
519 | + if ( ! isset($defaults['event']) ) { |
|
520 | 520 | $defaults['event'] = array( 'create' ); |
521 | - } |
|
521 | + } |
|
522 | 522 | |
523 | - if ( ! isset($defaults['conditions']) ) { |
|
524 | - $defaults['conditions'] = array( |
|
525 | - 'send_stop' => '', |
|
526 | - 'any_all' => '', |
|
527 | - ); |
|
528 | - } |
|
523 | + if ( ! isset($defaults['conditions']) ) { |
|
524 | + $defaults['conditions'] = array( |
|
525 | + 'send_stop' => '', |
|
526 | + 'any_all' => '', |
|
527 | + ); |
|
528 | + } |
|
529 | 529 | |
530 | - return $defaults; |
|
530 | + return $defaults; |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | public function get_global_switch_fields() { |
534 | - $switch = $this->get_switch_fields(); |
|
534 | + $switch = $this->get_switch_fields(); |
|
535 | 535 | $switch['conditions'] = array( 'hide_field' ); |
536 | - return $switch; |
|
536 | + return $switch; |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
540 | 540 | * Migrate settings from form->options into new action. |
541 | 541 | */ |
542 | 542 | public function migrate_to_2( $form, $update = 'update' ) { |
543 | - $action = $this->prepare_new($form->id); |
|
544 | - $form->options = maybe_unserialize($form->options); |
|
543 | + $action = $this->prepare_new($form->id); |
|
544 | + $form->options = maybe_unserialize($form->options); |
|
545 | 545 | |
546 | - // fill with existing options |
|
547 | - foreach ( $action->post_content as $name => $val ) { |
|
546 | + // fill with existing options |
|
547 | + foreach ( $action->post_content as $name => $val ) { |
|
548 | 548 | if ( isset( $form->options[ $name ] ) ) { |
549 | 549 | $action->post_content[ $name ] = $form->options[ $name ]; |
550 | 550 | unset( $form->options[ $name ] ); |
551 | - } |
|
552 | - } |
|
551 | + } |
|
552 | + } |
|
553 | 553 | |
554 | - $action = $this->migrate_values($action, $form); |
|
554 | + $action = $this->migrate_values($action, $form); |
|
555 | 555 | |
556 | - // check if action already exists |
|
557 | - $post_id = get_posts( array( |
|
558 | - 'name' => $action->post_name, |
|
559 | - 'post_type' => FrmFormActionsController::$action_post_type, |
|
560 | - 'post_status' => $action->post_status, |
|
561 | - 'numberposts' => 1, |
|
562 | - ) ); |
|
556 | + // check if action already exists |
|
557 | + $post_id = get_posts( array( |
|
558 | + 'name' => $action->post_name, |
|
559 | + 'post_type' => FrmFormActionsController::$action_post_type, |
|
560 | + 'post_status' => $action->post_status, |
|
561 | + 'numberposts' => 1, |
|
562 | + ) ); |
|
563 | 563 | |
564 | - if ( empty($post_id) ) { |
|
565 | - // create action now |
|
566 | - $post_id = $this->save_settings($action); |
|
567 | - } |
|
564 | + if ( empty($post_id) ) { |
|
565 | + // create action now |
|
566 | + $post_id = $this->save_settings($action); |
|
567 | + } |
|
568 | 568 | |
569 | - if ( $post_id && 'update' == $update ) { |
|
570 | - global $wpdb; |
|
571 | - $form->options = maybe_serialize($form->options); |
|
569 | + if ( $post_id && 'update' == $update ) { |
|
570 | + global $wpdb; |
|
571 | + $form->options = maybe_serialize($form->options); |
|
572 | 572 | |
573 | - // update form options |
|
573 | + // update form options |
|
574 | 574 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
575 | - wp_cache_delete( $form->id, 'frm_form'); |
|
576 | - } |
|
575 | + wp_cache_delete( $form->id, 'frm_form'); |
|
576 | + } |
|
577 | 577 | |
578 | - return $post_id; |
|
579 | - } |
|
578 | + return $post_id; |
|
579 | + } |
|
580 | 580 | |
581 | 581 | public static function action_conditions_met( $action, $entry ) { |
582 | 582 | $notification = $action->post_content; |
@@ -2,16 +2,16 @@ discard block |
||
2 | 2 | |
3 | 3 | class FrmFormAction { |
4 | 4 | |
5 | - public $id_base; // Root id for all actions of this type. |
|
6 | - public $name; // Name for this action type. |
|
5 | + public $id_base; // Root id for all actions of this type. |
|
6 | + public $name; // Name for this action type. |
|
7 | 7 | public $option_name; |
8 | - public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
9 | - public $control_options; // Option array passed to wp_register_widget_control() |
|
8 | + public $action_options; // Option array passed to wp_register_sidebar_widget() |
|
9 | + public $control_options; // Option array passed to wp_register_widget_control() |
|
10 | 10 | |
11 | - public $form_id; // The ID of the form to evaluate |
|
12 | - public $number = false; // Unique ID number of the current instance. |
|
13 | - public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
14 | - public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
11 | + public $form_id; // The ID of the form to evaluate |
|
12 | + public $number = false; // Unique ID number of the current instance. |
|
13 | + public $id = ''; // Unique ID string of the current instance (id_base-number) |
|
14 | + public $updated = false; // Set true when we update the data after a POST submit - makes sure we don't do it twice. |
|
15 | 15 | |
16 | 16 | // Member functions that you must over-ride. |
17 | 17 | |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | * - height: currently not used but may be needed in the future |
70 | 70 | */ |
71 | 71 | public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) { |
72 | - if ( ! defined('ABSPATH') ) { |
|
73 | - die('You are not allowed to call this page directly.'); |
|
72 | + if ( ! defined( 'ABSPATH' ) ) { |
|
73 | + die( 'You are not allowed to call this page directly.' ); |
|
74 | 74 | } |
75 | 75 | |
76 | - $this->id_base = strtolower($id_base); |
|
76 | + $this->id_base = strtolower( $id_base ); |
|
77 | 77 | $this->name = $name; |
78 | 78 | $this->option_name = 'frm_' . $this->id_base . '_action'; |
79 | 79 | |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | $default_values = $this->get_global_defaults(); |
144 | 144 | |
145 | 145 | // fill default values |
146 | - $post_content = wp_parse_args( $post_content, $default_values); |
|
146 | + $post_content = wp_parse_args( $post_content, $default_values ); |
|
147 | 147 | |
148 | - if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) { |
|
149 | - $post_content['event'] = array( reset($this->action_options['event']) ); |
|
148 | + if ( ! isset( $post_content['event'] ) && ! $this->action_options['force_event'] ) { |
|
149 | + $post_content['event'] = array( reset( $this->action_options['event'] ) ); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $form_action = array( |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'post_name' => $this->form_id . '_' . $this->id_base . '_' . $this->number, |
160 | 160 | 'menu_order' => $this->form_id, |
161 | 161 | ); |
162 | - unset($post_content); |
|
162 | + unset( $post_content ); |
|
163 | 163 | |
164 | 164 | return (object) $form_action; |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $action = $this->prepare_new(); |
171 | 171 | |
172 | - return $this->save_settings($action); |
|
172 | + return $this->save_settings( $action ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | public function duplicate_form_actions( $form_id, $old_id ) { |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | $this->form_id = $form_id; |
185 | 185 | foreach ( $actions as $action ) { |
186 | - $this->duplicate_one($action, $form_id); |
|
187 | - unset($action); |
|
186 | + $this->duplicate_one( $action, $form_id ); |
|
187 | + unset( $action ); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | * @return integer $post_id |
197 | 197 | */ |
198 | 198 | public function maybe_create_action( $action, $forms ) { |
199 | - if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) { |
|
199 | + if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[$action['menu_order']] == 'updated' ) { |
|
200 | 200 | // Update action only |
201 | 201 | $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
202 | 202 | $post_id = $this->save_settings( $action ); |
203 | 203 | } else { |
204 | 204 | // Create action |
205 | - $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']); |
|
206 | - $post_id = $this->duplicate_one( (object) $action, $action['menu_order']); |
|
205 | + $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] ); |
|
206 | + $post_id = $this->duplicate_one( (object) $action, $action['menu_order'] ); |
|
207 | 207 | } |
208 | 208 | return $post_id; |
209 | 209 | } |
@@ -214,47 +214,47 @@ discard block |
||
214 | 214 | $action->menu_order = $form_id; |
215 | 215 | $switch = $this->get_global_switch_fields(); |
216 | 216 | foreach ( (array) $action->post_content as $key => $val ) { |
217 | - if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) { |
|
218 | - $action->post_content[ $key ] = $frm_duplicate_ids[ $val ]; |
|
217 | + if ( is_numeric( $val ) && isset( $frm_duplicate_ids[$val] ) ) { |
|
218 | + $action->post_content[$key] = $frm_duplicate_ids[$val]; |
|
219 | 219 | } else if ( ! is_array( $val ) ) { |
220 | - $action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val ); |
|
221 | - } else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) { |
|
220 | + $action->post_content[$key] = FrmFieldsHelper::switch_field_ids( $val ); |
|
221 | + } else if ( isset( $switch[$key] ) && is_array( $switch[$key] ) ) { |
|
222 | 222 | // loop through each value if empty |
223 | - if ( empty( $switch[ $key ] ) ) { |
|
224 | - $switch[ $key ] = array_keys( $val ); |
|
223 | + if ( empty( $switch[$key] ) ) { |
|
224 | + $switch[$key] = array_keys( $val ); |
|
225 | 225 | } |
226 | 226 | |
227 | - foreach ( $switch[ $key ] as $subkey ) { |
|
228 | - $action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val ); |
|
227 | + foreach ( $switch[$key] as $subkey ) { |
|
228 | + $action->post_content[$key] = $this->duplicate_array_walk( $action->post_content[$key], $subkey, $val ); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - unset($key, $val); |
|
232 | + unset( $key, $val ); |
|
233 | 233 | } |
234 | - unset($action->ID); |
|
234 | + unset( $action->ID ); |
|
235 | 235 | |
236 | - return $this->save_settings($action); |
|
236 | + return $this->save_settings( $action ); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | private function duplicate_array_walk( $action, $subkey, $val ) { |
240 | 240 | global $frm_duplicate_ids; |
241 | 241 | |
242 | - if ( is_array($subkey) ) { |
|
242 | + if ( is_array( $subkey ) ) { |
|
243 | 243 | foreach ( $subkey as $subkey2 ) { |
244 | 244 | foreach ( (array) $val as $ck => $cv ) { |
245 | - if ( is_array($cv) ) { |
|
246 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv ); |
|
247 | - } else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) { |
|
248 | - $action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ]; |
|
245 | + if ( is_array( $cv ) ) { |
|
246 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey2, $cv ); |
|
247 | + } else if ( isset( $cv[$subkey] ) && is_numeric( $cv[$subkey] ) && isset( $frm_duplicate_ids[$cv[$subkey]] ) ) { |
|
248 | + $action[$ck][$subkey] = $frm_duplicate_ids[$cv[$subkey]]; |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } else { |
253 | 253 | foreach ( (array) $val as $ck => $cv ) { |
254 | - if ( is_array($cv) ) { |
|
255 | - $action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv ); |
|
256 | - } else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) { |
|
257 | - $action[ $ck ] = $frm_duplicate_ids[ $cv ]; |
|
254 | + if ( is_array( $cv ) ) { |
|
255 | + $action[$ck] = $this->duplicate_array_walk( $action[$ck], $subkey, $cv ); |
|
256 | + } else if ( $ck == $subkey && isset( $frm_duplicate_ids[$cv] ) ) { |
|
257 | + $action[$ck] = $frm_duplicate_ids[$cv]; |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | - if ( isset( $_POST[ $this->option_name ] ) && is_array( $_POST[ $this->option_name ] ) ) { |
|
282 | - $settings = $_POST[ $this->option_name ]; |
|
281 | + if ( isset( $_POST[$this->option_name] ) && is_array( $_POST[$this->option_name] ) ) { |
|
282 | + $settings = $_POST[$this->option_name]; |
|
283 | 283 | } else { |
284 | 284 | return; |
285 | 285 | } |
@@ -287,19 +287,19 @@ discard block |
||
287 | 287 | $action_ids = array(); |
288 | 288 | |
289 | 289 | foreach ( $settings as $number => $new_instance ) { |
290 | - $this->_set($number); |
|
290 | + $this->_set( $number ); |
|
291 | 291 | |
292 | - if ( ! isset($new_instance['post_title']) ) { |
|
292 | + if ( ! isset( $new_instance['post_title'] ) ) { |
|
293 | 293 | // settings were never opened, so don't update |
294 | 294 | $action_ids[] = $new_instance['ID']; |
295 | 295 | $this->updated = true; |
296 | 296 | continue; |
297 | 297 | } |
298 | 298 | |
299 | - $old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array(); |
|
299 | + $old_instance = isset( $all_instances[$number] ) ? $all_instances[$number] : array(); |
|
300 | 300 | |
301 | - $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
302 | - $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
301 | + $new_instance['post_type'] = FrmFormActionsController::$action_post_type; |
|
302 | + $new_instance['post_name'] = $this->form_id . '_' . $this->id_base . '_' . $this->number; |
|
303 | 303 | $new_instance['menu_order'] = $this->form_id; |
304 | 304 | $new_instance['post_status'] = 'publish'; |
305 | 305 | $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : ''; |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | */ |
322 | 322 | $instance = apply_filters( 'frm_action_update_callback', $instance, $new_instance, $old_instance, $this ); |
323 | 323 | |
324 | - $instance['post_content'] = apply_filters('frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this); |
|
324 | + $instance['post_content'] = apply_filters( 'frm_before_save_action', $instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
|
325 | 325 | $instance['post_content'] = apply_filters( 'frm_before_save_' . $this->id_base . '_action', $new_instance['post_content'], $instance, $new_instance, $old_instance, $this ); |
326 | 326 | |
327 | 327 | if ( false !== $instance ) { |
328 | - $all_instances[ $number ] = $instance; |
|
328 | + $all_instances[$number] = $instance; |
|
329 | 329 | } |
330 | 330 | |
331 | - $action_ids[] = $this->save_settings($instance); |
|
331 | + $action_ids[] = $this->save_settings( $instance ); |
|
332 | 332 | |
333 | 333 | $this->updated = true; |
334 | 334 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | public function get_single_action( $id ) { |
345 | - $action = get_post($id); |
|
345 | + $action = get_post( $id ); |
|
346 | 346 | if ( $action ) { |
347 | 347 | $action = $this->prepare_action( $action ); |
348 | 348 | $this->_set( $id ); |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | public function get_one( $form_id ) { |
354 | - return $this->get_all($form_id, 1); |
|
354 | + return $this->get_all( $form_id, 1 ); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) { |
358 | 358 | $action_controls = FrmFormActionsController::get_form_actions( $type ); |
359 | - if ( empty($action_controls) ) { |
|
359 | + if ( empty( $action_controls ) ) { |
|
360 | 360 | // don't continue if there are no available actions |
361 | 361 | return array(); |
362 | 362 | } |
@@ -377,12 +377,12 @@ discard block |
||
377 | 377 | // some plugins/themes are formatting the post_excerpt |
378 | 378 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
379 | 379 | |
380 | - if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) { |
|
380 | + if ( ! isset( $action_controls[$action->post_excerpt] ) ) { |
|
381 | 381 | continue; |
382 | 382 | } |
383 | 383 | |
384 | - $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action ); |
|
385 | - $settings[ $action->ID ] = $action; |
|
384 | + $action = $action_controls[$action->post_excerpt]->prepare_action( $action ); |
|
385 | + $settings[$action->ID] = $action; |
|
386 | 386 | |
387 | 387 | if ( count( $settings ) >= $limit ) { |
388 | 388 | break; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | } |
391 | 391 | |
392 | 392 | if ( 1 === $limit ) { |
393 | - $settings = reset($settings); |
|
393 | + $settings = reset( $settings ); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | return $settings; |
@@ -423,33 +423,33 @@ discard block |
||
423 | 423 | global $frm_vars; |
424 | 424 | $frm_vars['action_type'] = $type; |
425 | 425 | |
426 | - add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
426 | + add_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
427 | 427 | $query = self::action_args( $form_id, $limit ); |
428 | 428 | $query['post_status'] = 'any'; |
429 | 429 | $query['suppress_filters'] = false; |
430 | 430 | |
431 | 431 | $actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' ); |
432 | - unset($query); |
|
432 | + unset( $query ); |
|
433 | 433 | |
434 | - remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' ); |
|
434 | + remove_filter( 'posts_where', 'FrmFormActionsController::limit_by_type' ); |
|
435 | 435 | |
436 | - if ( empty($actions) ) { |
|
436 | + if ( empty( $actions ) ) { |
|
437 | 437 | return array(); |
438 | 438 | } |
439 | 439 | |
440 | 440 | $settings = array(); |
441 | 441 | foreach ( $actions as $action ) { |
442 | - if ( count($settings) >= $limit ) { |
|
442 | + if ( count( $settings ) >= $limit ) { |
|
443 | 443 | continue; |
444 | 444 | } |
445 | 445 | |
446 | - $action = $this->prepare_action($action); |
|
446 | + $action = $this->prepare_action( $action ); |
|
447 | 447 | |
448 | - $settings[ $action->ID ] = $action; |
|
448 | + $settings[$action->ID] = $action; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | if ( 1 === $limit ) { |
452 | - $settings = reset($settings); |
|
452 | + $settings = reset( $settings ); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | return $settings; |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | public function prepare_action( $action ) { |
475 | - $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content); |
|
475 | + $action->post_content = (array) FrmAppHelper::maybe_json_decode( $action->post_content ); |
|
476 | 476 | $action->post_excerpt = sanitize_title( $action->post_excerpt ); |
477 | 477 | |
478 | 478 | $default_values = $this->get_global_defaults(); |
@@ -481,16 +481,16 @@ discard block |
||
481 | 481 | $action->post_content += $default_values; |
482 | 482 | |
483 | 483 | foreach ( $default_values as $k => $vals ) { |
484 | - if ( is_array($vals) && ! empty($vals) ) { |
|
485 | - if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) { |
|
484 | + if ( is_array( $vals ) && ! empty( $vals ) ) { |
|
485 | + if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[$k] ) ) { |
|
486 | 486 | continue; |
487 | 487 | } |
488 | - $action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals ); |
|
488 | + $action->post_content[$k] = wp_parse_args( $action->post_content[$k], $vals ); |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( ! is_array($action->post_content['event']) ) { |
|
493 | - $action->post_content['event'] = explode(',', $action->post_content['event']); |
|
492 | + if ( ! is_array( $action->post_content['event'] ) ) { |
|
493 | + $action->post_content['event'] = explode( ',', $action->post_content['event'] ); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | return $action; |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' ); |
513 | 513 | |
514 | 514 | foreach ( $post_ids as $id ) { |
515 | - wp_delete_post($id); |
|
515 | + wp_delete_post( $id ); |
|
516 | 516 | } |
517 | 517 | self::clear_cache(); |
518 | 518 | } |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function get_global_defaults() { |
534 | 534 | $defaults = $this->get_defaults(); |
535 | 535 | |
536 | - if ( ! isset($defaults['event']) ) { |
|
536 | + if ( ! isset( $defaults['event'] ) ) { |
|
537 | 537 | $defaults['event'] = array( 'create' ); |
538 | 538 | } |
539 | 539 | |
540 | - if ( ! isset($defaults['conditions']) ) { |
|
540 | + if ( ! isset( $defaults['conditions'] ) ) { |
|
541 | 541 | $defaults['conditions'] = array( |
542 | 542 | 'send_stop' => '', |
543 | 543 | 'any_all' => '', |
@@ -557,18 +557,18 @@ discard block |
||
557 | 557 | * Migrate settings from form->options into new action. |
558 | 558 | */ |
559 | 559 | public function migrate_to_2( $form, $update = 'update' ) { |
560 | - $action = $this->prepare_new($form->id); |
|
561 | - $form->options = maybe_unserialize($form->options); |
|
560 | + $action = $this->prepare_new( $form->id ); |
|
561 | + $form->options = maybe_unserialize( $form->options ); |
|
562 | 562 | |
563 | 563 | // fill with existing options |
564 | 564 | foreach ( $action->post_content as $name => $val ) { |
565 | - if ( isset( $form->options[ $name ] ) ) { |
|
566 | - $action->post_content[ $name ] = $form->options[ $name ]; |
|
567 | - unset( $form->options[ $name ] ); |
|
565 | + if ( isset( $form->options[$name] ) ) { |
|
566 | + $action->post_content[$name] = $form->options[$name]; |
|
567 | + unset( $form->options[$name] ); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | - $action = $this->migrate_values($action, $form); |
|
571 | + $action = $this->migrate_values( $action, $form ); |
|
572 | 572 | |
573 | 573 | // check if action already exists |
574 | 574 | $post_id = get_posts( array( |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | 'numberposts' => 1, |
579 | 579 | ) ); |
580 | 580 | |
581 | - if ( empty($post_id) ) { |
|
581 | + if ( empty( $post_id ) ) { |
|
582 | 582 | // create action now |
583 | - $post_id = $this->save_settings($action); |
|
583 | + $post_id = $this->save_settings( $action ); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | if ( $post_id && 'update' == $update ) { |
587 | 587 | global $wpdb; |
588 | - $form->options = maybe_serialize($form->options); |
|
588 | + $form->options = maybe_serialize( $form->options ); |
|
589 | 589 | |
590 | 590 | // update form options |
591 | 591 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) ); |
592 | - wp_cache_delete( $form->id, 'frm_form'); |
|
592 | + wp_cache_delete( $form->id, 'frm_form' ); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | return $post_id; |
@@ -617,18 +617,18 @@ discard block |
||
617 | 617 | |
618 | 618 | $observed_value = self::get_value_from_entry( $entry, $condition['hide_field'] ); |
619 | 619 | |
620 | - $stop = FrmFieldsHelper::value_meets_condition($observed_value, $condition['hide_field_cond'], $condition['hide_opt']); |
|
620 | + $stop = FrmFieldsHelper::value_meets_condition( $observed_value, $condition['hide_field_cond'], $condition['hide_opt'] ); |
|
621 | 621 | |
622 | 622 | if ( $notification['conditions']['send_stop'] == 'send' ) { |
623 | 623 | $stop = $stop ? false : true; |
624 | 624 | } |
625 | 625 | |
626 | - $met[ $stop ] = $stop; |
|
626 | + $met[$stop] = $stop; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | if ( $notification['conditions']['any_all'] == 'all' && ! empty( $met ) && isset( $met[0] ) && isset( $met[1] ) ) { |
630 | - $stop = ($notification['conditions']['send_stop'] == 'send'); |
|
631 | - } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset($met[0]) ) { |
|
630 | + $stop = ( $notification['conditions']['send_stop'] == 'send' ); |
|
631 | + } else if ( $notification['conditions']['any_all'] == 'any' && $notification['conditions']['send_stop'] == 'send' && isset( $met[0] ) ) { |
|
632 | 632 | $stop = false; |
633 | 633 | } |
634 | 634 | |
@@ -665,8 +665,8 @@ discard block |
||
665 | 665 | private static function get_value_from_entry( $entry, $field_id ) { |
666 | 666 | $observed_value = ''; |
667 | 667 | |
668 | - if ( isset( $entry->metas[ $field_id ] ) ) { |
|
669 | - $observed_value = $entry->metas[ $field_id ]; |
|
668 | + if ( isset( $entry->metas[$field_id] ) ) { |
|
669 | + $observed_value = $entry->metas[$field_id]; |
|
670 | 670 | } else if ( $entry->post_id && FrmAppHelper::pro_is_installed() ) { |
671 | 671 | $field = FrmField::getOne( $field_id ); |
672 | 672 | $observed_value = FrmProEntryMetaHelper::get_post_or_meta_value( $entry, $field, array( 'links' => false, 'truncate' => false ) ); |
@@ -1,251 +1,251 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('ABSPATH') ) { |
3 | - die('You are not allowed to call this page directly.'); |
|
3 | + die('You are not allowed to call this page directly.'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
7 | 7 | |
8 | - /** |
|
9 | - * @return int|boolean id on success or false on failure |
|
10 | - */ |
|
11 | - public static function create( $values ) { |
|
12 | - global $wpdb; |
|
8 | + /** |
|
9 | + * @return int|boolean id on success or false on failure |
|
10 | + */ |
|
11 | + public static function create( $values ) { |
|
12 | + global $wpdb; |
|
13 | 13 | |
14 | - $new_values = array( |
|
14 | + $new_values = array( |
|
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | - 'name' => $values['name'], |
|
17 | - 'description' => $values['description'], |
|
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
16 | + 'name' => $values['name'], |
|
17 | + 'description' => $values['description'], |
|
18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | - ); |
|
22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | + ); |
|
26 | 26 | |
27 | - $options = array(); |
|
27 | + $options = array(); |
|
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | + $new_values['options'] = serialize($options); |
|
36 | 36 | |
37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | - // $new_values['id'] = $values['id']; |
|
37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | + // $new_values['id'] = $values['id']; |
|
39 | 39 | |
40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
41 | 41 | |
42 | - $id = $wpdb->insert_id; |
|
42 | + $id = $wpdb->insert_id; |
|
43 | 43 | |
44 | 44 | // Clear form caching |
45 | 45 | self::clear_form_cache(); |
46 | 46 | |
47 | - return $id; |
|
48 | - } |
|
47 | + return $id; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return int|boolean ID on success or false on failure |
|
52 | - */ |
|
53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | - global $wpdb; |
|
50 | + /** |
|
51 | + * @return int|boolean ID on success or false on failure |
|
52 | + */ |
|
53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | + global $wpdb; |
|
55 | 55 | |
56 | - $values = self::getOne( $id, $blog_id ); |
|
57 | - if ( ! $values ) { |
|
58 | - return false; |
|
59 | - } |
|
56 | + $values = self::getOne( $id, $blog_id ); |
|
57 | + if ( ! $values ) { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
62 | 62 | |
63 | - $new_values = array( |
|
63 | + $new_values = array( |
|
64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
65 | - 'name' => $values->name, |
|
66 | - 'description' => $values->description, |
|
67 | - 'status' => $template ? 'published' : 'draft', |
|
68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
70 | - 'created_at' => current_time('mysql', 1), |
|
71 | - 'is_template' => $template ? 1 : 0, |
|
72 | - ); |
|
73 | - |
|
74 | - if ( $blog_id ) { |
|
75 | - $new_values['status'] = 'published'; |
|
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
78 | - $new_options['copy'] = false; |
|
79 | - $new_values['options'] = $new_options; |
|
80 | - } else { |
|
81 | - $new_values['options'] = $values->options; |
|
82 | - } |
|
83 | - |
|
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
86 | - } |
|
65 | + 'name' => $values->name, |
|
66 | + 'description' => $values->description, |
|
67 | + 'status' => $template ? 'published' : 'draft', |
|
68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
70 | + 'created_at' => current_time('mysql', 1), |
|
71 | + 'is_template' => $template ? 1 : 0, |
|
72 | + ); |
|
73 | + |
|
74 | + if ( $blog_id ) { |
|
75 | + $new_values['status'] = 'published'; |
|
76 | + $new_options = maybe_unserialize($values->options); |
|
77 | + $new_options['email_to'] = get_option('admin_email'); |
|
78 | + $new_options['copy'] = false; |
|
79 | + $new_values['options'] = $new_options; |
|
80 | + } else { |
|
81 | + $new_values['options'] = $values->options; |
|
82 | + } |
|
83 | + |
|
84 | + if ( is_array($new_values['options']) ) { |
|
85 | + $new_values['options'] = serialize($new_values['options']); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
89 | 89 | |
90 | - if ( $query_results ) { |
|
90 | + if ( $query_results ) { |
|
91 | 91 | // Clear form caching |
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | - $form_id = $wpdb->insert_id; |
|
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
94 | + $form_id = $wpdb->insert_id; |
|
95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
96 | 96 | |
97 | - // update form settings after fields are created |
|
97 | + // update form settings after fields are created |
|
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
99 | - return $form_id; |
|
100 | - } |
|
99 | + return $form_id; |
|
100 | + } |
|
101 | 101 | |
102 | - return false; |
|
103 | - } |
|
102 | + return false; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
106 | + $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
107 | 107 | |
108 | - if ( isset($new_opts['success_msg']) ) { |
|
109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
110 | - } |
|
108 | + if ( isset($new_opts['success_msg']) ) { |
|
109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
110 | + } |
|
111 | 111 | |
112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
112 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
113 | 113 | |
114 | - if ( $new_opts != $values['options'] ) { |
|
115 | - global $wpdb; |
|
114 | + if ( $new_opts != $values['options'] ) { |
|
115 | + global $wpdb; |
|
116 | 116 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
117 | - } |
|
118 | - } |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @return int|boolean |
|
122 | - */ |
|
123 | - public static function update( $id, $values, $create_link = false ) { |
|
124 | - global $wpdb; |
|
120 | + /** |
|
121 | + * @return int|boolean |
|
122 | + */ |
|
123 | + public static function update( $id, $values, $create_link = false ) { |
|
124 | + global $wpdb; |
|
125 | 125 | |
126 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
127 | - $values['status'] = 'published'; |
|
128 | - } |
|
126 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
127 | + $values['status'] = 'published'; |
|
128 | + } |
|
129 | 129 | |
130 | - if ( isset($values['form_key']) ) { |
|
130 | + if ( isset($values['form_key']) ) { |
|
131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | - $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
134 | + $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
|
135 | 135 | |
136 | - $new_values = self::set_update_options( array(), $values); |
|
136 | + $new_values = self::set_update_options( array(), $values); |
|
137 | 137 | |
138 | - foreach ( $values as $value_key => $value ) { |
|
139 | - if ( in_array($value_key, $form_fields) ) { |
|
138 | + foreach ( $values as $value_key => $value ) { |
|
139 | + if ( in_array($value_key, $form_fields) ) { |
|
140 | 140 | $new_values[ $value_key ] = $value; |
141 | - } |
|
142 | - } |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
145 | - $new_values['status'] = $values['new_status']; |
|
146 | - } |
|
144 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
145 | + $new_values['status'] = $values['new_status']; |
|
146 | + } |
|
147 | 147 | |
148 | - if ( ! empty( $new_values ) ) { |
|
148 | + if ( ! empty( $new_values ) ) { |
|
149 | 149 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
150 | - if ( $query_results ) { |
|
150 | + if ( $query_results ) { |
|
151 | 151 | self::clear_form_cache(); |
152 | - } |
|
153 | - } else { |
|
154 | - $query_results = true; |
|
155 | - } |
|
156 | - unset($new_values); |
|
152 | + } |
|
153 | + } else { |
|
154 | + $query_results = true; |
|
155 | + } |
|
156 | + unset($new_values); |
|
157 | 157 | |
158 | - $values = self::update_fields($id, $values); |
|
158 | + $values = self::update_fields($id, $values); |
|
159 | 159 | |
160 | 160 | do_action( 'frm_update_form', $id, $values ); |
161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
162 | 162 | |
163 | - return $query_results; |
|
164 | - } |
|
163 | + return $query_results; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * @return array |
|
168 | - */ |
|
166 | + /** |
|
167 | + * @return array |
|
168 | + */ |
|
169 | 169 | public static function set_update_options( $new_values, $values ) { |
170 | - if ( ! isset($values['options']) ) { |
|
171 | - return $new_values; |
|
172 | - } |
|
170 | + if ( ! isset($values['options']) ) { |
|
171 | + return $new_values; |
|
172 | + } |
|
173 | 173 | |
174 | - $options = array(); |
|
174 | + $options = array(); |
|
175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
176 | 176 | |
177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
177 | + $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | + $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
181 | 181 | |
182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | - $new_values['options'] = serialize($options); |
|
182 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | + $new_values['options'] = serialize($options); |
|
184 | 184 | |
185 | - return $new_values; |
|
186 | - } |
|
185 | + return $new_values; |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | - /** |
|
190 | - * @return array |
|
191 | - */ |
|
189 | + /** |
|
190 | + * @return array |
|
191 | + */ |
|
192 | 192 | public static function update_fields( $id, $values ) { |
193 | 193 | |
194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
195 | - return $values; |
|
196 | - } |
|
194 | + if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
195 | + return $values; |
|
196 | + } |
|
197 | 197 | |
198 | - $all_fields = FrmField::get_all_for_form($id); |
|
199 | - if ( empty($all_fields) ) { |
|
200 | - return $values; |
|
201 | - } |
|
198 | + $all_fields = FrmField::get_all_for_form($id); |
|
199 | + if ( empty($all_fields) ) { |
|
200 | + return $values; |
|
201 | + } |
|
202 | 202 | |
203 | - if ( ! isset($values['item_meta']) ) { |
|
204 | - $values['item_meta'] = array(); |
|
205 | - } |
|
203 | + if ( ! isset($values['item_meta']) ) { |
|
204 | + $values['item_meta'] = array(); |
|
205 | + } |
|
206 | 206 | |
207 | - $field_array = array(); |
|
208 | - $existing_keys = array_keys($values['item_meta']); |
|
209 | - foreach ( $all_fields as $fid ) { |
|
210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
207 | + $field_array = array(); |
|
208 | + $existing_keys = array_keys($values['item_meta']); |
|
209 | + foreach ( $all_fields as $fid ) { |
|
210 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
211 | 211 | $values['item_meta'][ $fid->id ] = ''; |
212 | - } |
|
212 | + } |
|
213 | 213 | $field_array[ $fid->id ] = $fid; |
214 | - } |
|
215 | - unset($all_fields); |
|
214 | + } |
|
215 | + unset($all_fields); |
|
216 | 216 | |
217 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
217 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
218 | 218 | if ( isset( $field_array[ $field_id ] ) ) { |
219 | 219 | $field = $field_array[ $field_id ]; |
220 | - } else { |
|
221 | - $field = FrmField::getOne($field_id); |
|
222 | - } |
|
220 | + } else { |
|
221 | + $field = FrmField::getOne($field_id); |
|
222 | + } |
|
223 | 223 | |
224 | - if ( ! $field ) { |
|
225 | - continue; |
|
226 | - } |
|
224 | + if ( ! $field ) { |
|
225 | + continue; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
229 | - //updating the settings page |
|
229 | + //updating the settings page |
|
230 | 230 | if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
231 | 231 | $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
232 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
232 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
233 | 233 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
234 | - } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
235 | - $prev_opts = $field->field_options; |
|
236 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
237 | - if ( $prev_opts != $field->field_options ) { |
|
234 | + } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
235 | + $prev_opts = $field->field_options; |
|
236 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
237 | + if ( $prev_opts != $field->field_options ) { |
|
238 | 238 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
239 | - } |
|
240 | - unset($prev_opts); |
|
241 | - } |
|
242 | - } |
|
239 | + } |
|
240 | + unset($prev_opts); |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | 244 | if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
245 | - continue; |
|
246 | - } |
|
245 | + continue; |
|
246 | + } |
|
247 | 247 | |
248 | - //updating the form |
|
248 | + //updating the form |
|
249 | 249 | $update_options = array( |
250 | 250 | 'size', 'max', 'label', 'invalid', 'blank', |
251 | 251 | 'classes', 'captcha_size', 'default_blank', |
@@ -254,129 +254,129 @@ discard block |
||
254 | 254 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
255 | 255 | foreach ( $update_options as $opt ) { |
256 | 256 | $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( $values['field_options'][ $opt . '_' . $field_id ] ) : ''; |
257 | - } |
|
257 | + } |
|
258 | 258 | |
259 | 259 | $field->field_options['required_indicator'] = isset( $values['field_options'][ 'required_indicator_' . $field_id ] ) ? trim( $values['field_options'][ 'required_indicator_' . $field_id ] ) : '*'; |
260 | 260 | $field->field_options['separate_value'] = isset( $values['field_options'][ 'separate_value_' . $field_id ] ) ? trim( $values['field_options'][ 'separate_value_' . $field_id ] ) : 0; |
261 | 261 | |
262 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
262 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
263 | 263 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
264 | 264 | $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
265 | 265 | $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
266 | 266 | $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
267 | 267 | $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
268 | 268 | |
269 | - FrmField::update($field_id, array( |
|
270 | - 'field_key' => $field_key, 'type' => $field_type, |
|
271 | - 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
272 | - 'description' => $field_description, 'required' => $required, |
|
273 | - ) ); |
|
269 | + FrmField::update($field_id, array( |
|
270 | + 'field_key' => $field_key, 'type' => $field_type, |
|
271 | + 'default_value' => $default_value, 'field_options' => $field->field_options, |
|
272 | + 'description' => $field_description, 'required' => $required, |
|
273 | + ) ); |
|
274 | 274 | |
275 | - FrmField::delete_form_transient($field->form_id); |
|
276 | - } |
|
275 | + FrmField::delete_form_transient($field->form_id); |
|
276 | + } |
|
277 | 277 | |
278 | - return $values; |
|
279 | - } |
|
278 | + return $values; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * @param string $status |
|
283 | - * @return int|boolean |
|
284 | - */ |
|
281 | + /** |
|
282 | + * @param string $status |
|
283 | + * @return int|boolean |
|
284 | + */ |
|
285 | 285 | public static function set_status( $id, $status ) { |
286 | - if ( 'trash' == $status ) { |
|
287 | - return self::trash($id); |
|
288 | - } |
|
286 | + if ( 'trash' == $status ) { |
|
287 | + return self::trash($id); |
|
288 | + } |
|
289 | 289 | |
290 | 290 | $statuses = array( 'published', 'draft', 'trash' ); |
291 | - if ( ! in_array( $status, $statuses ) ) { |
|
292 | - return false; |
|
293 | - } |
|
291 | + if ( ! in_array( $status, $statuses ) ) { |
|
292 | + return false; |
|
293 | + } |
|
294 | 294 | |
295 | - global $wpdb; |
|
295 | + global $wpdb; |
|
296 | 296 | |
297 | - if ( is_array($id) ) { |
|
297 | + if ( is_array($id) ) { |
|
298 | 298 | $where = array( 'id' => $id ); |
299 | 299 | FrmDb::get_where_clause_and_values( $where ); |
300 | 300 | array_unshift( $where['values'], $status ); |
301 | 301 | |
302 | 302 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
303 | - } else { |
|
303 | + } else { |
|
304 | 304 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
305 | - } |
|
305 | + } |
|
306 | 306 | |
307 | - if ( $query_results ) { |
|
307 | + if ( $query_results ) { |
|
308 | 308 | self::clear_form_cache(); |
309 | - } |
|
309 | + } |
|
310 | 310 | |
311 | - return $query_results; |
|
312 | - } |
|
311 | + return $query_results; |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @return int|boolean |
|
316 | - */ |
|
314 | + /** |
|
315 | + * @return int|boolean |
|
316 | + */ |
|
317 | 317 | public static function trash( $id ) { |
318 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
319 | - return self::destroy( $id ); |
|
320 | - } |
|
318 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
319 | + return self::destroy( $id ); |
|
320 | + } |
|
321 | 321 | |
322 | - $form = self::getOne($id); |
|
323 | - if ( ! $form ) { |
|
324 | - return false; |
|
325 | - } |
|
322 | + $form = self::getOne($id); |
|
323 | + if ( ! $form ) { |
|
324 | + return false; |
|
325 | + } |
|
326 | 326 | |
327 | - $options = $form->options; |
|
328 | - $options['trash_time'] = time(); |
|
327 | + $options = $form->options; |
|
328 | + $options['trash_time'] = time(); |
|
329 | 329 | |
330 | - global $wpdb; |
|
331 | - $query_results = $wpdb->update( |
|
330 | + global $wpdb; |
|
331 | + $query_results = $wpdb->update( |
|
332 | 332 | $wpdb->prefix . 'frm_forms', |
333 | 333 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
334 | 334 | array( 'id' => $id ) |
335 | - ); |
|
335 | + ); |
|
336 | 336 | |
337 | - if ( $query_results ) { |
|
337 | + if ( $query_results ) { |
|
338 | 338 | self::clear_form_cache(); |
339 | - } |
|
339 | + } |
|
340 | 340 | |
341 | - return $query_results; |
|
342 | - } |
|
341 | + return $query_results; |
|
342 | + } |
|
343 | 343 | |
344 | - /** |
|
345 | - * @return int|boolean |
|
346 | - */ |
|
344 | + /** |
|
345 | + * @return int|boolean |
|
346 | + */ |
|
347 | 347 | public static function destroy( $id ) { |
348 | - global $wpdb; |
|
348 | + global $wpdb; |
|
349 | 349 | |
350 | - $form = self::getOne($id); |
|
351 | - if ( ! $form ) { |
|
352 | - return false; |
|
353 | - } |
|
350 | + $form = self::getOne($id); |
|
351 | + if ( ! $form ) { |
|
352 | + return false; |
|
353 | + } |
|
354 | 354 | |
355 | - // Disconnect the entries from this form |
|
355 | + // Disconnect the entries from this form |
|
356 | 356 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
357 | - foreach ( $entries as $entry_id ) { |
|
358 | - FrmEntry::destroy($entry_id); |
|
359 | - unset($entry_id); |
|
360 | - } |
|
357 | + foreach ( $entries as $entry_id ) { |
|
358 | + FrmEntry::destroy($entry_id); |
|
359 | + unset($entry_id); |
|
360 | + } |
|
361 | 361 | |
362 | - // Disconnect the fields from this form |
|
362 | + // Disconnect the fields from this form |
|
363 | 363 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
364 | 364 | |
365 | 365 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
366 | - if ( $query_results ) { |
|
367 | - // Delete all form actions linked to this form |
|
368 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
369 | - $action_control->destroy($id, 'all'); |
|
366 | + if ( $query_results ) { |
|
367 | + // Delete all form actions linked to this form |
|
368 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
369 | + $action_control->destroy($id, 'all'); |
|
370 | 370 | |
371 | 371 | // Clear form caching |
372 | 372 | self::clear_form_cache(); |
373 | 373 | |
374 | 374 | do_action( 'frm_destroy_form', $id ); |
375 | 375 | do_action( 'frm_destroy_form_' . $id ); |
376 | - } |
|
376 | + } |
|
377 | 377 | |
378 | - return $query_results; |
|
379 | - } |
|
378 | + return $query_results; |
|
379 | + } |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * Delete trashed forms based on how long they have been trashed |
@@ -408,49 +408,49 @@ discard block |
||
408 | 408 | return $count; |
409 | 409 | } |
410 | 410 | |
411 | - /** |
|
412 | - * @return string form name |
|
413 | - */ |
|
414 | - public static function &getName( $id ) { |
|
415 | - global $wpdb; |
|
416 | - |
|
417 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
418 | - if ( $form ) { |
|
419 | - $r = stripslashes($form->name); |
|
420 | - return $r; |
|
421 | - } |
|
422 | - |
|
423 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
424 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
425 | - $r = stripslashes($r); |
|
426 | - |
|
427 | - return $r; |
|
428 | - } |
|
429 | - |
|
430 | - /** |
|
431 | - * @param string $key |
|
432 | - * @return int form id |
|
433 | - */ |
|
411 | + /** |
|
412 | + * @return string form name |
|
413 | + */ |
|
414 | + public static function &getName( $id ) { |
|
415 | + global $wpdb; |
|
416 | + |
|
417 | + $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
418 | + if ( $form ) { |
|
419 | + $r = stripslashes($form->name); |
|
420 | + return $r; |
|
421 | + } |
|
422 | + |
|
423 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
424 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
425 | + $r = stripslashes($r); |
|
426 | + |
|
427 | + return $r; |
|
428 | + } |
|
429 | + |
|
430 | + /** |
|
431 | + * @param string $key |
|
432 | + * @return int form id |
|
433 | + */ |
|
434 | 434 | public static function &getIdByKey( $key ) { |
435 | - $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
436 | - return $id; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * @param int $id |
|
441 | - * @return string form key |
|
442 | - */ |
|
435 | + $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
436 | + return $id; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * @param int $id |
|
441 | + * @return string form key |
|
442 | + */ |
|
443 | 443 | public static function &getKeyById( $id ) { |
444 | - $id = (int) $id; |
|
445 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
446 | - if ( $cache ) { |
|
447 | - return $cache->form_key; |
|
448 | - } |
|
444 | + $id = (int) $id; |
|
445 | + $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
446 | + if ( $cache ) { |
|
447 | + return $cache->form_key; |
|
448 | + } |
|
449 | 449 | |
450 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
450 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
451 | 451 | |
452 | - return $key; |
|
453 | - } |
|
452 | + return $key; |
|
453 | + } |
|
454 | 454 | |
455 | 455 | /** |
456 | 456 | * If $form is numeric, get the form object |
@@ -463,47 +463,47 @@ discard block |
||
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | - /** |
|
467 | - * @return object form |
|
468 | - */ |
|
469 | - public static function getOne( $id, $blog_id = false ) { |
|
470 | - global $wpdb; |
|
466 | + /** |
|
467 | + * @return object form |
|
468 | + */ |
|
469 | + public static function getOne( $id, $blog_id = false ) { |
|
470 | + global $wpdb; |
|
471 | 471 | |
472 | - if ( $blog_id && is_multisite() ) { |
|
473 | - global $wpmuBaseTablePrefix; |
|
472 | + if ( $blog_id && is_multisite() ) { |
|
473 | + global $wpmuBaseTablePrefix; |
|
474 | 474 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
475 | 475 | |
476 | 476 | $table_name = $prefix . 'frm_forms'; |
477 | - } else { |
|
477 | + } else { |
|
478 | 478 | $table_name = $wpdb->prefix . 'frm_forms'; |
479 | - $cache = wp_cache_get($id, 'frm_form'); |
|
480 | - if ( $cache ) { |
|
481 | - if ( isset($cache->options) ) { |
|
482 | - $cache->options = maybe_unserialize($cache->options); |
|
483 | - } |
|
484 | - |
|
485 | - return stripslashes_deep($cache); |
|
486 | - } |
|
487 | - } |
|
488 | - |
|
489 | - if ( is_numeric($id) ) { |
|
490 | - $where = array( 'id' => $id ); |
|
491 | - } else { |
|
492 | - $where = array( 'form_key' => $id ); |
|
493 | - } |
|
494 | - |
|
495 | - $results = FrmDb::get_row( $table_name, $where ); |
|
496 | - |
|
497 | - if ( isset($results->options) ) { |
|
498 | - wp_cache_set($results->id, $results, 'frm_form'); |
|
499 | - $results->options = maybe_unserialize($results->options); |
|
500 | - } |
|
501 | - return stripslashes_deep($results); |
|
502 | - } |
|
503 | - |
|
504 | - /** |
|
505 | - * @return object|array of objects |
|
506 | - */ |
|
479 | + $cache = wp_cache_get($id, 'frm_form'); |
|
480 | + if ( $cache ) { |
|
481 | + if ( isset($cache->options) ) { |
|
482 | + $cache->options = maybe_unserialize($cache->options); |
|
483 | + } |
|
484 | + |
|
485 | + return stripslashes_deep($cache); |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + if ( is_numeric($id) ) { |
|
490 | + $where = array( 'id' => $id ); |
|
491 | + } else { |
|
492 | + $where = array( 'form_key' => $id ); |
|
493 | + } |
|
494 | + |
|
495 | + $results = FrmDb::get_row( $table_name, $where ); |
|
496 | + |
|
497 | + if ( isset($results->options) ) { |
|
498 | + wp_cache_set($results->id, $results, 'frm_form'); |
|
499 | + $results->options = maybe_unserialize($results->options); |
|
500 | + } |
|
501 | + return stripslashes_deep($results); |
|
502 | + } |
|
503 | + |
|
504 | + /** |
|
505 | + * @return object|array of objects |
|
506 | + */ |
|
507 | 507 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
508 | 508 | if ( is_array( $where ) && ! empty( $where ) ) { |
509 | 509 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) ); |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | $results = reset( $results ); |
528 | 528 | } |
529 | 529 | |
530 | - return stripslashes_deep($results); |
|
531 | - } |
|
530 | + return stripslashes_deep($results); |
|
531 | + } |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Get all published forms |
@@ -546,47 +546,47 @@ discard block |
||
546 | 546 | return $forms; |
547 | 547 | } |
548 | 548 | |
549 | - /** |
|
550 | - * @return int count of forms |
|
551 | - */ |
|
552 | - public static function &get_count() { |
|
553 | - global $wpdb; |
|
549 | + /** |
|
550 | + * @return int count of forms |
|
551 | + */ |
|
552 | + public static function &get_count() { |
|
553 | + global $wpdb; |
|
554 | 554 | |
555 | - $cache_key = 'frm_form_counts'; |
|
555 | + $cache_key = 'frm_form_counts'; |
|
556 | 556 | |
557 | - $counts = wp_cache_get( $cache_key, 'counts' ); |
|
558 | - if ( false !== $counts ) { |
|
559 | - return $counts; |
|
560 | - } |
|
557 | + $counts = wp_cache_get( $cache_key, 'counts' ); |
|
558 | + if ( false !== $counts ) { |
|
559 | + return $counts; |
|
560 | + } |
|
561 | 561 | |
562 | - $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
562 | + $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
563 | 563 | |
564 | 564 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
565 | - $counts = array_fill_keys( $statuses, 0 ); |
|
565 | + $counts = array_fill_keys( $statuses, 0 ); |
|
566 | 566 | |
567 | - foreach ( $results as $row ) { |
|
568 | - if ( 'trash' != $row->status ) { |
|
569 | - if ( $row->is_template ) { |
|
567 | + foreach ( $results as $row ) { |
|
568 | + if ( 'trash' != $row->status ) { |
|
569 | + if ( $row->is_template ) { |
|
570 | 570 | $counts['template']++; |
571 | - } else { |
|
571 | + } else { |
|
572 | 572 | $counts['published']++; |
573 | - } |
|
574 | - } else { |
|
573 | + } |
|
574 | + } else { |
|
575 | 575 | $counts['trash']++; |
576 | - } |
|
576 | + } |
|
577 | 577 | |
578 | - if ( 'draft' == $row->status ) { |
|
578 | + if ( 'draft' == $row->status ) { |
|
579 | 579 | $counts['draft']++; |
580 | - } |
|
580 | + } |
|
581 | 581 | |
582 | - unset($row); |
|
583 | - } |
|
582 | + unset($row); |
|
583 | + } |
|
584 | 584 | |
585 | - $counts = (object) $counts; |
|
586 | - wp_cache_set( $cache_key, $counts, 'counts' ); |
|
585 | + $counts = (object) $counts; |
|
586 | + wp_cache_set( $cache_key, $counts, 'counts' ); |
|
587 | 587 | |
588 | - return $counts; |
|
589 | - } |
|
588 | + return $counts; |
|
589 | + } |
|
590 | 590 | |
591 | 591 | /** |
592 | 592 | * Clear form caching |
@@ -599,14 +599,14 @@ discard block |
||
599 | 599 | FrmAppHelper::cache_delete_group( 'frm_form' ); |
600 | 600 | } |
601 | 601 | |
602 | - /** |
|
603 | - * @return array of errors |
|
604 | - */ |
|
602 | + /** |
|
603 | + * @return array of errors |
|
604 | + */ |
|
605 | 605 | public static function validate( $values ) { |
606 | - $errors = array(); |
|
606 | + $errors = array(); |
|
607 | 607 | |
608 | - return apply_filters('frm_validate_form', $errors, $values); |
|
609 | - } |
|
608 | + return apply_filters('frm_validate_form', $errors, $values); |
|
609 | + } |
|
610 | 610 | |
611 | 611 | public static function get_params( $form = null ) { |
612 | 612 | global $frm_vars; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
3 | - die('You are not allowed to call this page directly.'); |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + die( 'You are not allowed to call this page directly.' ); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | 16 | 'name' => $values['name'], |
17 | 17 | 'description' => $values['description'], |
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | $options = array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
35 | + $new_values['options'] = serialize( $options ); |
|
36 | 36 | |
37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
38 | 38 | // $new_values['id'] = $values['id']; |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | 'status' => $template ? 'published' : 'draft', |
68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
70 | - 'created_at' => current_time('mysql', 1), |
|
70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
71 | 71 | 'is_template' => $template ? 1 : 0, |
72 | 72 | ); |
73 | 73 | |
74 | 74 | if ( $blog_id ) { |
75 | 75 | $new_values['status'] = 'published'; |
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
76 | + $new_options = maybe_unserialize( $values->options ); |
|
77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
78 | 78 | $new_options['copy'] = false; |
79 | 79 | $new_values['options'] = $new_options; |
80 | 80 | } else { |
81 | 81 | $new_values['options'] = $values->options; |
82 | 82 | } |
83 | 83 | |
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
84 | + if ( is_array( $new_values['options'] ) ) { |
|
85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | 94 | $form_id = $wpdb->insert_id; |
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
96 | 96 | |
97 | 97 | // update form settings after fields are created |
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
106 | + $new_opts = $values['options'] = maybe_unserialize( $values['options'] ); |
|
107 | 107 | |
108 | - if ( isset($new_opts['success_msg']) ) { |
|
109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
108 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
110 | 110 | } |
111 | 111 | |
112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
112 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
113 | 113 | |
114 | 114 | if ( $new_opts != $values['options'] ) { |
115 | 115 | global $wpdb; |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | $values['status'] = 'published'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( isset($values['form_key']) ) { |
|
130 | + if ( isset( $values['form_key'] ) ) { |
|
131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
132 | 132 | } |
133 | 133 | |
134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
135 | 135 | |
136 | - $new_values = self::set_update_options( array(), $values); |
|
136 | + $new_values = self::set_update_options( array(), $values ); |
|
137 | 137 | |
138 | 138 | foreach ( $values as $value_key => $value ) { |
139 | - if ( in_array($value_key, $form_fields) ) { |
|
140 | - $new_values[ $value_key ] = $value; |
|
139 | + if ( in_array( $value_key, $form_fields ) ) { |
|
140 | + $new_values[$value_key] = $value; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | } else { |
154 | 154 | $query_results = true; |
155 | 155 | } |
156 | - unset($new_values); |
|
156 | + unset( $new_values ); |
|
157 | 157 | |
158 | - $values = self::update_fields($id, $values); |
|
158 | + $values = self::update_fields( $id, $values ); |
|
159 | 159 | |
160 | 160 | do_action( 'frm_update_form', $id, $values ); |
161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | * @return array |
168 | 168 | */ |
169 | 169 | public static function set_update_options( $new_values, $values ) { |
170 | - if ( ! isset($values['options']) ) { |
|
170 | + if ( ! isset( $values['options'] ) ) { |
|
171 | 171 | return $new_values; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $options = array(); |
175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
176 | 176 | |
177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
177 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
178 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
179 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
180 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
181 | 181 | |
182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | - $new_values['options'] = serialize($options); |
|
182 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
183 | + $new_values['options'] = serialize( $options ); |
|
184 | 184 | |
185 | 185 | return $new_values; |
186 | 186 | } |
@@ -191,57 +191,57 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function update_fields( $id, $values ) { |
193 | 193 | |
194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
194 | + if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
195 | 195 | return $values; |
196 | 196 | } |
197 | 197 | |
198 | - $all_fields = FrmField::get_all_for_form($id); |
|
199 | - if ( empty($all_fields) ) { |
|
198 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
199 | + if ( empty( $all_fields ) ) { |
|
200 | 200 | return $values; |
201 | 201 | } |
202 | 202 | |
203 | - if ( ! isset($values['item_meta']) ) { |
|
203 | + if ( ! isset( $values['item_meta'] ) ) { |
|
204 | 204 | $values['item_meta'] = array(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | $field_array = array(); |
208 | - $existing_keys = array_keys($values['item_meta']); |
|
208 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
209 | 209 | foreach ( $all_fields as $fid ) { |
210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
211 | - $values['item_meta'][ $fid->id ] = ''; |
|
210 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
211 | + $values['item_meta'][$fid->id] = ''; |
|
212 | 212 | } |
213 | - $field_array[ $fid->id ] = $fid; |
|
213 | + $field_array[$fid->id] = $fid; |
|
214 | 214 | } |
215 | - unset($all_fields); |
|
215 | + unset( $all_fields ); |
|
216 | 216 | |
217 | 217 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
218 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
219 | - $field = $field_array[ $field_id ]; |
|
218 | + if ( isset( $field_array[$field_id] ) ) { |
|
219 | + $field = $field_array[$field_id]; |
|
220 | 220 | } else { |
221 | - $field = FrmField::getOne($field_id); |
|
221 | + $field = FrmField::getOne( $field_id ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if ( ! $field ) { |
225 | 225 | continue; |
226 | 226 | } |
227 | 227 | |
228 | - if ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
228 | + if ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
229 | 229 | //updating the settings page |
230 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
231 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
232 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
230 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
231 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
232 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
233 | 233 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
234 | 234 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
235 | 235 | $prev_opts = $field->field_options; |
236 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
236 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
237 | 237 | if ( $prev_opts != $field->field_options ) { |
238 | 238 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
239 | 239 | } |
240 | - unset($prev_opts); |
|
240 | + unset( $prev_opts ); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - if ( ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
|
244 | + if ( ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ) && ! defined( 'WP_IMPORTING' ) ) { |
|
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
@@ -251,23 +251,23 @@ discard block |
||
251 | 251 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
252 | 252 | |
253 | 253 | foreach ( $update_options as $opt => $default ) { |
254 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
254 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
255 | 255 | } |
256 | 256 | |
257 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
258 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
259 | - $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
|
260 | - $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
|
261 | - $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
|
262 | - $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
|
257 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
258 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
259 | + $field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key; |
|
260 | + $required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false; |
|
261 | + $field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type; |
|
262 | + $field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description; |
|
263 | 263 | |
264 | - FrmField::update($field_id, array( |
|
264 | + FrmField::update( $field_id, array( |
|
265 | 265 | 'field_key' => $field_key, 'type' => $field_type, |
266 | 266 | 'default_value' => $default_value, 'field_options' => $field->field_options, |
267 | 267 | 'description' => $field_description, 'required' => $required, |
268 | 268 | ) ); |
269 | 269 | |
270 | - FrmField::delete_form_transient($field->form_id); |
|
270 | + FrmField::delete_form_transient( $field->form_id ); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | return $values; |
@@ -279,17 +279,17 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public static function set_status( $id, $status ) { |
281 | 281 | if ( 'trash' == $status ) { |
282 | - return self::trash($id); |
|
282 | + return self::trash( $id ); |
|
283 | 283 | } |
284 | 284 | |
285 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
285 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
286 | 286 | if ( ! in_array( $status, $statuses ) ) { |
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | 290 | global $wpdb; |
291 | 291 | |
292 | - if ( is_array($id) ) { |
|
292 | + if ( is_array( $id ) ) { |
|
293 | 293 | $where = array( 'id' => $id ); |
294 | 294 | FrmDb::get_where_clause_and_values( $where ); |
295 | 295 | array_unshift( $where['values'], $status ); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | return self::destroy( $id ); |
315 | 315 | } |
316 | 316 | |
317 | - $form = self::getOne($id); |
|
317 | + $form = self::getOne( $id ); |
|
318 | 318 | if ( ! $form ) { |
319 | 319 | return false; |
320 | 320 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | public static function destroy( $id ) { |
343 | 343 | global $wpdb; |
344 | 344 | |
345 | - $form = self::getOne($id); |
|
345 | + $form = self::getOne( $id ); |
|
346 | 346 | if ( ! $form ) { |
347 | 347 | return false; |
348 | 348 | } |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | // Disconnect the entries from this form |
351 | 351 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
352 | 352 | foreach ( $entries as $entry_id ) { |
353 | - FrmEntry::destroy($entry_id); |
|
354 | - unset($entry_id); |
|
353 | + FrmEntry::destroy( $entry_id ); |
|
354 | + unset( $entry_id ); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | // Disconnect the fields from this form |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | if ( $query_results ) { |
362 | 362 | // Delete all form actions linked to this form |
363 | 363 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
364 | - $action_control->destroy($id, 'all'); |
|
364 | + $action_control->destroy( $id, 'all' ); |
|
365 | 365 | |
366 | 366 | // Clear form caching |
367 | 367 | self::clear_form_cache(); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $form->options = maybe_unserialize( $form->options ); |
396 | 396 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
397 | 397 | self::destroy( $form->id ); |
398 | - $count++; |
|
398 | + $count ++; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | unset( $form ); |
@@ -409,15 +409,15 @@ discard block |
||
409 | 409 | public static function &getName( $id ) { |
410 | 410 | global $wpdb; |
411 | 411 | |
412 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
412 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
413 | 413 | if ( $form ) { |
414 | - $r = stripslashes($form->name); |
|
414 | + $r = stripslashes( $form->name ); |
|
415 | 415 | return $r; |
416 | 416 | } |
417 | 417 | |
418 | 418 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
419 | 419 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
420 | - $r = stripslashes($r); |
|
420 | + $r = stripslashes( $r ); |
|
421 | 421 | |
422 | 422 | return $r; |
423 | 423 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | */ |
438 | 438 | public static function &getKeyById( $id ) { |
439 | 439 | $id = (int) $id; |
440 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
440 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
441 | 441 | if ( $cache ) { |
442 | 442 | return $cache->form_key; |
443 | 443 | } |
@@ -471,17 +471,17 @@ discard block |
||
471 | 471 | $table_name = $prefix . 'frm_forms'; |
472 | 472 | } else { |
473 | 473 | $table_name = $wpdb->prefix . 'frm_forms'; |
474 | - $cache = wp_cache_get($id, 'frm_form'); |
|
474 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
475 | 475 | if ( $cache ) { |
476 | - if ( isset($cache->options) ) { |
|
477 | - $cache->options = maybe_unserialize($cache->options); |
|
476 | + if ( isset( $cache->options ) ) { |
|
477 | + $cache->options = maybe_unserialize( $cache->options ); |
|
478 | 478 | } |
479 | 479 | |
480 | - return stripslashes_deep($cache); |
|
480 | + return stripslashes_deep( $cache ); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
484 | - if ( is_numeric($id) ) { |
|
484 | + if ( is_numeric( $id ) ) { |
|
485 | 485 | $where = array( 'id' => $id ); |
486 | 486 | } else { |
487 | 487 | $where = array( 'form_key' => $id ); |
@@ -489,11 +489,11 @@ discard block |
||
489 | 489 | |
490 | 490 | $results = FrmDb::get_row( $table_name, $where ); |
491 | 491 | |
492 | - if ( isset($results->options) ) { |
|
493 | - wp_cache_set($results->id, $results, 'frm_form'); |
|
494 | - $results->options = maybe_unserialize($results->options); |
|
492 | + if ( isset( $results->options ) ) { |
|
493 | + wp_cache_set( $results->id, $results, 'frm_form' ); |
|
494 | + $results->options = maybe_unserialize( $results->options ); |
|
495 | 495 | } |
496 | - return stripslashes_deep($results); |
|
496 | + return stripslashes_deep( $results ); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $results = reset( $results ); |
523 | 523 | } |
524 | 524 | |
525 | - return stripslashes_deep($results); |
|
525 | + return stripslashes_deep( $results ); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -562,19 +562,19 @@ discard block |
||
562 | 562 | foreach ( $results as $row ) { |
563 | 563 | if ( 'trash' != $row->status ) { |
564 | 564 | if ( $row->is_template ) { |
565 | - $counts['template']++; |
|
565 | + $counts['template'] ++; |
|
566 | 566 | } else { |
567 | - $counts['published']++; |
|
567 | + $counts['published'] ++; |
|
568 | 568 | } |
569 | 569 | } else { |
570 | - $counts['trash']++; |
|
570 | + $counts['trash'] ++; |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | if ( 'draft' == $row->status ) { |
574 | - $counts['draft']++; |
|
574 | + $counts['draft'] ++; |
|
575 | 575 | } |
576 | 576 | |
577 | - unset($row); |
|
577 | + unset( $row ); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | $counts = (object) $counts; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | public static function validate( $values ) { |
601 | 601 | $errors = array(); |
602 | 602 | |
603 | - return apply_filters('frm_validate_form', $errors, $values); |
|
603 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | public static function get_params( $form = null ) { |
@@ -612,11 +612,11 @@ discard block |
||
612 | 612 | self::maybe_get_form( $form ); |
613 | 613 | } |
614 | 614 | |
615 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
616 | - return $frm_vars['form_params'][ $form->id ]; |
|
615 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
616 | + return $frm_vars['form_params'][$form->id]; |
|
617 | 617 | } |
618 | 618 | |
619 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
619 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
620 | 620 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
621 | 621 | |
622 | 622 | $default_values = array( |
@@ -634,15 +634,15 @@ discard block |
||
634 | 634 | //if there are two forms on the same page, make sure not to submit both |
635 | 635 | foreach ( $default_values as $var => $default ) { |
636 | 636 | if ( $var == 'action' ) { |
637 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
637 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
638 | 638 | } else { |
639 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
639 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
640 | 640 | } |
641 | 641 | unset( $var, $default ); |
642 | 642 | } |
643 | 643 | } else { |
644 | 644 | foreach ( $default_values as $var => $default ) { |
645 | - $values[ $var ] = $default; |
|
645 | + $values[$var] = $default; |
|
646 | 646 | unset( $var, $default ); |
647 | 647 | } |
648 | 648 | } |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | public static function list_page_params() { |
658 | 658 | $values = array(); |
659 | 659 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
660 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
660 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | return $values; |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
678 | 678 | 'keep_post' => '', |
679 | 679 | ) as $var => $default ) { |
680 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
680 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | return $values; |
@@ -719,16 +719,16 @@ discard block |
||
719 | 719 | $small_form = new stdClass(); |
720 | 720 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
721 | 721 | $small_form->{$var} = $form->{$var}; |
722 | - unset($var); |
|
722 | + unset( $var ); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | $frm_vars['forms_loaded'][] = $small_form; |
726 | 726 | |
727 | - if ( $this_load && empty($global_load) ) { |
|
727 | + if ( $this_load && empty( $global_load ) ) { |
|
728 | 728 | $global_load = $frm_vars['load_css'] = true; |
729 | 729 | } |
730 | 730 | |
731 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
731 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | public static function show_submit( $form ) { |
@@ -2,166 +2,166 @@ 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 | 12 | if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
13 | - return; |
|
14 | - } |
|
15 | - |
|
16 | - global $wpdb; |
|
17 | - |
|
18 | - $notification = $action->post_content; |
|
19 | - $email_key = $action->ID; |
|
20 | - |
|
21 | - // Set the subject |
|
22 | - if ( empty($notification['email_subject']) ) { |
|
23 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
24 | - } |
|
25 | - |
|
26 | - $plain_text = $notification['plain_text'] ? true : false; |
|
27 | - |
|
28 | - //Filter these fields |
|
29 | - $filter_fields = array( |
|
30 | - 'email_to', 'cc', 'bcc', |
|
31 | - 'reply_to', 'from', |
|
32 | - 'email_subject', 'email_message', |
|
33 | - ); |
|
34 | - |
|
35 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
36 | - |
|
37 | - //Get all values in entry in order to get User ID field ID |
|
38 | - $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
39 | - $user_id_field = $user_id_key = ''; |
|
40 | - foreach ( $values as $value ) { |
|
41 | - if ( $value->field_type == 'user_id' ) { |
|
42 | - $user_id_field = $value->field_id; |
|
43 | - $user_id_key = $value->field_key; |
|
44 | - break; |
|
45 | - } |
|
46 | - unset($value); |
|
47 | - } |
|
48 | - |
|
49 | - //Filter and prepare the email fields |
|
50 | - foreach ( $filter_fields as $f ) { |
|
51 | - //Don't allow empty From |
|
13 | + return; |
|
14 | + } |
|
15 | + |
|
16 | + global $wpdb; |
|
17 | + |
|
18 | + $notification = $action->post_content; |
|
19 | + $email_key = $action->ID; |
|
20 | + |
|
21 | + // Set the subject |
|
22 | + if ( empty($notification['email_subject']) ) { |
|
23 | + $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
24 | + } |
|
25 | + |
|
26 | + $plain_text = $notification['plain_text'] ? true : false; |
|
27 | + |
|
28 | + //Filter these fields |
|
29 | + $filter_fields = array( |
|
30 | + 'email_to', 'cc', 'bcc', |
|
31 | + 'reply_to', 'from', |
|
32 | + 'email_subject', 'email_message', |
|
33 | + ); |
|
34 | + |
|
35 | + add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
36 | + |
|
37 | + //Get all values in entry in order to get User ID field ID |
|
38 | + $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
|
39 | + $user_id_field = $user_id_key = ''; |
|
40 | + foreach ( $values as $value ) { |
|
41 | + if ( $value->field_type == 'user_id' ) { |
|
42 | + $user_id_field = $value->field_id; |
|
43 | + $user_id_key = $value->field_key; |
|
44 | + break; |
|
45 | + } |
|
46 | + unset($value); |
|
47 | + } |
|
48 | + |
|
49 | + //Filter and prepare the email fields |
|
50 | + foreach ( $filter_fields as $f ) { |
|
51 | + //Don't allow empty From |
|
52 | 52 | if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
53 | 53 | $notification[ $f ] = '[admin_email]'; |
54 | 54 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
55 | 55 | //Remove brackets |
56 | - //Add a space in case there isn't one |
|
56 | + //Add a space in case there isn't one |
|
57 | 57 | $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
58 | 58 | $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
59 | 59 | |
60 | - //Switch userID shortcode to email address |
|
60 | + //Switch userID shortcode to email address |
|
61 | 61 | if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
62 | 62 | $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
63 | - $user_email = $user_data->user_email; |
|
63 | + $user_email = $user_data->user_email; |
|
64 | 64 | $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
65 | - } |
|
66 | - } |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | - //Put recipients, cc, and bcc into an array if they aren't empty |
|
71 | + //Put recipients, cc, and bcc into an array if they aren't empty |
|
72 | 72 | $to_emails = self::explode_emails( $notification['email_to'] ); |
73 | 73 | $cc = self::explode_emails( $notification['cc'] ); |
74 | 74 | $bcc = self::explode_emails( $notification['bcc'] ); |
75 | 75 | |
76 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
76 | + $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
77 | 77 | |
78 | - // Stop now if there aren't any recipients |
|
79 | - if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
80 | - return; |
|
81 | - } |
|
78 | + // Stop now if there aren't any recipients |
|
79 | + if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
|
80 | + return; |
|
81 | + } |
|
82 | 82 | |
83 | - $to_emails = array_unique( (array) $to_emails ); |
|
83 | + $to_emails = array_unique( (array) $to_emails ); |
|
84 | 84 | |
85 | - $prev_mail_body = $mail_body = $notification['email_message']; |
|
86 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
87 | - 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
88 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
89 | - ) ); |
|
85 | + $prev_mail_body = $mail_body = $notification['email_message']; |
|
86 | + $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
87 | + 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
|
88 | + 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
89 | + ) ); |
|
90 | 90 | |
91 | - // Add the user info if it isn't already included |
|
92 | - if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
93 | - $data = maybe_unserialize($entry->description); |
|
91 | + // Add the user info if it isn't already included |
|
92 | + if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
|
93 | + $data = maybe_unserialize($entry->description); |
|
94 | 94 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
95 | 95 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
96 | 96 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
97 | 97 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
98 | - } |
|
99 | - unset($prev_mail_body); |
|
100 | - |
|
101 | - // Add attachments |
|
102 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
103 | - |
|
104 | - if ( ! empty($notification['email_subject']) ) { |
|
105 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
106 | - } |
|
107 | - |
|
108 | - // check for a phone number |
|
109 | - foreach ( (array) $to_emails as $email_key => $e ) { |
|
110 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | - $e = explode(' ', $e); |
|
112 | - |
|
113 | - //If to_email has name <[email protected]> format |
|
114 | - if ( is_email(end($e)) ) { |
|
115 | - continue; |
|
116 | - } |
|
117 | - |
|
118 | - do_action('frm_send_to_not_email', array( |
|
119 | - 'e' => $e, |
|
120 | - 'subject' => $notification['email_subject'], |
|
121 | - 'mail_body' => $mail_body, |
|
122 | - 'reply_to' => $notification['reply_to'], |
|
123 | - 'from' => $notification['from'], |
|
124 | - 'plain_text' => $plain_text, |
|
125 | - 'attachments' => $attachments, |
|
126 | - 'form' => $form, |
|
127 | - 'email_key' => $email_key, |
|
128 | - ) ); |
|
98 | + } |
|
99 | + unset($prev_mail_body); |
|
100 | + |
|
101 | + // Add attachments |
|
102 | + $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
103 | + |
|
104 | + if ( ! empty($notification['email_subject']) ) { |
|
105 | + $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
106 | + } |
|
107 | + |
|
108 | + // check for a phone number |
|
109 | + foreach ( (array) $to_emails as $email_key => $e ) { |
|
110 | + if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | + $e = explode(' ', $e); |
|
112 | + |
|
113 | + //If to_email has name <[email protected]> format |
|
114 | + if ( is_email(end($e)) ) { |
|
115 | + continue; |
|
116 | + } |
|
117 | + |
|
118 | + do_action('frm_send_to_not_email', array( |
|
119 | + 'e' => $e, |
|
120 | + 'subject' => $notification['email_subject'], |
|
121 | + 'mail_body' => $mail_body, |
|
122 | + 'reply_to' => $notification['reply_to'], |
|
123 | + 'from' => $notification['from'], |
|
124 | + 'plain_text' => $plain_text, |
|
125 | + 'attachments' => $attachments, |
|
126 | + 'form' => $form, |
|
127 | + 'email_key' => $email_key, |
|
128 | + ) ); |
|
129 | 129 | |
130 | 130 | unset( $to_emails[ $email_key ] ); |
131 | - } |
|
132 | - } |
|
133 | - |
|
134 | - // Send the email now |
|
135 | - $sent_to = self::send_email( array( |
|
136 | - 'to_email' => $to_emails, |
|
137 | - 'subject' => $notification['email_subject'], |
|
138 | - 'message' => $mail_body, |
|
139 | - 'from' => $notification['from'], |
|
140 | - 'plain_text' => $plain_text, |
|
141 | - 'reply_to' => $notification['reply_to'], |
|
142 | - 'attachments' => $attachments, |
|
143 | - 'cc' => $cc, |
|
144 | - 'bcc' => $bcc, |
|
145 | - ) ); |
|
146 | - |
|
147 | - return $sent_to; |
|
148 | - } |
|
131 | + } |
|
132 | + } |
|
133 | + |
|
134 | + // Send the email now |
|
135 | + $sent_to = self::send_email( array( |
|
136 | + 'to_email' => $to_emails, |
|
137 | + 'subject' => $notification['email_subject'], |
|
138 | + 'message' => $mail_body, |
|
139 | + 'from' => $notification['from'], |
|
140 | + 'plain_text' => $plain_text, |
|
141 | + 'reply_to' => $notification['reply_to'], |
|
142 | + 'attachments' => $attachments, |
|
143 | + 'cc' => $cc, |
|
144 | + 'bcc' => $bcc, |
|
145 | + ) ); |
|
146 | + |
|
147 | + return $sent_to; |
|
148 | + } |
|
149 | 149 | |
150 | 150 | public function entry_created( $entry_id, $form_id ) { |
151 | 151 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
152 | 152 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
153 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
154 | - } |
|
153 | + FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
154 | + } |
|
155 | 155 | |
156 | 156 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
157 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
157 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
|
158 | 158 | |
159 | - return self::send_email(compact( |
|
160 | - 'to_email', 'subject', 'message', |
|
161 | - 'from', 'from_name', 'plain_text', |
|
162 | - 'attachments', 'reply_to' |
|
163 | - )); |
|
164 | - } |
|
159 | + return self::send_email(compact( |
|
160 | + 'to_email', 'subject', 'message', |
|
161 | + 'from', 'from_name', 'plain_text', |
|
162 | + 'attachments', 'reply_to' |
|
163 | + )); |
|
164 | + } |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Extract the emails from cc and bcc. Allow separation by , or ;. |
@@ -179,53 +179,53 @@ discard block |
||
179 | 179 | return $emails; |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
184 | - * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
185 | - * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
186 | - * "First Last" <[email protected]> |
|
187 | - * |
|
188 | - * Things that won't work: First Last (with no email entered) |
|
189 | - * @since 2.0 |
|
190 | - * @param array $atts array of email fields, pass by reference |
|
191 | - * @param $admin_email |
|
192 | - */ |
|
193 | - private static function format_email_fields( &$atts, $admin_email ) { |
|
194 | - |
|
195 | - // If from is empty or is set to admin_email, set it now |
|
196 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
197 | - |
|
198 | - // Filter values in these fields |
|
182 | + /** |
|
183 | + * Put To, BCC, CC, Reply To, and From fields in Name <[email protected]> format |
|
184 | + * Formats that should work: Name, "Name", [email protected], <[email protected]>, Name <[email protected]>, |
|
185 | + * "Name" <[email protected]>, Name [email protected], "Name" [email protected], Name<[email protected]>, "Name"<[email protected]> |
|
186 | + * "First Last" <[email protected]> |
|
187 | + * |
|
188 | + * Things that won't work: First Last (with no email entered) |
|
189 | + * @since 2.0 |
|
190 | + * @param array $atts array of email fields, pass by reference |
|
191 | + * @param $admin_email |
|
192 | + */ |
|
193 | + private static function format_email_fields( &$atts, $admin_email ) { |
|
194 | + |
|
195 | + // If from is empty or is set to admin_email, set it now |
|
196 | + $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
197 | + |
|
198 | + // Filter values in these fields |
|
199 | 199 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
200 | 200 | |
201 | - foreach ( $filter_fields as $f ) { |
|
202 | - // If empty, just skip it |
|
201 | + foreach ( $filter_fields as $f ) { |
|
202 | + // If empty, just skip it |
|
203 | 203 | if ( empty( $atts[ $f ] ) ) { |
204 | - continue; |
|
205 | - } |
|
204 | + continue; |
|
205 | + } |
|
206 | 206 | |
207 | - // to_email, cc, and bcc can be an array |
|
207 | + // to_email, cc, and bcc can be an array |
|
208 | 208 | if ( is_array( $atts[ $f ] ) ) { |
209 | 209 | foreach ( $atts[ $f ] as $key => $val ) { |
210 | - self::format_single_field( $atts, $f, $val, $key ); |
|
211 | - unset( $key, $val ); |
|
212 | - } |
|
213 | - unset($f); |
|
214 | - continue; |
|
215 | - } |
|
210 | + self::format_single_field( $atts, $f, $val, $key ); |
|
211 | + unset( $key, $val ); |
|
212 | + } |
|
213 | + unset($f); |
|
214 | + continue; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | self::format_single_field( $atts, $f, $atts[ $f ] ); |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - // If reply-to isn't set, make it match the from settings |
|
221 | - if ( empty( $atts['reply_to'] ) ) { |
|
222 | - $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
223 | - } |
|
220 | + // If reply-to isn't set, make it match the from settings |
|
221 | + if ( empty( $atts['reply_to'] ) ) { |
|
222 | + $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
|
223 | + } |
|
224 | 224 | |
225 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
226 | - $atts['to_email'] = $admin_email; |
|
227 | - } |
|
228 | - } |
|
225 | + if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
226 | + $atts['to_email'] = $admin_email; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | 230 | private static function get_email_from_formatted_string( $value ) { |
231 | 231 | if ( strpos( $value, '<' ) !== false ) { |
@@ -235,48 +235,48 @@ discard block |
||
235 | 235 | return $value; |
236 | 236 | } |
237 | 237 | |
238 | - /** |
|
239 | - * Format individual email fields |
|
240 | - * |
|
241 | - * @since 2.0 |
|
242 | - * @param array $atts pass by reference |
|
243 | - * @param string $f (to, from, reply_to, etc) |
|
244 | - * @param string $val value saved in field |
|
245 | - * @param int $key if in array, this will be set |
|
246 | - */ |
|
247 | - private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
248 | - $val = trim($val); |
|
249 | - |
|
250 | - // If just a plain email is used |
|
251 | - if ( is_email($val) ) { |
|
252 | - // add sender's name if not included in $from |
|
253 | - if ( $f == 'from' ) { |
|
238 | + /** |
|
239 | + * Format individual email fields |
|
240 | + * |
|
241 | + * @since 2.0 |
|
242 | + * @param array $atts pass by reference |
|
243 | + * @param string $f (to, from, reply_to, etc) |
|
244 | + * @param string $val value saved in field |
|
245 | + * @param int $key if in array, this will be set |
|
246 | + */ |
|
247 | + private static function format_single_field( &$atts, $f, $val, $key = false ) { |
|
248 | + $val = trim($val); |
|
249 | + |
|
250 | + // If just a plain email is used |
|
251 | + if ( is_email($val) ) { |
|
252 | + // add sender's name if not included in $from |
|
253 | + if ( $f == 'from' ) { |
|
254 | 254 | $part_2 = $atts[ $f ]; |
255 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
256 | - } else { |
|
257 | - return; |
|
258 | - } |
|
259 | - } else { |
|
260 | - $parts = explode(' ', $val); |
|
261 | - $part_2 = end($parts); |
|
262 | - |
|
263 | - // If inputted correcly, $part_2 should be an email |
|
264 | - if ( is_email( $part_2 ) ) { |
|
265 | - $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
266 | - } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
255 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
256 | + } else { |
|
257 | + return; |
|
258 | + } |
|
259 | + } else { |
|
260 | + $parts = explode(' ', $val); |
|
261 | + $part_2 = end($parts); |
|
262 | + |
|
263 | + // If inputted correcly, $part_2 should be an email |
|
264 | + if ( is_email( $part_2 ) ) { |
|
265 | + $part_1 = trim( str_replace( $part_2, '', $val ) ); |
|
266 | + } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
|
267 | 267 | // In case someone just puts a name in the From or Reply To field |
268 | 268 | $part_1 = $val; |
269 | - $part_2 = get_option('admin_email'); |
|
270 | - } else { |
|
269 | + $part_2 = get_option('admin_email'); |
|
270 | + } else { |
|
271 | 271 | // In case someone just puts a name in any other email field |
272 | - if ( false !== $key ) { |
|
272 | + if ( false !== $key ) { |
|
273 | 273 | unset( $atts[ $f ][ $key ] ); |
274 | - return; |
|
275 | - } |
|
274 | + return; |
|
275 | + } |
|
276 | 276 | $atts[ $f ] = ''; |
277 | - return; |
|
278 | - } |
|
279 | - } |
|
277 | + return; |
|
278 | + } |
|
279 | + } |
|
280 | 280 | |
281 | 281 | // if sending the email from a yahoo address, change it to the WordPress default |
282 | 282 | if ( $f == 'from' && strpos( $part_2, '@yahoo.com' ) ) { |
@@ -289,110 +289,110 @@ discard block |
||
289 | 289 | $part_2 = 'wordpress@' . $sitename; |
290 | 290 | } |
291 | 291 | |
292 | - // Set up formatted value |
|
292 | + // Set up formatted value |
|
293 | 293 | $final_val = str_replace( '"', '', $part_1 ) . ' <' . $part_2 . '>'; |
294 | 294 | |
295 | - // If value is an array |
|
296 | - if ( false !== $key ) { |
|
295 | + // If value is an array |
|
296 | + if ( false !== $key ) { |
|
297 | 297 | $atts[ $f ][ $key ] = $final_val; |
298 | - return; |
|
299 | - } |
|
298 | + return; |
|
299 | + } |
|
300 | 300 | $atts[ $f ] = $final_val; |
301 | - } |
|
301 | + } |
|
302 | 302 | |
303 | 303 | public static function send_email( $atts ) { |
304 | - $admin_email = get_option('admin_email'); |
|
305 | - $defaults = array( |
|
306 | - 'to_email' => $admin_email, |
|
307 | - 'subject' => '', |
|
308 | - 'message' => '', |
|
309 | - 'from' => $admin_email, |
|
310 | - 'from_name' => '', |
|
311 | - 'cc' => '', |
|
312 | - 'bcc' => '', |
|
313 | - 'plain_text' => true, |
|
314 | - 'reply_to' => $admin_email, |
|
315 | - 'attachments' => array(), |
|
316 | - ); |
|
317 | - $atts = wp_parse_args($atts, $defaults); |
|
318 | - |
|
319 | - // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
320 | - self::format_email_fields( $atts, $admin_email ); |
|
321 | - |
|
322 | - $recipient = $atts['to_email']; //recipient |
|
323 | - $header = array(); |
|
324 | - $header[] = 'From: ' . $atts['from']; |
|
325 | - |
|
326 | - //Allow for cc and bcc arrays |
|
304 | + $admin_email = get_option('admin_email'); |
|
305 | + $defaults = array( |
|
306 | + 'to_email' => $admin_email, |
|
307 | + 'subject' => '', |
|
308 | + 'message' => '', |
|
309 | + 'from' => $admin_email, |
|
310 | + 'from_name' => '', |
|
311 | + 'cc' => '', |
|
312 | + 'bcc' => '', |
|
313 | + 'plain_text' => true, |
|
314 | + 'reply_to' => $admin_email, |
|
315 | + 'attachments' => array(), |
|
316 | + ); |
|
317 | + $atts = wp_parse_args($atts, $defaults); |
|
318 | + |
|
319 | + // Put To, BCC, CC, Reply To, and From fields in the correct format |
|
320 | + self::format_email_fields( $atts, $admin_email ); |
|
321 | + |
|
322 | + $recipient = $atts['to_email']; //recipient |
|
323 | + $header = array(); |
|
324 | + $header[] = 'From: ' . $atts['from']; |
|
325 | + |
|
326 | + //Allow for cc and bcc arrays |
|
327 | 327 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
328 | 328 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
329 | - foreach ( $array_fields as $key => $a_field ) { |
|
330 | - if ( empty($a_field) ) { |
|
331 | - continue; |
|
332 | - } |
|
329 | + foreach ( $array_fields as $key => $a_field ) { |
|
330 | + if ( empty($a_field) ) { |
|
331 | + continue; |
|
332 | + } |
|
333 | 333 | |
334 | 334 | foreach ( (array) $a_field as $email ) { |
335 | 335 | $cc[ $key ][] = $email; |
336 | - } |
|
337 | - unset($key, $a_field); |
|
338 | - } |
|
336 | + } |
|
337 | + unset($key, $a_field); |
|
338 | + } |
|
339 | 339 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
340 | 340 | |
341 | 341 | foreach ( $cc as $k => $v ) { |
342 | 342 | $header[] = $k . ': ' . implode( ',', $v ); |
343 | 343 | } |
344 | 344 | |
345 | - $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
346 | - $charset = get_option('blog_charset'); |
|
345 | + $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
|
346 | + $charset = get_option('blog_charset'); |
|
347 | 347 | |
348 | 348 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
349 | 349 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
350 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
350 | + $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
351 | 351 | |
352 | - $message = do_shortcode($atts['message']); |
|
352 | + $message = do_shortcode($atts['message']); |
|
353 | 353 | |
354 | - if ( $atts['plain_text'] ) { |
|
355 | - //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
356 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
357 | - } else { |
|
354 | + if ( $atts['plain_text'] ) { |
|
355 | + //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
|
356 | + $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
357 | + } else { |
|
358 | 358 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
359 | - add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
360 | - } |
|
359 | + add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
|
360 | + } |
|
361 | 361 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
362 | 362 | |
363 | - $header = apply_filters('frm_email_header', $header, array( |
|
363 | + $header = apply_filters('frm_email_header', $header, array( |
|
364 | 364 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
365 | 365 | ) ); |
366 | 366 | |
367 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | + if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
368 | 368 | $atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?='; |
369 | - } |
|
369 | + } |
|
370 | 370 | |
371 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
372 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
371 | + remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
372 | + remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
373 | 373 | |
374 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
375 | - if ( ! $sent ) { |
|
374 | + $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
375 | + if ( ! $sent ) { |
|
376 | 376 | $header = 'From: ' . $atts['from'] . "\r\n"; |
377 | - $recipient = implode(',', (array) $recipient); |
|
378 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
379 | - } |
|
377 | + $recipient = implode(',', (array) $recipient); |
|
378 | + $sent = mail($recipient, $atts['subject'], $message, $header); |
|
379 | + } |
|
380 | 380 | |
381 | 381 | // remove the filter now so other emails can still use it |
382 | 382 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
383 | 383 | |
384 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
384 | + do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
385 | 385 | |
386 | - if ( $sent ) { |
|
386 | + if ( $sent ) { |
|
387 | 387 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
388 | - $sent_to = array_filter( $sent_to ); |
|
389 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
390 | - $temp = str_replace('<', '<', $sent_to); |
|
388 | + $sent_to = array_filter( $sent_to ); |
|
389 | + if ( apply_filters('frm_echo_emails', false) ) { |
|
390 | + $temp = str_replace('<', '<', $sent_to); |
|
391 | 391 | echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
392 | - } |
|
393 | - return $sent_to; |
|
394 | - } |
|
395 | - } |
|
392 | + } |
|
393 | + return $sent_to; |
|
394 | + } |
|
395 | + } |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * This function should only be fired when Mandrill is sending an HTML email |
@@ -2,14 +2,14 @@ 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 ) { |
12 | - if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
12 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | $email_key = $action->ID; |
20 | 20 | |
21 | 21 | // Set the subject |
22 | - if ( empty($notification['email_subject']) ) { |
|
23 | - $notification['email_subject'] = sprintf(__( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]'); |
|
22 | + if ( empty( $notification['email_subject'] ) ) { |
|
23 | + $notification['email_subject'] = sprintf( __( '%1$s Form submitted on %2$s', 'formidable' ), $form->name, '[sitename]' ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $plain_text = $notification['plain_text'] ? true : false; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | 'email_subject', 'email_message', |
33 | 33 | ); |
34 | 34 | |
35 | - add_filter('frm_plain_text_email', ($plain_text ? '__return_true' : '__return_false')); |
|
35 | + add_filter( 'frm_plain_text_email', ( $plain_text ? '__return_true' : '__return_false' ) ); |
|
36 | 36 | |
37 | 37 | //Get all values in entry in order to get User ID field ID |
38 | 38 | $values = FrmEntryMeta::getAll( array( 'it.field_id !' => 0, 'it.item_id' => $entry->id ), ' ORDER BY fi.field_order' ); |
@@ -43,29 +43,29 @@ discard block |
||
43 | 43 | $user_id_key = $value->field_key; |
44 | 44 | break; |
45 | 45 | } |
46 | - unset($value); |
|
46 | + unset( $value ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | //Filter and prepare the email fields |
50 | 50 | foreach ( $filter_fields as $f ) { |
51 | 51 | //Don't allow empty From |
52 | - if ( $f == 'from' && empty( $notification[ $f ] ) ) { |
|
53 | - $notification[ $f ] = '[admin_email]'; |
|
52 | + if ( $f == 'from' && empty( $notification[$f] ) ) { |
|
53 | + $notification[$f] = '[admin_email]'; |
|
54 | 54 | } else if ( in_array( $f, array( 'email_to', 'cc', 'bcc', 'reply_to', 'from' ) ) ) { |
55 | 55 | //Remove brackets |
56 | 56 | //Add a space in case there isn't one |
57 | - $notification[ $f ] = str_replace( '<', ' ', $notification[ $f ] ); |
|
58 | - $notification[ $f ] = str_replace( array( '"', '>' ), '', $notification[ $f ] ); |
|
57 | + $notification[$f] = str_replace( '<', ' ', $notification[$f] ); |
|
58 | + $notification[$f] = str_replace( array( '"', '>' ), '', $notification[$f] ); |
|
59 | 59 | |
60 | 60 | //Switch userID shortcode to email address |
61 | - if ( strpos( $notification[ $f ], '[' . $user_id_field . ']' ) !== false || strpos( $notification[ $f ], '[' . $user_id_key . ']' ) !== false ) { |
|
62 | - $user_data = get_userdata( $entry->metas[ $user_id_field ] ); |
|
61 | + if ( strpos( $notification[$f], '[' . $user_id_field . ']' ) !== false || strpos( $notification[$f], '[' . $user_id_key . ']' ) !== false ) { |
|
62 | + $user_data = get_userdata( $entry->metas[$user_id_field] ); |
|
63 | 63 | $user_email = $user_data->user_email; |
64 | - $notification[ $f ] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[ $f ] ); |
|
64 | + $notification[$f] = str_replace( array( '[' . $user_id_field . ']', '[' . $user_id_key . ']' ), $user_email, $notification[$f] ); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - $notification[ $f ] = FrmFieldsHelper::basic_replace_shortcodes( $notification[ $f ], $form, $entry ); |
|
68 | + $notification[$f] = FrmFieldsHelper::basic_replace_shortcodes( $notification[$f], $form, $entry ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | //Put recipients, cc, and bcc into an array if they aren't empty |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $cc = self::explode_emails( $notification['cc'] ); |
74 | 74 | $bcc = self::explode_emails( $notification['bcc'] ); |
75 | 75 | |
76 | - $to_emails = apply_filters('frm_to_email', $to_emails, $values, $form->id, compact('email_key', 'entry', 'form')); |
|
76 | + $to_emails = apply_filters( 'frm_to_email', $to_emails, $values, $form->id, compact( 'email_key', 'entry', 'form' ) ); |
|
77 | 77 | |
78 | 78 | // Stop now if there aren't any recipients |
79 | 79 | if ( empty( $to_emails ) && empty( $cc ) && empty( $bcc ) ) { |
@@ -83,39 +83,39 @@ discard block |
||
83 | 83 | $to_emails = array_unique( (array) $to_emails ); |
84 | 84 | |
85 | 85 | $prev_mail_body = $mail_body = $notification['email_message']; |
86 | - $mail_body = FrmEntriesHelper::replace_default_message($mail_body, array( |
|
86 | + $mail_body = FrmEntriesHelper::replace_default_message( $mail_body, array( |
|
87 | 87 | 'id' => $entry->id, 'entry' => $entry, 'plain_text' => $plain_text, |
88 | - 'user_info' => (isset($notification['inc_user_info']) ? $notification['inc_user_info'] : false), |
|
88 | + 'user_info' => ( isset( $notification['inc_user_info'] ) ? $notification['inc_user_info'] : false ), |
|
89 | 89 | ) ); |
90 | 90 | |
91 | 91 | // Add the user info if it isn't already included |
92 | 92 | if ( $notification['inc_user_info'] && $prev_mail_body == $mail_body ) { |
93 | - $data = maybe_unserialize($entry->description); |
|
93 | + $data = maybe_unserialize( $entry->description ); |
|
94 | 94 | $mail_body .= "\r\n\r\n" . __( 'User Information', 'formidable' ) . "\r\n"; |
95 | 95 | $mail_body .= __( 'IP Address', 'formidable' ) . ': ' . $entry->ip . "\r\n"; |
96 | 96 | $mail_body .= __( 'User-Agent (Browser/OS)', 'formidable' ) . ': ' . FrmEntryFormat::get_browser( $data['browser'] ) . "\r\n"; |
97 | 97 | $mail_body .= __( 'Referrer', 'formidable' ) . ': ' . $data['referrer'] . "\r\n"; |
98 | 98 | } |
99 | - unset($prev_mail_body); |
|
99 | + unset( $prev_mail_body ); |
|
100 | 100 | |
101 | 101 | // Add attachments |
102 | - $attachments = apply_filters('frm_notification_attachment', array(), $form, compact('entry', 'email_key') ); |
|
102 | + $attachments = apply_filters( 'frm_notification_attachment', array(), $form, compact( 'entry', 'email_key' ) ); |
|
103 | 103 | |
104 | - if ( ! empty($notification['email_subject']) ) { |
|
105 | - $notification['email_subject'] = apply_filters('frm_email_subject', $notification['email_subject'], compact('form', 'entry', 'email_key')); |
|
104 | + if ( ! empty( $notification['email_subject'] ) ) { |
|
105 | + $notification['email_subject'] = apply_filters( 'frm_email_subject', $notification['email_subject'], compact( 'form', 'entry', 'email_key' ) ); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | // check for a phone number |
109 | 109 | foreach ( (array) $to_emails as $email_key => $e ) { |
110 | - if ( $e != '[admin_email]' && ! is_email($e) ) { |
|
111 | - $e = explode(' ', $e); |
|
110 | + if ( $e != '[admin_email]' && ! is_email( $e ) ) { |
|
111 | + $e = explode( ' ', $e ); |
|
112 | 112 | |
113 | 113 | //If to_email has name <[email protected]> format |
114 | - if ( is_email(end($e)) ) { |
|
114 | + if ( is_email( end( $e ) ) ) { |
|
115 | 115 | continue; |
116 | 116 | } |
117 | 117 | |
118 | - do_action('frm_send_to_not_email', array( |
|
118 | + do_action( 'frm_send_to_not_email', array( |
|
119 | 119 | 'e' => $e, |
120 | 120 | 'subject' => $notification['email_subject'], |
121 | 121 | 'mail_body' => $mail_body, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'email_key' => $email_key, |
128 | 128 | ) ); |
129 | 129 | |
130 | - unset( $to_emails[ $email_key ] ); |
|
130 | + unset( $to_emails[$email_key] ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | public function entry_created( $entry_id, $form_id ) { |
151 | 151 | $new_function = 'FrmFormActionsController::trigger_actions("create", ' . $form_id . ', ' . $entry_id . ', "email")'; |
152 | 152 | _deprecated_function( __FUNCTION__, '2.0', $new_function ); |
153 | - FrmFormActionsController::trigger_actions('create', $form_id, $entry_id, 'email'); |
|
153 | + FrmFormActionsController::trigger_actions( 'create', $form_id, $entry_id, 'email' ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | public function send_notification_email( $to_email, $subject, $message, $from = '', $from_name = '', $plain_text = true, $attachments = array(), $reply_to = '' ) { |
157 | 157 | _deprecated_function( __FUNCTION__, '2.0', 'FrmNotification::send_email' ); |
158 | 158 | |
159 | - return self::send_email(compact( |
|
159 | + return self::send_email( compact( |
|
160 | 160 | 'to_email', 'subject', 'message', |
161 | 161 | 'from', 'from_name', 'plain_text', |
162 | 162 | 'attachments', 'reply_to' |
163 | - )); |
|
163 | + ) ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -193,28 +193,28 @@ discard block |
||
193 | 193 | private static function format_email_fields( &$atts, $admin_email ) { |
194 | 194 | |
195 | 195 | // If from is empty or is set to admin_email, set it now |
196 | - $atts['from'] = ( empty($atts['from']) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
196 | + $atts['from'] = ( empty( $atts['from'] ) || $atts['from'] == '[admin_email]' ) ? $admin_email : $atts['from']; |
|
197 | 197 | |
198 | 198 | // Filter values in these fields |
199 | 199 | $filter_fields = array( 'to_email', 'bcc', 'cc', 'from', 'reply_to' ); |
200 | 200 | |
201 | 201 | foreach ( $filter_fields as $f ) { |
202 | 202 | // If empty, just skip it |
203 | - if ( empty( $atts[ $f ] ) ) { |
|
203 | + if ( empty( $atts[$f] ) ) { |
|
204 | 204 | continue; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // to_email, cc, and bcc can be an array |
208 | - if ( is_array( $atts[ $f ] ) ) { |
|
209 | - foreach ( $atts[ $f ] as $key => $val ) { |
|
208 | + if ( is_array( $atts[$f] ) ) { |
|
209 | + foreach ( $atts[$f] as $key => $val ) { |
|
210 | 210 | self::format_single_field( $atts, $f, $val, $key ); |
211 | 211 | unset( $key, $val ); |
212 | 212 | } |
213 | - unset($f); |
|
213 | + unset( $f ); |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | - self::format_single_field( $atts, $f, $atts[ $f ] ); |
|
217 | + self::format_single_field( $atts, $f, $atts[$f] ); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // If reply-to isn't set, make it match the from settings |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $atts['reply_to'] = self::get_email_from_formatted_string( $atts['from'] ); |
223 | 223 | } |
224 | 224 | |
225 | - if ( ! is_array($atts['to_email']) && '[admin_email]' == $atts['to_email'] ) { |
|
225 | + if ( ! is_array( $atts['to_email'] ) && '[admin_email]' == $atts['to_email'] ) { |
|
226 | 226 | $atts['to_email'] = $admin_email; |
227 | 227 | } |
228 | 228 | } |
@@ -245,20 +245,20 @@ discard block |
||
245 | 245 | * @param int $key if in array, this will be set |
246 | 246 | */ |
247 | 247 | private static function format_single_field( &$atts, $f, $val, $key = false ) { |
248 | - $val = trim($val); |
|
248 | + $val = trim( $val ); |
|
249 | 249 | |
250 | 250 | // If just a plain email is used |
251 | - if ( is_email($val) ) { |
|
251 | + if ( is_email( $val ) ) { |
|
252 | 252 | // add sender's name if not included in $from |
253 | 253 | if ( $f == 'from' ) { |
254 | - $part_2 = $atts[ $f ]; |
|
255 | - $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
254 | + $part_2 = $atts[$f]; |
|
255 | + $part_1 = $atts['from_name'] ? $atts['from_name'] : wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
256 | 256 | } else { |
257 | 257 | return; |
258 | 258 | } |
259 | 259 | } else { |
260 | - $parts = explode(' ', $val); |
|
261 | - $part_2 = end($parts); |
|
260 | + $parts = explode( ' ', $val ); |
|
261 | + $part_2 = end( $parts ); |
|
262 | 262 | |
263 | 263 | // If inputted correcly, $part_2 should be an email |
264 | 264 | if ( is_email( $part_2 ) ) { |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | } else if ( in_array( $f, array( 'from', 'reply_to' ) ) ) { |
267 | 267 | // In case someone just puts a name in the From or Reply To field |
268 | 268 | $part_1 = $val; |
269 | - $part_2 = get_option('admin_email'); |
|
269 | + $part_2 = get_option( 'admin_email' ); |
|
270 | 270 | } else { |
271 | 271 | // In case someone just puts a name in any other email field |
272 | 272 | if ( false !== $key ) { |
273 | - unset( $atts[ $f ][ $key ] ); |
|
273 | + unset( $atts[$f][$key] ); |
|
274 | 274 | return; |
275 | 275 | } |
276 | - $atts[ $f ] = ''; |
|
276 | + $atts[$f] = ''; |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | } |
@@ -294,14 +294,14 @@ discard block |
||
294 | 294 | |
295 | 295 | // If value is an array |
296 | 296 | if ( false !== $key ) { |
297 | - $atts[ $f ][ $key ] = $final_val; |
|
297 | + $atts[$f][$key] = $final_val; |
|
298 | 298 | return; |
299 | 299 | } |
300 | - $atts[ $f ] = $final_val; |
|
300 | + $atts[$f] = $final_val; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | public static function send_email( $atts ) { |
304 | - $admin_email = get_option('admin_email'); |
|
304 | + $admin_email = get_option( 'admin_email' ); |
|
305 | 305 | $defaults = array( |
306 | 306 | 'to_email' => $admin_email, |
307 | 307 | 'subject' => '', |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | 'reply_to' => $admin_email, |
315 | 315 | 'attachments' => array(), |
316 | 316 | ); |
317 | - $atts = wp_parse_args($atts, $defaults); |
|
317 | + $atts = wp_parse_args( $atts, $defaults ); |
|
318 | 318 | |
319 | 319 | // Put To, BCC, CC, Reply To, and From fields in the correct format |
320 | 320 | self::format_email_fields( $atts, $admin_email ); |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | $array_fields = array( 'CC' => $atts['cc'], 'BCC' => $atts['bcc'] ); |
328 | 328 | $cc = array( 'CC' => array(), 'BCC' => array() ); |
329 | 329 | foreach ( $array_fields as $key => $a_field ) { |
330 | - if ( empty($a_field) ) { |
|
330 | + if ( empty( $a_field ) ) { |
|
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | |
334 | 334 | foreach ( (array) $a_field as $email ) { |
335 | - $cc[ $key ][] = $email; |
|
335 | + $cc[$key][] = $email; |
|
336 | 336 | } |
337 | - unset($key, $a_field); |
|
337 | + unset( $key, $a_field ); |
|
338 | 338 | } |
339 | 339 | $cc = array_filter( $cc ); // remove cc and bcc if they are empty |
340 | 340 | |
@@ -343,52 +343,52 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | $content_type = $atts['plain_text'] ? 'text/plain' : 'text/html'; |
346 | - $charset = get_option('blog_charset'); |
|
346 | + $charset = get_option( 'blog_charset' ); |
|
347 | 347 | |
348 | 348 | $header[] = 'Reply-To: ' . $atts['reply_to']; |
349 | 349 | $header[] = 'Content-Type: ' . $content_type . '; charset="' . esc_attr( $charset ) . '"'; |
350 | - $atts['subject'] = wp_specialchars_decode(strip_tags(stripslashes($atts['subject'])), ENT_QUOTES ); |
|
350 | + $atts['subject'] = wp_specialchars_decode( strip_tags( stripslashes( $atts['subject'] ) ), ENT_QUOTES ); |
|
351 | 351 | |
352 | - $message = do_shortcode($atts['message']); |
|
352 | + $message = do_shortcode( $atts['message'] ); |
|
353 | 353 | |
354 | 354 | if ( $atts['plain_text'] ) { |
355 | 355 | //$message = wordwrap($message, 70, "\r\n"); //in case any lines are longer than 70 chars |
356 | - $message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES ); |
|
356 | + $message = wp_specialchars_decode( strip_tags( $message ), ENT_QUOTES ); |
|
357 | 357 | } else { |
358 | 358 | // remove line breaks in HTML emails to prevent conflicts with Mandrill |
359 | 359 | add_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
360 | 360 | } |
361 | 361 | $message = apply_filters( 'frm_email_message', $message, $atts ); |
362 | 362 | |
363 | - $header = apply_filters('frm_email_header', $header, array( |
|
363 | + $header = apply_filters( 'frm_email_header', $header, array( |
|
364 | 364 | 'to_email' => $atts['to_email'], 'subject' => $atts['subject'], |
365 | 365 | ) ); |
366 | 366 | |
367 | - if ( apply_filters('frm_encode_subject', 1, $atts['subject'] ) ) { |
|
367 | + if ( apply_filters( 'frm_encode_subject', 1, $atts['subject'] ) ) { |
|
368 | 368 | $atts['subject'] = '=?' . $charset . '?B?' . base64_encode( $atts['subject'] ) . '?='; |
369 | 369 | } |
370 | 370 | |
371 | - remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
372 | - remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter'); |
|
371 | + remove_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' ); |
|
372 | + remove_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' ); |
|
373 | 373 | |
374 | - $sent = wp_mail($recipient, $atts['subject'], $message, $header, $atts['attachments']); |
|
374 | + $sent = wp_mail( $recipient, $atts['subject'], $message, $header, $atts['attachments'] ); |
|
375 | 375 | if ( ! $sent ) { |
376 | 376 | $header = 'From: ' . $atts['from'] . "\r\n"; |
377 | - $recipient = implode(',', (array) $recipient); |
|
378 | - $sent = mail($recipient, $atts['subject'], $message, $header); |
|
377 | + $recipient = implode( ',', (array) $recipient ); |
|
378 | + $sent = mail( $recipient, $atts['subject'], $message, $header ); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | // remove the filter now so other emails can still use it |
382 | 382 | remove_filter( 'mandrill_nl2br', 'FrmNotification::remove_mandrill_br' ); |
383 | 383 | |
384 | - do_action('frm_notification', $recipient, $atts['subject'], $message); |
|
384 | + do_action( 'frm_notification', $recipient, $atts['subject'], $message ); |
|
385 | 385 | |
386 | 386 | if ( $sent ) { |
387 | 387 | $sent_to = array_merge( (array) $atts['to_email'], (array) $atts['cc'], (array) $atts['bcc'] ); |
388 | 388 | $sent_to = array_filter( $sent_to ); |
389 | - if ( apply_filters('frm_echo_emails', false) ) { |
|
390 | - $temp = str_replace('<', '<', $sent_to); |
|
391 | - echo ' ' . FrmAppHelper::kses( implode(', ', (array) $temp ) ); |
|
389 | + if ( apply_filters( 'frm_echo_emails', false ) ) { |
|
390 | + $temp = str_replace( '<', '<', $sent_to ); |
|
391 | + echo ' ' . FrmAppHelper::kses( implode( ', ', (array) $temp ) ); |
|
392 | 392 | } |
393 | 393 | return $sent_to; |
394 | 394 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmFormsListHelper extends FrmListHelper { |
7 | - var $status = ''; |
|
7 | + var $status = ''; |
|
8 | 8 | |
9 | 9 | public function __construct( $args ) { |
10 | 10 | $this->status = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | public function prepare_items() { |
16 | - global $wpdb, $per_page, $mode; |
|
16 | + global $wpdb, $per_page, $mode; |
|
17 | 17 | |
18 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
18 | + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
19 | 19 | |
20 | 20 | $default_orderby = 'name'; |
21 | 21 | $default_order = 'ASC'; |
22 | 22 | |
23 | - $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
23 | + $orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : $default_orderby; |
|
24 | 24 | $order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : $default_order; |
25 | 25 | |
26 | 26 | $page = $this->get_pagenum(); |
@@ -28,40 +28,40 @@ discard block |
||
28 | 28 | |
29 | 29 | $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
30 | 30 | |
31 | - $s_query = array(); |
|
32 | - $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
31 | + $s_query = array(); |
|
32 | + $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
|
33 | 33 | switch ( $this->status ) { |
34 | - case 'template': |
|
35 | - $s_query['is_template'] = 1; |
|
36 | - $s_query['status !'] = 'trash'; |
|
37 | - break; |
|
38 | - case 'draft': |
|
39 | - $s_query['is_template'] = 0; |
|
40 | - $s_query['status'] = 'draft'; |
|
41 | - break; |
|
42 | - case 'trash': |
|
43 | - $s_query['status'] = 'trash'; |
|
44 | - break; |
|
45 | - default: |
|
46 | - $s_query['is_template'] = 0; |
|
47 | - $s_query['status !'] = 'trash'; |
|
48 | - break; |
|
34 | + case 'template': |
|
35 | + $s_query['is_template'] = 1; |
|
36 | + $s_query['status !'] = 'trash'; |
|
37 | + break; |
|
38 | + case 'draft': |
|
39 | + $s_query['is_template'] = 0; |
|
40 | + $s_query['status'] = 'draft'; |
|
41 | + break; |
|
42 | + case 'trash': |
|
43 | + $s_query['status'] = 'trash'; |
|
44 | + break; |
|
45 | + default: |
|
46 | + $s_query['is_template'] = 0; |
|
47 | + $s_query['status !'] = 'trash'; |
|
48 | + break; |
|
49 | 49 | } |
50 | 50 | |
51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
52 | - if ( $s != '' ) { |
|
53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
54 | - $search_terms = array_map('trim', $matches[0]); |
|
55 | - foreach ( (array) $search_terms as $term ) { |
|
56 | - $s_query[] = array( |
|
57 | - 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
58 | - ); |
|
59 | - unset($term); |
|
60 | - } |
|
61 | - } |
|
51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
52 | + if ( $s != '' ) { |
|
53 | + preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
54 | + $search_terms = array_map('trim', $matches[0]); |
|
55 | + foreach ( (array) $search_terms as $term ) { |
|
56 | + $s_query[] = array( |
|
57 | + 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
|
58 | + ); |
|
59 | + unset($term); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | 63 | $this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page ); |
64 | - $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
64 | + $total_items = FrmDb::get_count( 'frm_forms', $s_query ); |
|
65 | 65 | |
66 | 66 | $this->set_pagination_args( array( |
67 | 67 | 'total_items' => $total_items, |
@@ -70,69 +70,69 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | public function no_items() { |
73 | - if ( 'template' == $this->status ) { |
|
74 | - _e( 'No Templates Found.', 'formidable' ) ?> |
|
73 | + if ( 'template' == $this->status ) { |
|
74 | + _e( 'No Templates Found.', 'formidable' ) ?> |
|
75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
76 | 76 | <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
77 | 77 | <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
79 | 79 | </ol> |
80 | 80 | <?php } else { |
81 | - _e( 'No Forms Found.', 'formidable' ) ?> |
|
81 | + _e( 'No Forms Found.', 'formidable' ) ?> |
|
82 | 82 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php _e( 'Add New', 'formidable' ); ?></a> |
83 | 83 | <?php } |
84 | 84 | } |
85 | 85 | |
86 | 86 | public function get_bulk_actions() { |
87 | - $actions = array(); |
|
87 | + $actions = array(); |
|
88 | 88 | |
89 | 89 | if ( in_array( $this->status, array( '', 'published' ) ) ) { |
90 | - $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
91 | - } |
|
92 | - |
|
93 | - if ( 'trash' == $this->status ) { |
|
94 | - if ( current_user_can('frm_edit_forms') ) { |
|
95 | - $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
96 | - } |
|
97 | - |
|
98 | - if ( current_user_can('frm_delete_forms') ) { |
|
99 | - $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
100 | - } |
|
101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
102 | - $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
105 | - } |
|
106 | - |
|
107 | - return $actions; |
|
108 | - } |
|
90 | + $actions['bulk_create_template'] = __( 'Create Template', 'formidable' ); |
|
91 | + } |
|
92 | + |
|
93 | + if ( 'trash' == $this->status ) { |
|
94 | + if ( current_user_can('frm_edit_forms') ) { |
|
95 | + $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
|
96 | + } |
|
97 | + |
|
98 | + if ( current_user_can('frm_delete_forms') ) { |
|
99 | + $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
|
100 | + } |
|
101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
102 | + $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
|
103 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
104 | + $actions['bulk_delete'] = __( 'Delete'); |
|
105 | + } |
|
106 | + |
|
107 | + return $actions; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | public function extra_tablenav( $which ) { |
111 | - if ( 'top' != $which ) { |
|
112 | - return; |
|
113 | - } |
|
111 | + if ( 'top' != $which ) { |
|
112 | + return; |
|
113 | + } |
|
114 | 114 | |
115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
115 | + if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
116 | 116 | ?> |
117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
119 | 119 | </div> |
120 | 120 | <?php |
121 | - return; |
|
122 | - } |
|
121 | + return; |
|
122 | + } |
|
123 | 123 | |
124 | - if ( 'template' != $this->status ) { |
|
125 | - return; |
|
126 | - } |
|
124 | + if ( 'template' != $this->status ) { |
|
125 | + return; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
130 | 130 | |
131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
132 | - $args = array( |
|
133 | - 'frm_action' => 'duplicate', |
|
134 | - 'template' => true, |
|
135 | - ); |
|
131 | + $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
132 | + $args = array( |
|
133 | + 'frm_action' => 'duplicate', |
|
134 | + 'template' => true, |
|
135 | + ); |
|
136 | 136 | |
137 | 137 | ?> |
138 | 138 | <div class="alignleft actions frm_visible_overflow"> |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | <a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php _e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a> |
141 | 141 | <ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop"> |
142 | 142 | <?php |
143 | - if ( empty( $forms ) ) { ?> |
|
143 | + if ( empty( $forms ) ) { ?> |
|
144 | 144 | <li class="frm_dropdown_li"><?php _e( 'You have not created any forms yet. <br/>You must create a form before you can make a template.', 'formidable' ) ?></li> |
145 | 145 | <?php |
146 | - } else { |
|
147 | - foreach ( $forms as $form ) { |
|
148 | - $args['id'] = $form->id; ?> |
|
146 | + } else { |
|
147 | + foreach ( $forms as $form ) { |
|
148 | + $args['id'] = $form->id; ?> |
|
149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
150 | 150 | <?php |
151 | - unset($form); |
|
151 | + unset($form); |
|
152 | 152 | } |
153 | - } |
|
154 | - ?> |
|
153 | + } |
|
154 | + ?> |
|
155 | 155 | </ul> |
156 | 156 | </div> |
157 | 157 | </div> |
@@ -161,30 +161,30 @@ discard block |
||
161 | 161 | public function get_views() { |
162 | 162 | |
163 | 163 | $statuses = array( |
164 | - 'published' => __( 'My Forms', 'formidable' ), |
|
165 | - 'template' => __( 'Templates', 'formidable' ), |
|
166 | - 'draft' => __( 'Drafts', 'formidable' ), |
|
167 | - 'trash' => __( 'Trash', 'formidable' ), |
|
164 | + 'published' => __( 'My Forms', 'formidable' ), |
|
165 | + 'template' => __( 'Templates', 'formidable' ), |
|
166 | + 'draft' => __( 'Drafts', 'formidable' ), |
|
167 | + 'trash' => __( 'Trash', 'formidable' ), |
|
168 | 168 | ); |
169 | 169 | |
170 | - $links = array(); |
|
171 | - $counts = FrmForm::get_count(); |
|
172 | - $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
170 | + $links = array(); |
|
171 | + $counts = FrmForm::get_count(); |
|
172 | + $form_type = isset( $_REQUEST['form_type'] ) ? sanitize_text_field( $_REQUEST['form_type'] ) : 'published'; |
|
173 | 173 | |
174 | - foreach ( $statuses as $status => $name ) { |
|
174 | + foreach ( $statuses as $status => $name ) { |
|
175 | 175 | |
176 | - if ( $status == $form_type ) { |
|
177 | - $class = ' class="current"'; |
|
178 | - } else { |
|
179 | - $class = ''; |
|
180 | - } |
|
176 | + if ( $status == $form_type ) { |
|
177 | + $class = ' class="current"'; |
|
178 | + } else { |
|
179 | + $class = ''; |
|
180 | + } |
|
181 | 181 | |
182 | - if ( $counts->{$status} || 'published' == $status ) { |
|
182 | + if ( $counts->{$status} || 'published' == $status ) { |
|
183 | 183 | $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | - unset($status, $name); |
|
187 | - } |
|
186 | + unset($status, $name); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | return $links; |
190 | 190 | } |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | public function single_row( $item, $style = '' ) { |
203 | - global $frm_vars, $mode; |
|
203 | + global $frm_vars, $mode; |
|
204 | 204 | |
205 | 205 | // Set up the hover actions for this user |
206 | 206 | $actions = array(); |
207 | 207 | $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
208 | 208 | $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id; |
209 | 209 | |
210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
210 | + $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
211 | 211 | |
212 | - $action_links = $this->row_actions( $actions ); |
|
212 | + $action_links = $this->row_actions( $actions ); |
|
213 | 213 | |
214 | 214 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
215 | 215 | $checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />'; |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | |
219 | 219 | list( $columns, $hidden ) = $this->get_column_info(); |
220 | 220 | |
221 | - $format = 'Y/m/d'; |
|
222 | - if ( 'list' != $mode ) { |
|
223 | - $format .= ' \<\b\r \/\> g:i:s a'; |
|
221 | + $format = 'Y/m/d'; |
|
222 | + if ( 'list' != $mode ) { |
|
223 | + $format .= ' \<\b\r \/\> g:i:s a'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | $style = ''; |
230 | 230 | if ( in_array( $column_name, $hidden ) ) { |
231 | - $class .= ' frm_hidden'; |
|
231 | + $class .= ' frm_hidden'; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | $class = 'class="' . esc_attr( $class ) . '"'; |
@@ -241,41 +241,41 @@ discard block |
||
241 | 241 | break; |
242 | 242 | case 'id': |
243 | 243 | case 'form_key': |
244 | - $val = $item->{$column_name}; |
|
245 | - break; |
|
244 | + $val = $item->{$column_name}; |
|
245 | + break; |
|
246 | 246 | case 'name': |
247 | - $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
248 | - $val .= $action_links; |
|
247 | + $val = $this->get_form_name( $item, $actions, $edit_link, $mode ); |
|
248 | + $val .= $action_links; |
|
249 | 249 | |
250 | - break; |
|
250 | + break; |
|
251 | 251 | case 'created_at': |
252 | - $date = date($format, strtotime($item->created_at)); |
|
252 | + $date = date($format, strtotime($item->created_at)); |
|
253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
254 | 254 | break; |
255 | 255 | case 'shortcode': |
256 | 256 | $val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>'; |
257 | - if ( 'excerpt' == $mode ) { |
|
257 | + if ( 'excerpt' == $mode ) { |
|
258 | 258 | $val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />'; |
259 | - } |
|
260 | - break; |
|
261 | - case 'entries': |
|
259 | + } |
|
260 | + break; |
|
261 | + case 'entries': |
|
262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
263 | 263 | $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>'; |
264 | - } else { |
|
265 | - $text = FrmEntry::getRecordCount($item->id); |
|
264 | + } else { |
|
265 | + $text = FrmEntry::getRecordCount($item->id); |
|
266 | 266 | $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
267 | - unset($text); |
|
268 | - } |
|
269 | - break; |
|
270 | - case 'type': |
|
271 | - $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
272 | - break; |
|
267 | + unset($text); |
|
268 | + } |
|
269 | + break; |
|
270 | + case 'type': |
|
271 | + $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' ); |
|
272 | + break; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | if ( isset($val) ) { |
276 | - $r .= "<td $attributes>"; |
|
277 | - $r .= $val; |
|
278 | - $r .= '</td>'; |
|
276 | + $r .= "<td $attributes>"; |
|
277 | + $r .= $val; |
|
278 | + $r .= '</td>'; |
|
279 | 279 | } |
280 | 280 | unset($val); |
281 | 281 | } |
@@ -284,38 +284,38 @@ discard block |
||
284 | 284 | return $r; |
285 | 285 | } |
286 | 286 | |
287 | - /** |
|
288 | - * @param string $edit_link |
|
289 | - * @param string $duplicate_link |
|
290 | - */ |
|
291 | - private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
287 | + /** |
|
288 | + * @param string $edit_link |
|
289 | + * @param string $duplicate_link |
|
290 | + */ |
|
291 | + private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
|
292 | 292 | if ( 'trash' == $this->status ) { |
293 | 293 | if ( current_user_can('frm_edit_forms') ) { |
294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
295 | 295 | } |
296 | 296 | |
297 | - if ( current_user_can('frm_delete_forms') ) { |
|
297 | + if ( current_user_can('frm_delete_forms') ) { |
|
298 | 298 | $trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ); |
299 | 299 | $actions['trash'] = '<a href="' . esc_url( $trash_url ) .'" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
300 | - } |
|
301 | - return; |
|
300 | + } |
|
301 | + return; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | if ( current_user_can('frm_edit_forms') ) { |
305 | - if ( ! $item->is_template || ! $item->default_template ) { |
|
305 | + if ( ! $item->is_template || ! $item->default_template ) { |
|
306 | 306 | $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
307 | - } |
|
307 | + } |
|
308 | 308 | |
309 | - if ( $item->is_template ) { |
|
309 | + if ( $item->is_template ) { |
|
310 | 310 | $actions['frm_duplicate'] = '<a href="'. esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Create Form from Template', 'formidable' ) . '</a>'; |
311 | - } else { |
|
311 | + } else { |
|
312 | 312 | $actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
313 | 313 | |
314 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
314 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
315 | 315 | $actions['duplicate'] = '<a href="' . esc_url( wp_nonce_url( $duplicate_link ) ) . '">' . __( 'Duplicate', 'formidable' ) . '</a>'; |
316 | - } |
|
317 | - } |
|
318 | - } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | 320 | $actions['trash'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
321 | 321 | if ( empty( $actions['trash'] ) ) { |
@@ -324,52 +324,52 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
327 | - } |
|
327 | + } |
|
328 | 328 | |
329 | - /** |
|
330 | - * @param string $edit_link |
|
331 | - */ |
|
329 | + /** |
|
330 | + * @param string $edit_link |
|
331 | + */ |
|
332 | 332 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
333 | - $form_name = $item->name; |
|
334 | - if ( trim($form_name) == '' ) { |
|
335 | - $form_name = __( '(no title)'); |
|
336 | - } |
|
333 | + $form_name = $item->name; |
|
334 | + if ( trim($form_name) == '' ) { |
|
335 | + $form_name = __( '(no title)'); |
|
336 | + } |
|
337 | 337 | $form_name = FrmAppHelper::kses( $form_name ); |
338 | 338 | if ( 'excerpt' != $mode ) { |
339 | 339 | $form_name = FrmAppHelper::truncate( $form_name, 50 ); |
340 | 340 | } |
341 | 341 | |
342 | - $val = '<strong>'; |
|
343 | - if ( 'trash' == $this->status ) { |
|
344 | - $val .= $form_name; |
|
345 | - } else { |
|
342 | + $val = '<strong>'; |
|
343 | + if ( 'trash' == $this->status ) { |
|
344 | + $val .= $form_name; |
|
345 | + } else { |
|
346 | 346 | $val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> '; |
347 | - } |
|
347 | + } |
|
348 | 348 | |
349 | - $this->add_draft_label( $item, $val ); |
|
350 | - $val .= '</strong>'; |
|
349 | + $this->add_draft_label( $item, $val ); |
|
350 | + $val .= '</strong>'; |
|
351 | 351 | |
352 | - $this->add_form_description( $item, $val ); |
|
352 | + $this->add_form_description( $item, $val ); |
|
353 | 353 | |
354 | - return $val; |
|
355 | - } |
|
354 | + return $val; |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * @param string $val |
|
359 | - */ |
|
360 | - private function add_draft_label( $item, &$val ) { |
|
361 | - if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
357 | + /** |
|
358 | + * @param string $val |
|
359 | + */ |
|
360 | + private function add_draft_label( $item, &$val ) { |
|
361 | + if ( 'draft' == $item->status && 'draft' != $this->status ) { |
|
362 | 362 | $val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>'; |
363 | - } |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * @param string $val |
|
368 | - */ |
|
369 | - private function add_form_description( $item, &$val ) { |
|
370 | - global $mode; |
|
371 | - if ( 'excerpt' == $mode ) { |
|
372 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
373 | - } |
|
374 | - } |
|
363 | + } |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * @param string $val |
|
368 | + */ |
|
369 | + private function add_form_description( $item, &$val ) { |
|
370 | + global $mode; |
|
371 | + if ( 'excerpt' == $mode ) { |
|
372 | + $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
373 | + } |
|
374 | + } |
|
375 | 375 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $page = $this->get_pagenum(); |
27 | 27 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' ); |
28 | 28 | |
29 | - $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : (( $page - 1 ) * $per_page); |
|
29 | + $start = ( isset( $_REQUEST['start'] ) ) ? $_REQUEST['start'] : ( ( $page - 1 ) * $per_page ); |
|
30 | 30 | |
31 | 31 | $s_query = array(); |
32 | 32 | $s_query[] = array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 1 ); |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | break; |
49 | 49 | } |
50 | 50 | |
51 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
51 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
52 | 52 | if ( $s != '' ) { |
53 | - preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
|
54 | - $search_terms = array_map('trim', $matches[0]); |
|
53 | + preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches ); |
|
54 | + $search_terms = array_map( 'trim', $matches[0] ); |
|
55 | 55 | foreach ( (array) $search_terms as $term ) { |
56 | 56 | $s_query[] = array( |
57 | 57 | 'or' => true, 'name LIKE' => $term, 'description LIKE' => $term, 'created_at LIKE' => $term, |
58 | 58 | ); |
59 | - unset($term); |
|
59 | + unset( $term ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | _e( 'No Templates Found.', 'formidable' ) ?> |
75 | 75 | <br/><br/><?php _e( 'To add a new template:', 'formidable' ) ?> |
76 | 76 | <ol><li><?php printf( __( 'Create a new %1$sform%2$s.', 'formidable' ), '<a href="' . esc_url( admin_url( 'admin?page=formidable&frm_action=new' ) ) . '"', '</a>' ) ?></li> |
77 | - <li><?php printf(__( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>') ?></li> |
|
77 | + <li><?php printf( __( 'After your form is created, go to Formidable -> %1$sForms%2$s.', 'formidable' ), '<a href="?page=formidable">', '</a>' ) ?></li> |
|
78 | 78 | <li><?php _e( 'Place your mouse over the name of the form you just created, and click the "Create Template" link.', 'formidable' ) ?></li> |
79 | 79 | </ol> |
80 | 80 | <?php } else { |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | if ( 'trash' == $this->status ) { |
94 | - if ( current_user_can('frm_edit_forms') ) { |
|
94 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
95 | 95 | $actions['bulk_untrash'] = __( 'Restore', 'formidable' ); |
96 | 96 | } |
97 | 97 | |
98 | - if ( current_user_can('frm_delete_forms') ) { |
|
98 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
99 | 99 | $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' ); |
100 | 100 | } |
101 | - } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) { |
|
101 | + } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) { |
|
102 | 102 | $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' ); |
103 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
104 | - $actions['bulk_delete'] = __( 'Delete'); |
|
103 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
104 | + $actions['bulk_delete'] = __( 'Delete' ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $actions; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) { |
|
115 | + if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) { |
|
116 | 116 | ?> |
117 | 117 | <div class="alignleft actions frm_visible_overflow"> |
118 | 118 | <?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
129 | 129 | $forms = FrmForm::get_published_forms( $where ); |
130 | 130 | |
131 | - $base = admin_url('admin.php?page=formidable&form_type=template'); |
|
131 | + $base = admin_url( 'admin.php?page=formidable&form_type=template' ); |
|
132 | 132 | $args = array( |
133 | 133 | 'frm_action' => 'duplicate', |
134 | 134 | 'template' => true, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $args['id'] = $form->id; ?> |
149 | 149 | <li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li> |
150 | 150 | <?php |
151 | - unset($form); |
|
151 | + unset( $form ); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | ?> |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | } |
181 | 181 | |
182 | 182 | if ( $counts->{$status} || 'published' == $status ) { |
183 | - $links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
183 | + $links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>'; |
|
184 | 184 | } |
185 | 185 | |
186 | - unset($status, $name); |
|
186 | + unset( $status, $name ); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $links; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $edit_link = '?page=formidable&frm_action=edit&id=' . $item->id; |
208 | 208 | $duplicate_link = '?page=formidable&frm_action=duplicate&id=' . $item->id; |
209 | 209 | |
210 | - $this->get_actions($actions, $item, $edit_link, $duplicate_link); |
|
210 | + $this->get_actions( $actions, $item, $edit_link, $duplicate_link ); |
|
211 | 211 | |
212 | 212 | $action_links = $this->row_actions( $actions ); |
213 | 213 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | break; |
251 | 251 | case 'created_at': |
252 | - $date = date($format, strtotime($item->created_at)); |
|
252 | + $date = date( $format, strtotime( $item->created_at ) ); |
|
253 | 253 | $val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>'; |
254 | 254 | break; |
255 | 255 | case 'shortcode': |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | break; |
261 | 261 | case 'entries': |
262 | 262 | if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) { |
263 | - $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Entries are not being saved', 'formidable' ) . '"></i>'; |
|
263 | + $val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Entries are not being saved', 'formidable' ) . '"></i>'; |
|
264 | 264 | } else { |
265 | - $text = FrmEntry::getRecordCount($item->id); |
|
266 | - $val = current_user_can('frm_view_entries') ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
|
267 | - unset($text); |
|
265 | + $text = FrmEntry::getRecordCount( $item->id ); |
|
266 | + $val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text; |
|
267 | + unset( $text ); |
|
268 | 268 | } |
269 | 269 | break; |
270 | 270 | case 'type': |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | break; |
273 | 273 | } |
274 | 274 | |
275 | - if ( isset($val) ) { |
|
275 | + if ( isset( $val ) ) { |
|
276 | 276 | $r .= "<td $attributes>"; |
277 | 277 | $r .= $val; |
278 | 278 | $r .= '</td>'; |
279 | 279 | } |
280 | - unset($val); |
|
280 | + unset( $val ); |
|
281 | 281 | } |
282 | 282 | $r .= '</tr>'; |
283 | 283 | |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | */ |
291 | 291 | private function get_actions( &$actions, $item, $edit_link, $duplicate_link ) { |
292 | 292 | if ( 'trash' == $this->status ) { |
293 | - if ( current_user_can('frm_edit_forms') ) { |
|
293 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
294 | 294 | $actions['restore'] = FrmFormsHelper::delete_trash_link( $item->id, $item->status, 'short' ); |
295 | 295 | } |
296 | 296 | |
297 | - if ( current_user_can('frm_delete_forms') ) { |
|
297 | + if ( current_user_can( 'frm_delete_forms' ) ) { |
|
298 | 298 | $trash_url = wp_nonce_url( '?page=formidable&form_status=trash&frm_action=destroy&id=' . $item->id, 'destroy_form_' . $item->id ); |
299 | 299 | $actions['trash'] = '<a href="' . esc_url( $trash_url ) . '" class="submitdelete" onclick="return confirm(\'' . __( 'Are you sure you want to permanently delete that?', 'formidable' ) . '\')">' . __( 'Delete Permanently' ) . '</a>'; |
300 | 300 | } |
301 | 301 | return; |
302 | 302 | } |
303 | 303 | |
304 | - if ( current_user_can('frm_edit_forms') ) { |
|
304 | + if ( current_user_can( 'frm_edit_forms' ) ) { |
|
305 | 305 | if ( ! $item->is_template || ! $item->default_template ) { |
306 | 306 | $actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>'; |
307 | 307 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | unset( $actions['trash'] ); |
324 | 324 | } |
325 | 325 | |
326 | - $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>'; |
|
326 | + $actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>'; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) { |
333 | 333 | $form_name = $item->name; |
334 | - if ( trim($form_name) == '' ) { |
|
335 | - $form_name = __( '(no title)'); |
|
334 | + if ( trim( $form_name ) == '' ) { |
|
335 | + $form_name = __( '(no title)' ); |
|
336 | 336 | } |
337 | 337 | $form_name = FrmAppHelper::kses( $form_name ); |
338 | 338 | if ( 'excerpt' != $mode ) { |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | private function add_form_description( $item, &$val ) { |
370 | 370 | global $mode; |
371 | 371 | if ( 'excerpt' == $mode ) { |
372 | - $val .= FrmAppHelper::truncate(strip_tags($item->description), 50); |
|
372 | + $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 ); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | } |
@@ -6,46 +6,46 @@ discard block |
||
6 | 6 | protected $field; |
7 | 7 | |
8 | 8 | public function prepare_items() { |
9 | - global $wpdb, $per_page; |
|
9 | + global $wpdb, $per_page; |
|
10 | 10 | |
11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
12 | 12 | |
13 | - $form_id = $this->params['form']; |
|
14 | - if ( ! $form_id ) { |
|
15 | - $this->items = array(); |
|
16 | - $this->set_pagination_args( array( |
|
17 | - 'total_items' => 0, |
|
13 | + $form_id = $this->params['form']; |
|
14 | + if ( ! $form_id ) { |
|
15 | + $this->items = array(); |
|
16 | + $this->set_pagination_args( array( |
|
17 | + 'total_items' => 0, |
|
18 | 18 | 'per_page' => $per_page, |
19 | - ) ); |
|
20 | - return; |
|
21 | - } |
|
19 | + ) ); |
|
20 | + return; |
|
21 | + } |
|
22 | 22 | |
23 | 23 | $default_orderby = 'id'; |
24 | 24 | $default_order = 'DESC'; |
25 | 25 | |
26 | - $s_query = array( 'it.form_id' => $form_id ); |
|
26 | + $s_query = array( 'it.form_id' => $form_id ); |
|
27 | 27 | |
28 | 28 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
29 | 29 | |
30 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | - } |
|
30 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
31 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
33 | + } |
|
34 | 34 | |
35 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
37 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
35 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
36 | + if ( strpos($orderby, 'meta') !== false ) { |
|
37 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
42 | 42 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
43 | 43 | |
44 | - $page = $this->get_pagenum(); |
|
44 | + $page = $this->get_pagenum(); |
|
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
48 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | public function no_items() { |
57 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | - if ( ! empty($s) ) { |
|
59 | - _e( 'No Entries Found', 'formidable' ); |
|
60 | - return; |
|
61 | - } |
|
62 | - |
|
63 | - $form_id = $form = $this->params['form']; |
|
64 | - if ( $form_id ) { |
|
65 | - $form = FrmForm::getOne($form_id); |
|
66 | - } |
|
67 | - $colspan = $this->get_column_count(); |
|
57 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
58 | + if ( ! empty($s) ) { |
|
59 | + _e( 'No Entries Found', 'formidable' ); |
|
60 | + return; |
|
61 | + } |
|
62 | + |
|
63 | + $form_id = $form = $this->params['form']; |
|
64 | + if ( $form_id ) { |
|
65 | + $form = FrmForm::getOne($form_id); |
|
66 | + } |
|
67 | + $colspan = $this->get_column_count(); |
|
68 | 68 | |
69 | 69 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
70 | 70 | } |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Gets the name of the primary column in the Entries screen |
|
78 | - * |
|
79 | - * @since 2.0.14 |
|
80 | - * |
|
81 | - * @return string $primary_column |
|
82 | - */ |
|
77 | + * Gets the name of the primary column in the Entries screen |
|
78 | + * |
|
79 | + * @since 2.0.14 |
|
80 | + * |
|
81 | + * @return string $primary_column |
|
82 | + */ |
|
83 | 83 | protected function get_primary_column_name() { |
84 | 84 | $columns = get_column_headers( $this->screen ); |
85 | 85 | $hidden = get_hidden_columns( $this->screen ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | $this->get_actions( $actions, $item, $view_link ); |
105 | 105 | |
106 | - $action_links = $this->row_actions( $actions ); |
|
106 | + $action_links = $this->row_actions( $actions ); |
|
107 | 107 | |
108 | 108 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
109 | 109 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | 113 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
114 | - $action_col = false; |
|
114 | + $action_col = false; |
|
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
117 | 117 | $class = $column_name . ' column-' . $column_name; |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | if ( in_array( $column_name, $hidden ) ) { |
124 | 124 | $class .= ' frm_hidden'; |
125 | 125 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
126 | - $action_col = $column_name; |
|
127 | - } |
|
126 | + $action_col = $column_name; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | 130 | unset($class); |
@@ -140,30 +140,30 @@ discard block |
||
140 | 140 | case 'ip': |
141 | 141 | case 'id': |
142 | 142 | case 'item_key': |
143 | - $val = $item->{$col_name}; |
|
144 | - break; |
|
143 | + $val = $item->{$col_name}; |
|
144 | + break; |
|
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | - break; |
|
147 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
148 | + break; |
|
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | - break; |
|
155 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
156 | + break; |
|
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | - break; |
|
158 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
159 | + break; |
|
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | - break; |
|
161 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
162 | + break; |
|
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
165 | - $val = $user->user_login; |
|
166 | - break; |
|
164 | + $user = get_userdata($item->user_id); |
|
165 | + $val = $user->user_login; |
|
166 | + break; |
|
167 | 167 | default: |
168 | 168 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
169 | 169 | if ( $val === false ) { |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | if ( isset( $val ) ) { |
176 | - $r .= "<td $attributes>"; |
|
176 | + $r .= "<td $attributes>"; |
|
177 | 177 | if ( $column_name == $action_col ) { |
178 | 178 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
179 | 179 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
180 | - $r .= $action_links; |
|
180 | + $r .= $action_links; |
|
181 | 181 | } else { |
182 | - $r .= $val; |
|
183 | - } |
|
184 | - $r .= '</td>'; |
|
182 | + $r .= $val; |
|
183 | + } |
|
184 | + $r .= '</td>'; |
|
185 | 185 | } |
186 | 186 | unset($val); |
187 | 187 | } |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | return $r; |
191 | 191 | } |
192 | 192 | |
193 | - /** |
|
194 | - * @param string $view_link |
|
195 | - */ |
|
196 | - private function get_actions( &$actions, $item, $view_link ) { |
|
193 | + /** |
|
194 | + * @param string $view_link |
|
195 | + */ |
|
196 | + private function get_actions( &$actions, $item, $view_link ) { |
|
197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
199 | + if ( current_user_can('frm_delete_entries') ) { |
|
200 | 200 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | - } |
|
204 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
205 | + } |
|
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
208 | 208 | $col_name = $this->column_name; |
@@ -25,15 +25,15 @@ discard block |
||
25 | 25 | |
26 | 26 | $s_query = array( 'it.form_id' => $form_id ); |
27 | 27 | |
28 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
28 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
29 | 29 | |
30 | 30 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
31 | 31 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
32 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid); |
|
32 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
36 | - if ( strpos($orderby, 'meta') !== false ) { |
|
36 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
37 | 37 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
38 | 38 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
46 | 46 | |
47 | 47 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
48 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
48 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
49 | 49 | |
50 | 50 | $this->set_pagination_args( array( |
51 | 51 | 'total_items' => $total_items, |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | |
56 | 56 | public function no_items() { |
57 | 57 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
58 | - if ( ! empty($s) ) { |
|
58 | + if ( ! empty( $s ) ) { |
|
59 | 59 | _e( 'No Entries Found', 'formidable' ); |
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | $form_id = $form = $this->params['form']; |
64 | 64 | if ( $form_id ) { |
65 | - $form = FrmForm::getOne($form_id); |
|
65 | + $form = FrmForm::getOne( $form_id ); |
|
66 | 66 | } |
67 | 67 | $colspan = $this->get_column_count(); |
68 | 68 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $r = "<tr id='item-action-{$item->id}'$style>"; |
112 | 112 | |
113 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
113 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
114 | 114 | $action_col = false; |
115 | 115 | |
116 | 116 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
130 | - unset($class); |
|
130 | + unset( $class ); |
|
131 | 131 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
132 | 132 | |
133 | 133 | $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
@@ -144,24 +144,24 @@ discard block |
||
144 | 144 | break; |
145 | 145 | case 'name': |
146 | 146 | case 'description': |
147 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
147 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
148 | 148 | break; |
149 | 149 | case 'created_at': |
150 | 150 | case 'updated_at': |
151 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
151 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
152 | 152 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
153 | 153 | break; |
154 | 154 | case 'is_draft': |
155 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
155 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
156 | 156 | break; |
157 | 157 | case 'form_id': |
158 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
158 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
159 | 159 | break; |
160 | 160 | case 'post_id': |
161 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
161 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
162 | 162 | break; |
163 | 163 | case 'user_id': |
164 | - $user = get_userdata($item->user_id); |
|
164 | + $user = get_userdata( $item->user_id ); |
|
165 | 165 | $val = $user->user_login; |
166 | 166 | break; |
167 | 167 | default: |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | $r .= '</td>'; |
185 | 185 | } |
186 | - unset($val); |
|
186 | + unset( $val ); |
|
187 | 187 | } |
188 | 188 | $r .= '</tr>'; |
189 | 189 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | private function get_actions( &$actions, $item, $view_link ) { |
197 | 197 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
198 | 198 | |
199 | - if ( current_user_can('frm_delete_entries') ) { |
|
199 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
200 | 200 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
201 | 201 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
202 | 202 | } |
203 | 203 | |
204 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
204 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | private function get_column_value( $item, &$val ) { |
@@ -1,67 +1,67 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStylesHelper { |
3 | 3 | |
4 | - public static function jquery_themes() { |
|
5 | - $themes = array( |
|
6 | - 'ui-lightness' => 'UI Lightness', |
|
7 | - 'ui-darkness' => 'UI Darkness', |
|
8 | - 'smoothness' => 'Smoothness', |
|
9 | - 'start' => 'Start', |
|
10 | - 'redmond' => 'Redmond', |
|
11 | - 'sunny' => 'Sunny', |
|
12 | - 'overcast' => 'Overcast', |
|
13 | - 'le-frog' => 'Le Frog', |
|
14 | - 'flick' => 'Flick', |
|
4 | + public static function jquery_themes() { |
|
5 | + $themes = array( |
|
6 | + 'ui-lightness' => 'UI Lightness', |
|
7 | + 'ui-darkness' => 'UI Darkness', |
|
8 | + 'smoothness' => 'Smoothness', |
|
9 | + 'start' => 'Start', |
|
10 | + 'redmond' => 'Redmond', |
|
11 | + 'sunny' => 'Sunny', |
|
12 | + 'overcast' => 'Overcast', |
|
13 | + 'le-frog' => 'Le Frog', |
|
14 | + 'flick' => 'Flick', |
|
15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
16 | - 'eggplant' => 'Eggplant', |
|
17 | - 'dark-hive' => 'Dark Hive', |
|
18 | - 'cupertino' => 'Cupertino', |
|
19 | - 'south-street' => 'South Street', |
|
20 | - 'blitzer' => 'Blitzer', |
|
21 | - 'humanity' => 'Humanity', |
|
22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
23 | - 'excite-bike' => 'Excite Bike', |
|
24 | - 'vader' => 'Vader', |
|
25 | - 'dot-luv' => 'Dot Luv', |
|
26 | - 'mint-choc' => 'Mint Choc', |
|
27 | - 'black-tie' => 'Black Tie', |
|
28 | - 'trontastic' => 'Trontastic', |
|
29 | - 'swanky-purse' => 'Swanky Purse', |
|
30 | - ); |
|
31 | - |
|
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | - return $themes; |
|
34 | - } |
|
16 | + 'eggplant' => 'Eggplant', |
|
17 | + 'dark-hive' => 'Dark Hive', |
|
18 | + 'cupertino' => 'Cupertino', |
|
19 | + 'south-street' => 'South Street', |
|
20 | + 'blitzer' => 'Blitzer', |
|
21 | + 'humanity' => 'Humanity', |
|
22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
23 | + 'excite-bike' => 'Excite Bike', |
|
24 | + 'vader' => 'Vader', |
|
25 | + 'dot-luv' => 'Dot Luv', |
|
26 | + 'mint-choc' => 'Mint Choc', |
|
27 | + 'black-tie' => 'Black Tie', |
|
28 | + 'trontastic' => 'Trontastic', |
|
29 | + 'swanky-purse' => 'Swanky Purse', |
|
30 | + ); |
|
31 | + |
|
32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | + return $themes; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public static function jquery_css_url( $theme_css ) { |
37 | - if ( $theme_css == -1 ) { |
|
38 | - return; |
|
39 | - } |
|
40 | - |
|
41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | - $css_file = $theme_css; |
|
45 | - } else { |
|
46 | - $uploads = self::get_upload_base(); |
|
37 | + if ( $theme_css == -1 ) { |
|
38 | + return; |
|
39 | + } |
|
40 | + |
|
41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | + $css_file = $theme_css; |
|
45 | + } else { |
|
46 | + $uploads = self::get_upload_base(); |
|
47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
50 | - } else { |
|
48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
50 | + } else { |
|
51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
52 | - } |
|
53 | - } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - return $css_file; |
|
56 | - } |
|
55 | + return $css_file; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function enqueue_jquery_css() { |
|
58 | + public static function enqueue_jquery_css() { |
|
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | - if ( $theme_css != -1 ) { |
|
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | - } |
|
64 | - } |
|
61 | + if ( $theme_css != -1 ) { |
|
62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function get_form_for_page() { |
67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | return $form_id; |
78 | 78 | } |
79 | 79 | |
80 | - public static function get_upload_base() { |
|
81 | - $uploads = wp_upload_dir(); |
|
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | - } |
|
80 | + public static function get_upload_base() { |
|
81 | + $uploads = wp_upload_dir(); |
|
82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | + } |
|
85 | 85 | |
86 | - return $uploads; |
|
87 | - } |
|
86 | + return $uploads; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | public static function style_menu( $active = '' ) { |
90 | 90 | ?> |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
95 | 95 | </h2> |
96 | 96 | <?php |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - public static function minus_icons() { |
|
100 | - return array( |
|
99 | + public static function minus_icons() { |
|
100 | + return array( |
|
101 | 101 | 0 => array( '-' => '62e', '+' => '62f' ), |
102 | 102 | 1 => array( '-' => '600', '+' => '602' ), |
103 | 103 | 2 => array( '-' => '604', '+' => '603' ), |
104 | 104 | 3 => array( '-' => '633', '+' => '632' ), |
105 | 105 | 4 => array( '-' => '613', '+' => '60f' ), |
106 | - ); |
|
107 | - } |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - public static function arrow_icons() { |
|
110 | - $minus_icons = self::minus_icons(); |
|
109 | + public static function arrow_icons() { |
|
110 | + $minus_icons = self::minus_icons(); |
|
111 | 111 | |
112 | - return array( |
|
112 | + return array( |
|
113 | 113 | 6 => array( '-' => '62d', '+' => '62a' ), |
114 | 114 | 0 => array( '-' => '60d', '+' => '609' ), |
115 | 115 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | 3 => array( '-' => '62b', '+' => '628' ), |
118 | 118 | 4 => array( '-' => '62c', '+' => '629' ), |
119 | 119 | 5 => array( '-' => '635', '+' => '634' ), |
120 | - 'p0' => $minus_icons[0], |
|
121 | - 'p1' => $minus_icons[1], |
|
122 | - 'p2' => $minus_icons[2], |
|
123 | - 'p3' => $minus_icons[3], |
|
124 | - 'p4' => $minus_icons[4], |
|
125 | - ); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @since 2.0 |
|
130 | - * @return The class for this icon |
|
131 | - */ |
|
120 | + 'p0' => $minus_icons[0], |
|
121 | + 'p1' => $minus_icons[1], |
|
122 | + 'p2' => $minus_icons[2], |
|
123 | + 'p3' => $minus_icons[3], |
|
124 | + 'p4' => $minus_icons[4], |
|
125 | + ); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @since 2.0 |
|
130 | + * @return The class for this icon |
|
131 | + */ |
|
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | - //frm_arrowup6_icon |
|
133 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | + //frm_arrowup6_icon |
|
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | 136 | $class = 'frm_arrow' . $arrow[ $icon ]; |
137 | - } else { |
|
138 | - //frm_minus1_icon |
|
139 | - $key = str_replace('p', '', $key); |
|
137 | + } else { |
|
138 | + //frm_minus1_icon |
|
139 | + $key = str_replace('p', '', $key); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | 141 | $class = 'frm_' . $plus[ $icon ]; |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - if ( $key ) { |
|
145 | - $class .= $key; |
|
146 | - } |
|
147 | - $class .= '_icon'; |
|
144 | + if ( $key ) { |
|
145 | + $class .= $key; |
|
146 | + } |
|
147 | + $class .= '_icon'; |
|
148 | 148 | |
149 | - return $class; |
|
150 | - } |
|
149 | + return $class; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
153 | 153 | $function_name = $type . '_icons'; |
154 | 154 | $icons = self::$function_name(); |
155 | 155 | unset( $function_name ); |
156 | 156 | |
157 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
157 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
158 | 158 | ?> |
159 | 159 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -187,22 +187,22 @@ discard block |
||
187 | 187 | </ul> |
188 | 188 | </div> |
189 | 189 | <?php |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace('#', '', $hex); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
195 | + if ( strlen($hex) == 3 ) { |
|
196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
199 | - } else { |
|
199 | + } else { |
|
200 | 200 | $r = hexdec( substr( $hex, 0, 2 ) ); |
201 | 201 | $g = hexdec( substr( $hex, 2, 2 ) ); |
202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
203 | - } |
|
203 | + } |
|
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | - //return $rgb; // returns an array with the rgb values |
|
207 | - } |
|
205 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | + //return $rgb; // returns an array with the rgb values |
|
207 | + } |
|
208 | 208 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | 'swanky-purse' => 'Swanky Purse', |
30 | 30 | ); |
31 | 31 | |
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
33 | 33 | return $themes; |
34 | 34 | } |
35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
44 | 44 | $css_file = $theme_css; |
45 | 45 | } else { |
46 | 46 | $uploads = self::get_upload_base(); |
47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
50 | 50 | } else { |
51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | 61 | if ( $theme_css != -1 ) { |
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | public static function get_upload_base() { |
81 | 81 | $uploads = wp_upload_dir(); |
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | <h2 class="nav-tab-wrapper"> |
92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
95 | 95 | </h2> |
96 | 96 | <?php |
97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @return The class for this icon |
131 | 131 | */ |
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
134 | 134 | //frm_arrowup6_icon |
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
137 | 137 | } else { |
138 | 138 | //frm_minus1_icon |
139 | - $key = str_replace('p', '', $key); |
|
139 | + $key = str_replace( 'p', '', $key ); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | - $class = 'frm_' . $plus[ $icon ]; |
|
141 | + $class = 'frm_' . $plus[$icon]; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | if ( $key ) { |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
158 | 158 | ?> |
159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
162 | 162 | <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
163 | 163 | </option> |
164 | 164 | <?php } ?> |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | |
167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
171 | 171 | <b class="caret"></b> |
172 | 172 | </button> |
173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace( '#', '', $hex ); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
195 | + if ( strlen( $hex ) == 3 ) { |
|
196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
203 | 203 | } |
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
206 | 206 | //return $rgb; // returns an array with the rgb values |
207 | 207 | } |
208 | 208 | } |