@@ -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 = array_intersect_key( (array) $passed_atts, $filtered_atts ); |
|
| 221 | + $filtered_atts = array_intersect_key( (array)$passed_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; |
@@ -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,7 +102,7 @@ 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; |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | case 'select': |
| 119 | 119 | case 'radio': |
| 120 | - $options = isset( $defaults[ $key ]['choices'] ) ? $defaults[ $key ]['choices'] : $defaults[ $key ]['options']; |
|
| 121 | - if( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 120 | + $options = isset( $defaults[ $key ][ 'choices' ] ) ? $defaults[ $key ][ 'choices' ] : $defaults[ $key ][ 'options' ]; |
|
| 121 | + if ( in_array( $passed_value, array_keys( $options ) ) ) { |
|
| 122 | 122 | $atts[ $key ] = $passed_value; |
| 123 | 123 | } |
| 124 | 124 | break; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | $gravityview_view = GravityView_View::getInstance(); |
| 148 | 148 | $return = ''; |
| 149 | 149 | |
| 150 | - switch( $detail ) { |
|
| 150 | + switch ( $detail ) { |
|
| 151 | 151 | case 'total_entries': |
| 152 | 152 | $return = number_format_i18n( $gravityview_view->getTotalEntries() ); |
| 153 | 153 | break; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public static function get_instance() { |
| 89 | 89 | |
| 90 | - if( empty( self::$instance ) ) { |
|
| 90 | + if ( empty( self::$instance ) ) { |
|
| 91 | 91 | self::$instance = new self; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -121,9 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
| 123 | 123 | |
| 124 | - if( $with_values ) { |
|
| 124 | + if ( $with_values ) { |
|
| 125 | 125 | $operators_with_values = array(); |
| 126 | - foreach( $operators as $key ) { |
|
| 126 | + foreach ( $operators as $key ) { |
|
| 127 | 127 | $operators_with_values[ $key ] = ''; |
| 128 | 128 | } |
| 129 | 129 | return $operators_with_values; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | $operators = $this->get_operators( false ); |
| 144 | 144 | |
| 145 | - if( !in_array( $operation, $operators ) ) { |
|
| 145 | + if ( ! in_array( $operation, $operators ) ) { |
|
| 146 | 146 | gravityview()->log->debug( ' Attempted to add invalid operation type. {operation}', array( 'operation' => $operation ) ); |
| 147 | 147 | return false; |
| 148 | 148 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | return null; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if( empty( $atts ) ) { |
|
| 197 | + if ( empty( $atts ) ) { |
|
| 198 | 198 | gravityview()->log->error( '$atts are empty.', array( 'data' => $atts ) ); |
| 199 | 199 | return null; |
| 200 | 200 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $this->parse_atts(); |
| 210 | 210 | |
| 211 | 211 | // We need an "if" |
| 212 | - if( false === $this->if ) { |
|
| 212 | + if ( false === $this->if ) { |
|
| 213 | 213 | gravityview()->log->error( '$atts->if is empty.', array( 'data' => $this->passed_atts ) ); |
| 214 | 214 | return null; |
| 215 | 215 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $setup = $this->setup_operation_and_comparison(); |
| 218 | 218 | |
| 219 | 219 | // We need an operation and comparison value |
| 220 | - if( ! $setup ) { |
|
| 220 | + if ( ! $setup ) { |
|
| 221 | 221 | gravityview()->log->error( 'No valid operators were passed.', array( 'data' => $this->atts ) ); |
| 222 | 222 | return null; |
| 223 | 223 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | private function get_output() { |
| 269 | 269 | |
| 270 | - if( $this->is_match ) { |
|
| 270 | + if ( $this->is_match ) { |
|
| 271 | 271 | $output = $this->content; |
| 272 | 272 | } else { |
| 273 | 273 | $output = $this->else_content; |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param string $output HTML/text output |
| 286 | 286 | * @param GVLogic_Shortcode $this This class |
| 287 | 287 | */ |
| 288 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
| 288 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
| 289 | 289 | |
| 290 | 290 | gravityview()->log->debug( 'Output: ', array( 'data' => $output ) ); |
| 291 | 291 | |
@@ -305,14 +305,14 @@ discard block |
||
| 305 | 305 | list( $before_else, $after_else ) = array_pad( explode( '[else]', $passed_content ), 2, NULL ); |
| 306 | 306 | list( $before_else_if, $after_else_if ) = array_pad( explode( '[else', $passed_content ), 2, NULL ); |
| 307 | 307 | |
| 308 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
| 308 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
| 309 | 309 | $else_content = isset( $after_else ) ? $after_else : $else_attr; |
| 310 | 310 | |
| 311 | 311 | // The content is everything OTHER than the [else] |
| 312 | 312 | $this->content = $before_else_if; |
| 313 | 313 | |
| 314 | 314 | if ( ! $this->is_match ) { |
| 315 | - if( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
| 315 | + if ( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
| 316 | 316 | $this->else_content = $elseif_content; |
| 317 | 317 | } else { |
| 318 | 318 | $this->else_content = $else_content; |
@@ -340,16 +340,16 @@ discard block |
||
| 340 | 340 | foreach ( $else_if_matches as $key => $else_if_match ) { |
| 341 | 341 | |
| 342 | 342 | // If $else_if_match[5] exists and has content, check for more shortcodes |
| 343 | - preg_match_all( '/' . $regex . '/', $else_if_match[5] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
| 343 | + preg_match_all( '/' . $regex . '/', $else_if_match[ 5 ] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
| 344 | 344 | |
| 345 | 345 | // If the logic passes, this is the value that should be used for $this->else_content |
| 346 | - $else_if_value = $else_if_match[5]; |
|
| 347 | - $check_elseif_match = $else_if_match[0]; |
|
| 346 | + $else_if_value = $else_if_match[ 5 ]; |
|
| 347 | + $check_elseif_match = $else_if_match[ 0 ]; |
|
| 348 | 348 | |
| 349 | 349 | // Retrieve the value of the match that is currently being checked, without any other [else] tags |
| 350 | - if( ! empty( $recursive_matches[0][0] ) ) { |
|
| 351 | - $else_if_value = str_replace( $recursive_matches[0][0], '', $else_if_value ); |
|
| 352 | - $check_elseif_match = str_replace( $recursive_matches[0][0], '', $check_elseif_match ); |
|
| 350 | + if ( ! empty( $recursive_matches[ 0 ][ 0 ] ) ) { |
|
| 351 | + $else_if_value = str_replace( $recursive_matches[ 0 ][ 0 ], '', $else_if_value ); |
|
| 352 | + $check_elseif_match = str_replace( $recursive_matches[ 0 ][ 0 ], '', $check_elseif_match ); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | $check_elseif_match = str_replace( '[else', '[gvlogicelse', $check_elseif_match ); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Process any remaining [else] tags |
| 369 | - return $this->process_elseif( $else_if_match[5] ); |
|
| 369 | + return $this->process_elseif( $else_if_match[ 5 ] ); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | return false; |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $this->atts = array_intersect_key( $this->passed_atts, $this->atts ); |
| 393 | 393 | |
| 394 | 394 | // Strip whitespace if it's not default false |
| 395 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
| 395 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | 398 | * @action `gravityview/gvlogic/parse_atts/after` Modify shortcode attributes after it's been parsed |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | do_action( 'gravityview/gvlogic/parse_atts/after', $this ); |
| 404 | 404 | |
| 405 | 405 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
| 406 | - unset( $this->atts['if'] ); |
|
| 406 | + unset( $this->atts[ 'if' ] ); |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |