@@ -1,59 +1,59 @@ |
||
1 | 1 | <p> |
2 | - <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('center_form') ) ?>" id="frm_center_form" value="1" <?php checked($style->post_content['center_form'], 1) ?> /> |
|
2 | + <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'center_form' ) ) ?>" id="frm_center_form" value="1" <?php checked( $style->post_content['center_form'], 1 ) ?> /> |
|
3 | 3 | <?php _e( 'Center form on page', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will center your form on the page where it is published if the form width is less than the available width on the page.', 'formidable' ) ?>" ></span> |
4 | 4 | </label> |
5 | 5 | </p> |
6 | 6 | |
7 | 7 | <div class="field-group clearfix frm-first-row"> |
8 | 8 | <label><?php _e( 'Alignment', 'formidable' ) ?></label> |
9 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('form_align') ) ?>" id="frm_form_align"> |
|
10 | - <option value="left" <?php selected($style->post_content['form_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
11 | - <option value="right" <?php selected($style->post_content['form_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
12 | - <option value="center" <?php selected($style->post_content['form_align'], 'center') ?>><?php _e( 'center', 'formidable' ) ?></option> |
|
9 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'form_align' ) ) ?>" id="frm_form_align"> |
|
10 | + <option value="left" <?php selected( $style->post_content['form_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
11 | + <option value="right" <?php selected( $style->post_content['form_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
12 | + <option value="center" <?php selected( $style->post_content['form_align'], 'center' ) ?>><?php _e( 'center', 'formidable' ) ?></option> |
|
13 | 13 | </select> |
14 | 14 | </div> |
15 | 15 | |
16 | 16 | <div class="field-group clearfix frm-first-row"> |
17 | 17 | <label><?php _e( 'Max Width', 'formidable' ) ?></label> |
18 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_width') ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/> |
|
18 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_width' ) ) ?>" value="<?php echo esc_attr( $style->post_content['form_width'] ) ?>"/> |
|
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class="field-group clearfix frm-first-row"> |
22 | 22 | <label><?php _e( 'Background', 'formidable' ) ?></label> |
23 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_bg_color') ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" /> |
|
23 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_bg_color' ) ) ?>" id="frm_fieldset_bg_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_bg_color'] ) ?>" size="4" /> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | <div class="field-group field-group-border clearfix"> |
27 | 27 | <label><?php _e( 'Border', 'formidable' ) ?></label> |
28 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset') ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" /> |
|
28 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset' ) ) ?>" id="frm_fieldset" value="<?php echo esc_attr( $style->post_content['fieldset'] ) ?>" size="4" /> |
|
29 | 29 | </div> |
30 | 30 | |
31 | 31 | <div class="field-group clearfix"> |
32 | 32 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
33 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_color') ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" /> |
|
33 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_color' ) ) ?>" id="frm_fieldset_color" class="hex" value="<?php echo esc_attr( $style->post_content['fieldset_color'] ) ?>" /> |
|
34 | 34 | </div> |
35 | 35 | |
36 | 36 | <div class="field-group clearfix"> |
37 | 37 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
38 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('fieldset_padding') ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" /> |
|
38 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'fieldset_padding' ) ) ?>" id="frm_fieldset_padding" value="<?php echo esc_attr( $style->post_content['fieldset_padding'] ) ?>" size="4" /> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <div id="frm_gen_font_box" class="field-group clearfix"> |
42 | 42 | <label><?php _e( 'Font Family', 'formidable' ) ?></label> |
43 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font') ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>" class="frm_full_width" /> |
|
43 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font' ) ) ?>" id="frm_font" value="<?php echo esc_attr( $style->post_content['font'] ) ?>" class="frm_full_width" /> |
|
44 | 44 | </div> |
45 | 45 | |
46 | 46 | <div class="field-group clearfix frm-half"> |
47 | 47 | <label><?php _e( 'Direction', 'formidable' ) ?></label> |
48 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('direction') ) ?>" id="frm_direction"> |
|
49 | - <option value="ltr" <?php selected($style->post_content['direction'], 'ltr') ?>><?php _e( 'Left to Right', 'formidable' ) ?></option> |
|
50 | - <option value="rtl" <?php selected($style->post_content['direction'], 'rtl') ?>><?php _e( 'Right to Left', 'formidable' ) ?></option> |
|
48 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'direction' ) ) ?>" id="frm_direction"> |
|
49 | + <option value="ltr" <?php selected( $style->post_content['direction'], 'ltr' ) ?>><?php _e( 'Left to Right', 'formidable' ) ?></option> |
|
50 | + <option value="rtl" <?php selected( $style->post_content['direction'], 'rtl' ) ?>><?php _e( 'Right to Left', 'formidable' ) ?></option> |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | |
54 | 54 | <div class="clear"></div> |
55 | 55 | <p class="frm_no_bottom_margin"> |
56 | - <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name('important_style') ) ?>" id="frm_important_style" value="1" <?php checked($style->post_content['important_style'], 1) ?> /> |
|
56 | + <label><input type="checkbox" name="<?php echo esc_attr( $frm_style->get_field_name( 'important_style' ) ) ?>" id="frm_important_style" value="1" <?php checked( $style->post_content['important_style'], 1 ) ?> /> |
|
57 | 57 | <?php _e( 'Override theme styling', 'formidable' ) ?> <span class="frm_help frm_icon_font frm_tooltip_icon" title="<?php esc_attr_e( 'This will add !important to many of the lines in the Formidable styling to make sure it will be used.', 'formidable' ) ?>" ></span> |
58 | 58 | </label> |
59 | 59 | </p> |
@@ -121,6 +121,9 @@ |
||
121 | 121 | $stylesheet_urls['formidable'] = $url; |
122 | 122 | } |
123 | 123 | |
124 | + /** |
|
125 | + * @param string $version |
|
126 | + */ |
|
124 | 127 | private static function get_css_version( $css_key, $version ) { |
125 | 128 | if ( 'formidable' == $css_key ) { |
126 | 129 | $this_version = get_option( 'frm_last_style_update' ); |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmStylesController { |
4 | - public static $post_type = 'frm_styles'; |
|
5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
6 | - |
|
7 | - public static function load_pro_hooks() { |
|
8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | - FrmProStylesController::load_pro_hooks(); |
|
10 | - } |
|
11 | - } |
|
12 | - |
|
13 | - public static function register_post_types() { |
|
14 | - register_post_type( self::$post_type, array( |
|
15 | - 'label' => __( 'Styles', 'formidable' ), |
|
16 | - 'public' => false, |
|
17 | - 'show_ui' => false, |
|
18 | - 'capability_type' => 'page', |
|
4 | + public static $post_type = 'frm_styles'; |
|
5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
6 | + |
|
7 | + public static function load_pro_hooks() { |
|
8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
9 | + FrmProStylesController::load_pro_hooks(); |
|
10 | + } |
|
11 | + } |
|
12 | + |
|
13 | + public static function register_post_types() { |
|
14 | + register_post_type( self::$post_type, array( |
|
15 | + 'label' => __( 'Styles', 'formidable' ), |
|
16 | + 'public' => false, |
|
17 | + 'show_ui' => false, |
|
18 | + 'capability_type' => 'page', |
|
19 | 19 | 'capabilities' => array( |
20 | 20 | 'edit_post' => 'frm_change_settings', |
21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | 'delete_posts' => 'frm_change_settings', |
26 | 26 | 'read_private_posts' => 'read_private_posts', |
27 | 27 | ), |
28 | - 'supports' => array( |
|
28 | + 'supports' => array( |
|
29 | 29 | 'title', |
30 | - ), |
|
31 | - 'has_archive' => false, |
|
32 | - 'labels' => array( |
|
30 | + ), |
|
31 | + 'has_archive' => false, |
|
32 | + 'labels' => array( |
|
33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
39 | 39 | ), |
40 | - ) ); |
|
41 | - } |
|
40 | + ) ); |
|
41 | + } |
|
42 | 42 | |
43 | - public static function menu() { |
|
43 | + public static function menu() { |
|
44 | 44 | add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - public static function admin_init() { |
|
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | - return; |
|
50 | - } |
|
47 | + public static function admin_init() { |
|
48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - self::load_pro_hooks(); |
|
52 | + self::load_pro_hooks(); |
|
53 | 53 | |
54 | 54 | $style_tab = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
55 | 55 | if ( $style_tab == 'manage' || $style_tab == 'custom_css' ) { |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
60 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
61 | 61 | |
62 | - $version = FrmAppHelper::plugin_version(); |
|
62 | + $version = FrmAppHelper::plugin_version(); |
|
63 | 63 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
64 | 64 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version ); |
65 | 65 | |
66 | 66 | wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
67 | 67 | |
68 | - $style = apply_filters('frm_style_head', false); |
|
69 | - if ( $style ) { |
|
68 | + $style = apply_filters('frm_style_head', false); |
|
69 | + if ( $style ) { |
|
70 | 70 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
71 | - } |
|
72 | - } |
|
71 | + } |
|
72 | + } |
|
73 | 73 | |
74 | 74 | public static function enqueue_css( $register = 'enqueue' ) { |
75 | 75 | global $frm_vars; |
@@ -163,207 +163,207 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | public static function new_style( $return = '' ) { |
166 | - self::load_styler('default'); |
|
167 | - } |
|
166 | + self::load_styler('default'); |
|
167 | + } |
|
168 | 168 | |
169 | 169 | public static function duplicate() { |
170 | 170 | self::load_styler('default'); |
171 | 171 | } |
172 | 172 | |
173 | 173 | public static function edit( $style_id = false, $message = '' ) { |
174 | - if ( ! $style_id ) { |
|
174 | + if ( ! $style_id ) { |
|
175 | 175 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
176 | - if ( empty($style_id) ) { |
|
177 | - $style_id = 'default'; |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - if ( 'default' == $style_id ) { |
|
182 | - $style = 'default'; |
|
183 | - } else { |
|
184 | - $frm_style = new FrmStyle($style_id); |
|
185 | - $style = $frm_style->get_one(); |
|
186 | - $style = $style->ID; |
|
187 | - } |
|
188 | - |
|
189 | - self::load_styler($style, $message); |
|
190 | - } |
|
191 | - |
|
192 | - public static function save() { |
|
193 | - $frm_style = new FrmStyle(); |
|
194 | - $message = ''; |
|
176 | + if ( empty($style_id) ) { |
|
177 | + $style_id = 'default'; |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + if ( 'default' == $style_id ) { |
|
182 | + $style = 'default'; |
|
183 | + } else { |
|
184 | + $frm_style = new FrmStyle($style_id); |
|
185 | + $style = $frm_style->get_one(); |
|
186 | + $style = $style->ID; |
|
187 | + } |
|
188 | + |
|
189 | + self::load_styler($style, $message); |
|
190 | + } |
|
191 | + |
|
192 | + public static function save() { |
|
193 | + $frm_style = new FrmStyle(); |
|
194 | + $message = ''; |
|
195 | 195 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
196 | 196 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
197 | 197 | |
198 | 198 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
199 | - $id = $frm_style->update($post_id); |
|
200 | - if ( empty($post_id) && ! empty($id) ) { |
|
201 | - // set the post id to the new style so it will be loaded for editing |
|
202 | - $post_id = reset($id); |
|
203 | - } |
|
204 | - // include the CSS that includes this style |
|
199 | + $id = $frm_style->update($post_id); |
|
200 | + if ( empty($post_id) && ! empty($id) ) { |
|
201 | + // set the post id to the new style so it will be loaded for editing |
|
202 | + $post_id = reset($id); |
|
203 | + } |
|
204 | + // include the CSS that includes this style |
|
205 | 205 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
206 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
207 | - } |
|
206 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
207 | + } |
|
208 | 208 | |
209 | - return self::edit($post_id, $message); |
|
210 | - } |
|
209 | + return self::edit($post_id, $message); |
|
210 | + } |
|
211 | 211 | |
212 | 212 | public static function load_styler( $style, $message = '' ) { |
213 | - global $frm_settings; |
|
213 | + global $frm_settings; |
|
214 | 214 | |
215 | - $frm_style = new FrmStyle(); |
|
216 | - $styles = $frm_style->get_all(); |
|
215 | + $frm_style = new FrmStyle(); |
|
216 | + $styles = $frm_style->get_all(); |
|
217 | 217 | |
218 | - if ( is_numeric($style) ) { |
|
219 | - $style = $styles[ $style ]; |
|
220 | - } else if ( 'default' == $style ) { |
|
221 | - $style = $frm_style->get_default_style($styles); |
|
222 | - } |
|
218 | + if ( is_numeric($style) ) { |
|
219 | + $style = $styles[ $style ]; |
|
220 | + } else if ( 'default' == $style ) { |
|
221 | + $style = $frm_style->get_default_style($styles); |
|
222 | + } |
|
223 | 223 | |
224 | - self::add_meta_boxes(); |
|
224 | + self::add_meta_boxes(); |
|
225 | 225 | |
226 | 226 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @param string $message |
231 | 231 | * @param array|object $forms |
232 | 232 | */ |
233 | 233 | private static function manage( $message = '', $forms = array() ) { |
234 | - $frm_style = new FrmStyle(); |
|
235 | - $styles = $frm_style->get_all(); |
|
236 | - $default_style = $frm_style->get_default_style($styles); |
|
234 | + $frm_style = new FrmStyle(); |
|
235 | + $styles = $frm_style->get_all(); |
|
236 | + $default_style = $frm_style->get_default_style($styles); |
|
237 | 237 | |
238 | - if ( empty($forms) ) { |
|
239 | - $forms = FrmForm::get_published_forms(); |
|
240 | - } |
|
238 | + if ( empty($forms) ) { |
|
239 | + $forms = FrmForm::get_published_forms(); |
|
240 | + } |
|
241 | 241 | |
242 | 242 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | - private static function manage_styles() { |
|
245 | + private static function manage_styles() { |
|
246 | 246 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
247 | 247 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
248 | - return self::manage(); |
|
249 | - } |
|
248 | + return self::manage(); |
|
249 | + } |
|
250 | 250 | |
251 | - global $wpdb; |
|
251 | + global $wpdb; |
|
252 | 252 | |
253 | 253 | $forms = FrmForm::get_published_forms(); |
254 | - foreach ( $forms as $form ) { |
|
255 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
256 | - continue; |
|
257 | - } |
|
254 | + foreach ( $forms as $form ) { |
|
255 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
256 | + continue; |
|
257 | + } |
|
258 | 258 | |
259 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
259 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
260 | 260 | |
261 | 261 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
262 | - unset($form); |
|
263 | - } |
|
262 | + unset($form); |
|
263 | + } |
|
264 | 264 | |
265 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
266 | - return self::manage($message, $forms); |
|
267 | - } |
|
265 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
266 | + return self::manage($message, $forms); |
|
267 | + } |
|
268 | 268 | |
269 | - public static function custom_css( $message = '', $style = null ) { |
|
270 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
271 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
272 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
269 | + public static function custom_css( $message = '', $style = null ) { |
|
270 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
271 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
272 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
273 | 273 | |
274 | - if ( ! isset($style) ) { |
|
275 | - $frm_style = new FrmStyle(); |
|
276 | - $style = $frm_style->get_default_style(); |
|
277 | - } |
|
274 | + if ( ! isset($style) ) { |
|
275 | + $frm_style = new FrmStyle(); |
|
276 | + $style = $frm_style->get_default_style(); |
|
277 | + } |
|
278 | 278 | |
279 | 279 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - public static function save_css() { |
|
283 | - $frm_style = new FrmStyle(); |
|
282 | + public static function save_css() { |
|
283 | + $frm_style = new FrmStyle(); |
|
284 | 284 | |
285 | - $message = ''; |
|
285 | + $message = ''; |
|
286 | 286 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
287 | 287 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
288 | 288 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
289 | - $frm_style->update($post_id); |
|
290 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
291 | - } |
|
289 | + $frm_style->update($post_id); |
|
290 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
291 | + } |
|
292 | 292 | |
293 | - return self::custom_css($message); |
|
294 | - } |
|
293 | + return self::custom_css($message); |
|
294 | + } |
|
295 | 295 | |
296 | - public static function route() { |
|
296 | + public static function route() { |
|
297 | 297 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
298 | 298 | |
299 | - switch ( $action ) { |
|
300 | - case 'edit': |
|
301 | - case 'save': |
|
302 | - case 'manage': |
|
303 | - case 'manage_styles': |
|
304 | - case 'custom_css': |
|
305 | - case 'save_css': |
|
299 | + switch ( $action ) { |
|
300 | + case 'edit': |
|
301 | + case 'save': |
|
302 | + case 'manage': |
|
303 | + case 'manage_styles': |
|
304 | + case 'custom_css': |
|
305 | + case 'save_css': |
|
306 | 306 | return self::$action(); |
307 | - default: |
|
308 | - do_action( 'frm_style_action_route', $action ); |
|
309 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
310 | - return; |
|
311 | - } |
|
307 | + default: |
|
308 | + do_action( 'frm_style_action_route', $action ); |
|
309 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
310 | + return; |
|
311 | + } |
|
312 | 312 | |
313 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
314 | - return self::$action(); |
|
315 | - } |
|
313 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
314 | + return self::$action(); |
|
315 | + } |
|
316 | 316 | |
317 | - return self::edit(); |
|
318 | - } |
|
319 | - } |
|
317 | + return self::edit(); |
|
318 | + } |
|
319 | + } |
|
320 | 320 | |
321 | - public static function reset_styling() { |
|
321 | + public static function reset_styling() { |
|
322 | 322 | FrmAppHelper::permission_check('frm_change_settings'); |
323 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
323 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
324 | 324 | |
325 | - $frm_style = new FrmStyle(); |
|
326 | - $defaults = $frm_style->get_defaults(); |
|
325 | + $frm_style = new FrmStyle(); |
|
326 | + $defaults = $frm_style->get_defaults(); |
|
327 | 327 | |
328 | - echo json_encode( $defaults ); |
|
329 | - wp_die(); |
|
330 | - } |
|
328 | + echo json_encode( $defaults ); |
|
329 | + wp_die(); |
|
330 | + } |
|
331 | 331 | |
332 | - public static function change_styling() { |
|
333 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
332 | + public static function change_styling() { |
|
333 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
334 | 334 | |
335 | - $frm_style = new FrmStyle(); |
|
336 | - $defaults = $frm_style->get_defaults(); |
|
335 | + $frm_style = new FrmStyle(); |
|
336 | + $defaults = $frm_style->get_defaults(); |
|
337 | 337 | $style = ''; |
338 | 338 | |
339 | - // remove the # from the colors |
|
340 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
341 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
342 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
343 | - } |
|
344 | - } |
|
339 | + // remove the # from the colors |
|
340 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
341 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
342 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
343 | + } |
|
344 | + } |
|
345 | 345 | |
346 | - echo '<style type="text/css">'; |
|
346 | + echo '<style type="text/css">'; |
|
347 | 347 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
348 | - echo '</style>'; |
|
349 | - wp_die(); |
|
350 | - } |
|
351 | - |
|
352 | - private static function add_meta_boxes() { |
|
353 | - |
|
354 | - // setup meta boxes |
|
355 | - $meta_boxes = array( |
|
356 | - 'general' => __( 'General', 'formidable' ), |
|
357 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
358 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
359 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
360 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
361 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
362 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
363 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
364 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
365 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
366 | - ); |
|
348 | + echo '</style>'; |
|
349 | + wp_die(); |
|
350 | + } |
|
351 | + |
|
352 | + private static function add_meta_boxes() { |
|
353 | + |
|
354 | + // setup meta boxes |
|
355 | + $meta_boxes = array( |
|
356 | + 'general' => __( 'General', 'formidable' ), |
|
357 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
358 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
359 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
360 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
361 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
362 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
363 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
364 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
365 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
366 | + ); |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Add custom boxes to the styling settings |
@@ -371,14 +371,14 @@ discard block |
||
371 | 371 | */ |
372 | 372 | $meta_boxes = apply_filters( 'frm_style_boxes', $meta_boxes ); |
373 | 373 | |
374 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
374 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
375 | 375 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
376 | - unset($nicename, $name); |
|
377 | - } |
|
378 | - } |
|
376 | + unset($nicename, $name); |
|
377 | + } |
|
378 | + } |
|
379 | 379 | |
380 | 380 | public static function include_style_section( $atts, $sec ) { |
381 | - extract($atts); |
|
381 | + extract($atts); |
|
382 | 382 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
383 | 383 | $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php'; |
384 | 384 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | $file_name = apply_filters( 'frm_style_settings_' . $sec['args'], $file_name ); |
393 | 393 | |
394 | 394 | include( $file_name ); |
395 | - } |
|
395 | + } |
|
396 | 396 | |
397 | - public static function load_css() { |
|
398 | - header('Content-type: text/css'); |
|
397 | + public static function load_css() { |
|
398 | + header('Content-type: text/css'); |
|
399 | 399 | |
400 | - $frm_style = new FrmStyle(); |
|
401 | - $defaults = $frm_style->get_defaults(); |
|
400 | + $frm_style = new FrmStyle(); |
|
401 | + $defaults = $frm_style->get_defaults(); |
|
402 | 402 | $style = ''; |
403 | 403 | |
404 | 404 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
405 | - wp_die(); |
|
406 | - } |
|
405 | + wp_die(); |
|
406 | + } |
|
407 | 407 | |
408 | 408 | public static function load_saved_css() { |
409 | 409 | $css = get_transient( 'frmpro_css' ); |
@@ -412,142 +412,142 @@ discard block |
||
412 | 412 | wp_die(); |
413 | 413 | } |
414 | 414 | |
415 | - /** |
|
416 | - * Check if the Formidable styling should be loaded, |
|
417 | - * then enqueue it for the footer |
|
418 | - * @since 2.0 |
|
419 | - */ |
|
420 | - public static function enqueue_style() { |
|
421 | - global $frm_vars; |
|
422 | - |
|
423 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
424 | - // the CSS has already been loaded |
|
425 | - return; |
|
426 | - } |
|
427 | - |
|
428 | - $frm_settings = FrmAppHelper::get_settings(); |
|
429 | - if ( $frm_settings->load_style != 'none' ) { |
|
430 | - wp_enqueue_style( 'formidable' ); |
|
431 | - $frm_vars['css_loaded'] = true; |
|
432 | - } |
|
433 | - } |
|
434 | - |
|
435 | - // Get the stylesheets for the form settings page |
|
436 | - public static function get_style_opts() { |
|
437 | - $frm_style = new FrmStyle(); |
|
438 | - $styles = $frm_style->get_all(); |
|
439 | - |
|
440 | - return $styles; |
|
441 | - } |
|
442 | - |
|
443 | - public static function get_form_style( $form = 'default' ) { |
|
444 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
445 | - |
|
446 | - if ( empty( $style ) || 1 == $style ) { |
|
447 | - $style = 'default'; |
|
448 | - } |
|
449 | - |
|
450 | - $frm_style = new FrmStyle( $style ); |
|
451 | - return $frm_style->get_one(); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * @param string $class |
|
456 | - * @param string $style |
|
457 | - */ |
|
415 | + /** |
|
416 | + * Check if the Formidable styling should be loaded, |
|
417 | + * then enqueue it for the footer |
|
418 | + * @since 2.0 |
|
419 | + */ |
|
420 | + public static function enqueue_style() { |
|
421 | + global $frm_vars; |
|
422 | + |
|
423 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
424 | + // the CSS has already been loaded |
|
425 | + return; |
|
426 | + } |
|
427 | + |
|
428 | + $frm_settings = FrmAppHelper::get_settings(); |
|
429 | + if ( $frm_settings->load_style != 'none' ) { |
|
430 | + wp_enqueue_style( 'formidable' ); |
|
431 | + $frm_vars['css_loaded'] = true; |
|
432 | + } |
|
433 | + } |
|
434 | + |
|
435 | + // Get the stylesheets for the form settings page |
|
436 | + public static function get_style_opts() { |
|
437 | + $frm_style = new FrmStyle(); |
|
438 | + $styles = $frm_style->get_all(); |
|
439 | + |
|
440 | + return $styles; |
|
441 | + } |
|
442 | + |
|
443 | + public static function get_form_style( $form = 'default' ) { |
|
444 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
445 | + |
|
446 | + if ( empty( $style ) || 1 == $style ) { |
|
447 | + $style = 'default'; |
|
448 | + } |
|
449 | + |
|
450 | + $frm_style = new FrmStyle( $style ); |
|
451 | + return $frm_style->get_one(); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * @param string $class |
|
456 | + * @param string $style |
|
457 | + */ |
|
458 | 458 | public static function get_form_style_class( $class, $style ) { |
459 | - if ( 1 == $style ) { |
|
460 | - $style = 'default'; |
|
461 | - } |
|
459 | + if ( 1 == $style ) { |
|
460 | + $style = 'default'; |
|
461 | + } |
|
462 | 462 | |
463 | - $frm_style = new FrmStyle($style); |
|
464 | - $style = $frm_style->get_one(); |
|
463 | + $frm_style = new FrmStyle($style); |
|
464 | + $style = $frm_style->get_one(); |
|
465 | 465 | |
466 | - if ( $style ) { |
|
466 | + if ( $style ) { |
|
467 | 467 | $class .= ' frm_style_' . $style->post_name; |
468 | - } |
|
468 | + } |
|
469 | 469 | |
470 | - return $class; |
|
471 | - } |
|
470 | + return $class; |
|
471 | + } |
|
472 | 472 | |
473 | - /** |
|
474 | - * @param string $val |
|
475 | - */ |
|
473 | + /** |
|
474 | + * @param string $val |
|
475 | + */ |
|
476 | 476 | public static function get_style_val( $val, $form = 'default' ) { |
477 | - $style = self::get_form_style($form); |
|
478 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
479 | - return $style->post_content[ $val ]; |
|
480 | - } |
|
481 | - } |
|
477 | + $style = self::get_form_style($form); |
|
478 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
479 | + return $style->post_content[ $val ]; |
|
480 | + } |
|
481 | + } |
|
482 | 482 | |
483 | 483 | public static function show_entry_styles( $default_styles ) { |
484 | - $frm_style = new FrmStyle('default'); |
|
485 | - $style = $frm_style->get_one(); |
|
486 | - |
|
487 | - if ( ! $style ) { |
|
488 | - return $default_styles; |
|
489 | - } |
|
490 | - |
|
491 | - foreach ( $default_styles as $name => $val ) { |
|
492 | - $setting = $name; |
|
493 | - if ( 'border_width' == $name ) { |
|
494 | - $setting = 'field_border_width'; |
|
495 | - } else if ( 'alt_bg_color' == $name ) { |
|
496 | - $setting = 'bg_color_active'; |
|
497 | - } |
|
498 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
499 | - unset($name, $val); |
|
500 | - } |
|
501 | - |
|
502 | - return $default_styles; |
|
503 | - } |
|
484 | + $frm_style = new FrmStyle('default'); |
|
485 | + $style = $frm_style->get_one(); |
|
486 | + |
|
487 | + if ( ! $style ) { |
|
488 | + return $default_styles; |
|
489 | + } |
|
490 | + |
|
491 | + foreach ( $default_styles as $name => $val ) { |
|
492 | + $setting = $name; |
|
493 | + if ( 'border_width' == $name ) { |
|
494 | + $setting = 'field_border_width'; |
|
495 | + } else if ( 'alt_bg_color' == $name ) { |
|
496 | + $setting = 'bg_color_active'; |
|
497 | + } |
|
498 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
499 | + unset($name, $val); |
|
500 | + } |
|
501 | + |
|
502 | + return $default_styles; |
|
503 | + } |
|
504 | 504 | |
505 | 505 | public static function &important_style( $important, $field ) { |
506 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
507 | - return $important; |
|
508 | - } |
|
506 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
507 | + return $important; |
|
508 | + } |
|
509 | 509 | |
510 | - /** |
|
511 | - * Fallback for WP < 3.6 |
|
512 | - */ |
|
513 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
514 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
515 | - return do_accordion_sections( $screen, $context, $object ); |
|
516 | - } |
|
510 | + /** |
|
511 | + * Fallback for WP < 3.6 |
|
512 | + */ |
|
513 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
514 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
515 | + return do_accordion_sections( $screen, $context, $object ); |
|
516 | + } |
|
517 | 517 | |
518 | - global $wp_meta_boxes; |
|
518 | + global $wp_meta_boxes; |
|
519 | 519 | |
520 | - $screen = 'formidable_page_formidable-styles'; |
|
521 | - $screen = convert_to_screen( $screen ); |
|
520 | + $screen = 'formidable_page_formidable-styles'; |
|
521 | + $screen = convert_to_screen( $screen ); |
|
522 | 522 | |
523 | - $page = $screen->id; |
|
523 | + $page = $screen->id; |
|
524 | 524 | |
525 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
526 | - ?> |
|
525 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
526 | + ?> |
|
527 | 527 | <div id="side-sortables" class="accordion-container"> |
528 | 528 | <?php |
529 | - $i = 0; |
|
530 | - $first_open = false; |
|
531 | - do { |
|
529 | + $i = 0; |
|
530 | + $first_open = false; |
|
531 | + do { |
|
532 | 532 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
533 | 533 | break; |
534 | 534 | } |
535 | 535 | |
536 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
537 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
538 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
539 | - if ( false == $box || ! $box['title'] ) { |
|
540 | - continue; |
|
536 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
537 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
538 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
539 | + if ( false == $box || ! $box['title'] ) { |
|
540 | + continue; |
|
541 | 541 | } |
542 | 542 | |
543 | - $i++; |
|
544 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
543 | + $i++; |
|
544 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
545 | 545 | |
546 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
547 | - $first_open = true; |
|
548 | - } |
|
546 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
547 | + $first_open = true; |
|
548 | + } |
|
549 | 549 | |
550 | - ?> |
|
550 | + ?> |
|
551 | 551 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
552 | 552 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
553 | 553 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | </div><!-- .accordion-section-content --> |
559 | 559 | </div><!-- .postbox --> |
560 | 560 | <?php |
561 | - } |
|
562 | - } |
|
563 | - } |
|
564 | - } while ( 0 ); |
|
565 | - ?> |
|
561 | + } |
|
562 | + } |
|
563 | + } |
|
564 | + } while ( 0 ); |
|
565 | + ?> |
|
566 | 566 | </div><!-- .accordion-container --> |
567 | 567 | <?php |
568 | - return $i; |
|
569 | - } |
|
568 | + return $i; |
|
569 | + } |
|
570 | 570 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | public static function menu() { |
44 | - add_submenu_page('formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
44 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route' ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public static function admin_init() { |
48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
48 | + if ( ! FrmAppHelper::is_admin_page( 'formidable-styles' ) ) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
60 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
60 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
61 | 61 | |
62 | 62 | $version = FrmAppHelper::plugin_version(); |
63 | 63 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
64 | 64 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker' . $suffix . '.js', array( 'jquery' ), $version ); |
65 | 65 | |
66 | - wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
|
66 | + wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
|
67 | 67 | |
68 | - $style = apply_filters('frm_style_head', false); |
|
68 | + $style = apply_filters( 'frm_style_head', false ); |
|
69 | 69 | if ( $style ) { |
70 | 70 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
71 | 71 | } |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | public static function new_style( $return = '' ) { |
166 | - self::load_styler('default'); |
|
166 | + self::load_styler( 'default' ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | public static function duplicate() { |
170 | - self::load_styler('default'); |
|
170 | + self::load_styler( 'default' ); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | public static function edit( $style_id = false, $message = '' ) { |
174 | 174 | if ( ! $style_id ) { |
175 | 175 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
176 | - if ( empty($style_id) ) { |
|
176 | + if ( empty( $style_id ) ) { |
|
177 | 177 | $style_id = 'default'; |
178 | 178 | } |
179 | 179 | } |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | if ( 'default' == $style_id ) { |
182 | 182 | $style = 'default'; |
183 | 183 | } else { |
184 | - $frm_style = new FrmStyle($style_id); |
|
184 | + $frm_style = new FrmStyle( $style_id ); |
|
185 | 185 | $style = $frm_style->get_one(); |
186 | 186 | $style = $style->ID; |
187 | 187 | } |
188 | 188 | |
189 | - self::load_styler($style, $message); |
|
189 | + self::load_styler( $style, $message ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function save() { |
@@ -196,17 +196,17 @@ discard block |
||
196 | 196 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
197 | 197 | |
198 | 198 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
199 | - $id = $frm_style->update($post_id); |
|
200 | - if ( empty($post_id) && ! empty($id) ) { |
|
199 | + $id = $frm_style->update( $post_id ); |
|
200 | + if ( empty( $post_id ) && ! empty( $id ) ) { |
|
201 | 201 | // set the post id to the new style so it will be loaded for editing |
202 | - $post_id = reset($id); |
|
202 | + $post_id = reset( $id ); |
|
203 | 203 | } |
204 | 204 | // include the CSS that includes this style |
205 | 205 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
206 | 206 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
207 | 207 | } |
208 | 208 | |
209 | - return self::edit($post_id, $message); |
|
209 | + return self::edit( $post_id, $message ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | public static function load_styler( $style, $message = '' ) { |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | $frm_style = new FrmStyle(); |
216 | 216 | $styles = $frm_style->get_all(); |
217 | 217 | |
218 | - if ( is_numeric($style) ) { |
|
219 | - $style = $styles[ $style ]; |
|
218 | + if ( is_numeric( $style ) ) { |
|
219 | + $style = $styles[$style]; |
|
220 | 220 | } else if ( 'default' == $style ) { |
221 | - $style = $frm_style->get_default_style($styles); |
|
221 | + $style = $frm_style->get_default_style( $styles ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | self::add_meta_boxes(); |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | private static function manage( $message = '', $forms = array() ) { |
234 | 234 | $frm_style = new FrmStyle(); |
235 | 235 | $styles = $frm_style->get_all(); |
236 | - $default_style = $frm_style->get_default_style($styles); |
|
236 | + $default_style = $frm_style->get_default_style( $styles ); |
|
237 | 237 | |
238 | - if ( empty($forms) ) { |
|
238 | + if ( empty( $forms ) ) { |
|
239 | 239 | $forms = FrmForm::get_published_forms(); |
240 | 240 | } |
241 | 241 | |
@@ -252,26 +252,26 @@ discard block |
||
252 | 252 | |
253 | 253 | $forms = FrmForm::get_published_forms(); |
254 | 254 | foreach ( $forms as $form ) { |
255 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
255 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | |
259 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
259 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
260 | 260 | |
261 | 261 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
262 | - unset($form); |
|
262 | + unset( $form ); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $message = __( 'Your form styles have been saved.', 'formidable' ); |
266 | - return self::manage($message, $forms); |
|
266 | + return self::manage( $message, $forms ); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | public static function custom_css( $message = '', $style = null ) { |
270 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
271 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
270 | + wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' ); |
|
271 | + wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' ); |
|
272 | 272 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
273 | 273 | |
274 | - if ( ! isset($style) ) { |
|
274 | + if ( ! isset( $style ) ) { |
|
275 | 275 | $frm_style = new FrmStyle(); |
276 | 276 | $style = $frm_style->get_default_style(); |
277 | 277 | } |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
287 | 287 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
288 | 288 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
289 | - $frm_style->update($post_id); |
|
289 | + $frm_style->update( $post_id ); |
|
290 | 290 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
291 | 291 | } |
292 | 292 | |
293 | - return self::custom_css($message); |
|
293 | + return self::custom_css( $message ); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | public static function route() { |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | public static function reset_styling() { |
322 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
322 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
323 | 323 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
324 | 324 | |
325 | 325 | $frm_style = new FrmStyle(); |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | |
339 | 339 | // remove the # from the colors |
340 | 340 | foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
341 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
342 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
341 | + if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) { |
|
342 | + $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v ); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | |
374 | 374 | foreach ( $meta_boxes as $nicename => $name ) { |
375 | 375 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
376 | - unset($nicename, $name); |
|
376 | + unset( $nicename, $name ); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | |
380 | 380 | public static function include_style_section( $atts, $sec ) { |
381 | - extract($atts); |
|
381 | + extract( $atts ); |
|
382 | 382 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
383 | 383 | $file_name = FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php'; |
384 | 384 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | } |
396 | 396 | |
397 | 397 | public static function load_css() { |
398 | - header('Content-type: text/css'); |
|
398 | + header( 'Content-type: text/css' ); |
|
399 | 399 | |
400 | 400 | $frm_style = new FrmStyle(); |
401 | 401 | $defaults = $frm_style->get_defaults(); |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $style = 'default'; |
461 | 461 | } |
462 | 462 | |
463 | - $frm_style = new FrmStyle($style); |
|
463 | + $frm_style = new FrmStyle( $style ); |
|
464 | 464 | $style = $frm_style->get_one(); |
465 | 465 | |
466 | 466 | if ( $style ) { |
@@ -474,14 +474,14 @@ discard block |
||
474 | 474 | * @param string $val |
475 | 475 | */ |
476 | 476 | public static function get_style_val( $val, $form = 'default' ) { |
477 | - $style = self::get_form_style($form); |
|
478 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
479 | - return $style->post_content[ $val ]; |
|
477 | + $style = self::get_form_style( $form ); |
|
478 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
479 | + return $style->post_content[$val]; |
|
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | 483 | public static function show_entry_styles( $default_styles ) { |
484 | - $frm_style = new FrmStyle('default'); |
|
484 | + $frm_style = new FrmStyle( 'default' ); |
|
485 | 485 | $style = $frm_style->get_one(); |
486 | 486 | |
487 | 487 | if ( ! $style ) { |
@@ -495,15 +495,15 @@ discard block |
||
495 | 495 | } else if ( 'alt_bg_color' == $name ) { |
496 | 496 | $setting = 'bg_color_active'; |
497 | 497 | } |
498 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
499 | - unset($name, $val); |
|
498 | + $default_styles[$name] = $style->post_content[$setting]; |
|
499 | + unset( $name, $val ); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | return $default_styles; |
503 | 503 | } |
504 | 504 | |
505 | 505 | public static function &important_style( $important, $field ) { |
506 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
506 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); |
|
507 | 507 | return $important; |
508 | 508 | } |
509 | 509 | |
@@ -529,18 +529,18 @@ discard block |
||
529 | 529 | $i = 0; |
530 | 530 | $first_open = false; |
531 | 531 | do { |
532 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
532 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
533 | 533 | break; |
534 | 534 | } |
535 | 535 | |
536 | 536 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
537 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
538 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
537 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
538 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
539 | 539 | if ( false == $box || ! $box['title'] ) { |
540 | 540 | continue; |
541 | 541 | } |
542 | 542 | |
543 | - $i++; |
|
543 | + $i ++; |
|
544 | 544 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
545 | 545 | |
546 | 546 | if ( ! $first_open && empty( $hidden_class ) ) { |
@@ -275,7 +275,7 @@ |
||
275 | 275 | return $message; |
276 | 276 | } |
277 | 277 | |
278 | - public function manually_queue_update() { |
|
279 | - set_site_transient( 'update_plugins', null ); |
|
280 | - } |
|
278 | + public function manually_queue_update() { |
|
279 | + set_site_transient( 'update_plugins', null ); |
|
280 | + } |
|
281 | 281 | } |
@@ -292,6 +292,9 @@ |
||
292 | 292 | wp_die(); |
293 | 293 | } |
294 | 294 | |
295 | + /** |
|
296 | + * @param string $action |
|
297 | + */ |
|
295 | 298 | public function send_mothership_request( $action ) { |
296 | 299 | $api_params = array( |
297 | 300 | 'edd_action' => $action, |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function insert_installed_addon( $plugins ) { |
41 | - $plugins[ $this->plugin_slug ] = $this; |
|
41 | + $plugins[$this->plugin_slug] = $this; |
|
42 | 42 | return $plugins; |
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function get_addon( $plugin_slug ) { |
46 | 46 | $plugins = apply_filters( 'frm_installed_addons', array() ); |
47 | 47 | $plugin = false; |
48 | - if ( isset( $plugins[ $plugin_slug ] ) ) { |
|
49 | - $plugin = $plugins[ $plugin_slug ]; |
|
48 | + if ( isset( $plugins[$plugin_slug] ) ) { |
|
49 | + $plugin = $plugins[$plugin_slug]; |
|
50 | 50 | } |
51 | 51 | return $plugin; |
52 | 52 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function show_license_message( $file, $plugin ) { |
101 | 101 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
102 | 102 | echo '<tr class="plugin-update-tr active"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message">'; |
103 | - echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url('admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
103 | + echo sprintf( __( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), $this->plugin_name, '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' ); |
|
104 | 104 | $id = sanitize_title( $plugin['Name'] ); |
105 | 105 | echo '<script type="text/javascript">var d = document.getElementById("' . esc_attr( $id ) . '");if ( d !== null ){ d.className = d.className + " update"; }</script>'; |
106 | 106 | echo '</div></td></tr>'; |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | |
114 | 114 | if ( $this->is_current_version( $transient ) ) { |
115 | 115 | //make sure it doesn't show there is an update if plugin is up-to-date |
116 | - if ( isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
117 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
116 | + if ( isset( $transient->response[$this->plugin_folder] ) ) { |
|
117 | + unset( $transient->response[$this->plugin_folder] ); |
|
118 | 118 | } |
119 | - } else if ( isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) ) { |
|
119 | + } else if ( isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) ) { |
|
120 | 120 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $this->license . $this->version ) . '_get_version' ); |
121 | 121 | $version_info = get_transient( $cache_key ); |
122 | 122 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | if ( $version_info !== false && version_compare( $version_info->new_version, $this->version, '>' ) ) { |
130 | - $transient->response[ $this->plugin_folder ] = $version_info; |
|
130 | + $transient->response[$this->plugin_folder] = $version_info; |
|
131 | 131 | } else { |
132 | 132 | delete_transient( $cache_key ); |
133 | 133 | if ( ! $this->has_been_cleared() ) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $this->manually_queue_update(); |
137 | 137 | } |
138 | 138 | |
139 | - unset( $transient->response[ $this->plugin_folder ] ); |
|
139 | + unset( $transient->response[$this->plugin_folder] ); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | private function is_current_version( $transient ) { |
147 | - if ( empty( $transient->checked ) || ! isset( $transient->checked[ $this->plugin_folder ] ) ) { |
|
147 | + if ( empty( $transient->checked ) || ! isset( $transient->checked[$this->plugin_folder] ) ) { |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -153,16 +153,16 @@ discard block |
||
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | |
156 | - return isset( $transient->response ) && isset( $transient->response[ $this->plugin_folder ] ) && $transient->checked[ $this->plugin_folder ] == $transient->response[ $this->plugin_folder ]->new_version; |
|
156 | + return isset( $transient->response ) && isset( $transient->response[$this->plugin_folder] ) && $transient->checked[$this->plugin_folder] == $transient->response[$this->plugin_folder]->new_version; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | private function has_been_cleared() { |
160 | 160 | $last_cleared = get_option( 'frm_last_cleared' ); |
161 | - return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime('-5 minutes') ) ); |
|
161 | + return ( $last_cleared && $last_cleared > date( 'Y-m-d H:i:s', strtotime( '-5 minutes' ) ) ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | private function cleared_plugins() { |
165 | - update_option( 'frm_last_cleared', date('Y-m-d H:i:s') ); |
|
165 | + update_option( 'frm_last_cleared', date( 'Y-m-d H:i:s' ) ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | private function is_license_revoked() { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | $last_checked = get_site_option( $this->transient_key() ); |
174 | - $seven_days_ago = date( 'Y-m-d H:i:s', strtotime('-7 days') ); |
|
174 | + $seven_days_ago = date( 'Y-m-d H:i:s', strtotime( '-7 days' ) ); |
|
175 | 175 | |
176 | 176 | if ( ! $last_checked || $last_checked < $seven_days_ago ) { |
177 | 177 | update_site_option( $this->transient_key(), date( 'Y-m-d H:i:s' ) ); // check weekly |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | public static function activate() { |
190 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
190 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
191 | 191 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
192 | 192 | |
193 | 193 | if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) { |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | $response['message'] = $response['status']; |
209 | 209 | } else { |
210 | 210 | $messages = $this_plugin->get_messages(); |
211 | - if ( is_string( $response['status'] ) && isset( $messages[ $response['status'] ] ) ) { |
|
212 | - $response['message'] = $messages[ $response['status'] ]; |
|
211 | + if ( is_string( $response['status'] ) && isset( $messages[$response['status']] ) ) { |
|
212 | + $response['message'] = $messages[$response['status']]; |
|
213 | 213 | } else { |
214 | 214 | $response['message'] = FrmAppHelper::kses( $response['status'], array( 'a' ) ); |
215 | 215 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | public static function deactivate() { |
268 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
268 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
269 | 269 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
270 | 270 | |
271 | 271 | $plugin_slug = sanitize_text_field( $_POST['plugin'] ); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | $message = __( 'Your License Key was invalid', 'formidable' ); |
319 | 319 | if ( is_wp_error( $resp ) ) { |
320 | - $message = sprintf( __( 'You had an error communicating with the Formidable API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
320 | + $message = sprintf( __( 'You had an error communicating with the Formidable API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
321 | 321 | $message .= ' ' . $resp->get_error_message(); |
322 | 322 | } else if ( $body == 'error' || is_wp_error( $body ) ) { |
323 | 323 | $message = __( 'You had an HTTP error connecting to the Formidable API', 'formidable' ); |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_size') ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_size' ) ) ?>" id="frm_form_desc_size" value="<?php echo esc_attr( $style->post_content['form_desc_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_color') ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_color' ) ) ?>" id="frm_form_desc_color" class="hex" value="<?php echo esc_attr( $style->post_content['form_desc_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_top') ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_top' ) ) ?>" id="frm_form_desc_margin_top" value="<?php echo esc_attr( $style->post_content['form_desc_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('form_desc_margin_bottom') ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'form_desc_margin_bottom' ) ) ?>" id="frm_form_desc_margin_bottom" value="<?php echo esc_attr( $style->post_content['form_desc_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <div class="field-group clearfix frm-half frm-first-row"> |
2 | 2 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_size') ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_size' ) ) ?>" id="frm_title_size" value="<?php echo esc_attr( $style->post_content['title_size'] ) ?>" /> |
|
4 | 4 | </div> |
5 | 5 | |
6 | 6 | <div class="field-group clearfix frm-half frm-first-row"> |
7 | 7 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
8 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_color') ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
8 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_color' ) ) ?>" id="frm_title_color" class="hex" value="<?php echo esc_attr( $style->post_content['title_color'] ) ?>" /> |
|
9 | 9 | </div> |
10 | 10 | <div class="field-group clearfix frm-half"> |
11 | 11 | <label><?php _e( 'Margin Top', 'formidable' ) ?></label> |
12 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_top') ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
12 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_top' ) ) ?>" id="frm_title_margin_top" value="<?php echo esc_attr( $style->post_content['title_margin_top'] ) ?>" size="4" /> |
|
13 | 13 | </div> |
14 | 14 | <div class="field-group clearfix frm-half"> |
15 | 15 | <label><?php _e( 'Margin Bottom', 'formidable' ) ?></label> |
16 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('title_margin_bottom') ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
16 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'title_margin_bottom' ) ) ?>" id="frm_title_margin_bottom" value="<?php echo esc_attr( $style->post_content['title_margin_bottom'] ) ?>" size="4" /> |
|
17 | 17 | </div> |
@@ -181,13 +181,13 @@ |
||
181 | 181 | ), |
182 | 182 | ); |
183 | 183 | $random = rand( 0, count( $tips ) - 1 ); |
184 | - $tip = $tips[ $random ]; |
|
184 | + $tip = $tips[$random]; |
|
185 | 185 | $tip['num'] = $random; |
186 | 186 | return $tip; |
187 | 187 | } |
188 | 188 | |
189 | 189 | public static function get_random_tip( $tips ) { |
190 | 190 | $random = rand( 0, count( $tips ) - 1 ); |
191 | - return $tips[ $random ]; |
|
191 | + return $tips[$random]; |
|
192 | 192 | } |
193 | 193 | } |
@@ -180,6 +180,7 @@ |
||
180 | 180 | * |
181 | 181 | * @param int $id |
182 | 182 | * @param array $values |
183 | + * @param string $update_type |
|
183 | 184 | * @return boolean|int $query_results |
184 | 185 | */ |
185 | 186 | private static function update_entry( $id, $values, $update_type ) { |
@@ -6,11 +6,11 @@ discard block |
||
6 | 6 | class FrmEntry { |
7 | 7 | |
8 | 8 | /** |
9 | - * Create a new entry |
|
10 | - * |
|
11 | - * @param array $values |
|
12 | - * @return int | boolean $entry_id |
|
13 | - */ |
|
9 | + * Create a new entry |
|
10 | + * |
|
11 | + * @param array $values |
|
12 | + * @return int | boolean $entry_id |
|
13 | + */ |
|
14 | 14 | public static function create( $values ) { |
15 | 15 | $entry_id = self::create_entry( $values, 'standard' ); |
16 | 16 | |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * Create a new entry with some differences depending on type |
|
22 | - * |
|
23 | - * @param array $values |
|
24 | - * @param string $type |
|
25 | - * @return int | boolean $entry_id |
|
26 | - */ |
|
21 | + * Create a new entry with some differences depending on type |
|
22 | + * |
|
23 | + * @param array $values |
|
24 | + * @param string $type |
|
25 | + * @return int | boolean $entry_id |
|
26 | + */ |
|
27 | 27 | private static function create_entry( $values, $type ) { |
28 | 28 | $new_values = self::before_insert_entry_in_database( $values, $type ); |
29 | 29 | |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | return $entry_id; |
38 | 38 | } |
39 | 39 | |
40 | - /** |
|
41 | - * check for duplicate entries created in the last minute |
|
42 | - * @return boolean |
|
43 | - */ |
|
40 | + /** |
|
41 | + * check for duplicate entries created in the last minute |
|
42 | + * @return boolean |
|
43 | + */ |
|
44 | 44 | public static function is_duplicate( $new_values, $values ) { |
45 | 45 | $duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values ); |
46 | 46 | |
@@ -48,55 +48,55 @@ discard block |
||
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
51 | - $check_val = $new_values; |
|
51 | + $check_val = $new_values; |
|
52 | 52 | $check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) ); |
53 | 53 | |
54 | 54 | unset( $check_val['created_at'], $check_val['updated_at'] ); |
55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
56 | 56 | |
57 | - if ( $new_values['item_key'] == $new_values['name'] ) { |
|
58 | - unset($check_val['name']); |
|
59 | - } |
|
57 | + if ( $new_values['item_key'] == $new_values['name'] ) { |
|
58 | + unset($check_val['name']); |
|
59 | + } |
|
60 | 60 | |
61 | - global $wpdb; |
|
61 | + global $wpdb; |
|
62 | 62 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
63 | 63 | |
64 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
65 | - return false; |
|
66 | - } |
|
64 | + if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
65 | + return false; |
|
66 | + } |
|
67 | 67 | |
68 | - $is_duplicate = false; |
|
69 | - foreach ( $entry_exists as $entry_exist ) { |
|
70 | - $is_duplicate = true; |
|
68 | + $is_duplicate = false; |
|
69 | + foreach ( $entry_exists as $entry_exist ) { |
|
70 | + $is_duplicate = true; |
|
71 | 71 | |
72 | - //add more checks here to make sure it's a duplicate |
|
73 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
74 | - $field_metas = array(); |
|
75 | - foreach ( $metas as $meta ) { |
|
72 | + //add more checks here to make sure it's a duplicate |
|
73 | + $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
74 | + $field_metas = array(); |
|
75 | + foreach ( $metas as $meta ) { |
|
76 | 76 | $field_metas[ $meta->field_id ] = $meta->meta_value; |
77 | - } |
|
78 | - |
|
79 | - // If prev entry is empty and current entry is not, they are not duplicates |
|
80 | - $filtered_vals = array_filter( $values['item_meta'] ); |
|
81 | - if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
82 | - return false; |
|
83 | - } |
|
84 | - |
|
85 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
86 | - foreach ( $diff as $field_id => $meta_value ) { |
|
87 | - if ( ! empty($meta_value) ) { |
|
88 | - $is_duplicate = false; |
|
89 | - continue; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - if ( $is_duplicate ) { |
|
77 | + } |
|
78 | + |
|
79 | + // If prev entry is empty and current entry is not, they are not duplicates |
|
80 | + $filtered_vals = array_filter( $values['item_meta'] ); |
|
81 | + if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
82 | + return false; |
|
83 | + } |
|
84 | + |
|
85 | + $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
86 | + foreach ( $diff as $field_id => $meta_value ) { |
|
87 | + if ( ! empty($meta_value) ) { |
|
88 | + $is_duplicate = false; |
|
89 | + continue; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + if ( $is_duplicate ) { |
|
94 | 94 | break; |
95 | - } |
|
96 | - } |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | - return $is_duplicate; |
|
99 | - } |
|
98 | + return $is_duplicate; |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Determine if an entry needs to be checked as a possible duplicate |
@@ -125,48 +125,48 @@ discard block |
||
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | |
128 | - public static function duplicate( $id ) { |
|
129 | - global $wpdb; |
|
128 | + public static function duplicate( $id ) { |
|
129 | + global $wpdb; |
|
130 | 130 | |
131 | - $values = self::getOne( $id ); |
|
131 | + $values = self::getOne( $id ); |
|
132 | 132 | |
133 | - $new_values = array(); |
|
133 | + $new_values = array(); |
|
134 | 134 | $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
135 | - $new_values['name'] = $values->name; |
|
136 | - $new_values['is_draft'] = $values->is_draft; |
|
135 | + $new_values['name'] = $values->name; |
|
136 | + $new_values['is_draft'] = $values->is_draft; |
|
137 | 137 | $new_values['user_id'] = (int) $values->user_id; |
138 | 138 | $new_values['updated_by'] = (int) $values->user_id; |
139 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
139 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
140 | 140 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
141 | 141 | $new_values['updated_at'] = $new_values['created_at']; |
142 | 142 | |
143 | 143 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
144 | - if ( ! $query_results ) { |
|
145 | - return false; |
|
146 | - } |
|
144 | + if ( ! $query_results ) { |
|
145 | + return false; |
|
146 | + } |
|
147 | 147 | |
148 | - $entry_id = $wpdb->insert_id; |
|
148 | + $entry_id = $wpdb->insert_id; |
|
149 | 149 | |
150 | - global $frm_vars; |
|
151 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
152 | - $frm_vars['saved_entries'] = array(); |
|
153 | - } |
|
154 | - $frm_vars['saved_entries'][] = (int) $entry_id; |
|
150 | + global $frm_vars; |
|
151 | + if ( ! isset($frm_vars['saved_entries']) ) { |
|
152 | + $frm_vars['saved_entries'] = array(); |
|
153 | + } |
|
154 | + $frm_vars['saved_entries'][] = (int) $entry_id; |
|
155 | 155 | |
156 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
156 | + FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
157 | 157 | self::clear_cache(); |
158 | 158 | |
159 | 159 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
160 | - return $entry_id; |
|
161 | - } |
|
160 | + return $entry_id; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | /** |
164 | - * Update an entry (not via XML) |
|
165 | - * |
|
166 | - * @param int $id |
|
167 | - * @param array $values |
|
168 | - * @return boolean|int $update_results |
|
169 | - */ |
|
164 | + * Update an entry (not via XML) |
|
165 | + * |
|
166 | + * @param int $id |
|
167 | + * @param array $values |
|
168 | + * @return boolean|int $update_results |
|
169 | + */ |
|
170 | 170 | public static function update( $id, $values ) { |
171 | 171 | $update_results = self::update_entry( $id, $values, 'standard' ); |
172 | 172 | |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Update an entry with some differences depending on the update type |
|
178 | - * |
|
179 | - * @since 2.0.16 |
|
180 | - * |
|
181 | - * @param int $id |
|
182 | - * @param array $values |
|
183 | - * @return boolean|int $query_results |
|
184 | - */ |
|
177 | + * Update an entry with some differences depending on the update type |
|
178 | + * |
|
179 | + * @since 2.0.16 |
|
180 | + * |
|
181 | + * @param int $id |
|
182 | + * @param array $values |
|
183 | + * @return boolean|int $query_results |
|
184 | + */ |
|
185 | 185 | private static function update_entry( $id, $values, $update_type ) { |
186 | 186 | global $wpdb; |
187 | 187 | |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | public static function destroy( $id ) { |
203 | - global $wpdb; |
|
204 | - $id = (int) $id; |
|
203 | + global $wpdb; |
|
204 | + $id = (int) $id; |
|
205 | 205 | |
206 | 206 | $entry = self::getOne( $id ); |
207 | - if ( ! $entry ) { |
|
208 | - $result = false; |
|
209 | - return $result; |
|
210 | - } |
|
207 | + if ( ! $entry ) { |
|
208 | + $result = false; |
|
209 | + return $result; |
|
210 | + } |
|
211 | 211 | |
212 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
212 | + do_action('frm_before_destroy_entry', $id, $entry); |
|
213 | 213 | |
214 | 214 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
215 | 215 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
216 | 216 | |
217 | 217 | self::clear_cache(); |
218 | 218 | |
219 | - return $result; |
|
220 | - } |
|
219 | + return $result; |
|
220 | + } |
|
221 | 221 | |
222 | 222 | public static function update_form( $id, $value, $form_id ) { |
223 | - global $wpdb; |
|
224 | - $form_id = isset($value) ? $form_id : null; |
|
223 | + global $wpdb; |
|
224 | + $form_id = isset($value) ? $form_id : null; |
|
225 | 225 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
226 | 226 | if ( $result ) { |
227 | 227 | self::clear_cache(); |
228 | 228 | } |
229 | - return $result; |
|
230 | - } |
|
229 | + return $result; |
|
230 | + } |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Clear entry caching |
@@ -263,159 +263,159 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | public static function getOne( $id, $meta = false ) { |
266 | - global $wpdb; |
|
266 | + global $wpdb; |
|
267 | 267 | |
268 | - $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
268 | + $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
269 | 269 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
270 | 270 | |
271 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
272 | - $query_args = array( $id ); |
|
273 | - $query = $wpdb->prepare( $query, $query_args ); |
|
271 | + $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
272 | + $query_args = array( $id ); |
|
273 | + $query = $wpdb->prepare( $query, $query_args ); |
|
274 | 274 | |
275 | - if ( ! $meta ) { |
|
275 | + if ( ! $meta ) { |
|
276 | 276 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
277 | - return stripslashes_deep($entry); |
|
278 | - } |
|
277 | + return stripslashes_deep($entry); |
|
278 | + } |
|
279 | 279 | |
280 | - $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
281 | - if ( $entry !== false ) { |
|
282 | - return stripslashes_deep($entry); |
|
283 | - } |
|
280 | + $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
281 | + if ( $entry !== false ) { |
|
282 | + return stripslashes_deep($entry); |
|
283 | + } |
|
284 | 284 | |
285 | - $entry = $wpdb->get_row( $query ); |
|
286 | - $entry = self::get_meta($entry); |
|
285 | + $entry = $wpdb->get_row( $query ); |
|
286 | + $entry = self::get_meta($entry); |
|
287 | 287 | |
288 | - return stripslashes_deep($entry); |
|
289 | - } |
|
288 | + return stripslashes_deep($entry); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | public static function get_meta( $entry ) { |
292 | - if ( ! $entry ) { |
|
293 | - return $entry; |
|
294 | - } |
|
292 | + if ( ! $entry ) { |
|
293 | + return $entry; |
|
294 | + } |
|
295 | 295 | |
296 | - global $wpdb; |
|
296 | + global $wpdb; |
|
297 | 297 | $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', array( 'item_id' => $entry->id, 'field_id !' => 0 ), 'field_id, meta_value, field_key, item_id' ); |
298 | 298 | |
299 | - $entry->metas = array(); |
|
299 | + $entry->metas = array(); |
|
300 | 300 | |
301 | 301 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
302 | - foreach ( $metas as $meta_val ) { |
|
303 | - if ( $meta_val->item_id == $entry->id ) { |
|
302 | + foreach ( $metas as $meta_val ) { |
|
303 | + if ( $meta_val->item_id == $entry->id ) { |
|
304 | 304 | $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
305 | 305 | if ( $include_key ) { |
306 | 306 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
307 | 307 | } |
308 | - continue; |
|
309 | - } |
|
308 | + continue; |
|
309 | + } |
|
310 | 310 | |
311 | - // include sub entries in an array |
|
311 | + // include sub entries in an array |
|
312 | 312 | if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
313 | 313 | $entry->metas[ $meta_val->field_id ] = array(); |
314 | - } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
317 | 317 | |
318 | - unset($meta_val); |
|
319 | - } |
|
320 | - unset($metas); |
|
318 | + unset($meta_val); |
|
319 | + } |
|
320 | + unset($metas); |
|
321 | 321 | |
322 | 322 | FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' ); |
323 | 323 | |
324 | - return $entry; |
|
325 | - } |
|
324 | + return $entry; |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * @param string $id |
|
329 | - */ |
|
327 | + /** |
|
328 | + * @param string $id |
|
329 | + */ |
|
330 | 330 | public static function exists( $id ) { |
331 | - global $wpdb; |
|
332 | - |
|
333 | - if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
334 | - $exists = true; |
|
335 | - return $exists; |
|
336 | - } |
|
337 | - |
|
338 | - if ( is_numeric($id) ) { |
|
339 | - $where = array( 'id' => $id ); |
|
340 | - } else { |
|
341 | - $where = array( 'item_key' => $id ); |
|
342 | - } |
|
331 | + global $wpdb; |
|
332 | + |
|
333 | + if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
334 | + $exists = true; |
|
335 | + return $exists; |
|
336 | + } |
|
337 | + |
|
338 | + if ( is_numeric($id) ) { |
|
339 | + $where = array( 'id' => $id ); |
|
340 | + } else { |
|
341 | + $where = array( 'item_key' => $id ); |
|
342 | + } |
|
343 | 343 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
344 | 344 | |
345 | - $exists = ($id && $id > 0) ? true : false; |
|
346 | - return $exists; |
|
347 | - } |
|
345 | + $exists = ($id && $id > 0) ? true : false; |
|
346 | + return $exists; |
|
347 | + } |
|
348 | 348 | |
349 | - public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
349 | + public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
350 | 350 | global $wpdb; |
351 | 351 | |
352 | - $limit = FrmAppHelper::esc_limit($limit); |
|
352 | + $limit = FrmAppHelper::esc_limit($limit); |
|
353 | 353 | |
354 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
355 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
354 | + $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
355 | + $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
356 | 356 | |
357 | - if ( false === $entries ) { |
|
358 | - $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
357 | + if ( false === $entries ) { |
|
358 | + $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
|
359 | 359 | $table = $wpdb->prefix . 'frm_items it '; |
360 | 360 | |
361 | - if ( $inc_form ) { |
|
362 | - $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
363 | - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
364 | - } |
|
361 | + if ( $inc_form ) { |
|
362 | + $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
363 | + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
364 | + } |
|
365 | 365 | |
366 | - if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
367 | - // sort by a requested field |
|
368 | - $field_id = (int) $order_matches[1]; |
|
366 | + if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
367 | + // sort by a requested field |
|
368 | + $field_id = (int) $order_matches[1]; |
|
369 | 369 | $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
370 | 370 | unset( $order_matches, $field_id ); |
371 | - } |
|
371 | + } |
|
372 | 372 | |
373 | 373 | // prepare the query |
374 | 374 | $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
375 | 375 | |
376 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
377 | - unset($query); |
|
376 | + $entries = $wpdb->get_results($query, OBJECT_K); |
|
377 | + unset($query); |
|
378 | 378 | |
379 | 379 | FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' ); |
380 | - } |
|
380 | + } |
|
381 | 381 | |
382 | - if ( ! $meta || ! $entries ) { |
|
383 | - return stripslashes_deep($entries); |
|
384 | - } |
|
385 | - unset($meta); |
|
382 | + if ( ! $meta || ! $entries ) { |
|
383 | + return stripslashes_deep($entries); |
|
384 | + } |
|
385 | + unset($meta); |
|
386 | 386 | |
387 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
387 | + if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
388 | 388 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
389 | - } |
|
389 | + } |
|
390 | 390 | |
391 | - $meta_where = array( 'field_id !' => 0 ); |
|
392 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
393 | - $meta_where['fi.form_id'] = $where['it.form_id']; |
|
394 | - } else { |
|
395 | - $meta_where['item_id'] = array_keys( $entries ); |
|
396 | - } |
|
391 | + $meta_where = array( 'field_id !' => 0 ); |
|
392 | + if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
393 | + $meta_where['fi.form_id'] = $where['it.form_id']; |
|
394 | + } else { |
|
395 | + $meta_where['item_id'] = array_keys( $entries ); |
|
396 | + } |
|
397 | 397 | |
398 | - $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
398 | + $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
399 | 399 | |
400 | - unset( $meta_where ); |
|
400 | + unset( $meta_where ); |
|
401 | 401 | |
402 | - if ( ! $metas ) { |
|
403 | - return stripslashes_deep($entries); |
|
404 | - } |
|
402 | + if ( ! $metas ) { |
|
403 | + return stripslashes_deep($entries); |
|
404 | + } |
|
405 | 405 | |
406 | - foreach ( $metas as $m_key => $meta_val ) { |
|
407 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
408 | - continue; |
|
409 | - } |
|
406 | + foreach ( $metas as $m_key => $meta_val ) { |
|
407 | + if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
408 | + continue; |
|
409 | + } |
|
410 | 410 | |
411 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
411 | + if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
412 | 412 | $entries[ $meta_val->item_id ]->metas = array(); |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | 415 | $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
416 | 416 | |
417 | - unset($m_key, $meta_val); |
|
418 | - } |
|
417 | + unset($m_key, $meta_val); |
|
418 | + } |
|
419 | 419 | |
420 | 420 | if ( ! FrmAppHelper::prevent_caching() ) { |
421 | 421 | foreach ( $entries as $entry ) { |
@@ -424,31 +424,31 @@ discard block |
||
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | - return stripslashes_deep($entries); |
|
428 | - } |
|
427 | + return stripslashes_deep($entries); |
|
428 | + } |
|
429 | 429 | |
430 | - // Pagination Methods |
|
431 | - public static function getRecordCount( $where = '' ) { |
|
432 | - global $wpdb; |
|
430 | + // Pagination Methods |
|
431 | + public static function getRecordCount( $where = '' ) { |
|
432 | + global $wpdb; |
|
433 | 433 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
434 | 434 | |
435 | - if ( is_numeric($where) ) { |
|
436 | - $table_join = 'frm_items'; |
|
437 | - $where = array( 'form_id' => $where ); |
|
438 | - } |
|
435 | + if ( is_numeric($where) ) { |
|
436 | + $table_join = 'frm_items'; |
|
437 | + $where = array( 'form_id' => $where ); |
|
438 | + } |
|
439 | 439 | |
440 | - if ( is_array( $where ) ) { |
|
441 | - $count = FrmDb::get_count( $table_join, $where ); |
|
442 | - } else { |
|
440 | + if ( is_array( $where ) ) { |
|
441 | + $count = FrmDb::get_count( $table_join, $where ); |
|
442 | + } else { |
|
443 | 443 | $cache_key = 'count_' . maybe_serialize( $where ); |
444 | 444 | $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
445 | 445 | $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
446 | - } |
|
446 | + } |
|
447 | 447 | |
448 | - return $count; |
|
449 | - } |
|
448 | + return $count; |
|
449 | + } |
|
450 | 450 | |
451 | - public static function getPageCount( $p_size, $where = '' ) { |
|
451 | + public static function getPageCount( $p_size, $where = '' ) { |
|
452 | 452 | $p_size = (int) $p_size; |
453 | 453 | $count = 1; |
454 | 454 | if ( $p_size ) { |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | return $count; |
462 | - } |
|
462 | + } |
|
463 | 463 | |
464 | 464 | /** |
465 | - * Prepare the data before inserting it into the database |
|
466 | - * |
|
467 | - * @since 2.0.16 |
|
468 | - * @param array $values |
|
469 | - * @param string $type |
|
470 | - * @return array $new_values |
|
471 | - */ |
|
465 | + * Prepare the data before inserting it into the database |
|
466 | + * |
|
467 | + * @since 2.0.16 |
|
468 | + * @param array $values |
|
469 | + * @param string $type |
|
470 | + * @return array $new_values |
|
471 | + */ |
|
472 | 472 | private static function before_insert_entry_in_database( &$values, $type ) { |
473 | 473 | |
474 | 474 | self::sanitize_entry_post( $values ); |
@@ -483,13 +483,13 @@ discard block |
||
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
486 | - * Create an entry and perform after create actions |
|
487 | - * |
|
488 | - * @since 2.0.16 |
|
489 | - * @param array $values |
|
490 | - * @param array $new_values |
|
491 | - * @return boolean|int $entry_id |
|
492 | - */ |
|
486 | + * Create an entry and perform after create actions |
|
487 | + * |
|
488 | + * @since 2.0.16 |
|
489 | + * @param array $values |
|
490 | + * @param array $new_values |
|
491 | + * @return boolean|int $entry_id |
|
492 | + */ |
|
493 | 493 | private static function continue_to_create_entry( $values, $new_values ) { |
494 | 494 | $entry_id = self::insert_entry_into_database( $new_values ); |
495 | 495 | if ( ! $entry_id ) { |
@@ -501,37 +501,37 @@ discard block |
||
501 | 501 | return $entry_id; |
502 | 502 | } |
503 | 503 | |
504 | - /** |
|
505 | - * Sanitize the POST values before we use them |
|
506 | - * |
|
507 | - * @since 2.0 |
|
508 | - * @param array $values The POST values by reference |
|
509 | - */ |
|
510 | - public static function sanitize_entry_post( &$values ) { |
|
511 | - $sanitize_method = array( |
|
512 | - 'form_id' => 'absint', |
|
513 | - 'frm_action' => 'sanitize_title', |
|
514 | - 'form_key' => 'sanitize_title', |
|
515 | - 'item_key' => 'sanitize_title', |
|
516 | - 'item_name' => 'sanitize_text_field', |
|
517 | - 'frm_saving_draft' => 'absint', |
|
518 | - 'is_draft' => 'absint', |
|
519 | - 'post_id' => 'absint', |
|
520 | - 'parent_item_id' => 'absint', |
|
521 | - 'created_at' => 'sanitize_text_field', |
|
522 | - 'updated_at' => 'sanitize_text_field', |
|
523 | - ); |
|
524 | - |
|
525 | - FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * Prepare the new values for inserting into the database |
|
530 | - * |
|
531 | - * @since 2.0.16 |
|
532 | - * @param array $values |
|
533 | - * @return array $new_values |
|
534 | - */ |
|
504 | + /** |
|
505 | + * Sanitize the POST values before we use them |
|
506 | + * |
|
507 | + * @since 2.0 |
|
508 | + * @param array $values The POST values by reference |
|
509 | + */ |
|
510 | + public static function sanitize_entry_post( &$values ) { |
|
511 | + $sanitize_method = array( |
|
512 | + 'form_id' => 'absint', |
|
513 | + 'frm_action' => 'sanitize_title', |
|
514 | + 'form_key' => 'sanitize_title', |
|
515 | + 'item_key' => 'sanitize_title', |
|
516 | + 'item_name' => 'sanitize_text_field', |
|
517 | + 'frm_saving_draft' => 'absint', |
|
518 | + 'is_draft' => 'absint', |
|
519 | + 'post_id' => 'absint', |
|
520 | + 'parent_item_id' => 'absint', |
|
521 | + 'created_at' => 'sanitize_text_field', |
|
522 | + 'updated_at' => 'sanitize_text_field', |
|
523 | + ); |
|
524 | + |
|
525 | + FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
526 | + } |
|
527 | + |
|
528 | + /** |
|
529 | + * Prepare the new values for inserting into the database |
|
530 | + * |
|
531 | + * @since 2.0.16 |
|
532 | + * @param array $values |
|
533 | + * @return array $new_values |
|
534 | + */ |
|
535 | 535 | private static function package_entry_data( &$values ) { |
536 | 536 | global $wpdb; |
537 | 537 | |
@@ -564,67 +564,67 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | - * Get the is_draft value for a new entry |
|
568 | - * |
|
569 | - * @since 2.0.16 |
|
570 | - * @param array $values |
|
571 | - * @return int |
|
572 | - */ |
|
567 | + * Get the is_draft value for a new entry |
|
568 | + * |
|
569 | + * @since 2.0.16 |
|
570 | + * @param array $values |
|
571 | + * @return int |
|
572 | + */ |
|
573 | 573 | private static function get_is_draft_value( $values ) { |
574 | 574 | return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
578 | - * Get the form_id value for a new entry |
|
579 | - * |
|
580 | - * @since 2.0.16 |
|
581 | - * @param array $values |
|
582 | - * @return int|null |
|
583 | - */ |
|
578 | + * Get the form_id value for a new entry |
|
579 | + * |
|
580 | + * @since 2.0.16 |
|
581 | + * @param array $values |
|
582 | + * @return int|null |
|
583 | + */ |
|
584 | 584 | private static function get_form_id( $values ) { |
585 | 585 | return isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
589 | - * Get the post_id value for a new entry |
|
590 | - * |
|
591 | - * @since 2.0.16 |
|
592 | - * @param array $values |
|
593 | - * @return int |
|
594 | - */ |
|
589 | + * Get the post_id value for a new entry |
|
590 | + * |
|
591 | + * @since 2.0.16 |
|
592 | + * @param array $values |
|
593 | + * @return int |
|
594 | + */ |
|
595 | 595 | private static function get_post_id( $values ) { |
596 | 596 | return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
600 | - * Get the parent_item_id value for a new entry |
|
601 | - * |
|
602 | - * @since 2.0.16 |
|
603 | - * @param array $values |
|
604 | - * @return int |
|
605 | - */ |
|
600 | + * Get the parent_item_id value for a new entry |
|
601 | + * |
|
602 | + * @since 2.0.16 |
|
603 | + * @param array $values |
|
604 | + * @return int |
|
605 | + */ |
|
606 | 606 | private static function get_parent_item_id( $values ) { |
607 | 607 | return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
611 | - * Get the created_at value for a new entry |
|
612 | - * |
|
613 | - * @since 2.0.16 |
|
614 | - * @param array $values |
|
615 | - * @return string |
|
616 | - */ |
|
611 | + * Get the created_at value for a new entry |
|
612 | + * |
|
613 | + * @since 2.0.16 |
|
614 | + * @param array $values |
|
615 | + * @return string |
|
616 | + */ |
|
617 | 617 | private static function get_created_at( $values ) { |
618 | 618 | return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
622 | - * Get the updated_at value for a new entry |
|
623 | - * |
|
624 | - * @since 2.0.16 |
|
625 | - * @param array $values |
|
626 | - * @return string |
|
627 | - */ |
|
622 | + * Get the updated_at value for a new entry |
|
623 | + * |
|
624 | + * @since 2.0.16 |
|
625 | + * @param array $values |
|
626 | + * @return string |
|
627 | + */ |
|
628 | 628 | private static function get_updated_at( $values ) { |
629 | 629 | if ( isset( $values['updated_at'] ) ) { |
630 | 630 | $updated_at = $values['updated_at']; |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
639 | - * Get the description value for a new entry |
|
640 | - * |
|
641 | - * @since 2.0.16 |
|
642 | - * @param array $values |
|
643 | - * @return string |
|
644 | - */ |
|
639 | + * Get the description value for a new entry |
|
640 | + * |
|
641 | + * @since 2.0.16 |
|
642 | + * @param array $values |
|
643 | + * @return string |
|
644 | + */ |
|
645 | 645 | private static function get_entry_description( $values ) { |
646 | 646 | if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) { |
647 | 647 | $description = maybe_serialize( $values['description'] ); |
@@ -656,12 +656,12 @@ discard block |
||
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
659 | - * Get the user_id value for a new entry |
|
660 | - * |
|
661 | - * @since 2.0.16 |
|
662 | - * @param array $values |
|
663 | - * @return int |
|
664 | - */ |
|
659 | + * Get the user_id value for a new entry |
|
660 | + * |
|
661 | + * @since 2.0.16 |
|
662 | + * @param array $values |
|
663 | + * @return int |
|
664 | + */ |
|
665 | 665 | private static function get_entry_user_id( $values ) { |
666 | 666 | if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) { |
667 | 667 | $user_id = $values['frm_user_id']; |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
677 | - * Insert new entry into the database |
|
678 | - * |
|
679 | - * @since 2.0.16 |
|
680 | - * @param array $new_values |
|
681 | - * @return int | boolean $entry_id |
|
682 | - */ |
|
677 | + * Insert new entry into the database |
|
678 | + * |
|
679 | + * @since 2.0.16 |
|
680 | + * @param array $new_values |
|
681 | + * @return int | boolean $entry_id |
|
682 | + */ |
|
683 | 683 | private static function insert_entry_into_database( $new_values ) { |
684 | 684 | global $wpdb; |
685 | 685 | |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
698 | - * Add the new entry to global $frm_vars |
|
699 | - * |
|
700 | - * @since 2.0.16 |
|
701 | - * @param int $entry_id |
|
702 | - */ |
|
698 | + * Add the new entry to global $frm_vars |
|
699 | + * |
|
700 | + * @since 2.0.16 |
|
701 | + * @param int $entry_id |
|
702 | + */ |
|
703 | 703 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
704 | 704 | global $frm_vars; |
705 | 705 | |
@@ -711,12 +711,12 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | /** |
714 | - * Add entry metas, if there are any |
|
715 | - * |
|
716 | - * @since 2.0.16 |
|
717 | - * @param array $values |
|
718 | - * @param int $entry_id |
|
719 | - */ |
|
714 | + * Add entry metas, if there are any |
|
715 | + * |
|
716 | + * @since 2.0.16 |
|
717 | + * @param array $values |
|
718 | + * @param int $entry_id |
|
719 | + */ |
|
720 | 720 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
721 | 721 | if ( isset($values['item_meta']) ) { |
722 | 722 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | } |
725 | 725 | |
726 | 726 | /** |
727 | - * Trigger frm_after_create_entry hooks |
|
728 | - * |
|
729 | - * @since 2.0.16 |
|
730 | - * @param int $entry_id |
|
731 | - * @param array $new_values |
|
732 | - */ |
|
727 | + * Trigger frm_after_create_entry hooks |
|
728 | + * |
|
729 | + * @since 2.0.16 |
|
730 | + * @param int $entry_id |
|
731 | + * @param array $new_values |
|
732 | + */ |
|
733 | 733 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
734 | 734 | // this is a child entry |
735 | 735 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
@@ -739,13 +739,13 @@ discard block |
||
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
742 | - * Actions to perform immediately after an entry is inserted in the frm_items database |
|
743 | - * |
|
744 | - * @since 2.0.16 |
|
745 | - * @param array $values |
|
746 | - * @param array $new_values |
|
747 | - * @param int $entry_id |
|
748 | - */ |
|
742 | + * Actions to perform immediately after an entry is inserted in the frm_items database |
|
743 | + * |
|
744 | + * @since 2.0.16 |
|
745 | + * @param array $values |
|
746 | + * @param array $new_values |
|
747 | + * @param int $entry_id |
|
748 | + */ |
|
749 | 749 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
750 | 750 | |
751 | 751 | self::add_new_entry_to_frm_vars( $entry_id ); |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
761 | - * Perform some actions right before updating an entry |
|
762 | - * |
|
763 | - * @since 2.0.16 |
|
764 | - * @param int $id |
|
765 | - * @param array $values |
|
766 | - * @param string $update_type |
|
767 | - * @return boolean $update |
|
768 | - */ |
|
761 | + * Perform some actions right before updating an entry |
|
762 | + * |
|
763 | + * @since 2.0.16 |
|
764 | + * @param int $id |
|
765 | + * @param array $values |
|
766 | + * @param string $update_type |
|
767 | + * @return boolean $update |
|
768 | + */ |
|
769 | 769 | private static function before_update_entry( $id, &$values, $update_type ) { |
770 | 770 | $update = true; |
771 | 771 | |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
786 | - * Package the entry data for updating |
|
787 | - * |
|
788 | - * @since 2.0.16 |
|
789 | - * @param int $id |
|
790 | - * @param array $values |
|
791 | - * @return array $new_values |
|
792 | - */ |
|
786 | + * Package the entry data for updating |
|
787 | + * |
|
788 | + * @since 2.0.16 |
|
789 | + * @param int $id |
|
790 | + * @param array $values |
|
791 | + * @return array $new_values |
|
792 | + */ |
|
793 | 793 | private static function package_entry_to_update( $id, $values ) { |
794 | 794 | global $wpdb; |
795 | 795 | |
@@ -823,14 +823,14 @@ discard block |
||
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
826 | - * Perform some actions right after updating an entry |
|
827 | - * |
|
828 | - * @since 2.0.16 |
|
829 | - * @param boolean|int $query_results |
|
830 | - * @param int $id |
|
831 | - * @param array $values |
|
832 | - * @param array $new_values |
|
833 | - */ |
|
826 | + * Perform some actions right after updating an entry |
|
827 | + * |
|
828 | + * @since 2.0.16 |
|
829 | + * @param boolean|int $query_results |
|
830 | + * @param int $id |
|
831 | + * @param array $values |
|
832 | + * @param array $new_values |
|
833 | + */ |
|
834 | 834 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
835 | 835 | if ( $query_results ) { |
836 | 836 | self::clear_cache(); |
@@ -852,13 +852,13 @@ discard block |
||
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
855 | - * Create entry from an XML import |
|
856 | - * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
857 | - * |
|
858 | - * @since 2.0.16 |
|
859 | - * @param array $values |
|
860 | - * @return int | boolean $entry_id |
|
861 | - */ |
|
855 | + * Create entry from an XML import |
|
856 | + * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
857 | + * |
|
858 | + * @since 2.0.16 |
|
859 | + * @param array $values |
|
860 | + * @return int | boolean $entry_id |
|
861 | + */ |
|
862 | 862 | public static function create_entry_from_xml( $values ) { |
863 | 863 | $entry_id = self::create_entry( $values, 'xml' ); |
864 | 864 | |
@@ -866,28 +866,28 @@ discard block |
||
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
869 | - * Update entry from an XML import |
|
870 | - * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
871 | - * |
|
872 | - * @since 2.0.16 |
|
873 | - * @param int $id |
|
874 | - * @param array $values |
|
875 | - * @return int | boolean $updated |
|
876 | - */ |
|
869 | + * Update entry from an XML import |
|
870 | + * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
871 | + * |
|
872 | + * @since 2.0.16 |
|
873 | + * @param int $id |
|
874 | + * @param array $values |
|
875 | + * @return int | boolean $updated |
|
876 | + */ |
|
877 | 877 | public static function update_entry_from_xml( $id, $values ) { |
878 | 878 | $updated = self::update_entry( $id, $values, 'xml' ); |
879 | 879 | |
880 | 880 | return $updated; |
881 | 881 | } |
882 | 882 | |
883 | - /** |
|
884 | - * @param string $key |
|
885 | - * @return int entry_id |
|
886 | - */ |
|
883 | + /** |
|
884 | + * @param string $key |
|
885 | + * @return int entry_id |
|
886 | + */ |
|
887 | 887 | public static function get_id_by_key( $key ) { |
888 | - $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
889 | - return $entry_id; |
|
890 | - } |
|
888 | + $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
889 | + return $entry_id; |
|
890 | + } |
|
891 | 891 | |
892 | 892 | public static function validate( $values, $exclude = false ) { |
893 | 893 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryValidate::validate' ); |
@@ -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 | |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
56 | 56 | |
57 | 57 | if ( $new_values['item_key'] == $new_values['name'] ) { |
58 | - unset($check_val['name']); |
|
58 | + unset( $check_val['name'] ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | global $wpdb; |
62 | 62 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
63 | 63 | |
64 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
64 | + if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | 67 | |
@@ -70,10 +70,10 @@ discard block |
||
70 | 70 | $is_duplicate = true; |
71 | 71 | |
72 | 72 | //add more checks here to make sure it's a duplicate |
73 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
73 | + $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
|
74 | 74 | $field_metas = array(); |
75 | 75 | foreach ( $metas as $meta ) { |
76 | - $field_metas[ $meta->field_id ] = $meta->meta_value; |
|
76 | + $field_metas[$meta->field_id] = $meta->meta_value; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | // If prev entry is empty and current entry is not, they are not duplicates |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
85 | + $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) ); |
|
86 | 86 | foreach ( $diff as $field_id => $meta_value ) { |
87 | - if ( ! empty($meta_value) ) { |
|
87 | + if ( ! empty( $meta_value ) ) { |
|
88 | 88 | $is_duplicate = false; |
89 | 89 | continue; |
90 | 90 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // If CSV is importing, don't check for duplicates |
116 | - if ( defined('WP_IMPORTING') && WP_IMPORTING ) { |
|
116 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $new_values['is_draft'] = $values->is_draft; |
137 | 137 | $new_values['user_id'] = (int) $values->user_id; |
138 | 138 | $new_values['updated_by'] = (int) $values->user_id; |
139 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
139 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
140 | 140 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
141 | 141 | $new_values['updated_at'] = $new_values['created_at']; |
142 | 142 | |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | $entry_id = $wpdb->insert_id; |
149 | 149 | |
150 | 150 | global $frm_vars; |
151 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
151 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
152 | 152 | $frm_vars['saved_entries'] = array(); |
153 | 153 | } |
154 | 154 | $frm_vars['saved_entries'][] = (int) $entry_id; |
155 | 155 | |
156 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
156 | + FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
|
157 | 157 | self::clear_cache(); |
158 | 158 | |
159 | 159 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $new_values = self::package_entry_to_update( $id, $values ); |
194 | 194 | |
195 | - $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') ); |
|
195 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); |
|
196 | 196 | |
197 | 197 | self::after_update_entry( $query_results, $id, $values, $new_values ); |
198 | 198 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | return $result; |
210 | 210 | } |
211 | 211 | |
212 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
212 | + do_action( 'frm_before_destroy_entry', $id, $entry ); |
|
213 | 213 | |
214 | 214 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
215 | 215 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | public static function update_form( $id, $value, $form_id ) { |
223 | 223 | global $wpdb; |
224 | - $form_id = isset($value) ? $form_id : null; |
|
224 | + $form_id = isset( $value ) ? $form_id : null; |
|
225 | 225 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
226 | 226 | if ( $result ) { |
227 | 227 | self::clear_cache(); |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
269 | 269 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
270 | 270 | |
271 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
271 | + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
|
272 | 272 | $query_args = array( $id ); |
273 | 273 | $query = $wpdb->prepare( $query, $query_args ); |
274 | 274 | |
275 | 275 | if ( ! $meta ) { |
276 | 276 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
277 | - return stripslashes_deep($entry); |
|
277 | + return stripslashes_deep( $entry ); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
281 | 281 | if ( $entry !== false ) { |
282 | - return stripslashes_deep($entry); |
|
282 | + return stripslashes_deep( $entry ); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | $entry = $wpdb->get_row( $query ); |
286 | - $entry = self::get_meta($entry); |
|
286 | + $entry = self::get_meta( $entry ); |
|
287 | 287 | |
288 | - return stripslashes_deep($entry); |
|
288 | + return stripslashes_deep( $entry ); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | public static function get_meta( $entry ) { |
@@ -301,23 +301,23 @@ discard block |
||
301 | 301 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
302 | 302 | foreach ( $metas as $meta_val ) { |
303 | 303 | if ( $meta_val->item_id == $entry->id ) { |
304 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
304 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
305 | 305 | if ( $include_key ) { |
306 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
306 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
307 | 307 | } |
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // include sub entries in an array |
312 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
313 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
312 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
313 | + $entry->metas[$meta_val->field_id] = array(); |
|
314 | 314 | } |
315 | 315 | |
316 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
316 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
317 | 317 | |
318 | - unset($meta_val); |
|
318 | + unset( $meta_val ); |
|
319 | 319 | } |
320 | - unset($metas); |
|
320 | + unset( $metas ); |
|
321 | 321 | |
322 | 322 | FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' ); |
323 | 323 | |
@@ -335,24 +335,24 @@ discard block |
||
335 | 335 | return $exists; |
336 | 336 | } |
337 | 337 | |
338 | - if ( is_numeric($id) ) { |
|
338 | + if ( is_numeric( $id ) ) { |
|
339 | 339 | $where = array( 'id' => $id ); |
340 | 340 | } else { |
341 | 341 | $where = array( 'item_key' => $id ); |
342 | 342 | } |
343 | 343 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
344 | 344 | |
345 | - $exists = ($id && $id > 0) ? true : false; |
|
345 | + $exists = ( $id && $id > 0 ) ? true : false; |
|
346 | 346 | return $exists; |
347 | 347 | } |
348 | 348 | |
349 | 349 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
350 | 350 | global $wpdb; |
351 | 351 | |
352 | - $limit = FrmAppHelper::esc_limit($limit); |
|
352 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
353 | 353 | |
354 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
355 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
354 | + $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
|
355 | + $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
|
356 | 356 | |
357 | 357 | if ( false === $entries ) { |
358 | 358 | $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
@@ -371,25 +371,25 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | // prepare the query |
374 | - $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
374 | + $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
375 | 375 | |
376 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
377 | - unset($query); |
|
376 | + $entries = $wpdb->get_results( $query, OBJECT_K ); |
|
377 | + unset( $query ); |
|
378 | 378 | |
379 | 379 | FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' ); |
380 | 380 | } |
381 | 381 | |
382 | 382 | if ( ! $meta || ! $entries ) { |
383 | - return stripslashes_deep($entries); |
|
383 | + return stripslashes_deep( $entries ); |
|
384 | 384 | } |
385 | - unset($meta); |
|
385 | + unset( $meta ); |
|
386 | 386 | |
387 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
387 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
388 | 388 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
389 | 389 | } |
390 | 390 | |
391 | 391 | $meta_where = array( 'field_id !' => 0 ); |
392 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
392 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
393 | 393 | $meta_where['fi.form_id'] = $where['it.form_id']; |
394 | 394 | } else { |
395 | 395 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -400,21 +400,21 @@ discard block |
||
400 | 400 | unset( $meta_where ); |
401 | 401 | |
402 | 402 | if ( ! $metas ) { |
403 | - return stripslashes_deep($entries); |
|
403 | + return stripslashes_deep( $entries ); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | foreach ( $metas as $m_key => $meta_val ) { |
407 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
407 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | |
411 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
412 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
411 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
412 | + $entries[$meta_val->item_id]->metas = array(); |
|
413 | 413 | } |
414 | 414 | |
415 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
415 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
416 | 416 | |
417 | - unset($m_key, $meta_val); |
|
417 | + unset( $m_key, $meta_val ); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | - return stripslashes_deep($entries); |
|
427 | + return stripslashes_deep( $entries ); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | // Pagination Methods |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | global $wpdb; |
433 | 433 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
434 | 434 | |
435 | - if ( is_numeric($where) ) { |
|
435 | + if ( is_numeric( $where ) ) { |
|
436 | 436 | $table_join = 'frm_items'; |
437 | 437 | $where = array( 'form_id' => $where ); |
438 | 438 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | self::sanitize_entry_post( $values ); |
475 | 475 | |
476 | 476 | if ( $type != 'xml' ) { |
477 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
477 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | $new_values = self::package_entry_data( $values ); |
@@ -554,11 +554,11 @@ discard block |
||
554 | 554 | 'user_id' => self::get_entry_user_id( $values ), |
555 | 555 | ); |
556 | 556 | |
557 | - if ( is_array($new_values['name']) ) { |
|
558 | - $new_values['name'] = reset($new_values['name']); |
|
557 | + if ( is_array( $new_values['name'] ) ) { |
|
558 | + $new_values['name'] = reset( $new_values['name'] ); |
|
559 | 559 | } |
560 | 560 | |
561 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
561 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
562 | 562 | |
563 | 563 | return $new_values; |
564 | 564 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * @return int |
594 | 594 | */ |
595 | 595 | private static function get_post_id( $values ) { |
596 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
596 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @return int |
605 | 605 | */ |
606 | 606 | private static function get_parent_item_id( $values ) { |
607 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
607 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @return string |
616 | 616 | */ |
617 | 617 | private static function get_created_at( $values ) { |
618 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
618 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
704 | 704 | global $frm_vars; |
705 | 705 | |
706 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
706 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
707 | 707 | $frm_vars['saved_entries'] = array(); |
708 | 708 | } |
709 | 709 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * @param int $entry_id |
719 | 719 | */ |
720 | 720 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
721 | - if ( isset($values['item_meta']) ) { |
|
721 | + if ( isset( $values['item_meta'] ) ) { |
|
722 | 722 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
723 | 723 | } |
724 | 724 | } |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
736 | 736 | |
737 | 737 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
738 | - do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
738 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | } |
777 | 777 | |
778 | 778 | if ( $update && $update_type != 'xml' ) { |
779 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
779 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | return $update; |
@@ -797,27 +797,27 @@ discard block |
||
797 | 797 | 'name' => self::get_new_entry_name( $values ), |
798 | 798 | 'form_id' => self::get_form_id( $values ), |
799 | 799 | 'is_draft' => self::get_is_draft_value( $values ), |
800 | - 'updated_at' => current_time('mysql', 1), |
|
801 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
800 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
801 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
802 | 802 | ); |
803 | 803 | |
804 | - if ( isset($values['post_id']) ) { |
|
804 | + if ( isset( $values['post_id'] ) ) { |
|
805 | 805 | $new_values['post_id'] = (int) $values['post_id']; |
806 | 806 | } |
807 | 807 | |
808 | - if ( isset($values['item_key']) ) { |
|
808 | + if ( isset( $values['item_key'] ) ) { |
|
809 | 809 | $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
810 | 810 | } |
811 | 811 | |
812 | - if ( isset($values['parent_item_id']) ) { |
|
812 | + if ( isset( $values['parent_item_id'] ) ) { |
|
813 | 813 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
814 | 814 | } |
815 | 815 | |
816 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
816 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
817 | 817 | $new_values['user_id'] = $values['frm_user_id']; |
818 | 818 | } |
819 | 819 | |
820 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
820 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
821 | 821 | |
822 | 822 | return $new_values; |
823 | 823 | } |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | 'highrise' => 'FrmDefHrsAction', |
49 | 49 | ) ); |
50 | 50 | |
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
51 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php' ); |
|
52 | + include_once( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php' ); |
|
53 | 53 | |
54 | 54 | foreach ( $action_classes as $action_class ) { |
55 | - self::$registered_actions->register($action_class); |
|
55 | + self::$registered_actions->register( $action_class ); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | 60 | $temp_actions = self::$registered_actions; |
61 | - if ( empty($temp_actions) ) { |
|
61 | + if ( empty( $temp_actions ) ) { |
|
62 | 62 | self::actions_init(); |
63 | 63 | $temp_actions = self::$registered_actions->actions; |
64 | 64 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $a; |
73 | 73 | } |
74 | 74 | |
75 | - $actions[ $a->id_base ] = $a; |
|
75 | + $actions[$a->id_base] = $a; |
|
76 | 76 | } |
77 | 77 | unset( $temp_actions, $a ); |
78 | 78 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | arsort( $temp_actions ); |
87 | 87 | foreach ( $temp_actions as $type => $a ) { |
88 | 88 | if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
89 | - unset( $actions[ $type ] ); |
|
89 | + unset( $actions[$type] ); |
|
90 | 90 | if ( count( $actions ) <= $action_limit ) { |
91 | 91 | break; |
92 | 92 | } |
@@ -118,26 +118,26 @@ discard block |
||
118 | 118 | $action_map = array(); |
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
121 | + $action_map[$control->id_base] = $key; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | foreach ( $form_actions as $action ) { |
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
125 | + if ( ! isset( $action_map[$action->post_excerpt] ) ) { |
|
126 | 126 | // don't try and show settings if action no longer exists |
127 | 127 | continue; |
128 | 128 | } |
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[$action_map[$action->post_excerpt]], $values ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
135 | + $action_control->_set( $action_key ); |
|
136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | public static function add_form_action() { |
140 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
140 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
141 | 141 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
142 | 142 | |
143 | 143 | global $frm_vars; |
@@ -146,55 +146,55 @@ discard block |
||
146 | 146 | $action_type = sanitize_text_field( $_POST['type'] ); |
147 | 147 | |
148 | 148 | $action_control = self::get_form_actions( $action_type ); |
149 | - $action_control->_set($action_key); |
|
149 | + $action_control->_set( $action_key ); |
|
150 | 150 | |
151 | 151 | $form_id = absint( $_POST['form_id'] ); |
152 | 152 | |
153 | - $form_action = $action_control->prepare_new($form_id); |
|
153 | + $form_action = $action_control->prepare_new( $form_id ); |
|
154 | 154 | |
155 | 155 | $values = array(); |
156 | - $form = self::fields_to_values($form_id, $values); |
|
156 | + $form = self::fields_to_values( $form_id, $values ); |
|
157 | 157 | |
158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
159 | 159 | wp_die(); |
160 | 160 | } |
161 | 161 | |
162 | 162 | public static function fill_action() { |
163 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
163 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
164 | 164 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
165 | 165 | |
166 | 166 | $action_key = absint( $_POST['action_id'] ); |
167 | 167 | $action_type = sanitize_text_field( $_POST['action_type'] ); |
168 | 168 | |
169 | 169 | $action_control = self::get_form_actions( $action_type ); |
170 | - if ( empty($action_control) ) { |
|
170 | + if ( empty( $action_control ) ) { |
|
171 | 171 | wp_die(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | $form_action = $action_control->get_single_action( $action_key ); |
175 | 175 | |
176 | 176 | $values = array(); |
177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
177 | + $form = self::fields_to_values( $form_action->menu_order, $values ); |
|
178 | 178 | |
179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
180 | 180 | wp_die(); |
181 | 181 | } |
182 | 182 | |
183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
184 | - $form = FrmForm::getOne($form_id); |
|
184 | + $form = FrmForm::getOne( $form_id ); |
|
185 | 185 | |
186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
187 | 187 | |
188 | - $fields = FrmField::get_all_for_form($form->id); |
|
188 | + $fields = FrmField::get_all_for_form( $form->id ); |
|
189 | 189 | foreach ( $fields as $k => $f ) { |
190 | 190 | $f = (array) $f; |
191 | 191 | $opts = (array) $f['field_options']; |
192 | - $f = array_merge($opts, $f); |
|
192 | + $f = array_merge( $opts, $f ); |
|
193 | 193 | if ( ! isset( $f['post_field'] ) ) { |
194 | 194 | $f['post_field'] = ''; |
195 | 195 | } |
196 | 196 | $values['fields'][] = $f; |
197 | - unset($k, $f); |
|
197 | + unset( $k, $f ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $form; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $new_actions = array(); |
210 | 210 | |
211 | 211 | foreach ( $registered_actions as $registered_action ) { |
212 | - $action_ids = $registered_action->update_callback($form_id); |
|
212 | + $action_ids = $registered_action->update_callback( $form_id ); |
|
213 | 213 | if ( ! empty( $action_ids ) ) { |
214 | 214 | $new_actions[] = $action_ids; |
215 | 215 | } |
@@ -291,33 +291,33 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | // store actions so they can be triggered with the correct priority |
294 | - $stored_actions[ $action->ID ] = $action; |
|
295 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
294 | + $stored_actions[$action->ID] = $action; |
|
295 | + $action_priority[$action->ID] = $link_settings[$action->post_excerpt]->action_options['priority']; |
|
296 | 296 | |
297 | - unset($action); |
|
297 | + unset( $action ); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | if ( ! empty( $stored_actions ) ) { |
301 | - asort($action_priority); |
|
301 | + asort( $action_priority ); |
|
302 | 302 | |
303 | 303 | // make sure hooks are loaded |
304 | 304 | new FrmNotification(); |
305 | 305 | |
306 | 306 | foreach ( $action_priority as $action_id => $priority ) { |
307 | - $action = $stored_actions[ $action_id ]; |
|
307 | + $action = $stored_actions[$action_id]; |
|
308 | 308 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
309 | 309 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
310 | 310 | |
311 | 311 | // If post is created, get updated $entry object |
312 | 312 | if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
313 | - $entry = FrmEntry::getOne($entry->id, true); |
|
313 | + $entry = FrmEntry::getOne( $entry->id, true ); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
318 | 318 | |
319 | 319 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
320 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
320 | + if ( ! isset( $args['old_id'] ) || empty( $args['old_id'] ) ) { |
|
321 | 321 | // continue if we know which actions to copy |
322 | 322 | return; |
323 | 323 | } |
@@ -351,22 +351,22 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | public function register( $action_class ) { |
354 | - $this->actions[ $action_class ] = new $action_class(); |
|
354 | + $this->actions[$action_class] = new $action_class(); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | public function unregister( $action_class ) { |
358 | - if ( isset( $this->actions[ $action_class ] ) ) { |
|
359 | - unset($this->actions[ $action_class ]); |
|
358 | + if ( isset( $this->actions[$action_class] ) ) { |
|
359 | + unset( $this->actions[$action_class] ); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | 363 | public function _register_actions() { |
364 | - $keys = array_keys($this->actions); |
|
364 | + $keys = array_keys( $this->actions ); |
|
365 | 365 | |
366 | 366 | foreach ( $keys as $key ) { |
367 | 367 | // don't register new action if old action with the same id is already registered |
368 | - if ( ! isset( $this->actions[ $key ] ) ) { |
|
369 | - $this->actions[ $key ]->_register(); |
|
368 | + if ( ! isset( $this->actions[$key] ) ) { |
|
369 | + $this->actions[$key]->_register(); |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | } |
@@ -1,109 +1,109 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | class FrmFormActionsController { |
4 | - public static $action_post_type = 'frm_form_actions'; |
|
5 | - public static $registered_actions; |
|
6 | - |
|
7 | - public static function register_post_types() { |
|
8 | - register_post_type( self::$action_post_type, array( |
|
9 | - 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | - 'description' => '', |
|
11 | - 'public' => false, |
|
12 | - 'show_ui' => false, |
|
13 | - 'exclude_from_search' => true, |
|
14 | - 'show_in_nav_menus' => false, |
|
15 | - 'show_in_menu' => true, |
|
16 | - 'capability_type' => 'page', |
|
17 | - 'supports' => array( |
|
4 | + public static $action_post_type = 'frm_form_actions'; |
|
5 | + public static $registered_actions; |
|
6 | + |
|
7 | + public static function register_post_types() { |
|
8 | + register_post_type( self::$action_post_type, array( |
|
9 | + 'label' => __( 'Form Actions', 'formidable' ), |
|
10 | + 'description' => '', |
|
11 | + 'public' => false, |
|
12 | + 'show_ui' => false, |
|
13 | + 'exclude_from_search' => true, |
|
14 | + 'show_in_nav_menus' => false, |
|
15 | + 'show_in_menu' => true, |
|
16 | + 'capability_type' => 'page', |
|
17 | + 'supports' => array( |
|
18 | 18 | 'title', 'editor', 'excerpt', 'custom-fields', |
19 | 19 | 'page-attributes', |
20 | - ), |
|
21 | - 'has_archive' => false, |
|
22 | - ) ); |
|
23 | - |
|
24 | - /** |
|
25 | - * post_content: json settings |
|
26 | - * menu_order: form id |
|
27 | - * post_excerpt: action type |
|
28 | - */ |
|
29 | - |
|
30 | - self::actions_init(); |
|
31 | - } |
|
32 | - |
|
33 | - public static function actions_init() { |
|
34 | - self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | - self::register_actions(); |
|
36 | - do_action( 'frm_form_actions_init' ); |
|
37 | - } |
|
38 | - |
|
39 | - public static function register_actions() { |
|
40 | - $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | - 'email' => 'FrmEmailAction', |
|
42 | - 'wppost' => 'FrmDefPostAction', |
|
43 | - 'register' => 'FrmDefRegAction', |
|
44 | - 'paypal' => 'FrmDefPayPalAction', |
|
45 | - //'aweber' => 'FrmDefAweberAction', |
|
46 | - 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | - 'twilio' => 'FrmDefTwilioAction', |
|
48 | - 'highrise' => 'FrmDefHrsAction', |
|
49 | - ) ); |
|
50 | - |
|
51 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | - include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | - |
|
54 | - foreach ( $action_classes as $action_class ) { |
|
55 | - self::$registered_actions->register($action_class); |
|
56 | - } |
|
57 | - } |
|
20 | + ), |
|
21 | + 'has_archive' => false, |
|
22 | + ) ); |
|
23 | + |
|
24 | + /** |
|
25 | + * post_content: json settings |
|
26 | + * menu_order: form id |
|
27 | + * post_excerpt: action type |
|
28 | + */ |
|
29 | + |
|
30 | + self::actions_init(); |
|
31 | + } |
|
32 | + |
|
33 | + public static function actions_init() { |
|
34 | + self::$registered_actions = new Frm_Form_Action_Factory(); |
|
35 | + self::register_actions(); |
|
36 | + do_action( 'frm_form_actions_init' ); |
|
37 | + } |
|
38 | + |
|
39 | + public static function register_actions() { |
|
40 | + $action_classes = apply_filters( 'frm_registered_form_actions', array( |
|
41 | + 'email' => 'FrmEmailAction', |
|
42 | + 'wppost' => 'FrmDefPostAction', |
|
43 | + 'register' => 'FrmDefRegAction', |
|
44 | + 'paypal' => 'FrmDefPayPalAction', |
|
45 | + //'aweber' => 'FrmDefAweberAction', |
|
46 | + 'mailchimp' => 'FrmDefMlcmpAction', |
|
47 | + 'twilio' => 'FrmDefTwilioAction', |
|
48 | + 'highrise' => 'FrmDefHrsAction', |
|
49 | + ) ); |
|
50 | + |
|
51 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'); |
|
52 | + include_once(FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'); |
|
53 | + |
|
54 | + foreach ( $action_classes as $action_class ) { |
|
55 | + self::$registered_actions->register($action_class); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | 59 | public static function get_form_actions( $action = 'all' ) { |
60 | - $temp_actions = self::$registered_actions; |
|
61 | - if ( empty($temp_actions) ) { |
|
62 | - self::actions_init(); |
|
63 | - $temp_actions = self::$registered_actions->actions; |
|
64 | - } else { |
|
65 | - $temp_actions = $temp_actions->actions; |
|
66 | - } |
|
60 | + $temp_actions = self::$registered_actions; |
|
61 | + if ( empty($temp_actions) ) { |
|
62 | + self::actions_init(); |
|
63 | + $temp_actions = self::$registered_actions->actions; |
|
64 | + } else { |
|
65 | + $temp_actions = $temp_actions->actions; |
|
66 | + } |
|
67 | 67 | |
68 | - $actions = array(); |
|
68 | + $actions = array(); |
|
69 | 69 | |
70 | - foreach ( $temp_actions as $a ) { |
|
71 | - if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | - return $a; |
|
73 | - } |
|
70 | + foreach ( $temp_actions as $a ) { |
|
71 | + if ( 'all' != $action && $a->id_base == $action ) { |
|
72 | + return $a; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | $actions[ $a->id_base ] = $a; |
76 | - } |
|
77 | - unset( $temp_actions, $a ); |
|
78 | - |
|
79 | - $action_limit = 10; |
|
80 | - if ( count( $actions ) <= $action_limit ) { |
|
81 | - return $actions; |
|
82 | - } |
|
83 | - |
|
84 | - // remove the last few inactive icons if there are too many |
|
85 | - $temp_actions = $actions; |
|
86 | - arsort( $temp_actions ); |
|
87 | - foreach ( $temp_actions as $type => $a ) { |
|
88 | - if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
76 | + } |
|
77 | + unset( $temp_actions, $a ); |
|
78 | + |
|
79 | + $action_limit = 10; |
|
80 | + if ( count( $actions ) <= $action_limit ) { |
|
81 | + return $actions; |
|
82 | + } |
|
83 | + |
|
84 | + // remove the last few inactive icons if there are too many |
|
85 | + $temp_actions = $actions; |
|
86 | + arsort( $temp_actions ); |
|
87 | + foreach ( $temp_actions as $type => $a ) { |
|
88 | + if ( ! isset( $a->action_options['active'] ) || empty( $a->action_options['active'] ) ) { |
|
89 | 89 | unset( $actions[ $type ] ); |
90 | - if ( count( $actions ) <= $action_limit ) { |
|
91 | - break; |
|
92 | - } |
|
93 | - } |
|
94 | - unset( $type, $a ); |
|
95 | - } |
|
90 | + if ( count( $actions ) <= $action_limit ) { |
|
91 | + break; |
|
92 | + } |
|
93 | + } |
|
94 | + unset( $type, $a ); |
|
95 | + } |
|
96 | 96 | |
97 | - return $actions; |
|
98 | - } |
|
97 | + return $actions; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @since 2.0 |
102 | 102 | */ |
103 | - public static function list_actions( $form, $values ) { |
|
104 | - if ( empty( $form ) ) { |
|
105 | - return; |
|
106 | - } |
|
103 | + public static function list_actions( $form, $values ) { |
|
104 | + if ( empty( $form ) ) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | 108 | /** |
109 | 109 | * use this hook to migrate old settings into a new action |
@@ -113,116 +113,116 @@ discard block |
||
113 | 113 | |
114 | 114 | $form_actions = FrmFormAction::get_action_for_form( $form->id ); |
115 | 115 | |
116 | - $action_controls = self::get_form_actions(); |
|
116 | + $action_controls = self::get_form_actions(); |
|
117 | 117 | |
118 | - $action_map = array(); |
|
118 | + $action_map = array(); |
|
119 | 119 | |
120 | 120 | foreach ( $action_controls as $key => $control ) { |
121 | - $action_map[ $control->id_base ] = $key; |
|
122 | - } |
|
121 | + $action_map[ $control->id_base ] = $key; |
|
122 | + } |
|
123 | 123 | |
124 | - foreach ( $form_actions as $action ) { |
|
125 | - if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | - // don't try and show settings if action no longer exists |
|
127 | - continue; |
|
128 | - } |
|
124 | + foreach ( $form_actions as $action ) { |
|
125 | + if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
|
126 | + // don't try and show settings if action no longer exists |
|
127 | + continue; |
|
128 | + } |
|
129 | 129 | |
130 | - self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | - } |
|
132 | - } |
|
130 | + self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
135 | - $action_control->_set($action_key); |
|
135 | + $action_control->_set($action_key); |
|
136 | 136 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - public static function add_form_action() { |
|
139 | + public static function add_form_action() { |
|
140 | 140 | FrmAppHelper::permission_check('frm_edit_forms'); |
141 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
141 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
142 | 142 | |
143 | - global $frm_vars; |
|
143 | + global $frm_vars; |
|
144 | 144 | |
145 | 145 | $action_key = absint( $_POST['list_id'] ); |
146 | - $action_type = sanitize_text_field( $_POST['type'] ); |
|
146 | + $action_type = sanitize_text_field( $_POST['type'] ); |
|
147 | 147 | |
148 | - $action_control = self::get_form_actions( $action_type ); |
|
149 | - $action_control->_set($action_key); |
|
148 | + $action_control = self::get_form_actions( $action_type ); |
|
149 | + $action_control->_set($action_key); |
|
150 | 150 | |
151 | - $form_id = absint( $_POST['form_id'] ); |
|
151 | + $form_id = absint( $_POST['form_id'] ); |
|
152 | 152 | |
153 | - $form_action = $action_control->prepare_new($form_id); |
|
153 | + $form_action = $action_control->prepare_new($form_id); |
|
154 | 154 | |
155 | - $values = array(); |
|
156 | - $form = self::fields_to_values($form_id, $values); |
|
155 | + $values = array(); |
|
156 | + $form = self::fields_to_values($form_id, $values); |
|
157 | 157 | |
158 | 158 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/form_action.php' ); |
159 | - wp_die(); |
|
160 | - } |
|
159 | + wp_die(); |
|
160 | + } |
|
161 | 161 | |
162 | - public static function fill_action() { |
|
162 | + public static function fill_action() { |
|
163 | 163 | FrmAppHelper::permission_check('frm_edit_forms'); |
164 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
164 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
165 | 165 | |
166 | - $action_key = absint( $_POST['action_id'] ); |
|
167 | - $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
166 | + $action_key = absint( $_POST['action_id'] ); |
|
167 | + $action_type = sanitize_text_field( $_POST['action_type'] ); |
|
168 | 168 | |
169 | - $action_control = self::get_form_actions( $action_type ); |
|
170 | - if ( empty($action_control) ) { |
|
171 | - wp_die(); |
|
172 | - } |
|
169 | + $action_control = self::get_form_actions( $action_type ); |
|
170 | + if ( empty($action_control) ) { |
|
171 | + wp_die(); |
|
172 | + } |
|
173 | 173 | |
174 | - $form_action = $action_control->get_single_action( $action_key ); |
|
174 | + $form_action = $action_control->get_single_action( $action_key ); |
|
175 | 175 | |
176 | - $values = array(); |
|
177 | - $form = self::fields_to_values($form_action->menu_order, $values); |
|
176 | + $values = array(); |
|
177 | + $form = self::fields_to_values($form_action->menu_order, $values); |
|
178 | 178 | |
179 | 179 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/_action_inside.php' ); |
180 | - wp_die(); |
|
181 | - } |
|
180 | + wp_die(); |
|
181 | + } |
|
182 | 182 | |
183 | 183 | private static function fields_to_values( $form_id, array &$values ) { |
184 | - $form = FrmForm::getOne($form_id); |
|
184 | + $form = FrmForm::getOne($form_id); |
|
185 | 185 | |
186 | 186 | $values = array( 'fields' => array(), 'id' => $form->id ); |
187 | 187 | |
188 | - $fields = FrmField::get_all_for_form($form->id); |
|
189 | - foreach ( $fields as $k => $f ) { |
|
190 | - $f = (array) $f; |
|
191 | - $opts = (array) $f['field_options']; |
|
192 | - $f = array_merge($opts, $f); |
|
193 | - if ( ! isset( $f['post_field'] ) ) { |
|
194 | - $f['post_field'] = ''; |
|
195 | - } |
|
196 | - $values['fields'][] = $f; |
|
197 | - unset($k, $f); |
|
198 | - } |
|
199 | - |
|
200 | - return $form; |
|
201 | - } |
|
188 | + $fields = FrmField::get_all_for_form($form->id); |
|
189 | + foreach ( $fields as $k => $f ) { |
|
190 | + $f = (array) $f; |
|
191 | + $opts = (array) $f['field_options']; |
|
192 | + $f = array_merge($opts, $f); |
|
193 | + if ( ! isset( $f['post_field'] ) ) { |
|
194 | + $f['post_field'] = ''; |
|
195 | + } |
|
196 | + $values['fields'][] = $f; |
|
197 | + unset($k, $f); |
|
198 | + } |
|
199 | + |
|
200 | + return $form; |
|
201 | + } |
|
202 | 202 | |
203 | 203 | public static function update_settings( $form_id ) { |
204 | - global $wpdb; |
|
204 | + global $wpdb; |
|
205 | 205 | |
206 | - $registered_actions = self::$registered_actions->actions; |
|
206 | + $registered_actions = self::$registered_actions->actions; |
|
207 | 207 | |
208 | 208 | $old_actions = FrmDb::get_col( $wpdb->posts, array( 'post_type' => self::$action_post_type, 'menu_order' => $form_id ), 'ID' ); |
209 | - $new_actions = array(); |
|
209 | + $new_actions = array(); |
|
210 | 210 | |
211 | - foreach ( $registered_actions as $registered_action ) { |
|
212 | - $action_ids = $registered_action->update_callback($form_id); |
|
213 | - if ( ! empty( $action_ids ) ) { |
|
214 | - $new_actions[] = $action_ids; |
|
215 | - } |
|
216 | - } |
|
211 | + foreach ( $registered_actions as $registered_action ) { |
|
212 | + $action_ids = $registered_action->update_callback($form_id); |
|
213 | + if ( ! empty( $action_ids ) ) { |
|
214 | + $new_actions[] = $action_ids; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | - //Only use array_merge if there are new actions |
|
219 | - if ( ! empty( $new_actions ) ) { |
|
220 | - $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
221 | - } |
|
222 | - $old_actions = array_diff( $old_actions, $new_actions ); |
|
218 | + //Only use array_merge if there are new actions |
|
219 | + if ( ! empty( $new_actions ) ) { |
|
220 | + $new_actions = call_user_func_array( 'array_merge', $new_actions ); |
|
221 | + } |
|
222 | + $old_actions = array_diff( $old_actions, $new_actions ); |
|
223 | 223 | |
224 | 224 | self::delete_missing_actions( $old_actions ); |
225 | - } |
|
225 | + } |
|
226 | 226 | |
227 | 227 | public static function delete_missing_actions( $old_actions ) { |
228 | 228 | if ( ! empty( $old_actions ) ) { |
@@ -242,22 +242,22 @@ discard block |
||
242 | 242 | self::trigger_actions( $event, $form_id, $entry_id, 'all', $args ); |
243 | 243 | } |
244 | 244 | |
245 | - /** |
|
246 | - * @param string $event |
|
247 | - */ |
|
245 | + /** |
|
246 | + * @param string $event |
|
247 | + */ |
|
248 | 248 | public static function trigger_actions( $event, $form, $entry, $type = 'all', $args = array() ) { |
249 | 249 | $form_actions = FrmFormAction::get_action_for_form( ( is_object( $form ) ? $form->id : $form ), $type ); |
250 | 250 | |
251 | 251 | if ( empty( $form_actions ) ) { |
252 | - return; |
|
253 | - } |
|
252 | + return; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | FrmForm::maybe_get_form( $form ); |
256 | 256 | |
257 | - $link_settings = self::get_form_actions( $type ); |
|
258 | - if ( 'all' != $type ) { |
|
259 | - $link_settings = array( $type => $link_settings ); |
|
260 | - } |
|
257 | + $link_settings = self::get_form_actions( $type ); |
|
258 | + if ( 'all' != $type ) { |
|
259 | + $link_settings = array( $type => $link_settings ); |
|
260 | + } |
|
261 | 261 | |
262 | 262 | $stored_actions = array(); |
263 | 263 | $action_priority = array(); |
@@ -268,17 +268,17 @@ discard block |
||
268 | 268 | $this_event = $event; |
269 | 269 | } |
270 | 270 | |
271 | - foreach ( $form_actions as $action ) { |
|
271 | + foreach ( $form_actions as $action ) { |
|
272 | 272 | |
273 | 273 | $skip_this_action = ( ! in_array( $this_event, $action->post_content['event'] ) ); |
274 | 274 | $skip_this_action = apply_filters( 'frm_skip_form_action', $skip_this_action, compact( 'action', 'entry', 'form', 'event' ) ); |
275 | 275 | if ( $skip_this_action ) { |
276 | - continue; |
|
277 | - } |
|
276 | + continue; |
|
277 | + } |
|
278 | 278 | |
279 | - if ( ! is_object( $entry ) ) { |
|
280 | - $entry = FrmEntry::getOne( $entry, true ); |
|
281 | - } |
|
279 | + if ( ! is_object( $entry ) ) { |
|
280 | + $entry = FrmEntry::getOne( $entry, true ); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | if ( empty( $entry ) || ( $entry->is_draft && $event != 'draft' ) ) { |
284 | 284 | continue; |
@@ -292,64 +292,64 @@ discard block |
||
292 | 292 | if ( ! $trigger_children ) { |
293 | 293 | continue; |
294 | 294 | } |
295 | - } |
|
295 | + } |
|
296 | 296 | |
297 | - // check conditional logic |
|
297 | + // check conditional logic |
|
298 | 298 | $stop = FrmFormAction::action_conditions_met( $action, $entry ); |
299 | - if ( $stop ) { |
|
300 | - continue; |
|
301 | - } |
|
299 | + if ( $stop ) { |
|
300 | + continue; |
|
301 | + } |
|
302 | 302 | |
303 | - // store actions so they can be triggered with the correct priority |
|
304 | - $stored_actions[ $action->ID ] = $action; |
|
305 | - $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
303 | + // store actions so they can be triggered with the correct priority |
|
304 | + $stored_actions[ $action->ID ] = $action; |
|
305 | + $action_priority[ $action->ID ] = $link_settings[ $action->post_excerpt ]->action_options['priority']; |
|
306 | 306 | |
307 | - unset($action); |
|
308 | - } |
|
307 | + unset($action); |
|
308 | + } |
|
309 | 309 | |
310 | - if ( ! empty( $stored_actions ) ) { |
|
311 | - asort($action_priority); |
|
310 | + if ( ! empty( $stored_actions ) ) { |
|
311 | + asort($action_priority); |
|
312 | 312 | |
313 | - // make sure hooks are loaded |
|
314 | - new FrmNotification(); |
|
313 | + // make sure hooks are loaded |
|
314 | + new FrmNotification(); |
|
315 | 315 | |
316 | - foreach ( $action_priority as $action_id => $priority ) { |
|
317 | - $action = $stored_actions[ $action_id ]; |
|
316 | + foreach ( $action_priority as $action_id => $priority ) { |
|
317 | + $action = $stored_actions[ $action_id ]; |
|
318 | 318 | do_action( 'frm_trigger_' . $action->post_excerpt . '_action', $action, $entry, $form, $event ); |
319 | 319 | do_action( 'frm_trigger_' . $action->post_excerpt . '_' . $event . '_action', $action, $entry, $form ); |
320 | 320 | |
321 | - // If post is created, get updated $entry object |
|
322 | - if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
323 | - $entry = FrmEntry::getOne($entry->id, true); |
|
324 | - } |
|
325 | - } |
|
326 | - } |
|
327 | - } |
|
321 | + // If post is created, get updated $entry object |
|
322 | + if ( $action->post_excerpt == 'wppost' && $event == 'create' ) { |
|
323 | + $entry = FrmEntry::getOne($entry->id, true); |
|
324 | + } |
|
325 | + } |
|
326 | + } |
|
327 | + } |
|
328 | 328 | |
329 | 329 | public static function duplicate_form_actions( $form_id, $values, $args = array() ) { |
330 | - if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
331 | - // continue if we know which actions to copy |
|
332 | - return; |
|
333 | - } |
|
330 | + if ( ! isset($args['old_id']) || empty($args['old_id']) ) { |
|
331 | + // continue if we know which actions to copy |
|
332 | + return; |
|
333 | + } |
|
334 | 334 | |
335 | - $action_controls = self::get_form_actions( ); |
|
335 | + $action_controls = self::get_form_actions( ); |
|
336 | 336 | |
337 | - foreach ( $action_controls as $action_control ) { |
|
338 | - $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
339 | - unset( $action_control ); |
|
340 | - } |
|
341 | - } |
|
337 | + foreach ( $action_controls as $action_control ) { |
|
338 | + $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
|
339 | + unset( $action_control ); |
|
340 | + } |
|
341 | + } |
|
342 | 342 | |
343 | - public static function limit_by_type( $where ) { |
|
344 | - global $frm_vars, $wpdb; |
|
343 | + public static function limit_by_type( $where ) { |
|
344 | + global $frm_vars, $wpdb; |
|
345 | 345 | |
346 | - if ( ! isset( $frm_vars['action_type'] ) ) { |
|
347 | - return $where; |
|
348 | - } |
|
346 | + if ( ! isset( $frm_vars['action_type'] ) ) { |
|
347 | + return $where; |
|
348 | + } |
|
349 | 349 | |
350 | - $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
351 | - return $where; |
|
352 | - } |
|
350 | + $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
|
351 | + return $where; |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | foreach ( $keys as $key ) { |
377 | 377 | // don't register new action if old action with the same id is already registered |
378 | 378 | if ( ! isset( $this->actions[ $key ] ) ) { |
379 | - $this->actions[ $key ]->_register(); |
|
379 | + $this->actions[ $key ]->_register(); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! is_array($field['options']) ) { |
3 | - return; |
|
3 | + return; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
7 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
8 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
9 | 9 | |
10 | - // Get string for Other text field, if needed |
|
10 | + // Get string for Other text field, if needed |
|
11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
12 | 12 | |
13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
13 | + $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
14 | 14 | |
15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - unset($checked, $other_val); |
|
21 | + unset($checked, $other_val); |
|
22 | 22 | } |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! is_array($field['options']) ) { |
|
2 | +if ( ! is_array( $field['options'] ) ) { |
|
3 | 3 | return; |
4 | 4 | } |
5 | 5 | |
6 | 6 | foreach ( $field['options'] as $opt_key => $opt ) { |
7 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
8 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
7 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
8 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
9 | 9 | |
10 | 10 | // Get string for Other text field, if needed |
11 | 11 | $other_val = FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field' ) ); |
12 | 12 | |
13 | - $checked = ( $other_val || isset($field['value']) && (( ! is_array($field['value']) && $field['value'] == $field_val ) || (is_array($field['value']) && in_array($field_val, $field['value']) ) ) ) ? ' checked="checked"':''; |
|
13 | + $checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : ''; |
|
14 | 14 | |
15 | 15 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
16 | 16 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
@@ -18,5 +18,5 @@ discard block |
||
18 | 18 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
19 | 19 | } |
20 | 20 | |
21 | - unset($checked, $other_val); |
|
21 | + unset( $checked, $other_val ); |
|
22 | 22 | } |