@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | $atts = shortcode_atts( self::$defaults, $atts ); |
77 | 77 | |
78 | - $atts['action'] = 'edit'; |
|
78 | + $atts[ 'action' ] = 'edit'; |
|
79 | 79 | |
80 | 80 | return $this->shortcode( $atts, $content, $context ); |
81 | 81 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $atts = shortcode_atts( self::$defaults, $atts ); |
93 | 93 | |
94 | - $atts['action'] = 'delete'; |
|
94 | + $atts[ 'action' ] = 'delete'; |
|
95 | 95 | |
96 | 96 | return $this->shortcode( $atts, $content, $context ); |
97 | 97 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
133 | 133 | |
134 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
134 | + $this->view_id = empty( $this->settings[ 'view_id' ] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings[ 'view_id' ] ); |
|
135 | 135 | |
136 | 136 | if ( empty( $this->view_id ) ) { |
137 | 137 | gravityview()->log->error( 'A View ID was not defined and we are not inside a View' ); |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | return null; |
140 | 140 | } |
141 | 141 | |
142 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
142 | + $this->entry = $this->get_entry( $this->settings[ 'entry_id' ] ); |
|
143 | 143 | |
144 | 144 | if ( empty( $this->entry ) ) { |
145 | - gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings['entry_id'] ) ); |
|
145 | + gravityview()->log->error( 'An Entry ID was not defined or found. Entry ID: {entry_id}', array( 'entry_id' => $this->settings[ 'entry_id' ] ) ); |
|
146 | 146 | |
147 | 147 | return null; |
148 | 148 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | gravityview()->log->debug( '{context} atts:', array( 'context' => $context, 'data' => $atts ) ); |
151 | 151 | |
152 | 152 | if ( ! $this->has_cap() ) { |
153 | - gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings['action'] ), 'entry_id' => $this->entry['id'] ) ); |
|
153 | + gravityview()->log->error( 'User does not have the capability to {action} this entry: {entry_id}', array( 'action' => esc_attr( $this->settings[ 'action' ] ), 'entry_id' => $this->entry[ 'id' ] ) ); |
|
154 | 154 | |
155 | 155 | return null; |
156 | 156 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | // Get just the URL, not the tag |
167 | - if ( 'url' === $this->settings['return'] ) { |
|
167 | + if ( 'url' === $this->settings[ 'return' ] ) { |
|
168 | 168 | return $url; |
169 | 169 | } |
170 | 170 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | */ |
186 | 186 | private function get_link_atts() { |
187 | 187 | |
188 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
188 | + wp_parse_str( $this->settings[ 'link_atts' ], $link_atts ); |
|
189 | 189 | |
190 | - if ( 'delete' === $this->settings['action'] ) { |
|
191 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
190 | + if ( 'delete' === $this->settings[ 'action' ] ) { |
|
191 | + $link_atts[ 'onclick' ] = isset( $link_atts[ 'onclick' ] ) ? $link_atts[ 'onclick' ] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
192 | 192 | } |
193 | 193 | |
194 | - return (array) $link_atts; |
|
194 | + return (array)$link_atts; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | return do_shortcode( $content ); |
212 | 212 | } |
213 | 213 | |
214 | - switch ( $this->settings['action'] ) { |
|
214 | + switch ( $this->settings[ 'action' ] ) { |
|
215 | 215 | case 'edit': |
216 | 216 | $anchor_text = __( 'Edit Entry', 'gravityview' ); |
217 | 217 | break; |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | private function get_url() { |
240 | 240 | |
241 | 241 | // if post_id is not defined, default to view_id |
242 | - $post_id = empty( $this->settings['post_id'] ) ? $this->view_id : $this->settings['post_id']; |
|
242 | + $post_id = empty( $this->settings[ 'post_id' ] ) ? $this->view_id : $this->settings[ 'post_id' ]; |
|
243 | 243 | |
244 | - switch ( $this->settings['action'] ) { |
|
244 | + switch ( $this->settings[ 'action' ] ) { |
|
245 | 245 | case 'edit': |
246 | 246 | $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
247 | 247 | break; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | */ |
267 | 267 | private function has_cap() { |
268 | 268 | |
269 | - switch ( $this->settings['action'] ) { |
|
269 | + switch ( $this->settings[ 'action' ] ) { |
|
270 | 270 | case 'edit': |
271 | 271 | $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
272 | 272 | break; |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private function maybe_add_field_values_query_args( $url ) { |
333 | 333 | |
334 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
334 | + if ( $url && ! empty( $this->settings[ 'field_values' ] ) ) { |
|
335 | 335 | |
336 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
336 | + wp_parse_str( $this->settings[ 'field_values' ], $field_values ); |
|
337 | 337 | |
338 | 338 | $url = add_query_arg( $field_values, $url ); |
339 | 339 | } |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 ); |
29 | 29 | |
30 | 30 | // Tooltips |
31 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
31 | + add_filter( 'gform_tooltips', array( $this, 'tooltips' ) ); |
|
32 | 32 | |
33 | 33 | // adding styles and scripts |
34 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
35 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
36 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
37 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
38 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
39 | - |
|
40 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
41 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
42 | - add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers') ); |
|
43 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
44 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
45 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
34 | + add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles' ), 999 ); |
|
35 | + add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
36 | + add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
37 | + add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
38 | + add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
39 | + |
|
40 | + add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas' ), 10, 4 ); |
|
41 | + add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas' ), 10, 3 ); |
|
42 | + add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers' ) ); |
|
43 | + add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields' ), 10, 2 ); |
|
44 | + add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets' ) ); |
|
45 | + add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas' ), 10, 5 ); |
|
46 | 46 | |
47 | 47 | // @todo check if this hook is needed.. |
48 | 48 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
49 | 49 | |
50 | 50 | // Add Connected Form column |
51 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
51 | + add_filter( 'manage_gravityview_posts_columns', array( $this, 'add_post_type_columns' ) ); |
|
52 | 52 | |
53 | 53 | add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
54 | 54 | |
55 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
55 | + add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content' ), 10, 2 ); |
|
56 | 56 | |
57 | 57 | add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
58 | 58 | |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function suggest_support_articles( $localization_data = array() ) { |
73 | 73 | |
74 | - if( ! gravityview()->request->is_view() ) { |
|
74 | + if ( ! gravityview()->request->is_view() ) { |
|
75 | 75 | return $localization_data; |
76 | 76 | } |
77 | 77 | |
78 | - $localization_data['suggest'] = array( |
|
78 | + $localization_data[ 'suggest' ] = array( |
|
79 | 79 | '57ef23539033602e61d4a560', |
80 | 80 | '54c67bb9e4b0512429885513', |
81 | 81 | '54c67bb9e4b0512429885512', |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | public function filter_pre_get_posts_by_gravityview_form_id( &$query ) { |
97 | 97 | global $pagenow; |
98 | 98 | |
99 | - if ( !is_admin() ) { |
|
99 | + if ( ! is_admin() ) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - $form_id = isset( $_GET['gravityview_form_id'] ) ? (int) $_GET['gravityview_form_id'] : false; |
|
103 | + $form_id = isset( $_GET[ 'gravityview_form_id' ] ) ? (int)$_GET[ 'gravityview_form_id' ] : false; |
|
104 | 104 | |
105 | - if( 'edit.php' !== $pagenow || ! $form_id || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
105 | + if ( 'edit.php' !== $pagenow || ! $form_id || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | function add_view_dropdown() { |
120 | 120 | $current_screen = get_current_screen(); |
121 | 121 | |
122 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
122 | + if ( 'gravityview' !== $current_screen->post_type ) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $forms = gravityview_get_forms(); |
127 | 127 | $current_form = \GV\Utils::_GET( 'gravityview_form_id' ); |
128 | 128 | // If there are no forms to select, show no forms. |
129 | - if( !empty( $forms ) ) { ?> |
|
129 | + if ( ! empty( $forms ) ) { ?> |
|
130 | 130 | <select name="gravityview_form_id" id="gravityview_form_id"> |
131 | 131 | <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
132 | - <?php foreach( $forms as $form ) { ?> |
|
133 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
132 | + <?php foreach ( $forms as $form ) { ?> |
|
133 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
134 | 134 | <?php } ?> |
135 | 135 | </select> |
136 | 136 | <?php } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
145 | 145 | _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
146 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
146 | + GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name, $id ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | |
167 | 167 | $connected_views = gravityview_get_connected_views( $id, array( 'post_status' => 'any' ) ); |
168 | 168 | |
169 | - if( empty( $connected_views ) ) { |
|
169 | + if ( empty( $connected_views ) ) { |
|
170 | 170 | |
171 | - $menu_items['gravityview'] = array( |
|
171 | + $menu_items[ 'gravityview' ] = array( |
|
172 | 172 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
173 | 173 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
174 | 174 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -184,22 +184,22 @@ discard block |
||
184 | 184 | $sub_menu_items = array(); |
185 | 185 | foreach ( (array)$connected_views as $view ) { |
186 | 186 | |
187 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
187 | + if ( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | |
191 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
191 | + $label = empty( $view->post_title ) ? sprintf( __( 'No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
192 | 192 | |
193 | - $sub_menu_items[] = array( |
|
193 | + $sub_menu_items[ ] = array( |
|
194 | 194 | 'label' => esc_attr( $label ), |
195 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
195 | + 'url' => admin_url( 'post.php?action=edit&post=' . $view->ID ), |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | |
199 | 199 | // If there were no items added, then let's create the parent menu |
200 | - if( $sub_menu_items ) { |
|
200 | + if ( $sub_menu_items ) { |
|
201 | 201 | |
202 | - $sub_menu_items[] = array( |
|
202 | + $sub_menu_items[ ] = array( |
|
203 | 203 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
204 | 204 | 'link_class' => 'gv-create-view', |
205 | 205 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
211 | - $sub_menu_items[] = array( |
|
211 | + $sub_menu_items[ ] = array( |
|
212 | 212 | 'url' => '#', |
213 | 213 | 'label' => '', |
214 | 214 | 'menu_class' => 'hidden', |
215 | 215 | 'capabilities' => '', |
216 | 216 | ); |
217 | 217 | |
218 | - $menu_items['gravityview'] = array( |
|
218 | + $menu_items[ 'gravityview' ] = array( |
|
219 | 219 | 'label' => __( 'Connected Views', 'gravityview' ), |
220 | 220 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
221 | 221 | 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | $add = array( 'captcha', 'page' ); |
245 | 245 | |
246 | 246 | // Don't allowing editing the following values: |
247 | - if( $context === 'edit' ) { |
|
248 | - $add[] = 'post_id'; |
|
247 | + if ( $context === 'edit' ) { |
|
248 | + $add[ ] = 'post_id'; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $return = array_merge( $array, $add ); |
@@ -268,32 +268,32 @@ discard block |
||
268 | 268 | foreach ( $default_args as $key => $arg ) { |
269 | 269 | |
270 | 270 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
271 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
271 | + if ( isset( $arg[ 'tooltip' ] ) && empty( $arg[ 'tooltip' ] ) ) { continue; } |
|
272 | 272 | |
273 | 273 | // By default, use `tooltip` if defined. |
274 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
274 | + $tooltip = empty( $arg[ 'tooltip' ] ) ? NULL : $arg[ 'tooltip' ]; |
|
275 | 275 | |
276 | 276 | // Otherwise, use the description as a tooltip. |
277 | - if( empty( $tooltip ) && !empty( $arg['desc'] ) ) { |
|
278 | - $tooltip = $arg['desc']; |
|
277 | + if ( empty( $tooltip ) && ! empty( $arg[ 'desc' ] ) ) { |
|
278 | + $tooltip = $arg[ 'desc' ]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // If there's no tooltip set, continue |
282 | - if( empty( $tooltip ) ) { |
|
282 | + if ( empty( $tooltip ) ) { |
|
283 | 283 | continue; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Add the tooltip |
287 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
288 | - 'title' => $arg['label'], |
|
287 | + $gv_tooltips[ 'gv_' . $key ] = array( |
|
288 | + 'title' => $arg[ 'label' ], |
|
289 | 289 | 'value' => $tooltip, |
290 | 290 | ); |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | - $gv_tooltips['gv_css_merge_tags'] = array( |
|
295 | - 'title' => __('CSS Merge Tags', 'gravityview'), |
|
296 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
294 | + $gv_tooltips[ 'gv_css_merge_tags' ] = array( |
|
295 | + 'title' => __( 'CSS Merge Tags', 'gravityview' ), |
|
296 | + 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview' ), '<code>', '</code>' ) |
|
297 | 297 | ); |
298 | 298 | |
299 | 299 | /** |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | |
312 | 312 | foreach ( $gv_tooltips as $key => $tooltip ) { |
313 | 313 | |
314 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
314 | + $title = empty( $tooltip[ 'title' ] ) ? '' : '<h6>' . esc_html( $tooltip[ 'title' ] ) . '</h6>'; |
|
315 | 315 | |
316 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
316 | + $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip[ 'value' ] ) ); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | return $tooltips; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
330 | + public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
331 | 331 | |
332 | 332 | $output = ''; |
333 | 333 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
350 | 350 | $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
351 | 351 | |
352 | - $output = $template ? $template['label'] : $template_id_pretty; |
|
352 | + $output = $template ? $template[ 'label' ] : $template_id_pretty; |
|
353 | 353 | |
354 | 354 | break; |
355 | 355 | |
@@ -390,44 +390,44 @@ discard block |
||
390 | 390 | static public function get_connected_form_links( $form, $include_form_link = true ) { |
391 | 391 | |
392 | 392 | // Either the form is empty or the form ID is 0, not yet set. |
393 | - if( empty( $form ) ) { |
|
393 | + if ( empty( $form ) ) { |
|
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // The $form is passed as the form ID |
398 | - if( !is_array( $form ) ) { |
|
398 | + if ( ! is_array( $form ) ) { |
|
399 | 399 | $form = gravityview_get_form( $form ); |
400 | 400 | } |
401 | 401 | |
402 | - $form_id = $form['id']; |
|
402 | + $form_id = $form[ 'id' ]; |
|
403 | 403 | $links = array(); |
404 | 404 | |
405 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
405 | + if ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
406 | 406 | $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
407 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
408 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
407 | + $form_link = '<strong class="gv-form-title">' . gravityview_get_link( $form_url, $form[ 'title' ], 'class=row-title' ) . '</strong>'; |
|
408 | + $links[ ] = '<span>' . gravityview_get_link( $form_url, __( 'Edit Form', 'gravityview' ) ) . '</span>'; |
|
409 | 409 | } else { |
410 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
410 | + $form_link = '<strong class="gv-form-title">' . esc_html( $form[ 'title' ] ) . '</strong>'; |
|
411 | 411 | } |
412 | 412 | |
413 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
413 | + if ( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
414 | 414 | $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
415 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
415 | + $links[ ] = '<span>' . gravityview_get_link( $entries_url, __( 'Entries', 'gravityview' ) ) . '</span>'; |
|
416 | 416 | } |
417 | 417 | |
418 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
418 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
419 | 419 | $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
420 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
420 | + $links[ ] = '<span>' . gravityview_get_link( $settings_url, __( 'Settings', 'gravityview' ), 'title=' . __( 'Edit settings for this form', 'gravityview' ) ) . '</span>'; |
|
421 | 421 | } |
422 | 422 | |
423 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
423 | + if ( GVCommon::has_cap( array( "gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms" ) ) ) { |
|
424 | 424 | $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
425 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
425 | + $links[ ] = '<span>' . gravityview_get_link( $preview_url, __( 'Preview Form', 'gravityview' ), 'title=' . __( 'Preview this form', 'gravityview' ) ) . '</span>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $output = ''; |
429 | 429 | |
430 | - if( !empty( $include_form_link ) ) { |
|
430 | + if ( ! empty( $include_form_link ) ) { |
|
431 | 431 | $output .= $form_link; |
432 | 432 | } |
433 | 433 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | $links = apply_filters( 'gravityview_connected_form_links', $links, $form ); |
441 | 441 | |
442 | - $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>'; |
|
442 | + $output .= '<div class="row-actions">' . implode( ' | ', $links ) . '</div>'; |
|
443 | 443 | |
444 | 444 | return $output; |
445 | 445 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | // Get the date column and save it for later to add back in. |
454 | 454 | // This adds it after the Data Source column. |
455 | 455 | // This way, we don't need to do array_slice, array_merge, etc. |
456 | - $date = $columns['date']; |
|
457 | - unset( $columns['date'] ); |
|
456 | + $date = $columns[ 'date' ]; |
|
457 | + unset( $columns[ 'date' ] ); |
|
458 | 458 | |
459 | 459 | $data_source_required_caps = array( |
460 | 460 | 'gravityforms_edit_forms', |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | 'gravityforms_preview_forms', |
466 | 466 | ); |
467 | 467 | |
468 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
469 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
468 | + if ( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
469 | + $columns[ 'gv_connected_form' ] = __( 'Data Source', 'gravityview' ); |
|
470 | 470 | } |
471 | 471 | |
472 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
472 | + $columns[ 'gv_template' ] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
473 | 473 | |
474 | 474 | // Add the date back in. |
475 | - $columns['date'] = $date; |
|
475 | + $columns[ 'date' ] = $date; |
|
476 | 476 | |
477 | 477 | return $columns; |
478 | 478 | } |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | function save_postdata( $post_id ) { |
488 | 488 | |
489 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
489 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | 493 | // validate post_type |
494 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
494 | + if ( ! isset( $_POST[ 'post_type' ] ) || 'gravityview' != $_POST[ 'post_type' ] ) { |
|
495 | 495 | return; |
496 | 496 | } |
497 | 497 | |
@@ -506,64 +506,64 @@ discard block |
||
506 | 506 | $statii = array(); |
507 | 507 | |
508 | 508 | // check if this is a start fresh View |
509 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
509 | + if ( isset( $_POST[ 'gravityview_select_form_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_form_nonce' ], 'gravityview_select_form' ) ) { |
|
510 | 510 | |
511 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
511 | + $form_id = ! empty( $_POST[ 'gravityview_form_id' ] ) ? $_POST[ 'gravityview_form_id' ] : ''; |
|
512 | 512 | // save form id |
513 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
513 | + $statii[ 'form_id' ] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
517 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
517 | + if ( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii[ 'form_id' ] ) ) { |
|
518 | 518 | gravityview()->log->error( 'Current user does not have the capability to create a new Form.', array( 'data' => wp_get_current_user() ) ); |
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | 522 | // Was this a start fresh? |
523 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
524 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
523 | + if ( ! empty( $_POST[ 'gravityview_form_id_start_fresh' ] ) ) { |
|
524 | + $statii[ 'start_fresh' ] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
525 | 525 | } else { |
526 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
526 | + $statii[ 'start_fresh' ] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | // Check if we have a template id |
530 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
530 | + if ( isset( $_POST[ 'gravityview_select_template_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_template_nonce' ], 'gravityview_select_template' ) ) { |
|
531 | 531 | |
532 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
532 | + $template_id = ! empty( $_POST[ 'gravityview_directory_template' ] ) ? $_POST[ 'gravityview_directory_template' ] : ''; |
|
533 | 533 | |
534 | 534 | // now save template id |
535 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
535 | + $statii[ 'directory_template' ] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
539 | 539 | // save View Configuration metabox |
540 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
540 | + if ( isset( $_POST[ 'gravityview_view_configuration_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_view_configuration_nonce' ], 'gravityview_view_configuration' ) ) { |
|
541 | 541 | |
542 | 542 | // template settings |
543 | - if( empty( $_POST['template_settings'] ) ) { |
|
544 | - $_POST['template_settings'] = array(); |
|
543 | + if ( empty( $_POST[ 'template_settings' ] ) ) { |
|
544 | + $_POST[ 'template_settings' ] = array(); |
|
545 | 545 | } |
546 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
546 | + $statii[ 'template_settings' ] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST[ 'template_settings' ] ); |
|
547 | 547 | |
548 | 548 | $fields = array(); |
549 | 549 | |
550 | 550 | // Directory&single Visible Fields |
551 | - if( !empty( $preset_fields ) ) { |
|
551 | + if ( ! empty( $preset_fields ) ) { |
|
552 | 552 | |
553 | 553 | $fields = $preset_fields; |
554 | 554 | |
555 | - } elseif( !empty( $_POST['gv_fields'] ) ) { |
|
555 | + } elseif ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
556 | 556 | $fields = _gravityview_process_posted_fields(); |
557 | 557 | } |
558 | 558 | |
559 | 559 | $fields = map_deep( $fields, 'addslashes' ); |
560 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
560 | + $statii[ 'directory_fields' ] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
561 | 561 | |
562 | 562 | // Directory Visible Widgets |
563 | - if( empty( $_POST['widgets'] ) ) { |
|
564 | - $_POST['widgets'] = array(); |
|
563 | + if ( empty( $_POST[ 'widgets' ] ) ) { |
|
564 | + $_POST[ 'widgets' ] = array(); |
|
565 | 565 | } |
566 | - $statii['directory_widgets'] = gravityview_set_directory_widgets( $post_id, $_POST['widgets'] ); |
|
566 | + $statii[ 'directory_widgets' ] = gravityview_set_directory_widgets( $post_id, $_POST[ 'widgets' ] ); |
|
567 | 567 | |
568 | 568 | } // end save view configuration |
569 | 569 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false. |
574 | 574 | * @since 1.17.2 |
575 | 575 | */ |
576 | - do_action('gravityview_view_saved', $post_id, $statii ); |
|
576 | + do_action( 'gravityview_view_saved', $post_id, $statii ); |
|
577 | 577 | |
578 | 578 | gravityview()->log->debug( '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array( 'data' => array_map( 'intval', $statii ) ) ); |
579 | 579 | } |
@@ -617,20 +617,20 @@ discard block |
||
617 | 617 | |
618 | 618 | $output = ''; |
619 | 619 | |
620 | - if( !empty( $fields ) ) { |
|
620 | + if ( ! empty( $fields ) ) { |
|
621 | 621 | |
622 | - foreach( $fields as $id => $details ) { |
|
622 | + foreach ( $fields as $id => $details ) { |
|
623 | 623 | |
624 | - if( in_array( $details['type'], (array) $blacklist_field_types ) ) { |
|
624 | + if ( in_array( $details[ 'type' ], (array)$blacklist_field_types ) ) { |
|
625 | 625 | continue; |
626 | 626 | } |
627 | 627 | |
628 | 628 | // Edit mode only allows editing the parent fields, not single inputs. |
629 | - if( $context === 'edit' && !empty( $details['parent'] ) ) { |
|
629 | + if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) { |
|
630 | 630 | continue; |
631 | 631 | } |
632 | 632 | |
633 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details, $settings = array(), $form ); |
|
633 | + $output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details, $settings = array(), $form ); |
|
634 | 634 | |
635 | 635 | } // End foreach |
636 | 636 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | echo $output; |
639 | 639 | |
640 | 640 | // For the EDIT view we only want to allow the form fields. |
641 | - if( $context === 'edit' ) { |
|
641 | + if ( $context === 'edit' ) { |
|
642 | 642 | return; |
643 | 643 | } |
644 | 644 | |
@@ -662,16 +662,16 @@ discard block |
||
662 | 662 | $additional_fields = apply_filters( 'gravityview_additional_fields', array( |
663 | 663 | array( |
664 | 664 | 'label_text' => __( '+ Add All Fields', 'gravityview' ), |
665 | - 'desc' => __('Add all the available fields at once.', 'gravityview'), |
|
665 | + 'desc' => __( 'Add all the available fields at once.', 'gravityview' ), |
|
666 | 666 | 'field_id' => 'all-fields', |
667 | 667 | 'label_type' => 'field', |
668 | 668 | 'input_type' => NULL, |
669 | 669 | 'field_options' => NULL, |
670 | 670 | 'settings_html' => NULL, |
671 | 671 | ) |
672 | - )); |
|
672 | + ) ); |
|
673 | 673 | |
674 | - if( !empty( $additional_fields )) { |
|
674 | + if ( ! empty( $additional_fields ) ) { |
|
675 | 675 | foreach ( (array)$additional_fields as $item ) { |
676 | 676 | |
677 | 677 | // Prevent items from not having index set |
@@ -682,16 +682,16 @@ discard block |
||
682 | 682 | 'input_type' => NULL, |
683 | 683 | 'field_options' => NULL, |
684 | 684 | 'settings_html' => NULL, |
685 | - )); |
|
685 | + ) ); |
|
686 | 686 | |
687 | 687 | // Backward compat. |
688 | - if( !empty( $item['field_options'] ) ) { |
|
688 | + if ( ! empty( $item[ 'field_options' ] ) ) { |
|
689 | 689 | // Use settings_html from now on. |
690 | - $item['settings_html'] = $item['field_options']; |
|
690 | + $item[ 'settings_html' ] = $item[ 'field_options' ]; |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | // Render a label for each of them |
694 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item, $settings = array(), $form ); |
|
694 | + echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item, $settings = array(), $form ); |
|
695 | 695 | |
696 | 696 | } |
697 | 697 | } |
@@ -704,54 +704,54 @@ discard block |
||
704 | 704 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
705 | 705 | * @return array |
706 | 706 | */ |
707 | - function get_entry_default_fields($form, $zone) { |
|
707 | + function get_entry_default_fields( $form, $zone ) { |
|
708 | 708 | |
709 | 709 | $entry_default_fields = array(); |
710 | 710 | |
711 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
711 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
712 | 712 | |
713 | 713 | $entry_default_fields = array( |
714 | 714 | 'id' => array( |
715 | - 'label' => __('Entry ID', 'gravityview'), |
|
715 | + 'label' => __( 'Entry ID', 'gravityview' ), |
|
716 | 716 | 'type' => 'id', |
717 | - 'desc' => __('The unique ID of the entry.', 'gravityview'), |
|
717 | + 'desc' => __( 'The unique ID of the entry.', 'gravityview' ), |
|
718 | 718 | ), |
719 | 719 | 'date_created' => array( |
720 | - 'label' => __('Entry Date', 'gravityview'), |
|
721 | - 'desc' => __('The date the entry was created.', 'gravityview'), |
|
720 | + 'label' => __( 'Entry Date', 'gravityview' ), |
|
721 | + 'desc' => __( 'The date the entry was created.', 'gravityview' ), |
|
722 | 722 | 'type' => 'date_created', |
723 | 723 | ), |
724 | 724 | 'source_url' => array( |
725 | - 'label' => __('Source URL', 'gravityview'), |
|
725 | + 'label' => __( 'Source URL', 'gravityview' ), |
|
726 | 726 | 'type' => 'source_url', |
727 | - 'desc' => __('The URL of the page where the form was submitted.', 'gravityview'), |
|
727 | + 'desc' => __( 'The URL of the page where the form was submitted.', 'gravityview' ), |
|
728 | 728 | ), |
729 | 729 | 'ip' => array( |
730 | - 'label' => __('User IP', 'gravityview'), |
|
730 | + 'label' => __( 'User IP', 'gravityview' ), |
|
731 | 731 | 'type' => 'ip', |
732 | - 'desc' => __('The IP Address of the user who created the entry.', 'gravityview'), |
|
732 | + 'desc' => __( 'The IP Address of the user who created the entry.', 'gravityview' ), |
|
733 | 733 | ), |
734 | 734 | 'created_by' => array( |
735 | - 'label' => __('User', 'gravityview'), |
|
735 | + 'label' => __( 'User', 'gravityview' ), |
|
736 | 736 | 'type' => 'created_by', |
737 | - 'desc' => __('Details of the logged-in user who created the entry (if any).', 'gravityview'), |
|
737 | + 'desc' => __( 'Details of the logged-in user who created the entry (if any).', 'gravityview' ), |
|
738 | 738 | ), |
739 | 739 | |
740 | 740 | /** |
741 | 741 | * @since 1.7.2 |
742 | 742 | */ |
743 | 743 | 'other_entries' => array( |
744 | - 'label' => __('Other Entries', 'gravityview'), |
|
744 | + 'label' => __( 'Other Entries', 'gravityview' ), |
|
745 | 745 | 'type' => 'other_entries', |
746 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
746 | + 'desc' => __( 'Display other entries created by the entry creator.', 'gravityview' ), |
|
747 | 747 | ), |
748 | 748 | ); |
749 | 749 | |
750 | - if( 'single' !== $zone) { |
|
750 | + if ( 'single' !== $zone ) { |
|
751 | 751 | |
752 | - $entry_default_fields['entry_link'] = array( |
|
753 | - 'label' => __('Link to Entry', 'gravityview'), |
|
754 | - 'desc' => __('A dedicated link to the single entry with customizable text.', 'gravityview'), |
|
752 | + $entry_default_fields[ 'entry_link' ] = array( |
|
753 | + 'label' => __( 'Link to Entry', 'gravityview' ), |
|
754 | + 'desc' => __( 'A dedicated link to the single entry with customizable text.', 'gravityview' ), |
|
755 | 755 | 'type' => 'entry_link', |
756 | 756 | ); |
757 | 757 | } |
@@ -761,10 +761,10 @@ discard block |
||
761 | 761 | /** |
762 | 762 | * @since 1.2 |
763 | 763 | */ |
764 | - $entry_default_fields['custom'] = array( |
|
765 | - 'label' => __('Custom Content', 'gravityview'), |
|
764 | + $entry_default_fields[ 'custom' ] = array( |
|
765 | + 'label' => __( 'Custom Content', 'gravityview' ), |
|
766 | 766 | 'type' => 'custom', |
767 | - 'desc' => __('Insert custom text or HTML.', 'gravityview'), |
|
767 | + 'desc' => __( 'Insert custom text or HTML.', 'gravityview' ), |
|
768 | 768 | ); |
769 | 769 | |
770 | 770 | /** |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | * @param string|array $form form_ID or form object |
774 | 774 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
775 | 775 | */ |
776 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
776 | + return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone ); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | */ |
785 | 785 | function get_available_fields( $form = '', $zone = NULL ) { |
786 | 786 | |
787 | - if( empty( $form ) ) { |
|
787 | + if ( empty( $form ) ) { |
|
788 | 788 | gravityview()->log->error( '$form is empty' ); |
789 | 789 | return array(); |
790 | 790 | } |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | $fields = gravityview_get_form_fields( $form, true ); |
794 | 794 | |
795 | 795 | // get meta fields ( only if form was already created ) |
796 | - if( !is_array( $form ) ) { |
|
796 | + if ( ! is_array( $form ) ) { |
|
797 | 797 | $meta_fields = gravityview_get_entry_meta( $form ); |
798 | 798 | } else { |
799 | 799 | $meta_fields = array(); |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | $fields = $fields + $meta_fields + $default_fields; |
807 | 807 | |
808 | 808 | // Move Custom Content to top |
809 | - $fields = array( 'custom' => $fields['custom'] ) + $fields; |
|
809 | + $fields = array( 'custom' => $fields[ 'custom' ] ) + $fields; |
|
810 | 810 | |
811 | 811 | return $fields; |
812 | 812 | } |
@@ -820,11 +820,11 @@ discard block |
||
820 | 820 | |
821 | 821 | $widgets = $this->get_registered_widgets(); |
822 | 822 | |
823 | - if( !empty( $widgets ) ) { |
|
823 | + if ( ! empty( $widgets ) ) { |
|
824 | 824 | |
825 | - foreach( $widgets as $id => $details ) { |
|
825 | + foreach ( $widgets as $id => $details ) { |
|
826 | 826 | |
827 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
827 | + echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details ); |
|
828 | 828 | |
829 | 829 | } |
830 | 830 | } |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
854 | 854 | global $post; |
855 | 855 | |
856 | - if( $type === 'widget' ) { |
|
856 | + if ( $type === 'widget' ) { |
|
857 | 857 | $button_label = __( 'Add Widget', 'gravityview' ); |
858 | 858 | } else { |
859 | 859 | $button_label = __( 'Add Field', 'gravityview' ); |
@@ -865,10 +865,10 @@ discard block |
||
865 | 865 | $form_id = null; |
866 | 866 | |
867 | 867 | // if saved values, get available fields to label everyone |
868 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
868 | + if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) { |
|
869 | 869 | |
870 | - if( !empty( $_POST['template_id'] ) ) { |
|
871 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
870 | + if ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
871 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
872 | 872 | } else { |
873 | 873 | $form_id = $form = gravityview_get_form_id( $post->ID ); |
874 | 874 | } |
@@ -886,44 +886,44 @@ discard block |
||
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | - foreach( $rows as $row ) : |
|
890 | - foreach( $row as $col => $areas ) : |
|
891 | - $column = ($col == '2-2') ? '1-2' : $col; ?> |
|
889 | + foreach ( $rows as $row ) : |
|
890 | + foreach ( $row as $col => $areas ) : |
|
891 | + $column = ( $col == '2-2' ) ? '1-2' : $col; ?> |
|
892 | 892 | |
893 | 893 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
894 | 894 | |
895 | - <?php foreach( $areas as $area ) : ?> |
|
895 | + <?php foreach ( $areas as $area ) : ?> |
|
896 | 896 | |
897 | - <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
898 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"> |
|
897 | + <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
898 | + <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"> |
|
899 | 899 | |
900 | 900 | <?php // render saved fields |
901 | 901 | |
902 | - if( ! empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
902 | + if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
903 | 903 | |
904 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
904 | + foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) { |
|
905 | 905 | |
906 | 906 | // Maybe has a form ID |
907 | - $form_id = empty( $field['form_id'] ) ? $form_id : $field['form_id']; |
|
907 | + $form_id = empty( $field[ 'form_id' ] ) ? $form_id : $field[ 'form_id' ]; |
|
908 | 908 | |
909 | 909 | $input_type = NULL; |
910 | 910 | |
911 | 911 | if ( $form_id ) { |
912 | - $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
|
912 | + $original_item = isset( $available_items[ $form_id ] [ $field[ 'id' ] ] ) ? $available_items[ $form_id ] [ $field[ 'id' ] ] : false; |
|
913 | 913 | } else { |
914 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
914 | + $original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false; |
|
915 | 915 | } |
916 | 916 | |
917 | - if ( !$original_item ) { |
|
918 | - gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
|
917 | + if ( ! $original_item ) { |
|
918 | + gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array( ' data' => array( 'available_items' => $available_items, 'field' => $field ) ) ); |
|
919 | 919 | |
920 | 920 | $original_item = $field; |
921 | 921 | } else { |
922 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
922 | + $input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | // Field options dialog box |
926 | - $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
926 | + $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field[ 'id' ], $original_item[ 'label' ], $zone . '_' . $area[ 'areaid' ], $input_type, $uniqid, $field, $zone, $original_item ); |
|
927 | 927 | |
928 | 928 | $item = array( |
929 | 929 | 'input_type' => $input_type, |
@@ -936,23 +936,23 @@ discard block |
||
936 | 936 | $item = wp_parse_args( $item, $original_item ); |
937 | 937 | } |
938 | 938 | |
939 | - switch( $type ) { |
|
939 | + switch ( $type ) { |
|
940 | 940 | case 'widget': |
941 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
941 | + echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field ); |
|
942 | 942 | break; |
943 | 943 | default: |
944 | - echo new GravityView_Admin_View_Field( $field['label'], $field['id'], $item, $field, $form_id ); |
|
944 | + echo new GravityView_Admin_View_Field( $field[ 'label' ], $field[ 'id' ], $item, $field, $form_id ); |
|
945 | 945 | } |
946 | 946 | } |
947 | 947 | |
948 | 948 | } // End if zone is not empty ?> |
949 | 949 | |
950 | - <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span> |
|
950 | + <span class="drop-message"><?php echo sprintf( esc_attr__( '"+ %s" or drag existing %ss here.', 'gravityview' ), $button_label, $type ); ?></span> |
|
951 | 951 | </div> |
952 | 952 | <div class="gv-droppable-area-action"> |
953 | - <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>" data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '+ '.esc_html( $button_label ); ?></a> |
|
953 | + <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>" data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '+ ' . esc_html( $button_label ); ?></a> |
|
954 | 954 | |
955 | - <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p> |
|
955 | + <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area[ 'title' ] ); ?></strong><?php if ( ! empty( $area[ 'subtitle' ] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area[ 'subtitle' ] ); ?></span><?php } ?></p> |
|
956 | 956 | </div> |
957 | 957 | </div> |
958 | 958 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | $default_widget_areas = GravityView_Widget::get_default_widget_areas(); |
975 | 975 | |
976 | 976 | $widgets = array(); |
977 | - if( !empty( $post_id ) ) { |
|
977 | + if ( ! empty( $post_id ) ) { |
|
978 | 978 | $widgets = gravityview_get_directory_widgets( $post_id ); |
979 | 979 | } |
980 | 980 | |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | // list of available fields to be shown in the popup |
1008 | 1008 | $forms = gravityview_get_forms( 'any' ); |
1009 | 1009 | |
1010 | - $form_ids = array_map( function ($form) { return $form['id']; }, $forms); |
|
1010 | + $form_ids = array_map( function( $form ) { return $form[ 'id' ]; }, $forms ); |
|
1011 | 1011 | |
1012 | 1012 | foreach ( $form_ids as $form_id ) { |
1013 | 1013 | $filter_field_id = sprintf( 'gv-field-filter-%s-%d', $context, $form_id ); |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | </div> |
1021 | 1021 | |
1022 | 1022 | <div id="available-fields-<?php echo $filter_field_id; ?>" aria-live="polite" role="listbox"> |
1023 | - <?php do_action('gravityview_render_available_fields', $form_id, $context ); ?> |
|
1023 | + <?php do_action( 'gravityview_render_available_fields', $form_id, $context ); ?> |
|
1024 | 1024 | </div> |
1025 | 1025 | |
1026 | 1026 | <div class="gv-no-results hidden description"><?php esc_html_e( 'No fields were found matching the search.', 'gravityview' ); ?></div> |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | * @return string HTML of the active areas |
1040 | 1040 | */ |
1041 | 1041 | function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
1042 | - if( empty( $template_id ) ) { |
|
1042 | + if ( empty( $template_id ) ) { |
|
1043 | 1043 | gravityview()->log->debug( '[render_directory_active_areas] {template_id} is empty', array( 'template_id' => $template_id ) ); |
1044 | 1044 | return ''; |
1045 | 1045 | } |
@@ -1053,12 +1053,12 @@ discard block |
||
1053 | 1053 | */ |
1054 | 1054 | $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
1055 | 1055 | |
1056 | - if( empty( $template_areas ) ) { |
|
1056 | + if ( empty( $template_areas ) ) { |
|
1057 | 1057 | |
1058 | 1058 | gravityview()->log->debug( '[render_directory_active_areas] No areas defined. Maybe template {template_id} is disabled.', array( 'data' => $template_id ) ); |
1059 | 1059 | $output = '<div>'; |
1060 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
1061 | - $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
|
1060 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>' . $template_id . '</em>' ) . '</h2>'; |
|
1061 | + $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__( 'The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview' ) . '</p>'; |
|
1062 | 1062 | $output .= '</div>'; |
1063 | 1063 | } else { |
1064 | 1064 | |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - if( $echo ) { |
|
1076 | + if ( $echo ) { |
|
1077 | 1077 | echo $output; |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1093,26 +1093,26 @@ discard block |
||
1093 | 1093 | $is_widgets_page = ( $pagenow === 'widgets.php' ); |
1094 | 1094 | |
1095 | 1095 | // Add the GV font (with the Astronaut) |
1096 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
1096 | + wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
1097 | 1097 | |
1098 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
1098 | + wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
1099 | 1099 | |
1100 | 1100 | // Don't process any scripts below here if it's not a GravityView page. |
1101 | - if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1101 | + if ( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1102 | 1102 | return; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
1106 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1106 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), GravityView_Plugin::version ); |
|
1107 | 1107 | |
1108 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1108 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
1109 | 1109 | |
1110 | 1110 | //enqueue scripts |
1111 | 1111 | wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
1112 | 1112 | |
1113 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1113 | + wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | 1114 | 'cookiepath' => COOKIEPATH, |
1115 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1115 | + 'passed_form_id' => (bool)\GV\Utils::_GET( 'form_id' ), |
|
1116 | 1116 | 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
1117 | 1117 | 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
1118 | 1118 | 'label_close' => __( 'Close', 'gravityview' ), |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
1125 | 1125 | 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
1126 | 1126 | 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
1127 | - )); |
|
1127 | + ) ); |
|
1128 | 1128 | |
1129 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1129 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | 1130 | |
1131 | 1131 | // Enqueue scripts needed for merge tags |
1132 | 1132 | self::enqueue_gravity_forms_scripts(); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | if ( wp_is_mobile() ) { |
1154 | - $scripts[] = 'jquery-touch-punch'; |
|
1154 | + $scripts[ ] = 'jquery-touch-punch'; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | wp_enqueue_script( $scripts ); |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | // If there's an overriding CSS file in the current template folder, use it. |
33 | 33 | $template_css_path = trailingslashit( get_stylesheet_directory() ) . 'gravityview/css/' . $css_file; |
34 | 34 | |
35 | - if( file_exists( $template_css_path ) ) { |
|
35 | + if ( file_exists( $template_css_path ) ) { |
|
36 | 36 | $path = trailingslashit( get_stylesheet_directory_uri() ) . 'gravityview/css/' . $css_file; |
37 | 37 | gravityview()->log->debug( 'Stylesheet override ({css_file})', array( 'css_file' => esc_attr( $css_file ) ) ); |
38 | 38 | } else { |
39 | 39 | // Default: use GravityView CSS file |
40 | 40 | |
41 | 41 | // If no path is provided, assume default plugin templates CSS folder |
42 | - if( '' === $dir_path ) { |
|
42 | + if ( '' === $dir_path ) { |
|
43 | 43 | $dir_path = GRAVITYVIEW_DIR . 'templates/css/'; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // plugins_url() expects a path to a file, not directory. We append a file to be stripped. |
47 | - $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
47 | + $path = plugins_url( $css_file, trailingslashit( $dir_path ) . 'stripped-by-plugin_basename.php' ); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return $path; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | $parsed_permalink = parse_url( get_permalink( $id ) ); |
84 | 84 | |
85 | - $permalink_args = isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false; |
|
85 | + $permalink_args = isset( $parsed_permalink[ 'query' ] ) ? $parsed_permalink[ 'query' ] : false; |
|
86 | 86 | |
87 | - if( empty( $permalink_args ) ) { |
|
87 | + if ( empty( $permalink_args ) ) { |
|
88 | 88 | return array(); |
89 | 89 | } |
90 | 90 | |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | function gv_selected( $value, $current, $echo = true, $type = 'selected' ) { |
110 | 110 | |
111 | 111 | $output = ''; |
112 | - if( is_array( $current ) ) { |
|
113 | - if( in_array( $value, $current ) ) { |
|
112 | + if ( is_array( $current ) ) { |
|
113 | + if ( in_array( $value, $current ) ) { |
|
114 | 114 | $output = __checked_selected_helper( true, true, false, $type ); |
115 | 115 | } |
116 | 116 | } else { |
117 | 117 | $output = __checked_selected_helper( $value, $current, false, $type ); |
118 | 118 | } |
119 | 119 | |
120 | - if( $echo ) { |
|
120 | + if ( $echo ) { |
|
121 | 121 | echo $output; |
122 | 122 | } |
123 | 123 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | -if( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
128 | +if ( ! function_exists( 'gravityview_sanitize_html_class' ) ) { |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | function gravityview_strip_whitespace( $string ) { |
173 | 173 | $string = normalize_whitespace( $string ); |
174 | - return preg_replace('/[\r\n\t ]+/', ' ', $string ); |
|
174 | + return preg_replace( '/[\r\n\t ]+/', ' ', $string ); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return string Included file contents |
186 | 186 | */ |
187 | 187 | function gravityview_ob_include( $file_path, $object = NULL ) { |
188 | - if( ! file_exists( $file_path ) ) { |
|
188 | + if ( ! file_exists( $file_path ) ) { |
|
189 | 189 | gravityview()->log->error( 'File path does not exist. {path}', array( 'path' => $file_path ) ); |
190 | 190 | return ''; |
191 | 191 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | $width = $height * 0.7586206897; |
211 | 211 | |
212 | - if( function_exists('is_rtl') && is_rtl() ) { |
|
212 | + if ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
213 | 213 | $style = 'margin:10px 10px 10px 0;'; |
214 | 214 | $css_class = is_string( $css_class ) ? $css_class : 'alignright'; |
215 | 215 | } else { |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $css_class = is_string( $css_class ) ? $css_class : 'alignleft'; |
218 | 218 | } |
219 | 219 | |
220 | - return '<img src="'. esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) .'" class="'. gravityview_sanitize_html_class( $css_class ).'" height="'.intval( $height ).'" width="'.round( $width, 2 ).'" alt="The GravityView Astronaut Says:" style="'.$style.'" />'; |
|
220 | + return '<img src="' . esc_url( plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ) ) . '" class="' . gravityview_sanitize_html_class( $css_class ) . '" height="' . intval( $height ) . '" width="' . round( $width, 2 ) . '" alt="The GravityView Astronaut Says:" style="' . $style . '" />'; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | function gravityview_number_format( $number, $decimals = '' ) { |
241 | 241 | global $wp_locale; |
242 | 242 | |
243 | - if( '' === $decimals ) { |
|
243 | + if ( '' === $decimals ) { |
|
244 | 244 | |
245 | - $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.'; |
|
245 | + $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[ 'decimal_point' ] : '.'; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Calculate the position of the decimal point in the number |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $parts = parse_url( $value ); |
272 | 272 | |
273 | 273 | // No domain? Strange...show the original text. |
274 | - if( empty( $parts['host'] ) ) { |
|
274 | + if ( empty( $parts[ 'host' ] ) ) { |
|
275 | 275 | return $value; |
276 | 276 | } |
277 | 277 | |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n |
285 | 285 | * If true: `http://example.com => example.com` |
286 | 286 | */ |
287 | - if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) { |
|
287 | + if ( false === apply_filters( 'gravityview_anchor_text_striphttp', true ) ) { |
|
288 | 288 | |
289 | - if( isset( $parts['scheme'] ) ) { |
|
290 | - $return .= $parts['scheme']; |
|
289 | + if ( isset( $parts[ 'scheme' ] ) ) { |
|
290 | + $return .= $parts[ 'scheme' ]; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | // The domain, which may contain a subdomain |
296 | - $domain = $parts['host']; |
|
296 | + $domain = $parts[ 'host' ]; |
|
297 | 297 | |
298 | 298 | /** |
299 | 299 | * @filter `gravityview_anchor_text_stripwww` Strip www from the domain? |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n |
302 | 302 | * If true: `www.example.com => example.com` |
303 | 303 | */ |
304 | - $strip_www = apply_filters('gravityview_anchor_text_stripwww', true ); |
|
304 | + $strip_www = apply_filters( 'gravityview_anchor_text_stripwww', true ); |
|
305 | 305 | |
306 | - if( $strip_www ) { |
|
307 | - $domain = str_replace('www.', '', $domain ); |
|
306 | + if ( $strip_www ) { |
|
307 | + $domain = str_replace( 'www.', '', $domain ); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * If true: `http://demo.example.com => example.com` \n |
315 | 315 | * If false: `http://demo.example.com => demo.example.com` |
316 | 316 | */ |
317 | - $strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true); |
|
317 | + $strip_subdomains = apply_filters( 'gravityview_anchor_text_nosubdomain', true ); |
|
318 | 318 | |
319 | - if( $strip_subdomains ) { |
|
319 | + if ( $strip_subdomains ) { |
|
320 | 320 | |
321 | - $domain = _gravityview_strip_subdomain( $parts['host'] ); |
|
321 | + $domain = _gravityview_strip_subdomain( $parts[ 'host' ] ); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * If true: `http://example.com/sub/directory/page.html => example.com` \n |
333 | 333 | * If false: `http://example.com/sub/directory/page.html => example.com/sub/directory/page.html` |
334 | 334 | */ |
335 | - $root_only = apply_filters('gravityview_anchor_text_rootonly', true); |
|
335 | + $root_only = apply_filters( 'gravityview_anchor_text_rootonly', true ); |
|
336 | 336 | |
337 | - if( empty( $root_only ) ) { |
|
337 | + if ( empty( $root_only ) ) { |
|
338 | 338 | |
339 | - if( isset( $parts['path'] ) ) { |
|
340 | - $return .= $parts['path']; |
|
339 | + if ( isset( $parts[ 'path' ] ) ) { |
|
340 | + $return .= $parts[ 'path' ]; |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n |
348 | 348 | * If true: `http://example.com/?query=example => example.com` |
349 | 349 | */ |
350 | - $strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true ); |
|
350 | + $strip_query_string = apply_filters( 'gravityview_anchor_text_noquerystring', true ); |
|
351 | 351 | |
352 | - if( empty( $strip_query_string ) ) { |
|
352 | + if ( empty( $strip_query_string ) ) { |
|
353 | 353 | |
354 | - if( isset( $parts['query'] ) ) { |
|
355 | - $return .= '?'.$parts['query']; |
|
354 | + if ( isset( $parts[ 'query' ] ) ) { |
|
355 | + $return .= '?' . $parts[ 'query' ]; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | } |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) { |
371 | 371 | |
372 | - if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
373 | - return $matches['domain']; |
|
372 | + if ( preg_match( "/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) { |
|
373 | + return $matches[ 'domain' ]; |
|
374 | 374 | } else { |
375 | 375 | return $string_maybe_has_subdomain; |
376 | 376 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | |
440 | 440 | if ( in_array( $value, array( 'yes', 'true' ), true ) ) { |
441 | 441 | $value = true; |
442 | - } else if( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
442 | + } else if ( in_array( $value, array( 'no', 'false' ), true ) ) { |
|
443 | 443 | $value = false; |
444 | 444 | } |
445 | 445 | } |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | */ |
469 | 469 | function gv_maybe_json_decode( $value, $assoc = false, $depth = 512, $options = 0 ) { |
470 | 470 | |
471 | - if( ! is_string( $value ) ) { |
|
471 | + if ( ! is_string( $value ) ) { |
|
472 | 472 | return $value; |
473 | 473 | } |
474 | 474 | |
475 | 475 | $decoded = json_decode( $value ); |
476 | 476 | |
477 | 477 | // There was a JSON error (PHP 5.3+) |
478 | - if( function_exists('json_last_error') && JSON_ERROR_NONE !== json_last_error() ) { |
|
478 | + if ( function_exists( 'json_last_error' ) && JSON_ERROR_NONE !== json_last_error() ) { |
|
479 | 479 | return $value; |
480 | 480 | } |
481 | 481 | |
482 | 482 | // It wasn't JSON (PHP < 5.3 fallback) |
483 | - if( is_null( $decoded ) ) { |
|
483 | + if ( is_null( $decoded ) ) { |
|
484 | 484 | return $value; |
485 | 485 | } |
486 | 486 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | |
504 | 504 | // Use the original function, if exists. |
505 | 505 | // Requires WP 4.4+ |
506 | - if( function_exists( 'map_deep') ) { |
|
506 | + if ( function_exists( 'map_deep' ) ) { |
|
507 | 507 | return map_deep( $value, $callback ); |
508 | 508 | } |
509 | 509 | |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | $exploded = explode( '.', "{$field_id}" ); |
570 | 570 | |
571 | - return isset( $exploded[1] ) ? intval( $exploded[1] ) : false; |
|
571 | + return isset( $exploded[ 1 ] ) ? intval( $exploded[ 1 ] ) : false; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | */ |
610 | 610 | $args = apply_filters( 'gravityview_get_terms_choices_args', $args ); |
611 | 611 | |
612 | - $terms = get_terms( $args['taxonomy'], $args ); |
|
612 | + $terms = get_terms( $args[ 'taxonomy' ], $args ); |
|
613 | 613 | |
614 | 614 | $choices = array(); |
615 | 615 | |
616 | 616 | if ( is_array( $terms ) ) { |
617 | 617 | foreach ( $terms as $term_id => $term_name ) { |
618 | - $choices[] = array( |
|
618 | + $choices[ ] = array( |
|
619 | 619 | 'text' => $term_name, |
620 | 620 | 'value' => $term_id |
621 | 621 | ); |
@@ -639,21 +639,21 @@ discard block |
||
639 | 639 | function _gravityview_process_posted_fields() { |
640 | 640 | $fields = array(); |
641 | 641 | |
642 | - if( !empty( $_POST['gv_fields'] ) ) { |
|
643 | - if ( ! is_array( $_POST['gv_fields'] ) ) { |
|
642 | + if ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
643 | + if ( ! is_array( $_POST[ 'gv_fields' ] ) ) { |
|
644 | 644 | |
645 | 645 | // We are not using parse_str() due to max_input_vars limitation with large View configurations |
646 | 646 | $fields_holder = array(); |
647 | - GVCommon::gv_parse_str( $_POST['gv_fields'], $fields_holder ); |
|
647 | + GVCommon::gv_parse_str( $_POST[ 'gv_fields' ], $fields_holder ); |
|
648 | 648 | |
649 | - if ( isset( $fields_holder['fields'] ) ) { |
|
650 | - $fields = $fields_holder['fields']; |
|
649 | + if ( isset( $fields_holder[ 'fields' ] ) ) { |
|
650 | + $fields = $fields_holder[ 'fields' ]; |
|
651 | 651 | } else { |
652 | 652 | gravityview()->log->error( 'No `fields` key was found after parsing $fields string', array( 'data' => $fields_holder ) ); |
653 | 653 | } |
654 | 654 | |
655 | 655 | } else { |
656 | - $fields = $_POST['gv_fields']; |
|
656 | + $fields = $_POST[ 'gv_fields' ]; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @return array |
103 | 103 | */ |
104 | 104 | public function modify_app_settings_menu_title( $setting_tabs ) { |
105 | - $setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview' ); |
|
105 | + $setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' ); |
|
106 | 106 | return $setting_tabs; |
107 | 107 | } |
108 | 108 | |
@@ -308,15 +308,15 @@ discard block |
||
308 | 308 | </ul> |
309 | 309 | <div class="gv-followup widefat"> |
310 | 310 | <p><strong><label for="gv-reason-details"><?php esc_html_e( 'Comments', 'gravityview' ); ?></label></strong></p> |
311 | - <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview') ?>" placeholder="<?php esc_attr_e('Please share your thoughts about GravityView', 'gravityview'); ?>" class="large-text"></textarea> |
|
311 | + <textarea id="gv-reason-details" name="reason_details" data-default="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ) ?>" placeholder="<?php esc_attr_e( 'Please share your thoughts about GravityView', 'gravityview' ); ?>" class="large-text"></textarea> |
|
312 | 312 | </div> |
313 | 313 | <div class="scale-description"> |
314 | 314 | <p><strong><?php esc_html_e( 'How likely are you to recommend GravityView?', 'gravityview' ); ?></strong></p> |
315 | 315 | <ul class="inline"> |
316 | 316 | <?php |
317 | 317 | $i = 0; |
318 | - while( $i < 11 ) { |
|
319 | - echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_'.$i.'" value="'.$i.'" type="radio"> '.$i.'</label></li>'; |
|
318 | + while ( $i < 11 ) { |
|
319 | + echo '<li class="inline number-scale"><label><input name="likely_to_refer" id="likely_to_refer_' . $i . '" value="' . $i . '" type="radio"> ' . $i . '</label></li>'; |
|
320 | 320 | $i++; |
321 | 321 | } |
322 | 322 | ?> |
@@ -533,15 +533,15 @@ discard block |
||
533 | 533 | * @return string The HTML |
534 | 534 | */ |
535 | 535 | public function as_html( $field, $echo = true ) { |
536 | - $field['type'] = ( isset( $field['type'] ) && in_array( $field['type'], array( 'submit','reset','button' ) ) ) ? $field['type'] : 'submit'; |
|
536 | + $field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit'; |
|
537 | 537 | |
538 | 538 | $attributes = $this->get_field_attributes( $field ); |
539 | 539 | $default_value = Utils::get( $field, 'value', Utils::get( $field, 'default_value' ) ); |
540 | - $value = $this->get( $field['name'], $default_value ); |
|
540 | + $value = $this->get( $field[ 'name' ], $default_value ); |
|
541 | 541 | |
542 | 542 | |
543 | - $attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton'; |
|
544 | - $name = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_' . $field['name']; |
|
543 | + $attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton'; |
|
544 | + $name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ]; |
|
545 | 545 | |
546 | 546 | if ( empty( $value ) ) { |
547 | 547 | $value = __( 'Update Settings', 'gravityview' ); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $attributes = $this->get_field_attributes( $field ); |
551 | 551 | |
552 | 552 | $html = '<input |
553 | - type="' . $field['type'] . '" |
|
553 | + type="' . $field[ 'type' ] . '" |
|
554 | 554 | name="' . esc_attr( $name ) . '" |
555 | 555 | value="' . $value . '" ' . |
556 | 556 | implode( ' ', $attributes ) . |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return bool |
582 | 582 | */ |
583 | 583 | public function is_save_postback() { |
584 | - return isset( $_POST['gform-settings-save'] ) && isset( $_POST['_gravityview_save_settings_nonce'] ); |
|
584 | + return isset( $_POST[ 'gform-settings-save' ] ) && isset( $_POST[ '_gravityview_save_settings_nonce' ] ); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | */ |
592 | 592 | public function license_key_notice() { |
593 | 593 | |
594 | - if( $this->is_save_postback() ) { |
|
594 | + if ( $this->is_save_postback() ) { |
|
595 | 595 | $settings = $this->get_posted_settings(); |
596 | 596 | $license_key = \GV\Utils::get( $settings, 'license_key' ); |
597 | 597 | $license_status = \GV\Utils::get( $settings, 'license_key_status', 'inactive' ); |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | * but didn't want to mess up the translation strings for the translators. |
613 | 613 | */ |
614 | 614 | $message = mb_substr( $message, 0, mb_strlen( $message ) - 1 ); |
615 | - $title = __( 'Inactive License', 'gravityview'); |
|
615 | + $title = __( 'Inactive License', 'gravityview' ); |
|
616 | 616 | $status = ''; |
617 | 617 | $update_below = false; |
618 | 618 | $primary_button_link = admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $update_below = __( 'Activate your license key below.', 'gravityview' ); |
643 | 643 | break; |
644 | 644 | } |
645 | - $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice'; |
|
645 | + $url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice'; |
|
646 | 646 | |
647 | 647 | // Show a different notice on settings page for inactive licenses (hide the buttons) |
648 | 648 | if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) { |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | public function scripts() { |
687 | 687 | $scripts = parent::scripts(); |
688 | 688 | |
689 | - $scripts[] = array( |
|
689 | + $scripts[ ] = array( |
|
690 | 690 | 'handle' => 'gform_tooltip_init', |
691 | 691 | 'enqueue' => array( |
692 | 692 | array( |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public function styles() { |
706 | 706 | $styles = parent::styles(); |
707 | 707 | |
708 | - $styles[] = array( |
|
708 | + $styles[ ] = array( |
|
709 | 709 | 'handle' => 'gravityview_settings', |
710 | 710 | 'src' => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ), |
711 | 711 | 'version' => Plugin::$version, |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * If multisite and not network admin, we don't want the settings to show. |
737 | 737 | * @since 1.7.6 |
738 | 738 | */ |
739 | - $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
739 | + $show_submenu = ( ! is_multisite() ) || is_main_site() || ( ! gravityview()->plugin->is_network_activated() ) || ( is_network_admin() && gravityview()->plugin->is_network_activated() ); |
|
740 | 740 | |
741 | 741 | /** |
742 | 742 | * Override whether to show the Settings menu on a per-blog basis. |
@@ -784,26 +784,26 @@ discard block |
||
784 | 784 | 'label' => __( 'License Key', 'gravityview' ), |
785 | 785 | 'description' => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates & support.', 'gravityview' ) . $this->get_license_handler()->license_details( $this->get_app_setting( 'license_key_response' ) ), |
786 | 786 | 'type' => 'edd_license', |
787 | - 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
787 | + 'disabled' => ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ), |
|
788 | 788 | 'data-pending-text' => __( 'Verifying license…', 'gravityview' ), |
789 | - 'default_value' => $default_settings['license_key'], |
|
789 | + 'default_value' => $default_settings[ 'license_key' ], |
|
790 | 790 | 'class' => ( '' == $this->get( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key', |
791 | 791 | ), |
792 | 792 | array( |
793 | 793 | 'name' => 'license_key_response', |
794 | - 'default_value' => $default_settings['license_key_response'], |
|
794 | + 'default_value' => $default_settings[ 'license_key_response' ], |
|
795 | 795 | 'type' => 'hidden', |
796 | 796 | ), |
797 | 797 | array( |
798 | 798 | 'name' => 'license_key_status', |
799 | - 'default_value' => $default_settings['license_key_status'], |
|
799 | + 'default_value' => $default_settings[ 'license_key_status' ], |
|
800 | 800 | 'type' => 'hidden', |
801 | 801 | ), |
802 | 802 | array( |
803 | 803 | 'name' => 'support-email', |
804 | 804 | 'type' => 'text', |
805 | 805 | 'validate' => 'email', |
806 | - 'default_value' => $default_settings['support-email'], |
|
806 | + 'default_value' => $default_settings[ 'support-email' ], |
|
807 | 807 | 'label' => __( 'Support Email', 'gravityview' ), |
808 | 808 | 'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ), |
809 | 809 | 'class' => 'code regular-text', |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | 'name' => 'support_port', |
816 | 816 | 'type' => 'radio', |
817 | 817 | 'label' => __( 'Show Support Port?', 'gravityview' ), |
818 | - 'default_value' => $default_settings['support_port'], |
|
818 | + 'default_value' => $default_settings[ 'support_port' ], |
|
819 | 819 | 'horizontal' => 1, |
820 | 820 | 'choices' => array( |
821 | 821 | array( |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'name' => 'no-conflict-mode', |
835 | 835 | 'type' => 'radio', |
836 | 836 | 'label' => __( 'No-Conflict Mode', 'gravityview' ), |
837 | - 'default_value' => $default_settings['no-conflict-mode'], |
|
837 | + 'default_value' => $default_settings[ 'no-conflict-mode' ], |
|
838 | 838 | 'horizontal' => 1, |
839 | 839 | 'choices' => array( |
840 | 840 | array( |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | 'name' => 'rest_api', |
857 | 857 | 'type' => 'radio', |
858 | 858 | 'label' => __( 'REST API', 'gravityview' ), |
859 | - 'default_value' => $default_settings['rest_api'], |
|
859 | + 'default_value' => $default_settings[ 'rest_api' ], |
|
860 | 860 | 'horizontal' => 1, |
861 | 861 | 'choices' => array( |
862 | 862 | array( |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'name' => 'beta', |
876 | 876 | 'type' => 'checkbox', |
877 | 877 | 'label' => __( 'Become a Beta Tester', 'gravityview' ), |
878 | - 'default_value' => $default_settings['beta'], |
|
878 | + 'default_value' => $default_settings[ 'beta' ], |
|
879 | 879 | 'horizontal' => 1, |
880 | 880 | 'choices' => array( |
881 | 881 | array( |
@@ -908,17 +908,17 @@ discard block |
||
908 | 908 | * @since 1.7.4 |
909 | 909 | */ |
910 | 910 | foreach ( $fields as &$field ) { |
911 | - $field['name'] = isset( $field['name'] ) ? $field['name'] : Utils::get( $field, 'id' ); |
|
912 | - $field['label'] = isset( $field['label'] ) ? $field['label'] : Utils::get( $field, 'title' ); |
|
913 | - $field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : Utils::get( $field, 'default' ); |
|
914 | - $field['description'] = isset( $field['description'] ) ? $field['description'] : Utils::get( $field, 'subtitle' ); |
|
911 | + $field[ 'name' ] = isset( $field[ 'name' ] ) ? $field[ 'name' ] : Utils::get( $field, 'id' ); |
|
912 | + $field[ 'label' ] = isset( $field[ 'label' ] ) ? $field[ 'label' ] : Utils::get( $field, 'title' ); |
|
913 | + $field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : Utils::get( $field, 'default' ); |
|
914 | + $field[ 'description' ] = isset( $field[ 'description' ] ) ? $field[ 'description' ] : Utils::get( $field, 'subtitle' ); |
|
915 | 915 | |
916 | 916 | if ( $disabled_attribute ) { |
917 | - $field['disabled'] = $disabled_attribute; |
|
917 | + $field[ 'disabled' ] = $disabled_attribute; |
|
918 | 918 | } |
919 | 919 | |
920 | - if ( empty( $field['disabled'] ) ) { |
|
921 | - unset( $field['disabled'] ); |
|
920 | + if ( empty( $field[ 'disabled' ] ) ) { |
|
921 | + unset( $field[ 'disabled' ] ); |
|
922 | 922 | } |
923 | 923 | } |
924 | 924 | |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | ); |
937 | 937 | |
938 | 938 | if ( $disabled_attribute ) { |
939 | - $button['disabled'] = $disabled_attribute; |
|
939 | + $button[ 'disabled' ] = $disabled_attribute; |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -955,20 +955,20 @@ discard block |
||
955 | 955 | // If there are extensions, add a section for them |
956 | 956 | if ( ! empty( $extension_sections ) ) { |
957 | 957 | |
958 | - if( $disabled_attribute ) { |
|
958 | + if ( $disabled_attribute ) { |
|
959 | 959 | foreach ( $extension_sections as &$section ) { |
960 | - foreach ( $section['fields'] as &$field ) { |
|
961 | - $field['disabled'] = $disabled_attribute; |
|
960 | + foreach ( $section[ 'fields' ] as &$field ) { |
|
961 | + $field[ 'disabled' ] = $disabled_attribute; |
|
962 | 962 | } |
963 | 963 | } |
964 | 964 | } |
965 | 965 | |
966 | - $k = count( $extension_sections ) - 1 ; |
|
967 | - $extension_sections[ $k ]['fields'][] = $button; |
|
966 | + $k = count( $extension_sections ) - 1; |
|
967 | + $extension_sections[ $k ][ 'fields' ][ ] = $button; |
|
968 | 968 | $sections = array_merge( $sections, $extension_sections ); |
969 | 969 | } else { |
970 | 970 | // add the 'update settings' button to the general section |
971 | - $sections[0]['fields'][] = $button; |
|
971 | + $sections[ 0 ][ 'fields' ][ ] = $button; |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | return $sections; |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | protected function settings_edd_license( $field, $echo = true ) { |
1025 | 1025 | |
1026 | 1026 | if ( defined( 'GRAVITYVIEW_LICENSE_KEY' ) && GRAVITYVIEW_LICENSE_KEY ) { |
1027 | - $field['input_type'] = 'password'; |
|
1027 | + $field[ 'input_type' ] = 'password'; |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $text = $this->settings_text( $field, false ); |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | public function single_setting_row_html( $field ) { |
1074 | 1074 | ?> |
1075 | 1075 | |
1076 | - <tr id="gaddon-setting-row-<?php echo esc_attr( $field['name'] ); ?>"> |
|
1076 | + <tr id="gaddon-setting-row-<?php echo esc_attr( $field[ 'name' ] ); ?>"> |
|
1077 | 1077 | <td colspan="2"> |
1078 | 1078 | <?php $this->single_setting( $field ); ?> |
1079 | 1079 | </td> |
@@ -1091,10 +1091,10 @@ discard block |
||
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | 1093 | public function settings_save( $field, $echo = true ) { |
1094 | - $field['type'] = 'submit'; |
|
1095 | - $field['name'] = 'gform-settings-save'; |
|
1096 | - $field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton'; |
|
1097 | - $field['value'] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
1094 | + $field[ 'type' ] = 'submit'; |
|
1095 | + $field[ 'name' ] = 'gform-settings-save'; |
|
1096 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton'; |
|
1097 | + $field[ 'value' ] = Utils::get( $field, 'value', __( 'Update Settings', 'gravityview' ) ); |
|
1098 | 1098 | |
1099 | 1099 | $output = $this->settings_submit( $field, false ); |
1100 | 1100 | |
@@ -1125,8 +1125,8 @@ discard block |
||
1125 | 1125 | * @return void |
1126 | 1126 | */ |
1127 | 1127 | public function single_setting_row( $field ) { |
1128 | - $field['gv_description'] = Utils::get( $field, 'description' ); |
|
1129 | - $field['description'] = Utils::get( $field, 'subtitle' ); |
|
1128 | + $field[ 'gv_description' ] = Utils::get( $field, 'description' ); |
|
1129 | + $field[ 'description' ] = Utils::get( $field, 'subtitle' ); |
|
1130 | 1130 | parent::single_setting_row( $field ); |
1131 | 1131 | } |
1132 | 1132 | |
@@ -1138,7 +1138,7 @@ discard block |
||
1138 | 1138 | public function single_setting_label( $field ) { |
1139 | 1139 | parent::single_setting_label( $field ); |
1140 | 1140 | if ( $description = Utils::get( $field, 'gv_description' ) ) { |
1141 | - echo '<span class="description">'. $description .'</span>'; |
|
1141 | + echo '<span class="description">' . $description . '</span>'; |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1175,9 +1175,9 @@ discard block |
||
1175 | 1175 | // If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response), |
1176 | 1176 | // then we assume it's changed. If it's changed, unset the status and the previous response. |
1177 | 1177 | if ( $local_key !== $response_key ) { |
1178 | - unset( $posted_settings['license_key_response'] ); |
|
1179 | - unset( $posted_settings['license_key_status'] ); |
|
1180 | - \GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
1178 | + unset( $posted_settings[ 'license_key_response' ] ); |
|
1179 | + unset( $posted_settings[ 'license_key_status' ] ); |
|
1180 | + \GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) ); |
|
1181 | 1181 | } |
1182 | 1182 | return $posted_settings; |
1183 | 1183 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | return false; |
24 | 24 | } |
25 | 25 | |
26 | - if( ! function_exists( '\get_current_screen' ) ) { |
|
26 | + if ( ! function_exists( '\get_current_screen' ) ) { |
|
27 | 27 | return false; |
28 | 28 | } |
29 | 29 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - $context = $args[1]; |
|
37 | + $context = $args[ 1 ]; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Assume false by default. |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $is_page = 'single'; |
51 | 51 | } else if ( $is_gv_settings = 'gravityview_page_gravityview_settings' === $current_screen->id ) { |
52 | 52 | $is_page = 'settings'; |
53 | - } else if( $is_extensions = 'gravityview_page_gv-admin-installer' === $current_screen->id ) { |
|
53 | + } else if ( $is_extensions = 'gravityview_page_gv-admin-installer' === $current_screen->id ) { |
|
54 | 54 | $is_page = 'downloads'; |
55 | 55 | } |
56 | 56 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) |
61 | 61 | * @param[in] string $hook The name of the page to check against. Is passed to the method. |
62 | 62 | */ |
63 | - $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $args[0] ); |
|
63 | + $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $args[ 0 ] ); |
|
64 | 64 | |
65 | 65 | // If the current page is the same as the compared page |
66 | 66 | if ( ! empty( $context ) ) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ); |
101 | 101 | |
102 | 102 | if ( ! empty( $action ) ) { |
103 | - $settings['edd_action'] = esc_attr( $action ); |
|
103 | + $settings[ 'edd_action' ] = esc_attr( $action ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | return array_map( 'urlencode', $settings ); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'format' => 'json', |
157 | 157 | ) ); |
158 | 158 | |
159 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
159 | + if ( $is_ajax && empty( $data[ 'license' ] ) ) { |
|
160 | 160 | die( -1 ); |
161 | 161 | } |
162 | 162 | |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | $json = json_encode( $license_data ); |
186 | 186 | |
187 | - $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST('action'); |
|
187 | + $update_license = Utils::get( $data, 'update' ) || 'gravityview_license' === Utils::_POST( 'action' ); |
|
188 | 188 | |
189 | 189 | $is_check_action_button = ( 'check_license' === Utils::get( $data, 'edd_action' ) && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
190 | 190 | |
191 | 191 | if ( 'deactivate_license' === Utils::get( $data, 'edd_action' ) ) { |
192 | - do_action('gravityview/admin_installer/delete_downloads_data', true ); |
|
192 | + do_action( 'gravityview/admin_installer/delete_downloads_data', true ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | if ( $is_check_action_button ) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | // most likely a mistake. |
202 | 202 | } else if ( $license_data->license !== 'failed' && $update_license ) { |
203 | 203 | |
204 | - if ( ! empty( $data['field_id'] ) ) { |
|
204 | + if ( ! empty( $data[ 'field_id' ] ) ) { |
|
205 | 205 | set_transient( self::status_transient_key, $license_data, DAY_IN_SECONDS ); |
206 | 206 | } |
207 | 207 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | if ( empty( $license_data ) ) { |
229 | 229 | $message = ''; |
230 | 230 | } else { |
231 | - if( ! empty( $license_data->error ) ) { |
|
231 | + if ( ! empty( $license_data->error ) ) { |
|
232 | 232 | $class = 'error'; |
233 | 233 | $string_key = $license_data->error; |
234 | 234 | } else { $class = $license_data->license; |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function license_details( $response = array() ) { |
256 | 256 | |
257 | - $response = (array) $response; |
|
257 | + $response = (array)$response; |
|
258 | 258 | |
259 | 259 | $return = ''; |
260 | 260 | $wrapper = '<span class="gv-license-details" aria-live="polite" aria-busy="false">%s</span>'; |
261 | 261 | |
262 | - if ( ! empty( $response['license_key'] ) ) { |
|
262 | + if ( ! empty( $response[ 'license_key' ] ) ) { |
|
263 | 263 | $return .= '<h3>' . esc_html__( 'License Details:', 'gravityview' ) . '</h3>'; |
264 | 264 | |
265 | 265 | if ( in_array( Utils::get( $response, 'license' ), array( 'invalid', 'deactivated' ) ) ) { |
266 | - $return .= $this->strings( $response['license'], $response ); |
|
267 | - } elseif ( ! empty( $response['license_name'] ) ) { |
|
266 | + $return .= $this->strings( $response[ 'license' ], $response ); |
|
267 | + } elseif ( ! empty( $response[ 'license_name' ] ) ) { |
|
268 | 268 | $response_keys = array( |
269 | 269 | 'license_name' => '', |
270 | 270 | 'license_limit' => '', |
@@ -278,19 +278,19 @@ discard block |
||
278 | 278 | // Make sure all the keys are set |
279 | 279 | $response = wp_parse_args( $response, $response_keys ); |
280 | 280 | |
281 | - $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' ) ); |
|
282 | - $local_text = ( ! empty( $response['is_local'] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
281 | + $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' ) ); |
|
282 | + $local_text = ( ! empty( $response[ 'is_local' ] ) ? '<span class="howto">' . __( 'This development site does not count toward license activation limits', 'gravityview' ) . '</span>' : '' ); |
|
283 | 283 | $details = array( |
284 | - 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response['license_name'] ), esc_html( $response['license_limit'] ) ), |
|
285 | - '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, |
|
286 | - 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response['site_count'] ), esc_html( $response['license_limit'] ) ) . $local_text, |
|
287 | - 'expires' => 'lifetime' === $response['expires'] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response['expires'] ) - DAY_IN_SECONDS ) ), |
|
288 | - 'upgrade' => $this->get_upgrade_html( $response['upgrades'] ), |
|
284 | + 'license' => sprintf( esc_html__( 'License level: %s', 'gravityview' ), esc_html( $response[ 'license_name' ] ), esc_html( $response[ 'license_limit' ] ) ), |
|
285 | + '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, |
|
286 | + 'activations' => sprintf( esc_html__( 'Activations: %d of %s sites', 'gravityview' ), intval( $response[ 'site_count' ] ), esc_html( $response[ 'license_limit' ] ) ) . $local_text, |
|
287 | + 'expires' => 'lifetime' === $response[ 'expires' ] ? '' : sprintf( esc_html__( 'Renew on: %s', 'gravityview' ), date_i18n( get_option( 'date_format' ), strtotime( $response[ 'expires' ] ) - DAY_IN_SECONDS ) ), |
|
288 | + 'upgrade' => $this->get_upgrade_html( $response[ 'upgrades' ] ), |
|
289 | 289 | ); |
290 | 290 | |
291 | - if ( ! empty( $response['error'] ) && 'expired' === $response['error'] ) { |
|
292 | - unset( $details['upgrade'] ); |
|
293 | - $details['expires'] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
291 | + if ( ! empty( $response[ 'error' ] ) && 'expired' === $response[ 'error' ] ) { |
|
292 | + unset( $details[ 'upgrade' ] ); |
|
293 | + $details[ 'expires' ] = '<div class="error inline"><p>' . $this->strings( 'expired', $response ) . '</p></div>'; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $return .= '<ul><li>' . implode( '</li><li>', array_filter( $details ) ) . '</li></ul>'; |
@@ -316,20 +316,20 @@ discard block |
||
316 | 316 | if ( ! empty( $upgrades ) ) { |
317 | 317 | |
318 | 318 | $locale_parts = explode( '_', get_locale() ); |
319 | - $is_english = ( 'en' === $locale_parts[0] ); |
|
319 | + $is_english = ( 'en' === $locale_parts[ 0 ] ); |
|
320 | 320 | |
321 | 321 | $output .= '<h4>' . esc_html__( 'Upgrades available:', 'gravityview' ) . '</h4>'; |
322 | 322 | $output .= '<ul class="ul-disc">'; |
323 | 323 | |
324 | 324 | foreach ( $upgrades as $upgrade_id => $upgrade ) { |
325 | - $upgrade = (object) $upgrade; |
|
325 | + $upgrade = (object)$upgrade; |
|
326 | 326 | |
327 | 327 | $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 ) ); |
328 | 328 | |
329 | 329 | if ( $is_english && isset( $upgrade->description ) ) { |
330 | 330 | $message = esc_html( $upgrade->description ); |
331 | 331 | } else { |
332 | - switch( $upgrade->price_id ) { |
|
332 | + switch ( $upgrade->price_id ) { |
|
333 | 333 | // Interstellar |
334 | 334 | case 1: |
335 | 335 | default: |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | 'invalid' => esc_html__( 'The license key entered is invalid.', 'gravityview' ), |
389 | 389 | 'missing' => esc_html__( 'Invalid license key.', 'gravityview' ), |
390 | 390 | 'revoked' => esc_html__( 'This license key has been revoked.', 'gravityview' ), |
391 | - '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>' ), |
|
391 | + '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>' ), |
|
392 | 392 | 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
393 | 393 | |
394 | 394 | 'verifying_license' => esc_html__( 'Verifying license…', 'gravityview' ), |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | if ( ! empty( $license_data->renewal_url ) ) { |
419 | 419 | $renew_license_url = $license_data->renewal_url; |
420 | - } elseif( ! empty( $license_data->license_key ) ) { |
|
420 | + } elseif ( ! empty( $license_data->license_key ) ) { |
|
421 | 421 | $renew_license_url = sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s', $license_data->license_key ); |
422 | 422 | } else { |
423 | 423 | $renew_license_url = 'https://gravityview.co/account/'; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * @return array|\WP_Error |
435 | 435 | */ |
436 | 436 | private function _license_get_remote_response( $data, $license = '' ) { |
437 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
437 | + $api_params = $this->_get_edd_settings( $data[ 'edd_action' ], $license ); |
|
438 | 438 | |
439 | 439 | $url = add_query_arg( $api_params, self::url ); |
440 | 440 | |
@@ -474,9 +474,9 @@ discard block |
||
474 | 474 | private function license_call_update_settings( $license_data, $data ) { |
475 | 475 | $settings = array(); |
476 | 476 | |
477 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
478 | - $settings['license_key_status'] = $license_data->license; |
|
479 | - $settings['license_key_response'] = (array)$license_data; |
|
477 | + $settings[ 'license_key' ] = $license_data->license_key = trim( $data[ 'license' ] ); |
|
478 | + $settings[ 'license_key_status' ] = $license_data->license; |
|
479 | + $settings[ 'license_key_response' ] = (array)$license_data; |
|
480 | 480 | |
481 | 481 | $this->settings->set( $settings ); |
482 | 482 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | |
492 | 492 | if ( ! empty( $key ) ) { |
493 | 493 | $response = $this->settings->get( 'license_key_response' ); |
494 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
494 | + $response = is_array( $response ) ? (object)$response : json_decode( $response ); |
|
495 | 495 | } else { |
496 | 496 | $response = array(); |
497 | 497 | } |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | |
534 | 534 | $submit = '<div class="gv-edd-button-wrapper">'; |
535 | 535 | foreach ( $fields as $field ) { |
536 | - $field['type'] = 'button'; |
|
537 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
538 | - $field['style'] = 'margin-left: 10px;'; |
|
539 | - if( $disabled_attribute ) { |
|
540 | - $field['disabled'] = $disabled_attribute; |
|
536 | + $field[ 'type' ] = 'button'; |
|
537 | + $field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] . ' ' . $class : $class; |
|
538 | + $field[ 'style' ] = 'margin-left: 10px;'; |
|
539 | + if ( $disabled_attribute ) { |
|
540 | + $field[ 'disabled' ] = $disabled_attribute; |
|
541 | 541 | } |
542 | 542 | $submit .= $this->settings->as_html( $field, $echo ); |
543 | 543 | } |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | 'url' => home_url(), |
617 | 617 | 'site_data' => $this->get_site_data(), |
618 | 618 | ), |
619 | - )); |
|
619 | + ) ); |
|
620 | 620 | |
621 | 621 | // make sure the response came back okay |
622 | 622 | if ( is_wp_error( $response ) ) { |
@@ -647,45 +647,45 @@ discard block |
||
647 | 647 | $theme_data = wp_get_theme(); |
648 | 648 | $theme = $theme_data->Name . ' ' . $theme_data->Version; |
649 | 649 | |
650 | - $data['gv_version'] = Plugin::$version; |
|
651 | - $data['php_version'] = phpversion(); |
|
652 | - $data['wp_version'] = get_bloginfo( 'version' ); |
|
653 | - $data['gf_version'] = \GFForms::$version; |
|
654 | - $data['server'] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
655 | - $data['multisite'] = is_multisite(); |
|
656 | - $data['theme'] = $theme; |
|
657 | - $data['url'] = home_url(); |
|
658 | - $data['license_key'] = $this->settings->get( 'license_key' ); |
|
659 | - $data['beta'] = $this->settings->get( 'beta' ); |
|
650 | + $data[ 'gv_version' ] = Plugin::$version; |
|
651 | + $data[ 'php_version' ] = phpversion(); |
|
652 | + $data[ 'wp_version' ] = get_bloginfo( 'version' ); |
|
653 | + $data[ 'gf_version' ] = \GFForms::$version; |
|
654 | + $data[ 'server' ] = Utils::get( $_SERVER, 'SERVER_SOFTWARE' ); |
|
655 | + $data[ 'multisite' ] = is_multisite(); |
|
656 | + $data[ 'theme' ] = $theme; |
|
657 | + $data[ 'url' ] = home_url(); |
|
658 | + $data[ 'license_key' ] = $this->settings->get( 'license_key' ); |
|
659 | + $data[ 'beta' ] = $this->settings->get( 'beta' ); |
|
660 | 660 | |
661 | 661 | // View Data |
662 | 662 | $gravityview_posts = wp_count_posts( 'gravityview', 'readable' ); |
663 | 663 | |
664 | - $data['view_count'] = null; |
|
665 | - $data['view_first'] = null; |
|
666 | - $data['view_latest'] = null; |
|
664 | + $data[ 'view_count' ] = null; |
|
665 | + $data[ 'view_first' ] = null; |
|
666 | + $data[ 'view_latest' ] = null; |
|
667 | 667 | |
668 | 668 | if ( $gravityview_posts->publish ) { |
669 | - $data['view_count'] = $gravityview_posts->publish; |
|
669 | + $data[ 'view_count' ] = $gravityview_posts->publish; |
|
670 | 670 | |
671 | 671 | $first = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=ASC' ); |
672 | 672 | $latest = get_posts( 'numberposts=1&post_type=gravityview&post_status=publish&order=DESC' ); |
673 | 673 | |
674 | 674 | if ( $first = array_shift( $first ) ) { |
675 | - $data['view_first'] = $first->post_date; |
|
675 | + $data[ 'view_first' ] = $first->post_date; |
|
676 | 676 | } |
677 | 677 | if ( $latest = array_pop( $latest ) ) { |
678 | - $data['view_latest'] = $latest->post_date; |
|
678 | + $data[ 'view_latest' ] = $latest->post_date; |
|
679 | 679 | } |
680 | 680 | } |
681 | 681 | |
682 | 682 | // Form counts |
683 | 683 | if ( class_exists( 'GFFormsModel' ) ) { |
684 | 684 | $form_data = \GFFormsModel::get_form_count(); |
685 | - $data['forms_total'] = Utils::get( $form_data, 'total', 0 ); |
|
686 | - $data['forms_active'] = Utils::get( $form_data, 'active', 0 ); |
|
687 | - $data['forms_inactive'] = Utils::get( $form_data, 'inactive', 0 ); |
|
688 | - $data['forms_trash'] = Utils::get( $form_data, 'inactive', 0 ); |
|
685 | + $data[ 'forms_total' ] = Utils::get( $form_data, 'total', 0 ); |
|
686 | + $data[ 'forms_active' ] = Utils::get( $form_data, 'active', 0 ); |
|
687 | + $data[ 'forms_inactive' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
688 | + $data[ 'forms_trash' ] = Utils::get( $form_data, 'inactive', 0 ); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | // Retrieve current plugin information |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
694 | 694 | } |
695 | 695 | |
696 | - $data['integrations'] = self::get_related_plugins_and_extensions(); |
|
697 | - $data['active_plugins'] = get_option( 'active_plugins', array() ); |
|
698 | - $data['inactive_plugins'] = array(); |
|
699 | - $data['locale'] = get_locale(); |
|
696 | + $data[ 'integrations' ] = self::get_related_plugins_and_extensions(); |
|
697 | + $data[ 'active_plugins' ] = get_option( 'active_plugins', array() ); |
|
698 | + $data[ 'inactive_plugins' ] = array(); |
|
699 | + $data[ 'locale' ] = get_locale(); |
|
700 | 700 | |
701 | 701 | // Validate request on the GV server |
702 | - $data['hash'] = 'gv_version.url.locale:' . sha1( $data['gv_version'] . $data['url'] . $data['locale'] ); |
|
702 | + $data[ 'hash' ] = 'gv_version.url.locale:' . sha1( $data[ 'gv_version' ] . $data[ 'url' ] . $data[ 'locale' ] ); |
|
703 | 703 | |
704 | 704 | return $data; |
705 | 705 | } |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | |
730 | 730 | $plugin_data = get_plugin_data( $active_plugin ); |
731 | 731 | |
732 | - $extensions[] = sprintf( '%s %s', $plugin_data['Name'], $plugin_data['Version'] ); |
|
732 | + $extensions[ ] = sprintf( '%s %s', $plugin_data[ 'Name' ], $plugin_data[ 'Version' ] ); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | if ( ! empty( $extensions ) ) { |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | 'detail' => null, |
42 | 42 | ) ); |
43 | 43 | |
44 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
45 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
44 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
45 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
46 | 46 | $view_id = $view->ID; |
47 | 47 | } |
48 | 48 | } |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
114 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
114 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
115 | 115 | |
116 | 116 | /** |
117 | 117 | * View details. |
118 | 118 | */ |
119 | - if ( $atts['detail'] ) { |
|
119 | + if ( $atts[ 'detail' ] ) { |
|
120 | 120 | return self::_return( $this->detail( $view, $entries, $atts ) ); |
121 | 121 | |
122 | 122 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return self::_return( '' ); |
133 | 133 | } |
134 | 134 | |
135 | - if ( $entry['status'] != 'active' ) { |
|
135 | + if ( $entry[ 'status' ] != 'active' ) { |
|
136 | 136 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
137 | 137 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
138 | 138 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
146 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
146 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
147 | 147 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
148 | 148 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
149 | 149 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return self::_return( '' ); |
164 | 164 | } |
165 | 165 | |
166 | - if ( $entry['status'] != 'active' ) { |
|
166 | + if ( $entry[ 'status' ] != 'active' ) { |
|
167 | 167 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
168 | 168 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
169 | 169 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
177 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
177 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
178 | 178 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
179 | 179 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
180 | 180 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | $error = \GVCommon::check_entry_display( $entry->as_entry() ); |
184 | 184 | |
185 | - if( is_wp_error( $error ) ) { |
|
185 | + if ( is_wp_error( $error ) ) { |
|
186 | 186 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing: {message}', array( 'entry_id' => $entry->ID, 'message' => $error->get_error_message() ) ); |
187 | 187 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
188 | 188 | } |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | |
199 | 199 | // Mock the request with the actual View, not the global one |
200 | 200 | $mock_request = new \GV\Mock_Request(); |
201 | - $mock_request->returns['is_view'] = $view; |
|
202 | - $mock_request->returns['is_entry'] = $request->is_entry(); |
|
203 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry(); |
|
204 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
201 | + $mock_request->returns[ 'is_view' ] = $view; |
|
202 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry(); |
|
203 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry(); |
|
204 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
205 | 205 | |
206 | 206 | $request = $mock_request; |
207 | 207 | } |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
238 | 238 | |
239 | 239 | // Only keep the passed attributes after making sure that they're valid pairs |
240 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
240 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
241 | 241 | |
242 | 242 | $atts = array(); |
243 | 243 | |
244 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
244 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
245 | 245 | |
246 | 246 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
247 | 247 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
248 | 248 | |
249 | - switch( $defaults[ $key ]['type'] ) { |
|
249 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Make sure number fields are numeric. |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
255 | 255 | */ |
256 | 256 | case 'number': |
257 | - if( is_numeric( $passed_value ) ) { |
|
257 | + if ( is_numeric( $passed_value ) ) { |
|
258 | 258 | $atts[ $key ] = ( $passed_value + 0 ); |
259 | 259 | } |
260 | 260 | break; |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | */ |
270 | 270 | case 'select': |
271 | 271 | case 'radio': |
272 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
273 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
272 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
273 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
274 | 274 | $atts[ $key ] = $passed_value; |
275 | 275 | } |
276 | 276 | break; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | |
285 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
285 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
286 | 286 | |
287 | 287 | return $atts; |
288 | 288 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | private function detail( $view, $entries, $atts ) { |
300 | 300 | $output = ''; |
301 | 301 | |
302 | - switch ( $key = $atts['detail'] ): |
|
302 | + switch ( $key = $atts[ 'detail' ] ): |
|
303 | 303 | case 'total_entries': |
304 | 304 | $output = number_format_i18n( $entries->total() ); |
305 | 305 | break; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | $format = '(?:\.(?P<format>html|json))?'; |
134 | 134 | |
135 | - register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ) , array( |
|
135 | + register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ), array( |
|
136 | 136 | array( |
137 | 137 | 'methods' => \WP_REST_Server::READABLE, |
138 | 138 | 'callback' => array( $this, 'get_sub_item' ), |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return \WP_REST_Response |
384 | 384 | */ |
385 | 385 | protected function not_implemented( ) { |
386 | - $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
386 | + $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
387 | 387 | return new \WP_REST_Response( $error, 501 ); |
388 | 388 | } |
389 | 389 |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | // Multiple Views embedded, don't proceed if nonce fails |
244 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
244 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
245 | 245 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
246 | 246 | return; |
247 | 247 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | private function process_save( $gv_data ) { |
288 | 288 | |
289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 | |
293 | 293 | // Make sure the entry, view, and form IDs are all correct |
294 | 294 | $valid = $this->verify_nonce(); |
295 | 295 | |
296 | - if ( !$valid ) { |
|
296 | + if ( ! $valid ) { |
|
297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
303 | 303 | return; |
304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $this->validate(); |
311 | 311 | |
312 | - if( $this->is_valid ) { |
|
312 | + if ( $this->is_valid ) { |
|
313 | 313 | |
314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | /** |
322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
323 | 323 | */ |
324 | - unset( $_GET['page'] ); |
|
324 | + unset( $_GET[ 'page' ] ); |
|
325 | 325 | |
326 | - $date_created = $this->entry['date_created']; |
|
326 | + $date_created = $this->entry[ 'date_created' ]; |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
330 | 330 | * @since 1.17.2 |
331 | 331 | */ |
332 | - unset( $this->entry['date_created'] ); |
|
332 | + unset( $this->entry[ 'date_created' ] ); |
|
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | 336 | // Delete the values for hidden inputs |
337 | 337 | $this->unset_hidden_field_values(); |
338 | 338 | |
339 | - $this->entry['date_created'] = $date_created; |
|
339 | + $this->entry[ 'date_created' ] = $date_created; |
|
340 | 340 | |
341 | 341 | // Process calculation fields |
342 | 342 | $this->update_calculation_fields(); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | * @param GravityView_Edit_Entry_Render $this This object |
358 | 358 | * @param GravityView_View_Data $gv_data The View data |
359 | 359 | */ |
360 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
360 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
361 | 361 | |
362 | 362 | } else { |
363 | 363 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | */ |
386 | 386 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
387 | 387 | |
388 | - if( ! $unset_hidden_field_values ) { |
|
388 | + if ( ! $unset_hidden_field_values ) { |
|
389 | 389 | return; |
390 | 390 | } |
391 | 391 | |
392 | 392 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
393 | 393 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
394 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
394 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
395 | 395 | } else { |
396 | 396 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
397 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
397 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | /** No file is being uploaded. */ |
478 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
478 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
479 | 479 | /** So return the original upload */ |
480 | 480 | return $entry[ $input_id ]; |
481 | 481 | } |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @return mixed |
494 | 494 | */ |
495 | 495 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
496 | - if( ! $this->is_edit_entry() ) { |
|
496 | + if ( ! $this->is_edit_entry() ) { |
|
497 | 497 | return $plupload_init; |
498 | 498 | } |
499 | 499 | |
500 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
500 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
501 | 501 | |
502 | 502 | return $plupload_init; |
503 | 503 | } |
@@ -512,22 +512,22 @@ discard block |
||
512 | 512 | $form = $this->form; |
513 | 513 | |
514 | 514 | /** @var GF_Field $field */ |
515 | - foreach( $form['fields'] as $k => &$field ) { |
|
515 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
516 | 516 | |
517 | 517 | /** |
518 | 518 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
519 | 519 | * @since 1.16.3 |
520 | 520 | * @var GF_Field $field |
521 | 521 | */ |
522 | - if( $field->has_calculation() ) { |
|
523 | - unset( $form['fields'][ $k ] ); |
|
522 | + if ( $field->has_calculation() ) { |
|
523 | + unset( $form[ 'fields' ][ $k ] ); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | $field->adminOnly = false; |
527 | 527 | |
528 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
529 | - foreach( $field->inputs as $key => $input ) { |
|
530 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
528 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
529 | + foreach ( $field->inputs as $key => $input ) { |
|
530 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | } |
@@ -541,30 +541,30 @@ discard block |
||
541 | 541 | $update = false; |
542 | 542 | |
543 | 543 | // get the most up to date entry values |
544 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
544 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
545 | 545 | |
546 | - if( !empty( $this->fields_with_calculation ) ) { |
|
546 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
547 | 547 | $update = true; |
548 | 548 | foreach ( $this->fields_with_calculation as $calc_field ) { |
549 | 549 | $inputs = $calc_field->get_entry_inputs(); |
550 | 550 | if ( is_array( $inputs ) ) { |
551 | 551 | foreach ( $inputs as $input ) { |
552 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
553 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
552 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
553 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
554 | 554 | } |
555 | 555 | } else { |
556 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
557 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
556 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
557 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | 561 | } |
562 | 562 | |
563 | - if( $update ) { |
|
563 | + if ( $update ) { |
|
564 | 564 | |
565 | 565 | $return_entry = GFAPI::update_entry( $entry ); |
566 | 566 | |
567 | - if( is_wp_error( $return_entry ) ) { |
|
567 | + if ( is_wp_error( $return_entry ) ) { |
|
568 | 568 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
569 | 569 | } else { |
570 | 570 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -595,19 +595,19 @@ discard block |
||
595 | 595 | |
596 | 596 | $input_name = 'input_' . $field_id; |
597 | 597 | |
598 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
598 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
599 | 599 | |
600 | 600 | // We have a new image |
601 | 601 | |
602 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
602 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
603 | 603 | |
604 | 604 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
605 | 605 | $ary = stripslashes_deep( $ary ); |
606 | 606 | $img_url = \GV\Utils::get( $ary, 0 ); |
607 | 607 | |
608 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
609 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
610 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
608 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
609 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
610 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
611 | 611 | |
612 | 612 | $image_meta = array( |
613 | 613 | 'post_excerpt' => $img_caption, |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | |
617 | 617 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
618 | 618 | if ( ! empty( $img_title ) ) { |
619 | - $image_meta['post_title'] = $img_title; |
|
619 | + $image_meta[ 'post_title' ] = $img_title; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -674,15 +674,15 @@ discard block |
||
674 | 674 | */ |
675 | 675 | private function maybe_update_post_fields( $form ) { |
676 | 676 | |
677 | - if( empty( $this->entry['post_id'] ) ) { |
|
677 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
678 | 678 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
679 | 679 | return; |
680 | 680 | } |
681 | 681 | |
682 | - $post_id = $this->entry['post_id']; |
|
682 | + $post_id = $this->entry[ 'post_id' ]; |
|
683 | 683 | |
684 | 684 | // Security check |
685 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
685 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
686 | 686 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
687 | 687 | return; |
688 | 688 | } |
@@ -695,25 +695,25 @@ discard block |
||
695 | 695 | |
696 | 696 | $field = RGFormsModel::get_field( $form, $field_id ); |
697 | 697 | |
698 | - if( ! $field ) { |
|
698 | + if ( ! $field ) { |
|
699 | 699 | continue; |
700 | 700 | } |
701 | 701 | |
702 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
702 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
703 | 703 | |
704 | 704 | // Get the value of the field, including $_POSTed value |
705 | 705 | $value = RGFormsModel::get_field_value( $field ); |
706 | 706 | |
707 | 707 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
708 | 708 | $entry_tmp = $this->entry; |
709 | - $entry_tmp["{$field_id}"] = $value; |
|
709 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
710 | 710 | |
711 | - switch( $field->type ) { |
|
711 | + switch ( $field->type ) { |
|
712 | 712 | |
713 | 713 | case 'post_title': |
714 | 714 | $post_title = $value; |
715 | 715 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
716 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
716 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
717 | 717 | } |
718 | 718 | $updated_post->post_title = $post_title; |
719 | 719 | $updated_post->post_name = $post_title; |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | case 'post_content': |
724 | 724 | $post_content = $value; |
725 | 725 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
726 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
726 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
727 | 727 | } |
728 | 728 | $updated_post->post_content = $post_content; |
729 | 729 | unset( $post_content ); |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $value = $value[ $field_id ]; |
742 | 742 | } |
743 | 743 | |
744 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
744 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
745 | 745 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
746 | 746 | } |
747 | 747 | |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | } |
760 | 760 | |
761 | 761 | // update entry after |
762 | - $this->entry["{$field_id}"] = $value; |
|
762 | + $this->entry[ "{$field_id}" ] = $value; |
|
763 | 763 | |
764 | 764 | $update_entry = true; |
765 | 765 | |
@@ -768,11 +768,11 @@ discard block |
||
768 | 768 | |
769 | 769 | } |
770 | 770 | |
771 | - if( $update_entry ) { |
|
771 | + if ( $update_entry ) { |
|
772 | 772 | |
773 | 773 | $return_entry = GFAPI::update_entry( $this->entry ); |
774 | 774 | |
775 | - if( is_wp_error( $return_entry ) ) { |
|
775 | + if ( is_wp_error( $return_entry ) ) { |
|
776 | 776 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
777 | 777 | } else { |
778 | 778 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | |
783 | 783 | $return_post = wp_update_post( $updated_post, true ); |
784 | 784 | |
785 | - if( is_wp_error( $return_post ) ) { |
|
785 | + if ( is_wp_error( $return_post ) ) { |
|
786 | 786 | $return_post->add_data( $updated_post, '$updated_post' ); |
787 | 787 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
788 | 788 | } else { |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $input_type = RGFormsModel::get_input_type( $field ); |
805 | 805 | |
806 | 806 | // Only certain custom field types are supported |
807 | - switch( $input_type ) { |
|
807 | + switch ( $input_type ) { |
|
808 | 808 | case 'fileupload': |
809 | 809 | case 'list': |
810 | 810 | case 'multiselect': |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
842 | 842 | |
843 | 843 | // replace conditional shortcodes |
844 | - if( $do_shortcode ) { |
|
844 | + if ( $do_shortcode ) { |
|
845 | 845 | $output = do_shortcode( $output ); |
846 | 846 | } |
847 | 847 | |
@@ -860,19 +860,19 @@ discard block |
||
860 | 860 | */ |
861 | 861 | private function after_update() { |
862 | 862 | |
863 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
864 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
863 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
864 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
865 | 865 | |
866 | 866 | // Re-define the entry now that we've updated it. |
867 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
867 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
868 | 868 | |
869 | 869 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
870 | 870 | |
871 | 871 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
872 | 872 | // We need to clear the cache because Gravity Forms caches the field values, which |
873 | 873 | // we have just updated. |
874 | - foreach ($this->form['fields'] as $key => $field) { |
|
875 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
874 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
875 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
876 | 876 | } |
877 | 877 | } |
878 | 878 | |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | |
892 | 892 | <div class="gv-edit-entry-wrapper"><?php |
893 | 893 | |
894 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
894 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
895 | 895 | |
896 | 896 | /** |
897 | 897 | * Fixes weird wpautop() issue |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * @param string $edit_entry_title Modify the "Edit Entry" title |
908 | 908 | * @param GravityView_Edit_Entry_Render $this This object |
909 | 909 | */ |
910 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
910 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
911 | 911 | |
912 | 912 | echo esc_attr( $edit_entry_title ); |
913 | 913 | ?></span> |
@@ -957,16 +957,16 @@ discard block |
||
957 | 957 | |
958 | 958 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
959 | 959 | |
960 | - if( ! $this->is_valid ){ |
|
960 | + if ( ! $this->is_valid ) { |
|
961 | 961 | |
962 | 962 | // Keeping this compatible with Gravity Forms. |
963 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
964 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
963 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
964 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
965 | 965 | |
966 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
966 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
967 | 967 | |
968 | 968 | } else { |
969 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
969 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
970 | 970 | |
971 | 971 | /** |
972 | 972 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | * @param array $entry Gravity Forms entry array |
977 | 977 | * @param string $back_link URL to return to the original entry. @since 1.6 |
978 | 978 | */ |
979 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
979 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
980 | 980 | |
981 | 981 | echo GVCommon::generate_notice( $message ); |
982 | 982 | } |
@@ -1000,21 +1000,21 @@ discard block |
||
1000 | 1000 | */ |
1001 | 1001 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1002 | 1002 | |
1003 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1004 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1003 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1004 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1005 | 1005 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1006 | 1006 | |
1007 | 1007 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1008 | 1008 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1009 | 1009 | |
1010 | 1010 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1011 | - unset( $_GET['page'] ); |
|
1011 | + unset( $_GET[ 'page' ] ); |
|
1012 | 1012 | |
1013 | 1013 | // TODO: Verify multiple-page forms |
1014 | 1014 | |
1015 | 1015 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1016 | 1016 | |
1017 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1017 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1018 | 1018 | |
1019 | 1019 | ob_get_clean(); |
1020 | 1020 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | * @return string |
1041 | 1041 | */ |
1042 | 1042 | public function render_form_buttons() { |
1043 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1043 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | |
@@ -1060,10 +1060,10 @@ discard block |
||
1060 | 1060 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1061 | 1061 | |
1062 | 1062 | // In case we have validated the form, use it to inject the validation results into the form render |
1063 | - if( isset( $this->form_after_validation ) ) { |
|
1063 | + if ( isset( $this->form_after_validation ) ) { |
|
1064 | 1064 | $form = $this->form_after_validation; |
1065 | 1065 | } else { |
1066 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1066 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $form = $this->filter_conditional_logic( $form ); |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | $form = $this->prefill_conditional_logic( $form ); |
1072 | 1072 | |
1073 | 1073 | // for now we don't support Save and Continue feature. |
1074 | - if( ! self::$supports_save_and_continue ) { |
|
1075 | - unset( $form['save'] ); |
|
1074 | + if ( ! self::$supports_save_and_continue ) { |
|
1075 | + unset( $form[ 'save' ] ); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | return $form; |
@@ -1093,29 +1093,29 @@ discard block |
||
1093 | 1093 | */ |
1094 | 1094 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1095 | 1095 | |
1096 | - if( GFCommon::is_post_field( $field ) ) { |
|
1096 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1097 | 1097 | |
1098 | 1098 | $message = null; |
1099 | 1099 | |
1100 | 1100 | // First, make sure they have the capability to edit the post. |
1101 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1101 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1102 | 1102 | |
1103 | 1103 | /** |
1104 | 1104 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1105 | 1105 | * @param string $message The existing "You don't have permission..." text |
1106 | 1106 | */ |
1107 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1107 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1108 | 1108 | |
1109 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1109 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1110 | 1110 | /** |
1111 | 1111 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1112 | 1112 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1113 | 1113 | */ |
1114 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1114 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if( $message ) { |
|
1118 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1117 | + if ( $message ) { |
|
1118 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1119 | 1119 | } |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1140,8 +1140,8 @@ discard block |
||
1140 | 1140 | |
1141 | 1141 | // If the form has been submitted, then we don't need to pre-fill the values, |
1142 | 1142 | // Except for fileupload type and when a field input is overridden- run always!! |
1143 | - if( |
|
1144 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1143 | + if ( |
|
1144 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1145 | 1145 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1146 | 1146 | && ! GFCommon::is_product_field( $field->type ) |
1147 | 1147 | || ! empty( $field_content ) |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | $return = null; |
1162 | 1162 | |
1163 | 1163 | /** @var GravityView_Field $gv_field */ |
1164 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1164 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1165 | 1165 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1166 | 1166 | } else { |
1167 | 1167 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | // If there was output, it's an error |
1171 | 1171 | $warnings = ob_get_clean(); |
1172 | 1172 | |
1173 | - if( !empty( $warnings ) ) { |
|
1173 | + if ( ! empty( $warnings ) ) { |
|
1174 | 1174 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1175 | 1175 | } |
1176 | 1176 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1196 | 1196 | |
1197 | 1197 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1198 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1198 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1199 | 1199 | |
1200 | 1200 | $field_value = array(); |
1201 | 1201 | |
@@ -1204,10 +1204,10 @@ discard block |
||
1204 | 1204 | |
1205 | 1205 | foreach ( (array)$field->inputs as $input ) { |
1206 | 1206 | |
1207 | - $input_id = strval( $input['id'] ); |
|
1207 | + $input_id = strval( $input[ 'id' ] ); |
|
1208 | 1208 | |
1209 | 1209 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1210 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1210 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1211 | 1211 | $allow_pre_populated = false; |
1212 | 1212 | } |
1213 | 1213 | |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $pre_value = $field->get_value_submission( array(), false ); |
1217 | 1217 | |
1218 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1218 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1219 | 1219 | |
1220 | 1220 | } else { |
1221 | 1221 | |
@@ -1226,13 +1226,13 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1228 | 1228 | // or pre-populated value if not empty and set to override saved value |
1229 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1229 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1230 | 1230 | |
1231 | 1231 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1232 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1232 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1233 | 1233 | $categories = array(); |
1234 | 1234 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1235 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1235 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1236 | 1236 | } |
1237 | 1237 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1238 | 1238 | } |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | * @param GF_Field $field Gravity Forms field object |
1261 | 1261 | * @param GravityView_Edit_Entry_Render $this Current object |
1262 | 1262 | */ |
1263 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1263 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1264 | 1264 | |
1265 | 1265 | return $field_value; |
1266 | 1266 | } |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | */ |
1278 | 1278 | public function gform_pre_validation( $form ) { |
1279 | 1279 | |
1280 | - if( ! $this->verify_nonce() ) { |
|
1280 | + if ( ! $this->verify_nonce() ) { |
|
1281 | 1281 | return $form; |
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | // Fix PHP warning regarding undefined index. |
1285 | - foreach ( $form['fields'] as &$field) { |
|
1285 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1286 | 1286 | |
1287 | 1287 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1288 | 1288 | // expects certain field array items to be set. |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1291 | 1291 | } |
1292 | 1292 | |
1293 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1293 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1294 | 1294 | |
1295 | 1295 | /** |
1296 | 1296 | * 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. |
@@ -1304,26 +1304,26 @@ discard block |
||
1304 | 1304 | // Set the previous value |
1305 | 1305 | $entry = $this->get_entry(); |
1306 | 1306 | |
1307 | - $input_name = 'input_'.$field->id; |
|
1308 | - $form_id = $form['id']; |
|
1307 | + $input_name = 'input_' . $field->id; |
|
1308 | + $form_id = $form[ 'id' ]; |
|
1309 | 1309 | |
1310 | 1310 | $value = NULL; |
1311 | 1311 | |
1312 | 1312 | // Use the previous entry value as the default. |
1313 | - if( isset( $entry[ $field->id ] ) ) { |
|
1313 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1314 | 1314 | $value = $entry[ $field->id ]; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | // If this is a single upload file |
1318 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1319 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1320 | - $value = $file_path['url']; |
|
1318 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1319 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1320 | + $value = $file_path[ 'url' ]; |
|
1321 | 1321 | |
1322 | 1322 | } else { |
1323 | 1323 | |
1324 | 1324 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1325 | 1325 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1326 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1326 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1327 | 1327 | |
1328 | 1328 | } |
1329 | 1329 | |
@@ -1331,10 +1331,10 @@ discard block |
||
1331 | 1331 | |
1332 | 1332 | // If there are fresh uploads, process and merge them. |
1333 | 1333 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1334 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1334 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1335 | 1335 | $value = empty( $value ) ? '[]' : $value; |
1336 | 1336 | $value = stripslashes_deep( $value ); |
1337 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1337 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | } else { |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | case 'number': |
1354 | 1354 | // Fix "undefined index" issue at line 1286 in form_display.php |
1355 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1356 | - $_POST['input_'.$field->id ] = NULL; |
|
1355 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1356 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1357 | 1357 | } |
1358 | 1358 | break; |
1359 | 1359 | } |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | * You can enter whatever you want! |
1391 | 1391 | * We try validating, and customize the results using `self::custom_validation()` |
1392 | 1392 | */ |
1393 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1393 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1394 | 1394 | |
1395 | 1395 | // Needed by the validate funtion |
1396 | 1396 | $failed_validation_page = NULL; |
@@ -1398,14 +1398,14 @@ discard block |
||
1398 | 1398 | |
1399 | 1399 | // Prevent entry limit from running when editing an entry, also |
1400 | 1400 | // prevent form scheduling from preventing editing |
1401 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1401 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1402 | 1402 | |
1403 | 1403 | // Hide fields depending on Edit Entry settings |
1404 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1404 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1405 | 1405 | |
1406 | 1406 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1407 | 1407 | |
1408 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1408 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | |
1429 | 1429 | $gv_valid = true; |
1430 | 1430 | |
1431 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1431 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1432 | 1432 | |
1433 | 1433 | $value = RGFormsModel::get_field_value( $field ); |
1434 | 1434 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1441,35 +1441,35 @@ discard block |
||
1441 | 1441 | case 'post_image': |
1442 | 1442 | |
1443 | 1443 | // in case nothing is uploaded but there are already files saved |
1444 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1444 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1445 | 1445 | $field->failed_validation = false; |
1446 | 1446 | unset( $field->validation_message ); |
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1450 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1450 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1451 | 1451 | |
1452 | 1452 | $input_name = 'input_' . $field->id; |
1453 | 1453 | //uploaded |
1454 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1454 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1455 | 1455 | |
1456 | 1456 | //existent |
1457 | 1457 | $entry = $this->get_entry(); |
1458 | 1458 | $value = NULL; |
1459 | - if( isset( $entry[ $field->id ] ) ) { |
|
1459 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1460 | 1460 | $value = json_decode( $entry[ $field->id ], true ); |
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | // count uploaded files and existent entry files |
1464 | 1464 | $count_files = count( $file_names ) + count( $value ); |
1465 | 1465 | |
1466 | - if( $count_files > $field->maxFiles ) { |
|
1466 | + if ( $count_files > $field->maxFiles ) { |
|
1467 | 1467 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1468 | 1468 | $field->failed_validation = 1; |
1469 | 1469 | $gv_valid = false; |
1470 | 1470 | |
1471 | 1471 | // in case of error make sure the newest upload files are removed from the upload input |
1472 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1472 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | } |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | // This field has failed validation. |
1483 | - if( !empty( $field->failed_validation ) ) { |
|
1483 | + if ( ! empty( $field->failed_validation ) ) { |
|
1484 | 1484 | |
1485 | 1485 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1486 | 1486 | |
@@ -1498,19 +1498,19 @@ discard block |
||
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | // You can't continue inside a switch, so we do it after. |
1501 | - if( empty( $field->failed_validation ) ) { |
|
1501 | + if ( empty( $field->failed_validation ) ) { |
|
1502 | 1502 | continue; |
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // checks if the No Duplicates option is not validating entry against itself, since |
1506 | 1506 | // we're editing a stored entry, it would also assume it's a duplicate. |
1507 | - if( !empty( $field->noDuplicates ) ) { |
|
1507 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1508 | 1508 | |
1509 | 1509 | $entry = $this->get_entry(); |
1510 | 1510 | |
1511 | 1511 | // If the value of the entry is the same as the stored value |
1512 | 1512 | // Then we can assume it's not a duplicate, it's the same. |
1513 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1513 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1514 | 1514 | //if value submitted was not changed, then don't validate |
1515 | 1515 | $field->failed_validation = false; |
1516 | 1516 | |
@@ -1523,7 +1523,7 @@ discard block |
||
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1526 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1526 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1527 | 1527 | unset( $field->validation_message ); |
1528 | 1528 | $field->validation_message = false; |
1529 | 1529 | continue; |
@@ -1535,12 +1535,12 @@ discard block |
||
1535 | 1535 | |
1536 | 1536 | } |
1537 | 1537 | |
1538 | - $validation_results['is_valid'] = $gv_valid; |
|
1538 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1539 | 1539 | |
1540 | 1540 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1541 | 1541 | |
1542 | 1542 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1543 | - $this->form_after_validation = $validation_results['form']; |
|
1543 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1544 | 1544 | |
1545 | 1545 | return $validation_results; |
1546 | 1546 | } |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | */ |
1554 | 1554 | public function get_entry() { |
1555 | 1555 | |
1556 | - if( empty( $this->entry ) ) { |
|
1556 | + if ( empty( $this->entry ) ) { |
|
1557 | 1557 | // Get the database value of the entry that's being edited |
1558 | 1558 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1559 | 1559 | } |
@@ -1585,10 +1585,10 @@ discard block |
||
1585 | 1585 | } |
1586 | 1586 | |
1587 | 1587 | // If edit tab not yet configured, show all fields |
1588 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1588 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1589 | 1589 | |
1590 | 1590 | // Hide fields depending on admin settings |
1591 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1591 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1592 | 1592 | |
1593 | 1593 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1594 | 1594 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | */ |
1621 | 1621 | private function filter_fields( $fields, $configured_fields ) { |
1622 | 1622 | |
1623 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1623 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1624 | 1624 | return $fields; |
1625 | 1625 | } |
1626 | 1626 | |
@@ -1633,18 +1633,18 @@ discard block |
||
1633 | 1633 | |
1634 | 1634 | // Remove the fields that have calculation properties and keep them to be used later |
1635 | 1635 | // @since 1.16.2 |
1636 | - if( $field->has_calculation() ) { |
|
1637 | - $this->fields_with_calculation[] = $field; |
|
1636 | + if ( $field->has_calculation() ) { |
|
1637 | + $this->fields_with_calculation[ ] = $field; |
|
1638 | 1638 | // don't remove the calculation fields on form render. |
1639 | 1639 | } |
1640 | 1640 | |
1641 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1641 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1642 | 1642 | unset( $fields[ $key ] ); |
1643 | 1643 | } |
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | // The Edit tab has not been configured, so we return all fields by default. |
1647 | - if( empty( $configured_fields ) ) { |
|
1647 | + if ( empty( $configured_fields ) ) { |
|
1648 | 1648 | return $fields; |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1653,8 +1653,8 @@ discard block |
||
1653 | 1653 | |
1654 | 1654 | /** @var GF_Field $field */ |
1655 | 1655 | foreach ( $fields as $field ) { |
1656 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1657 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1656 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1657 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1658 | 1658 | break; |
1659 | 1659 | } |
1660 | 1660 | |
@@ -1677,14 +1677,14 @@ discard block |
||
1677 | 1677 | |
1678 | 1678 | $return_field = $field; |
1679 | 1679 | |
1680 | - if( empty( $field_setting['show_label'] ) ) { |
|
1680 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1681 | 1681 | $return_field->label = ''; |
1682 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1683 | - $return_field->label = $field_setting['custom_label']; |
|
1682 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1683 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1687 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1686 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1687 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1688 | 1688 | } |
1689 | 1689 | |
1690 | 1690 | /** |
@@ -1722,16 +1722,16 @@ discard block |
||
1722 | 1722 | */ |
1723 | 1723 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1724 | 1724 | |
1725 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1726 | - foreach( $fields as $k => $field ) { |
|
1727 | - if( $field->adminOnly ) { |
|
1725 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1726 | + foreach ( $fields as $k => $field ) { |
|
1727 | + if ( $field->adminOnly ) { |
|
1728 | 1728 | unset( $fields[ $k ] ); |
1729 | 1729 | } |
1730 | 1730 | } |
1731 | 1731 | return $fields; |
1732 | 1732 | } |
1733 | 1733 | |
1734 | - foreach( $fields as &$field ) { |
|
1734 | + foreach ( $fields as &$field ) { |
|
1735 | 1735 | $field->adminOnly = false; |
1736 | 1736 | } |
1737 | 1737 | |
@@ -1755,22 +1755,22 @@ discard block |
||
1755 | 1755 | */ |
1756 | 1756 | function prefill_conditional_logic( $form ) { |
1757 | 1757 | |
1758 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1758 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1759 | 1759 | return $form; |
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | // Have Conditional Logic pre-fill fields as if the data were default values |
1763 | 1763 | /** @var GF_Field $field */ |
1764 | - foreach ( $form['fields'] as &$field ) { |
|
1764 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1765 | 1765 | |
1766 | - if( 'checkbox' === $field->type ) { |
|
1766 | + if ( 'checkbox' === $field->type ) { |
|
1767 | 1767 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1768 | - $input_id = $input['id']; |
|
1768 | + $input_id = $input[ 'id' ]; |
|
1769 | 1769 | $choice = $field->choices[ $key ]; |
1770 | 1770 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1771 | 1771 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1772 | - if( $match ) { |
|
1773 | - $field->choices[ $key ]['isSelected'] = true; |
|
1772 | + if ( $match ) { |
|
1773 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1774 | 1774 | } |
1775 | 1775 | } |
1776 | 1776 | } else { |
@@ -1778,15 +1778,15 @@ discard block |
||
1778 | 1778 | // We need to run through each field to set the default values |
1779 | 1779 | foreach ( $this->entry as $field_id => $field_value ) { |
1780 | 1780 | |
1781 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1781 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1782 | 1782 | |
1783 | - if( 'list' === $field->type ) { |
|
1783 | + if ( 'list' === $field->type ) { |
|
1784 | 1784 | $list_rows = maybe_unserialize( $field_value ); |
1785 | 1785 | |
1786 | 1786 | $list_field_value = array(); |
1787 | - foreach ( (array) $list_rows as $row ) { |
|
1788 | - foreach ( (array) $row as $column ) { |
|
1789 | - $list_field_value[] = $column; |
|
1787 | + foreach ( (array)$list_rows as $row ) { |
|
1788 | + foreach ( (array)$row as $column ) { |
|
1789 | + $list_field_value[ ] = $column; |
|
1790 | 1790 | } |
1791 | 1791 | } |
1792 | 1792 | |
@@ -1821,16 +1821,16 @@ discard block |
||
1821 | 1821 | */ |
1822 | 1822 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1823 | 1823 | |
1824 | - if( $use_conditional_logic ) { |
|
1824 | + if ( $use_conditional_logic ) { |
|
1825 | 1825 | return $form; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - foreach( $form['fields'] as &$field ) { |
|
1828 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1829 | 1829 | /* @var GF_Field $field */ |
1830 | 1830 | $field->conditionalLogic = null; |
1831 | 1831 | } |
1832 | 1832 | |
1833 | - unset( $form['button']['conditionalLogic'] ); |
|
1833 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1834 | 1834 | |
1835 | 1835 | return $form; |
1836 | 1836 | |
@@ -1847,7 +1847,7 @@ discard block |
||
1847 | 1847 | */ |
1848 | 1848 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1849 | 1849 | |
1850 | - if( ! $this->is_edit_entry() ) { |
|
1850 | + if ( ! $this->is_edit_entry() ) { |
|
1851 | 1851 | return $has_conditional_logic; |
1852 | 1852 | } |
1853 | 1853 | |
@@ -1879,44 +1879,44 @@ discard block |
||
1879 | 1879 | * 2. There are two entries embedded using oEmbed |
1880 | 1880 | * 3. One of the entries has just been saved |
1881 | 1881 | */ |
1882 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1882 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1883 | 1883 | |
1884 | 1884 | $error = true; |
1885 | 1885 | |
1886 | 1886 | } |
1887 | 1887 | |
1888 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1888 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1889 | 1889 | |
1890 | 1890 | $error = true; |
1891 | 1891 | |
1892 | - } elseif( ! $this->verify_nonce() ) { |
|
1892 | + } elseif ( ! $this->verify_nonce() ) { |
|
1893 | 1893 | |
1894 | 1894 | /** |
1895 | 1895 | * If the Entry is embedded, there may be two entries on the same page. |
1896 | 1896 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1897 | 1897 | */ |
1898 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1898 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1899 | 1899 | $error = true; |
1900 | 1900 | } else { |
1901 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1901 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1907 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1906 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1907 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1908 | 1908 | } |
1909 | 1909 | |
1910 | - if( $this->entry['status'] === 'trash' ) { |
|
1911 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1910 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1911 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1912 | 1912 | } |
1913 | 1913 | |
1914 | 1914 | // No errors; everything's fine here! |
1915 | - if( empty( $error ) ) { |
|
1915 | + if ( empty( $error ) ) { |
|
1916 | 1916 | return true; |
1917 | 1917 | } |
1918 | 1918 | |
1919 | - if( $echo && $error !== true ) { |
|
1919 | + if ( $echo && $error !== true ) { |
|
1920 | 1920 | |
1921 | 1921 | $error = esc_html( $error ); |
1922 | 1922 | |
@@ -1924,10 +1924,10 @@ discard block |
||
1924 | 1924 | * @since 1.9 |
1925 | 1925 | */ |
1926 | 1926 | if ( ! empty( $this->entry ) ) { |
1927 | - $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;" ) ); |
|
1927 | + $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;" ) ); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1930 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1931 | 1931 | } |
1932 | 1932 | |
1933 | 1933 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1947,17 +1947,17 @@ discard block |
||
1947 | 1947 | |
1948 | 1948 | $error = NULL; |
1949 | 1949 | |
1950 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1951 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1950 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1951 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1952 | 1952 | } |
1953 | 1953 | |
1954 | 1954 | // No errors; everything's fine here! |
1955 | - if( empty( $error ) ) { |
|
1955 | + if ( empty( $error ) ) { |
|
1956 | 1956 | return true; |
1957 | 1957 | } |
1958 | 1958 | |
1959 | - if( $echo ) { |
|
1960 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1959 | + if ( $echo ) { |
|
1960 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1978,14 +1978,14 @@ discard block |
||
1978 | 1978 | private function check_user_cap_edit_field( $field ) { |
1979 | 1979 | |
1980 | 1980 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1981 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1981 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1982 | 1982 | return true; |
1983 | 1983 | } |
1984 | 1984 | |
1985 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1985 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1986 | 1986 | |
1987 | - if( $field_cap ) { |
|
1988 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1987 | + if ( $field_cap ) { |
|
1988 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | return false; |
@@ -1999,17 +1999,17 @@ discard block |
||
1999 | 1999 | public function verify_nonce() { |
2000 | 2000 | |
2001 | 2001 | // Verify form submitted for editing single |
2002 | - if( $this->is_edit_entry_submission() ) { |
|
2002 | + if ( $this->is_edit_entry_submission() ) { |
|
2003 | 2003 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2004 | 2004 | } |
2005 | 2005 | |
2006 | 2006 | // Verify |
2007 | - else if( ! $this->is_edit_entry() ) { |
|
2007 | + else if ( ! $this->is_edit_entry() ) { |
|
2008 | 2008 | $valid = false; |
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | else { |
2012 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2012 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2013 | 2013 | } |
2014 | 2014 | |
2015 | 2015 | /** |