@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | 'detail' => null, |
38 | 38 | ) ); |
39 | 39 | |
40 | - if ( ! $view_id = $atts['id'] ? : $atts['view_id'] ) { |
|
41 | - if ( $atts['detail'] && $view = $request->is_view() ) { |
|
40 | + if ( ! $view_id = $atts[ 'id' ] ?: $atts[ 'view_id' ] ) { |
|
41 | + if ( $atts[ 'detail' ] && $view = $request->is_view() ) { |
|
42 | 42 | $view_id = $view->ID; |
43 | 43 | } |
44 | 44 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return get_the_password_form( $view->ID ); |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! $view->form ) { |
|
83 | + if ( ! $view->form ) { |
|
84 | 84 | gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) ); |
85 | 85 | |
86 | 86 | /** |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
102 | 102 | } |
103 | 103 | |
104 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
104 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * View details. |
108 | 108 | */ |
109 | - if ( $atts['detail'] ) { |
|
109 | + if ( $atts[ 'detail' ] ) { |
|
110 | 110 | return $this->detail( $view, $entries, $atts ); |
111 | 111 | |
112 | 112 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | return ''; |
121 | 121 | } |
122 | 122 | |
123 | - if ( $entry['status'] != 'active' ) { |
|
123 | + if ( $entry[ 'status' ] != 'active' ) { |
|
124 | 124 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
125 | 125 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
126 | 126 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
134 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
134 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
135 | 135 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
136 | 136 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
137 | 137 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | return ''; |
152 | 152 | } |
153 | 153 | |
154 | - if ( $entry['status'] != 'active' ) { |
|
154 | + if ( $entry[ 'status' ] != 'active' ) { |
|
155 | 155 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
156 | 156 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
157 | 157 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | |
164 | 164 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
165 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
165 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
166 | 166 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
167 | 167 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
168 | 168 | } |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | |
180 | 180 | // Mock the request with the actual View, not the global one |
181 | 181 | $mock_request = new \GV\Mock_Request(); |
182 | - $mock_request->returns['is_view'] = $view; |
|
183 | - $mock_request->returns['is_entry'] = $request->is_entry(); |
|
184 | - $mock_request->returns['is_edit_entry'] = $request->is_edit_entry(); |
|
185 | - $mock_request->returns['is_search'] = $request->is_search(); |
|
182 | + $mock_request->returns[ 'is_view' ] = $view; |
|
183 | + $mock_request->returns[ 'is_entry' ] = $request->is_entry(); |
|
184 | + $mock_request->returns[ 'is_edit_entry' ] = $request->is_edit_entry(); |
|
185 | + $mock_request->returns[ 'is_search' ] = $request->is_search(); |
|
186 | 186 | |
187 | 187 | $request = $mock_request; |
188 | 188 | } |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $filtered_atts = shortcode_atts( $supported_atts, $passed_atts, 'gravityview' ); |
219 | 219 | |
220 | 220 | // Only keep the passed attributes after making sure that they're valid pairs |
221 | - $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( (array) $passed_atts, $filtered_atts ) : $filtered_atts; |
|
221 | + $filtered_atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( (array)$passed_atts, $filtered_atts ) : $filtered_atts; |
|
222 | 222 | |
223 | 223 | $atts = array(); |
224 | 224 | |
225 | - foreach( $filtered_atts as $key => $passed_value ) { |
|
225 | + foreach ( $filtered_atts as $key => $passed_value ) { |
|
226 | 226 | |
227 | 227 | // Allow using GravityView merge tags in shortcode attributes, like {get} and {created_by} |
228 | 228 | $passed_value = \GravityView_Merge_Tags::replace_variables( $passed_value ); |
229 | 229 | |
230 | - switch( $defaults[ $key ]['type'] ) { |
|
230 | + switch ( $defaults[ $key ][ 'type' ] ) { |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Make sure number fields are numeric. |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @see http://php.net/manual/en/function.is-numeric.php#107326 |
236 | 236 | */ |
237 | 237 | case 'number': |
238 | - if( is_numeric( $passed_value ) ) { |
|
238 | + if ( is_numeric( $passed_value ) ) { |
|
239 | 239 | $atts[ $key ] = ( $passed_value + 0 ); |
240 | 240 | } |
241 | 241 | break; |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | */ |
251 | 251 | case 'select': |
252 | 252 | case 'radio': |
253 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
254 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
253 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
254 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
255 | 255 | $atts[ $key ] = $passed_value; |
256 | 256 | } |
257 | 257 | break; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - $atts['detail'] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
266 | + $atts[ 'detail' ] = \GV\Utils::get( $passed_atts, 'detail', null ); |
|
267 | 267 | |
268 | 268 | return $atts; |
269 | 269 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | private function detail( $view, $entries, $atts ) { |
281 | 281 | $output = ''; |
282 | 282 | |
283 | - switch ( $key = $atts['detail'] ): |
|
283 | + switch ( $key = $atts[ 'detail' ] ): |
|
284 | 284 | case 'total_entries': |
285 | 285 | $output = number_format_i18n( $entries->total() ); |
286 | 286 | break; |