@@ -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' ); |
@@ -41,23 +41,23 @@ 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 | |
52 | 52 | self::load_pro_hooks(); |
53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
53 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
54 | 54 | |
55 | 55 | $version = FrmAppHelper::plugin_version(); |
56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
57 | 57 | |
58 | - wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
|
58 | + wp_enqueue_style( 'frm-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_css' ) ); |
|
59 | 59 | |
60 | - $style = apply_filters('frm_style_head', false); |
|
60 | + $style = apply_filters( 'frm_style_head', false ); |
|
61 | 61 | if ( $style ) { |
62 | 62 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
63 | 63 | } |
@@ -143,17 +143,17 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | public static function new_style( $return = '' ) { |
146 | - self::load_styler('default'); |
|
146 | + self::load_styler( 'default' ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public static function duplicate() { |
150 | - self::load_styler('default'); |
|
150 | + self::load_styler( 'default' ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | public static function edit( $style_id = false, $message = '' ) { |
154 | 154 | if ( ! $style_id ) { |
155 | 155 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
156 | - if ( empty($style_id) ) { |
|
156 | + if ( empty( $style_id ) ) { |
|
157 | 157 | $style_id = 'default'; |
158 | 158 | } |
159 | 159 | } |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | if ( 'default' == $style_id ) { |
162 | 162 | $style = 'default'; |
163 | 163 | } else { |
164 | - $frm_style = new FrmStyle($style_id); |
|
164 | + $frm_style = new FrmStyle( $style_id ); |
|
165 | 165 | $style = $frm_style->get_one(); |
166 | 166 | $style = $style->ID; |
167 | 167 | } |
168 | 168 | |
169 | - self::load_styler($style, $message); |
|
169 | + self::load_styler( $style, $message ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public static function save() { |
@@ -176,17 +176,17 @@ discard block |
||
176 | 176 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
177 | 177 | |
178 | 178 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
179 | - $id = $frm_style->update($post_id); |
|
180 | - if ( empty($post_id) && ! empty($id) ) { |
|
179 | + $id = $frm_style->update( $post_id ); |
|
180 | + if ( empty( $post_id ) && ! empty( $id ) ) { |
|
181 | 181 | // set the post id to the new style so it will be loaded for editing |
182 | - $post_id = reset($id); |
|
182 | + $post_id = reset( $id ); |
|
183 | 183 | } |
184 | 184 | // include the CSS that includes this style |
185 | 185 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
186 | 186 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
187 | 187 | } |
188 | 188 | |
189 | - return self::edit($post_id, $message); |
|
189 | + return self::edit( $post_id, $message ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function load_styler( $style, $message = '' ) { |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | $frm_style = new FrmStyle(); |
196 | 196 | $styles = $frm_style->get_all(); |
197 | 197 | |
198 | - if ( is_numeric($style) ) { |
|
199 | - $style = $styles[ $style ]; |
|
198 | + if ( is_numeric( $style ) ) { |
|
199 | + $style = $styles[$style]; |
|
200 | 200 | } else if ( 'default' == $style ) { |
201 | - $style = $frm_style->get_default_style($styles); |
|
201 | + $style = $frm_style->get_default_style( $styles ); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | self::add_meta_boxes(); |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | private static function manage( $message = '', $forms = array() ) { |
214 | 214 | $frm_style = new FrmStyle(); |
215 | 215 | $styles = $frm_style->get_all(); |
216 | - $default_style = $frm_style->get_default_style($styles); |
|
216 | + $default_style = $frm_style->get_default_style( $styles ); |
|
217 | 217 | |
218 | - if ( empty($forms) ) { |
|
218 | + if ( empty( $forms ) ) { |
|
219 | 219 | $forms = FrmForm::get_published_forms(); |
220 | 220 | } |
221 | 221 | |
@@ -232,26 +232,26 @@ discard block |
||
232 | 232 | |
233 | 233 | $forms = FrmForm::get_published_forms(); |
234 | 234 | foreach ( $forms as $form ) { |
235 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
235 | + if ( $_POST['style'][$form->id] == $_POST['prev_style'][$form->id] ) { |
|
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | |
239 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
239 | + $form->options['custom_style'] = $_POST['style'][$form->id]; |
|
240 | 240 | |
241 | 241 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
242 | - unset($form); |
|
242 | + unset( $form ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $message = __( 'Your form styles have been saved.', 'formidable' ); |
246 | - return self::manage($message, $forms); |
|
246 | + return self::manage( $message, $forms ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | public static function custom_css( $message = '', $style = null ) { |
250 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
251 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
250 | + wp_enqueue_style( 'codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css' ); |
|
251 | + wp_enqueue_script( 'codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7' ); |
|
252 | 252 | wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
253 | 253 | |
254 | - if ( ! isset($style) ) { |
|
254 | + if ( ! isset( $style ) ) { |
|
255 | 255 | $frm_style = new FrmStyle(); |
256 | 256 | $style = $frm_style->get_default_style(); |
257 | 257 | } |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
267 | 267 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
268 | 268 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
269 | - $frm_style->update($post_id); |
|
269 | + $frm_style->update( $post_id ); |
|
270 | 270 | $message = __( 'Your styling settings have been saved.', 'formidable' ); |
271 | 271 | } |
272 | 272 | |
273 | - return self::custom_css($message); |
|
273 | + return self::custom_css( $message ); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | public static function route() { |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | public static function reset_styling() { |
302 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
302 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
303 | 303 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
304 | 304 | |
305 | 305 | $frm_style = new FrmStyle(); |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | |
318 | 318 | // remove the # from the colors |
319 | 319 | foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
320 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
321 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
320 | + if ( ! is_array( $v ) && strpos( $v, '#' ) === 0 ) { |
|
321 | + $_GET['frm_style_setting']['post_content'][$k] = str_replace( '#', '', $v ); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
@@ -348,18 +348,18 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $meta_boxes as $nicename => $name ) { |
350 | 350 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
351 | - unset($nicename, $name); |
|
351 | + unset( $nicename, $name ); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | public static function include_style_section( $atts, $sec ) { |
356 | - extract($atts); |
|
356 | + extract( $atts ); |
|
357 | 357 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
358 | 358 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
359 | 359 | } |
360 | 360 | |
361 | 361 | public static function load_css() { |
362 | - header('Content-type: text/css'); |
|
362 | + header( 'Content-type: text/css' ); |
|
363 | 363 | |
364 | 364 | $frm_style = new FrmStyle(); |
365 | 365 | $defaults = $frm_style->get_defaults(); |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $style = 'default'; |
424 | 424 | } |
425 | 425 | |
426 | - $frm_style = new FrmStyle($style); |
|
426 | + $frm_style = new FrmStyle( $style ); |
|
427 | 427 | $style = $frm_style->get_one(); |
428 | 428 | |
429 | 429 | if ( $style ) { |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | * @param string $val |
438 | 438 | */ |
439 | 439 | public static function get_style_val( $val, $form = 'default' ) { |
440 | - $style = self::get_form_style($form); |
|
441 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
442 | - return $style->post_content[ $val ]; |
|
440 | + $style = self::get_form_style( $form ); |
|
441 | + if ( $style && isset( $style->post_content[$val] ) ) { |
|
442 | + return $style->post_content[$val]; |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | 446 | public static function show_entry_styles( $default_styles ) { |
447 | - $frm_style = new FrmStyle('default'); |
|
447 | + $frm_style = new FrmStyle( 'default' ); |
|
448 | 448 | $style = $frm_style->get_one(); |
449 | 449 | |
450 | 450 | if ( ! $style ) { |
@@ -458,15 +458,15 @@ discard block |
||
458 | 458 | } else if ( 'alt_bg_color' == $name ) { |
459 | 459 | $setting = 'bg_color_active'; |
460 | 460 | } |
461 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
462 | - unset($name, $val); |
|
461 | + $default_styles[$name] = $style->post_content[$setting]; |
|
462 | + unset( $name, $val ); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | return $default_styles; |
466 | 466 | } |
467 | 467 | |
468 | 468 | public static function &important_style( $important, $field ) { |
469 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
469 | + $important = self::get_style_val( 'important_style', $field['form_id'] ); |
|
470 | 470 | return $important; |
471 | 471 | } |
472 | 472 | |
@@ -492,18 +492,18 @@ discard block |
||
492 | 492 | $i = 0; |
493 | 493 | $first_open = false; |
494 | 494 | do { |
495 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
|
495 | + if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) { |
|
496 | 496 | break; |
497 | 497 | } |
498 | 498 | |
499 | 499 | foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
500 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
501 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
500 | + if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
501 | + foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
502 | 502 | if ( false == $box || ! $box['title'] ) { |
503 | 503 | continue; |
504 | 504 | } |
505 | 505 | |
506 | - $i++; |
|
506 | + $i ++; |
|
507 | 507 | $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
508 | 508 | |
509 | 509 | if ( ! $first_open && empty( $hidden_class ) ) { |
@@ -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,18 +57,18 @@ 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 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
64 | 64 | |
65 | 65 | wp_enqueue_style( 'frm-custom-theme', admin_url('admin-ajax.php?action=frmpro_css' ) ); |
66 | 66 | |
67 | - $style = apply_filters('frm_style_head', false); |
|
68 | - if ( $style ) { |
|
67 | + $style = apply_filters('frm_style_head', false); |
|
68 | + if ( $style ) { |
|
69 | 69 | wp_enqueue_style( 'frm-single-custom-theme', admin_url( 'admin-ajax.php?action=frmpro_load_css&flat=1' ) . '&' . http_build_query( $style->post_content ) ); |
70 | - } |
|
71 | - } |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | public static function enqueue_css( $register = 'enqueue' ) { |
74 | 74 | global $frm_vars; |
@@ -162,230 +162,230 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | public static function new_style( $return = '' ) { |
165 | - self::load_styler('default'); |
|
166 | - } |
|
165 | + self::load_styler('default'); |
|
166 | + } |
|
167 | 167 | |
168 | 168 | public static function duplicate() { |
169 | 169 | self::load_styler('default'); |
170 | 170 | } |
171 | 171 | |
172 | 172 | public static function edit( $style_id = false, $message = '' ) { |
173 | - if ( ! $style_id ) { |
|
173 | + if ( ! $style_id ) { |
|
174 | 174 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
175 | - if ( empty($style_id) ) { |
|
176 | - $style_id = 'default'; |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - if ( 'default' == $style_id ) { |
|
181 | - $style = 'default'; |
|
182 | - } else { |
|
183 | - $frm_style = new FrmStyle($style_id); |
|
184 | - $style = $frm_style->get_one(); |
|
185 | - $style = $style->ID; |
|
186 | - } |
|
187 | - |
|
188 | - self::load_styler($style, $message); |
|
189 | - } |
|
190 | - |
|
191 | - public static function save() { |
|
192 | - $frm_style = new FrmStyle(); |
|
193 | - $message = ''; |
|
175 | + if ( empty($style_id) ) { |
|
176 | + $style_id = 'default'; |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + if ( 'default' == $style_id ) { |
|
181 | + $style = 'default'; |
|
182 | + } else { |
|
183 | + $frm_style = new FrmStyle($style_id); |
|
184 | + $style = $frm_style->get_one(); |
|
185 | + $style = $style->ID; |
|
186 | + } |
|
187 | + |
|
188 | + self::load_styler($style, $message); |
|
189 | + } |
|
190 | + |
|
191 | + public static function save() { |
|
192 | + $frm_style = new FrmStyle(); |
|
193 | + $message = ''; |
|
194 | 194 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
195 | 195 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
196 | 196 | |
197 | 197 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
198 | - $id = $frm_style->update($post_id); |
|
199 | - if ( empty($post_id) && ! empty($id) ) { |
|
200 | - // set the post id to the new style so it will be loaded for editing |
|
201 | - $post_id = reset($id); |
|
202 | - } |
|
203 | - // include the CSS that includes this style |
|
198 | + $id = $frm_style->update($post_id); |
|
199 | + if ( empty($post_id) && ! empty($id) ) { |
|
200 | + // set the post id to the new style so it will be loaded for editing |
|
201 | + $post_id = reset($id); |
|
202 | + } |
|
203 | + // include the CSS that includes this style |
|
204 | 204 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php?action=frmpro_css' ) ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
205 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
206 | - } |
|
205 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
206 | + } |
|
207 | 207 | |
208 | - return self::edit($post_id, $message); |
|
209 | - } |
|
208 | + return self::edit($post_id, $message); |
|
209 | + } |
|
210 | 210 | |
211 | 211 | public static function load_styler( $style, $message = '' ) { |
212 | - global $frm_settings; |
|
212 | + global $frm_settings; |
|
213 | 213 | |
214 | - $frm_style = new FrmStyle(); |
|
215 | - $styles = $frm_style->get_all(); |
|
214 | + $frm_style = new FrmStyle(); |
|
215 | + $styles = $frm_style->get_all(); |
|
216 | 216 | |
217 | - if ( is_numeric($style) ) { |
|
218 | - $style = $styles[ $style ]; |
|
219 | - } else if ( 'default' == $style ) { |
|
220 | - $style = $frm_style->get_default_style($styles); |
|
221 | - } |
|
217 | + if ( is_numeric($style) ) { |
|
218 | + $style = $styles[ $style ]; |
|
219 | + } else if ( 'default' == $style ) { |
|
220 | + $style = $frm_style->get_default_style($styles); |
|
221 | + } |
|
222 | 222 | |
223 | - self::add_meta_boxes(); |
|
223 | + self::add_meta_boxes(); |
|
224 | 224 | |
225 | 225 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/show.php' ); |
226 | - } |
|
226 | + } |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @param string $message |
230 | 230 | * @param array|object $forms |
231 | 231 | */ |
232 | 232 | private static function manage( $message = '', $forms = array() ) { |
233 | - $frm_style = new FrmStyle(); |
|
234 | - $styles = $frm_style->get_all(); |
|
235 | - $default_style = $frm_style->get_default_style($styles); |
|
233 | + $frm_style = new FrmStyle(); |
|
234 | + $styles = $frm_style->get_all(); |
|
235 | + $default_style = $frm_style->get_default_style($styles); |
|
236 | 236 | |
237 | - if ( empty($forms) ) { |
|
238 | - $forms = FrmForm::get_published_forms(); |
|
239 | - } |
|
237 | + if ( empty($forms) ) { |
|
238 | + $forms = FrmForm::get_published_forms(); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/manage.php' ); |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - private static function manage_styles() { |
|
244 | + private static function manage_styles() { |
|
245 | 245 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
246 | 246 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
247 | - return self::manage(); |
|
248 | - } |
|
247 | + return self::manage(); |
|
248 | + } |
|
249 | 249 | |
250 | - global $wpdb; |
|
250 | + global $wpdb; |
|
251 | 251 | |
252 | 252 | $forms = FrmForm::get_published_forms(); |
253 | - foreach ( $forms as $form ) { |
|
254 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
255 | - continue; |
|
256 | - } |
|
253 | + foreach ( $forms as $form ) { |
|
254 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
255 | + continue; |
|
256 | + } |
|
257 | 257 | |
258 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
258 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
259 | 259 | |
260 | 260 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
261 | - unset($form); |
|
262 | - } |
|
261 | + unset($form); |
|
262 | + } |
|
263 | 263 | |
264 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
265 | - return self::manage($message, $forms); |
|
266 | - } |
|
264 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
265 | + return self::manage($message, $forms); |
|
266 | + } |
|
267 | 267 | |
268 | - public static function custom_css( $message = '', $style = null ) { |
|
269 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
270 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
271 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
268 | + public static function custom_css( $message = '', $style = null ) { |
|
269 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
270 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
271 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
272 | 272 | |
273 | - if ( ! isset($style) ) { |
|
274 | - $frm_style = new FrmStyle(); |
|
275 | - $style = $frm_style->get_default_style(); |
|
276 | - } |
|
273 | + if ( ! isset($style) ) { |
|
274 | + $frm_style = new FrmStyle(); |
|
275 | + $style = $frm_style->get_default_style(); |
|
276 | + } |
|
277 | 277 | |
278 | 278 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/custom_css.php' ); |
279 | - } |
|
279 | + } |
|
280 | 280 | |
281 | - public static function save_css() { |
|
282 | - $frm_style = new FrmStyle(); |
|
281 | + public static function save_css() { |
|
282 | + $frm_style = new FrmStyle(); |
|
283 | 283 | |
284 | - $message = ''; |
|
284 | + $message = ''; |
|
285 | 285 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
286 | 286 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
287 | 287 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
288 | - $frm_style->update($post_id); |
|
289 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
290 | - } |
|
288 | + $frm_style->update($post_id); |
|
289 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
290 | + } |
|
291 | 291 | |
292 | - return self::custom_css($message); |
|
293 | - } |
|
292 | + return self::custom_css($message); |
|
293 | + } |
|
294 | 294 | |
295 | - public static function route() { |
|
295 | + public static function route() { |
|
296 | 296 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
297 | 297 | |
298 | - switch ( $action ) { |
|
299 | - case 'edit': |
|
300 | - case 'save': |
|
301 | - case 'manage': |
|
302 | - case 'manage_styles': |
|
303 | - case 'custom_css': |
|
304 | - case 'save_css': |
|
298 | + switch ( $action ) { |
|
299 | + case 'edit': |
|
300 | + case 'save': |
|
301 | + case 'manage': |
|
302 | + case 'manage_styles': |
|
303 | + case 'custom_css': |
|
304 | + case 'save_css': |
|
305 | 305 | return self::$action(); |
306 | - default: |
|
307 | - do_action( 'frm_style_action_route', $action ); |
|
308 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
309 | - return; |
|
310 | - } |
|
306 | + default: |
|
307 | + do_action( 'frm_style_action_route', $action ); |
|
308 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
309 | + return; |
|
310 | + } |
|
311 | 311 | |
312 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
313 | - return self::$action(); |
|
314 | - } |
|
312 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
313 | + return self::$action(); |
|
314 | + } |
|
315 | 315 | |
316 | - return self::edit(); |
|
317 | - } |
|
318 | - } |
|
316 | + return self::edit(); |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | - public static function reset_styling() { |
|
320 | + public static function reset_styling() { |
|
321 | 321 | FrmAppHelper::permission_check('frm_change_settings'); |
322 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
322 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
323 | 323 | |
324 | - $frm_style = new FrmStyle(); |
|
325 | - $defaults = $frm_style->get_defaults(); |
|
324 | + $frm_style = new FrmStyle(); |
|
325 | + $defaults = $frm_style->get_defaults(); |
|
326 | 326 | |
327 | - echo json_encode( $defaults ); |
|
328 | - wp_die(); |
|
329 | - } |
|
327 | + echo json_encode( $defaults ); |
|
328 | + wp_die(); |
|
329 | + } |
|
330 | 330 | |
331 | - public static function change_styling() { |
|
332 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
331 | + public static function change_styling() { |
|
332 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
333 | 333 | |
334 | - $frm_style = new FrmStyle(); |
|
335 | - $defaults = $frm_style->get_defaults(); |
|
334 | + $frm_style = new FrmStyle(); |
|
335 | + $defaults = $frm_style->get_defaults(); |
|
336 | 336 | |
337 | - // remove the # from the colors |
|
338 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
339 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
340 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
341 | - } |
|
342 | - } |
|
337 | + // remove the # from the colors |
|
338 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
339 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
340 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
341 | + } |
|
342 | + } |
|
343 | 343 | |
344 | - echo '<style type="text/css">'; |
|
344 | + echo '<style type="text/css">'; |
|
345 | 345 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
346 | - echo '</style>'; |
|
347 | - wp_die(); |
|
348 | - } |
|
349 | - |
|
350 | - private static function add_meta_boxes() { |
|
351 | - |
|
352 | - // setup meta boxes |
|
353 | - $meta_boxes = array( |
|
354 | - 'general' => __( 'General', 'formidable' ), |
|
355 | - 'form-title' => __( 'Form Title', 'formidable' ), |
|
356 | - 'form-description' => __( 'Form Description', 'formidable' ), |
|
357 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
358 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
359 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
360 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
361 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
362 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
363 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
364 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
365 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
366 | - ); |
|
367 | - |
|
368 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
346 | + echo '</style>'; |
|
347 | + wp_die(); |
|
348 | + } |
|
349 | + |
|
350 | + private static function add_meta_boxes() { |
|
351 | + |
|
352 | + // setup meta boxes |
|
353 | + $meta_boxes = array( |
|
354 | + 'general' => __( 'General', 'formidable' ), |
|
355 | + 'form-title' => __( 'Form Title', 'formidable' ), |
|
356 | + 'form-description' => __( 'Form Description', 'formidable' ), |
|
357 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
358 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
359 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
360 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
361 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
362 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
363 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
364 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
365 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
366 | + ); |
|
367 | + |
|
368 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
369 | 369 | add_meta_box( $nicename . '-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
370 | - unset($nicename, $name); |
|
371 | - } |
|
372 | - } |
|
370 | + unset($nicename, $name); |
|
371 | + } |
|
372 | + } |
|
373 | 373 | |
374 | 374 | public static function include_style_section( $atts, $sec ) { |
375 | - extract($atts); |
|
375 | + extract($atts); |
|
376 | 376 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
377 | 377 | include( FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php' ); |
378 | - } |
|
378 | + } |
|
379 | 379 | |
380 | - public static function load_css() { |
|
381 | - header('Content-type: text/css'); |
|
380 | + public static function load_css() { |
|
381 | + header('Content-type: text/css'); |
|
382 | 382 | |
383 | - $frm_style = new FrmStyle(); |
|
384 | - $defaults = $frm_style->get_defaults(); |
|
383 | + $frm_style = new FrmStyle(); |
|
384 | + $defaults = $frm_style->get_defaults(); |
|
385 | 385 | |
386 | 386 | include( FrmAppHelper::plugin_path() . '/css/_single_theme.css.php' ); |
387 | - wp_die(); |
|
388 | - } |
|
387 | + wp_die(); |
|
388 | + } |
|
389 | 389 | |
390 | 390 | public static function load_saved_css() { |
391 | 391 | $css = get_transient( 'frmpro_css' ); |
@@ -394,142 +394,142 @@ discard block |
||
394 | 394 | wp_die(); |
395 | 395 | } |
396 | 396 | |
397 | - /** |
|
398 | - * Check if the Formidable styling should be loaded, |
|
399 | - * then enqueue it for the footer |
|
400 | - * @since 2.0 |
|
401 | - */ |
|
402 | - public static function enqueue_style() { |
|
403 | - global $frm_vars; |
|
404 | - |
|
405 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
406 | - // the CSS has already been loaded |
|
407 | - return; |
|
408 | - } |
|
409 | - |
|
410 | - $frm_settings = FrmAppHelper::get_settings(); |
|
411 | - if ( $frm_settings->load_style != 'none' ) { |
|
412 | - wp_enqueue_style( 'formidable' ); |
|
413 | - $frm_vars['css_loaded'] = true; |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - // Get the stylesheets for the form settings page |
|
418 | - public static function get_style_opts() { |
|
419 | - $frm_style = new FrmStyle(); |
|
420 | - $styles = $frm_style->get_all(); |
|
421 | - |
|
422 | - return $styles; |
|
423 | - } |
|
424 | - |
|
425 | - public static function get_form_style( $form = 'default' ) { |
|
426 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
427 | - |
|
428 | - if ( empty( $style ) || 1 == $style ) { |
|
429 | - $style = 'default'; |
|
430 | - } |
|
431 | - |
|
432 | - $frm_style = new FrmStyle( $style ); |
|
433 | - return $frm_style->get_one(); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * @param string $class |
|
438 | - * @param string $style |
|
439 | - */ |
|
397 | + /** |
|
398 | + * Check if the Formidable styling should be loaded, |
|
399 | + * then enqueue it for the footer |
|
400 | + * @since 2.0 |
|
401 | + */ |
|
402 | + public static function enqueue_style() { |
|
403 | + global $frm_vars; |
|
404 | + |
|
405 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
406 | + // the CSS has already been loaded |
|
407 | + return; |
|
408 | + } |
|
409 | + |
|
410 | + $frm_settings = FrmAppHelper::get_settings(); |
|
411 | + if ( $frm_settings->load_style != 'none' ) { |
|
412 | + wp_enqueue_style( 'formidable' ); |
|
413 | + $frm_vars['css_loaded'] = true; |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + // Get the stylesheets for the form settings page |
|
418 | + public static function get_style_opts() { |
|
419 | + $frm_style = new FrmStyle(); |
|
420 | + $styles = $frm_style->get_all(); |
|
421 | + |
|
422 | + return $styles; |
|
423 | + } |
|
424 | + |
|
425 | + public static function get_form_style( $form = 'default' ) { |
|
426 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
427 | + |
|
428 | + if ( empty( $style ) || 1 == $style ) { |
|
429 | + $style = 'default'; |
|
430 | + } |
|
431 | + |
|
432 | + $frm_style = new FrmStyle( $style ); |
|
433 | + return $frm_style->get_one(); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * @param string $class |
|
438 | + * @param string $style |
|
439 | + */ |
|
440 | 440 | public static function get_form_style_class( $class, $style ) { |
441 | - if ( 1 == $style ) { |
|
442 | - $style = 'default'; |
|
443 | - } |
|
441 | + if ( 1 == $style ) { |
|
442 | + $style = 'default'; |
|
443 | + } |
|
444 | 444 | |
445 | - $frm_style = new FrmStyle($style); |
|
446 | - $style = $frm_style->get_one(); |
|
445 | + $frm_style = new FrmStyle($style); |
|
446 | + $style = $frm_style->get_one(); |
|
447 | 447 | |
448 | - if ( $style ) { |
|
448 | + if ( $style ) { |
|
449 | 449 | $class .= ' frm_style_' . $style->post_name; |
450 | - } |
|
450 | + } |
|
451 | 451 | |
452 | - return $class; |
|
453 | - } |
|
452 | + return $class; |
|
453 | + } |
|
454 | 454 | |
455 | - /** |
|
456 | - * @param string $val |
|
457 | - */ |
|
455 | + /** |
|
456 | + * @param string $val |
|
457 | + */ |
|
458 | 458 | public static function get_style_val( $val, $form = 'default' ) { |
459 | - $style = self::get_form_style($form); |
|
460 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
461 | - return $style->post_content[ $val ]; |
|
462 | - } |
|
463 | - } |
|
459 | + $style = self::get_form_style($form); |
|
460 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
461 | + return $style->post_content[ $val ]; |
|
462 | + } |
|
463 | + } |
|
464 | 464 | |
465 | 465 | public static function show_entry_styles( $default_styles ) { |
466 | - $frm_style = new FrmStyle('default'); |
|
467 | - $style = $frm_style->get_one(); |
|
468 | - |
|
469 | - if ( ! $style ) { |
|
470 | - return $default_styles; |
|
471 | - } |
|
472 | - |
|
473 | - foreach ( $default_styles as $name => $val ) { |
|
474 | - $setting = $name; |
|
475 | - if ( 'border_width' == $name ) { |
|
476 | - $setting = 'field_border_width'; |
|
477 | - } else if ( 'alt_bg_color' == $name ) { |
|
478 | - $setting = 'bg_color_active'; |
|
479 | - } |
|
480 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
481 | - unset($name, $val); |
|
482 | - } |
|
483 | - |
|
484 | - return $default_styles; |
|
485 | - } |
|
466 | + $frm_style = new FrmStyle('default'); |
|
467 | + $style = $frm_style->get_one(); |
|
468 | + |
|
469 | + if ( ! $style ) { |
|
470 | + return $default_styles; |
|
471 | + } |
|
472 | + |
|
473 | + foreach ( $default_styles as $name => $val ) { |
|
474 | + $setting = $name; |
|
475 | + if ( 'border_width' == $name ) { |
|
476 | + $setting = 'field_border_width'; |
|
477 | + } else if ( 'alt_bg_color' == $name ) { |
|
478 | + $setting = 'bg_color_active'; |
|
479 | + } |
|
480 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
481 | + unset($name, $val); |
|
482 | + } |
|
483 | + |
|
484 | + return $default_styles; |
|
485 | + } |
|
486 | 486 | |
487 | 487 | public static function &important_style( $important, $field ) { |
488 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
489 | - return $important; |
|
490 | - } |
|
488 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
489 | + return $important; |
|
490 | + } |
|
491 | 491 | |
492 | - /** |
|
493 | - * Fallback for WP < 3.6 |
|
494 | - */ |
|
495 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
496 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
497 | - return do_accordion_sections( $screen, $context, $object ); |
|
498 | - } |
|
492 | + /** |
|
493 | + * Fallback for WP < 3.6 |
|
494 | + */ |
|
495 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
496 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
497 | + return do_accordion_sections( $screen, $context, $object ); |
|
498 | + } |
|
499 | 499 | |
500 | - global $wp_meta_boxes; |
|
500 | + global $wp_meta_boxes; |
|
501 | 501 | |
502 | - $screen = 'formidable_page_formidable-styles'; |
|
503 | - $screen = convert_to_screen( $screen ); |
|
502 | + $screen = 'formidable_page_formidable-styles'; |
|
503 | + $screen = convert_to_screen( $screen ); |
|
504 | 504 | |
505 | - $page = $screen->id; |
|
505 | + $page = $screen->id; |
|
506 | 506 | |
507 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
508 | - ?> |
|
507 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
508 | + ?> |
|
509 | 509 | <div id="side-sortables" class="accordion-container"> |
510 | 510 | <?php |
511 | - $i = 0; |
|
512 | - $first_open = false; |
|
513 | - do { |
|
511 | + $i = 0; |
|
512 | + $first_open = false; |
|
513 | + do { |
|
514 | 514 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
515 | 515 | break; |
516 | 516 | } |
517 | 517 | |
518 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
519 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
520 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
521 | - if ( false == $box || ! $box['title'] ) { |
|
522 | - continue; |
|
518 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
519 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
520 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
521 | + if ( false == $box || ! $box['title'] ) { |
|
522 | + continue; |
|
523 | 523 | } |
524 | 524 | |
525 | - $i++; |
|
526 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
525 | + $i++; |
|
526 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
527 | 527 | |
528 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
529 | - $first_open = true; |
|
530 | - } |
|
528 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
529 | + $first_open = true; |
|
530 | + } |
|
531 | 531 | |
532 | - ?> |
|
532 | + ?> |
|
533 | 533 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
534 | 534 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
535 | 535 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -540,13 +540,13 @@ discard block |
||
540 | 540 | </div><!-- .accordion-section-content --> |
541 | 541 | </div><!-- .postbox --> |
542 | 542 | <?php |
543 | - } |
|
544 | - } |
|
545 | - } |
|
546 | - } while ( 0 ); |
|
547 | - ?> |
|
543 | + } |
|
544 | + } |
|
545 | + } |
|
546 | + } while ( 0 ); |
|
547 | + ?> |
|
548 | 548 | </div><!-- .accordion-container --> |
549 | 549 | <?php |
550 | - return $i; |
|
551 | - } |
|
550 | + return $i; |
|
551 | + } |
|
552 | 552 | } |
@@ -7,10 +7,10 @@ |
||
7 | 7 | continue; |
8 | 8 | } |
9 | 9 | |
10 | - if ( isset( $plugin_names[ $addon['info']['slug'] ] ) ) { |
|
11 | - $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[ $addon['info']['slug'] ] ); |
|
10 | + if ( isset( $plugin_names[$addon['info']['slug']] ) ) { |
|
11 | + $installed = is_dir( WP_PLUGIN_DIR . '/' . $plugin_names[$addon['info']['slug']] ); |
|
12 | 12 | } else { |
13 | - $installed = isset( $installed_addons[ $addon['info']['slug'] ] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
13 | + $installed = isset( $installed_addons[$addon['info']['slug']] ) || is_dir( WP_PLUGIN_DIR . '/formidable-' . $addon['info']['slug'] ); |
|
14 | 14 | } |
15 | 15 | $has_thumbnail = ! empty( $addon['info']['thumbnail'] ); |
16 | 16 | if ( $addon['info']['slug'] == 'formidable-pro' ) { |
@@ -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() { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | public static function activate() { |
189 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
189 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
190 | 190 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
191 | 191 | |
192 | 192 | if ( ! isset( $_POST['license'] ) || empty( $_POST['license'] ) ) { |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | $response['message'] = $response['status']; |
208 | 208 | } else { |
209 | 209 | $messages = $this_plugin->get_messages(); |
210 | - if ( is_string( $response['status'] ) && isset( $messages[ $response['status'] ] ) ) { |
|
211 | - $response['message'] = $messages[ $response['status'] ]; |
|
210 | + if ( is_string( $response['status'] ) && isset( $messages[$response['status']] ) ) { |
|
211 | + $response['message'] = $messages[$response['status']]; |
|
212 | 212 | } else { |
213 | 213 | $response['message'] = FrmAppHelper::kses( $response['status'], array( 'a' ) ); |
214 | 214 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | public static function deactivate() { |
267 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
267 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
268 | 268 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
269 | 269 | |
270 | 270 | $plugin_slug = sanitize_text_field( $_POST['plugin'] ); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | $message = __( 'Your License Key was invalid', 'formidable' ); |
317 | 317 | if ( is_wp_error( $resp ) ) { |
318 | - $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>'); |
|
318 | + $message = sprintf( __( 'You had an error communicating with Formidable Pro\'s API. %1$sClick here%2$s for more information.', 'formidable' ), '<a href="http://formidablepro.com/knowledgebase/why-cant-i-activate-formidable-pro/" target="_blank">', '</a>' ); |
|
319 | 319 | $message .= ' ' . $resp->get_error_message(); |
320 | 320 | } else if ( $body == 'error' || is_wp_error( $body ) ) { |
321 | 321 | $message = __( 'You had an HTTP error connecting to Formidable Pro\'s 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,46 +125,46 @@ 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; |
|
137 | - $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
|
138 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
139 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
135 | + $new_values['name'] = $values->name; |
|
136 | + $new_values['is_draft'] = $values->is_draft; |
|
137 | + $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
|
138 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
139 | + $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
140 | 140 | |
141 | 141 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
142 | - if ( ! $query_results ) { |
|
143 | - return false; |
|
144 | - } |
|
142 | + if ( ! $query_results ) { |
|
143 | + return false; |
|
144 | + } |
|
145 | 145 | |
146 | - $entry_id = $wpdb->insert_id; |
|
146 | + $entry_id = $wpdb->insert_id; |
|
147 | 147 | |
148 | - global $frm_vars; |
|
149 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
150 | - $frm_vars['saved_entries'] = array(); |
|
151 | - } |
|
152 | - $frm_vars['saved_entries'][] = (int) $entry_id; |
|
148 | + global $frm_vars; |
|
149 | + if ( ! isset($frm_vars['saved_entries']) ) { |
|
150 | + $frm_vars['saved_entries'] = array(); |
|
151 | + } |
|
152 | + $frm_vars['saved_entries'][] = (int) $entry_id; |
|
153 | 153 | |
154 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
154 | + FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
155 | 155 | self::clear_cache(); |
156 | 156 | |
157 | 157 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
158 | - return $entry_id; |
|
159 | - } |
|
158 | + return $entry_id; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | /** |
162 | - * Update an entry (not via XML) |
|
163 | - * |
|
164 | - * @param int $id |
|
165 | - * @param array $values |
|
166 | - * @return boolean|int $update_results |
|
167 | - */ |
|
162 | + * Update an entry (not via XML) |
|
163 | + * |
|
164 | + * @param int $id |
|
165 | + * @param array $values |
|
166 | + * @return boolean|int $update_results |
|
167 | + */ |
|
168 | 168 | public static function update( $id, $values ) { |
169 | 169 | $update_results = self::update_entry( $id, $values, 'standard' ); |
170 | 170 | |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
175 | - * Update an entry with some differences depending on the update type |
|
176 | - * |
|
177 | - * @since 2.0.16 |
|
178 | - * |
|
179 | - * @param int $id |
|
180 | - * @param array $values |
|
181 | - * @return boolean|int $query_results |
|
182 | - */ |
|
175 | + * Update an entry with some differences depending on the update type |
|
176 | + * |
|
177 | + * @since 2.0.16 |
|
178 | + * |
|
179 | + * @param int $id |
|
180 | + * @param array $values |
|
181 | + * @return boolean|int $query_results |
|
182 | + */ |
|
183 | 183 | private static function update_entry( $id, $values, $update_type ) { |
184 | 184 | global $wpdb; |
185 | 185 | |
@@ -198,34 +198,34 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | public static function &destroy( $id ) { |
201 | - global $wpdb; |
|
202 | - $id = (int) $id; |
|
201 | + global $wpdb; |
|
202 | + $id = (int) $id; |
|
203 | 203 | |
204 | 204 | $entry = self::getOne( $id ); |
205 | - if ( ! $entry ) { |
|
206 | - $result = false; |
|
207 | - return $result; |
|
208 | - } |
|
205 | + if ( ! $entry ) { |
|
206 | + $result = false; |
|
207 | + return $result; |
|
208 | + } |
|
209 | 209 | |
210 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
210 | + do_action('frm_before_destroy_entry', $id, $entry); |
|
211 | 211 | |
212 | 212 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
213 | 213 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
214 | 214 | |
215 | 215 | self::clear_cache(); |
216 | 216 | |
217 | - return $result; |
|
218 | - } |
|
217 | + return $result; |
|
218 | + } |
|
219 | 219 | |
220 | 220 | public static function &update_form( $id, $value, $form_id ) { |
221 | - global $wpdb; |
|
222 | - $form_id = isset($value) ? $form_id : null; |
|
221 | + global $wpdb; |
|
222 | + $form_id = isset($value) ? $form_id : null; |
|
223 | 223 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
224 | 224 | if ( $result ) { |
225 | 225 | self::clear_cache(); |
226 | 226 | } |
227 | - return $result; |
|
228 | - } |
|
227 | + return $result; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Clear entry caching |
@@ -261,159 +261,159 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function getOne( $id, $meta = false ) { |
264 | - global $wpdb; |
|
264 | + global $wpdb; |
|
265 | 265 | |
266 | - $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
266 | + $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
267 | 267 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
268 | 268 | |
269 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
270 | - $query_args = array( $id ); |
|
271 | - $query = $wpdb->prepare( $query, $query_args ); |
|
269 | + $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
270 | + $query_args = array( $id ); |
|
271 | + $query = $wpdb->prepare( $query, $query_args ); |
|
272 | 272 | |
273 | - if ( ! $meta ) { |
|
273 | + if ( ! $meta ) { |
|
274 | 274 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
275 | - return stripslashes_deep($entry); |
|
276 | - } |
|
275 | + return stripslashes_deep($entry); |
|
276 | + } |
|
277 | 277 | |
278 | - $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
279 | - if ( $entry !== false ) { |
|
280 | - return stripslashes_deep($entry); |
|
281 | - } |
|
278 | + $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
|
279 | + if ( $entry !== false ) { |
|
280 | + return stripslashes_deep($entry); |
|
281 | + } |
|
282 | 282 | |
283 | - $entry = $wpdb->get_row( $query ); |
|
284 | - $entry = self::get_meta($entry); |
|
283 | + $entry = $wpdb->get_row( $query ); |
|
284 | + $entry = self::get_meta($entry); |
|
285 | 285 | |
286 | - return stripslashes_deep($entry); |
|
287 | - } |
|
286 | + return stripslashes_deep($entry); |
|
287 | + } |
|
288 | 288 | |
289 | 289 | public static function get_meta( $entry ) { |
290 | - if ( ! $entry ) { |
|
291 | - return $entry; |
|
292 | - } |
|
290 | + if ( ! $entry ) { |
|
291 | + return $entry; |
|
292 | + } |
|
293 | 293 | |
294 | - global $wpdb; |
|
294 | + global $wpdb; |
|
295 | 295 | $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' ); |
296 | 296 | |
297 | - $entry->metas = array(); |
|
297 | + $entry->metas = array(); |
|
298 | 298 | |
299 | 299 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
300 | - foreach ( $metas as $meta_val ) { |
|
301 | - if ( $meta_val->item_id == $entry->id ) { |
|
300 | + foreach ( $metas as $meta_val ) { |
|
301 | + if ( $meta_val->item_id == $entry->id ) { |
|
302 | 302 | $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
303 | 303 | if ( $include_key ) { |
304 | 304 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
305 | 305 | } |
306 | - continue; |
|
307 | - } |
|
306 | + continue; |
|
307 | + } |
|
308 | 308 | |
309 | - // include sub entries in an array |
|
309 | + // include sub entries in an array |
|
310 | 310 | if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
311 | 311 | $entry->metas[ $meta_val->field_id ] = array(); |
312 | - } |
|
312 | + } |
|
313 | 313 | |
314 | 314 | $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
315 | 315 | |
316 | - unset($meta_val); |
|
317 | - } |
|
318 | - unset($metas); |
|
316 | + unset($meta_val); |
|
317 | + } |
|
318 | + unset($metas); |
|
319 | 319 | |
320 | 320 | FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' ); |
321 | 321 | |
322 | - return $entry; |
|
323 | - } |
|
322 | + return $entry; |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * @param string $id |
|
327 | - */ |
|
325 | + /** |
|
326 | + * @param string $id |
|
327 | + */ |
|
328 | 328 | public static function &exists( $id ) { |
329 | - global $wpdb; |
|
330 | - |
|
331 | - if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
332 | - $exists = true; |
|
333 | - return $exists; |
|
334 | - } |
|
335 | - |
|
336 | - if ( is_numeric($id) ) { |
|
337 | - $where = array( 'id' => $id ); |
|
338 | - } else { |
|
339 | - $where = array( 'item_key' => $id ); |
|
340 | - } |
|
329 | + global $wpdb; |
|
330 | + |
|
331 | + if ( FrmAppHelper::check_cache( $id, 'frm_entry' ) ) { |
|
332 | + $exists = true; |
|
333 | + return $exists; |
|
334 | + } |
|
335 | + |
|
336 | + if ( is_numeric($id) ) { |
|
337 | + $where = array( 'id' => $id ); |
|
338 | + } else { |
|
339 | + $where = array( 'item_key' => $id ); |
|
340 | + } |
|
341 | 341 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
342 | 342 | |
343 | - $exists = ($id && $id > 0) ? true : false; |
|
344 | - return $exists; |
|
345 | - } |
|
343 | + $exists = ($id && $id > 0) ? true : false; |
|
344 | + return $exists; |
|
345 | + } |
|
346 | 346 | |
347 | - public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
347 | + public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
348 | 348 | global $wpdb; |
349 | 349 | |
350 | - $limit = FrmAppHelper::esc_limit($limit); |
|
350 | + $limit = FrmAppHelper::esc_limit($limit); |
|
351 | 351 | |
352 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
353 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
352 | + $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
353 | + $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
354 | 354 | |
355 | - if ( false === $entries ) { |
|
356 | - $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'; |
|
355 | + if ( false === $entries ) { |
|
356 | + $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 | 357 | $table = $wpdb->prefix . 'frm_items it '; |
358 | 358 | |
359 | - if ( $inc_form ) { |
|
360 | - $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
361 | - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
362 | - } |
|
359 | + if ( $inc_form ) { |
|
360 | + $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
361 | + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
362 | + } |
|
363 | 363 | |
364 | - if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
365 | - // sort by a requested field |
|
366 | - $field_id = (int) $order_matches[1]; |
|
364 | + if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
365 | + // sort by a requested field |
|
366 | + $field_id = (int) $order_matches[1]; |
|
367 | 367 | $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
368 | 368 | unset( $order_matches, $field_id ); |
369 | - } |
|
369 | + } |
|
370 | 370 | |
371 | 371 | // prepare the query |
372 | 372 | $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
373 | 373 | |
374 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
375 | - unset($query); |
|
374 | + $entries = $wpdb->get_results($query, OBJECT_K); |
|
375 | + unset($query); |
|
376 | 376 | |
377 | 377 | FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' ); |
378 | - } |
|
378 | + } |
|
379 | 379 | |
380 | - if ( ! $meta || ! $entries ) { |
|
381 | - return stripslashes_deep($entries); |
|
382 | - } |
|
383 | - unset($meta); |
|
380 | + if ( ! $meta || ! $entries ) { |
|
381 | + return stripslashes_deep($entries); |
|
382 | + } |
|
383 | + unset($meta); |
|
384 | 384 | |
385 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
385 | + if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
386 | 386 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | - $meta_where = array( 'field_id !' => 0 ); |
|
390 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
391 | - $meta_where['fi.form_id'] = $where['it.form_id']; |
|
392 | - } else { |
|
393 | - $meta_where['item_id'] = array_keys( $entries ); |
|
394 | - } |
|
389 | + $meta_where = array( 'field_id !' => 0 ); |
|
390 | + if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
391 | + $meta_where['fi.form_id'] = $where['it.form_id']; |
|
392 | + } else { |
|
393 | + $meta_where['item_id'] = array_keys( $entries ); |
|
394 | + } |
|
395 | 395 | |
396 | - $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' ); |
|
396 | + $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' ); |
|
397 | 397 | |
398 | - unset( $meta_where ); |
|
398 | + unset( $meta_where ); |
|
399 | 399 | |
400 | - if ( ! $metas ) { |
|
401 | - return stripslashes_deep($entries); |
|
402 | - } |
|
400 | + if ( ! $metas ) { |
|
401 | + return stripslashes_deep($entries); |
|
402 | + } |
|
403 | 403 | |
404 | - foreach ( $metas as $m_key => $meta_val ) { |
|
405 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
406 | - continue; |
|
407 | - } |
|
404 | + foreach ( $metas as $m_key => $meta_val ) { |
|
405 | + if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
406 | + continue; |
|
407 | + } |
|
408 | 408 | |
409 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
409 | + if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
410 | 410 | $entries[ $meta_val->item_id ]->metas = array(); |
411 | - } |
|
411 | + } |
|
412 | 412 | |
413 | 413 | $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
414 | 414 | |
415 | - unset($m_key, $meta_val); |
|
416 | - } |
|
415 | + unset($m_key, $meta_val); |
|
416 | + } |
|
417 | 417 | |
418 | 418 | if ( ! FrmAppHelper::prevent_caching() ) { |
419 | 419 | foreach ( $entries as $entry ) { |
@@ -422,31 +422,31 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - return stripslashes_deep($entries); |
|
426 | - } |
|
425 | + return stripslashes_deep($entries); |
|
426 | + } |
|
427 | 427 | |
428 | - // Pagination Methods |
|
429 | - public static function getRecordCount( $where = '' ) { |
|
430 | - global $wpdb; |
|
428 | + // Pagination Methods |
|
429 | + public static function getRecordCount( $where = '' ) { |
|
430 | + global $wpdb; |
|
431 | 431 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
432 | 432 | |
433 | - if ( is_numeric($where) ) { |
|
434 | - $table_join = 'frm_items'; |
|
435 | - $where = array( 'form_id' => $where ); |
|
436 | - } |
|
433 | + if ( is_numeric($where) ) { |
|
434 | + $table_join = 'frm_items'; |
|
435 | + $where = array( 'form_id' => $where ); |
|
436 | + } |
|
437 | 437 | |
438 | - if ( is_array( $where ) ) { |
|
439 | - $count = FrmDb::get_count( $table_join, $where ); |
|
440 | - } else { |
|
438 | + if ( is_array( $where ) ) { |
|
439 | + $count = FrmDb::get_count( $table_join, $where ); |
|
440 | + } else { |
|
441 | 441 | $cache_key = 'count_' . maybe_serialize( $where ); |
442 | 442 | $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
443 | 443 | $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
444 | - } |
|
444 | + } |
|
445 | 445 | |
446 | - return $count; |
|
447 | - } |
|
446 | + return $count; |
|
447 | + } |
|
448 | 448 | |
449 | - public static function getPageCount( $p_size, $where = '' ) { |
|
449 | + public static function getPageCount( $p_size, $where = '' ) { |
|
450 | 450 | $p_size = (int) $p_size; |
451 | 451 | $count = 1; |
452 | 452 | if ( $p_size ) { |
@@ -457,16 +457,16 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | return $count; |
460 | - } |
|
460 | + } |
|
461 | 461 | |
462 | 462 | /** |
463 | - * Prepare the data before inserting it into the database |
|
464 | - * |
|
465 | - * @since 2.0.16 |
|
466 | - * @param array $values |
|
467 | - * @param string $type |
|
468 | - * @return array $new_values |
|
469 | - */ |
|
463 | + * Prepare the data before inserting it into the database |
|
464 | + * |
|
465 | + * @since 2.0.16 |
|
466 | + * @param array $values |
|
467 | + * @param string $type |
|
468 | + * @return array $new_values |
|
469 | + */ |
|
470 | 470 | private static function before_insert_entry_in_database( &$values, $type ) { |
471 | 471 | |
472 | 472 | self::sanitize_entry_post( $values ); |
@@ -481,13 +481,13 @@ discard block |
||
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
484 | - * Create an entry and perform after create actions |
|
485 | - * |
|
486 | - * @since 2.0.16 |
|
487 | - * @param array $values |
|
488 | - * @param array $new_values |
|
489 | - * @return boolean|int $entry_id |
|
490 | - */ |
|
484 | + * Create an entry and perform after create actions |
|
485 | + * |
|
486 | + * @since 2.0.16 |
|
487 | + * @param array $values |
|
488 | + * @param array $new_values |
|
489 | + * @return boolean|int $entry_id |
|
490 | + */ |
|
491 | 491 | private static function continue_to_create_entry( $values, $new_values ) { |
492 | 492 | $entry_id = self::insert_entry_into_database( $new_values ); |
493 | 493 | if ( ! $entry_id ) { |
@@ -499,37 +499,37 @@ discard block |
||
499 | 499 | return $entry_id; |
500 | 500 | } |
501 | 501 | |
502 | - /** |
|
503 | - * Sanitize the POST values before we use them |
|
504 | - * |
|
505 | - * @since 2.0 |
|
506 | - * @param array $values The POST values by reference |
|
507 | - */ |
|
508 | - public static function sanitize_entry_post( &$values ) { |
|
509 | - $sanitize_method = array( |
|
510 | - 'form_id' => 'absint', |
|
511 | - 'frm_action' => 'sanitize_title', |
|
512 | - 'form_key' => 'sanitize_title', |
|
513 | - 'item_key' => 'sanitize_title', |
|
514 | - 'item_name' => 'sanitize_text_field', |
|
515 | - 'frm_saving_draft' => 'absint', |
|
516 | - 'is_draft' => 'absint', |
|
517 | - 'post_id' => 'absint', |
|
518 | - 'parent_item_id' => 'absint', |
|
519 | - 'created_at' => 'sanitize_text_field', |
|
520 | - 'updated_at' => 'sanitize_text_field', |
|
521 | - ); |
|
522 | - |
|
523 | - FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Prepare the new values for inserting into the database |
|
528 | - * |
|
529 | - * @since 2.0.16 |
|
530 | - * @param array $values |
|
531 | - * @return array $new_values |
|
532 | - */ |
|
502 | + /** |
|
503 | + * Sanitize the POST values before we use them |
|
504 | + * |
|
505 | + * @since 2.0 |
|
506 | + * @param array $values The POST values by reference |
|
507 | + */ |
|
508 | + public static function sanitize_entry_post( &$values ) { |
|
509 | + $sanitize_method = array( |
|
510 | + 'form_id' => 'absint', |
|
511 | + 'frm_action' => 'sanitize_title', |
|
512 | + 'form_key' => 'sanitize_title', |
|
513 | + 'item_key' => 'sanitize_title', |
|
514 | + 'item_name' => 'sanitize_text_field', |
|
515 | + 'frm_saving_draft' => 'absint', |
|
516 | + 'is_draft' => 'absint', |
|
517 | + 'post_id' => 'absint', |
|
518 | + 'parent_item_id' => 'absint', |
|
519 | + 'created_at' => 'sanitize_text_field', |
|
520 | + 'updated_at' => 'sanitize_text_field', |
|
521 | + ); |
|
522 | + |
|
523 | + FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
524 | + } |
|
525 | + |
|
526 | + /** |
|
527 | + * Prepare the new values for inserting into the database |
|
528 | + * |
|
529 | + * @since 2.0.16 |
|
530 | + * @param array $values |
|
531 | + * @return array $new_values |
|
532 | + */ |
|
533 | 533 | private static function package_entry_data( &$values ) { |
534 | 534 | global $wpdb; |
535 | 535 | |
@@ -562,67 +562,67 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
565 | - * Get the is_draft value for a new entry |
|
566 | - * |
|
567 | - * @since 2.0.16 |
|
568 | - * @param array $values |
|
569 | - * @return int |
|
570 | - */ |
|
565 | + * Get the is_draft value for a new entry |
|
566 | + * |
|
567 | + * @since 2.0.16 |
|
568 | + * @param array $values |
|
569 | + * @return int |
|
570 | + */ |
|
571 | 571 | private static function get_is_draft_value( $values ) { |
572 | 572 | return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
576 | - * Get the form_id value for a new entry |
|
577 | - * |
|
578 | - * @since 2.0.16 |
|
579 | - * @param array $values |
|
580 | - * @return int|null |
|
581 | - */ |
|
576 | + * Get the form_id value for a new entry |
|
577 | + * |
|
578 | + * @since 2.0.16 |
|
579 | + * @param array $values |
|
580 | + * @return int|null |
|
581 | + */ |
|
582 | 582 | private static function get_form_id( $values ) { |
583 | 583 | return isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
587 | - * Get the post_id value for a new entry |
|
588 | - * |
|
589 | - * @since 2.0.16 |
|
590 | - * @param array $values |
|
591 | - * @return int |
|
592 | - */ |
|
587 | + * Get the post_id value for a new entry |
|
588 | + * |
|
589 | + * @since 2.0.16 |
|
590 | + * @param array $values |
|
591 | + * @return int |
|
592 | + */ |
|
593 | 593 | private static function get_post_id( $values ) { |
594 | 594 | return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
598 | - * Get the parent_item_id value for a new entry |
|
599 | - * |
|
600 | - * @since 2.0.16 |
|
601 | - * @param array $values |
|
602 | - * @return int |
|
603 | - */ |
|
598 | + * Get the parent_item_id value for a new entry |
|
599 | + * |
|
600 | + * @since 2.0.16 |
|
601 | + * @param array $values |
|
602 | + * @return int |
|
603 | + */ |
|
604 | 604 | private static function get_parent_item_id( $values ) { |
605 | 605 | return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
609 | - * Get the created_at value for a new entry |
|
610 | - * |
|
611 | - * @since 2.0.16 |
|
612 | - * @param array $values |
|
613 | - * @return string |
|
614 | - */ |
|
609 | + * Get the created_at value for a new entry |
|
610 | + * |
|
611 | + * @since 2.0.16 |
|
612 | + * @param array $values |
|
613 | + * @return string |
|
614 | + */ |
|
615 | 615 | private static function get_created_at( $values ) { |
616 | 616 | return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
620 | - * Get the updated_at value for a new entry |
|
621 | - * |
|
622 | - * @since 2.0.16 |
|
623 | - * @param array $values |
|
624 | - * @return string |
|
625 | - */ |
|
620 | + * Get the updated_at value for a new entry |
|
621 | + * |
|
622 | + * @since 2.0.16 |
|
623 | + * @param array $values |
|
624 | + * @return string |
|
625 | + */ |
|
626 | 626 | private static function get_updated_at( $values ) { |
627 | 627 | if ( isset( $values['updated_at'] ) ) { |
628 | 628 | $updated_at = $values['updated_at']; |
@@ -634,12 +634,12 @@ discard block |
||
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
637 | - * Get the description value for a new entry |
|
638 | - * |
|
639 | - * @since 2.0.16 |
|
640 | - * @param array $values |
|
641 | - * @return string |
|
642 | - */ |
|
637 | + * Get the description value for a new entry |
|
638 | + * |
|
639 | + * @since 2.0.16 |
|
640 | + * @param array $values |
|
641 | + * @return string |
|
642 | + */ |
|
643 | 643 | private static function get_entry_description( $values ) { |
644 | 644 | if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) { |
645 | 645 | $description = maybe_serialize( $values['description'] ); |
@@ -654,12 +654,12 @@ discard block |
||
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
657 | - * Get the user_id value for a new entry |
|
658 | - * |
|
659 | - * @since 2.0.16 |
|
660 | - * @param array $values |
|
661 | - * @return int |
|
662 | - */ |
|
657 | + * Get the user_id value for a new entry |
|
658 | + * |
|
659 | + * @since 2.0.16 |
|
660 | + * @param array $values |
|
661 | + * @return int |
|
662 | + */ |
|
663 | 663 | private static function get_entry_user_id( $values ) { |
664 | 664 | if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) { |
665 | 665 | $user_id = $values['frm_user_id']; |
@@ -672,12 +672,12 @@ discard block |
||
672 | 672 | } |
673 | 673 | |
674 | 674 | /** |
675 | - * Insert new entry into the database |
|
676 | - * |
|
677 | - * @since 2.0.16 |
|
678 | - * @param array $new_values |
|
679 | - * @return int | boolean $entry_id |
|
680 | - */ |
|
675 | + * Insert new entry into the database |
|
676 | + * |
|
677 | + * @since 2.0.16 |
|
678 | + * @param array $new_values |
|
679 | + * @return int | boolean $entry_id |
|
680 | + */ |
|
681 | 681 | private static function insert_entry_into_database( $new_values ) { |
682 | 682 | global $wpdb; |
683 | 683 | |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
696 | - * Add the new entry to global $frm_vars |
|
697 | - * |
|
698 | - * @since 2.0.16 |
|
699 | - * @param int $entry_id |
|
700 | - */ |
|
696 | + * Add the new entry to global $frm_vars |
|
697 | + * |
|
698 | + * @since 2.0.16 |
|
699 | + * @param int $entry_id |
|
700 | + */ |
|
701 | 701 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
702 | 702 | global $frm_vars; |
703 | 703 | |
@@ -709,12 +709,12 @@ discard block |
||
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
712 | - * Add entry metas, if there are any |
|
713 | - * |
|
714 | - * @since 2.0.16 |
|
715 | - * @param array $values |
|
716 | - * @param int $entry_id |
|
717 | - */ |
|
712 | + * Add entry metas, if there are any |
|
713 | + * |
|
714 | + * @since 2.0.16 |
|
715 | + * @param array $values |
|
716 | + * @param int $entry_id |
|
717 | + */ |
|
718 | 718 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
719 | 719 | if ( isset($values['item_meta']) ) { |
720 | 720 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
@@ -722,12 +722,12 @@ discard block |
||
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
725 | - * Trigger frm_after_create_entry hooks |
|
726 | - * |
|
727 | - * @since 2.0.16 |
|
728 | - * @param int $entry_id |
|
729 | - * @param array $new_values |
|
730 | - */ |
|
725 | + * Trigger frm_after_create_entry hooks |
|
726 | + * |
|
727 | + * @since 2.0.16 |
|
728 | + * @param int $entry_id |
|
729 | + * @param array $new_values |
|
730 | + */ |
|
731 | 731 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
732 | 732 | // this is a child entry |
733 | 733 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
@@ -737,13 +737,13 @@ discard block |
||
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
740 | - * Actions to perform immediately after an entry is inserted in the frm_items database |
|
741 | - * |
|
742 | - * @since 2.0.16 |
|
743 | - * @param array $values |
|
744 | - * @param array $new_values |
|
745 | - * @param int $entry_id |
|
746 | - */ |
|
740 | + * Actions to perform immediately after an entry is inserted in the frm_items database |
|
741 | + * |
|
742 | + * @since 2.0.16 |
|
743 | + * @param array $values |
|
744 | + * @param array $new_values |
|
745 | + * @param int $entry_id |
|
746 | + */ |
|
747 | 747 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
748 | 748 | |
749 | 749 | self::add_new_entry_to_frm_vars( $entry_id ); |
@@ -756,14 +756,14 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | - * Perform some actions right before updating an entry |
|
760 | - * |
|
761 | - * @since 2.0.16 |
|
762 | - * @param int $id |
|
763 | - * @param array $values |
|
764 | - * @param string $update_type |
|
765 | - * @return boolean $update |
|
766 | - */ |
|
759 | + * Perform some actions right before updating an entry |
|
760 | + * |
|
761 | + * @since 2.0.16 |
|
762 | + * @param int $id |
|
763 | + * @param array $values |
|
764 | + * @param string $update_type |
|
765 | + * @return boolean $update |
|
766 | + */ |
|
767 | 767 | private static function before_update_entry( $id, &$values, $update_type ) { |
768 | 768 | $update = true; |
769 | 769 | |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | } |
782 | 782 | |
783 | 783 | /** |
784 | - * Package the entry data for updating |
|
785 | - * |
|
786 | - * @since 2.0.16 |
|
787 | - * @param int $id |
|
788 | - * @param array $values |
|
789 | - * @return array $new_values |
|
790 | - */ |
|
784 | + * Package the entry data for updating |
|
785 | + * |
|
786 | + * @since 2.0.16 |
|
787 | + * @param int $id |
|
788 | + * @param array $values |
|
789 | + * @return array $new_values |
|
790 | + */ |
|
791 | 791 | private static function package_entry_to_update( $id, $values ) { |
792 | 792 | global $wpdb; |
793 | 793 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
824 | - * Perform some actions right after updating an entry |
|
825 | - * |
|
826 | - * @since 2.0.16 |
|
827 | - * @param boolean|int $query_results |
|
828 | - * @param int $id |
|
829 | - * @param array $values |
|
830 | - * @param array $new_values |
|
831 | - */ |
|
824 | + * Perform some actions right after updating an entry |
|
825 | + * |
|
826 | + * @since 2.0.16 |
|
827 | + * @param boolean|int $query_results |
|
828 | + * @param int $id |
|
829 | + * @param array $values |
|
830 | + * @param array $new_values |
|
831 | + */ |
|
832 | 832 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
833 | 833 | if ( $query_results ) { |
834 | 834 | self::clear_cache(); |
@@ -850,13 +850,13 @@ discard block |
||
850 | 850 | } |
851 | 851 | |
852 | 852 | /** |
853 | - * Create entry from an XML import |
|
854 | - * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
855 | - * |
|
856 | - * @since 2.0.16 |
|
857 | - * @param array $values |
|
858 | - * @return int | boolean $entry_id |
|
859 | - */ |
|
853 | + * Create entry from an XML import |
|
854 | + * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
855 | + * |
|
856 | + * @since 2.0.16 |
|
857 | + * @param array $values |
|
858 | + * @return int | boolean $entry_id |
|
859 | + */ |
|
860 | 860 | public static function create_entry_from_xml( $values ) { |
861 | 861 | $entry_id = self::create_entry( $values, 'xml' ); |
862 | 862 | |
@@ -864,28 +864,28 @@ discard block |
||
864 | 864 | } |
865 | 865 | |
866 | 866 | /** |
867 | - * Update entry from an XML import |
|
868 | - * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
869 | - * |
|
870 | - * @since 2.0.16 |
|
871 | - * @param int $id |
|
872 | - * @param array $values |
|
873 | - * @return int | boolean $updated |
|
874 | - */ |
|
867 | + * Update entry from an XML import |
|
868 | + * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
869 | + * |
|
870 | + * @since 2.0.16 |
|
871 | + * @param int $id |
|
872 | + * @param array $values |
|
873 | + * @return int | boolean $updated |
|
874 | + */ |
|
875 | 875 | public static function update_entry_from_xml( $id, $values ) { |
876 | 876 | $updated = self::update_entry( $id, $values, 'xml' ); |
877 | 877 | |
878 | 878 | return $updated; |
879 | 879 | } |
880 | 880 | |
881 | - /** |
|
882 | - * @param string $key |
|
883 | - * @return int entry_id |
|
884 | - */ |
|
881 | + /** |
|
882 | + * @param string $key |
|
883 | + * @return int entry_id |
|
884 | + */ |
|
885 | 885 | public static function get_id_by_key( $key ) { |
886 | - $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
887 | - return $entry_id; |
|
888 | - } |
|
886 | + $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
887 | + return $entry_id; |
|
888 | + } |
|
889 | 889 | |
890 | 890 | public static function validate( $values, $exclude = false ) { |
891 | 891 | _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 | |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | $new_values['name'] = $values->name; |
136 | 136 | $new_values['is_draft'] = $values->is_draft; |
137 | 137 | $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
138 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
139 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
138 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
139 | + $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 ); |
|
140 | 140 | |
141 | 141 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
142 | 142 | if ( ! $query_results ) { |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | $entry_id = $wpdb->insert_id; |
147 | 147 | |
148 | 148 | global $frm_vars; |
149 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
149 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
150 | 150 | $frm_vars['saved_entries'] = array(); |
151 | 151 | } |
152 | 152 | $frm_vars['saved_entries'][] = (int) $entry_id; |
153 | 153 | |
154 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
154 | + FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
|
155 | 155 | self::clear_cache(); |
156 | 156 | |
157 | 157 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $new_values = self::package_entry_to_update( $id, $values ); |
192 | 192 | |
193 | - $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') ); |
|
193 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); |
|
194 | 194 | |
195 | 195 | self::after_update_entry( $query_results, $id, $values, $new_values ); |
196 | 196 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | return $result; |
208 | 208 | } |
209 | 209 | |
210 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
210 | + do_action( 'frm_before_destroy_entry', $id, $entry ); |
|
211 | 211 | |
212 | 212 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
213 | 213 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | public static function &update_form( $id, $value, $form_id ) { |
221 | 221 | global $wpdb; |
222 | - $form_id = isset($value) ? $form_id : null; |
|
222 | + $form_id = isset( $value ) ? $form_id : null; |
|
223 | 223 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
224 | 224 | if ( $result ) { |
225 | 225 | self::clear_cache(); |
@@ -266,24 +266,24 @@ discard block |
||
266 | 266 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
267 | 267 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
268 | 268 | |
269 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
269 | + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
|
270 | 270 | $query_args = array( $id ); |
271 | 271 | $query = $wpdb->prepare( $query, $query_args ); |
272 | 272 | |
273 | 273 | if ( ! $meta ) { |
274 | 274 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
275 | - return stripslashes_deep($entry); |
|
275 | + return stripslashes_deep( $entry ); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
279 | 279 | if ( $entry !== false ) { |
280 | - return stripslashes_deep($entry); |
|
280 | + return stripslashes_deep( $entry ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $entry = $wpdb->get_row( $query ); |
284 | - $entry = self::get_meta($entry); |
|
284 | + $entry = self::get_meta( $entry ); |
|
285 | 285 | |
286 | - return stripslashes_deep($entry); |
|
286 | + return stripslashes_deep( $entry ); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | public static function get_meta( $entry ) { |
@@ -299,23 +299,23 @@ discard block |
||
299 | 299 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
300 | 300 | foreach ( $metas as $meta_val ) { |
301 | 301 | if ( $meta_val->item_id == $entry->id ) { |
302 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
302 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
303 | 303 | if ( $include_key ) { |
304 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
304 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
305 | 305 | } |
306 | 306 | continue; |
307 | 307 | } |
308 | 308 | |
309 | 309 | // include sub entries in an array |
310 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
311 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
310 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
311 | + $entry->metas[$meta_val->field_id] = array(); |
|
312 | 312 | } |
313 | 313 | |
314 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
314 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
315 | 315 | |
316 | - unset($meta_val); |
|
316 | + unset( $meta_val ); |
|
317 | 317 | } |
318 | - unset($metas); |
|
318 | + unset( $metas ); |
|
319 | 319 | |
320 | 320 | FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' ); |
321 | 321 | |
@@ -333,24 +333,24 @@ discard block |
||
333 | 333 | return $exists; |
334 | 334 | } |
335 | 335 | |
336 | - if ( is_numeric($id) ) { |
|
336 | + if ( is_numeric( $id ) ) { |
|
337 | 337 | $where = array( 'id' => $id ); |
338 | 338 | } else { |
339 | 339 | $where = array( 'item_key' => $id ); |
340 | 340 | } |
341 | 341 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
342 | 342 | |
343 | - $exists = ($id && $id > 0) ? true : false; |
|
343 | + $exists = ( $id && $id > 0 ) ? true : false; |
|
344 | 344 | return $exists; |
345 | 345 | } |
346 | 346 | |
347 | 347 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
348 | 348 | global $wpdb; |
349 | 349 | |
350 | - $limit = FrmAppHelper::esc_limit($limit); |
|
350 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
351 | 351 | |
352 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
353 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
352 | + $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
|
353 | + $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
|
354 | 354 | |
355 | 355 | if ( false === $entries ) { |
356 | 356 | $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'; |
@@ -369,25 +369,25 @@ discard block |
||
369 | 369 | } |
370 | 370 | |
371 | 371 | // prepare the query |
372 | - $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
372 | + $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
373 | 373 | |
374 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
375 | - unset($query); |
|
374 | + $entries = $wpdb->get_results( $query, OBJECT_K ); |
|
375 | + unset( $query ); |
|
376 | 376 | |
377 | 377 | FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' ); |
378 | 378 | } |
379 | 379 | |
380 | 380 | if ( ! $meta || ! $entries ) { |
381 | - return stripslashes_deep($entries); |
|
381 | + return stripslashes_deep( $entries ); |
|
382 | 382 | } |
383 | - unset($meta); |
|
383 | + unset( $meta ); |
|
384 | 384 | |
385 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
385 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
386 | 386 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
387 | 387 | } |
388 | 388 | |
389 | 389 | $meta_where = array( 'field_id !' => 0 ); |
390 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
390 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
391 | 391 | $meta_where['fi.form_id'] = $where['it.form_id']; |
392 | 392 | } else { |
393 | 393 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -398,21 +398,21 @@ discard block |
||
398 | 398 | unset( $meta_where ); |
399 | 399 | |
400 | 400 | if ( ! $metas ) { |
401 | - return stripslashes_deep($entries); |
|
401 | + return stripslashes_deep( $entries ); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | foreach ( $metas as $m_key => $meta_val ) { |
405 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
405 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
406 | 406 | continue; |
407 | 407 | } |
408 | 408 | |
409 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
410 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
409 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
410 | + $entries[$meta_val->item_id]->metas = array(); |
|
411 | 411 | } |
412 | 412 | |
413 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
413 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
414 | 414 | |
415 | - unset($m_key, $meta_val); |
|
415 | + unset( $m_key, $meta_val ); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - return stripslashes_deep($entries); |
|
425 | + return stripslashes_deep( $entries ); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // Pagination Methods |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | global $wpdb; |
431 | 431 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
432 | 432 | |
433 | - if ( is_numeric($where) ) { |
|
433 | + if ( is_numeric( $where ) ) { |
|
434 | 434 | $table_join = 'frm_items'; |
435 | 435 | $where = array( 'form_id' => $where ); |
436 | 436 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | self::sanitize_entry_post( $values ); |
473 | 473 | |
474 | 474 | if ( $type != 'xml' ) { |
475 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
475 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | $new_values = self::package_entry_data( $values ); |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | 'user_id' => self::get_entry_user_id( $values ), |
553 | 553 | ); |
554 | 554 | |
555 | - if ( is_array($new_values['name']) ) { |
|
556 | - $new_values['name'] = reset($new_values['name']); |
|
555 | + if ( is_array( $new_values['name'] ) ) { |
|
556 | + $new_values['name'] = reset( $new_values['name'] ); |
|
557 | 557 | } |
558 | 558 | |
559 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
559 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
560 | 560 | |
561 | 561 | return $new_values; |
562 | 562 | } |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @return int |
570 | 570 | */ |
571 | 571 | private static function get_is_draft_value( $values ) { |
572 | - return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
572 | + return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | * @return int |
592 | 592 | */ |
593 | 593 | private static function get_post_id( $values ) { |
594 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
594 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @return int |
603 | 603 | */ |
604 | 604 | private static function get_parent_item_id( $values ) { |
605 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
605 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | * @return string |
614 | 614 | */ |
615 | 615 | private static function get_created_at( $values ) { |
616 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
616 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
702 | 702 | global $frm_vars; |
703 | 703 | |
704 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
704 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
705 | 705 | $frm_vars['saved_entries'] = array(); |
706 | 706 | } |
707 | 707 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param int $entry_id |
717 | 717 | */ |
718 | 718 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
719 | - if ( isset($values['item_meta']) ) { |
|
719 | + if ( isset( $values['item_meta'] ) ) { |
|
720 | 720 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
721 | 721 | } |
722 | 722 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
734 | 734 | |
735 | 735 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
736 | - do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
736 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | } |
775 | 775 | |
776 | 776 | if ( $update && $update_type != 'xml' ) { |
777 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
777 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | return $update; |
@@ -795,27 +795,27 @@ discard block |
||
795 | 795 | 'name' => self::get_new_entry_name( $values ), |
796 | 796 | 'form_id' => self::get_form_id( $values ), |
797 | 797 | 'is_draft' => self::get_is_draft_value( $values ), |
798 | - 'updated_at' => current_time('mysql', 1), |
|
799 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
798 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
799 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
800 | 800 | ); |
801 | 801 | |
802 | - if ( isset($values['post_id']) ) { |
|
802 | + if ( isset( $values['post_id'] ) ) { |
|
803 | 803 | $new_values['post_id'] = (int) $values['post_id']; |
804 | 804 | } |
805 | 805 | |
806 | - if ( isset($values['item_key']) ) { |
|
806 | + if ( isset( $values['item_key'] ) ) { |
|
807 | 807 | $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
808 | 808 | } |
809 | 809 | |
810 | - if ( isset($values['parent_item_id']) ) { |
|
810 | + if ( isset( $values['parent_item_id'] ) ) { |
|
811 | 811 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
812 | 812 | } |
813 | 813 | |
814 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
814 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
815 | 815 | $new_values['user_id'] = $values['frm_user_id']; |
816 | 816 | } |
817 | 817 | |
818 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
818 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
819 | 819 | |
820 | 820 | return $new_values; |
821 | 821 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | <div class="update-nag frm-update-to-pro"> |
136 | 136 | <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> |
137 | 137 | <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> |
138 | - <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
138 | + <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidablepro.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
139 | 139 | </div> |
140 | 140 | <?php |
141 | 141 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | public static function uninstall() { |
388 | - FrmAppHelper::permission_check('administrator'); |
|
388 | + FrmAppHelper::permission_check( 'administrator' ); |
|
389 | 389 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
390 | 390 | |
391 | 391 | $frmdb = new FrmDb(); |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | public static function deauthorize() { |
423 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
423 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
424 | 424 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
425 | 425 | |
426 | 426 | delete_option( 'frmpro-credentials' ); |
@@ -3,14 +3,14 @@ discard block |
||
3 | 3 | class FrmAppController { |
4 | 4 | |
5 | 5 | public static function menu() { |
6 | - FrmAppHelper::maybe_add_permissions(); |
|
7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | - return; |
|
9 | - } |
|
6 | + FrmAppHelper::maybe_add_permissions(); |
|
7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
8 | + return; |
|
9 | + } |
|
10 | 10 | |
11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
13 | - } |
|
13 | + } |
|
14 | 14 | |
15 | 15 | private static function get_menu_position() { |
16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | return $pos; |
20 | 20 | } |
21 | 21 | |
22 | - public static function load_wp_admin_style() { |
|
23 | - FrmAppHelper::load_font_style(); |
|
24 | - } |
|
22 | + public static function load_wp_admin_style() { |
|
23 | + FrmAppHelper::load_font_style(); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
27 | 27 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
28 | - if ( empty( $show_nav ) || ! $form ) { |
|
29 | - return; |
|
30 | - } |
|
28 | + if ( empty( $show_nav ) || ! $form ) { |
|
29 | + return; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | FrmForm::maybe_get_form( $form ); |
33 | 33 | if ( ! is_object( $form ) ) { |
@@ -85,28 +85,28 @@ discard block |
||
85 | 85 | return $nav_items; |
86 | 86 | } |
87 | 87 | |
88 | - // Adds a settings link to the plugins page |
|
89 | - public static function settings_link( $links ) { |
|
88 | + // Adds a settings link to the plugins page |
|
89 | + public static function settings_link( $links ) { |
|
90 | 90 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
91 | - array_unshift( $links, $settings ); |
|
91 | + array_unshift( $links, $settings ); |
|
92 | 92 | |
93 | - return $links; |
|
94 | - } |
|
93 | + return $links; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function pro_get_started_headline() { |
|
96 | + public static function pro_get_started_headline() { |
|
97 | 97 | self::maybe_show_upgrade_bar(); |
98 | 98 | |
99 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
100 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
101 | - return; |
|
102 | - } |
|
99 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
100 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
101 | + return; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
105 | - FrmAppHelper::load_admin_wide_js(); |
|
105 | + FrmAppHelper::load_admin_wide_js(); |
|
106 | 106 | |
107 | - // user is authorized, but running free version |
|
108 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
109 | - ?> |
|
107 | + // user is authorized, but running free version |
|
108 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
109 | + ?> |
|
110 | 110 | <div class="error" class="frm_previous_install"> |
111 | 111 | <?php |
112 | 112 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | ) ); ?> |
119 | 119 | </div> |
120 | 120 | <?php |
121 | - } |
|
122 | - } |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | 124 | private static function maybe_show_upgrade_bar() { |
125 | 125 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - public static function admin_js() { |
|
224 | + public static function admin_js() { |
|
225 | 225 | $version = FrmAppHelper::plugin_version(); |
226 | 226 | FrmAppHelper::load_admin_wide_js( false ); |
227 | 227 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
233 | 233 | ), $version, true ); |
234 | 234 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
235 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
235 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
236 | 236 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
237 | 237 | wp_register_style( 'formidable-dropzone', FrmAppHelper::plugin_url() . '/css/dropzone.css', array(), $version ); |
238 | 238 | |
@@ -245,65 +245,65 @@ discard block |
||
245 | 245 | global $pagenow; |
246 | 246 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
247 | 247 | |
248 | - wp_enqueue_script( 'admin-widgets' ); |
|
249 | - wp_enqueue_style( 'widgets' ); |
|
250 | - wp_enqueue_script( 'formidable' ); |
|
251 | - wp_enqueue_script( 'formidable_admin' ); |
|
248 | + wp_enqueue_script( 'admin-widgets' ); |
|
249 | + wp_enqueue_style( 'widgets' ); |
|
250 | + wp_enqueue_script( 'formidable' ); |
|
251 | + wp_enqueue_script( 'formidable_admin' ); |
|
252 | 252 | FrmAppHelper::localize_script( 'admin' ); |
253 | 253 | |
254 | - wp_enqueue_style( 'formidable-admin' ); |
|
254 | + wp_enqueue_style( 'formidable-admin' ); |
|
255 | 255 | wp_enqueue_style( 'formidable-grids' ); |
256 | 256 | wp_enqueue_style( 'formidable-dropzone' ); |
257 | - add_thickbox(); |
|
257 | + add_thickbox(); |
|
258 | 258 | |
259 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
259 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
260 | 260 | |
261 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
262 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
263 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
261 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
262 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
263 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
264 | 264 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
265 | 265 | $post = get_post( absint( $_REQUEST['post'] ) ); |
266 | - if ( ! $post ) { |
|
267 | - return; |
|
268 | - } |
|
269 | - $post_type = $post->post_type; |
|
270 | - } else { |
|
271 | - return; |
|
272 | - } |
|
273 | - |
|
274 | - if ( $post_type == 'frm_display' ) { |
|
275 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
276 | - wp_enqueue_script( 'formidable_admin' ); |
|
277 | - wp_enqueue_style( 'formidable-admin' ); |
|
266 | + if ( ! $post ) { |
|
267 | + return; |
|
268 | + } |
|
269 | + $post_type = $post->post_type; |
|
270 | + } else { |
|
271 | + return; |
|
272 | + } |
|
273 | + |
|
274 | + if ( $post_type == 'frm_display' ) { |
|
275 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
276 | + wp_enqueue_script( 'formidable_admin' ); |
|
277 | + wp_enqueue_style( 'formidable-admin' ); |
|
278 | 278 | FrmAppHelper::localize_script( 'admin' ); |
279 | - } |
|
280 | - } else if ( $pagenow == 'widgets.php' ) { |
|
281 | - FrmAppHelper::load_admin_wide_js(); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - public static function load_lang() { |
|
286 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Filter shortcodes in text widgets |
|
291 | - */ |
|
292 | - public static function widget_text_filter( $content ) { |
|
293 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
294 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
295 | - } |
|
296 | - |
|
297 | - public static function front_head() { |
|
298 | - if ( is_multisite() ) { |
|
299 | - $old_db_version = get_option( 'frm_db_version' ); |
|
300 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
301 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
302 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
303 | - self::install( $old_db_version ); |
|
304 | - } |
|
305 | - } |
|
306 | - } |
|
279 | + } |
|
280 | + } else if ( $pagenow == 'widgets.php' ) { |
|
281 | + FrmAppHelper::load_admin_wide_js(); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + public static function load_lang() { |
|
286 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Filter shortcodes in text widgets |
|
291 | + */ |
|
292 | + public static function widget_text_filter( $content ) { |
|
293 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
294 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
295 | + } |
|
296 | + |
|
297 | + public static function front_head() { |
|
298 | + if ( is_multisite() ) { |
|
299 | + $old_db_version = get_option( 'frm_db_version' ); |
|
300 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
301 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
302 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
303 | + self::install( $old_db_version ); |
|
304 | + } |
|
305 | + } |
|
306 | + } |
|
307 | 307 | |
308 | 308 | public static function localize_script( $location ) { |
309 | 309 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -358,20 +358,20 @@ discard block |
||
358 | 358 | wp_die(); |
359 | 359 | } |
360 | 360 | |
361 | - public static function activation_install() { |
|
362 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
363 | - FrmFormActionsController::actions_init(); |
|
364 | - self::install(); |
|
365 | - } |
|
361 | + public static function activation_install() { |
|
362 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
363 | + FrmFormActionsController::actions_init(); |
|
364 | + self::install(); |
|
365 | + } |
|
366 | 366 | |
367 | - public static function install( $old_db_version = false ) { |
|
368 | - $frmdb = new FrmDb(); |
|
369 | - $frmdb->upgrade( $old_db_version ); |
|
370 | - } |
|
367 | + public static function install( $old_db_version = false ) { |
|
368 | + $frmdb = new FrmDb(); |
|
369 | + $frmdb->upgrade( $old_db_version ); |
|
370 | + } |
|
371 | 371 | |
372 | - public static function uninstall() { |
|
372 | + public static function uninstall() { |
|
373 | 373 | FrmAppHelper::permission_check('administrator'); |
374 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
374 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
375 | 375 | |
376 | 376 | $frmdb = new FrmDb(); |
377 | 377 | $frmdb->uninstall(); |
@@ -380,43 +380,43 @@ discard block |
||
380 | 380 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
381 | 381 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
382 | 382 | |
383 | - wp_die(); |
|
384 | - } |
|
383 | + wp_die(); |
|
384 | + } |
|
385 | 385 | |
386 | - public static function drop_tables( $tables ) { |
|
387 | - global $wpdb; |
|
388 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
389 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
390 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
391 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
392 | - return $tables; |
|
393 | - } |
|
386 | + public static function drop_tables( $tables ) { |
|
387 | + global $wpdb; |
|
388 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
389 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
390 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
391 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
392 | + return $tables; |
|
393 | + } |
|
394 | 394 | |
395 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
396 | - public static function page_route( $content ) { |
|
397 | - global $post; |
|
395 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
396 | + public static function page_route( $content ) { |
|
397 | + global $post; |
|
398 | 398 | |
399 | - $frm_settings = FrmAppHelper::get_settings(); |
|
400 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
401 | - $content = FrmFormsController::page_preview(); |
|
402 | - } |
|
399 | + $frm_settings = FrmAppHelper::get_settings(); |
|
400 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
401 | + $content = FrmFormsController::page_preview(); |
|
402 | + } |
|
403 | 403 | |
404 | - return $content; |
|
405 | - } |
|
404 | + return $content; |
|
405 | + } |
|
406 | 406 | |
407 | - public static function deauthorize() { |
|
407 | + public static function deauthorize() { |
|
408 | 408 | FrmAppHelper::permission_check('frm_change_settings'); |
409 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
410 | - |
|
411 | - delete_option( 'frmpro-credentials' ); |
|
412 | - delete_option( 'frmpro-authorized' ); |
|
413 | - delete_site_option( 'frmpro-credentials' ); |
|
414 | - delete_site_option( 'frmpro-authorized' ); |
|
415 | - wp_die(); |
|
416 | - } |
|
417 | - |
|
418 | - public static function get_form_shortcode( $atts ) { |
|
419 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
420 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
421 | - } |
|
409 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
410 | + |
|
411 | + delete_option( 'frmpro-credentials' ); |
|
412 | + delete_option( 'frmpro-authorized' ); |
|
413 | + delete_site_option( 'frmpro-credentials' ); |
|
414 | + delete_site_option( 'frmpro-authorized' ); |
|
415 | + wp_die(); |
|
416 | + } |
|
417 | + |
|
418 | + public static function get_form_shortcode( $atts ) { |
|
419 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
420 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
421 | + } |
|
422 | 422 | } |