@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $return = $input_type; |
47 | 47 | |
48 | - if( 'survey' === $field_type ) { |
|
48 | + if ( 'survey' === $field_type ) { |
|
49 | 49 | $return = 'select'; |
50 | 50 | } |
51 | 51 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | public function fix_survey_fields( $fields ) { |
66 | 66 | |
67 | 67 | /** @var GF_Field $field */ |
68 | - foreach( $fields as &$field ) { |
|
69 | - if( 'survey' === $field->type ) { |
|
68 | + foreach ( $fields as &$field ) { |
|
69 | + if ( 'survey' === $field->type ) { |
|
70 | 70 | $field->allowsPrepopulate = true; |
71 | 71 | } |
72 | 72 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | function add_render_hooks() { |
85 | - add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10, 3 ); |
|
85 | + add_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10, 3 ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | function remove_render_hooks() { |
98 | - remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value'), 10 ); |
|
98 | + remove_filter( 'gform_field_value', array( $this, 'fix_survey_field_value' ), 10 ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function fix_survey_field_value( $value, $field, $name ) { |
115 | 115 | |
116 | - if( 'survey' === $field->type ) { |
|
116 | + if ( 'survey' === $field->type ) { |
|
117 | 117 | |
118 | - $entry = GravityView_Edit_Entry::getInstance()->instances['render']->get_entry(); |
|
118 | + $entry = GravityView_Edit_Entry::getInstance()->instances[ 'render' ]->get_entry(); |
|
119 | 119 | |
120 | 120 | // We need to run through each survey row until we find a match for expected values |
121 | 121 | foreach ( $entry as $field_id => $field_value ) { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | - if( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
127 | + if ( rgar( $field, 'gsurveyLikertEnableMultipleRows' ) ) { |
|
128 | 128 | list( $row_val, $col_val ) = explode( ':', $field_value, 2 ); |
129 | 129 | |
130 | 130 | // If the $name matches the $row_val, we are processing the correct row |
131 | - if( $row_val === $name ) { |
|
131 | + if ( $row_val === $name ) { |
|
132 | 132 | $value = $field_value; |
133 | 133 | break; |
134 | 134 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | function __construct( $title = '', $item_id, $item = array(), $settings = array() ) { |
43 | 43 | |
44 | 44 | // Backward compat |
45 | - if ( ! empty( $item['type'] ) ) { |
|
46 | - $item['input_type'] = $item['type']; |
|
47 | - unset( $item['type'] ); |
|
45 | + if ( ! empty( $item[ 'type' ] ) ) { |
|
46 | + $item[ 'input_type' ] = $item[ 'type' ]; |
|
47 | + unset( $item[ 'type' ] ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // Prevent items from not having index set |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $this->item = $item; |
65 | 65 | $this->id = $item_id; |
66 | 66 | $this->settings = $settings; |
67 | - $this->label_type = $item['label_type']; |
|
67 | + $this->label_type = $item[ 'label_type' ]; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | if ( $html ) { |
108 | 108 | |
109 | 109 | foreach ( $field_info_items as $item ) { |
110 | - $class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description'; |
|
110 | + $class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description'; |
|
111 | 111 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
112 | 112 | $output .= '<span class="' . $class . '">'; |
113 | - $output .= esc_html( $item['value'] ); |
|
113 | + $output .= esc_html( $item[ 'value' ] ); |
|
114 | 114 | $output .= '</span>'; |
115 | 115 | } |
116 | 116 | |
@@ -138,29 +138,29 @@ discard block |
||
138 | 138 | |
139 | 139 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
140 | 140 | // TODO: Un-hack this |
141 | - $hide_settings_link = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
141 | + $hide_settings_link = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
142 | 142 | $settings_link = sprintf( '<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr( $settings_title ) ); |
143 | 143 | |
144 | 144 | // Should we show the icon that the field is being used as a link to single entry? |
145 | - $hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : ''; |
|
145 | + $hide_show_as_link_class = empty( $this->settings[ 'show_as_link' ] ) ? 'hide-if-js' : ''; |
|
146 | 146 | $show_as_link = '<span class="dashicons dashicons-admin-links ' . $hide_show_as_link_class . '" title="' . esc_attr( $single_link_title ) . '"></span>'; |
147 | 147 | |
148 | 148 | // When a field label is empty, use the Field ID |
149 | 149 | $label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title; |
150 | 150 | |
151 | 151 | // If there's a custom label, and show label is checked, use that as the field heading |
152 | - if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) { |
|
153 | - $label = $this->settings['custom_label']; |
|
154 | - } else if ( ! empty( $this->item['customLabel'] ) ) { |
|
155 | - $label = $this->item['customLabel']; |
|
152 | + if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) { |
|
153 | + $label = $this->settings[ 'custom_label' ]; |
|
154 | + } else if ( ! empty( $this->item[ 'customLabel' ] ) ) { |
|
155 | + $label = $this->item[ 'customLabel' ]; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $output = '<h5 class="selectable gfield field-id-' . esc_attr( $this->id ) . '">'; |
159 | 159 | |
160 | 160 | $label = esc_attr( $label ); |
161 | 161 | |
162 | - if ( ! empty( $this->item['parent'] ) ) { |
|
163 | - $label .= ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>'; |
|
162 | + if ( ! empty( $this->item[ 'parent' ] ) ) { |
|
163 | + $label .= ' <small>(' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . ')</small>'; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | // Name of field / widget |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | |
177 | 177 | $output .= '</h5>'; |
178 | 178 | |
179 | - $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
179 | + $container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : ''; |
|
180 | 180 | |
181 | - $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>'; |
|
181 | + $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>'; |
|
182 | 182 | |
183 | 183 | return $output; |
184 | 184 | } |
@@ -11,35 +11,35 @@ discard block |
||
11 | 11 | |
12 | 12 | function __construct() { |
13 | 13 | |
14 | - $this->widget_description = __('Links to multiple pages of results.', 'gravityview' ); |
|
14 | + $this->widget_description = __( 'Links to multiple pages of results.', 'gravityview' ); |
|
15 | 15 | |
16 | 16 | $default_values = array( 'header' => 1, 'footer' => 1 ); |
17 | 17 | $settings = array( 'show_all' => array( |
18 | 18 | 'type' => 'checkbox', |
19 | 19 | 'label' => __( 'Show each page number', 'gravityview' ), |
20 | - 'desc' => __('Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview'), |
|
20 | + 'desc' => __( 'Show every page number instead of summary (eg: 1 2 3 ... 8 »)', 'gravityview' ), |
|
21 | 21 | 'value' => false |
22 | - )); |
|
23 | - parent::__construct( __( 'Page Links', 'gravityview' ) , 'page_links', $default_values, $settings ); |
|
22 | + ) ); |
|
23 | + parent::__construct( __( 'Page Links', 'gravityview' ), 'page_links', $default_values, $settings ); |
|
24 | 24 | |
25 | 25 | } |
26 | 26 | |
27 | - public function render_frontend( $widget_args, $content = '', $context = '') { |
|
27 | + public function render_frontend( $widget_args, $content = '', $context = '' ) { |
|
28 | 28 | $gravityview_view = GravityView_View::getInstance(); |
29 | 29 | |
30 | - if( !$this->pre_render_frontend() ) { |
|
30 | + if ( ! $this->pre_render_frontend() ) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | $atts = shortcode_atts( array( |
35 | 35 | 'page_size' => rgar( $gravityview_view->paging, 'page_size' ), |
36 | 36 | 'total' => $gravityview_view->total_entries, |
37 | - 'show_all' => !empty( $this->settings['show_all']['default'] ), |
|
38 | - 'current' => (int) rgar( $_GET, 'pagenum', 1 ), |
|
37 | + 'show_all' => ! empty( $this->settings[ 'show_all' ][ 'default' ] ), |
|
38 | + 'current' => (int)rgar( $_GET, 'pagenum', 1 ), |
|
39 | 39 | ), $widget_args, 'gravityview_widget_page_links' ); |
40 | 40 | |
41 | 41 | $page_link_args = array( |
42 | - 'base' => add_query_arg('pagenum','%#%', gv_directory_link() ), |
|
42 | + 'base' => add_query_arg( 'pagenum', '%#%', gv_directory_link() ), |
|
43 | 43 | 'format' => '&pagenum=%#%', |
44 | 44 | 'add_args' => array(), // |
45 | 45 | 'prev_text' => '«', |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | 'type' => 'list', |
48 | 48 | 'end_size' => 1, |
49 | 49 | 'mid_size' => 2, |
50 | - 'total' => empty( $atts['page_size'] ) ? 0 : ceil( $atts['total'] / $atts['page_size'] ), |
|
51 | - 'current' => $atts['current'], |
|
52 | - 'show_all' => !empty( $atts['show_all'] ), // to be available at backoffice |
|
50 | + 'total' => empty( $atts[ 'page_size' ] ) ? 0 : ceil( $atts[ 'total' ] / $atts[ 'page_size' ] ), |
|
51 | + 'current' => $atts[ 'current' ], |
|
52 | + 'show_all' => ! empty( $atts[ 'show_all' ] ), // to be available at backoffice |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * @since 1.1.4 |
58 | 58 | * @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/) |
59 | 59 | */ |
60 | - $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args ); |
|
60 | + $page_link_args = apply_filters( 'gravityview_page_links_args', $page_link_args ); |
|
61 | 61 | |
62 | 62 | $page_links = paginate_links( $page_link_args ); |
63 | 63 | |
64 | - if( !empty( $page_links )) { |
|
65 | - $class = !empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
64 | + if ( ! empty( $page_links ) ) { |
|
65 | + $class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
66 | 66 | $class = gravityview_sanitize_html_class( $class ); |
67 | - echo '<div class="gv-widget-page-links '.$class.'">'. $page_links .'</div>'; |
|
67 | + echo '<div class="gv-widget-page-links ' . $class . '">' . $page_links . '</div>'; |
|
68 | 68 | } else { |
69 | 69 | do_action( 'gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.' ); |
70 | 70 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | wp_nonce_field( 'gravityview_select_form', 'gravityview_select_form_nonce' ); |
12 | 12 | |
13 | 13 | //current value |
14 | -$current_form = (int) rgar( (array) $_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
14 | +$current_form = (int)rgar( (array)$_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
15 | 15 | |
16 | 16 | // check for available gravity forms |
17 | 17 | $forms = gravityview_get_forms(); |
@@ -26,24 +26,24 @@ discard block |
||
26 | 26 | ?> |
27 | 27 | <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Start Fresh', 'gravityview' ); ?>"><?php esc_html_e( 'Start Fresh', 'gravityview' ); ?></a> |
28 | 28 | |
29 | - <?php if( !empty( $forms ) ) { ?> |
|
29 | + <?php if ( ! empty( $forms ) ) { ?> |
|
30 | 30 | <span> <?php esc_html_e( 'or use an existing form', 'gravityview' ); ?> </span> |
31 | 31 | <?php } |
32 | 32 | } |
33 | 33 | |
34 | 34 | // If there are no forms to select, show no forms. |
35 | - if( !empty( $forms ) ) { ?> |
|
35 | + if ( ! empty( $forms ) ) { ?> |
|
36 | 36 | <select name="gravityview_form_id" id="gravityview_form_id"> |
37 | 37 | <option value="" <?php selected( '', $current_form, true ); ?>>— <?php esc_html_e( 'list of forms', 'gravityview' ); ?> —</option> |
38 | - <?php foreach( $forms as $form ) { ?> |
|
39 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
38 | + <?php foreach ( $forms as $form ) { ?> |
|
39 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
40 | 40 | <?php } ?> |
41 | 41 | </select> |
42 | 42 | <?php } else { ?> |
43 | 43 | <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select> |
44 | 44 | <?php } ?> |
45 | 45 | |
46 | - <a class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
46 | + <a class="button button-primary" <?php if ( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
47 | 47 | </p> |
48 | 48 | |
49 | 49 | <?php // confirm dialog box ?> |
@@ -47,7 +47,7 @@ |
||
47 | 47 | function edit_entry_fix_hidden_fields( $fields ) { |
48 | 48 | |
49 | 49 | /** @var GF_Field $field */ |
50 | - foreach( $fields as &$field ) { |
|
50 | + foreach ( $fields as &$field ) { |
|
51 | 51 | if ( 'hidden' === $field->type ) { |
52 | 52 | |
53 | 53 | // Replace GF_Field_Hidden with GF_Field_Text, copying all the data from $field |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if ( empty( $assign_to_lead ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_lead_property( $entry[ 'id' ], 'created_by', $user_id, false, true ); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
66 | + if ( empty( $result ) ) { |
|
67 | + $status = __( 'Error', 'gravityview' ); |
|
68 | 68 | } else { |
69 | - $status = __('Success', 'gravityview'); |
|
69 | + $status = __( 'Success', 'gravityview' ); |
|
70 | 70 | } |
71 | 71 | |
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - ' . $note ); |
|
75 | 75 | |
76 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
76 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | |
86 | 86 | // Plugin that was provided here: |
87 | 87 | // @link https://gravityview.co/support/documentation/201991205/ |
88 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
89 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
88 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
89 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
90 | 90 | |
91 | 91 | // Disable for Gravity Forms Add-ons 3.6.2 and lower |
92 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
92 | + if ( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
93 | 93 | |
94 | 94 | $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
95 | 95 | |
96 | 96 | // Now, no validation is required in the methods; let's hook in. |
97 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
97 | + remove_action( 'admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
98 | 98 | |
99 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
99 | + remove_action( "gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10 ); |
|
100 | 100 | |
101 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
101 | + remove_action( "gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | function load() { |
111 | 111 | |
112 | 112 | // Does GF exist? |
113 | - if( !class_exists('GFCommon') ) { |
|
113 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Can the user edit entries? |
118 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
118 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // If screen mode isn't set, then we're in the wrong place. |
123 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
123 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Now, no validation is required in the methods; let's hook in. |
128 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
128 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
129 | 129 | |
130 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
130 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
131 | 131 | |
132 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
132 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | function set_screen_mode() { |
141 | 141 | |
142 | 142 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
143 | - if( rgget('screen_mode') === 'edit' ) { |
|
144 | - $_POST["screen_mode"] = 'edit'; |
|
143 | + if ( rgget( 'screen_mode' ) === 'edit' ) { |
|
144 | + $_POST[ "screen_mode" ] = 'edit'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
@@ -152,42 +152,42 @@ discard block |
||
152 | 152 | * @param int $entry_id Entry ID |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - function update_entry_creator($form, $entry_id) { |
|
155 | + function update_entry_creator( $form, $entry_id ) { |
|
156 | 156 | global $current_user; |
157 | 157 | |
158 | 158 | // Update the entry |
159 | - $created_by = absint( rgpost('created_by') ); |
|
159 | + $created_by = absint( rgpost( 'created_by' ) ); |
|
160 | 160 | |
161 | 161 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
162 | 162 | |
163 | 163 | // If the creator has changed, let's add a note about who it used to be. |
164 | - $originally_created_by = rgpost('originally_created_by'); |
|
164 | + $originally_created_by = rgpost( 'originally_created_by' ); |
|
165 | 165 | |
166 | 166 | // If there's no owner and there didn't used to be, keep going |
167 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
167 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | 171 | // If the values have changed |
172 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
172 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
173 | 173 | |
174 | - $user_data = get_userdata($current_user->ID); |
|
174 | + $user_data = get_userdata( $current_user->ID ); |
|
175 | 175 | |
176 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
176 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
177 | 177 | |
178 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
178 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
179 | 179 | |
180 | - if( !empty( $originally_created_by ) ) { |
|
181 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
180 | + if ( ! empty( $originally_created_by ) ) { |
|
181 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
182 | 182 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
183 | 183 | } |
184 | 184 | |
185 | - if( !empty( $created_by ) ) { |
|
186 | - $created_by_user_data = get_userdata($created_by); |
|
185 | + if ( ! empty( $created_by ) ) { |
|
186 | + $created_by_user_data = get_userdata( $created_by ); |
|
187 | 187 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
188 | 188 | } |
189 | 189 | |
190 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
190 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | * @param array $entry GF entry array |
199 | 199 | * @return void |
200 | 200 | */ |
201 | - function add_select($form_id, $entry ) { |
|
201 | + function add_select( $form_id, $entry ) { |
|
202 | 202 | |
203 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
203 | + if ( rgpost( 'screen_mode' ) !== 'edit' ) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $users = GVCommon::get_users( 'change_entry_creator' ); |
208 | 208 | |
209 | 209 | $output = '<label for="change_created_by">'; |
210 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
210 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
211 | 211 | $output .= '</label> |
212 | 212 | <select name="created_by" id="change_created_by" class="widefat">'; |
213 | - $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | - foreach($users as $user) { |
|
215 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
213 | + $output .= '<option value=""> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
214 | + foreach ( $users as $user ) { |
|
215 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
216 | 216 | } |
217 | 217 | $output .= '</select>'; |
218 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
218 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
219 | 219 | echo $output; |
220 | 220 | |
221 | 221 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return GV_License_Handler |
41 | 41 | */ |
42 | 42 | public static function get_instance( GravityView_Settings $GFAddOn ) { |
43 | - if( empty( self::$instance ) ) { |
|
43 | + if ( empty( self::$instance ) ) { |
|
44 | 44 | self::$instance = new self( $GFAddOn ); |
45 | 45 | } |
46 | 46 | return self::$instance; |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | public function refresh_license_status() { |
71 | 71 | |
72 | 72 | // Only perform on GravityView pages |
73 | - if( ! gravityview_is_admin_page() ) { |
|
73 | + if ( ! gravityview_is_admin_page() ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // The transient is fresh; don't fetch. |
78 | - if( $status = get_transient( self::status_transient_key ) ) { |
|
78 | + if ( $status = get_transient( self::status_transient_key ) ) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
@@ -101,37 +101,37 @@ discard block |
||
101 | 101 | $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
102 | 102 | $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
103 | 103 | |
104 | - if( !empty( $key ) ) { |
|
104 | + if ( ! empty( $key ) ) { |
|
105 | 105 | $response = $this->Addon->get_app_setting( 'license_key_response' ); |
106 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
106 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
107 | 107 | } else { |
108 | 108 | $response = array(); |
109 | 109 | } |
110 | 110 | |
111 | 111 | wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
112 | 112 | 'license_box' => $this->get_license_message( $response ) |
113 | - )); |
|
113 | + ) ); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | $fields = array( |
117 | 117 | array( |
118 | 118 | 'name' => 'edd-activate', |
119 | - 'value' => __('Activate License', 'gravityview'), |
|
120 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
119 | + 'value' => __( 'Activate License', 'gravityview' ), |
|
120 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
121 | 121 | 'data-edd_action' => 'activate_license', |
122 | 122 | 'class' => 'button-primary', |
123 | 123 | ), |
124 | 124 | array( |
125 | 125 | 'name' => 'edd-deactivate', |
126 | - 'value' => __('Deactivate License', 'gravityview'), |
|
127 | - 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
|
126 | + 'value' => __( 'Deactivate License', 'gravityview' ), |
|
127 | + 'data-pending_text' => __( 'Deactivating license…', 'gravityview' ), |
|
128 | 128 | 'data-edd_action' => 'deactivate_license', |
129 | 129 | 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
130 | 130 | ), |
131 | 131 | array( |
132 | 132 | 'name' => 'edd-check', |
133 | - 'value' => __('Check License', 'gravityview'), |
|
134 | - 'data-pending_text' => __('Verifying license…', 'gravityview'), |
|
133 | + 'value' => __( 'Check License', 'gravityview' ), |
|
134 | + 'data-pending_text' => __( 'Verifying license…', 'gravityview' ), |
|
135 | 135 | 'title' => 'Check the license before saving it', |
136 | 136 | 'data-edd_action' => 'check_license', |
137 | 137 | 'class' => 'button-secondary', |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | |
142 | 142 | $class = 'button gv-edd-action'; |
143 | 143 | |
144 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
144 | + $class .= ( ! empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
145 | 145 | |
146 | 146 | $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
147 | 147 | |
148 | 148 | $submit = '<div class="gv-edd-button-wrapper">'; |
149 | 149 | foreach ( $fields as $field ) { |
150 | - $field['type'] = 'button'; |
|
151 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
152 | - $field['style'] = 'margin-left: 10px;'; |
|
153 | - if( $disabled_attribute ) { |
|
154 | - $field['disabled'] = $disabled_attribute; |
|
150 | + $field[ 'type' ] = 'button'; |
|
151 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
152 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
153 | + if ( $disabled_attribute ) { |
|
154 | + $field[ 'disabled' ] = $disabled_attribute; |
|
155 | 155 | } |
156 | 156 | $submit .= $this->Addon->settings_submit( $field, $echo ); |
157 | 157 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function setup_edd() { |
169 | 169 | |
170 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
171 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
170 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
171 | + require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php' ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // setup the updater |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | 'url' => home_url(), |
206 | 206 | ); |
207 | 207 | |
208 | - if( !empty( $action ) ) { |
|
209 | - $settings['edd_action'] = esc_attr( $action ); |
|
208 | + if ( ! empty( $action ) ) { |
|
209 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $settings = array_map( 'urlencode', $settings ); |
@@ -220,14 +220,14 @@ discard block |
||
220 | 220 | */ |
221 | 221 | private function _license_get_remote_response( $data, $license = '' ) { |
222 | 222 | |
223 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
223 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
224 | 224 | |
225 | 225 | $url = add_query_arg( $api_params, self::url ); |
226 | 226 | |
227 | 227 | $response = wp_remote_get( $url, array( |
228 | 228 | 'timeout' => 15, |
229 | 229 | 'sslverify' => false, |
230 | - )); |
|
230 | + ) ); |
|
231 | 231 | |
232 | 232 | if ( is_wp_error( $response ) ) { |
233 | 233 | return array(); |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function get_license_message( $license_data ) { |
262 | 262 | |
263 | - if( empty( $license_data ) ) { |
|
263 | + if ( empty( $license_data ) ) { |
|
264 | 264 | $message = ''; |
265 | 265 | } else { |
266 | 266 | |
267 | - if( ! empty( $license_data->error ) ) { |
|
267 | + if ( ! empty( $license_data->error ) ) { |
|
268 | 268 | $class = 'error'; |
269 | 269 | $string_key = $license_data->error; |
270 | 270 | } else { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $string_key = $license_data->license; |
273 | 273 | } |
274 | 274 | |
275 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
275 | + $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings( 'status' ), $this->strings( $string_key, $license_data ) ); |
|
276 | 276 | |
277 | 277 | $message = $this->generate_license_box( $message, $class ); |
278 | 278 | } |
@@ -309,18 +309,18 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function license_details( $response = array() ) { |
311 | 311 | |
312 | - $response = (array) $response; |
|
312 | + $response = (array)$response; |
|
313 | 313 | |
314 | 314 | $return = ''; |
315 | 315 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
316 | 316 | |
317 | - if( ! empty( $response['license_key'] ) ) { |
|
317 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
318 | 318 | |
319 | 319 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
320 | 320 | |
321 | 321 | if ( in_array( rgar( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
322 | - $return .= $this->strings( $response['license'], $response ); |
|
323 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
322 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
323 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
324 | 324 | |
325 | 325 | $response_keys = array( |
326 | 326 | 'license_name' => '', |
@@ -335,19 +335,19 @@ discard block |
||
335 | 335 | // Make sure all the keys are set |
336 | 336 | $response = wp_parse_args( $response, $response_keys ); |
337 | 337 | |
338 | - $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response['customer_email'] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
339 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
338 | + $login_link = sprintf( '<a href="%s" class="howto" rel="external">%s</a>', esc_url( sprintf( 'https://gravityview.co/wp-login.php?username=%s', $response[ 'customer_email' ] ) ), esc_html__( 'Access your GravityView account', 'gravityview' ) ); |
|
339 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
340 | 340 | $details = array( |
341 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
342 | - 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response['customer_name'], 'gravityview' ), esc_html__( $response['customer_email'], 'gravityview' ) ) . $login_link, |
|
343 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
344 | - 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
345 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
341 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
342 | + 'licensed_to' => sprintf( esc_html_x( 'Licensed to: %1$s (%2$s)', '1: Customer name; 2: Customer email', 'gravityview' ), esc_html__( $response[ 'customer_name' ], 'gravityview' ), esc_html__( $response[ 'customer_email' ], 'gravityview' ) ) . $login_link, |
|
343 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
344 | + 'expires' => sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
345 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
346 | 346 | ); |
347 | 347 | |
348 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
349 | - unset( $details['upgrade'] ); |
|
350 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
348 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
349 | + unset( $details[ 'upgrade' ] ); |
|
350 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | |
371 | 371 | $output = ''; |
372 | 372 | |
373 | - if( ! empty( $upgrades ) ) { |
|
373 | + if ( ! empty( $upgrades ) ) { |
|
374 | 374 | |
375 | 375 | $locale_parts = explode( '_', get_locale() ); |
376 | 376 | |
377 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
377 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
378 | 378 | |
379 | 379 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
380 | 380 | |
@@ -382,14 +382,14 @@ discard block |
||
382 | 382 | |
383 | 383 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
384 | 384 | |
385 | - $upgrade = (object) $upgrade; |
|
385 | + $upgrade = (object)$upgrade; |
|
386 | 386 | |
387 | 387 | $anchor_text = sprintf( esc_html_x( 'Upgrade to %1$s for %2$s', '1: GravityView upgrade name, 2: Cost of upgrade', 'gravityview' ), esc_attr( $upgrade->name ), esc_attr( $upgrade->price ) ); |
388 | 388 | |
389 | - if( $is_english && isset( $upgrade->description ) ) { |
|
389 | + if ( $is_english && isset( $upgrade->description ) ) { |
|
390 | 390 | $message = esc_html( $upgrade->description ); |
391 | 391 | } else { |
392 | - switch( $upgrade->price_id ) { |
|
392 | + switch ( $upgrade->price_id ) { |
|
393 | 393 | // Interstellar |
394 | 394 | case 1: |
395 | 395 | default: |
@@ -427,16 +427,16 @@ discard block |
||
427 | 427 | */ |
428 | 428 | public function license_call( $array = array() ) { |
429 | 429 | |
430 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
431 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
430 | + $is_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
431 | + $data = empty( $array ) ? $_POST[ 'data' ] : $array; |
|
432 | 432 | $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
433 | 433 | |
434 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
435 | - die( - 1 ); |
|
434 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
435 | + die( -1 ); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | // If the user isn't allowed to edit settings, show an error message |
439 | - if( ! $has_cap ) { |
|
439 | + if ( ! $has_cap ) { |
|
440 | 440 | $license_data = new stdClass(); |
441 | 441 | $license_data->error = 'capability'; |
442 | 442 | $license_data->message = $this->get_license_message( $license_data ); |
@@ -460,9 +460,9 @@ discard block |
||
460 | 460 | |
461 | 461 | $json = json_encode( $license_data ); |
462 | 462 | |
463 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
463 | + $update_license = ( ! isset( $data[ 'update' ] ) || ! empty( $data[ 'update' ] ) ); |
|
464 | 464 | |
465 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
465 | + $is_check_action_button = ( 'check_license' === $data[ 'edd_action' ] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
466 | 466 | |
467 | 467 | // Failed is the response from trying to de-activate a license and it didn't work. |
468 | 468 | // This likely happened because people entered in a different key and clicked "Deactivate", |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | // most likely a mistake. |
471 | 471 | if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
472 | 472 | |
473 | - if ( ! empty( $data['field_id'] ) ) { |
|
473 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
474 | 474 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
475 | 475 | } |
476 | 476 | |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | if ( $is_ajax ) { |
482 | 482 | exit( $json ); |
483 | 483 | } else { // Non-ajax call |
484 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
484 | + return ( rgget( 'format', $data ) === 'object' ) ? $license_data : $json; |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -495,9 +495,9 @@ discard block |
||
495 | 495 | // Update option with passed data license |
496 | 496 | $settings = $this->Addon->get_app_settings(); |
497 | 497 | |
498 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
499 | - $settings['license_key_status'] = $license_data->license; |
|
500 | - $settings['license_key_response'] = (array)$license_data; |
|
498 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
499 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
500 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
501 | 501 | |
502 | 502 | $this->Addon->update_app_settings( $settings ); |
503 | 503 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | */ |
511 | 511 | private function get_license_renewal_url( $license_data ) { |
512 | 512 | $license_data = is_array( $license_data ) ? (object)$license_data : $license_data; |
513 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
513 | + $renew_license_url = ( ! empty( $license_data ) && ! empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation&force_login=1', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
514 | 514 | return $renew_license_url; |
515 | 515 | } |
516 | 516 | |
@@ -525,31 +525,31 @@ discard block |
||
525 | 525 | |
526 | 526 | |
527 | 527 | $strings = array( |
528 | - 'status' => esc_html__('Status', 'gravityview'), |
|
529 | - 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
|
530 | - 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
|
531 | - 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
532 | - 'inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
|
533 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
534 | - 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
|
535 | - 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
|
536 | - 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
|
537 | - 'missing' => esc_html__('Invalid license key.', 'gravityview'), |
|
538 | - 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
|
539 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
528 | + 'status' => esc_html__( 'Status', 'gravityview' ), |
|
529 | + 'error' => esc_html__( 'There was an error processing the request.', 'gravityview' ), |
|
530 | + 'failed' => esc_html__( 'Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview' ), |
|
531 | + 'site_inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
532 | + 'inactive' => esc_html__( 'The license key is valid, but it has not been activated for this site.', 'gravityview' ), |
|
533 | + 'no_activations_left' => esc_html__( 'Invalid: this license has reached its activation limit.', 'gravityview' ) . ' ' . sprintf( esc_html__( 'You can manage license activations %son your GravityView account page%s.', 'gravityview' ), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
534 | + 'deactivated' => esc_html__( 'The license has been deactivated.', 'gravityview' ), |
|
535 | + 'valid' => esc_html__( 'The license key is valid and active.', 'gravityview' ), |
|
536 | + 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
|
537 | + 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
|
538 | + 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
|
539 | + 'expired' => sprintf( esc_html__( 'This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview' ), '<a href="' . esc_url( $this->get_license_renewal_url( $license_data ) ) . '">', '</a>' ), |
|
540 | 540 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
541 | 541 | |
542 | - 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
|
543 | - 'activate_license' => esc_html__('Activate License', 'gravityview'), |
|
544 | - 'deactivate_license' => esc_html__('Deactivate License', 'gravityview'), |
|
545 | - 'check_license' => esc_html__('Verify License', 'gravityview'), |
|
542 | + 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
|
543 | + 'activate_license' => esc_html__( 'Activate License', 'gravityview' ), |
|
544 | + 'deactivate_license' => esc_html__( 'Deactivate License', 'gravityview' ), |
|
545 | + 'check_license' => esc_html__( 'Verify License', 'gravityview' ), |
|
546 | 546 | ); |
547 | 547 | |
548 | - if( empty( $status ) ) { |
|
548 | + if ( empty( $status ) ) { |
|
549 | 549 | return $strings; |
550 | 550 | } |
551 | 551 | |
552 | - if( isset( $strings[ $status ] ) ) { |
|
552 | + if ( isset( $strings[ $status ] ) ) { |
|
553 | 553 | return $strings[ $status ]; |
554 | 554 | } |
555 | 555 |
@@ -119,16 +119,16 @@ discard block |
||
119 | 119 | function load() { |
120 | 120 | |
121 | 121 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
122 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
122 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
123 | 123 | |
124 | 124 | // Don't display an embedded form when editing an entry |
125 | 125 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
126 | 126 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
127 | 127 | |
128 | 128 | // Stop Gravity Forms processing what is ours! |
129 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
129 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
130 | 130 | |
131 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
131 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
132 | 132 | |
133 | 133 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
140 | 140 | |
141 | 141 | // Add fields expected by GFFormDisplay::validate() |
142 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
142 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
143 | 143 | |
144 | 144 | } |
145 | 145 | |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | * @return void |
155 | 155 | */ |
156 | 156 | public function prevent_render_form() { |
157 | - if( $this->is_edit_entry() ) { |
|
158 | - if( 'wp_head' === current_filter() ) { |
|
157 | + if ( $this->is_edit_entry() ) { |
|
158 | + if ( 'wp_head' === current_filter() ) { |
|
159 | 159 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
160 | 160 | } else { |
161 | 161 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function prevent_maybe_process_form() { |
172 | 172 | |
173 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
173 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function is_edit_entry() { |
185 | 185 | |
186 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
186 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
187 | 187 | |
188 | 188 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
189 | 189 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @return boolean |
195 | 195 | */ |
196 | 196 | public function is_edit_entry_submission() { |
197 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
197 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | |
206 | 206 | |
207 | 207 | $entries = $gravityview_view->getEntries(); |
208 | - self::$original_entry = $entries[0]; |
|
209 | - $this->entry = $entries[0]; |
|
208 | + self::$original_entry = $entries[ 0 ]; |
|
209 | + $this->entry = $entries[ 0 ]; |
|
210 | 210 | |
211 | 211 | self::$original_form = $gravityview_view->getForm(); |
212 | 212 | $this->form = $gravityview_view->getForm(); |
213 | 213 | $this->form_id = $gravityview_view->getFormId(); |
214 | 214 | $this->view_id = $gravityview_view->getViewId(); |
215 | 215 | |
216 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
216 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | $this->setup_vars(); |
234 | 234 | |
235 | 235 | // Multiple Views embedded, don't proceed if nonce fails |
236 | - if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
237 | - do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
236 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
237 | + do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | 241 | // Sorry, you're not allowed here. |
242 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
243 | - do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
242 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
243 | + do_action( 'gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | private function print_scripts() { |
261 | 261 | $gravityview_view = GravityView_View::getInstance(); |
262 | 262 | |
263 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
263 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
264 | 264 | |
265 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
265 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
266 | 266 | |
267 | 267 | // Sack is required for images |
268 | 268 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -274,32 +274,32 @@ discard block |
||
274 | 274 | */ |
275 | 275 | private function process_save() { |
276 | 276 | |
277 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
277 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Make sure the entry, view, and form IDs are all correct |
282 | 282 | $valid = $this->verify_nonce(); |
283 | 283 | |
284 | - if( !$valid ) { |
|
285 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
284 | + if ( ! $valid ) { |
|
285 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
286 | 286 | return; |
287 | 287 | } |
288 | 288 | |
289 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
290 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
289 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
290 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | - do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
294 | + do_action( 'gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
295 | 295 | |
296 | 296 | $this->process_save_process_files( $this->form_id ); |
297 | 297 | |
298 | 298 | $this->validate(); |
299 | 299 | |
300 | - if( $this->is_valid ) { |
|
300 | + if ( $this->is_valid ) { |
|
301 | 301 | |
302 | - do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
302 | + do_action( 'gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
303 | 303 | |
304 | 304 | /** |
305 | 305 | * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields |
@@ -309,22 +309,22 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
311 | 311 | */ |
312 | - unset( $_GET['page'] ); |
|
312 | + unset( $_GET[ 'page' ] ); |
|
313 | 313 | |
314 | - $date_created = $this->entry['date_created']; |
|
314 | + $date_created = $this->entry[ 'date_created' ]; |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
318 | 318 | * @since 1.17.2 |
319 | 319 | */ |
320 | - unset( $this->entry['date_created'] ); |
|
320 | + unset( $this->entry[ 'date_created' ] ); |
|
321 | 321 | |
322 | 322 | GFFormsModel::save_lead( $form, $this->entry ); |
323 | 323 | |
324 | 324 | // Delete the values for hidden inputs |
325 | 325 | $this->unset_hidden_field_values(); |
326 | 326 | |
327 | - $this->entry['date_created'] = $date_created; |
|
327 | + $this->entry[ 'date_created' ] = $date_created; |
|
328 | 328 | |
329 | 329 | // Process calculation fields |
330 | 330 | $this->update_calculation_fields(); |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | * @param array $form Gravity Forms form array |
344 | 344 | * @param string $entry_id Numeric ID of the entry that was updated |
345 | 345 | */ |
346 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] ); |
|
346 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] ); |
|
347 | 347 | |
348 | 348 | } else { |
349 | - do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
349 | + do_action( 'gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | } // process_save |
@@ -363,8 +363,8 @@ discard block |
||
363 | 363 | private function unset_hidden_field_values() { |
364 | 364 | global $wpdb; |
365 | 365 | |
366 | - $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
|
367 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
366 | + $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
|
367 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
368 | 368 | |
369 | 369 | foreach ( $this->entry as $input_id => $field_value ) { |
370 | 370 | |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | * @return mixed |
418 | 418 | */ |
419 | 419 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
420 | - if( ! $this->is_edit_entry() ) { |
|
420 | + if ( ! $this->is_edit_entry() ) { |
|
421 | 421 | return $plupload_init; |
422 | 422 | } |
423 | 423 | |
424 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
424 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
425 | 425 | |
426 | 426 | return $plupload_init; |
427 | 427 | } |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | $form = $this->form; |
437 | 437 | |
438 | 438 | /** @var GF_Field $field */ |
439 | - foreach( $form['fields'] as $k => &$field ) { |
|
439 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
440 | 440 | |
441 | 441 | /** |
442 | 442 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
443 | 443 | * @since 1.16.3 |
444 | 444 | * @var GF_Field $field |
445 | 445 | */ |
446 | - if( $field->has_calculation() ) { |
|
447 | - unset( $form['fields'][ $k ] ); |
|
446 | + if ( $field->has_calculation() ) { |
|
447 | + unset( $form[ 'fields' ][ $k ] ); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | $field->adminOnly = false; |
451 | 451 | |
452 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
453 | - foreach( $field->inputs as $key => $input ) { |
|
454 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
452 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
453 | + foreach ( $field->inputs as $key => $input ) { |
|
454 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | $update = false; |
466 | 466 | |
467 | 467 | // get the most up to date entry values |
468 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
468 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
469 | 469 | |
470 | - if( !empty( $this->fields_with_calculation ) ) { |
|
470 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
471 | 471 | $update = true; |
472 | 472 | foreach ( $this->fields_with_calculation as $calc_field ) { |
473 | 473 | $inputs = $calc_field->get_entry_inputs(); |
474 | 474 | if ( is_array( $inputs ) ) { |
475 | 475 | foreach ( $inputs as $input ) { |
476 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
477 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
476 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
477 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
478 | 478 | } |
479 | 479 | } else { |
480 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
481 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
480 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
481 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
@@ -488,16 +488,16 @@ discard block |
||
488 | 488 | if ( ! empty( $this->total_fields ) ) { |
489 | 489 | $update = true; |
490 | 490 | foreach ( $this->total_fields as $total_field ) { |
491 | - $input_name = 'input_' . str_replace( '.', '_', $total_field->id); |
|
492 | - $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry['id'], $entry ); |
|
491 | + $input_name = 'input_' . str_replace( '.', '_', $total_field->id ); |
|
492 | + $entry[ strval( $total_field->id ) ] = RGFormsModel::prepare_value( $form, $total_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | |
496 | - if( $update ) { |
|
496 | + if ( $update ) { |
|
497 | 497 | |
498 | 498 | $return_entry = GFAPI::update_entry( $entry ); |
499 | 499 | |
500 | - if( is_wp_error( $return_entry ) ) { |
|
500 | + if ( is_wp_error( $return_entry ) ) { |
|
501 | 501 | do_action( 'gravityview_log_error', 'Updating the entry calculation and total fields failed', $return_entry ); |
502 | 502 | } else { |
503 | 503 | do_action( 'gravityview_log_debug', 'Updating the entry calculation and total fields succeeded' ); |
@@ -528,18 +528,18 @@ discard block |
||
528 | 528 | |
529 | 529 | $input_name = 'input_' . $field_id; |
530 | 530 | |
531 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
531 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
532 | 532 | |
533 | 533 | // We have a new image |
534 | 534 | |
535 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
535 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
536 | 536 | |
537 | 537 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
538 | 538 | $img_url = rgar( $ary, 0 ); |
539 | 539 | |
540 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
541 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
542 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
540 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
541 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
542 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
543 | 543 | |
544 | 544 | $image_meta = array( |
545 | 545 | 'post_excerpt' => $img_caption, |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | |
549 | 549 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
550 | 550 | if ( ! empty( $img_title ) ) { |
551 | - $image_meta['post_title'] = $img_title; |
|
551 | + $image_meta[ 'post_title' ] = $img_title; |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -563,22 +563,22 @@ discard block |
||
563 | 563 | set_post_thumbnail( $post_id, $media_id ); |
564 | 564 | } |
565 | 565 | |
566 | - } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
566 | + } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
567 | 567 | |
568 | 568 | // Same image although the image title, caption or description might have changed |
569 | 569 | |
570 | 570 | $ary = array(); |
571 | - if( ! empty( $entry[ $field_id ] ) ) { |
|
571 | + if ( ! empty( $entry[ $field_id ] ) ) { |
|
572 | 572 | $ary = is_array( $entry[ $field_id ] ) ? $entry[ $field_id ] : explode( '|:|', $entry[ $field_id ] ); |
573 | 573 | } |
574 | 574 | $img_url = rgar( $ary, 0 ); |
575 | 575 | |
576 | 576 | // is this really the same image or something went wrong ? |
577 | - if( $img_url === $_POST[ $input_name ] ) { |
|
577 | + if ( $img_url === $_POST[ $input_name ] ) { |
|
578 | 578 | |
579 | - $img_title = rgar( $value, $field_id .'.1' ); |
|
580 | - $img_caption = rgar( $value, $field_id .'.4' ); |
|
581 | - $img_description = rgar( $value, $field_id .'.7' ); |
|
579 | + $img_title = rgar( $value, $field_id . '.1' ); |
|
580 | + $img_caption = rgar( $value, $field_id . '.4' ); |
|
581 | + $img_description = rgar( $value, $field_id . '.7' ); |
|
582 | 582 | |
583 | 583 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : ''; |
584 | 584 | |
@@ -618,16 +618,16 @@ discard block |
||
618 | 618 | */ |
619 | 619 | private function maybe_update_post_fields( $form ) { |
620 | 620 | |
621 | - if( empty( $this->entry['post_id'] ) ) { |
|
621 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
622 | 622 | do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' ); |
623 | 623 | return; |
624 | 624 | } |
625 | 625 | |
626 | - $post_id = $this->entry['post_id']; |
|
626 | + $post_id = $this->entry[ 'post_id' ]; |
|
627 | 627 | |
628 | 628 | // Security check |
629 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
630 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
629 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
630 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | |
@@ -639,25 +639,25 @@ discard block |
||
639 | 639 | |
640 | 640 | $field = RGFormsModel::get_field( $form, $field_id ); |
641 | 641 | |
642 | - if( ! $field ) { |
|
642 | + if ( ! $field ) { |
|
643 | 643 | continue; |
644 | 644 | } |
645 | 645 | |
646 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
646 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
647 | 647 | |
648 | 648 | // Get the value of the field, including $_POSTed value |
649 | 649 | $value = RGFormsModel::get_field_value( $field ); |
650 | 650 | |
651 | 651 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
652 | 652 | $entry_tmp = $this->entry; |
653 | - $entry_tmp["{$field_id}"] = $value; |
|
653 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
654 | 654 | |
655 | - switch( $field->type ) { |
|
655 | + switch ( $field->type ) { |
|
656 | 656 | |
657 | 657 | case 'post_title': |
658 | 658 | $post_title = $value; |
659 | - if( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
660 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
659 | + if ( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
660 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
661 | 661 | } |
662 | 662 | $updated_post->post_title = $post_title; |
663 | 663 | $updated_post->post_name = $post_title; |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | |
667 | 667 | case 'post_content': |
668 | 668 | $post_content = $value; |
669 | - if( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
670 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
669 | + if ( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
670 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
671 | 671 | } |
672 | 672 | $updated_post->post_content = $post_content; |
673 | 673 | unset( $post_content ); |
@@ -681,12 +681,12 @@ discard block |
||
681 | 681 | case 'post_category': |
682 | 682 | break; |
683 | 683 | case 'post_custom_field': |
684 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
684 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
685 | 685 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
686 | 686 | } |
687 | 687 | |
688 | 688 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
689 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
689 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | } |
701 | 701 | |
702 | 702 | // update entry after |
703 | - $this->entry["{$field_id}"] = $value; |
|
703 | + $this->entry[ "{$field_id}" ] = $value; |
|
704 | 704 | |
705 | 705 | $update_entry = true; |
706 | 706 | |
@@ -709,25 +709,25 @@ discard block |
||
709 | 709 | |
710 | 710 | } |
711 | 711 | |
712 | - if( $update_entry ) { |
|
712 | + if ( $update_entry ) { |
|
713 | 713 | |
714 | 714 | $return_entry = GFAPI::update_entry( $this->entry ); |
715 | 715 | |
716 | - if( is_wp_error( $return_entry ) ) { |
|
716 | + if ( is_wp_error( $return_entry ) ) { |
|
717 | 717 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ); |
718 | 718 | } else { |
719 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
719 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | } |
723 | 723 | |
724 | 724 | $return_post = wp_update_post( $updated_post, true ); |
725 | 725 | |
726 | - if( is_wp_error( $return_post ) ) { |
|
726 | + if ( is_wp_error( $return_post ) ) { |
|
727 | 727 | $return_post->add_data( $updated_post, '$updated_post' ); |
728 | 728 | do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) ); |
729 | 729 | } else { |
730 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post ); |
|
730 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post ); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | $input_type = RGFormsModel::get_input_type( $field ); |
746 | 746 | |
747 | 747 | // Only certain custom field types are supported |
748 | - switch( $input_type ) { |
|
748 | + switch ( $input_type ) { |
|
749 | 749 | case 'fileupload': |
750 | 750 | case 'list': |
751 | 751 | case 'multiselect': |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
783 | 783 | |
784 | 784 | // replace conditional shortcodes |
785 | - if( $do_shortcode ) { |
|
785 | + if ( $do_shortcode ) { |
|
786 | 786 | $output = do_shortcode( $output ); |
787 | 787 | } |
788 | 788 | |
@@ -801,18 +801,18 @@ discard block |
||
801 | 801 | */ |
802 | 802 | private function after_update() { |
803 | 803 | |
804 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
805 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); |
|
804 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
805 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] ); |
|
806 | 806 | |
807 | 807 | // Re-define the entry now that we've updated it. |
808 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
808 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
809 | 809 | |
810 | 810 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
811 | 811 | |
812 | 812 | // We need to clear the cache because Gravity Forms caches the field values, which |
813 | 813 | // we have just updated. |
814 | - foreach ($this->form['fields'] as $key => $field) { |
|
815 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
814 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
815 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | $this->entry = $entry; |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | |
831 | 831 | <div class="gv-edit-entry-wrapper"><?php |
832 | 832 | |
833 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
833 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
834 | 834 | |
835 | 835 | /** |
836 | 836 | * Fixes weird wpautop() issue |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | * @param string $edit_entry_title Modify the "Edit Entry" title |
847 | 847 | * @param GravityView_Edit_Entry_Render $this This object |
848 | 848 | */ |
849 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
849 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
850 | 850 | |
851 | 851 | echo esc_attr( $edit_entry_title ); |
852 | 852 | ?></span> |
@@ -892,20 +892,20 @@ discard block |
||
892 | 892 | */ |
893 | 893 | private function maybe_print_message() { |
894 | 894 | |
895 | - if( rgpost('action') === 'update' ) { |
|
895 | + if ( rgpost( 'action' ) === 'update' ) { |
|
896 | 896 | |
897 | 897 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
898 | 898 | |
899 | - if( ! $this->is_valid ){ |
|
899 | + if ( ! $this->is_valid ) { |
|
900 | 900 | |
901 | 901 | // Keeping this compatible with Gravity Forms. |
902 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
903 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
902 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
903 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
904 | 904 | |
905 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
905 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
906 | 906 | |
907 | 907 | } else { |
908 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
908 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
909 | 909 | |
910 | 910 | /** |
911 | 911 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | * @param array $entry Gravity Forms entry array |
916 | 916 | * @param string $back_link URL to return to the original entry. @since 1.6 |
917 | 917 | */ |
918 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
918 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
919 | 919 | |
920 | 920 | echo GVCommon::generate_notice( $message ); |
921 | 921 | } |
@@ -939,22 +939,22 @@ discard block |
||
939 | 939 | */ |
940 | 940 | do_action( 'gravityview/edit-entry/render/before', $this ); |
941 | 941 | |
942 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
943 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
942 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
943 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
944 | 944 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
945 | 945 | |
946 | 946 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
947 | 947 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
948 | 948 | |
949 | 949 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
950 | - unset( $_GET['page'] ); |
|
950 | + unset( $_GET[ 'page' ] ); |
|
951 | 951 | |
952 | 952 | // TODO: Verify multiple-page forms |
953 | 953 | // TODO: Product fields are not editable |
954 | 954 | |
955 | 955 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
956 | 956 | |
957 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
957 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
958 | 958 | |
959 | 959 | ob_get_clean(); |
960 | 960 | |
@@ -980,7 +980,7 @@ discard block |
||
980 | 980 | * @return string |
981 | 981 | */ |
982 | 982 | public function render_form_buttons() { |
983 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
983 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | |
@@ -1000,10 +1000,10 @@ discard block |
||
1000 | 1000 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1001 | 1001 | |
1002 | 1002 | // In case we have validated the form, use it to inject the validation results into the form render |
1003 | - if( isset( $this->form_after_validation ) ) { |
|
1003 | + if ( isset( $this->form_after_validation ) ) { |
|
1004 | 1004 | $form = $this->form_after_validation; |
1005 | 1005 | } else { |
1006 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1006 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | $form = $this->filter_conditional_logic( $form ); |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | $form = $this->prefill_conditional_logic( $form ); |
1012 | 1012 | |
1013 | 1013 | // for now we don't support Save and Continue feature. |
1014 | - if( ! self::$supports_save_and_continue ) { |
|
1015 | - unset( $form['save'] ); |
|
1014 | + if ( ! self::$supports_save_and_continue ) { |
|
1015 | + unset( $form[ 'save' ] ); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | return $form; |
@@ -1033,29 +1033,29 @@ discard block |
||
1033 | 1033 | */ |
1034 | 1034 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1035 | 1035 | |
1036 | - if( GFCommon::is_post_field( $field ) ) { |
|
1036 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1037 | 1037 | |
1038 | 1038 | $message = null; |
1039 | 1039 | |
1040 | 1040 | // First, make sure they have the capability to edit the post. |
1041 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1041 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1042 | 1042 | |
1043 | 1043 | /** |
1044 | 1044 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1045 | 1045 | * @param string $message The existing "You don't have permission..." text |
1046 | 1046 | */ |
1047 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1047 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1048 | 1048 | |
1049 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1049 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1050 | 1050 | /** |
1051 | 1051 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1052 | 1052 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1053 | 1053 | */ |
1054 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1054 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | - if( $message ) { |
|
1058 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1057 | + if ( $message ) { |
|
1058 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | |
1081 | 1081 | // If the form has been submitted, then we don't need to pre-fill the values, |
1082 | 1082 | // Except for fileupload type and when a field input is overridden- run always!! |
1083 | - if( |
|
1084 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1083 | + if ( |
|
1084 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1085 | 1085 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1086 | 1086 | || ! empty( $field_content ) |
1087 | 1087 | || in_array( $field->type, array( 'honeypot' ) ) |
@@ -1091,8 +1091,8 @@ discard block |
||
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | // Turn on Admin-style display for file upload fields only |
1094 | - if( 'fileupload' === $field->type ) { |
|
1095 | - $_GET['page'] = 'gf_entries'; |
|
1094 | + if ( 'fileupload' === $field->type ) { |
|
1095 | + $_GET[ 'page' ] = 'gf_entries'; |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1119,13 +1119,13 @@ discard block |
||
1119 | 1119 | * @param mixed $field_value field value used to populate the input |
1120 | 1120 | * @param GF_Field $field Gravity Forms field object |
1121 | 1121 | */ |
1122 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field ); |
|
1122 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field ); |
|
1123 | 1123 | |
1124 | 1124 | // Prevent any PHP warnings, like undefined index |
1125 | 1125 | ob_start(); |
1126 | 1126 | |
1127 | 1127 | /** @var GravityView_Field $gv_field */ |
1128 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1128 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1129 | 1129 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1130 | 1130 | } else { |
1131 | 1131 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | // If there was output, it's an error |
1136 | 1136 | $warnings = ob_get_clean(); |
1137 | 1137 | |
1138 | - if( !empty( $warnings ) ) { |
|
1138 | + if ( ! empty( $warnings ) ) { |
|
1139 | 1139 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
1140 | 1140 | } |
1141 | 1141 | |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | * We need the fileupload html field to render with the proper id |
1145 | 1145 | * ( <li id="field_80_16" ... > ) |
1146 | 1146 | */ |
1147 | - unset( $_GET['page'] ); |
|
1147 | + unset( $_GET[ 'page' ] ); |
|
1148 | 1148 | |
1149 | 1149 | return $return; |
1150 | 1150 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1168 | 1168 | |
1169 | 1169 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1170 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1170 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1171 | 1171 | |
1172 | 1172 | $field_value = array(); |
1173 | 1173 | |
@@ -1176,10 +1176,10 @@ discard block |
||
1176 | 1176 | |
1177 | 1177 | foreach ( (array)$field->inputs as $input ) { |
1178 | 1178 | |
1179 | - $input_id = strval( $input['id'] ); |
|
1179 | + $input_id = strval( $input[ 'id' ] ); |
|
1180 | 1180 | |
1181 | 1181 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1182 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1182 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1183 | 1183 | $allow_pre_populated = false; |
1184 | 1184 | } |
1185 | 1185 | |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | $pre_value = $field->get_value_submission( array(), false ); |
1189 | 1189 | |
1190 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1190 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1191 | 1191 | |
1192 | 1192 | } else { |
1193 | 1193 | |
@@ -1198,13 +1198,13 @@ discard block |
||
1198 | 1198 | |
1199 | 1199 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1200 | 1200 | // or pre-populated value if not empty and set to override saved value |
1201 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1201 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1202 | 1202 | |
1203 | 1203 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1204 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1204 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1205 | 1205 | $categories = array(); |
1206 | 1206 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1207 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1207 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1208 | 1208 | } |
1209 | 1209 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1210 | 1210 | } |
@@ -1229,12 +1229,12 @@ discard block |
||
1229 | 1229 | */ |
1230 | 1230 | public function gform_pre_validation( $form ) { |
1231 | 1231 | |
1232 | - if( ! $this->verify_nonce() ) { |
|
1232 | + if ( ! $this->verify_nonce() ) { |
|
1233 | 1233 | return $form; |
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | // Fix PHP warning regarding undefined index. |
1237 | - foreach ( $form['fields'] as &$field) { |
|
1237 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1238 | 1238 | |
1239 | 1239 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1240 | 1240 | // expects certain field array items to be set. |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | $field['emailConfirmEnabled'] = ''; |
1248 | 1248 | }*/ |
1249 | 1249 | |
1250 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1250 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1251 | 1251 | |
1252 | 1252 | /** |
1253 | 1253 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1261,37 +1261,37 @@ discard block |
||
1261 | 1261 | // Set the previous value |
1262 | 1262 | $entry = $this->get_entry(); |
1263 | 1263 | |
1264 | - $input_name = 'input_'.$field->id; |
|
1265 | - $form_id = $form['id']; |
|
1264 | + $input_name = 'input_' . $field->id; |
|
1265 | + $form_id = $form[ 'id' ]; |
|
1266 | 1266 | |
1267 | 1267 | $value = NULL; |
1268 | 1268 | |
1269 | 1269 | // Use the previous entry value as the default. |
1270 | - if( isset( $entry[ $field->id ] ) ) { |
|
1270 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1271 | 1271 | $value = $entry[ $field->id ]; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | // If this is a single upload file |
1275 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1276 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1277 | - $value = $file_path['url']; |
|
1275 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1276 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1277 | + $value = $file_path[ 'url' ]; |
|
1278 | 1278 | |
1279 | 1279 | } else { |
1280 | 1280 | |
1281 | 1281 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1282 | 1282 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1283 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1283 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1284 | 1284 | |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - if( rgar($field, "multipleFiles") ) { |
|
1287 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
1288 | 1288 | |
1289 | 1289 | // If there are fresh uploads, process and merge them. |
1290 | 1290 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1291 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1291 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1292 | 1292 | $value = empty( $value ) ? '[]' : $value; |
1293 | 1293 | $value = stripslashes_deep( $value ); |
1294 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1294 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | } else { |
@@ -1309,14 +1309,14 @@ discard block |
||
1309 | 1309 | |
1310 | 1310 | case 'number': |
1311 | 1311 | // Fix "undefined index" issue at line 1286 in form_display.php |
1312 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1313 | - $_POST['input_'.$field->id ] = NULL; |
|
1312 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1313 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1314 | 1314 | } |
1315 | 1315 | break; |
1316 | 1316 | case 'captcha': |
1317 | 1317 | // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php |
1318 | - $_POST['recaptcha_challenge_field'] = NULL; |
|
1319 | - $_POST['recaptcha_response_field'] = NULL; |
|
1318 | + $_POST[ 'recaptcha_challenge_field' ] = NULL; |
|
1319 | + $_POST[ 'recaptcha_response_field' ] = NULL; |
|
1320 | 1320 | break; |
1321 | 1321 | } |
1322 | 1322 | |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | * You can enter whatever you want! |
1353 | 1353 | * We try validating, and customize the results using `self::custom_validation()` |
1354 | 1354 | */ |
1355 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1355 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1356 | 1356 | |
1357 | 1357 | // Needed by the validate funtion |
1358 | 1358 | $failed_validation_page = NULL; |
@@ -1360,14 +1360,14 @@ discard block |
||
1360 | 1360 | |
1361 | 1361 | // Prevent entry limit from running when editing an entry, also |
1362 | 1362 | // prevent form scheduling from preventing editing |
1363 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1363 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1364 | 1364 | |
1365 | 1365 | // Hide fields depending on Edit Entry settings |
1366 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1366 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1367 | 1367 | |
1368 | 1368 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1369 | 1369 | |
1370 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1370 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | |
@@ -1384,13 +1384,13 @@ discard block |
||
1384 | 1384 | */ |
1385 | 1385 | public function custom_validation( $validation_results ) { |
1386 | 1386 | |
1387 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1387 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1388 | 1388 | |
1389 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1389 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1390 | 1390 | |
1391 | 1391 | $gv_valid = true; |
1392 | 1392 | |
1393 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1393 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1394 | 1394 | |
1395 | 1395 | $value = RGFormsModel::get_field_value( $field ); |
1396 | 1396 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1403,35 +1403,35 @@ discard block |
||
1403 | 1403 | case 'post_image': |
1404 | 1404 | |
1405 | 1405 | // in case nothing is uploaded but there are already files saved |
1406 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1406 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1407 | 1407 | $field->failed_validation = false; |
1408 | 1408 | unset( $field->validation_message ); |
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1412 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
1412 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
1413 | 1413 | |
1414 | 1414 | $input_name = 'input_' . $field->id; |
1415 | 1415 | //uploaded |
1416 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1416 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1417 | 1417 | |
1418 | 1418 | //existent |
1419 | 1419 | $entry = $this->get_entry(); |
1420 | 1420 | $value = NULL; |
1421 | - if( isset( $entry[ $field->id ] ) ) { |
|
1421 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1422 | 1422 | $value = json_decode( $entry[ $field->id ], true ); |
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | // count uploaded files and existent entry files |
1426 | 1426 | $count_files = count( $file_names ) + count( $value ); |
1427 | 1427 | |
1428 | - if( $count_files > $field->maxFiles ) { |
|
1428 | + if ( $count_files > $field->maxFiles ) { |
|
1429 | 1429 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1430 | 1430 | $field->failed_validation = 1; |
1431 | 1431 | $gv_valid = false; |
1432 | 1432 | |
1433 | 1433 | // in case of error make sure the newest upload files are removed from the upload input |
1434 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1434 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | } |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | // This field has failed validation. |
1445 | - if( !empty( $field->failed_validation ) ) { |
|
1445 | + if ( ! empty( $field->failed_validation ) ) { |
|
1446 | 1446 | |
1447 | 1447 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
1448 | 1448 | |
@@ -1460,32 +1460,32 @@ discard block |
||
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | // You can't continue inside a switch, so we do it after. |
1463 | - if( empty( $field->failed_validation ) ) { |
|
1463 | + if ( empty( $field->failed_validation ) ) { |
|
1464 | 1464 | continue; |
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | // checks if the No Duplicates option is not validating entry against itself, since |
1468 | 1468 | // we're editing a stored entry, it would also assume it's a duplicate. |
1469 | - if( !empty( $field->noDuplicates ) ) { |
|
1469 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1470 | 1470 | |
1471 | 1471 | $entry = $this->get_entry(); |
1472 | 1472 | |
1473 | 1473 | // If the value of the entry is the same as the stored value |
1474 | 1474 | // Then we can assume it's not a duplicate, it's the same. |
1475 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1475 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1476 | 1476 | //if value submitted was not changed, then don't validate |
1477 | 1477 | $field->failed_validation = false; |
1478 | 1478 | |
1479 | 1479 | unset( $field->validation_message ); |
1480 | 1480 | |
1481 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1481 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1482 | 1482 | |
1483 | 1483 | continue; |
1484 | 1484 | } |
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1488 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1488 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1489 | 1489 | unset( $field->validation_message ); |
1490 | 1490 | $field->validation_message = false; |
1491 | 1491 | continue; |
@@ -1497,12 +1497,12 @@ discard block |
||
1497 | 1497 | |
1498 | 1498 | } |
1499 | 1499 | |
1500 | - $validation_results['is_valid'] = $gv_valid; |
|
1500 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1501 | 1501 | |
1502 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1502 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1503 | 1503 | |
1504 | 1504 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1505 | - $this->form_after_validation = $validation_results['form']; |
|
1505 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1506 | 1506 | |
1507 | 1507 | return $validation_results; |
1508 | 1508 | } |
@@ -1515,7 +1515,7 @@ discard block |
||
1515 | 1515 | */ |
1516 | 1516 | public function get_entry() { |
1517 | 1517 | |
1518 | - if( empty( $this->entry ) ) { |
|
1518 | + if ( empty( $this->entry ) ) { |
|
1519 | 1519 | // Get the database value of the entry that's being edited |
1520 | 1520 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1521 | 1521 | } |
@@ -1542,13 +1542,13 @@ discard block |
||
1542 | 1542 | $properties = GravityView_View_Data::getInstance()->get_fields( $view_id ); |
1543 | 1543 | |
1544 | 1544 | // If edit tab not yet configured, show all fields |
1545 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1545 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1546 | 1546 | |
1547 | 1547 | // Show hidden fields as text fields |
1548 | 1548 | $form = $this->fix_survey_fields( $form ); |
1549 | 1549 | |
1550 | 1550 | // Hide fields depending on admin settings |
1551 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1551 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1552 | 1552 | |
1553 | 1553 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1554 | 1554 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1578,7 +1578,7 @@ discard block |
||
1578 | 1578 | private function fix_survey_fields( $form ) { |
1579 | 1579 | |
1580 | 1580 | /** @var GF_Field $field */ |
1581 | - foreach( $form['fields'] as &$field ) { |
|
1581 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1582 | 1582 | $field->allowsPrepopulate = true; |
1583 | 1583 | } |
1584 | 1584 | |
@@ -1599,7 +1599,7 @@ discard block |
||
1599 | 1599 | */ |
1600 | 1600 | private function filter_fields( $fields, $configured_fields ) { |
1601 | 1601 | |
1602 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1602 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1603 | 1603 | return $fields; |
1604 | 1604 | } |
1605 | 1605 | |
@@ -1616,13 +1616,13 @@ discard block |
||
1616 | 1616 | */ |
1617 | 1617 | $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) ); |
1618 | 1618 | |
1619 | - if( $hide_product_fields ) { |
|
1620 | - $field_type_blacklist[] = 'option'; |
|
1621 | - $field_type_blacklist[] = 'quantity'; |
|
1622 | - $field_type_blacklist[] = 'product'; |
|
1623 | - $field_type_blacklist[] = 'total'; |
|
1624 | - $field_type_blacklist[] = 'shipping'; |
|
1625 | - $field_type_blacklist[] = 'calculation'; |
|
1619 | + if ( $hide_product_fields ) { |
|
1620 | + $field_type_blacklist[ ] = 'option'; |
|
1621 | + $field_type_blacklist[ ] = 'quantity'; |
|
1622 | + $field_type_blacklist[ ] = 'product'; |
|
1623 | + $field_type_blacklist[ ] = 'total'; |
|
1624 | + $field_type_blacklist[ ] = 'shipping'; |
|
1625 | + $field_type_blacklist[ ] = 'calculation'; |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | // First, remove blacklist or calculation fields |
@@ -1630,24 +1630,24 @@ discard block |
||
1630 | 1630 | |
1631 | 1631 | // Remove the fields that have calculation properties and keep them to be used later |
1632 | 1632 | // @since 1.16.2 |
1633 | - if( $field->has_calculation() ) { |
|
1634 | - $this->fields_with_calculation[] = $field; |
|
1633 | + if ( $field->has_calculation() ) { |
|
1634 | + $this->fields_with_calculation[ ] = $field; |
|
1635 | 1635 | // don't remove the calculation fields on form render. |
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | // process total field after all fields have been saved |
1639 | 1639 | if ( $field->type == 'total' ) { |
1640 | - $this->total_fields[] = $field; |
|
1640 | + $this->total_fields[ ] = $field; |
|
1641 | 1641 | unset( $fields[ $key ] ); |
1642 | 1642 | } |
1643 | 1643 | |
1644 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1644 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1645 | 1645 | unset( $fields[ $key ] ); |
1646 | 1646 | } |
1647 | 1647 | } |
1648 | 1648 | |
1649 | 1649 | // The Edit tab has not been configured, so we return all fields by default. |
1650 | - if( empty( $configured_fields ) ) { |
|
1650 | + if ( empty( $configured_fields ) ) { |
|
1651 | 1651 | return $fields; |
1652 | 1652 | } |
1653 | 1653 | |
@@ -1657,8 +1657,8 @@ discard block |
||
1657 | 1657 | /** @var GF_Field $field */ |
1658 | 1658 | foreach ( $fields as $field ) { |
1659 | 1659 | |
1660 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1661 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1660 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1661 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1662 | 1662 | break; |
1663 | 1663 | } |
1664 | 1664 | |
@@ -1681,14 +1681,14 @@ discard block |
||
1681 | 1681 | |
1682 | 1682 | $return_field = $field; |
1683 | 1683 | |
1684 | - if( empty( $field_setting['show_label'] ) ) { |
|
1684 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1685 | 1685 | $return_field->label = ''; |
1686 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1687 | - $return_field->label = $field_setting['custom_label']; |
|
1686 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1687 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1691 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1690 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1691 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | /** |
@@ -1726,16 +1726,16 @@ discard block |
||
1726 | 1726 | */ |
1727 | 1727 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1728 | 1728 | |
1729 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1730 | - foreach( $fields as $k => $field ) { |
|
1731 | - if( $field->adminOnly ) { |
|
1729 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1730 | + foreach ( $fields as $k => $field ) { |
|
1731 | + if ( $field->adminOnly ) { |
|
1732 | 1732 | unset( $fields[ $k ] ); |
1733 | 1733 | } |
1734 | 1734 | } |
1735 | 1735 | return $fields; |
1736 | 1736 | } |
1737 | 1737 | |
1738 | - foreach( $fields as &$field ) { |
|
1738 | + foreach ( $fields as &$field ) { |
|
1739 | 1739 | $field->adminOnly = false; |
1740 | 1740 | } |
1741 | 1741 | |
@@ -1759,22 +1759,22 @@ discard block |
||
1759 | 1759 | */ |
1760 | 1760 | function prefill_conditional_logic( $form ) { |
1761 | 1761 | |
1762 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1762 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1763 | 1763 | return $form; |
1764 | 1764 | } |
1765 | 1765 | |
1766 | 1766 | // Have Conditional Logic pre-fill fields as if the data were default values |
1767 | 1767 | /** @var GF_Field $field */ |
1768 | - foreach ( $form['fields'] as &$field ) { |
|
1768 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1769 | 1769 | |
1770 | - if( 'checkbox' === $field->type ) { |
|
1770 | + if ( 'checkbox' === $field->type ) { |
|
1771 | 1771 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1772 | - $input_id = $input['id']; |
|
1772 | + $input_id = $input[ 'id' ]; |
|
1773 | 1773 | $choice = $field->choices[ $key ]; |
1774 | 1774 | $value = rgar( $this->entry, $input_id ); |
1775 | 1775 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1776 | - if( $match ) { |
|
1777 | - $field->choices[ $key ]['isSelected'] = true; |
|
1776 | + if ( $match ) { |
|
1777 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1778 | 1778 | } |
1779 | 1779 | } |
1780 | 1780 | } else { |
@@ -1782,15 +1782,15 @@ discard block |
||
1782 | 1782 | // We need to run through each field to set the default values |
1783 | 1783 | foreach ( $this->entry as $field_id => $field_value ) { |
1784 | 1784 | |
1785 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1785 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1786 | 1786 | |
1787 | - if( 'list' === $field->type ) { |
|
1787 | + if ( 'list' === $field->type ) { |
|
1788 | 1788 | $list_rows = maybe_unserialize( $field_value ); |
1789 | 1789 | |
1790 | 1790 | $list_field_value = array(); |
1791 | 1791 | foreach ( $list_rows as $row ) { |
1792 | 1792 | foreach ( $row as $column ) { |
1793 | - $list_field_value[] = $column; |
|
1793 | + $list_field_value[ ] = $column; |
|
1794 | 1794 | } |
1795 | 1795 | } |
1796 | 1796 | |
@@ -1825,16 +1825,16 @@ discard block |
||
1825 | 1825 | */ |
1826 | 1826 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1827 | 1827 | |
1828 | - if( $use_conditional_logic ) { |
|
1828 | + if ( $use_conditional_logic ) { |
|
1829 | 1829 | return $form; |
1830 | 1830 | } |
1831 | 1831 | |
1832 | - foreach( $form['fields'] as &$field ) { |
|
1832 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1833 | 1833 | /* @var GF_Field $field */ |
1834 | 1834 | $field->conditionalLogic = null; |
1835 | 1835 | } |
1836 | 1836 | |
1837 | - unset( $form['button']['conditionalLogic'] ); |
|
1837 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1838 | 1838 | |
1839 | 1839 | return $form; |
1840 | 1840 | |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | */ |
1852 | 1852 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1853 | 1853 | |
1854 | - if( ! $this->is_edit_entry() ) { |
|
1854 | + if ( ! $this->is_edit_entry() ) { |
|
1855 | 1855 | return $has_conditional_logic; |
1856 | 1856 | } |
1857 | 1857 | |
@@ -1883,44 +1883,44 @@ discard block |
||
1883 | 1883 | * 2. There are two entries embedded using oEmbed |
1884 | 1884 | * 3. One of the entries has just been saved |
1885 | 1885 | */ |
1886 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1886 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1887 | 1887 | |
1888 | 1888 | $error = true; |
1889 | 1889 | |
1890 | 1890 | } |
1891 | 1891 | |
1892 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1892 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1893 | 1893 | |
1894 | 1894 | $error = true; |
1895 | 1895 | |
1896 | - } elseif( ! $this->verify_nonce() ) { |
|
1896 | + } elseif ( ! $this->verify_nonce() ) { |
|
1897 | 1897 | |
1898 | 1898 | /** |
1899 | 1899 | * If the Entry is embedded, there may be two entries on the same page. |
1900 | 1900 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1901 | 1901 | */ |
1902 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1902 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1903 | 1903 | $error = true; |
1904 | 1904 | } else { |
1905 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1905 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1906 | 1906 | } |
1907 | 1907 | |
1908 | 1908 | } |
1909 | 1909 | |
1910 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1911 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1910 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1911 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1912 | 1912 | } |
1913 | 1913 | |
1914 | - if( $this->entry['status'] === 'trash' ) { |
|
1915 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1914 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1915 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | // No errors; everything's fine here! |
1919 | - if( empty( $error ) ) { |
|
1919 | + if ( empty( $error ) ) { |
|
1920 | 1920 | return true; |
1921 | 1921 | } |
1922 | 1922 | |
1923 | - if( $echo && $error !== true ) { |
|
1923 | + if ( $echo && $error !== true ) { |
|
1924 | 1924 | |
1925 | 1925 | $error = esc_html( $error ); |
1926 | 1926 | |
@@ -1928,13 +1928,13 @@ discard block |
||
1928 | 1928 | * @since 1.9 |
1929 | 1929 | */ |
1930 | 1930 | if ( ! empty( $this->entry ) ) { |
1931 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1931 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1934 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1935 | 1935 | } |
1936 | 1936 | |
1937 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1937 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1938 | 1938 | |
1939 | 1939 | return false; |
1940 | 1940 | } |
@@ -1951,20 +1951,20 @@ discard block |
||
1951 | 1951 | |
1952 | 1952 | $error = NULL; |
1953 | 1953 | |
1954 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1955 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1954 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1955 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1956 | 1956 | } |
1957 | 1957 | |
1958 | 1958 | // No errors; everything's fine here! |
1959 | - if( empty( $error ) ) { |
|
1959 | + if ( empty( $error ) ) { |
|
1960 | 1960 | return true; |
1961 | 1961 | } |
1962 | 1962 | |
1963 | - if( $echo ) { |
|
1964 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1963 | + if ( $echo ) { |
|
1964 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1965 | 1965 | } |
1966 | 1966 | |
1967 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1967 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1968 | 1968 | |
1969 | 1969 | return false; |
1970 | 1970 | |
@@ -1982,15 +1982,15 @@ discard block |
||
1982 | 1982 | private function check_user_cap_edit_field( $field ) { |
1983 | 1983 | |
1984 | 1984 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1985 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1985 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1986 | 1986 | return true; |
1987 | 1987 | } |
1988 | 1988 | |
1989 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1989 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1990 | 1990 | |
1991 | 1991 | // If the field has custom editing capaibilities set, check those |
1992 | - if( $field_cap ) { |
|
1993 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1992 | + if ( $field_cap ) { |
|
1993 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1994 | 1994 | } |
1995 | 1995 | |
1996 | 1996 | return false; |
@@ -2004,17 +2004,17 @@ discard block |
||
2004 | 2004 | public function verify_nonce() { |
2005 | 2005 | |
2006 | 2006 | // Verify form submitted for editing single |
2007 | - if( $this->is_edit_entry_submission() ) { |
|
2007 | + if ( $this->is_edit_entry_submission() ) { |
|
2008 | 2008 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | // Verify |
2012 | - else if( ! $this->is_edit_entry() ) { |
|
2012 | + else if ( ! $this->is_edit_entry() ) { |
|
2013 | 2013 | $valid = false; |
2014 | 2014 | } |
2015 | 2015 | |
2016 | 2016 | else { |
2017 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2017 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2018 | 2018 | } |
2019 | 2019 | |
2020 | 2020 | /** |
@@ -59,8 +59,8 @@ |
||
59 | 59 | |
60 | 60 | $notes_table = class_exists( 'GFFormsModel' ) ? GFFormsModel::get_lead_notes_table_name() : $wpdb->prefix . 'rg_lead_notes'; |
61 | 61 | |
62 | - $disapproved = __('Disapproved the Entry for GravityView', 'gravityview'); |
|
63 | - $approved = __('Approved the Entry for GravityView', 'gravityview'); |
|
62 | + $disapproved = __( 'Disapproved the Entry for GravityView', 'gravityview' ); |
|
63 | + $approved = __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
64 | 64 | |
65 | 65 | $sql = $wpdb->prepare( " |
66 | 66 | DELETE FROM $notes_table |