Changeset 2948258
- Timestamp:
- 08/06/2023 11:06:07 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sheet-music-library/trunk/template/template-parts.php
r2892031 r2948258 59 59 60 60 // Returns markup for last updated text for sheet music PDFs. Displays the newer date of the score and parts attachment files. 61 61 62 function sml_sheet_music_last_updated_text( $score_url = false, $parts_url = false ) { 62 63 if ( ! $score_url ) { … … 65 66 $score_attachment_id = absint( attachment_url_to_postid( $score_url ) ); 66 67 } 67 $score_date = get_the_modified_date( 'U', $score_attachment_id ); 68 // Handle empty attachment. 69 if ( $score_attachment_id ) { 70 $score_date = get_the_modified_date( 'U', $score_attachment_id ); 71 } else { 72 $score_date = 0; 73 } 68 74 69 75 if ( ! $parts_url ) { … … 72 78 $parts_attachment_id = absint( attachment_url_to_postid( $parts_url ) ); 73 79 } 74 $parts_date = get_the_modified_date( 'U', $parts_attachment_id ); 80 // Handle empty attachment. 81 if ( $parts_attachment_id ) { 82 $parts_date = get_the_modified_date( 'U', $parts_attachment_id ); 83 } else { 84 $parts_date = 0; 85 } 86 87 // Ensure that the modified date is not before the piece publish date. 88 $post_publish = absint( get_the_date( 'U', get_the_ID() ) ); 75 89 76 90 // Report the more recent attachment modified date. Note this is not necessarily the file-modified date, but any other attachment modify triggers are unlikely. 77 if ( $score_date > $parts_date ) { 91 // Falls back to the post published date if both attachments are missing. 92 if ( $post_publish > $score_date && $post_publish > $parts_date ) { 93 $date = get_the_date( 'F j, Y', get_the_id() ); 94 } elseif ( $score_date > $parts_date ) { 78 95 $date = get_the_modified_date( 'F j, Y', $score_attachment_id ); 79 96 } else {
Note: See TracChangeset
for help on using the changeset viewer.