Changeset 2892031
- Timestamp:
- 04/01/2023 11:31:37 PM (16 months ago)
- Location:
- sheet-music-library/trunk/template
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sheet-music-library/trunk/template/template-filters.php
r2886954 r2892031 17 17 $no_download_message = get_post_meta( get_the_ID(), 'no-download-message', true ); 18 18 $button_text = ( $no_download_message ) ? __( 'View Piece →', 'sheet-music-library' ) : __( 'View & Download →', 'sheet-music-library' ); 19 19 20 20 ob_start(); 21 21 ?> … … 71 71 72 72 $video_url = esc_url( get_post_meta( get_the_ID(), 'piece-video-url', true ) ); 73 73 74 74 $no_download_message = get_post_meta( get_the_ID(), 'no-download-message', true ); 75 75 $no_download_message = wp_kses( $no_download_message, array( … … 134 134 // Filter post titles in archive contexts 135 135 function sml_post_title_filter( $title, $post_id ) { 136 if ( 'sheet_music' === get_post_type() && ! current_theme_supports( 'sheet_music_library' ) ) { 137 if ( ! is_singular() ) { 138 $no_download_message = get_post_meta( $post_id, 'no-download-message', true ); 139 if ( $no_download_message ) { 140 if ( ! is_admin() ) { 141 $title = '<span class="sml-restricted"></span>' . $title; 142 } else { 143 $title = '* ' . $title; 144 } 136 if ( 'sheet_music' === get_post_type( $post_id ) ) { 137 $no_download_message = get_post_meta( $post_id, 'no-download-message', true ); 138 if ( $no_download_message ) { 139 if ( ! is_admin() ) { 140 $title = '<span class="sml-restricted"></span>' . $title; 141 } else { 142 $title = '* ' . $title; 145 143 } 146 144 } … … 151 149 // All sheet music shortcode. 152 150 function sml_shortcode_all_sheet_music() { 153 $pieces = get_posts( array( 151 $pieces = get_posts( array( 154 152 'numberposts' => '-1', 155 153 'post_type' => 'sheet_music', … … 163 161 'number' => 10, 164 162 ), $attrs ); 165 $pieces = get_posts( array( 163 $pieces = get_posts( array( 166 164 'numberposts' => absint( $a['number'] ), 167 165 'post_type' => 'sheet_music', -
sheet-music-library/trunk/template/template-parts.php
r2886952 r2892031 19 19 20 20 // Returns markup for the download buttons and terms. 21 function sml_sheet_music_download_box( $score_url, $parts_url, $no_download_message ) {21 function sml_sheet_music_download_box( $score_url, $parts_url, $no_download_message ) { 22 22 23 23 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 24 $wrapper_attributes = get_block_wrapper_attributes(); 25 26 ob_start(); 27 ?><div class="download-box" <?php echo $wrapper_attributes; ?>> 24 if ( null === $block_attributes ) { 25 $wrapper_attributes = 'class="download-box"'; 26 } else { 27 $wrapper_attributes = get_block_wrapper_attributes(['class' => 'download-box']); 28 } 29 30 ob_start(); 31 ?><div <?php echo $wrapper_attributes; ?>> 28 32 <?php 29 33 if ( '' === $score_url && '' === $parts_url && '' === $no_download_message ) { … … 81 85 82 86 // Returns markup for the download buttons and terms for the current post. 83 function sml_sheet_music_download_box_current() { 87 // Block attributes is provided when this is run as a block render_callback. 88 function sml_sheet_music_download_box_current( $block_attributes = null ) { 84 89 85 90 // Get post meta fields' data. … … 105 110 ) ); 106 111 107 return sml_sheet_music_download_box( $score_url, $parts_url, $no_download_message );112 return sml_sheet_music_download_box( $score_url, $parts_url, $no_download_message ); 108 113 } 109 114 110 115 111 116 // Returns markup for a linked preview image for the current sheet music piece. 112 function sml_score_preview_current() { 113 114 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 115 $wrapper_attributes = get_block_wrapper_attributes(); 117 function sml_score_preview_current( $block_attributes = null ) { 118 119 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 120 if ( null === $block_attributes ) { 121 $wrapper_attributes = 'class="piece-preview"'; 122 } else { 123 $wrapper_attributes = get_block_wrapper_attributes(['class' => 'piece-preview']); 124 } 116 125 117 126 // Get post meta fields' data. … … 128 137 129 138 if ( $image_url && ! $no_download_message ) { ?> 130 <div class="piece-preview"<?php echo $wrapper_attributes; ?>>139 <div <?php echo $wrapper_attributes; ?>> 131 140 <a href="<?php echo $score_url; ?>" target="_blank"><img class="score-preview" src="<?php echo $image_url; ?>" alt="score preview"/></a> 132 141 </div> … … 135 144 // Dynamic blocks in the editor are rendered through REST API, frontend blocks are called directly. 136 145 elseif ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { ?> 137 <div class="piece-preview"<?php echo $wrapper_attributes; ?>>146 <div <?php echo $wrapper_attributes; ?>> 138 147 <div class="score-preview placeholder"> 139 148 <?php … … 155 164 156 165 // Returns markup for a button-link to a single piece from an archive excerpt view. 157 function sml_excerpt_button_current() { 158 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 159 $wrapper_attributes = get_block_wrapper_attributes(); 166 function sml_excerpt_button_current( $block_attributes = null ) { 167 168 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 169 if ( null === $block_attributes ) { 170 $wrapper_attributes = 'class="download-box"'; 171 } else { 172 $wrapper_attributes = get_block_wrapper_attributes(['class' => 'download-box']); 173 } 160 174 161 175 // Get post meta fields' data. … … 166 180 ?> 167 181 168 <div class="download-box"<?php echo $wrapper_attributes; ?>>182 <div <?php echo $wrapper_attributes; ?>> 169 183 <a class="button" href="<?php the_permalink(); ?>"><?php echo $button_text; ?></a> 170 184 </div> … … 179 193 180 194 // Returns markup for a search form based on the html5 version of `get_search_form()`, scoped to the sheet music post type. 181 function sml_sheet_music_search_form() { 182 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 183 $wrapper_attributes = get_block_wrapper_attributes(); 195 function sml_sheet_music_search_form( $block_attributes = null ) { 196 197 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 198 if ( null === $block_attributes ) { 199 $wrapper_attributes = ''; 200 } else { 201 $wrapper_attributes = get_block_wrapper_attributes(); 202 } 184 203 185 204 ob_start(); … … 203 222 204 223 // Returns markup for audio and/or video players for the current sheet music post. 205 function sml_sheet_music_audio_video_current( $block_attributes = false ) { 206 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 207 $wrapper_attributes = get_block_wrapper_attributes(); 224 function sml_sheet_music_audio_video_current( $block_attributes = null ) { 225 226 // Block wrapper element attributes if called as a block render callback, or empty string when called in other contexts. 227 if ( null === $block_attributes ) { 228 $wrapper_attributes = 'class="piece-recording"'; 229 } else { 230 $wrapper_attributes = get_block_wrapper_attributes(['class' => 'piece-recording']); 231 } 208 232 209 233 $audio_attachment_id = absint( get_post_meta( get_the_ID(), 'audio-attachment-id', true ) ); … … 223 247 ob_start(); 224 248 ?> 225 <div <?php echo $wrapper_attributes; ?> class="piece-recording"><?php249 <div <?php echo $wrapper_attributes; ?>><?php 226 250 if ( $audio_url ) { 227 251 // Embedded audio player.
Note: See TracChangeset
for help on using the changeset viewer.