Make WordPress Core


Ignore:
Timestamp:
06/10/2012 12:32:19 AM (14 years ago)
Author:
ryan
Message:
  • Introduce remove_header_image(), reset_header_image(), set_header_image(), and get_header_image_data() for Custom_Image_Header.
  • Handle all set/get of header theme mod through these methods.
  • Use these methods in the customizer.

Props kovshenin, nacin, SergeyBiryukov, koopersmith.
fixes #20871

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-setting.php

    r20936 r21037  
    368368        }
    369369}
     370
     371/**
     372 * A setting that is used to filter a value, but will not save the results.
     373 *
     374 * Results should be properly handled using another setting or callback.
     375 */
     376class WP_Customize_Filter_Setting extends WP_Customize_Setting {
     377        public function update() {}
     378}
     379
     380/**
     381 * A setting that is used to filter a value, but will not save the results.
     382 *
     383 * Results should be properly handled using another setting or callback.
     384 */
     385class WP_Customize_Header_Image_Setting extends WP_Customize_Setting {
     386        public $id = 'header_image_data';
     387
     388        public function update( $value ) {
     389                global $custom_image_header;
     390
     391                // If the value doesn't exist (removed or random),
     392                // use the header_image value.
     393                if ( ! $value )
     394                        $value = $this->manager->get_setting('header_image')->post_value();
     395
     396                if ( is_array( $value ) && isset( $value['choice'] ) )
     397                        $custom_image_header->set_header_image( $value['choice'] );
     398                else
     399                        $custom_image_header->set_header_image( $value );
     400        }
     401}
Note: See TracChangeset for help on using the changeset viewer.