@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | if ( ! empty( $passed_post ) ) { |
| 22 | 22 | $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
| 23 | - foreach( is_array( $id_or_id_array ) ? $id_or_id_array : array( $id_or_id_array ) as $view_id ) { |
|
| 23 | + foreach ( is_array( $id_or_id_array ) ? $id_or_id_array : array( $id_or_id_array ) as $view_id ) { |
|
| 24 | 24 | if ( \GV\View::exists( $view_id ) && ! $this->views->contains( $view_id ) ) { |
| 25 | 25 | $this->views->add( \GV\View::by_id( $view_id ) ); |
| 26 | 26 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | foreach ( $passed_post as &$post ) { |
| 79 | 79 | $views = \GV\View_Collection::from_post( $post ); |
| 80 | 80 | foreach ( $views->all() as $view ) { |
| 81 | - $ids []= $view->ID; |
|
| 81 | + $ids [ ] = $view->ID; |
|
| 82 | 82 | |
| 83 | 83 | /** And as a side-effect... add each view to the global scope. */ |
| 84 | 84 | if ( ! $this->views->contains( $view->ID ) ) { |
@@ -92,18 +92,18 @@ discard block |
||
| 92 | 92 | if ( is_string( $passed_post ) ) { |
| 93 | 93 | $shortcodes = \GV\Shortcode::parse( $passed_post ); |
| 94 | 94 | foreach ( $shortcodes as $shortcode ) { |
| 95 | - if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) { |
|
| 96 | - $ids []= $shortcode->atts['id']; |
|
| 95 | + if ( $shortcode->name == 'gravityview' && ! empty( $shortcode->atts[ 'id' ] ) ) { |
|
| 96 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
| 97 | 97 | |
| 98 | 98 | /** And as a side-effect... add each view to the global scope. */ |
| 99 | - if ( ! $this->views->contains( $shortcode->atts['id'] ) && \GV\View::exists( $shortcode->atts['id'] ) ) { |
|
| 100 | - $this->views->add( $shortcode->atts['id'] ); |
|
| 99 | + if ( ! $this->views->contains( $shortcode->atts[ 'id' ] ) && \GV\View::exists( $shortcode->atts[ 'id' ] ) ) { |
|
| 100 | + $this->views->add( $shortcode->atts[ 'id' ] ); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } else { |
| 105 | 105 | $id = $this->get_id_from_atts( $passed_post ); |
| 106 | - $ids[] = intval( $id ); |
|
| 106 | + $ids[ ] = intval( $id ); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | // If it's just one ID, return that. |
| 115 | 115 | // Otherwise, return array of IDs |
| 116 | - return ( count( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 116 | + return ( count( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public static function getInstance( $passed_post = NULL ) { |
| 123 | 123 | |
| 124 | - if( empty( self::$instance ) ) { |
|
| 124 | + if ( empty( self::$instance ) ) { |
|
| 125 | 125 | self::$instance = new GravityView_View_Data( $passed_post ); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -137,8 +137,8 @@ discard block |
||
| 137 | 137 | return array(); |
| 138 | 138 | } |
| 139 | 139 | return array_combine( |
| 140 | - array_map( function ( $view ) { return $view->ID; }, $this->views->all() ), |
|
| 141 | - array_map( function ( $view ) { return $view->as_data(); }, $this->views->all() ) |
|
| 140 | + array_map( function( $view ) { return $view->ID; }, $this->views->all() ), |
|
| 141 | + array_map( function( $view ) { return $view->as_data(); }, $this->views->all() ) |
|
| 142 | 142 | ); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -252,22 +252,22 @@ discard block |
||
| 252 | 252 | public function parse_post_content( $content ) { |
| 253 | 253 | $ids = array(); |
| 254 | 254 | foreach ( \GV\Shortcode::parse( $content ) as $shortcode ) { |
| 255 | - if ( $shortcode->name == 'gravityview' && is_numeric( $shortcode->atts['id'] ) ) { |
|
| 256 | - if ( \GV\View::exists( $shortcode->atts['id'] ) && ! $this->views->contains( $shortcode->atts['id'] ) ) { |
|
| 257 | - $this->views->add( \GV\View::by_id( $shortcode->atts['id'] ) ); |
|
| 255 | + if ( $shortcode->name == 'gravityview' && is_numeric( $shortcode->atts[ 'id' ] ) ) { |
|
| 256 | + if ( \GV\View::exists( $shortcode->atts[ 'id' ] ) && ! $this->views->contains( $shortcode->atts[ 'id' ] ) ) { |
|
| 257 | + $this->views->add( \GV\View::by_id( $shortcode->atts[ 'id' ] ) ); |
|
| 258 | 258 | } |
| 259 | 259 | /** |
| 260 | 260 | * The original function outputs the ID even though it wasn't added by ::add_view() |
| 261 | 261 | * Wether this is a bug or not remains a mystery. But we need to emulate this behavior |
| 262 | 262 | * until better times. |
| 263 | 263 | */ |
| 264 | - $ids []= $shortcode->atts['id']; |
|
| 264 | + $ids [ ] = $shortcode->atts[ 'id' ]; |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | if ( empty ( $ids ) ) { |
| 268 | 268 | return null; |
| 269 | 269 | } |
| 270 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 270 | + return ( sizeof( $ids ) === 1 ) ? $ids[ 0 ] : $ids; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | // Not invalid if not set! |
| 291 | 291 | if ( empty( $post_id ) || empty( $view_id ) ) { |
| 292 | 292 | |
| 293 | - if( $empty_is_valid ) { |
|
| 293 | + if ( $empty_is_valid ) { |
|
| 294 | 294 | return true; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); |
| 324 | 324 | |
| 325 | 325 | // The post or page specified does not contain the shortcode. |
| 326 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
| 326 | + if ( false === in_array( $view_id, (array)$view_ids_in_post ) ) { |
|
| 327 | 327 | $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | if ( ! $message ) { |
| 332 | 332 | // It's a View |
| 333 | 333 | if ( \GV\View::exists( $post_id ) ) { |
| 334 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
| 334 | + $message = esc_html__( 'The ID is already a View.', 'gravityview' ); ; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |