@@ -822,6 +822,7 @@ function wp_print_media_templates() {
822822 </script>
823823
824824 <?php // Template for the Attachment display settings, used for example in the sidebar. ?>
825+ <?php $ wp_attachment_pages_enabled = (bool ) get_option ( 'wp_attachment_pages_enabled ' ); ?>
825826 <script type="text/html" id="tmpl-attachment-display-settings">
826827 <h2><?php _e ( 'Attachment Display Settings ' ); ?> </h2>
827828
@@ -881,13 +882,15 @@ function wp_print_media_templates() {
881882 <?php esc_html_e ( 'Media File ' ); ?>
882883 <# } #>
883884 </option>
885+ <?php if ( $ wp_attachment_pages_enabled ) : ?>
884886 <option value="post">
885887 <# if ( data.model.canEmbed ) { #>
886888 <?php esc_html_e ( 'Link to Attachment Page ' ); ?>
887889 <# } else { #>
888890 <?php esc_html_e ( 'Attachment Page ' ); ?>
889891 <# } #>
890892 </option>
893+ <?php endif ; ?>
891894 <# if ( 'image' === data.type ) { #>
892895 <option value="custom">
893896 <?php esc_html_e ( 'Custom URL ' ); ?>
@@ -947,12 +950,16 @@ function wp_print_media_templates() {
947950 data-user-setting="urlbutton"
948951 <# } #>>
949952
953+ <?php if ( $ wp_attachment_pages_enabled ) : ?>
950954 <option value="post" <# if ( ! wp.media.galleryDefaults.link || 'post' === wp.media.galleryDefaults.link ) {
951955 #>selected="selected"<# }
952956 #>>
953957 <?php esc_html_e ( 'Attachment Page ' ); ?>
954958 </option>
955959 <option value="file" <# if ( 'file' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
960+ <?php else : ?>
961+ <option value="file" <# if ( ! wp.media.galleryDefaults.link || 'file' === wp.media.galleryDefaults.link || 'post' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
962+ <?php endif ; ?>
956963 <?php esc_html_e ( 'Media File ' ); ?>
957964 </option>
958965 <option value="none" <# if ( 'none' === wp.media.galleryDefaults.link ) { #>selected="selected"<# } #>>
@@ -1228,9 +1235,11 @@ function wp_print_media_templates() {
12281235 <option value="file">
12291236 <?php esc_html_e ( 'Media File ' ); ?>
12301237 </option>
1238+ <?php if ( $ wp_attachment_pages_enabled ) : ?>
12311239 <option value="post">
12321240 <?php esc_html_e ( 'Attachment Page ' ); ?>
12331241 </option>
1242+ <?php endif ; ?>
12341243 <# } else { #>
12351244 <option value="file">
12361245 <?php esc_html_e ( 'Image URL ' ); ?>
0 commit comments