WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #39512, comment 7


Ignore:
Timestamp:
01/21/2017 07:54:57 PM (2 years ago)
Author:
wpweaver
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #39512, comment 7

    initial v1  
    44
    55But putting the filter in `get_header_video_url` would also make `the_header_video_url` work as expected, so the filter really does belong on `get_header_video_url`, but it will require new logic for the attachment vs external video source to make a filter work.
     6
     7Maybe like this?
     8
     9{{{
     10
     11function get_header_video_url() {
     12        $id = absint( get_theme_mod( 'header_video' ) );
     13        $url = esc_url( get_theme_mod( 'external_header_video' ) );
     14
     15        //if ( ! $id && ! $url ) {
     16        //      return false;
     17        //}
     18
     19        if ( $id ) {
     20                // Get the file URL from the attachment ID.
     21                $url = wp_get_attachment_url( $id );
     22        }
     23        $url = apply_filters('get_header_video_url', $url);
     24        if ( ! $url )
     25                return false;
     26        return esc_url_raw( set_url_scheme( $url ) );
     27}
     28}}}