Plugin Directory

Changeset 2886957

Timestamp:
03/26/2023 12:00:13 AM (17 months ago)
Author:
celloexpressions
Message:

Sheet Music Library: Add fallback handling to account for missing attachment post objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sheet-music-library/trunk/admin/post-meta.php

    r2270479 r2886957  
    4848        $score_attachment_id = absint( $sml_stored_meta['score-attachment-id'][0] );
    4949        $score = get_post( $score_attachment_id );
    50         $score_attachment_title = $score->post_title;
     50        if ( $score === null ) {
     51            $score_attachment_title = '';
     52        } else {
     53            $score_attachment_title = $score->post_title;
     54        }
    5155        $score_attachment_link = wp_get_attachment_url( $score_attachment_id );
    5256        $score_attachment_image = esc_url( get_post_meta( $score_attachment_id, 'pdf_thumbnail_url', true ) );
     
    6165        $parts_attachment_id = absint( $sml_stored_meta['parts-attachment-id'][0] );
    6266        $parts = get_post( $parts_attachment_id );
    63         $parts_attachment_title = $parts->post_title;
     67        if ( $parts === null ) {
     68            $parts_attachment_title = '';
     69        } else {
     70            $parts_attachment_title = $parts->post_title;
     71        }
    6472        $parts_attachment_link = wp_get_attachment_url( $parts_attachment_id );
    6573    } else {
     
    7280        $audio_attachment_id = absint( $sml_stored_meta['audio-attachment-id'][0] );
    7381        $audio = get_post( $audio_attachment_id );
    74         $audio_attachment_title = $audio->post_title;
     82        if ( $audio === null ) {
     83            $audio_attachment_title = '';
     84        } else {
     85            $audio_attachment_title = $audio->post_title;
     86        }
    7587        $audio_attachment = wp_prepare_attachment_for_js( $audio_attachment_id );
    7688    } else {
Note: See TracChangeset for help on using the changeset viewer.