Skip to content

Commit

Permalink
Fix PHP Notice: Trying to get property of non-object, where the post …
Browse files Browse the repository at this point in the history
…ID saved in ACF referred to a deleted post.
  • Loading branch information
polevaultweb committed Apr 26, 2019
1 parent 9ef9343 commit d354915
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PostType/Testimonial.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ public static function fetch_by_section( $section, $post_id = false ) {
$testimonials = ACF::get_repeater_field( $section, array( 'testimonial' ), $post_id );
foreach ( $testimonials as $testimonial ) {
if ( is_array( $testimonial ) && isset( $testimonial['testimonial'] ) ) {
$all_testimonials[] = new \DeliciousBrains\WPTestimonials\Model\Testimonial( $testimonial['testimonial'] );
$testimonial_object = new \DeliciousBrains\WPTestimonials\Model\Testimonial( $testimonial['testimonial'] );
if ( ! isset( $testimonial_object->name ) ) {
continue;
}

$all_testimonials[] = $testimonial_object;
}
}

Expand Down

0 comments on commit d354915

Please sign in to comment.