Ticket #9015: 9015.functions_cleanup.diff
File 9015.functions_cleanup.diff, 18.5 KB (added by , 15 years ago) |
---|
-
wp-content/themes/twentyten/functions.php
1 1 <?php 2 2 3 // Set the content width based on the Theme CSS 4 $content_width = apply_filters('twentyten_content_width', 640 ); 3 if ( ! function_exists( 'twentyten_content_width' ) ) : 4 function twentyten_content_width() { 5 // Set the content width based on the Theme CSS 6 return apply_filters('twentyten_content_width', 640 ); 7 } 8 endif; 5 9 6 // Your Changeable header business starts here 7 // No CSS, just IMG call 8 define( 'HEADER_TEXTCOLOR', ''); 9 define( 'HEADER_IMAGE', '%s/images/header-1.jpg'); // %s is theme dir uri 10 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); 11 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) ); 12 define( 'NO_HEADER_TEXT', true ); 10 if ( ! function_exists( 'twentyten_init' ) ) : 11 function twentyten_init() { 12 // Your Changeable header business starts here 13 // No CSS, just IMG call 14 define( 'HEADER_TEXTCOLOR', ''); 15 define( 'HEADER_IMAGE', '%s/images/header-1.jpg'); // %s is theme dir uri 16 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); 17 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 198 ) ); 18 define( 'NO_HEADER_TEXT', true ); 13 19 20 add_custom_image_header( '', 'twentyten_admin_header_style' ); 21 // and thus ends the changeable header business 22 23 add_custom_background(); 24 25 // This theme needs post thumbnails 26 add_theme_support( 'post-thumbnails' ); 27 28 // We'll be using them for custom header images on posts and pages 29 // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit) 30 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); 31 32 // Make theme available for translation 33 // Translations can be filed in the /languages/ directory 34 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' ); 35 36 $locale = get_locale(); 37 $locale_file = TEMPLATEPATH . "/languages/$locale.php"; 38 if ( is_readable( $locale_file ) ) 39 require_once( $locale_file ); 40 } 41 endif; 42 add_action( 'init', 'twentyten_init' ); 43 44 if ( ! function_exists( 'twentyten_admin_header_style' ) ) : 14 45 function twentyten_admin_header_style() { 15 46 ?> 16 47 <style type="text/css"> … … 24 55 </style> 25 56 <?php 26 57 } 58 endif; 27 59 28 add_custom_image_header('', 'twentyten_admin_header_style');29 // and thus ends the changeable header business30 31 add_custom_background();32 33 // This theme needs post thumbnails34 add_theme_support( 'post-thumbnails' );35 36 // We'll be using them for custom header images on posts and pages37 // so we want them to be 940 pixels wide by 198 pixels tall (larger images will be auto-cropped to fit)38 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );39 40 // Make theme available for translation41 // Translations can be filed in the /languages/ directory42 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );43 44 $locale = get_locale();45 $locale_file = TEMPLATEPATH . "/languages/$locale.php";46 if ( is_readable($locale_file) )47 require_once($locale_file);48 49 60 // Get the page number 61 if ( ! function_exists( 'get_page_number' ) ) : 50 62 function get_page_number() { 51 63 if ( get_query_var('paged') ) 52 echo' | ' . __( 'Page ' , 'twentyten') . get_query_var('paged');64 return ' | ' . __( 'Page ' , 'twentyten') . get_query_var('paged'); 53 65 } 66 endif; 54 67 68 // Echo the page number 69 if ( ! function_exists( 'the_page_number' ) ) : 70 function the_page_number() { 71 echo get_page_number(); 72 } 73 endif; 74 55 75 // Control excerpt length 56 function new_excerpt_length($length) { 76 if ( ! function_exists( 'twentyten_excerpt_length' ) ) : 77 function twentyten_excerpt_length( $length ) { 57 78 return 40; 58 79 } 59 add_filter('excerpt_length', 'new_excerpt_length'); 80 endif; 81 add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); 60 82 61 83 62 84 // Make a nice read more link on excerpts 63 function new_excerpt_more($more) { 85 if ( ! function_exists( 'twentyten_excerpt_more' ) ) : 86 function twentyten_excerpt_more($more) { 64 87 return ' … <a href="'. get_permalink() . '">' . 'Continue reading <span class="meta-nav">→</span>' . '</a>'; 65 88 } 66 add_filter('excerpt_more', 'new_excerpt_more'); 89 endif; 90 add_filter( 'excerpt_more', 'twentyten_excerpt_more' ); 67 91 68 92 69 93 // Template for comments and pingbacks 70 function twentyten_comment($comment, $args, $depth) { 94 if ( ! function_exists( 'twentyten_comment' ) ) : 95 function twentyten_comment( $comment, $args, $depth ) { 71 96 $GLOBALS ['comment'] = $comment; ?> 72 <?php if ( '' == $comment->comment_type) {?>73 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">97 <?php if ( '' == $comment->comment_type ) : ?> 98 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>"> 74 99 <div id="comment-<?php comment_ID(); ?>"> 75 100 <div class="comment-author vcard"> 76 <?php echo get_avatar( $comment, 40); ?>101 <?php echo get_avatar( $comment, 40 ); ?> 77 102 78 <?php printf( __('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link())?>103 <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?> 79 104 </div> 80 <?php if ( $comment->comment_approved == '0') : ?>81 <em><?php _e( 'Your comment is awaiting moderation.')?></em>105 <?php if ( $comment->comment_approved == '0' ) : ?> 106 <em><?php _e( 'Your comment is awaiting moderation.' ); ?></em> 82 107 <br /> 83 108 <?php endif; ?> 84 109 85 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','')?></div>110 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf( __( '%1$s at %2$s' ), get_comment_date(), get_comment_time() ) ?></a><?php edit_comment_link( __( '(Edit)' ),' ','' ); ?></div> 86 111 87 <div class="comment-body"><?php comment_text() ?></div>112 <div class="comment-body"><?php comment_text(); ?></div> 88 113 89 114 <div class="reply"> 90 <?php comment_reply_link( array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])))?>115 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> 91 116 </div> 92 117 </div> 93 118 94 <?php } else {?>119 <?php else : ?> 95 120 <li class="post pingback"> 96 <p><?php _e( 'Pingback:') ?> <?php comment_author_link ()?><?php edit_comment_link( 'edit', ' ', '' ); ?></p>97 <?php }121 <p><?php _e( 'Pingback:' ); ?> <?php comment_author_link (); ?><?php edit_comment_link( 'edit', ' ', '' ); ?></p> 122 <?php endif; 98 123 } 124 endif; 99 125 100 126 // Make the Visual Editor styles match the theme's styles 101 function my_editor_style($url) { 102 if ( !empty($url) ) 127 if ( ! function_exists( 'twentyten_editor_style' ) ) : 128 function twentyten_editor_style( $url ) { 129 if ( ! empty( $url ) ) 103 130 $url .= ','; 104 131 105 132 // Change the path here if using sub-directory … … 107 134 108 135 return $url; 109 136 } 110 add_filter('mce_css', 'my_editor_style'); 137 endif; 138 add_filter( 'mce_css', 'twentyten_editor_style' ); 111 139 112 140 // Remove inline styles on gallery shortcode 113 function remove_gallery_css() { 114 return "<div class='gallery'>"; 141 if ( ! function_exists( 'twentyten_remove_gallery_css' ) ) : 142 function twentyten_remove_gallery_css() { 143 return "\t\t<div class='gallery'>\n\t\t"; 115 144 } 116 add_filter('gallery_style', 'remove_gallery_css'); 145 endif; 146 add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); 117 147 118 148 // For category lists on category archives: Returns other categories except the current one (redundant) 119 function cats_meow($glue) { 149 if ( ! function_exists( 'twentyten_cats_meow' ) ) : 150 function twentyten_cats_meow( $glue ) { 120 151 $current_cat = single_cat_title( '', false ); 121 152 $separator = "\n"; 122 $cats = explode( $separator, get_the_category_list( $separator) );153 $cats = explode( $separator, get_the_category_list( $separator ) ); 123 154 foreach ( $cats as $i => $str ) { 124 155 if ( strstr( $str, ">$current_cat<" ) ) { 125 unset( $cats[$i]);156 unset( $cats[$i] ); 126 157 break; 127 158 } 128 159 } 129 if ( empty( $cats) )160 if ( empty( $cats ) ) 130 161 return false; 131 162 132 return trim(join( $glue, $cats )); 133 } // end cats_meow 163 return trim( join( $glue, $cats ) ); 164 } 165 endif; 134 166 135 167 // For tag lists on tag archives: Returns other tags except the current one (redundant) 136 function tag_ur_it($glue) { 168 if ( ! function_exists( 'twentyten_tag_ur_it' ) ) : 169 function twentyten_tag_ur_it( $glue ) { 137 170 $current_tag = single_tag_title( '', '', false ); 138 171 $separator = "\n"; 139 172 $tags = explode( $separator, get_the_tag_list( "", "$separator", "" ) ); 140 173 foreach ( $tags as $i => $str ) { 141 174 if ( strstr( $str, ">$current_tag<" ) ) { 142 unset( $tags[$i]);175 unset( $tags[$i] ); 143 176 break; 144 177 } 145 178 } 146 if ( empty( $tags) )179 if ( empty( $tags ) ) 147 180 return false; 148 181 149 return trim(join( $glue, $tags )); 150 } // end tag_ur_it 182 return trim( join( $glue, $tags ) ); 183 } 184 endif; 151 185 152 186 // Register widgetized areas 153 function theme_widgets_init() { 187 if ( ! function_exists( 'twentyten_widgets_init' ) ) : 188 function twentyten_widgets_init() { 154 189 // Area 1 155 190 register_sidebar( array ( 156 191 'name' => 'Primary Widget Area', 157 192 'id' => 'primary-widget-area', 158 'description' => __( 'The primary widget area' , 'twentyten'),193 'description' => __( 'The primary widget area' , 'twentyten' ), 159 194 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 160 195 'after_widget' => "</li>", 161 196 'before_title' => '<h3 class="widget-title">', … … 166 201 register_sidebar( array ( 167 202 'name' => 'Secondary Widget Area', 168 203 'id' => 'secondary-widget-area', 169 'description' => __( 'The secondary widget area' , 'twentyten'),204 'description' => __( 'The secondary widget area' , 'twentyten' ), 170 205 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 171 206 'after_widget' => "</li>", 172 207 'before_title' => '<h3 class="widget-title">', … … 177 212 register_sidebar( array ( 178 213 'name' => 'First Footer Widget Area', 179 214 'id' => 'first-footer-widget-area', 180 'description' => __( 'The first footer widget area' , 'twentyten'),215 'description' => __( 'The first footer widget area' , 'twentyten' ), 181 216 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 182 217 'after_widget' => "</li>", 183 218 'before_title' => '<h3 class="widget-title">', … … 188 223 register_sidebar( array ( 189 224 'name' => 'Second Footer Widget Area', 190 225 'id' => 'second-footer-widget-area', 191 'description' => __( 'The second footer widget area' , 'twentyten'),226 'description' => __( 'The second footer widget area' , 'twentyten' ), 192 227 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 193 228 'after_widget' => "</li>", 194 229 'before_title' => '<h3 class="widget-title">', … … 199 234 register_sidebar( array ( 200 235 'name' => 'Third Footer Widget Area', 201 236 'id' => 'third-footer-widget-area', 202 'description' => __( 'The third footer widget area' , 'twentyten'),237 'description' => __( 'The third footer widget area' , 'twentyten' ), 203 238 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 204 239 'after_widget' => "</li>", 205 240 'before_title' => '<h3 class="widget-title">', … … 210 245 register_sidebar( array ( 211 246 'name' => 'Fourth Footer Widget Area', 212 247 'id' => 'fourth-footer-widget-area', 213 'description' => __( 'The fourth footer widget area' , 'twentyten'),248 'description' => __( 'The fourth footer widget area' , 'twentyten' ), 214 249 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 215 250 'after_widget' => "</li>", 216 251 'before_title' => '<h3 class="widget-title">', 217 252 'after_title' => '</h3>', 218 253 ) ); 219 254 220 } // end theme_widgets_init 221 222 // Add all the groovy widget areas 223 add_action( 'init', 'theme_widgets_init' ); 224 No newline at end of file 255 } 256 endif; 257 add_action( 'init', 'twentyten_widgets_init' ); -
wp-content/themes/twentyten/tag.php
35 35 <div class="entry-utility"> 36 36 <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'twentyten' ); ?></span><?php echo get_the_category_list(', '); ?></span> 37 37 <span class="meta-sep"> | </span> 38 <?php if ( $tag_ur_it = t ag_ur_it(', ') ) : // Returns tags other than the one queried ?>38 <?php if ( $tag_ur_it = twentyten_tag_ur_it(', ') ) : // Returns tags other than the one queried ?> 39 39 <span class="tag-links"><?php printf( __( 'Also tagged %s', 'twentyten' ), $tag_ur_it ) ?></span> 40 40 <?php endif; ?> 41 41 <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ) ?></span> … … 56 56 </div><!-- #container --> 57 57 58 58 <?php get_sidebar(); ?> 59 <?php get_footer(); ?> 60 No newline at end of file 59 <?php get_footer(); ?> -
wp-content/themes/twentyten/category.php
36 36 </div><!-- .entry-summary --> 37 37 38 38 <div class="entry-utility"> 39 <?php if ( $cats_meow = cats_meow(', ') ) : // Returns categories other than the one queried ?>39 <?php if ( $cats_meow = twentyten_cats_meow(', ') ) : // Returns categories other than the one queried ?> 40 40 <span class="cat-links"><?php printf( __( 'Also posted in %s', 'twentyten' ), $cats_meow ) ?></span> 41 41 <span class="meta-sep"> | </span> 42 42 <?php endif ?> … … 59 59 </div><!-- #container --> 60 60 61 61 <?php get_sidebar(); ?> 62 <?php get_footer(); ?> 63 No newline at end of file 62 <?php get_footer(); ?> -
wp-content/themes/twentyten/header.php
5 5 if ( is_single() ) { 6 6 single_post_title(); echo ' | '; bloginfo('name'); 7 7 } elseif ( is_home() || is_front_page() ) { 8 bloginfo('name'); echo ' | '; bloginfo('description'); get_page_number();8 bloginfo('name'); echo ' | '; bloginfo('description'); the_page_number(); 9 9 } elseif ( is_page() ) { 10 10 single_post_title(''); echo ' | '; bloginfo('name'); 11 11 } elseif ( is_search() ) { 12 printf(__('Search results for "%s"', 'twentyten'), esc_html($s)); get_page_number(); echo ' | '; bloginfo('name');12 printf(__('Search results for "%s"', 'twentyten'), esc_html($s)); the_page_number(); echo ' | '; bloginfo('name'); 13 13 } elseif ( is_404() ) { 14 14 _e('Not Found', 'twentyten'); echo ' | '; bloginfo('name'); 15 15 } else { 16 wp_title(''); echo ' | '; bloginfo('name'); get_page_number();16 wp_title(''); echo ' | '; bloginfo('name'); the_page_number(); 17 17 } 18 18 ?></title> 19 19 -
wp-content/themes/twentyten/attachment.php
5 5 6 6 <?php the_post(); ?> 7 7 8 <p class="page-title"><a href="<?php echo get_permalink( $post->post_parent) ?>" title="<?php printf( esc_attr__( 'Return to %s', 'twentyten' ), esc_html( get_the_title($post->post_parent), 1 ) ) ?>" rel="gallery">← <?php echo get_the_title($post->post_parent) ?></a></p>8 <p class="page-title"><a href="<?php echo get_permalink( $post->post_parent ) ?>" title="<?php printf( esc_attr__( 'Return to %s', 'twentyten' ), esc_html( get_the_title( $post->post_parent ), 1 ) ) ?>" rel="gallery">← <?php echo get_the_title( $post->post_parent ) ?></a></p> 9 9 10 10 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 11 11 <h2 class="entry-title"><?php the_title(); ?></h2> 12 12 13 13 <div class="entry-meta"> 14 <span class="meta-prep meta-prep-author"><?php _e( 'By ', 'twentyten'); ?></span>14 <span class="meta-prep meta-prep-author"><?php _e( 'By ', 'twentyten' ); ?></span> 15 15 <span class="author vcard"><a class="url fn n" href="<?php echo get_author_posts_url( $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( esc_attr__( 'View all posts by %s', 'twentyten' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span> 16 16 <span class="meta-sep"> | </span> 17 17 <span class="meta-prep meta-prep-entry-date"><?php _e('Published ', 'twentyten'); ?></span> … … 22 22 <div class="entry-content"> 23 23 <div class="entry-attachment"> 24 24 <?php if ( wp_attachment_is_image( $post->ID ) ) : ?> 25 <p class="attachment"><a href="<?php echo wp_get_attachment_url( $post->ID); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php26 echo wp_get_attachment_image( $post->ID, array( $content_width, $content_width) ); // max $content_width wide or high.25 <p class="attachment"><a href="<?php echo wp_get_attachment_url( $post->ID ); ?>" title="<?php echo esc_attr( get_the_title() ); ?>" rel="attachment"><?php 26 echo wp_get_attachment_image( $post->ID, array( twentyten_content_width(), twentyten_content_width() ) ); // max $content_width wide or high. 27 27 ?></a></p> 28 28 29 29 … … 32 32 <div class="nav-next"><?php next_image_link( false ); ?></div> 33 33 </div><!-- #nav-below --> 34 34 <?php else : ?> 35 <a href="<?php echo wp_get_attachment_url( $post->ID) ?>" title="<?php echo esc_attr( get_the_title($post->ID) ); ?>" rel="attachment"><?php echo basename(get_permalink()) ?></a>35 <a href="<?php echo wp_get_attachment_url( $post->ID ) ?>" title="<?php echo esc_attr( get_the_title( $post->ID ) ); ?>" rel="attachment"><?php echo basename( get_permalink() ) ?></a> 36 36 <?php endif; ?> 37 37 </div> 38 <div class="entry-caption"><?php if ( ! empty($post->post_excerpt) ) the_excerpt() ?></div>38 <div class="entry-caption"><?php if ( ! empty( $post->post_excerpt ) ) the_excerpt() ?></div> 39 39 40 40 <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> 41 <?php wp_link_pages( 'before=<div class="page-link">' . __( 'Pages:', 'twentyten' ) . '&after=</div>') ?>41 <?php wp_link_pages( 'before=<div class="page-link">' . __( 'Pages:', 'twentyten' ) . '&after=</div>' ) ?> 42 42 43 43 </div><!-- .entry-content --> 44 44 … … 69 69 </div><!-- #container --> 70 70 71 71 <?php get_sidebar(); ?> 72 <?php get_footer(); ?> 73 No newline at end of file 72 <?php get_footer(); ?>