Make WordPress Core

Ticket #26055: 26055.diff

File 26055.diff, 5.7 KB (added by obenland, 10 years ago)
  • wp-content/themes/twentyfourteen/functions.php

     
    3434if ( ! isset( $content_width ) )
    3535        $content_width = 474;
    3636
     37/**
     38 * Twenty Fourteen only works in WordPress 3.6 or later.
     39 */
     40if ( version_compare( $GLOBALS['wp_version'], '3.6', '<' ) )
     41        require get_template_directory() . '/inc/back-compat.php';
     42
    3743if ( ! function_exists( 'twentyfourteen_setup' ) ) :
    3844/**
    3945 * Twenty Fourteen setup.
  • wp-content/themes/twentyfourteen/inc/widgets.php

     
    131131                                                                else :
    132132                                                                        $images = array();
    133133
    134                                                                         if ( function_exists( 'get_post_galleries' ) ) {
    135                                                                                 $galleries = get_post_galleries( get_the_ID(), false );
    136                                                                                 if ( isset( $galleries[0]['ids'] ) )
    137                                                                                         $images = explode( ',', $galleries[0]['ids'] );
    138                                                                         } else {
    139                                                                                 $pattern = get_shortcode_regex();
    140                                                                                 preg_match( "/$pattern/s", get_the_content(), $match );
    141                                                                                 $atts = shortcode_parse_atts( $match[3] );
    142                                                                                 if ( isset( $atts['ids'] ) )
    143                                                                                         $images = explode( ',', $atts['ids'] );
    144                                                                         }
     134                                                                        $galleries = get_post_galleries( get_the_ID(), false );
     135                                                                        if ( isset( $galleries[0]['ids'] ) )
     136                                                                                $images = explode( ',', $galleries[0]['ids'] );
    145137
    146138                                                                        if ( ! $images ) :
    147139                                                                                $images = get_posts( array(
    148140                                                                                        'fields'         => 'ids',
    149                                                                                         'numberposts'    => 999,
     141                                                                                        'numberposts'    => -1,
    150142                                                                                        'order'          => 'ASC',
    151143                                                                                        'orderby'        => 'menu_order',
    152144                                                                                        'post_mime_type' => 'image',
     
    166158
    167159                                                                        if ( ! empty ( $post_thumbnail ) ) :
    168160                                                ?>
    169                                                                         <a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></a>
    170                                                                 <?php
    171                                                                         endif;
    172                                                                 ?>
    173                                                                         <p class="wp-caption-text">
    174                                                                         <?php
    175                                                                                 printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ),
    176                                                                                         esc_url( get_permalink() ),
    177                                                                                         number_format_i18n( $total_images )
    178                                                                                 );
    179                                                                         ?>
    180                                                                         </p>
     161                                                <a href="<?php the_permalink(); ?>"><?php echo $post_thumbnail; ?></a>
     162                                                <?php endif; ?>
     163                                                <p class="wp-caption-text">
    181164                                                        <?php
     165                                                                printf( _n( 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photo</a>.', 'This gallery contains <a href="%1$s" rel="bookmark">%2$s photos</a>.', $total_images, 'twentyfourteen' ),
     166                                                                        esc_url( get_permalink() ),
     167                                                                        number_format_i18n( $total_images )
     168                                                                );
     169                                                        ?>
     170                                                </p>
     171                                                <?php
    182172                                                                endif;
    183173
    184174                                                        else :
  • wp-content/themes/twentyfourteen/inc/back-compat.php

     
     1<?php
     2/**
     3 * Twenty Fourteen back compat functionality
     4 *
     5 * Prevents Twenty Fourteen from running on WordPress versions prior to 3.6,
     6 * since this theme is not meant to be backward compatible beyond that
     7 * and relies on many newer functions and markup changes introduced in 3.6.
     8 *
     9 * @package WordPress
     10 * @subpackage Twenty_Fourteen
     11 * @since Twenty Fourteen 1.0
     12 */
     13
     14/**
     15 * Prevent switching to Twenty Fourteen on old versions of WordPress.
     16 *
     17 * Switches to the default theme.
     18 *
     19 * @since Twenty Fourteen 1.0
     20 *
     21 * @return void
     22 */
     23function twentyfourteen_switch_theme() {
     24        switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
     25        unset( $_GET['activated'] );
     26        add_action( 'admin_notices', 'twentyfourteen_upgrade_notice' );
     27}
     28add_action( 'after_switch_theme', 'twentyfourteen_switch_theme' );
     29
     30/**
     31 * Add message for unsuccessful theme switch.
     32 *
     33 * Prints an update nag after an unsuccessful attempt to switch to
     34 * Twenty Fourteen on WordPress versions prior to 3.6.
     35 *
     36 * @since Twenty Fourteen 1.0
     37 *
     38 * @return void
     39 */
     40function twentyfourteen_upgrade_notice() {
     41        $message = sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] );
     42        printf( '<div class="error"><p>%s</p></div>', $message );
     43}
     44
     45/**
     46 * Prevent the Theme Customizer from being loaded on WordPress versions prior to 3.6.
     47 *
     48 * @since Twenty Fourteen 1.0
     49 *
     50 * @return void
     51 */
     52function twentyfourteen_customize() {
     53        wp_die( sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ), '', array(
     54                'back_link' => true,
     55        ) );
     56}
     57add_action( 'load-customize.php', 'twentyfourteen_customize' );
     58
     59/**
     60 * Prevent the Theme Preview from being loaded on WordPress versions prior to 3.4.
     61 *
     62 * @since Twenty Fourteen 1.0
     63 *
     64 * @return void
     65 */
     66function twentyfourteen_preview() {
     67        if ( isset( $_GET['preview'] ) ) {
     68                wp_die( sprintf( __( 'Twenty Fourteen requires at least WordPress version 3.6. You are running version %s. Please upgrade and try again.', 'twentyfourteen' ), $GLOBALS['wp_version'] ) );
     69        }
     70}
     71add_action( 'template_redirect', 'twentyfourteen_preview' );