get_uploaded_header_images example

function get_media_states( $post ) {
    static $header_images;

    $media_states = array();
    $stylesheet   = get_option( 'stylesheet' );

    if ( current_theme_supports( 'custom-header' ) ) {
        $meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );

        if ( is_random_header_image() ) {
            if ( ! isset( $header_images ) ) {
                $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
            }

            if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
                $media_states[] = __( 'Header Image' );
            }
        } else {
            $header_image = get_header_image();

            // Display "Header Image" if the image was ever used as a header image.             if ( ! empty( $meta_header ) && $meta_header === $stylesheet && wp_get_attachment_url( $post->ID ) !== $header_image ) {
                $media_states[] = __( 'Header Image' );
            }

    public function show_header_selector( $type = 'default' ) {
        if ( 'default' === $type ) {
            $headers = $this->default_headers;
        } else {
            $headers = get_uploaded_header_images();
            $type    = 'uploaded';
        }

        if ( 1 < count( $headers ) ) {
            echo '<div class="random-header">';
            echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />';
            _e( '<strong>Random:</strong> Show a different image on each page.' );
            echo '</label>';
            echo '</div>';
        }

        
public function prepare_control() {
        global $custom_image_header;
        if ( empty( $custom_image_header ) ) {
            return;
        }

        add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_header_image_template' ) );

        // Process default headers and uploaded headers.         $custom_image_header->process_default_headers();
        $this->default_headers  = $custom_image_header->get_default_header_images();
        $this->uploaded_headers = $custom_image_header->get_uploaded_header_images();
    }

    /** */
    public function print_header_image_template() {
        ?> <script type="text/template" id="tmpl-header-choice"> <# if (data.random) { #> <button type="button" class="button display-options random"> <span class="dashicons dashicons-randomize dice"></span> <# if ( data.type === 'uploaded' ) { #>

function _get_random_header_data() {
    global $_wp_default_headers;
    static $_wp_random_header = null;

    if ( empty( $_wp_random_header ) ) {
        $header_image_mod = get_theme_mod( 'header_image', '' );
        $headers          = array();

        if ( 'random-uploaded-image' === $header_image_mod ) {
            $headers = get_uploaded_header_images();
        } elseif ( ! empty( $_wp_default_headers ) ) {
            if ( 'random-default-image' === $header_image_mod ) {
                $headers = $_wp_default_headers;
            } else {
                if ( current_theme_supports( 'custom-header', 'random-default' ) ) {
                    $headers = $_wp_default_headers;
                }
            }
        }

        if ( empty( $headers ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.