~canonical-sysadmins/wordpress/4.9.1

« back to all changes in this revision

Viewing changes to wp-includes/theme.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
950
950
}
951
951
 
952
952
/**
953
 
 * Retrieves the custom header text color in HEX format.
 
953
 * Retrieves the custom header text color in 3- or 6-digit hexadecimal form.
954
954
 *
955
955
 * @since 2.1.0
956
956
 *
957
 
 * @return string Header text color in HEX format (minus the hash symbol).
 
957
 * @return string Header text color in 3- or 6-digit hexadecimal form (minus the hash symbol).
958
958
 */
959
959
function get_header_textcolor() {
960
960
        return get_theme_mod('header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) );
961
961
}
962
962
 
963
963
/**
964
 
 * Displays the custom header text color in HEX format (minus the hash symbol).
 
964
 * Displays the custom header text color in 3- or 6-digit hexadecimal form (minus the hash symbol).
965
965
 *
966
966
 * @since 2.1.0
967
967
 */
1325
1325
        return (bool) get_header_video_url();
1326
1326
}
1327
1327
 
1328
 
/* Retrieve header video URL for custom header.
 
1328
/**
 
1329
 * Retrieve header video URL for custom header.
1329
1330
 *
1330
 
 * Uses a local video if present, or falls back to an external video. Returns false if there is no video.
 
1331
 * Uses a local video if present, or falls back to an external video.
1331
1332
 *
1332
1333
 * @since 4.7.0
1333
1334
 *
1334
 
 * @return string|false
 
1335
 * @return string|false Header video URL or false if there is no video.
1335
1336
 */
1336
1337
function get_header_video_url() {
1337
1338
        $id = absint( get_theme_mod( 'header_video' ) );
1704
1705
        }
1705
1706
 
1706
1707
        /**
1707
 
         * Modify the Custom CSS Output into the <head>.
 
1708
         * Filters the Custom CSS Output into the <head>.
1708
1709
         *
1709
1710
         * @since 4.7.0
1710
1711
         *
1985
1986
                                'title' => _x( 'Home', 'Theme starter content' ),
1986
1987
                                'url' => home_url( '/' ),
1987
1988
                        ),
1988
 
                        'page_home' => array( // Deprecated in favor of home_link.
 
1989
                        'page_home' => array( // Deprecated in favor of link_home.
1989
1990
                                'type' => 'post_type',
1990
1991
                                'object' => 'page',
1991
1992
                                'object_id' => '{{home}}',
3058
3059
 
3059
3060
        return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
3060
3061
}
 
3062
 
 
3063
/**
 
3064
 * Make sure that auto-draft posts get their post_date bumped to prevent premature garbage-collection.
 
3065
 *
 
3066
 * When a changeset is updated but remains an auto-draft, ensure the post_date
 
3067
 * for the auto-draft posts remains the same so that it will be
 
3068
 * garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise,
 
3069
 * if the changeset is updated to be a draft then update the posts
 
3070
 * to have a far-future post_date so that they will never be garbage collected
 
3071
 * unless the changeset post itself is deleted.
 
3072
 *
 
3073
 * @since 4.8.0
 
3074
 * @access private
 
3075
 * @see wp_delete_auto_drafts()
 
3076
 *
 
3077
 * @param string   $new_status Transition to this post status.
 
3078
 * @param string   $old_status Previous post status.
 
3079
 * @param \WP_Post $post       Post data.
 
3080
 * @global wpdb $wpdb
 
3081
 */
 
3082
function _wp_keep_alive_customize_changeset_dependent_auto_drafts( $new_status, $old_status, $post ) {
 
3083
        global $wpdb;
 
3084
        unset( $old_status );
 
3085
 
 
3086
        // Short-circuit if not a changeset or if the changeset was published.
 
3087
        if ( 'customize_changeset' !== $post->post_type || 'publish' === $new_status ) {
 
3088
                return;
 
3089
        }
 
3090
 
 
3091
        if ( 'auto-draft' === $new_status ) {
 
3092
                /*
 
3093
                 * Keep the post date for the post matching the changeset
 
3094
                 * so that it will not be garbage-collected before the changeset.
 
3095
                 */
 
3096
                $new_post_date = $post->post_date;
 
3097
        } else {
 
3098
                /*
 
3099
                 * Since the changeset no longer has an auto-draft (and it is not published)
 
3100
                 * it is now a persistent changeset, a long-lived draft, and so any
 
3101
                 * associated auto-draft posts should have their dates
 
3102
                 * pushed out very far into the future to prevent them from ever
 
3103
                 * being garbage-collected.
 
3104
                 */
 
3105
                $new_post_date = gmdate( 'Y-m-d H:i:d', strtotime( '+100 years' ) );
 
3106
        }
 
3107
 
 
3108
        $data = json_decode( $post->post_content, true );
 
3109
        if ( empty( $data['nav_menus_created_posts']['value'] ) ) {
 
3110
                return;
 
3111
        }
 
3112
        foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) {
 
3113
                if ( empty( $post_id ) || 'auto-draft' !== get_post_status( $post_id ) ) {
 
3114
                        continue;
 
3115
                }
 
3116
                $wpdb->update(
 
3117
                        $wpdb->posts,
 
3118
                        array( 'post_date' => $new_post_date ), // Note wp_delete_auto_drafts() only looks at this this date.
 
3119
                        array( 'ID' => $post_id )
 
3120
                );
 
3121
                clean_post_cache( $post_id );
 
3122
        }
 
3123
}