WordPress.org

Make WordPress Core

Ticket #9015: functions.php-patch.diff

File functions.php-patch.diff, 6.7 KB (added by ptahdunbar, 8 years ago)

wraps the loop.php into twentyten_get_loop_template() which calls the locate_template function. wrap the title tag into a filterable function and removed cat_meow() and tag_ur_it() as their no longer used.

  • wp-content/themes/twentyten/search.php

     
    55
    66<?php if ( have_posts() ) : ?>
    77                                <h1 class="page-title"><?php _e( 'Search Results for: ', 'twentyten' ); ?><span><?php the_search_query(); ?></span></h1>
    8         <?php include 'loop.php'; ?>
     8        <?php twentyten_get_loop_template(); ?>
    99<?php else : ?>
    1010                                <div id="post-0" class="post no-results not-found">
    1111                                        <h2 class="entry-title"><?php _e( 'Nothing Found', 'twentyten' ); ?></h2>
  • wp-content/themes/twentyten/index.php

     
    44                        <div id="content">
    55
    66    <?php if ( have_posts() ) :
    7                 include 'loop.php';
     7                twentyten_get_loop_template();
    88    else : ?>
    99                <h2><?php _e( 'Not Found', 'twentyten' ); ?></h2>
    1010                <div class="entry-content">
  • wp-content/themes/twentyten/functions.php

     
    33// Set the content width based on the Theme CSS
    44$content_width = apply_filters( 'twentyten_content_width', 640 );
    55
     6// Enables automatic general feed link outputting
     7automatic_feed_links();
     8
    69// Your Changeable header business starts here
    710// No CSS, just IMG call
    811define( 'HEADER_TEXTCOLOR', '');
     
    4649if ( is_readable($locale_file) )
    4750        require_once( $locale_file );
    4851
     52// Gets the correct document title for the page
     53function twentyten_title( $sep = '|' ) {
     54        if ( is_single() ) {
     55                $title = sprintf( '%1$s %2$s %3$s', single_post_title( '', false ), $sep, get_bloginfo( 'name' ) );
     56        } elseif ( is_home() || is_front_page() ) {
     57                $title = sprintf( '%1$s %2$s %3$s %4$s', get_bloginfo( 'name' ), $sep, get_bloginfo( 'description' ), twentyten_get_page_number($sep) );
     58        } elseif ( is_page() ) {
     59                $title = sprintf( '%1$s %2$s %3$s', single_post_title( '', false ), $sep, get_bloginfo( 'name' ) );
     60        } elseif ( is_search() ) {
     61                $title = sprintf( __('Search results for "%1$s" | %2$s %3$s', 'twentyten'), esc_attr(get_search_query()), twentyten_get_page_number($sep), get_bloginfo('name') );
     62        } elseif ( is_404() ) {
     63                $title = sprintf( __( 'Not Found %1$s %2$s', 'twentyten' ), $sep, get_bloginfo( 'name' ) );
     64        } else {
     65                $title = sprintf( '%1$s | %2$s %3$s', wp_title(''), get_bloginfo('name'), twentyten_get_page_number($sep) );
     66        }
     67       
     68        echo apply_filters( 'twentyten_title', $title );
     69}
     70
    4971// Get the page number
    50 function twentyten_get_page_number() {
     72function twentyten_get_page_number( $sep = '|' ) {
    5173        if ( get_query_var('paged') )
    52                 echo ' | ' . __( 'Page ' , 'twentyten' ) . get_query_var('paged');
     74                return apply_filters( 'twentyten_get_page_number', sprintf( __( ' %s Page ' , 'twentyten' ), $sep, get_query_var('paged') ) );
    5375}
    5476
    5577// Control excerpt length
     
    116138add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
    117139
    118140
    119 // For category lists on category archives: Returns other categories except the current one (redundant)
    120 function cats_meow( $glue ) {
    121         $current_cat = single_cat_title( '', false );
    122         $separator = "\n";
    123         $cats = explode( $separator, get_the_category_list($separator) );
    124         foreach ( $cats as $i => $str ) {
    125                 if ( strstr( $str, ">$current_cat<" ) ) {
    126                         unset( $cats[$i] );
    127                         break;
    128                 }
    129         }
    130         if ( empty($cats) )
    131                 return false;
     141// Loads the loop.php template
     142function twentyten_get_loop_template() {
     143        locate_template( 'loop', true );
     144}
    132145
    133         return trim( join( $glue, $cats ) );
    134 } // end cats_meow
    135 
    136 
    137 // For tag lists on tag archives: Returns other tags except the current one (redundant)
    138 function tag_ur_it( $glue ) {
    139         $current_tag = single_tag_title( '', '',  false );
    140         $separator = "\n";
    141         $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) );
    142         foreach ( $tags as $i => $str ) {
    143                 if ( strstr( $str, ">$current_tag<" ) ) {
    144                         unset( $tags[$i] );
    145                         break;
    146                 }
    147         }
    148         if ( empty($tags) )
    149                 return false;
    150 
    151         return trim( join( $glue, $tags ) );
    152 } // end tag_ur_it
    153 
    154146// Register widgetized areas
    155147function twentyten_widgets_init() {
    156148        // Area 1
  • wp-content/themes/twentyten/tag.php

     
    99
    1010<?php rewind_posts(); ?>
    1111
    12 <?php include 'loop.php'; ?>
     12<?php twentyten_get_loop_template(); ?>
    1313
    1414                        </div><!-- #content -->
    1515                </div><!-- #container -->
  • wp-content/themes/twentyten/category.php

     
    1010
    1111<?php rewind_posts(); ?>
    1212
    13 <?php include 'loop.php'; ?>
     13<?php twentyten_get_loop_template(); ?>
    1414
    1515                        </div><!-- #content -->
    1616                </div><!-- #container -->
  • wp-content/themes/twentyten/archive.php

     
    1717
    1818<?php rewind_posts(); ?>
    1919
    20 <?php include 'loop.php'; ?>
     20<?php twentyten_get_loop_template(); ?>
    2121
    2222                        </div><!-- #content -->
    2323                </div><!-- #container -->
  • wp-content/themes/twentyten/header.php

     
    11<!DOCTYPE html>
    22<html <?php language_attributes(); ?>>
    33<head>
    4     <title><?php
    5         if ( is_single() ) {
    6                         single_post_title(); echo ' | '; bloginfo('name');
    7                 } elseif ( is_home() || is_front_page() ) {
    8                         bloginfo('name'); echo ' | '; bloginfo('description'); twentyten_get_page_number();
    9                 } elseif ( is_page() ) {
    10                         single_post_title(''); echo ' | '; bloginfo('name');
    11                 } elseif ( is_search() ) {
    12                         printf(__('Search results for "%s"', 'twentyten'), esc_html($s)); twentyten_get_page_number(); echo ' | '; bloginfo('name');
    13                 } elseif ( is_404() ) {
    14                         _e('Not Found', 'twentyten'); echo ' | '; bloginfo('name');
    15                 } else {
    16                         wp_title(''); echo ' | '; bloginfo('name'); twentyten_get_page_number();
    17                 }
    18     ?></title>
     4    <title><?php twentyten_title(); ?></title>
    195
    206        <meta http-equiv="content-type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    217