post_value example


    public function filter_previewed_wp_get_custom_css( $css$stylesheet ) {
        if ( $stylesheet === $this->stylesheet ) {
            $customized_value = $this->post_value( null );
            if ( ! is_null( $customized_value ) ) {
                $css = $customized_value;
            }
        }
        return $css;
    }

    /** * Fetch the value of the setting. Will return the previewed value when `preview()` is called. * * @since 4.7.0 * * @see WP_Customize_Setting::value() * * @return string */
global $wp_theme_directories$wp_customize$sidebars_widgets$wp_registered_sidebars;

    $requirements = validate_theme_requirements( $stylesheet );
    if ( is_wp_error( $requirements ) ) {
        wp_die( $requirements );
    }

    $_sidebars_widgets = null;
    if ( 'wp_ajax_customize_save' === current_action() ) {
        $old_sidebars_widgets_data_setting = $wp_customize->get_setting( 'old_sidebars_widgets_data' );
        if ( $old_sidebars_widgets_data_setting ) {
            $_sidebars_widgets = $wp_customize->post_value( $old_sidebars_widgets_data_setting );
        }
    } elseif ( is_array( $sidebars_widgets ) ) {
        $_sidebars_widgets = $sidebars_widgets;
    }

    if ( is_array( $_sidebars_widgets ) ) {
        set_theme_mod(
            'sidebars_widgets',
            array(
                'time' => time(),
                'data' => $_sidebars_widgets,
            )

    public function customize_set_last_used( $wp_customize ) {

        $header_image_data_setting = $wp_customize->get_setting( 'header_image_data' );

        if ( ! $header_image_data_setting ) {
            return;
        }

        $data = $header_image_data_setting->post_value();

        if ( ! isset( $data['attachment_id'] ) ) {
            return;
        }

        $attachment_id = $data['attachment_id'];
        $key           = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
        update_post_meta( $attachment_id$keytime() );
    }

    /** * Gets the details of default header images if defined. * * @since 3.9.0 * * @return array Default header images. */

    public function value() {
        if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
            $undefined  = new stdClass(); // Symbol.             $post_value = $this->post_value( $undefined );

            if ( $undefined === $post_value ) {
                $value = $this->_original_value;
            } else {
                $value = $post_value;
            }
        } else {
            $value = false;

            // Note that a term_id of less than one indicates a nav_menu not yet inserted.             if ( $this->term_id > 0 ) {
                
$args                   = get_theme_support( 'custom-header' );
            $admin_head_callback    = isset( $args[0]['admin-head-callback'] ) ? $args[0]['admin-head-callback'] : null;
            $admin_preview_callback = isset( $args[0]['admin-preview-callback'] ) ? $args[0]['admin-preview-callback'] : null;
            $custom_image_header    = new Custom_Image_Header( $admin_head_callback$admin_preview_callback );
        }

        /* * If the value doesn't exist (removed or random), * use the header_image value. */
        if ( ! $value ) {
            $value = $this->manager->get_setting( 'header_image' )->post_value();
        }

        if ( is_array( $value ) && isset( $value['choice'] ) ) {
            $custom_image_header->set_header_image( $value['choice'] );
        } else {
            $custom_image_header->set_header_image( $value );
        }
    }
}

    public function save_nav_menus_created_posts( $setting ) {
        $post_ids = $setting->post_value();
        if ( ! empty( $post_ids ) ) {
            foreach ( $post_ids as $post_id ) {

                // Prevent overriding the status that a user may have prematurely updated the post to.                 $current_status = get_post_status( $post_id );
                if ( 'auto-draft' !== $current_status && 'draft' !== $current_status ) {
                    continue;
                }

                $target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish';
                $args          = array(
                    

    public function value() {
        if ( $this->is_previewed && get_current_blog_id() === $this->_previewed_blog_id ) {
            $undefined  = new stdClass(); // Symbol.             $post_value = $this->post_value( $undefined );

            if ( $undefined === $post_value ) {
                $value = $this->_original_value;
            } else {
                $value = $post_value;
            }
            if ( ! empty( $value ) && empty( $value['original_title'] ) ) {
                $value['original_title'] = $this->get_original_title( (object) $value );
            }
        } elseif ( isset( $this->value ) ) {
            $value = $this->value;
        }
$id_base                 = $this->id_data['base'];
        $is_multidimensional     = ! empty( $this->id_data['keys'] );
        $multidimensional_filter = array( $this, '_multidimensional_preview_filter' );

        /* * Check if the setting has a pre-existing value (an isset check), * and if doesn't have any incoming post value. If both checks are true, * then the preview short-circuits because there is nothing that needs * to be previewed. */
        $undefined     = new stdClass();
        $needs_preview = ( $undefined !== $this->post_value( $undefined ) );
        $value         = null;

        // Since no post value was defined, check if we have an initial value set.         if ( ! $needs_preview ) {
            if ( $this->is_multidimensional_aggregated ) {
                $root  = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
                $value = $this->multidimensional_get( $root$this->id_data['keys']$undefined );
            } else {
                $default       = $this->default;
                $this->default = $undefined; // Temporarily set default to undefined so we can detect if existing value is set.                 $value         = $this->value();
                
Home | Imprint | This part of the site doesn't use cookies.