@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | |
20 | 20 | <tbody class="menu-locations"> |
21 | 21 | <?php |
22 | - if ( $forms ) { |
|
23 | - foreach ( $forms as $form ) { |
|
24 | - $this_style = isset($form->options['custom_style']) ? (int) $form->options['custom_style'] : 1; |
|
25 | - if ( 1 == $this_style ) { |
|
26 | - // use the default style |
|
27 | - $this_style = $default_style->ID; |
|
28 | - } |
|
29 | - ?> |
|
22 | + if ( $forms ) { |
|
23 | + foreach ( $forms as $form ) { |
|
24 | + $this_style = isset($form->options['custom_style']) ? (int) $form->options['custom_style'] : 1; |
|
25 | + if ( 1 == $this_style ) { |
|
26 | + // use the default style |
|
27 | + $this_style = $default_style->ID; |
|
28 | + } |
|
29 | + ?> |
|
30 | 30 | <tr id="menu-locations-row"> |
31 | 31 | <td class="menu-location-title"><strong><?php echo empty($form->name) ? __( '(no title)') : $form->name ?></strong></td> |
32 | 32 | <td class="menu-location-menus"> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | </td><!-- .menu-location-menus --> |
42 | 42 | </tr><!-- #menu-locations-row --> |
43 | 43 | <?php |
44 | - } |
|
44 | + } |
|
45 | 45 | } else { |
46 | 46 | ?> |
47 | 47 | <tr> |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <div class="nav-menus-php"> |
2 | 2 | <div class="wrap"> |
3 | - <?php FrmStylesHelper::style_menu('manage'); ?> |
|
3 | + <?php FrmStylesHelper::style_menu( 'manage' ); ?> |
|
4 | 4 | |
5 | - <p><?php printf(__( 'Easily change which template your forms are using by making changes below.', 'formidable' ), '<a href="?page=formidable-styles&frm_action=new_style">', '</a>'); ?></p> |
|
5 | + <p><?php printf( __( 'Easily change which template your forms are using by making changes below.', 'formidable' ), '<a href="?page=formidable-styles&frm_action=new_style">', '</a>' ); ?></p> |
|
6 | 6 | |
7 | 7 | <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
8 | 8 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | <?php |
22 | 22 | if ( $forms ) { |
23 | 23 | foreach ( $forms as $form ) { |
24 | - $this_style = isset($form->options['custom_style']) ? (int) $form->options['custom_style'] : 1; |
|
24 | + $this_style = isset( $form->options['custom_style'] ) ? (int) $form->options['custom_style'] : 1; |
|
25 | 25 | if ( 1 == $this_style ) { |
26 | 26 | // use the default style |
27 | 27 | $this_style = $default_style->ID; |
28 | 28 | } |
29 | 29 | ?> |
30 | 30 | <tr id="menu-locations-row"> |
31 | - <td class="menu-location-title"><strong><?php echo empty($form->name) ? __( '(no title)') : $form->name ?></strong></td> |
|
31 | + <td class="menu-location-title"><strong><?php echo empty( $form->name ) ? __( '(no title)' ) : $form->name ?></strong></td> |
|
32 | 32 | <td class="menu-location-menus"> |
33 | 33 | <input type="hidden" name="prev_style[<?php echo esc_attr( $form->id ) ?>]" value="<?php echo esc_attr( $this_style ) ?>" /> |
34 | 34 | <select name="style[<?php echo esc_attr( $form->id ) ?>]"> |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <?php echo esc_html( $s->post_title . ( empty( $s->menu_order ) ? '' : ' (' . __( 'default', 'formidable' ) . ')' ) ) ?> |
38 | 38 | </option> |
39 | 39 | <?php } ?> |
40 | - <option value="" <?php selected(0, $this_style) ?>><?php _e( 'Styling disabled', 'formidable' ) ?></option> |
|
40 | + <option value="" <?php selected( 0, $this_style ) ?>><?php _e( 'Styling disabled', 'formidable' ) ?></option> |
|
41 | 41 | </select> |
42 | 42 | |
43 | 43 | </td><!-- .menu-location-menus --> |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! $item_ids ) { |
4 | - return; |
|
4 | + return; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | // fetch 20 posts at a time rather than loading the entire table into memory |
@@ -45,6 +45,6 @@ discard block |
||
45 | 45 | <?php } ?> |
46 | 46 | </form> |
47 | 47 | <?php |
48 | - unset( $fields ); |
|
48 | + unset( $fields ); |
|
49 | 49 | } |
50 | 50 | } |
@@ -13,16 +13,16 @@ discard block |
||
13 | 13 | ?> |
14 | 14 | <form> |
15 | 15 | <id><?php echo $form->id ?></id> |
16 | - <form_key><?php echo FrmXMLHelper::cdata($form->form_key) ?></form_key> |
|
17 | - <name><?php echo FrmXMLHelper::cdata($form->name) ?></name> |
|
18 | - <description><?php echo FrmXMLHelper::cdata($form->description) ?></description> |
|
16 | + <form_key><?php echo FrmXMLHelper::cdata( $form->form_key ) ?></form_key> |
|
17 | + <name><?php echo FrmXMLHelper::cdata( $form->name ) ?></name> |
|
18 | + <description><?php echo FrmXMLHelper::cdata( $form->description ) ?></description> |
|
19 | 19 | <created_at><?php echo $form->created_at ?></created_at> |
20 | 20 | <logged_in><?php echo $form->logged_in ?></logged_in> |
21 | 21 | <is_template><?php echo $form->is_template ?></is_template> |
22 | 22 | <default_template><?php echo $form->default_template ?></default_template> |
23 | 23 | <editable><?php echo $form->editable ?></editable> |
24 | - <options><?php echo FrmXMLHelper::prepare_form_options_for_export($form->options) ?></options> |
|
25 | - <status><?php echo FrmXMLHelper::cdata($form->status) ?></status> |
|
24 | + <options><?php echo FrmXMLHelper::prepare_form_options_for_export( $form->options ) ?></options> |
|
25 | + <status><?php echo FrmXMLHelper::cdata( $form->status ) ?></status> |
|
26 | 26 | <parent_form_id><?php echo $form->parent_form_id ?></parent_form_id> |
27 | 27 | <?php |
28 | 28 | |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | foreach ( $fields as $field ) { ?> |
32 | 32 | <field> |
33 | 33 | <id><?php echo $field->id ?></id> |
34 | - <field_key><?php echo FrmXMLHelper::cdata($field->field_key) ?></field_key> |
|
35 | - <name><?php echo FrmXMLHelper::cdata($field->name) ?></name> |
|
36 | - <description><?php echo FrmXMLHelper::cdata($field->description) ?></description> |
|
37 | - <type><?php echo FrmXMLHelper::cdata($field->type) ?></type> |
|
38 | - <default_value><?php echo FrmXMLHelper::cdata($field->default_value) ?></default_value> |
|
34 | + <field_key><?php echo FrmXMLHelper::cdata( $field->field_key ) ?></field_key> |
|
35 | + <name><?php echo FrmXMLHelper::cdata( $field->name ) ?></name> |
|
36 | + <description><?php echo FrmXMLHelper::cdata( $field->description ) ?></description> |
|
37 | + <type><?php echo FrmXMLHelper::cdata( $field->type ) ?></type> |
|
38 | + <default_value><?php echo FrmXMLHelper::cdata( $field->default_value ) ?></default_value> |
|
39 | 39 | <field_order><?php echo $field->field_order ?></field_order> |
40 | 40 | <form_id><?php echo $field->form_id ?></form_id> |
41 | 41 | <required><?php echo (bool) $field->required ?></required> |
42 | - <options><?php echo FrmXMLHelper::cdata($field->options) ?></options> |
|
43 | - <field_options><?php echo FrmXMLHelper::cdata($field->field_options) ?></field_options> |
|
42 | + <options><?php echo FrmXMLHelper::cdata( $field->options ) ?></options> |
|
43 | + <field_options><?php echo FrmXMLHelper::cdata( $field->field_options ) ?></field_options> |
|
44 | 44 | </field> |
45 | 45 | <?php } ?> |
46 | 46 | </form> |
@@ -79,7 +79,7 @@ |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | $frm_inc_tax[] = $term->term_id; |
82 | - $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
82 | + $label = ( $term->taxonomy == 'category' || $term->taxonomy == 'tag' ) ? $term->taxonomy : 'term'; ?> |
|
83 | 83 | <term><term_id><?php echo $term->term_id ?></term_id><term_taxonomy><?php echo $term->taxonomy; ?></term_taxonomy><?php |
84 | 84 | if ( ! empty( $term->name ) ) { |
85 | 85 | echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! $item_ids ) { |
4 | - return; |
|
4 | + return; |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | global $wp_query; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | if ( empty( $taxonomies ) ) { |
68 | - return; |
|
68 | + return; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | global $frm_inc_tax; |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | |
76 | 76 | foreach ( (array) $terms as $term ) { |
77 | 77 | if ( in_array( $term->term_id, $frm_inc_tax ) ) { |
78 | - return; |
|
78 | + return; |
|
79 | 79 | } |
80 | 80 | |
81 | - $frm_inc_tax[] = $term->term_id; |
|
82 | - $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
81 | + $frm_inc_tax[] = $term->term_id; |
|
82 | + $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
83 | 83 | <term><term_id><?php echo esc_html( $term->term_id ) ?></term_id><term_taxonomy><?php echo esc_html( $term->taxonomy ); ?></term_taxonomy><?php |
84 | - if ( ! empty( $term->name ) ) { |
|
85 | - echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
|
86 | - } |
|
87 | - if ( ! empty( $term->description ) ) { |
|
88 | - ?><term_description><?php echo FrmXMLHelper::cdata( $term->description ) ?></term_description><?php |
|
89 | - } |
|
90 | - ?><term_slug><?php echo esc_html( $term->slug ); ?></term_slug></term> |
|
84 | + if ( ! empty( $term->name ) ) { |
|
85 | + echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
|
86 | + } |
|
87 | + if ( ! empty( $term->description ) ) { |
|
88 | + ?><term_description><?php echo FrmXMLHelper::cdata( $term->description ) ?></term_description><?php |
|
89 | + } |
|
90 | + ?><term_slug><?php echo esc_html( $term->slug ); ?></term_slug></term> |
|
91 | 91 | <?php |
92 | 92 | } |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | public function widget( $args, $instance ) { |
11 | - if ( empty($instance['title']) ) { |
|
12 | - $title = FrmForm::getName( $instance['form'] ); |
|
13 | - } else { |
|
14 | - $title = $instance['title']; |
|
15 | - } |
|
16 | - $title = apply_filters('widget_title', $title); |
|
11 | + if ( empty($instance['title']) ) { |
|
12 | + $title = FrmForm::getName( $instance['form'] ); |
|
13 | + } else { |
|
14 | + $title = $instance['title']; |
|
15 | + } |
|
16 | + $title = apply_filters('widget_title', $title); |
|
17 | 17 | |
18 | - $instance['description'] = isset($instance['description']) ? $instance['description'] : false; |
|
18 | + $instance['description'] = isset($instance['description']) ? $instance['description'] : false; |
|
19 | 19 | |
20 | 20 | echo $args['before_widget']; |
21 | 21 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | public function form( $instance ) { |
38 | - //Defaults |
|
38 | + //Defaults |
|
39 | 39 | $instance = wp_parse_args( (array) $instance, array( |
40 | - 'title' => false, 'form' => false, 'description' => false, |
|
40 | + 'title' => false, 'form' => false, 'description' => false, |
|
41 | 41 | ) ); |
42 | 42 | ?> |
43 | 43 | <p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/> |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | |
46 | 46 | <p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/> |
47 | 47 | <?php |
48 | - FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array( |
|
49 | - 'blank' => false, 'field_id' => $this->get_field_id('form'), |
|
50 | - 'class' => 'widefat', |
|
51 | - ) ); |
|
48 | + FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array( |
|
49 | + 'blank' => false, 'field_id' => $this->get_field_id('form'), |
|
50 | + 'class' => 'widefat', |
|
51 | + ) ); |
|
52 | 52 | ?> |
53 | 53 | </p> |
54 | 54 |
@@ -4,27 +4,27 @@ discard block |
||
4 | 4 | |
5 | 5 | public function __construct() { |
6 | 6 | $widget_ops = array( 'description' => __( 'Display a Formidable Form', 'formidable' ) ); |
7 | - parent::__construct('frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops); |
|
7 | + parent::__construct( 'frm_show_form', __( 'Formidable Form', 'formidable' ), $widget_ops ); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | public function widget( $args, $instance ) { |
11 | - if ( empty($instance['title']) ) { |
|
11 | + if ( empty( $instance['title'] ) ) { |
|
12 | 12 | $title = FrmForm::getName( $instance['form'] ); |
13 | 13 | } else { |
14 | 14 | $title = $instance['title']; |
15 | 15 | } |
16 | - $title = apply_filters('widget_title', $title); |
|
16 | + $title = apply_filters( 'widget_title', $title ); |
|
17 | 17 | |
18 | - $instance['description'] = isset($instance['description']) ? $instance['description'] : false; |
|
18 | + $instance['description'] = isset( $instance['description'] ) ? $instance['description'] : false; |
|
19 | 19 | |
20 | 20 | echo $args['before_widget']; |
21 | 21 | |
22 | 22 | echo '<div class="frm_form_widget">'; |
23 | 23 | if ( $title ) { |
24 | - echo $args['before_title'] . stripslashes($title) . $args['after_title']; |
|
24 | + echo $args['before_title'] . stripslashes( $title ) . $args['after_title']; |
|
25 | 25 | } |
26 | 26 | |
27 | - echo FrmFormsController::show_form($instance['form'], '', false, $instance['description']); |
|
27 | + echo FrmFormsController::show_form( $instance['form'], '', false, $instance['description'] ); |
|
28 | 28 | |
29 | 29 | echo '</div>'; |
30 | 30 | echo $args['after_widget']; |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | 'title' => false, 'form' => false, 'description' => false, |
41 | 41 | ) ); |
42 | 42 | ?> |
43 | - <p><label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/> |
|
44 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( stripslashes($instance['title']) ); ?>" /></p> |
|
43 | + <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'formidable' ) ?>:</label><br/> |
|
44 | + <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( stripslashes( $instance['title'] ) ); ?>" /></p> |
|
45 | 45 | |
46 | - <p><label for="<?php echo esc_attr( $this->get_field_id('form') ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/> |
|
46 | + <p><label for="<?php echo esc_attr( $this->get_field_id( 'form' ) ); ?>"><?php _e( 'Form', 'formidable' ) ?>:</label><br/> |
|
47 | 47 | <?php |
48 | - FrmFormsHelper::forms_dropdown( $this->get_field_name('form'), $instance['form'], array( |
|
49 | - 'blank' => false, 'field_id' => $this->get_field_id('form'), |
|
48 | + FrmFormsHelper::forms_dropdown( $this->get_field_name( 'form' ), $instance['form'], array( |
|
49 | + 'blank' => false, 'field_id' => $this->get_field_id( 'form' ), |
|
50 | 50 | 'class' => 'widefat', |
51 | 51 | ) ); |
52 | 52 | ?> |
53 | 53 | </p> |
54 | 54 | |
55 | - <p><label for="<?php echo esc_attr( $this->get_field_id('description') ); ?>"><input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo esc_attr( $this->get_field_id('description') ); ?>" name="<?php echo esc_attr( $this->get_field_name('description') ); ?>" value="1" /> |
|
55 | + <p><label for="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>"><input class="checkbox" type="checkbox" <?php checked( $instance['description'], true ) ?> id="<?php echo esc_attr( $this->get_field_id( 'description' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" value="1" /> |
|
56 | 56 | <?php _e( 'Show Description', 'formidable' ) ?></label></p> |
57 | 57 | <?php |
58 | 58 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | // 2.0 |
4 | 4 | if ( ! isset($frm_vars['pro_is_installed']) ) { |
5 | - $frm_vars['pro_is_installed'] = false; |
|
5 | + $frm_vars['pro_is_installed'] = false; |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | // Instansiate Models |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // 2.0 |
4 | -if ( ! isset($frm_vars['pro_is_installed']) ) { |
|
4 | +if ( ! isset( $frm_vars['pro_is_installed'] ) ) { |
|
5 | 5 | $frm_vars['pro_is_installed'] = false; |
6 | 6 | } |
7 | 7 |
@@ -1,5 +1,5 @@ |
||
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 |
@@ -375,6 +375,9 @@ |
||
375 | 375 | $reset_fields = true; |
376 | 376 | } |
377 | 377 | |
378 | + /** |
|
379 | + * @return string |
|
380 | + */ |
|
378 | 381 | public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
379 | 382 | foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) { |
380 | 383 | if ( $code == 'form_name' ) { |
@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | public static function get_direct_link( $key, $form = false ) { |
14 | 14 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
15 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
15 | + $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form ); |
|
16 | 16 | |
17 | 17 | return $target_url; |
18 | 18 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $query['id !'] = $args['exclude']; |
38 | 38 | } |
39 | 39 | |
40 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
40 | + $where = apply_filters( 'frm_forms_dropdown', $query, $field_name ); |
|
41 | 41 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
42 | 42 | $add_html = array(); |
43 | 43 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | <?php } ?> |
51 | 51 | <?php foreach ( $forms as $form ) { ?> |
52 | 52 | <option value="<?php echo esc_attr( $form->id ); ?>" <?php selected( $field_value, $form->id ); ?>><?php |
53 | - echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ) ; |
|
53 | + echo ( '' == $form->name ) ? esc_html__( '(no title)', 'formidable' ) : esc_html( FrmAppHelper::truncate( $form->name, 50 ) ) . ( $form->parent_form_id ? esc_html__( ' (child)', 'formidable' ) : '' ); |
|
54 | 54 | ?></option> |
55 | 55 | <?php } ?> |
56 | 56 | </select> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function add_html_attr( $class, $param, &$add_html ) { |
68 | 68 | if ( ! empty( $class ) ) { |
69 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
69 | + $add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $args = array( 'id' => 0, 'form' => 0 ); |
78 | 78 | if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) { |
79 | 79 | unset( $args['form'] ); |
80 | - } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
|
80 | + } else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) { |
|
81 | 81 | unset( $args['id'] ); |
82 | 82 | } |
83 | 83 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
86 | 86 | $args['frm_action'] = 'list'; |
87 | 87 | $args['form'] = 0; |
88 | - } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
88 | + } else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
|
89 | 89 | $args['frm_action'] = 'edit'; |
90 | 90 | } else if ( isset( $_GET['post'] ) ) { |
91 | 91 | $args['form'] = 0; |
92 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
92 | + $base = admin_url( 'edit.php?post_type=frm_display' ); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | ?> |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $args['form'] = $form->id; |
106 | 106 | } |
107 | 107 | ?> |
108 | - <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
|
108 | + <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
|
109 | 109 | <?php |
110 | 110 | unset( $form ); |
111 | 111 | } ?> |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
118 | - echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | - echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
118 | + echo ( $sort_col == $col ) ? 'sorted' : 'sortable'; |
|
119 | + echo ( $sort_col == $col && $sort_dir == 'desc' ) ? ' asc' : ' desc'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public static function get_success_message( $atts ) { |
@@ -136,20 +136,20 @@ discard block |
||
136 | 136 | $post_values = $values; |
137 | 137 | } else { |
138 | 138 | $values = array(); |
139 | - $post_values = isset($_POST) ? $_POST : array(); |
|
139 | + $post_values = isset( $_POST ) ? $_POST : array(); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) { |
143 | - if ( ! isset( $values[ $var ] ) ) { |
|
144 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
143 | + if ( ! isset( $values[$var] ) ) { |
|
144 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
148 | + $values['description'] = FrmAppHelper::use_wpautop( $values['description'] ); |
|
149 | 149 | |
150 | 150 | foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) { |
151 | - if ( ! isset( $values[ $var ] ) ) { |
|
152 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
151 | + if ( ! isset( $values[$var] ) ) { |
|
152 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
158 | 158 | } |
159 | 159 | |
160 | - $values = self::fill_default_opts($values, false, $post_values); |
|
160 | + $values = self::fill_default_opts( $values, false, $post_values ); |
|
161 | 161 | |
162 | - if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
162 | + if ( $post_values && isset( $post_values['options']['custom_style'] ) ) { |
|
163 | 163 | $values['custom_style'] = $post_values['options']['custom_style']; |
164 | 164 | } else { |
165 | 165 | $frm_settings = FrmAppHelper::get_settings(); |
166 | 166 | $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
167 | 167 | } |
168 | 168 | |
169 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
169 | + return apply_filters( 'frm_setup_new_form_vars', $values ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -177,42 +177,42 @@ discard block |
||
177 | 177 | $post_values = stripslashes_deep( $_POST ); |
178 | 178 | } |
179 | 179 | |
180 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
180 | + $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key; |
|
181 | + $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template; |
|
182 | + $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template; |
|
183 | 183 | $values['status'] = $record->status; |
184 | 184 | |
185 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
185 | + $values = self::fill_default_opts( $values, $record, $post_values ); |
|
186 | 186 | |
187 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
187 | + return apply_filters( 'frm_setup_edit_form_vars', $values ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | public static function fill_default_opts( $values, $record, $post_values ) { |
191 | 191 | |
192 | 192 | $defaults = self::get_default_opts(); |
193 | 193 | foreach ( $defaults as $var => $default ) { |
194 | - if ( is_array($default) ) { |
|
195 | - if ( ! isset( $values[ $var ] ) ) { |
|
196 | - $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
|
194 | + if ( is_array( $default ) ) { |
|
195 | + if ( ! isset( $values[$var] ) ) { |
|
196 | + $values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | foreach ( $default as $k => $v ) { |
200 | - $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v); |
|
200 | + $values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v ); |
|
201 | 201 | |
202 | 202 | if ( is_array( $v ) ) { |
203 | 203 | foreach ( $v as $k1 => $v1 ) { |
204 | - $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
|
204 | + $values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 ); |
|
205 | 205 | unset( $k1, $v1 ); |
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - unset($k, $v); |
|
209 | + unset( $k, $v ); |
|
210 | 210 | } |
211 | 211 | } else { |
212 | - $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
|
212 | + $values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default ); |
|
213 | 213 | } |
214 | 214 | |
215 | - unset($var, $default); |
|
215 | + unset( $var, $default ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $values; |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
226 | 226 | 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
227 | 227 | 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
228 | - 'before_html' => self::get_default_html('before'), |
|
228 | + 'before_html' => self::get_default_html( 'before' ), |
|
229 | 229 | 'after_html' => '', |
230 | - 'submit_html' => self::get_default_html('submit'), |
|
230 | + 'submit_html' => self::get_default_html( 'submit' ), |
|
231 | 231 | ); |
232 | 232 | } |
233 | 233 | |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public static function fill_form_options( &$options, $values ) { |
240 | 240 | $defaults = self::get_default_opts(); |
241 | 241 | foreach ( $defaults as $var => $default ) { |
242 | - $options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default; |
|
242 | + $options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default; |
|
243 | 243 | unset( $var, $default ); |
244 | 244 | } |
245 | 245 | } |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
282 | - $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | - if ( ! strpos($button, '[button_action]') ) { |
|
282 | + $button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values ); |
|
283 | + if ( ! strpos( $button, '[button_action]' ) ) { |
|
284 | 284 | return; |
285 | 285 | } |
286 | 286 | |
287 | - $button_parts = explode('[button_action]', $button); |
|
287 | + $button_parts = explode( '[button_action]', $button ); |
|
288 | 288 | echo $button_parts[0]; |
289 | 289 | //echo ' id="frm_submit_"'; |
290 | 290 | |
291 | - $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | - if ( ! empty($classes) ) { |
|
291 | + $classes = apply_filters( 'frm_submit_button_class', array(), $form ); |
|
292 | + if ( ! empty( $classes ) ) { |
|
293 | 293 | echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"'; |
294 | 294 | } |
295 | 295 | |
296 | - do_action('frm_submit_button_action', $form, $form_action); |
|
296 | + do_action( 'frm_submit_button_action', $form, $form_action ); |
|
297 | 297 | echo $button_parts[1]; |
298 | 298 | } |
299 | 299 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $last_field = false; |
315 | 315 | foreach ( $fields as $field ) { |
316 | 316 | if ( $prev_order === $field->field_order ) { |
317 | - $add_order++; |
|
317 | + $add_order ++; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | if ( $add_order ) { |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | if ( $code == 'form_name' ) { |
382 | 382 | $replace_with = $form->name; |
383 | 383 | } else if ( $code == 'form_description' ) { |
384 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
384 | + $replace_with = FrmAppHelper::use_wpautop( $form->description ); |
|
385 | + } else if ( $code == 'entry_key' && isset( $_GET ) && isset( $_GET['entry'] ) ) { |
|
386 | 386 | $replace_with = FrmAppHelper::simple_get( 'entry' ); |
387 | 387 | } else { |
388 | 388 | $replace_with = ''; |
389 | 389 | } |
390 | 390 | |
391 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
391 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | //replace [form_key] |
395 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
395 | + $html = str_replace( '[form_key]', $form->form_key, $html ); |
|
396 | 396 | |
397 | 397 | //replace [frmurl] |
398 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
398 | + $html = str_replace( '[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html ); |
|
399 | 399 | |
400 | 400 | if ( strpos( $html, '[button_label]' ) ) { |
401 | 401 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $html = str_replace( '[button_label]', $replace_with, $html ); |
404 | 404 | } |
405 | 405 | |
406 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
406 | + $html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values ); |
|
407 | 407 | |
408 | 408 | if ( strpos( $html, '[if back_button]' ) ) { |
409 | 409 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | } |
422 | 422 | |
423 | 423 | public static function submit_button_label( $submit ) { |
424 | - if ( ! $submit || empty($submit) ) { |
|
424 | + if ( ! $submit || empty( $submit ) ) { |
|
425 | 425 | $frm_settings = FrmAppHelper::get_settings(); |
426 | 426 | $submit = $frm_settings->submit_value; |
427 | 427 | } |
@@ -430,11 +430,11 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | public static function get_form_style_class( $form = false ) { |
433 | - $style = self::get_form_style($form); |
|
433 | + $style = self::get_form_style( $form ); |
|
434 | 434 | $class = ' with_frm_style'; |
435 | 435 | |
436 | - if ( empty($style) ) { |
|
437 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
436 | + if ( empty( $style ) ) { |
|
437 | + if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) { |
|
438 | 438 | return $class; |
439 | 439 | } else { |
440 | 440 | return; |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | //If submit button needs to be inline or centered |
445 | - if ( is_object($form) ) { |
|
445 | + if ( is_object( $form ) ) { |
|
446 | 446 | $form = $form->options; |
447 | 447 | } |
448 | 448 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | $class .= ' frm_center_submit'; |
455 | 455 | } |
456 | 456 | |
457 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
457 | + $class = apply_filters( 'frm_add_form_style_class', $class, $style ); |
|
458 | 458 | |
459 | 459 | return $class; |
460 | 460 | } |
@@ -542,12 +542,12 @@ discard block |
||
542 | 542 | } |
543 | 543 | |
544 | 544 | public static function edit_form_link( $form_id ) { |
545 | - if ( is_object($form_id) ) { |
|
545 | + if ( is_object( $form_id ) ) { |
|
546 | 546 | $form = $form_id; |
547 | 547 | $name = $form->name; |
548 | 548 | $form_id = $form->id; |
549 | 549 | } else { |
550 | - $name = FrmForm::getName($form_id); |
|
550 | + $name = FrmForm::getName( $form_id ); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | if ( $form_id ) { |
@@ -579,12 +579,12 @@ discard block |
||
579 | 579 | $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
580 | 580 | $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id; |
581 | 581 | if ( 'trash' == $status ) { |
582 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
|
583 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
582 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][$length] . '</a>'; |
|
583 | + } else if ( current_user_can( 'frm_delete_forms' ) ) { |
|
584 | 584 | if ( EMPTY_TRASH_DAYS ) { |
585 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
|
585 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][$length] . '</a>'; |
|
586 | 586 | } else { |
587 | - $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
|
587 | + $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][$length] . '</a>'; |
|
588 | 588 | } |
589 | 589 | } |
590 | 590 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | 'publish' => __( 'Published', 'formidable' ), |
599 | 599 | ); |
600 | 600 | |
601 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
601 | + if ( ! in_array( $status, array_keys( $nice_names ) ) ) { |
|
602 | 602 | $status = 'publish'; |
603 | 603 | } |
604 | 604 | |
605 | - $name = $nice_names[ $status ]; |
|
605 | + $name = $nice_names[$status]; |
|
606 | 606 | |
607 | 607 | return $name; |
608 | 608 | } |
@@ -12,38 +12,38 @@ discard block |
||
12 | 12 | |
13 | 13 | public static function get_direct_link( $key, $form = false ) { |
14 | 14 | $target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) ); |
15 | - $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
16 | - |
|
17 | - return $target_url; |
|
18 | - } |
|
19 | - |
|
20 | - public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
21 | - $defaults = array( |
|
22 | - 'blank' => true, |
|
23 | - 'field_id' => false, |
|
24 | - 'onchange' => false, |
|
25 | - 'exclude' => false, |
|
26 | - 'class' => '', |
|
15 | + $target_url = apply_filters('frm_direct_link', $target_url, $key, $form); |
|
16 | + |
|
17 | + return $target_url; |
|
18 | + } |
|
19 | + |
|
20 | + public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) { |
|
21 | + $defaults = array( |
|
22 | + 'blank' => true, |
|
23 | + 'field_id' => false, |
|
24 | + 'onchange' => false, |
|
25 | + 'exclude' => false, |
|
26 | + 'class' => '', |
|
27 | 27 | 'inc_children' => 'exclude', |
28 | - ); |
|
29 | - $args = wp_parse_args( $args, $defaults ); |
|
28 | + ); |
|
29 | + $args = wp_parse_args( $args, $defaults ); |
|
30 | 30 | |
31 | - if ( ! $args['field_id'] ) { |
|
32 | - $args['field_id'] = $field_name; |
|
33 | - } |
|
31 | + if ( ! $args['field_id'] ) { |
|
32 | + $args['field_id'] = $field_name; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | $query = array(); |
36 | - if ( $args['exclude'] ) { |
|
36 | + if ( $args['exclude'] ) { |
|
37 | 37 | $query['id !'] = $args['exclude']; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
40 | + $where = apply_filters('frm_forms_dropdown', $query, $field_name); |
|
41 | 41 | $forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] ); |
42 | 42 | $add_html = array(); |
43 | 43 | self::add_html_attr( $args['onchange'], 'onchange', $add_html ); |
44 | 44 | self::add_html_attr( $args['class'], 'class', $add_html ); |
45 | 45 | |
46 | - ?> |
|
46 | + ?> |
|
47 | 47 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>> |
48 | 48 | <?php if ( $args['blank'] ) { ?> |
49 | 49 | <option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option> |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | <?php } ?> |
56 | 56 | </select> |
57 | 57 | <?php |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @param string $class |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - public static function form_switcher() { |
|
73 | + public static function form_switcher() { |
|
74 | 74 | $where = apply_filters( 'frm_forms_dropdown', array(), '' ); |
75 | 75 | $forms = FrmForm::get_published_forms( $where ); |
76 | 76 | |
@@ -79,32 +79,32 @@ discard block |
||
79 | 79 | unset( $args['form'] ); |
80 | 80 | } else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) { |
81 | 81 | unset( $args['id'] ); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | $frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ); |
85 | 85 | if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) { |
86 | - $args['frm_action'] = 'list'; |
|
87 | - $args['form'] = 0; |
|
86 | + $args['frm_action'] = 'list'; |
|
87 | + $args['form'] = 0; |
|
88 | 88 | } else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) { |
89 | - $args['frm_action'] = 'edit'; |
|
89 | + $args['frm_action'] = 'edit'; |
|
90 | 90 | } else if ( isset( $_GET['post'] ) ) { |
91 | - $args['form'] = 0; |
|
92 | - $base = admin_url('edit.php?post_type=frm_display'); |
|
93 | - } |
|
91 | + $args['form'] = 0; |
|
92 | + $base = admin_url('edit.php?post_type=frm_display'); |
|
93 | + } |
|
94 | 94 | |
95 | - ?> |
|
95 | + ?> |
|
96 | 96 | <li class="dropdown last" id="frm_bs_dropdown"> |
97 | 97 | <a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php _e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a> |
98 | 98 | <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop"> |
99 | 99 | <?php |
100 | 100 | foreach ( $forms as $form ) { |
101 | 101 | if ( isset( $args['id'] ) ) { |
102 | - $args['id'] = $form->id; |
|
102 | + $args['id'] = $form->id; |
|
103 | 103 | } |
104 | - if ( isset( $args['form'] ) ) { |
|
105 | - $args['form'] = $form->id; |
|
104 | + if ( isset( $args['form'] ) ) { |
|
105 | + $args['form'] = $form->id; |
|
106 | 106 | } |
107 | - ?> |
|
107 | + ?> |
|
108 | 108 | <li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)') : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li> |
109 | 109 | <?php |
110 | 110 | unset( $form ); |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | </ul> |
113 | 113 | </li> |
114 | 114 | <?php |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | public static function get_sortable_classes( $col, $sort_col, $sort_dir ) { |
118 | - echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | - echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
120 | - } |
|
118 | + echo ($sort_col == $col) ? 'sorted' : 'sortable'; |
|
119 | + echo ($sort_col == $col && $sort_dir == 'desc') ? ' asc' : ' desc'; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | public static function get_success_message( $atts ) { |
123 | 123 | $message = apply_filters( 'frm_content', $atts['message'], $atts['form'], $atts['entry_id'] ); |
@@ -126,110 +126,110 @@ discard block |
||
126 | 126 | return $message; |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Used when a form is created |
|
131 | - */ |
|
132 | - public static function setup_new_vars( $values = array() ) { |
|
133 | - global $wpdb; |
|
129 | + /** |
|
130 | + * Used when a form is created |
|
131 | + */ |
|
132 | + public static function setup_new_vars( $values = array() ) { |
|
133 | + global $wpdb; |
|
134 | 134 | |
135 | - if ( ! empty( $values ) ) { |
|
136 | - $post_values = $values; |
|
137 | - } else { |
|
138 | - $values = array(); |
|
139 | - $post_values = isset($_POST) ? $_POST : array(); |
|
140 | - } |
|
135 | + if ( ! empty( $values ) ) { |
|
136 | + $post_values = $values; |
|
137 | + } else { |
|
138 | + $values = array(); |
|
139 | + $post_values = isset($_POST) ? $_POST : array(); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | foreach ( array( 'name' => '', 'description' => '' ) as $var => $default ) { |
143 | 143 | if ( ! isset( $values[ $var ] ) ) { |
144 | 144 | $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
145 | - } |
|
146 | - } |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
148 | + $values['description'] = FrmAppHelper::use_wpautop($values['description']); |
|
149 | 149 | |
150 | 150 | foreach ( array( 'form_id' => '', 'logged_in' => '', 'editable' => '', 'default_template' => 0, 'is_template' => 0, 'status' => 'draft', 'parent_form_id' => 0 ) as $var => $default ) { |
151 | - if ( ! isset( $values[ $var ] ) ) { |
|
151 | + if ( ! isset( $values[ $var ] ) ) { |
|
152 | 152 | $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
153 | - } |
|
154 | - } |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | - if ( ! isset( $values['form_key'] ) ) { |
|
156 | + if ( ! isset( $values['form_key'] ) ) { |
|
157 | 157 | $values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' ); |
158 | - } |
|
158 | + } |
|
159 | 159 | |
160 | - $values = self::fill_default_opts($values, false, $post_values); |
|
160 | + $values = self::fill_default_opts($values, false, $post_values); |
|
161 | 161 | |
162 | - if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
163 | - $values['custom_style'] = $post_values['options']['custom_style']; |
|
164 | - } else { |
|
165 | - $frm_settings = FrmAppHelper::get_settings(); |
|
166 | - $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
167 | - } |
|
162 | + if ( $post_values && isset($post_values['options']['custom_style']) ) { |
|
163 | + $values['custom_style'] = $post_values['options']['custom_style']; |
|
164 | + } else { |
|
165 | + $frm_settings = FrmAppHelper::get_settings(); |
|
166 | + $values['custom_style'] = ( $frm_settings->load_style != 'none' ); |
|
167 | + } |
|
168 | 168 | |
169 | - return apply_filters('frm_setup_new_form_vars', $values); |
|
170 | - } |
|
169 | + return apply_filters('frm_setup_new_form_vars', $values); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Used when editing a form |
|
174 | - */ |
|
175 | - public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
172 | + /** |
|
173 | + * Used when editing a form |
|
174 | + */ |
|
175 | + public static function setup_edit_vars( $values, $record, $post_values = array() ) { |
|
176 | 176 | if ( empty( $post_values ) ) { |
177 | 177 | $post_values = stripslashes_deep( $_POST ); |
178 | 178 | } |
179 | 179 | |
180 | - $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | - $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | - $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
183 | - $values['status'] = $record->status; |
|
180 | + $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key; |
|
181 | + $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template; |
|
182 | + $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template; |
|
183 | + $values['status'] = $record->status; |
|
184 | 184 | |
185 | - $values = self::fill_default_opts($values, $record, $post_values); |
|
185 | + $values = self::fill_default_opts($values, $record, $post_values); |
|
186 | 186 | |
187 | - return apply_filters('frm_setup_edit_form_vars', $values); |
|
188 | - } |
|
187 | + return apply_filters('frm_setup_edit_form_vars', $values); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | public static function fill_default_opts( $values, $record, $post_values ) { |
191 | 191 | |
192 | - $defaults = self::get_default_opts(); |
|
192 | + $defaults = self::get_default_opts(); |
|
193 | 193 | foreach ( $defaults as $var => $default ) { |
194 | - if ( is_array($default) ) { |
|
195 | - if ( ! isset( $values[ $var ] ) ) { |
|
194 | + if ( is_array($default) ) { |
|
195 | + if ( ! isset( $values[ $var ] ) ) { |
|
196 | 196 | $values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array(); |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - foreach ( $default as $k => $v ) { |
|
199 | + foreach ( $default as $k => $v ) { |
|
200 | 200 | $values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v); |
201 | 201 | |
202 | - if ( is_array( $v ) ) { |
|
203 | - foreach ( $v as $k1 => $v1 ) { |
|
202 | + if ( is_array( $v ) ) { |
|
203 | + foreach ( $v as $k1 => $v1 ) { |
|
204 | 204 | $values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
205 | - unset( $k1, $v1 ); |
|
206 | - } |
|
207 | - } |
|
205 | + unset( $k1, $v1 ); |
|
206 | + } |
|
207 | + } |
|
208 | 208 | |
209 | - unset($k, $v); |
|
210 | - } |
|
211 | - } else { |
|
209 | + unset($k, $v); |
|
210 | + } |
|
211 | + } else { |
|
212 | 212 | $values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default ); |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | - unset($var, $default); |
|
216 | - } |
|
215 | + unset($var, $default); |
|
216 | + } |
|
217 | 217 | |
218 | - return $values; |
|
219 | - } |
|
218 | + return $values; |
|
219 | + } |
|
220 | 220 | |
221 | - public static function get_default_opts() { |
|
222 | - $frm_settings = FrmAppHelper::get_settings(); |
|
221 | + public static function get_default_opts() { |
|
222 | + $frm_settings = FrmAppHelper::get_settings(); |
|
223 | 223 | |
224 | - return array( |
|
225 | - 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
|
226 | - 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
|
227 | - 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
|
228 | - 'before_html' => self::get_default_html('before'), |
|
229 | - 'after_html' => '', |
|
230 | - 'submit_html' => self::get_default_html('submit'), |
|
231 | - ); |
|
232 | - } |
|
224 | + return array( |
|
225 | + 'submit_value' => $frm_settings->submit_value, 'success_action' => 'message', |
|
226 | + 'success_msg' => $frm_settings->success_msg, 'show_form' => 0, 'akismet' => '', |
|
227 | + 'no_save' => 0, 'ajax_load' => 0, 'form_class' => '', 'custom_style' => 1, |
|
228 | + 'before_html' => self::get_default_html('before'), |
|
229 | + 'after_html' => '', |
|
230 | + 'submit_html' => self::get_default_html('submit'), |
|
231 | + ); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * @param array $options |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | - /** |
|
248 | - * @param string $loc |
|
249 | - */ |
|
247 | + /** |
|
248 | + * @param string $loc |
|
249 | + */ |
|
250 | 250 | public static function get_default_html( $loc ) { |
251 | 251 | if ( $loc == 'submit' ) { |
252 | - $sending = __( 'Sending', 'formidable' ); |
|
253 | - $draft_link = self::get_draft_link(); |
|
254 | - $img = '[frmurl]/images/ajax_loader.gif'; |
|
255 | - $default_html = <<<SUBMIT_HTML |
|
252 | + $sending = __( 'Sending', 'formidable' ); |
|
253 | + $draft_link = self::get_draft_link(); |
|
254 | + $img = '[frmurl]/images/ajax_loader.gif'; |
|
255 | + $default_html = <<<SUBMIT_HTML |
|
256 | 256 | <div class="frm_submit"> |
257 | 257 | [if back_button]<input type="button" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook] />[/if back_button] |
258 | 258 | <input type="submit" value="[button_label]" [button_action] /> |
@@ -261,49 +261,49 @@ discard block |
||
261 | 261 | </div> |
262 | 262 | SUBMIT_HTML; |
263 | 263 | } else if ( $loc == 'before' ) { |
264 | - $default_html = <<<BEFORE_HTML |
|
264 | + $default_html = <<<BEFORE_HTML |
|
265 | 265 | <legend class="frm_hidden">[form_name]</legend> |
266 | 266 | [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name] |
267 | 267 | [if form_description]<div class="frm_description">[form_description]</div>[/if form_description] |
268 | 268 | BEFORE_HTML; |
269 | 269 | } else { |
270 | - $default_html = ''; |
|
271 | - } |
|
270 | + $default_html = ''; |
|
271 | + } |
|
272 | 272 | |
273 | - return $default_html; |
|
274 | - } |
|
273 | + return $default_html; |
|
274 | + } |
|
275 | 275 | |
276 | - public static function get_draft_link() { |
|
277 | - $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
278 | - return $link; |
|
279 | - } |
|
276 | + public static function get_draft_link() { |
|
277 | + $link = '[if save_draft]<a href="#" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]'; |
|
278 | + return $link; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) { |
282 | - $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | - if ( ! strpos($button, '[button_action]') ) { |
|
284 | - return; |
|
285 | - } |
|
282 | + $button = self::replace_shortcodes($html, $form, $submit, $form_action, $values); |
|
283 | + if ( ! strpos($button, '[button_action]') ) { |
|
284 | + return; |
|
285 | + } |
|
286 | 286 | |
287 | - $button_parts = explode('[button_action]', $button); |
|
288 | - echo $button_parts[0]; |
|
289 | - //echo ' id="frm_submit_"'; |
|
287 | + $button_parts = explode('[button_action]', $button); |
|
288 | + echo $button_parts[0]; |
|
289 | + //echo ' id="frm_submit_"'; |
|
290 | 290 | |
291 | - $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | - if ( ! empty($classes) ) { |
|
291 | + $classes = apply_filters('frm_submit_button_class', array(), $form); |
|
292 | + if ( ! empty($classes) ) { |
|
293 | 293 | echo ' class="' . esc_attr( implode( ' ', $classes ) ) . '"'; |
294 | - } |
|
295 | - |
|
296 | - do_action('frm_submit_button_action', $form, $form_action); |
|
297 | - echo $button_parts[1]; |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Automatically add end section fields if they don't exist (2.0 migration) |
|
302 | - * @since 2.0 |
|
303 | - * |
|
304 | - * @param boolean $reset_fields |
|
305 | - */ |
|
306 | - public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
294 | + } |
|
295 | + |
|
296 | + do_action('frm_submit_button_action', $form, $form_action); |
|
297 | + echo $button_parts[1]; |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Automatically add end section fields if they don't exist (2.0 migration) |
|
302 | + * @since 2.0 |
|
303 | + * |
|
304 | + * @param boolean $reset_fields |
|
305 | + */ |
|
306 | + public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) { |
|
307 | 307 | if ( empty( $fields ) ) { |
308 | 308 | return; |
309 | 309 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $open = $prev_order = false; |
313 | 313 | $add_order = 0; |
314 | 314 | $last_field = false; |
315 | - foreach ( $fields as $field ) { |
|
315 | + foreach ( $fields as $field ) { |
|
316 | 316 | if ( $prev_order === $field->field_order ) { |
317 | 317 | $add_order++; |
318 | 318 | } |
@@ -323,48 +323,48 @@ discard block |
||
323 | 323 | FrmField::update( $field->id, array( 'field_order' => $field->field_order ) ); |
324 | 324 | } |
325 | 325 | |
326 | - switch ( $field->type ) { |
|
327 | - case 'divider': |
|
328 | - // create an end section if open |
|
326 | + switch ( $field->type ) { |
|
327 | + case 'divider': |
|
328 | + // create an end section if open |
|
329 | 329 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
330 | 330 | |
331 | - // mark it open for the next end section |
|
332 | - $open = true; |
|
333 | - break; |
|
334 | - case 'break'; |
|
331 | + // mark it open for the next end section |
|
332 | + $open = true; |
|
333 | + break; |
|
334 | + case 'break'; |
|
335 | 335 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' ); |
336 | - break; |
|
337 | - case 'end_divider': |
|
338 | - if ( ! $open ) { |
|
339 | - // the section isn't open, so this is an extra field that needs to be removed |
|
340 | - FrmField::destroy( $field->id ); |
|
341 | - $reset_fields = true; |
|
342 | - } |
|
343 | - |
|
344 | - // There is already an end section here, so there is no need to create one |
|
345 | - $open = false; |
|
346 | - } |
|
336 | + break; |
|
337 | + case 'end_divider': |
|
338 | + if ( ! $open ) { |
|
339 | + // the section isn't open, so this is an extra field that needs to be removed |
|
340 | + FrmField::destroy( $field->id ); |
|
341 | + $reset_fields = true; |
|
342 | + } |
|
343 | + |
|
344 | + // There is already an end section here, so there is no need to create one |
|
345 | + $open = false; |
|
346 | + } |
|
347 | 347 | $prev_order = $field->field_order; |
348 | 348 | |
349 | 349 | $last_field = $field; |
350 | 350 | unset( $field ); |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | 353 | self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field ); |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Create end section field if it doesn't exist. This is for migration from < 2.0 |
358 | 358 | * Fix any ordering that may be messed up |
359 | 359 | */ |
360 | 360 | public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) { |
361 | - if ( ! $open ) { |
|
362 | - return; |
|
363 | - } |
|
361 | + if ( ! $open ) { |
|
362 | + return; |
|
363 | + } |
|
364 | 364 | |
365 | 365 | $end_section_values['field_order'] = $field->field_order + 1; |
366 | 366 | |
367 | - FrmField::create( $end_section_values ); |
|
367 | + FrmField::create( $end_section_values ); |
|
368 | 368 | |
369 | 369 | if ( $move == 'move' ) { |
370 | 370 | // bump the order of current field unless we're at the end of the form |
@@ -372,39 +372,39 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | $add_order += 2; |
375 | - $open = false; |
|
376 | - $reset_fields = true; |
|
377 | - } |
|
375 | + $open = false; |
|
376 | + $reset_fields = true; |
|
377 | + } |
|
378 | 378 | |
379 | - public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
|
379 | + public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) { |
|
380 | 380 | foreach ( array( 'form_name' => $title, 'form_description' => $description, 'entry_key' => true ) as $code => $show ) { |
381 | - if ( $code == 'form_name' ) { |
|
382 | - $replace_with = $form->name; |
|
383 | - } else if ( $code == 'form_description' ) { |
|
384 | - $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | - } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
386 | - $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
387 | - } else { |
|
388 | - $replace_with = ''; |
|
389 | - } |
|
381 | + if ( $code == 'form_name' ) { |
|
382 | + $replace_with = $form->name; |
|
383 | + } else if ( $code == 'form_description' ) { |
|
384 | + $replace_with = FrmAppHelper::use_wpautop($form->description); |
|
385 | + } else if ( $code == 'entry_key' && isset($_GET) && isset($_GET['entry']) ) { |
|
386 | + $replace_with = FrmAppHelper::simple_get( 'entry' ); |
|
387 | + } else { |
|
388 | + $replace_with = ''; |
|
389 | + } |
|
390 | 390 | |
391 | - FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | - } |
|
391 | + FrmFieldsHelper::remove_inline_conditions( ( FrmAppHelper::is_true($show) && $replace_with != '' ), $code, $replace_with, $html ); |
|
392 | + } |
|
393 | 393 | |
394 | - //replace [form_key] |
|
395 | - $html = str_replace('[form_key]', $form->form_key, $html); |
|
394 | + //replace [form_key] |
|
395 | + $html = str_replace('[form_key]', $form->form_key, $html); |
|
396 | 396 | |
397 | - //replace [frmurl] |
|
398 | - $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
397 | + //replace [frmurl] |
|
398 | + $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values( 'frmurl' ), $html); |
|
399 | 399 | |
400 | 400 | if ( strpos( $html, '[button_label]' ) ) { |
401 | 401 | add_filter( 'frm_submit_button', 'FrmFormsHelper::submit_button_label', 1 ); |
402 | 402 | $submit_label = apply_filters( 'frm_submit_button', $title, $form ); |
403 | 403 | $submit_label = esc_attr( do_shortcode( $submit_label ) ); |
404 | 404 | $html = str_replace( '[button_label]', $submit_label, $html ); |
405 | - } |
|
405 | + } |
|
406 | 406 | |
407 | - $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
407 | + $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values); |
|
408 | 408 | |
409 | 409 | if ( strpos( $html, '[if back_button]' ) ) { |
410 | 410 | $html = preg_replace( '/(\[if\s+back_button\])(.*?)(\[\/if\s+back_button\])/mis', '', $html ); |
@@ -418,32 +418,32 @@ discard block |
||
418 | 418 | $html = do_shortcode( $html ); |
419 | 419 | } |
420 | 420 | |
421 | - return $html; |
|
422 | - } |
|
421 | + return $html; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | public static function submit_button_label( $submit ) { |
425 | - if ( ! $submit || empty($submit) ) { |
|
426 | - $frm_settings = FrmAppHelper::get_settings(); |
|
427 | - $submit = $frm_settings->submit_value; |
|
428 | - } |
|
425 | + if ( ! $submit || empty($submit) ) { |
|
426 | + $frm_settings = FrmAppHelper::get_settings(); |
|
427 | + $submit = $frm_settings->submit_value; |
|
428 | + } |
|
429 | 429 | |
430 | - return $submit; |
|
431 | - } |
|
430 | + return $submit; |
|
431 | + } |
|
432 | 432 | |
433 | 433 | public static function get_form_style_class( $form = false ) { |
434 | - $style = self::get_form_style($form); |
|
435 | - $class = ' with_frm_style'; |
|
436 | - |
|
437 | - if ( empty($style) ) { |
|
438 | - if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
439 | - return $class; |
|
440 | - } else { |
|
441 | - return; |
|
442 | - } |
|
443 | - } |
|
444 | - |
|
445 | - //If submit button needs to be inline or centered |
|
446 | - if ( is_object($form) ) { |
|
434 | + $style = self::get_form_style($form); |
|
435 | + $class = ' with_frm_style'; |
|
436 | + |
|
437 | + if ( empty($style) ) { |
|
438 | + if ( FrmAppHelper::is_admin_page('formidable-entries') ) { |
|
439 | + return $class; |
|
440 | + } else { |
|
441 | + return; |
|
442 | + } |
|
443 | + } |
|
444 | + |
|
445 | + //If submit button needs to be inline or centered |
|
446 | + if ( is_object($form) ) { |
|
447 | 447 | $form = $form->options; |
448 | 448 | } |
449 | 449 | |
@@ -455,17 +455,17 @@ discard block |
||
455 | 455 | $class .= ' frm_center_submit'; |
456 | 456 | } |
457 | 457 | |
458 | - $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
458 | + $class = apply_filters('frm_add_form_style_class', $class, $style); |
|
459 | 459 | |
460 | - return $class; |
|
461 | - } |
|
460 | + return $class; |
|
461 | + } |
|
462 | 462 | |
463 | - /** |
|
464 | - * @param string|boolean $form |
|
465 | - * |
|
466 | - * @return string |
|
467 | - */ |
|
468 | - public static function get_form_style( $form ) { |
|
463 | + /** |
|
464 | + * @param string|boolean $form |
|
465 | + * |
|
466 | + * @return string |
|
467 | + */ |
|
468 | + public static function get_form_style( $form ) { |
|
469 | 469 | $style = 1; |
470 | 470 | if ( empty( $form ) || 'default' == 'form' ) { |
471 | 471 | return $style; |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | $style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style; |
486 | 486 | |
487 | 487 | return $style; |
488 | - } |
|
488 | + } |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * Display the validation error messages when an entry is submitted |
@@ -539,74 +539,74 @@ discard block |
||
539 | 539 | } |
540 | 540 | |
541 | 541 | public static function get_scroll_js( $form_id ) { |
542 | - ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php |
|
543 | - } |
|
542 | + ?><script type="text/javascript">document.addEventListener('DOMContentLoaded',function(){frmFrontForm.scrollMsg(<?php echo (int) $form_id ?>);})</script><?php |
|
543 | + } |
|
544 | 544 | |
545 | 545 | public static function edit_form_link( $form_id ) { |
546 | - if ( is_object($form_id) ) { |
|
547 | - $form = $form_id; |
|
548 | - $name = $form->name; |
|
549 | - $form_id = $form->id; |
|
550 | - } else { |
|
551 | - $name = FrmForm::getName($form_id); |
|
552 | - } |
|
553 | - |
|
554 | - if ( $form_id ) { |
|
546 | + if ( is_object($form_id) ) { |
|
547 | + $form = $form_id; |
|
548 | + $name = $form->name; |
|
549 | + $form_id = $form->id; |
|
550 | + } else { |
|
551 | + $name = FrmForm::getName($form_id); |
|
552 | + } |
|
553 | + |
|
554 | + if ( $form_id ) { |
|
555 | 555 | $val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>'; |
556 | - } else { |
|
557 | - $val = ''; |
|
558 | - } |
|
556 | + } else { |
|
557 | + $val = ''; |
|
558 | + } |
|
559 | 559 | |
560 | - return $val; |
|
560 | + return $val; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | public static function delete_trash_link( $id, $status, $length = 'long' ) { |
564 | - $link = ''; |
|
565 | - $labels = array( |
|
566 | - 'restore' => array( |
|
567 | - 'long' => __( 'Restore from Trash', 'formidable' ), |
|
568 | - 'short' => __( 'Restore', 'formidable' ), |
|
569 | - ), |
|
570 | - 'trash' => array( |
|
571 | - 'long' => __( 'Move to Trash', 'formidable' ), |
|
572 | - 'short' => __( 'Trash', 'formidable' ), |
|
573 | - ), |
|
574 | - 'delete' => array( |
|
575 | - 'long' => __( 'Delete Permanently', 'formidable' ), |
|
576 | - 'short' => __( 'Delete', 'formidable' ), |
|
577 | - ), |
|
578 | - ); |
|
579 | - |
|
580 | - $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
564 | + $link = ''; |
|
565 | + $labels = array( |
|
566 | + 'restore' => array( |
|
567 | + 'long' => __( 'Restore from Trash', 'formidable' ), |
|
568 | + 'short' => __( 'Restore', 'formidable' ), |
|
569 | + ), |
|
570 | + 'trash' => array( |
|
571 | + 'long' => __( 'Move to Trash', 'formidable' ), |
|
572 | + 'short' => __( 'Trash', 'formidable' ), |
|
573 | + ), |
|
574 | + 'delete' => array( |
|
575 | + 'long' => __( 'Delete Permanently', 'formidable' ), |
|
576 | + 'short' => __( 'Delete', 'formidable' ), |
|
577 | + ), |
|
578 | + ); |
|
579 | + |
|
580 | + $current_page = isset( $_REQUEST['form_type'] ) ? $_REQUEST['form_type'] : ''; |
|
581 | 581 | $base_url = '?page=formidable&form_type=' . $current_page . '&id=' . $id; |
582 | - if ( 'trash' == $status ) { |
|
582 | + if ( 'trash' == $status ) { |
|
583 | 583 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=untrash', 'untrash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['restore'][ $length ] . '</a>'; |
584 | - } else if ( current_user_can('frm_delete_forms') ) { |
|
585 | - if ( EMPTY_TRASH_DAYS ) { |
|
584 | + } else if ( current_user_can('frm_delete_forms') ) { |
|
585 | + if ( EMPTY_TRASH_DAYS ) { |
|
586 | 586 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=trash', 'trash_form_' . $id ) ) . '" class="submitdelete deletion">' . $labels['trash'][ $length ] . '</a>'; |
587 | - } else { |
|
587 | + } else { |
|
588 | 588 | $link = '<a href="' . esc_url( wp_nonce_url( $base_url . '&frm_action=destroy', 'destroy_form_' . $id ) ) . '" class="submitdelete deletion" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete this form and all its entries?', 'formidable' ) ) . '\')">' . $labels['delete'][ $length ] . '</a>'; |
589 | - } |
|
590 | - } |
|
589 | + } |
|
590 | + } |
|
591 | 591 | |
592 | - return $link; |
|
593 | - } |
|
592 | + return $link; |
|
593 | + } |
|
594 | 594 | |
595 | 595 | public static function status_nice_name( $status ) { |
596 | - $nice_names = array( |
|
597 | - 'draft' => __( 'Draft', 'formidable' ), |
|
598 | - 'trash' => __( 'Trash', 'formidable' ), |
|
599 | - 'publish' => __( 'Published', 'formidable' ), |
|
600 | - ); |
|
601 | - |
|
602 | - if ( ! in_array($status, array_keys($nice_names)) ) { |
|
603 | - $status = 'publish'; |
|
604 | - } |
|
596 | + $nice_names = array( |
|
597 | + 'draft' => __( 'Draft', 'formidable' ), |
|
598 | + 'trash' => __( 'Trash', 'formidable' ), |
|
599 | + 'publish' => __( 'Published', 'formidable' ), |
|
600 | + ); |
|
601 | + |
|
602 | + if ( ! in_array($status, array_keys($nice_names)) ) { |
|
603 | + $status = 'publish'; |
|
604 | + } |
|
605 | 605 | |
606 | 606 | $name = $nice_names[ $status ]; |
607 | 607 | |
608 | - return $name; |
|
609 | - } |
|
608 | + return $name; |
|
609 | + } |
|
610 | 610 | |
611 | 611 | public static function get_params() { |
612 | 612 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmForm::list_page_params' ); |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | protected $modes = array(); |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @var array |
|
72 | - */ |
|
73 | - protected $params; |
|
70 | + * |
|
71 | + * @var array |
|
72 | + */ |
|
73 | + protected $params; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * Stores the value returned by ->get_column_info() |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | 'single_row_columns' ); |
88 | 88 | |
89 | 89 | /** |
90 | - * Construct the table object |
|
91 | - */ |
|
90 | + * Construct the table object |
|
91 | + */ |
|
92 | 92 | public function __construct( $args ) { |
93 | - $args = wp_parse_args( $args, array( |
|
93 | + $args = wp_parse_args( $args, array( |
|
94 | 94 | 'params' => array(), |
95 | 95 | 'plural' => '', |
96 | 96 | 'singular' => '', |
@@ -253,6 +253,9 @@ discard block |
||
253 | 253 | <?php |
254 | 254 | } |
255 | 255 | |
256 | + /** |
|
257 | + * @param string $param_name |
|
258 | + */ |
|
256 | 259 | private function hidden_search_inputs( $param_name ) { |
257 | 260 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
258 | 261 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
@@ -389,6 +392,9 @@ discard block |
||
389 | 392 | return $action; |
390 | 393 | } |
391 | 394 | |
395 | + /** |
|
396 | + * @param string $action_name |
|
397 | + */ |
|
392 | 398 | private static function get_bulk_action( $action_name ) { |
393 | 399 | $action = false; |
394 | 400 | if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
@@ -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 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | return $this->get_pagenum(); |
198 | 198 | } |
199 | 199 | |
200 | - if ( isset( $this->_pagination_args[ $key ] ) ) { |
|
201 | - return $this->_pagination_args[ $key ]; |
|
200 | + if ( isset( $this->_pagination_args[$key] ) ) { |
|
201 | + return $this->_pagination_args[$key]; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | } |
254 | 254 | |
255 | 255 | private function hidden_search_inputs( $param_name ) { |
256 | - if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
|
257 | - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />'; |
|
256 | + if ( ! empty( $_REQUEST[$param_name] ) ) { |
|
257 | + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />'; |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | echo "<ul class='subsubsub'>\n"; |
299 | 299 | foreach ( $views as $class => $view ) { |
300 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
300 | + $views[$class] = "\t<li class='$class'>$view"; |
|
301 | 301 | } |
302 | 302 | echo implode( " |</li>\n", $views ) . "</li>\n"; |
303 | 303 | echo '</ul>'; |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | |
391 | 391 | private static function get_bulk_action( $action_name ) { |
392 | 392 | $action = false; |
393 | - if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) { |
|
394 | - $action = sanitize_text_field( $_REQUEST[ $action_name ] ); |
|
393 | + if ( isset( $_REQUEST[$action_name] ) && -1 != sanitize_text_field( $_REQUEST[$action_name] ) ) { |
|
394 | + $action = sanitize_text_field( $_REQUEST[$action_name] ); |
|
395 | 395 | } |
396 | 396 | return $action; |
397 | 397 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | |
417 | 417 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
418 | 418 | foreach ( $actions as $action => $link ) { |
419 | - ++$i; |
|
419 | + ++ $i; |
|
420 | 420 | ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
421 | 421 | $out .= "<span class='$action'>$link$sep</span>"; |
422 | 422 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | |
685 | 685 | // If the primary column doesn't exist fall back to the |
686 | 686 | // first non-checkbox column. |
687 | - if ( ! isset( $columns[ $default ] ) ) { |
|
687 | + if ( ! isset( $columns[$default] ) ) { |
|
688 | 688 | $default = FrmListHelper::get_default_primary_column_name(); |
689 | 689 | } |
690 | 690 | |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
700 | 700 | |
701 | - if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
|
701 | + if ( empty( $column ) || ! isset( $columns[$column] ) ) { |
|
702 | 702 | $column = $default; |
703 | 703 | } |
704 | 704 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | // In 4.3, we added a fourth argument for primary column. |
721 | 721 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
722 | 722 | foreach ( $this->_column_headers as $key => $value ) { |
723 | - $column_headers[ $key ] = $value; |
|
723 | + $column_headers[$key] = $value; |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | return $column_headers; |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | $data[1] = false; |
754 | 754 | } |
755 | 755 | |
756 | - $sortable[ $id ] = $data; |
|
756 | + $sortable[$id] = $data; |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | $primary = $this->get_primary_column_name(); |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | static $cb_counter = 1; |
809 | 809 | $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
810 | 810 | . '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; |
811 | - $cb_counter++; |
|
811 | + $cb_counter ++; |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | foreach ( $columns as $column_key => $column_display_name ) { |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | $class[] = 'column-primary'; |
829 | 829 | } |
830 | 830 | |
831 | - if ( isset( $sortable[ $column_key ] ) ) { |
|
832 | - list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
|
831 | + if ( isset( $sortable[$column_key] ) ) { |
|
832 | + list( $orderby, $desc_first ) = $sortable[$column_key]; |
|
833 | 833 | |
834 | 834 | if ( $current_orderby == $orderby ) { |
835 | 835 | $order = 'asc' == $current_order ? 'desc' : 'asc'; |
@@ -69,7 +69,7 @@ |
||
69 | 69 | * @uses api_request() |
70 | 70 | * |
71 | 71 | * @param array $_transient_data Update array build by WordPress. |
72 | - * @return array Modified update array with custom plugin data. |
|
72 | + * @return stdClass Modified update array with custom plugin data. |
|
73 | 73 | */ |
74 | 74 | public function check_update( $_transient_data ) { |
75 | 75 |
@@ -15,23 +15,23 @@ discard block |
||
15 | 15 | * @version 1.6.3 |
16 | 16 | */ |
17 | 17 | class FrmEDD_SL_Plugin_Updater { |
18 | - private $api_url = ''; |
|
19 | - private $api_data = array(); |
|
20 | - private $name = ''; |
|
21 | - private $slug = ''; |
|
22 | - private $version = ''; |
|
23 | - |
|
24 | - /** |
|
25 | - * Class constructor. |
|
26 | - * |
|
27 | - * @uses plugin_basename() |
|
28 | - * @uses hook() |
|
29 | - * |
|
30 | - * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | - * @param string $_plugin_file Path to the plugin file. |
|
32 | - * @param array $_api_data Optional data to send with API calls. |
|
33 | - */ |
|
34 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
18 | + private $api_url = ''; |
|
19 | + private $api_data = array(); |
|
20 | + private $name = ''; |
|
21 | + private $slug = ''; |
|
22 | + private $version = ''; |
|
23 | + |
|
24 | + /** |
|
25 | + * Class constructor. |
|
26 | + * |
|
27 | + * @uses plugin_basename() |
|
28 | + * @uses hook() |
|
29 | + * |
|
30 | + * @param string $_api_url The URL pointing to the custom API endpoint. |
|
31 | + * @param string $_plugin_file Path to the plugin file. |
|
32 | + * @param array $_api_data Optional data to send with API calls. |
|
33 | + */ |
|
34 | + public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
35 | 35 | global $frm_edd_plugin_data; |
36 | 36 | |
37 | 37 | $this->api_url = trailingslashit( $_api_url ); |
@@ -44,159 +44,159 @@ discard block |
||
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Set up WordPress filters to hook into WP's update process. |
|
51 | - * |
|
52 | - * @uses add_filter() |
|
53 | - * |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function init() { |
|
57 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Set up WordPress filters to hook into WP's update process. |
|
51 | + * |
|
52 | + * @uses add_filter() |
|
53 | + * |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function init() { |
|
57 | + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
58 | + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
59 | 59 | add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | - * |
|
65 | - * This function dives into the update API just when WordPress creates its update array, |
|
66 | - * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | - * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | - * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | - * |
|
70 | - * @uses api_request() |
|
71 | - * |
|
72 | - * @param array $_transient_data Update array build by WordPress. |
|
73 | - * @return array Modified update array with custom plugin data. |
|
74 | - */ |
|
75 | - public function check_update( $_transient_data ) { |
|
76 | - |
|
77 | - global $pagenow; |
|
78 | - |
|
79 | - if ( ! is_object( $_transient_data ) ) { |
|
80 | - $_transient_data = new stdClass; |
|
81 | - } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Check for Updates at the defined API endpoint and modify the update array. |
|
64 | + * |
|
65 | + * This function dives into the update API just when WordPress creates its update array, |
|
66 | + * then adds a custom API call and injects the custom plugin data retrieved from the API. |
|
67 | + * It is reassembled from parts of the native WordPress plugin update code. |
|
68 | + * See wp-includes/update.php line 121 for the original wp_update_plugins() function. |
|
69 | + * |
|
70 | + * @uses api_request() |
|
71 | + * |
|
72 | + * @param array $_transient_data Update array build by WordPress. |
|
73 | + * @return array Modified update array with custom plugin data. |
|
74 | + */ |
|
75 | + public function check_update( $_transient_data ) { |
|
76 | + |
|
77 | + global $pagenow; |
|
78 | + |
|
79 | + if ( ! is_object( $_transient_data ) ) { |
|
80 | + $_transient_data = new stdClass; |
|
81 | + } |
|
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
84 | 84 | |
85 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
85 | + $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
86 | 86 | |
87 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
87 | + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
88 | 88 | |
89 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
89 | + if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
90 | 90 | |
91 | 91 | if ( empty( $version_info->plugin ) ) { |
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
96 | - |
|
97 | - } |
|
98 | - |
|
99 | - $_transient_data->last_checked = time(); |
|
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
101 | - |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - return $_transient_data; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Updates information on the "View version x.x details" page with custom data. |
|
110 | - * |
|
111 | - * @uses api_request() |
|
112 | - * |
|
113 | - * @param mixed $_data |
|
114 | - * @param string $_action |
|
115 | - * @param object $_args |
|
116 | - * @return object $_data |
|
117 | - */ |
|
118 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
119 | - |
|
120 | - if ( $_action != 'plugin_information' ) { |
|
95 | + $_transient_data->response[ $this->name ] = $version_info; |
|
121 | 96 | |
122 | - return $_data; |
|
97 | + } |
|
123 | 98 | |
124 | - } |
|
99 | + $_transient_data->last_checked = time(); |
|
100 | + $_transient_data->checked[ $this->name ] = $this->version; |
|
125 | 101 | |
126 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
102 | + } |
|
103 | + } |
|
127 | 104 | |
128 | - return $_data; |
|
105 | + return $_transient_data; |
|
106 | + } |
|
129 | 107 | |
130 | - } |
|
108 | + /** |
|
109 | + * Updates information on the "View version x.x details" page with custom data. |
|
110 | + * |
|
111 | + * @uses api_request() |
|
112 | + * |
|
113 | + * @param mixed $_data |
|
114 | + * @param string $_action |
|
115 | + * @param object $_args |
|
116 | + * @return object $_data |
|
117 | + */ |
|
118 | + public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
131 | 119 | |
132 | - $to_send = array( |
|
133 | - 'slug' => $this->slug, |
|
134 | - 'is_ssl' => is_ssl(), |
|
135 | - 'fields' => array( |
|
136 | - 'banners' => false, // These will be supported soon hopefully |
|
137 | - 'reviews' => false, |
|
138 | - ), |
|
139 | - ); |
|
120 | + if ( $_action != 'plugin_information' ) { |
|
140 | 121 | |
141 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
122 | + return $_data; |
|
142 | 123 | |
143 | - if ( false !== $api_response ) { |
|
144 | - $_data = $api_response; |
|
145 | - } |
|
124 | + } |
|
146 | 125 | |
147 | - return $_data; |
|
148 | - } |
|
126 | + if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
149 | 127 | |
128 | + return $_data; |
|
150 | 129 | |
151 | - /** |
|
152 | - * Disable SSL verification in order to prevent download update failures |
|
153 | - * |
|
154 | - * @param array $args |
|
155 | - * @param string $url |
|
156 | - * @return object $array |
|
157 | - */ |
|
158 | - public function http_request_args( $args, $url ) { |
|
159 | - // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | - $args['sslverify'] = false; |
|
162 | - } |
|
163 | - return $args; |
|
164 | - } |
|
130 | + } |
|
165 | 131 | |
166 | - /** |
|
167 | - * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | - * |
|
169 | - * @uses get_bloginfo() |
|
170 | - * @uses wp_remote_post() |
|
171 | - * @uses is_wp_error() |
|
172 | - * |
|
173 | - * @param string $_action The requested action. |
|
174 | - * @param array $_data Parameters for the API action. |
|
175 | - * @return false|object |
|
176 | - */ |
|
177 | - private function api_request( $_action, $_data ) { |
|
132 | + $to_send = array( |
|
133 | + 'slug' => $this->slug, |
|
134 | + 'is_ssl' => is_ssl(), |
|
135 | + 'fields' => array( |
|
136 | + 'banners' => false, // These will be supported soon hopefully |
|
137 | + 'reviews' => false, |
|
138 | + ), |
|
139 | + ); |
|
178 | 140 | |
179 | - global $wp_version; |
|
141 | + $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
180 | 142 | |
181 | - $data = array_merge( $this->api_data, $_data ); |
|
143 | + if ( false !== $api_response ) { |
|
144 | + $_data = $api_response; |
|
145 | + } |
|
182 | 146 | |
183 | - if ( $data['slug'] != $this->slug ) { |
|
184 | - return; |
|
147 | + return $_data; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * Disable SSL verification in order to prevent download update failures |
|
153 | + * |
|
154 | + * @param array $args |
|
155 | + * @param string $url |
|
156 | + * @return object $array |
|
157 | + */ |
|
158 | + public function http_request_args( $args, $url ) { |
|
159 | + // If it is an https request and we are performing a package download, disable ssl verification |
|
160 | + if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
161 | + $args['sslverify'] = false; |
|
162 | + } |
|
163 | + return $args; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Calls the API and, if successfull, returns the object delivered by the API. |
|
168 | + * |
|
169 | + * @uses get_bloginfo() |
|
170 | + * @uses wp_remote_post() |
|
171 | + * @uses is_wp_error() |
|
172 | + * |
|
173 | + * @param string $_action The requested action. |
|
174 | + * @param array $_data Parameters for the API action. |
|
175 | + * @return false|object |
|
176 | + */ |
|
177 | + private function api_request( $_action, $_data ) { |
|
178 | + |
|
179 | + global $wp_version; |
|
180 | + |
|
181 | + $data = array_merge( $this->api_data, $_data ); |
|
182 | + |
|
183 | + if ( $data['slug'] != $this->slug ) { |
|
184 | + return; |
|
185 | 185 | } |
186 | 186 | |
187 | - if ( $this->api_url == home_url() ) { |
|
188 | - return false; // Don't allow a plugin to ping itself |
|
189 | - } |
|
187 | + if ( $this->api_url == home_url() ) { |
|
188 | + return false; // Don't allow a plugin to ping itself |
|
189 | + } |
|
190 | 190 | |
191 | - $api_params = array( |
|
192 | - 'edd_action' => 'get_version', |
|
193 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | - 'slug' => $data['slug'], |
|
197 | - 'author' => $data['author'], |
|
198 | - 'url' => home_url(), |
|
199 | - ); |
|
191 | + $api_params = array( |
|
192 | + 'edd_action' => 'get_version', |
|
193 | + 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
194 | + 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
195 | + 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
196 | + 'slug' => $data['slug'], |
|
197 | + 'author' => $data['author'], |
|
198 | + 'url' => home_url(), |
|
199 | + ); |
|
200 | 200 | |
201 | 201 | $cache_key = 'edd_plugin_' . md5( sanitize_key( $api_params['license'] . $this->version ) . '_' . $api_params['edd_action'] ); |
202 | 202 | $cached_response = get_transient( $cache_key ); |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | return $cached_response; |
206 | 206 | } |
207 | 207 | |
208 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
208 | + $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
209 | 209 | |
210 | - if ( ! is_wp_error( $request ) ) { |
|
211 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | - } |
|
210 | + if ( ! is_wp_error( $request ) ) { |
|
211 | + $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
212 | + } |
|
213 | 213 | |
214 | - if ( $request && isset( $request->sections ) ) { |
|
215 | - $request->sections = maybe_unserialize( $request->sections ); |
|
214 | + if ( $request && isset( $request->sections ) ) { |
|
215 | + $request->sections = maybe_unserialize( $request->sections ); |
|
216 | 216 | set_transient( $cache_key, $request, DAY_IN_SECONDS ); |
217 | - } else { |
|
218 | - $request = false; |
|
217 | + } else { |
|
218 | + $request = false; |
|
219 | 219 | set_transient( $cache_key, 0, DAY_IN_SECONDS ); |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - return $request; |
|
223 | - } |
|
222 | + return $request; |
|
223 | + } |
|
224 | 224 | |
225 | - public function show_changelog() { |
|
225 | + public function show_changelog() { |
|
226 | 226 | |
227 | 227 | global $frm_edd_plugin_data; |
228 | 228 | |
@@ -278,5 +278,5 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | exit; |
281 | - } |
|
281 | + } |
|
282 | 282 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $this->slug = basename( $_plugin_file, '.php' ); |
41 | 41 | $this->version = $_api_data['version']; |
42 | 42 | |
43 | - $frm_edd_plugin_data[ $this->slug ] = $this->api_data; |
|
43 | + $frm_edd_plugin_data[$this->slug] = $this->api_data; |
|
44 | 44 | |
45 | 45 | // Set up hooks. |
46 | 46 | $this->init(); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $_transient_data = new stdClass; |
81 | 81 | } |
82 | 82 | |
83 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
83 | + if ( empty( $_transient_data->response ) || empty( $_transient_data->response[$this->name] ) ) { |
|
84 | 84 | |
85 | 85 | $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
86 | 86 | |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | $version_info->plugin = $this->name; |
93 | 93 | } |
94 | 94 | |
95 | - $_transient_data->response[ $this->name ] = $version_info; |
|
95 | + $_transient_data->response[$this->name] = $version_info; |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | 99 | $_transient_data->last_checked = time(); |
100 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
100 | + $_transient_data->checked[$this->name] = $this->version; |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) ); |
243 | 243 | } |
244 | 244 | |
245 | - $data = $frm_edd_plugin_data[ $_REQUEST['slug'] ]; |
|
245 | + $data = $frm_edd_plugin_data[$_REQUEST['slug']]; |
|
246 | 246 | $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' ); |
247 | 247 | $version_info = get_transient( $cache_key ); |
248 | 248 |