@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'args' => $this->create_sub_item_args() |
122 | 122 | ), |
123 | 123 | ) ); |
124 | - register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ) , array( |
|
124 | + register_rest_route( $namespace, sprintf( '/%s/(?P<id>[\d]+)/%s/(?P<s_id>[\w-]+)%s', $base, $sub_type, $format ), array( |
|
125 | 125 | array( |
126 | 126 | 'methods' => \WP_REST_Server::READABLE, |
127 | 127 | 'callback' => array( $this, 'get_sub_item' ), |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return \WP_REST_Response |
373 | 373 | */ |
374 | 374 | protected function not_implemented( ) { |
375 | - $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
375 | + $error = new \WP_Error( 'not-implemented-yet', __( 'Endpoint Not Yet Implemented.', 'gravityview' ) ); |
|
376 | 376 | return new \WP_REST_Response( $error, 501 ); |
377 | 377 | } |
378 | 378 |
@@ -7,15 +7,15 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | $html_input_type = RGFormsModel::is_html5_enabled() ? 'search' : 'text'; |
14 | 14 | ?> |
15 | 15 | |
16 | 16 | <div class="gv-search-box gv-search-field-text gv-search-field-search_all"> |
17 | 17 | <div class="gv-search"> |
18 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
18 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
19 | 19 | <label for="gv_search_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
20 | 20 | <?php } ?> |
21 | 21 | <p><input type="<?php echo $html_input_type; ?>" name="gv_search" id="gv_search_<?php echo $view_id; ?>" value="<?php echo esc_attr( $value ); ?>" /></p> |
@@ -7,13 +7,13 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="gv-search-box gv-search-field-entry_id"> |
15 | 15 | <div class="gv-search"> |
16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | 17 | <label for="gv_entry_id_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
18 | 18 | <?php } ?> |
19 | 19 | <p><input type="text" name="gv_id" id="gv_entry_id_<?php echo $view_id; ?>" value="<?php echo esc_attr( $value ); ?>" /></p> |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range gv-search-field-entry_date"> |
16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | 17 | <label for="gv_start_date_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo $value['start']; ?>"> |
|
21 | - <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo $value['end']; ?>"> |
|
20 | + <input name="gv_start" id="gv_start_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo $value[ 'start' ]; ?>"> |
|
21 | + <input name="gv_end" id="gv_end_date_<?php echo $view_id; ?>" type="text" class="<?php echo esc_attr( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo $value[ 'end' ]; ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
9 | 9 | $view_id = $gravityview_view->getViewId(); |
10 | -$value = $gravityview_view->search_field['value']; |
|
11 | -$label = $gravityview_view->search_field['label']; |
|
12 | -$name = $gravityview_view->search_field['name']; |
|
10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
12 | +$name = $gravityview_view->search_field[ 'name' ]; |
|
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class="gv-search-box gv-search-date gv-search-date-range"> |
16 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | - <label for="search-box-<?php echo esc_attr( $name ).'-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
16 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
17 | + <label for="search-box-<?php echo esc_attr( $name ) . '-start'; ?>"><?php echo esc_html( $label ); ?></label> |
|
18 | 18 | <?php } ?> |
19 | 19 | <p> |
20 | - <input name="<?php echo esc_attr( $name ).'[start]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['start'] ); ?>"> |
|
21 | - <input name="<?php echo esc_attr( $name ).'[end]'; ?>" id="search-box-<?php echo esc_attr( $name ).'-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e('End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value['end'] ); ?>"> |
|
20 | + <input name="<?php echo esc_attr( $name ) . '[start]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-start'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'Start date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'start' ] ); ?>"> |
|
21 | + <input name="<?php echo esc_attr( $name ) . '[end]'; ?>" id="search-box-<?php echo esc_attr( $name ) . '-end'; ?>" type="text" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" placeholder="<?php esc_attr_e( 'End date', 'gravityview' ); ?>" value="<?php echo esc_attr( $value[ 'end' ] ); ?>"> |
|
22 | 22 | </p> |
23 | 23 | </div> |
24 | 24 | \ No newline at end of file |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $args = array(); |
115 | 115 | |
116 | - $view_id = is_null ( $view ) ? null : $view->ID; |
|
116 | + $view_id = is_null( $view ) ? null : $view->ID; |
|
117 | 117 | |
118 | 118 | $permalink = null; |
119 | 119 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | |
127 | 127 | $view_collection = View_Collection::from_post( $post ); |
128 | 128 | |
129 | - if( 1 < $view_collection->count() ) { |
|
130 | - $args['gvid'] = $view_id; |
|
129 | + if ( 1 < $view_collection->count() ) { |
|
130 | + $args[ 'gvid' ] = $view_id; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | } |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | */ |
157 | 157 | $link_parts = explode( '?', $permalink ); |
158 | 158 | |
159 | - $query = ! empty( $link_parts[1] ) ? '?' . $link_parts[1] : ''; |
|
159 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
160 | 160 | |
161 | - $permalink = trailingslashit( $link_parts[0] ) . $entry_endpoint_name . '/'. $entry_slug .'/' . $query; |
|
161 | + $permalink = trailingslashit( $link_parts[ 0 ] ) . $entry_endpoint_name . '/' . $entry_slug . '/' . $query; |
|
162 | 162 | } else { |
163 | 163 | $args[ $entry_endpoint_name ] = $entry_slug; |
164 | 164 | } |
165 | 165 | |
166 | 166 | if ( $track_directory ) { |
167 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
168 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
167 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
168 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | if ( $sort = Utils::_GET( 'sort' ) ) { |
172 | - $args['sort'] = $sort; |
|
173 | - $args['dir'] = Utils::_GET( 'dir' ); |
|
172 | + $args[ 'sort' ] = $sort; |
|
173 | + $args[ 'dir' ] = Utils::_GET( 'dir' ); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'total' => wp_count_posts( 'gravityview' )->publish, |
64 | 64 | ); |
65 | 65 | foreach ( $items as $item ) { |
66 | - $data['views'][] = $this->prepare_view_for_response( $item, $request ); |
|
66 | + $data[ 'views' ][ ] = $this->prepare_view_for_response( $item, $request ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return new \WP_REST_Response( $data, 200 ); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | $url = $request->get_url_params(); |
84 | 84 | |
85 | - $view_id = intval( $url['id'] ); |
|
85 | + $view_id = intval( $url[ 'id' ] ); |
|
86 | 86 | |
87 | 87 | $item = get_post( $view_id ); |
88 | 88 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // Only output the fields that should be displayed. |
112 | 112 | $allowed = array(); |
113 | 113 | foreach ( $view->fields->by_position( "{$context}_*" )->by_visible()->all() as $field ) { |
114 | - $allowed[] = $field->ID; |
|
114 | + $allowed[ ] = $field->ID; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | public function get_sub_items( $request ) { |
157 | 157 | |
158 | 158 | $url = $request->get_url_params(); |
159 | - $view_id = intval( $url['id'] ); |
|
159 | + $view_id = intval( $url[ 'id' ] ); |
|
160 | 160 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
161 | 161 | |
162 | - if( $post_id = $request->get_param('post_id') ) { |
|
162 | + if ( $post_id = $request->get_param( 'post_id' ) ) { |
|
163 | 163 | global $post; |
164 | 164 | |
165 | 165 | $post = get_post( $post_id ); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $data = array( 'entries' => $entries->all(), 'total' => $entries->total() ); |
217 | 217 | |
218 | - foreach ( $data['entries'] as &$entry ) { |
|
218 | + foreach ( $data[ 'entries' ] as &$entry ) { |
|
219 | 219 | $entry = $this->prepare_entry_for_response( $view, $entry, $request, 'directory' ); |
220 | 220 | } |
221 | 221 | |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function get_sub_item( $request ) { |
236 | 236 | $url = $request->get_url_params(); |
237 | - $view_id = intval( $url['id'] ); |
|
238 | - $entry_id = intval( $url['s_id'] ); |
|
237 | + $view_id = intval( $url[ 'id' ] ); |
|
238 | + $entry_id = intval( $url[ 's_id' ] ); |
|
239 | 239 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
240 | 240 | |
241 | 241 | $view = \GV\View::by_id( $view_id ); |
@@ -270,32 +270,32 @@ discard block |
||
270 | 270 | // Add all the WP_Post data |
271 | 271 | $view_post = $view_post->to_array(); |
272 | 272 | |
273 | - unset( $view_post['to_ping'], $view_post['ping_status'], $view_post['pinged'], $view_post['post_type'], $view_post['filter'], $view_post['post_category'], $view_post['tags_input'], $view_post['post_content'], $view_post['post_content_filtered'] ); |
|
273 | + unset( $view_post[ 'to_ping' ], $view_post[ 'ping_status' ], $view_post[ 'pinged' ], $view_post[ 'post_type' ], $view_post[ 'filter' ], $view_post[ 'post_category' ], $view_post[ 'tags_input' ], $view_post[ 'post_content' ], $view_post[ 'post_content_filtered' ] ); |
|
274 | 274 | |
275 | 275 | $return = wp_parse_args( $item, $view_post ); |
276 | 276 | |
277 | - $return['title'] = $return['post_title']; |
|
277 | + $return[ 'title' ] = $return[ 'post_title' ]; |
|
278 | 278 | |
279 | - $return['settings'] = isset( $return['atts'] ) ? $return['atts'] : array(); |
|
280 | - unset( $return['atts'], $return['view_id'] ); |
|
279 | + $return[ 'settings' ] = isset( $return[ 'atts' ] ) ? $return[ 'atts' ] : array(); |
|
280 | + unset( $return[ 'atts' ], $return[ 'view_id' ] ); |
|
281 | 281 | |
282 | - $return['search_criteria'] = array( |
|
282 | + $return[ 'search_criteria' ] = array( |
|
283 | 283 | 'page_size' => rgars( $return, 'settings/page_size' ), |
284 | 284 | 'sort_field' => rgars( $return, 'settings/sort_field' ), |
285 | 285 | 'sort_direction' => rgars( $return, 'settings/sort_direction' ), |
286 | 286 | 'offset' => rgars( $return, 'settings/offset' ), |
287 | 287 | ); |
288 | 288 | |
289 | - unset( $return['settings']['page_size'], $return['settings']['sort_field'], $return['settings']['sort_direction'] ); |
|
289 | + unset( $return[ 'settings' ][ 'page_size' ], $return[ 'settings' ][ 'sort_field' ], $return[ 'settings' ][ 'sort_direction' ] ); |
|
290 | 290 | |
291 | 291 | // Redact for non-logged ins |
292 | 292 | if ( ! \GVCommon::has_cap( 'edit_others_gravityviews' ) ) { |
293 | - unset( $return['settings'] ); |
|
294 | - unset( $return['search_criteria'] ); |
|
293 | + unset( $return[ 'settings' ] ); |
|
294 | + unset( $return[ 'search_criteria' ] ); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if ( ! \GFCommon::current_user_can_any( 'gravityforms_edit_forms' ) ) { |
298 | - unset( $return['form'] ); |
|
298 | + unset( $return[ 'form' ] ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | return $return; |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $view_id = func_get_arg( 1 ); // $view_id override |
307 | 307 | } else { |
308 | 308 | $url = $request->get_url_params(); |
309 | - $view_id = intval( $url['id'] ); |
|
309 | + $view_id = intval( $url[ 'id' ] ); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | if ( ! $view = \GV\View::by_id( $view_id ) ) { |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | $url = $request->get_url_params(); |
362 | - $view_id = intval( $url['id'] ); |
|
363 | - $entry_id = intval( $url['s_id'] ); |
|
362 | + $view_id = intval( $url[ 'id' ] ); |
|
363 | + $entry_id = intval( $url[ 's_id' ] ); |
|
364 | 364 | |
365 | 365 | $view = \GV\View::by_id( $view_id ); |
366 | 366 | |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
369 | 369 | } |
370 | 370 | |
371 | - if ( $entry['form_id'] != $view->form->ID ) { |
|
371 | + if ( $entry[ 'form_id' ] != $view->form->ID ) { |
|
372 | 372 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
373 | 373 | } |
374 | 374 | |
375 | - if ( $entry['status'] != 'active' ) { |
|
375 | + if ( $entry[ 'status' ] != 'active' ) { |
|
376 | 376 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
377 | 377 | } |
378 | 378 | |
@@ -380,10 +380,10 @@ discard block |
||
380 | 380 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
381 | 381 | } |
382 | 382 | |
383 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
383 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
384 | 384 | |
385 | 385 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
386 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
386 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
387 | 387 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
388 | 388 | } |
389 | 389 | } |
@@ -319,8 +319,9 @@ |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | while ( $error = $view->can_render( array( 'rest' ), $request ) ) { |
322 | - if ( ! is_wp_error( $error ) ) |
|
323 | - break; |
|
322 | + if ( ! is_wp_error( $error ) ) { |
|
323 | + break; |
|
324 | + } |
|
324 | 325 | |
325 | 326 | switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) { |
326 | 327 | case 'rest_disabled': |
@@ -79,8 +79,9 @@ |
||
79 | 79 | * Check permissions. |
80 | 80 | */ |
81 | 81 | while ( $error = $view->can_render( array( 'shortcode' ), $request ) ) { |
82 | - if ( ! is_wp_error( $error ) ) |
|
83 | - break; |
|
82 | + if ( ! is_wp_error( $error ) ) { |
|
83 | + break; |
|
84 | + } |
|
84 | 85 | |
85 | 86 | switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) { |
86 | 87 | case 'post_password_required': |
@@ -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; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @param array $items Scripts or styles to exclude from no-conflict |
51 | 51 | * |
52 | - * @return array |
|
52 | + * @return string[] |
|
53 | 53 | */ |
54 | 54 | public function register_noconflict( $items ) { |
55 | 55 |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function add_admin_menu() { |
97 | 97 | |
98 | - $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
98 | + $menu_text = _x( 'Extensions', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
99 | 99 | |
100 | 100 | $menu_text = sprintf( '<span title="%s">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
101 | 101 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | - * When on the Installer page, show a different notice than on the Settings page |
|
114 | - * |
|
113 | + * When on the Installer page, show a different notice than on the Settings page |
|
114 | + * |
|
115 | 115 | * @param array $notice |
116 | 116 | * |
117 | 117 | * @return string License notice |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | public function maybe_modify_license_notice( $notice = '' ) { |
120 | 120 | |
121 | 121 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
122 | - return $notice; |
|
123 | - } |
|
122 | + return $notice; |
|
123 | + } |
|
124 | 124 | |
125 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
125 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -160,43 +160,43 @@ discard block |
||
160 | 160 | * Get downloads data from transient or from API; save transient after getting data from API |
161 | 161 | * |
162 | 162 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
163 | - * @type array $info { |
|
164 | - * @type string $id int 17 |
|
165 | - * @type string $slug Extension slug |
|
166 | - * @type string $title Extension title |
|
167 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
168 | - * @type string $modified_date |
|
169 | - * @type string $status |
|
170 | - * @type string $link URL to public plugin page |
|
171 | - * @type string $content |
|
172 | - * @type string $excerpt |
|
173 | - * @type string $thumbnail URL to thumbnail |
|
174 | - * @type array $category Taxonomy details for the plugin's category { |
|
175 | - * @type int $term_id => int 30 |
|
176 | - * @type string $name => string 'Plugins' (length=7) |
|
177 | - * @type string $slug => string 'plugins' (length=7) |
|
178 | - * @type int $term_group => int 0 |
|
179 | - * @type int $term_taxonomy_id => int 30 |
|
180 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
181 | - * @type string $description => string '' (length=0) |
|
182 | - * @type int $parent => int 0 |
|
183 | - * @type int $count => int 4 |
|
184 | - * @type string $filter => string 'raw' (length=3) |
|
185 | - * } |
|
186 | - * @type array $tags {see $category above} |
|
187 | - * @type string $textdomain string 'gravityview' (length=11) |
|
188 | - * } |
|
189 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
190 | - * @type array $licensing { |
|
191 | - * @type bool $enabled Is licensing enabled for the extension |
|
192 | - * @type string $version Version number |
|
193 | - * @type string $exp_unit Expiration unit ('years') |
|
194 | - * @type string $exp_length Expiration length ('1') |
|
195 | - * } |
|
196 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
197 | - * @type string $file string URL of the file download |
|
198 | - * } |
|
199 | - * } |
|
163 | + * @type array $info { |
|
164 | + * @type string $id int 17 |
|
165 | + * @type string $slug Extension slug |
|
166 | + * @type string $title Extension title |
|
167 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
168 | + * @type string $modified_date |
|
169 | + * @type string $status |
|
170 | + * @type string $link URL to public plugin page |
|
171 | + * @type string $content |
|
172 | + * @type string $excerpt |
|
173 | + * @type string $thumbnail URL to thumbnail |
|
174 | + * @type array $category Taxonomy details for the plugin's category { |
|
175 | + * @type int $term_id => int 30 |
|
176 | + * @type string $name => string 'Plugins' (length=7) |
|
177 | + * @type string $slug => string 'plugins' (length=7) |
|
178 | + * @type int $term_group => int 0 |
|
179 | + * @type int $term_taxonomy_id => int 30 |
|
180 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
181 | + * @type string $description => string '' (length=0) |
|
182 | + * @type int $parent => int 0 |
|
183 | + * @type int $count => int 4 |
|
184 | + * @type string $filter => string 'raw' (length=3) |
|
185 | + * } |
|
186 | + * @type array $tags {see $category above} |
|
187 | + * @type string $textdomain string 'gravityview' (length=11) |
|
188 | + * } |
|
189 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
190 | + * @type array $licensing { |
|
191 | + * @type bool $enabled Is licensing enabled for the extension |
|
192 | + * @type string $version Version number |
|
193 | + * @type string $exp_unit Expiration unit ('years') |
|
194 | + * @type string $exp_length Expiration length ('1') |
|
195 | + * } |
|
196 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
197 | + * @type string $file string URL of the file download |
|
198 | + * } |
|
199 | + * } |
|
200 | 200 | */ |
201 | 201 | public function get_downloads_data() { |
202 | 202 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | ) ); |
225 | 225 | |
226 | 226 | if ( is_wp_error( $response ) ) { |
227 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
227 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
228 | 228 | return $response; |
229 | 229 | } |
230 | 230 | |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | <div class="gv-admin-installer-notice notice inline error"> |
278 | 278 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
279 | 279 | <?php |
280 | - if ( is_wp_error( $downloads_data ) ) { |
|
281 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
282 | - } |
|
283 | - ?> |
|
280 | + if ( is_wp_error( $downloads_data ) ) { |
|
281 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
282 | + } |
|
283 | + ?> |
|
284 | 284 | </div> |
285 | 285 | </div> |
286 | 286 | <?php |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | protected function render_download( $download, $wp_plugins ) { |
337 | 337 | |
338 | 338 | |
339 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
339 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
340 | 340 | |
341 | - $download_info = $details['download_info']; |
|
341 | + $download_info = $details['download_info']; |
|
342 | 342 | |
343 | 343 | ?> |
344 | 344 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -367,25 +367,25 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
371 | - * |
|
370 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
371 | + * |
|
372 | 372 | * @param array $download Single download, as returned by {@see get_downloads_data} |
373 | 373 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
374 | 374 | * |
375 | 375 | * @return array { |
376 | - * @type array $download_info |
|
377 | - * @type string $plugin_path |
|
378 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
379 | - * @type string $status_label |
|
380 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
381 | - * @type string $button_class CSS class to use for the button |
|
382 | - * @type string $button_label Text to use for the download's anchor link |
|
383 | - * @type string $href URL for the download's button |
|
384 | - * @type bool $spinner Whether to show the spinner icon |
|
385 | - * @type string $item_class CSS class for the download container |
|
386 | - * @type string $required_license The name of the required license for the download ("Galactic" or "Interstellar") |
|
387 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
388 | - * } |
|
376 | + * @type array $download_info |
|
377 | + * @type string $plugin_path |
|
378 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
379 | + * @type string $status_label |
|
380 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
381 | + * @type string $button_class CSS class to use for the button |
|
382 | + * @type string $button_label Text to use for the download's anchor link |
|
383 | + * @type string $href URL for the download's button |
|
384 | + * @type bool $spinner Whether to show the spinner icon |
|
385 | + * @type string $item_class CSS class for the download container |
|
386 | + * @type string $required_license The name of the required license for the download ("Galactic" or "Interstellar") |
|
387 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
388 | + * } |
|
389 | 389 | */ |
390 | 390 | private function get_download_display_details( $download, $wp_plugins ) { |
391 | 391 | |
@@ -474,18 +474,18 @@ discard block |
||
474 | 474 | } |
475 | 475 | |
476 | 476 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
477 | - } |
|
477 | + } |
|
478 | 478 | |
479 | 479 | /** |
480 | - * Returns the base price for an extension |
|
481 | - * |
|
480 | + * Returns the base price for an extension |
|
481 | + * |
|
482 | 482 | * @param array $download |
483 | 483 | * |
484 | 484 | * @return float Base price for an extension. If not for sale separately, returns 0 |
485 | 485 | */ |
486 | 486 | private function get_download_base_price( $download ) { |
487 | 487 | |
488 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
488 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
489 | 489 | $base_price = \GFCommon::to_number( $base_price ); |
490 | 490 | |
491 | 491 | unset( $download['pricing']['amount'] ); |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | return floatval( $base_price ); |
499 | - } |
|
499 | + } |
|
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Handle AJAX request to activate extension |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | |
515 | 515 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
516 | 516 | wp_send_json_error( array( |
517 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
518 | - ) ); |
|
517 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
518 | + ) ); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | wp_send_json_success(); |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | deactivate_plugins( $data['path'] ); |
537 | 537 | |
538 | 538 | if( is_plugin_active( $data['path'] ) ) { |
539 | - wp_send_json_error( array( |
|
540 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
541 | - ) ); |
|
542 | - } |
|
539 | + wp_send_json_error( array( |
|
540 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
541 | + ) ); |
|
542 | + } |
|
543 | 543 | |
544 | 544 | wp_send_json_success(); |
545 | 545 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function register_noconflict( $items ) { |
55 | 55 | |
56 | - $items[] = 'gravityview-admin-installer'; |
|
56 | + $items[ ] = 'gravityview-admin-installer'; |
|
57 | 57 | |
58 | 58 | return $items; |
59 | 59 | } |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
73 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
73 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
74 | 74 | foreach ( $downloads_data as $extension ) { |
75 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
75 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | - return (object) array( |
|
80 | - 'slug' => $extension['info']['slug'], |
|
81 | - 'name' => $extension['info']['title'], |
|
82 | - 'version' => $extension['licensing']['version'], |
|
83 | - 'download_link' => $extension['files'][0]['file'], |
|
79 | + return (object)array( |
|
80 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
81 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
82 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
83 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | |
143 | 143 | foreach ( $all_plugins as $path => $plugin ) { |
144 | 144 | |
145 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
145 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
146 | 146 | continue; |
147 | 147 | } |
148 | 148 | |
149 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
149 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
150 | 150 | 'path' => $path, |
151 | - 'version' => $plugin['Version'], |
|
151 | + 'version' => $plugin[ 'Version' ], |
|
152 | 152 | 'activated' => is_plugin_active( $path ) |
153 | 153 | ); |
154 | 154 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | |
231 | 231 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
232 | 232 | |
233 | - if ( empty( $downloads_data['products'] ) ) { |
|
233 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
234 | 234 | return array(); |
235 | 235 | } |
236 | 236 | |
237 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
237 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
238 | 238 | |
239 | - return $downloads_data['products']; |
|
239 | + return $downloads_data[ 'products' ]; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | foreach ( $downloads_data as $extension ) { |
311 | 311 | |
312 | - if ( empty( $extension['info'] ) ) { |
|
312 | + if ( empty( $extension[ 'info' ] ) ) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | |
@@ -338,28 +338,28 @@ discard block |
||
338 | 338 | |
339 | 339 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
340 | 340 | |
341 | - $download_info = $details['download_info']; |
|
341 | + $download_info = $details[ 'download_info' ]; |
|
342 | 342 | |
343 | 343 | ?> |
344 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
344 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
345 | 345 | <div class="addon-inner"> |
346 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
347 | - <h3><?php echo esc_html( $download_info['title'] ); ?></h3> |
|
346 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
347 | + <h3><?php echo esc_html( $download_info[ 'title' ] ); ?></h3> |
|
348 | 348 | <div> |
349 | - <?php if( $details['status_label'] ) { ?> |
|
350 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
351 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
349 | + <?php if ( $details[ 'status_label' ] ) { ?> |
|
350 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
351 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
352 | 352 | </div> |
353 | 353 | <?php } ?> |
354 | 354 | |
355 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
356 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
357 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
355 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
356 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
357 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
358 | 358 | </a> |
359 | 359 | </div> |
360 | 360 | |
361 | 361 | <div class="addon-excerpt"> |
362 | - <?php echo wpautop( esc_html( $download_info['excerpt'] ) ); ?> |
|
362 | + <?php echo wpautop( esc_html( $download_info[ 'excerpt' ] ) ); ?> |
|
363 | 363 | </div> |
364 | 364 | </div> |
365 | 365 | </div> |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | */ |
390 | 390 | private function get_download_display_details( $download, $wp_plugins ) { |
391 | 391 | |
392 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
392 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
393 | 393 | 'thumbnail' => '', |
394 | 394 | 'title' => '', |
395 | 395 | 'textdomain' => '', |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | 'link' => '', |
399 | 399 | ) ); |
400 | 400 | |
401 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
401 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
402 | 402 | |
403 | - $has_access = ! empty( $download['files'] ); |
|
403 | + $has_access = ! empty( $download[ 'files' ] ); |
|
404 | 404 | $spinner = true; |
405 | 405 | $href = $plugin_path = '#'; |
406 | 406 | $status = $item_class = $button_title = $button_class = ''; |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $required_license = $galactic_only ? __( 'Galactic', 'gravityview' ) : __( 'Interstellar', 'gravityview' ); |
411 | 411 | |
412 | 412 | // The license is not active - no matter what level, this should not work |
413 | - if( ! $is_active && empty( $base_price ) ) { |
|
413 | + if ( ! $is_active && empty( $base_price ) ) { |
|
414 | 414 | $spinner = false; |
415 | 415 | $button_class = 'disabled disabled-license'; |
416 | 416 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $status_label = ''; |
423 | 423 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
424 | 424 | $button_class = 'button-primary button-large'; |
425 | - $href = $download_info['link']; |
|
425 | + $href = $download_info[ 'link' ]; |
|
426 | 426 | $item_class = 'featured'; |
427 | 427 | } |
428 | 428 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | $href = add_query_arg( |
442 | 442 | array( |
443 | 443 | 'action' => 'install-plugin', |
444 | - 'plugin' => $download_info['slug'], |
|
445 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
444 | + 'plugin' => $download_info[ 'slug' ], |
|
445 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
446 | 446 | ), |
447 | 447 | self_admin_url( 'update.php' ) |
448 | 448 | ); |
@@ -454,26 +454,26 @@ discard block |
||
454 | 454 | } |
455 | 455 | |
456 | 456 | // Access and the plugin is installed but not active |
457 | - else if ( false === $wp_plugin['activated'] ) { |
|
457 | + else if ( false === $wp_plugin[ 'activated' ] ) { |
|
458 | 458 | |
459 | 459 | $status = 'inactive'; |
460 | 460 | $status_label = __( 'Inactive', 'gravityview' ); |
461 | 461 | $button_label = __( 'Activate', 'gravityview' ); |
462 | - $plugin_path = $wp_plugin['path']; |
|
462 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
463 | 463 | |
464 | 464 | } |
465 | 465 | |
466 | 466 | // Access and the plugin is installed and active |
467 | 467 | else { |
468 | 468 | |
469 | - $plugin_path = $wp_plugin['path']; |
|
469 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
470 | 470 | $status = 'active'; |
471 | 471 | $status_label = __( 'Active', 'gravityview' ); |
472 | 472 | $button_label = __( 'Deactivate', 'gravityview' ); |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
476 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
489 | 489 | $base_price = \GFCommon::to_number( $base_price ); |
490 | 490 | |
491 | - unset( $download['pricing']['amount'] ); |
|
491 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
492 | 492 | |
493 | 493 | // Price options array, not single price |
494 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
495 | - $base_price = array_shift( $download['pricing'] ); |
|
494 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
495 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | return floatval( $base_price ); |
@@ -506,13 +506,13 @@ discard block |
||
506 | 506 | public function activate_download() { |
507 | 507 | $data = \GV\Utils::_POST( 'data', array() ); |
508 | 508 | |
509 | - if ( empty( $data['path'] ) ) { |
|
509 | + if ( empty( $data[ 'path' ] ) ) { |
|
510 | 510 | return; |
511 | 511 | } |
512 | 512 | |
513 | - $result = activate_plugin( $data['path'] ); |
|
513 | + $result = activate_plugin( $data[ 'path' ] ); |
|
514 | 514 | |
515 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
515 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
516 | 516 | wp_send_json_error( array( |
517 | 517 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
518 | 518 | ) ); |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | public function deactivate_download() { |
530 | 530 | $data = \GV\Utils::_POST( 'data', array() ); |
531 | 531 | |
532 | - if ( empty( $data['path'] ) ) { |
|
532 | + if ( empty( $data[ 'path' ] ) ) { |
|
533 | 533 | return; |
534 | 534 | } |
535 | 535 | |
536 | - deactivate_plugins( $data['path'] ); |
|
536 | + deactivate_plugins( $data[ 'path' ] ); |
|
537 | 537 | |
538 | - if( is_plugin_active( $data['path'] ) ) { |
|
538 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
539 | 539 | wp_send_json_error( array( |
540 | 540 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
541 | 541 | ) ); |