@@ -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 |
@@ -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 | } |
@@ -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': |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | 'class' => '', |
44 | 44 | ) ); |
45 | 45 | |
46 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
47 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
46 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
47 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
48 | 48 | $view_id = $view->ID; |
49 | 49 | } |
50 | 50 | } |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
117 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * View details. |
121 | 121 | */ |
122 | - if ( $atts['detail'] ) { |
|
122 | + if ( $atts[ 'detail' ] ) { |
|
123 | 123 | $entries = $view->get_entries( $request ); |
124 | 124 | return self::_return( $this->detail( $view, $entries, $atts ) ); |
125 | 125 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return self::_return( '' ); |
137 | 137 | } |
138 | 138 | |
139 | - if ( $entry['status'] != 'active' ) { |
|
139 | + if ( $entry[ 'status' ] != 'active' ) { |
|
140 | 140 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
141 | 141 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
142 | 142 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
150 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
150 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
151 | 151 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
152 | 152 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
153 | 153 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $entryset = $entry->is_multi() ? $entry->entries : array( $entry ); |
171 | 171 | |
172 | 172 | foreach ( $entryset as $e ) { |
173 | - if ( $e['status'] != 'active' ) { |
|
173 | + if ( $e[ 'status' ] != 'active' ) { |
|
174 | 174 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
175 | 175 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
184 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
184 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
185 | 185 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
186 | 186 | return self::_return( __( 'You are not allowed to view this content.', 'gravityview' ) ); |
187 | 187 | } |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | |
207 | 207 | // Mock the request with the actual View, not the global one |
208 | 208 | $mock_request = new \GV\Mock_Request(); |
209 | - $mock_request->returns['is_view'] = $view; |
|
210 | - $mock_request->returns['is_entry'] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
211 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
212 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
209 | + $mock_request->returns[ 'is_view' ] = $view; |
|
210 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry( $view->form ? $view->form->ID : 0 ); |
|
211 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ); |
|
212 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
213 | 213 | |
214 | 214 | $request = $mock_request; |
215 | 215 | } |
@@ -245,16 +245,16 @@ discard block |
||
245 | 245 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
246 | 246 | |
247 | 247 | // Only keep the passed attributes after making sure that they're valid pairs |
248 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
248 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
249 | 249 | |
250 | 250 | $atts = array(); |
251 | 251 | |
252 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
252 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
253 | 253 | |
254 | 254 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
255 | 255 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
256 | 256 | |
257 | - switch( $defaults[ $key ]['type'] ) { |
|
257 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Make sure number fields are numeric. |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
263 | 263 | */ |
264 | 264 | case 'number': |
265 | - if( is_numeric( $passed_value ) ) { |
|
265 | + if ( is_numeric( $passed_value ) ) { |
|
266 | 266 | $atts[ $key ] = ( $passed_value + 0 ); |
267 | 267 | } |
268 | 268 | break; |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | */ |
278 | 278 | case 'select': |
279 | 279 | case 'radio': |
280 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
281 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
280 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
281 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
282 | 282 | $atts[ $key ] = $passed_value; |
283 | 283 | } |
284 | 284 | break; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
293 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
294 | 294 | |
295 | 295 | return $atts; |
296 | 296 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | private function detail( $view, $entries, $atts ) { |
308 | 308 | $output = ''; |
309 | 309 | |
310 | - switch ( $key = $atts['detail'] ): |
|
310 | + switch ( $key = $atts[ 'detail' ] ): |
|
311 | 311 | case 'total_entries': |
312 | 312 | $output = number_format_i18n( $entries->total() ); |
313 | 313 | break; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | gravityview()->log->debug( '$passed_atts: ', array( 'data' => $passed_atts ) ); |
49 | 49 | |
50 | 50 | // Get details about the current View |
51 | - if( !empty( $passed_atts['detail'] ) ) { |
|
52 | - return $this->get_view_detail( $passed_atts['detail'] ); |
|
51 | + if ( ! empty( $passed_atts[ 'detail' ] ) ) { |
|
52 | + return $this->get_view_detail( $passed_atts[ 'detail' ] ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $atts = $this->parse_and_sanitize_atts( $passed_atts ); |
@@ -85,16 +85,16 @@ discard block |
||
85 | 85 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
86 | 86 | |
87 | 87 | // Only keep the passed attributes after making sure that they're valid pairs |
88 | - $filtered_atts = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
88 | + $filtered_atts = array_intersect_key( (array)$passed_atts, $filtered_atts ); |
|
89 | 89 | |
90 | 90 | $atts = array(); |
91 | 91 | |
92 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
92 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
93 | 93 | |
94 | 94 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
95 | 95 | $passed_value = GravityView_Merge_Tags::replace_variables( $passed_value ); |
96 | 96 | |
97 | - switch( $defaults[ $key ]['type'] ) { |
|
97 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Make sure number fields are numeric. |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
103 | 103 | */ |
104 | 104 | case 'number': |
105 | - if( is_numeric( $passed_value ) ) { |
|
105 | + if ( is_numeric( $passed_value ) ) { |
|
106 | 106 | $atts[ $key ] = ( $passed_value + 0 ); |
107 | 107 | } |
108 | 108 | break; |
109 | 109 | |
110 | 110 | /** @since 2.1 */ |
111 | 111 | case 'operator': |
112 | - if( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
112 | + if ( GFFormsModel::is_valid_operator( $passed_value ) ) { |
|
113 | 113 | $atts[ $key ] = $passed_value; |
114 | 114 | } |
115 | 115 | break; |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | */ |
125 | 125 | case 'select': |
126 | 126 | case 'radio': |
127 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
128 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
127 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
128 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
129 | 129 | $atts[ $key ] = $passed_value; |
130 | 130 | } |
131 | 131 | break; |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $gravityview_view = GravityView_View::getInstance(); |
155 | 155 | $return = ''; |
156 | 156 | |
157 | - switch( $detail ) { |
|
157 | + switch ( $detail ) { |
|
158 | 158 | case 'total_entries': |
159 | 159 | $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
160 | 160 | break; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class GravityView_Extension extends \GV\Extension { |
16 | 16 | public function __construct() { |
17 | - if( ! in_array( $this->_author, array( 'GravityView', 'Katz Web Services, Inc.', true ) ) ) { |
|
17 | + if ( ! in_array( $this->_author, array( 'GravityView', 'Katz Web Services, Inc.', true ) ) ) { |
|
18 | 18 | gravityview()->log->warning( '\GravityView_Extension is deprecated. Inherit from \GV\Extension instead', array( 'data' => $this ) ); |
19 | 19 | } |
20 | 20 | parent::__construct(); |
@@ -449,9 +449,7 @@ |
||
449 | 449 | $button_label = sprintf( __( 'Upgrade to %s for Access', 'gravityview' ), $required_license ); |
450 | 450 | $button_class = 'button-primary button-large'; |
451 | 451 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
452 | - } |
|
453 | - |
|
454 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
452 | + } elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
455 | 453 | $spinner = false; |
456 | 454 | $status = 'notinstalled'; |
457 | 455 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function add_downloads_data_filters() { |
68 | 68 | |
69 | - $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
69 | + $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
|
70 | 70 | |
71 | - if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
71 | + if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function add_admin_menu() { |
99 | 99 | |
100 | - $menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
100 | + $menu_text = _x( 'Manage Add-Ons', 'Extensions are WordPress plugins that add functionality to GravityView and Gravity Forms', 'gravityview' ); |
|
101 | 101 | |
102 | 102 | $menu_text = sprintf( '<span title="%s" style="margin: 0">%s</span>', esc_attr__( 'Plugins that extend GravityView and Gravity Forms functionality.', 'gravityview' ), $menu_text ); |
103 | 103 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * When on the Installer page, show a different notice than on the Settings page |
|
116 | - * |
|
115 | + * When on the Installer page, show a different notice than on the Settings page |
|
116 | + * |
|
117 | 117 | * @param array $notice |
118 | 118 | * |
119 | 119 | * @return string License notice |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | public function maybe_modify_license_notice( $notice = '' ) { |
122 | 122 | |
123 | 123 | if ( ! gravityview()->request->is_admin( '', 'downloads' ) ) { |
124 | - return $notice; |
|
125 | - } |
|
124 | + return $notice; |
|
125 | + } |
|
126 | 126 | |
127 | - return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
127 | + return esc_html__( 'Your license %s. Do you want access to these plugins? %sActivate your license%s or %sget a license here%s.', 'gravityview' ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -167,43 +167,43 @@ discard block |
||
167 | 167 | * Get downloads data from transient or from API; save transient after getting data from API |
168 | 168 | * |
169 | 169 | * @return WP_Error|array If error, returns WP_Error. If not valid JSON, empty array. Otherwise, this structure: { |
170 | - * @type array $info { |
|
171 | - * @type string $id int 17 |
|
172 | - * @type string $slug Extension slug |
|
173 | - * @type string $title Extension title |
|
174 | - * @type string $create_date in '2018-07-19 20:03:10' format |
|
175 | - * @type string $modified_date |
|
176 | - * @type string $status |
|
177 | - * @type string $link URL to public plugin page |
|
178 | - * @type string $content |
|
179 | - * @type string $excerpt |
|
180 | - * @type string $thumbnail URL to thumbnail |
|
181 | - * @type array $category Taxonomy details for the plugin's category { |
|
182 | - * @type int $term_id => int 30 |
|
183 | - * @type string $name => string 'Plugins' (length=7) |
|
184 | - * @type string $slug => string 'plugins' (length=7) |
|
185 | - * @type int $term_group => int 0 |
|
186 | - * @type int $term_taxonomy_id => int 30 |
|
187 | - * @type string $taxonomy => string 'download_category' (length=17) |
|
188 | - * @type string $description => string '' (length=0) |
|
189 | - * @type int $parent => int 0 |
|
190 | - * @type int $count => int 4 |
|
191 | - * @type string $filter => string 'raw' (length=3) |
|
192 | - * } |
|
193 | - * @type array $tags {see $category above} |
|
194 | - * @type string $textdomain string 'gravityview' (length=11) |
|
195 | - * } |
|
196 | - * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
197 | - * @type array $licensing { |
|
198 | - * @type bool $enabled Is licensing enabled for the extension |
|
199 | - * @type string $version Version number |
|
200 | - * @type string $exp_unit Expiration unit ('years') |
|
201 | - * @type string $exp_length Expiration length ('1') |
|
202 | - * } |
|
203 | - * @type array $files Array of files. Empty if user has no access to the file. { |
|
204 | - * @type string $file string URL of the file download |
|
205 | - * } |
|
206 | - * } |
|
170 | + * @type array $info { |
|
171 | + * @type string $id int 17 |
|
172 | + * @type string $slug Extension slug |
|
173 | + * @type string $title Extension title |
|
174 | + * @type string $create_date in '2018-07-19 20:03:10' format |
|
175 | + * @type string $modified_date |
|
176 | + * @type string $status |
|
177 | + * @type string $link URL to public plugin page |
|
178 | + * @type string $content |
|
179 | + * @type string $excerpt |
|
180 | + * @type string $thumbnail URL to thumbnail |
|
181 | + * @type array $category Taxonomy details for the plugin's category { |
|
182 | + * @type int $term_id => int 30 |
|
183 | + * @type string $name => string 'Plugins' (length=7) |
|
184 | + * @type string $slug => string 'plugins' (length=7) |
|
185 | + * @type int $term_group => int 0 |
|
186 | + * @type int $term_taxonomy_id => int 30 |
|
187 | + * @type string $taxonomy => string 'download_category' (length=17) |
|
188 | + * @type string $description => string '' (length=0) |
|
189 | + * @type int $parent => int 0 |
|
190 | + * @type int $count => int 4 |
|
191 | + * @type string $filter => string 'raw' (length=3) |
|
192 | + * } |
|
193 | + * @type array $tags {see $category above} |
|
194 | + * @type string $textdomain string 'gravityview' (length=11) |
|
195 | + * } |
|
196 | + * @type array $pricing array of `price_name_slugs` => '00.00' values, if price options exist |
|
197 | + * @type array $licensing { |
|
198 | + * @type bool $enabled Is licensing enabled for the extension |
|
199 | + * @type string $version Version number |
|
200 | + * @type string $exp_unit Expiration unit ('years') |
|
201 | + * @type string $exp_length Expiration length ('1') |
|
202 | + * } |
|
203 | + * @type array $files Array of files. Empty if user has no access to the file. { |
|
204 | + * @type string $file string URL of the file download |
|
205 | + * } |
|
206 | + * } |
|
207 | 207 | */ |
208 | 208 | public function get_downloads_data() { |
209 | 209 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ) ); |
236 | 236 | |
237 | 237 | if ( is_wp_error( $response ) ) { |
238 | - gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
238 | + gravityview()->log->error( "Extension data response is an error", array( 'data' => $response ) ); |
|
239 | 239 | return $response; |
240 | 240 | } |
241 | 241 | |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | <div class="gv-admin-installer-notice notice inline error"> |
289 | 289 | <h3><?php esc_html_e( 'Extensions and plugins data cannot be loaded at the moment. Please try again later.', 'gravityview' ); ?></h3> |
290 | 290 | <?php |
291 | - if ( is_wp_error( $downloads_data ) ) { |
|
292 | - echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
293 | - } |
|
294 | - ?> |
|
291 | + if ( is_wp_error( $downloads_data ) ) { |
|
292 | + echo wpautop( '<pre>' . esc_html( $downloads_data->get_error_message() ) . '</pre>' ); |
|
293 | + } |
|
294 | + ?> |
|
295 | 295 | </div> |
296 | 296 | </div> |
297 | 297 | <?php |
@@ -379,9 +379,9 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function render_download( $download, $wp_plugins ) { |
381 | 381 | |
382 | - $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
382 | + $details = $this->get_download_display_details( $download, $wp_plugins ); |
|
383 | 383 | |
384 | - $download_info = $details['download_info']; |
|
384 | + $download_info = $details['download_info']; |
|
385 | 385 | |
386 | 386 | ?> |
387 | 387 | <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
@@ -405,45 +405,45 @@ discard block |
||
405 | 405 | |
406 | 406 | <div class="addon-excerpt"><?php |
407 | 407 | |
408 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
408 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
409 | 409 | |
410 | - // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
411 | - $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
412 | - $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
410 | + // Allow some pure HTML tags, but remove everything else from the excerpt. |
|
411 | + $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
|
412 | + $replacements = array( '[b]', '[/b]', '[i]', '[/i]', '[code]', '[/code]' ); |
|
413 | 413 | |
414 | - $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
415 | - $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
414 | + $excerpt = str_replace( $tags, $replacements, $excerpt ); |
|
415 | + $excerpt = esc_html( strip_tags( $excerpt ) ); |
|
416 | 416 | $excerpt = str_replace( $replacements, $tags, $excerpt ); |
417 | 417 | |
418 | 418 | echo wpautop( $excerpt ); |
419 | - ?></div> |
|
419 | + ?></div> |
|
420 | 420 | </div> |
421 | 421 | </div> |
422 | 422 | <?php |
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
426 | - * Generates details array for the download to keep the render_download() method a bit tidier |
|
427 | - * |
|
426 | + * Generates details array for the download to keep the render_download() method a bit tidier |
|
427 | + * |
|
428 | 428 | * @since 2.10 Allow managing installed add-ons whether or not the user's license shows they have access. |
429 | 429 | * |
430 | 430 | * @param array $download Single download, as returned by {@see get_downloads_data} |
431 | 431 | * @param array $wp_plugins All active plugins, as returned by {@see get_plugins()} |
432 | 432 | * |
433 | 433 | * @return array { |
434 | - * @type array $download_info |
|
435 | - * @type string $plugin_path |
|
436 | - * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
437 | - * @type string $status_label |
|
438 | - * @type string $button_title Title attribute to show when hovering over the download's button |
|
439 | - * @type string $button_class CSS class to use for the button |
|
440 | - * @type string $button_label Text to use for the download's anchor link |
|
441 | - * @type string $href URL for the download's button |
|
442 | - * @type bool $spinner Whether to show the spinner icon |
|
443 | - * @type string $item_class CSS class for the download container |
|
444 | - * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
445 | - * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
446 | - * } |
|
434 | + * @type array $download_info |
|
435 | + * @type string $plugin_path |
|
436 | + * @type string $status License status returned by Easy Digital Downloads ("active", "inactive", "expired", "revoked", etc) |
|
437 | + * @type string $status_label |
|
438 | + * @type string $button_title Title attribute to show when hovering over the download's button |
|
439 | + * @type string $button_class CSS class to use for the button |
|
440 | + * @type string $button_label Text to use for the download's anchor link |
|
441 | + * @type string $href URL for the download's button |
|
442 | + * @type bool $spinner Whether to show the spinner icon |
|
443 | + * @type string $item_class CSS class for the download container |
|
444 | + * @type string $required_license The name of the required license for the download ("All Access" or "Core + Extensions") |
|
445 | + * @type bool $is_active Is the current GravityView license (as entered in Settings) active? |
|
446 | + * } |
|
447 | 447 | */ |
448 | 448 | private function get_download_display_details( $download, $wp_plugins ) { |
449 | 449 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | 'slug' => '', |
455 | 455 | 'excerpt' => '', |
456 | 456 | 'link' => '', |
457 | - 'coming_soon' => false, |
|
457 | + 'coming_soon' => false, |
|
458 | 458 | 'installer_title' => null, // May not be defined |
459 | 459 | 'installer_excerpt' => null, // May not be defined |
460 | 460 | ) ); |
@@ -496,14 +496,14 @@ discard block |
||
496 | 496 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
497 | 497 | } |
498 | 498 | |
499 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
500 | - $spinner = false; |
|
501 | - $status = 'notinstalled'; |
|
502 | - $status_label = __( 'Coming Soon', 'gravityview' ); |
|
503 | - $button_label = __( 'Learn More', 'gravityview' ); |
|
504 | - $button_class = 'button-primary button-large'; |
|
505 | - $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
506 | - } |
|
499 | + elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
500 | + $spinner = false; |
|
501 | + $status = 'notinstalled'; |
|
502 | + $status_label = __( 'Coming Soon', 'gravityview' ); |
|
503 | + $button_label = __( 'Learn More', 'gravityview' ); |
|
504 | + $button_class = 'button-primary button-large'; |
|
505 | + $href = \GV\Utils::get( $download_info, 'link', 'https://gravityview.co/extensions/' ); |
|
506 | + } |
|
507 | 507 | |
508 | 508 | // Access but the plugin is not installed |
509 | 509 | elseif ( ! $wp_plugin ) { |
@@ -547,18 +547,18 @@ discard block |
||
547 | 547 | $download_info['link'] = add_query_arg( array( 'license_key' => $license_key ), $download_info['link'] ); |
548 | 548 | |
549 | 549 | return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | 552 | /** |
553 | - * Returns the base price for an extension |
|
554 | - * |
|
553 | + * Returns the base price for an extension |
|
554 | + * |
|
555 | 555 | * @param array $download |
556 | 556 | * |
557 | 557 | * @return float Base price for an extension. If not for sale separately, returns 0 |
558 | 558 | */ |
559 | 559 | private function get_download_base_price( $download ) { |
560 | 560 | |
561 | - $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
561 | + $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
|
562 | 562 | $base_price = \GFCommon::to_number( $base_price ); |
563 | 563 | |
564 | 564 | unset( $download['pricing']['amount'] ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | return floatval( $base_price ); |
572 | - } |
|
572 | + } |
|
573 | 573 | |
574 | 574 | /** |
575 | 575 | * Handle AJAX request to activate extension |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | |
588 | 588 | if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
589 | 589 | wp_send_json_error( array( |
590 | - 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
591 | - ) ); |
|
590 | + 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
|
591 | + ) ); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | wp_send_json_success(); |
@@ -609,10 +609,10 @@ discard block |
||
609 | 609 | deactivate_plugins( $data['path'] ); |
610 | 610 | |
611 | 611 | if( is_plugin_active( $data['path'] ) ) { |
612 | - wp_send_json_error( array( |
|
613 | - 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
614 | - ) ); |
|
615 | - } |
|
612 | + wp_send_json_error( array( |
|
613 | + 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
|
614 | + ) ); |
|
615 | + } |
|
616 | 616 | |
617 | 617 | wp_send_json_success(); |
618 | 618 | } |
@@ -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 | } |
@@ -68,21 +68,21 @@ discard block |
||
68 | 68 | |
69 | 69 | $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
70 | 70 | |
71 | - if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
71 | + if ( ! $downloads_data && ! isset( $_GET[ 'cache' ] ) ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
76 | 76 | foreach ( $downloads_data as $extension ) { |
77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
81 | - return (object) array( |
|
82 | - 'slug' => $extension['info']['slug'], |
|
83 | - 'name' => $extension['info']['title'], |
|
84 | - 'version' => $extension['licensing']['version'], |
|
85 | - 'download_link' => $extension['files'][0]['file'], |
|
81 | + return (object)array( |
|
82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | |
150 | 150 | foreach ( $all_plugins as $path => $plugin ) { |
151 | 151 | |
152 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
152 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
153 | 153 | continue; |
154 | 154 | } |
155 | 155 | |
156 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
156 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
157 | 157 | 'path' => $path, |
158 | - 'version' => $plugin['Version'], |
|
158 | + 'version' => $plugin[ 'Version' ], |
|
159 | 159 | 'activated' => is_plugin_active( $path ) |
160 | 160 | ); |
161 | 161 | } |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | |
210 | 210 | $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT ); |
211 | 211 | |
212 | - if ( $downloads_data && ! isset( $_GET['cache'] ) ) { |
|
212 | + if ( $downloads_data && ! isset( $_GET[ 'cache' ] ) ) { |
|
213 | 213 | return $downloads_data; |
214 | 214 | } |
215 | 215 | |
216 | - if( \GV\Plugin::is_network_activated() ) { |
|
216 | + if ( \GV\Plugin::is_network_activated() ) { |
|
217 | 217 | $home_url = network_home_url(); |
218 | 218 | } else { |
219 | 219 | $home_url = home_url(); |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | |
242 | 242 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
243 | 243 | |
244 | - if ( empty( $downloads_data['products'] ) ) { |
|
244 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
245 | 245 | return array(); |
246 | 246 | } |
247 | 247 | |
248 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
248 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
249 | 249 | |
250 | - return $downloads_data['products']; |
|
250 | + return $downloads_data[ 'products' ]; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | <h2><?php esc_html_e( 'The following plugins extend GravityView and Gravity Forms functionality:', 'gravityview' ); ?></h2> |
309 | 309 | |
310 | - <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg(array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
310 | + <a class="button button-secondary gv-admin-installer-refresh-link" href="<?php echo add_query_arg( array( 'cache' => 1 ) ); ?>"><i class="dashicons dashicons-update" style="margin-top: .2em"></i> <?php esc_html_e( 'Refresh', 'gravityview' ); ?></a> |
|
311 | 311 | |
312 | 312 | <hr class="wp-header-end" /> |
313 | 313 | |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | |
325 | 325 | $this->render_section( 'extensions', esc_html__( 'GravityView Extensions', 'gravityview' ), $downloads_data, $wp_plugins ); |
326 | 326 | |
327 | - $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
327 | + $this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
328 | 328 | |
329 | - $this->render_section( 'labs', esc_html__( 'GravityView Labs', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
329 | + $this->render_section( 'labs', esc_html__( 'GravityView Labs', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
330 | 330 | |
331 | - $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
331 | + $this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins ); |
|
332 | 332 | ?> |
333 | 333 | </div> |
334 | 334 | </div> |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | continue; |
356 | 356 | } |
357 | 357 | |
358 | - if ( empty( $download['info'] ) ) { |
|
358 | + if ( empty( $download[ 'info' ] ) ) { |
|
359 | 359 | continue; |
360 | 360 | } |
361 | 361 | |
@@ -383,31 +383,31 @@ discard block |
||
383 | 383 | |
384 | 384 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
385 | 385 | |
386 | - $download_info = $details['download_info']; |
|
386 | + $download_info = $details[ 'download_info' ]; |
|
387 | 387 | |
388 | 388 | ?> |
389 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
389 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
390 | 390 | <div class="addon-inner"> |
391 | - <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> |
|
392 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
391 | + <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> |
|
392 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
393 | 393 | <div> |
394 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
395 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
396 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
394 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
395 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
396 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
397 | 397 | </div> |
398 | 398 | <?php } ?> |
399 | 399 | |
400 | - <?php if ( 'gravityview' !== $download_info['slug'] ) { ?> |
|
401 | - <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'] ); ?>"> |
|
402 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
403 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
400 | + <?php if ( 'gravityview' !== $download_info[ 'slug' ] ) { ?> |
|
401 | + <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' ] ); ?>"> |
|
402 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
403 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
404 | 404 | </a> |
405 | 405 | <?php } ?> |
406 | 406 | </div> |
407 | 407 | |
408 | 408 | <div class="addon-excerpt"><?php |
409 | 409 | |
410 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
410 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
411 | 411 | |
412 | 412 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
413 | 413 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | private function get_download_display_details( $download, $wp_plugins ) { |
451 | 451 | |
452 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
452 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
453 | 453 | 'thumbnail' => '', |
454 | 454 | 'title' => '', |
455 | 455 | 'textdomain' => '', |
@@ -461,9 +461,9 @@ discard block |
||
461 | 461 | 'installer_excerpt' => null, // May not be defined |
462 | 462 | ) ); |
463 | 463 | |
464 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
464 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
465 | 465 | |
466 | - $has_access = ! empty( $download['files'] ); |
|
466 | + $has_access = ! empty( $download[ 'files' ] ); |
|
467 | 467 | $spinner = true; |
468 | 468 | $href = $plugin_path = '#'; |
469 | 469 | $status = $item_class = $button_title = $button_class = ''; |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
474 | 474 | |
475 | 475 | // The license is not active - no matter what level, this should not work |
476 | - if( ! $is_active && empty( $base_price ) ) { |
|
476 | + if ( ! $is_active && empty( $base_price ) ) { |
|
477 | 477 | $spinner = false; |
478 | 478 | $status_label = ''; |
479 | 479 | $button_label = sprintf( __( 'Active %s License is Required.', 'gravityview' ), $required_license ); |
480 | - $href = $download_info['link']; |
|
480 | + $href = $download_info[ 'link' ]; |
|
481 | 481 | $button_class = 'button-primary'; |
482 | 482 | } |
483 | 483 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $status_label = ''; |
488 | 488 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
489 | 489 | $button_class = 'button-primary button-large'; |
490 | - $href = $download_info['link']; |
|
490 | + $href = $download_info[ 'link' ]; |
|
491 | 491 | $item_class = 'featured'; |
492 | 492 | } |
493 | 493 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
501 | 501 | } |
502 | 502 | |
503 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
503 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
504 | 504 | $spinner = false; |
505 | 505 | $status = 'notinstalled'; |
506 | 506 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | $href = add_query_arg( |
516 | 516 | array( |
517 | 517 | 'action' => 'install-plugin', |
518 | - 'plugin' => $download_info['slug'], |
|
519 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
518 | + 'plugin' => $download_info[ 'slug' ], |
|
519 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
520 | 520 | ), |
521 | 521 | self_admin_url( 'update.php' ) |
522 | 522 | ); |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | $status = 'inactive'; |
533 | 533 | $status_label = __( 'Inactive', 'gravityview' ); |
534 | 534 | $button_label = __( 'Activate', 'gravityview' ); |
535 | - $plugin_path = $wp_plugin['path']; |
|
535 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
536 | 536 | $button_class = 'button-secondary'; |
537 | 537 | } |
538 | 538 | // The plugin is installed and active |
539 | - elseif ( ! empty( $wp_plugin['path'] ) ) { |
|
540 | - $plugin_path = $wp_plugin['path']; |
|
539 | + elseif ( ! empty( $wp_plugin[ 'path' ] ) ) { |
|
540 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
541 | 541 | $status = 'active'; |
542 | 542 | $status_label = __( 'Active', 'gravityview' ); |
543 | 543 | $button_label = __( 'Deactivate', 'gravityview' ); |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | $href = add_query_arg( array( 'license_key' => $license_key ), $href ); |
551 | 551 | } |
552 | 552 | |
553 | - $download_info['link'] = add_query_arg( array( 'license_key' => $license_key ), $download_info['link'] ); |
|
553 | + $download_info[ 'link' ] = add_query_arg( array( 'license_key' => $license_key ), $download_info[ 'link' ] ); |
|
554 | 554 | |
555 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
555 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -567,11 +567,11 @@ discard block |
||
567 | 567 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
568 | 568 | $base_price = \GFCommon::to_number( $base_price ); |
569 | 569 | |
570 | - unset( $download['pricing']['amount'] ); |
|
570 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
571 | 571 | |
572 | 572 | // Price options array, not single price |
573 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
574 | - $base_price = array_shift( $download['pricing'] ); |
|
573 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
574 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | return floatval( $base_price ); |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | public function activate_download() { |
586 | 586 | $data = \GV\Utils::_POST( 'data', array() ); |
587 | 587 | |
588 | - if ( empty( $data['path'] ) ) { |
|
588 | + if ( empty( $data[ 'path' ] ) ) { |
|
589 | 589 | return; |
590 | 590 | } |
591 | 591 | |
592 | - $result = activate_plugin( $data['path'] ); |
|
592 | + $result = activate_plugin( $data[ 'path' ] ); |
|
593 | 593 | |
594 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
594 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
595 | 595 | wp_send_json_error( array( |
596 | 596 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
597 | 597 | ) ); |
@@ -608,13 +608,13 @@ discard block |
||
608 | 608 | public function deactivate_download() { |
609 | 609 | $data = \GV\Utils::_POST( 'data', array() ); |
610 | 610 | |
611 | - if ( empty( $data['path'] ) ) { |
|
611 | + if ( empty( $data[ 'path' ] ) ) { |
|
612 | 612 | return; |
613 | 613 | } |
614 | 614 | |
615 | - deactivate_plugins( $data['path'] ); |
|
615 | + deactivate_plugins( $data[ 'path' ] ); |
|
616 | 616 | |
617 | - if( is_plugin_active( $data['path'] ) ) { |
|
617 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
618 | 618 | wp_send_json_error( array( |
619 | 619 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
620 | 620 | ) ); |
@@ -78,7 +78,7 @@ |
||
78 | 78 | $gv_page = gravityview()->request->is_admin( '', 'single' ); |
79 | 79 | |
80 | 80 | // New View or Edit View page |
81 | - if( $gv_page && $pagenow === 'post-new.php' ) { |
|
81 | + if ( $gv_page && $pagenow === 'post-new.php' ) { |
|
82 | 82 | remove_meta_box( 'woothemes-settings', 'gravityview', 'normal' ); |
83 | 83 | } |
84 | 84 | } |