Changeset 8371
- Timestamp:
- 02/28/2019 07:10:01 AM (6 years ago)
- Location:
- sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php
r8367 r8371 19 19 } 20 20 21 // Add any actions/filters that should run for WordPress.TV & Blog.WordPress.TV here. 22 add_action( 'wp_head', array( $this, 'rel_canonical' ) ); 23 } 24 25 /** 26 * Runs during after_setup_theme. 21 add_action( 'after_setup_theme', array( $this, 'setup_always' ) ); 22 } 23 24 /** 25 * Runs during after_setup_theme on WordPress.TV 27 26 */ 28 27 function setup() { … … 39 38 add_filter( 'pre_option_blog_upload_space', array( $this, 'blog_upload_space' ) ); 40 39 40 add_filter( 'document_title_parts', array( $this, 'document_title_parts' ) ); 41 41 42 register_nav_menus( array( 42 43 'primary' => __( 'Primary Menu', 'wptv' ), … … 44 45 'featured_wordcamps' => __( 'Featured WordCamps', 'wptv' ), 45 46 ) ); 47 } 48 49 /** 50 * Runs during after_setup_theme on WordPress.TV & blog.WordPress.TV 51 */ 52 function setup_always() { 53 add_theme_support( 'title-tag' ); 54 55 // Add any actions/filters that should run for WordPress.TV & Blog.WordPress.TV here. 56 add_action( 'wp_head', array( $this, 'rel_canonical' ) ); 46 57 } 47 58 … … 71 82 printf( '<link rel="canonical" href="%s">', esc_url( $canonical ) ); 72 83 } 84 } 85 86 /** 87 * Filter archive titles where needed. 88 */ 89 function document_title_parts( $title ) { 90 $sep = apply_filters( 'document_title_separator', '-' ); 91 92 if ( is_tax( 'language' ) ) { 93 $title['title'] = sprintf( 94 /* translators: %s: The language name. */ 95 __( 'Videos in %s', 'wptv' ), 96 get_queried_object()->name 97 ); 98 } elseif ( is_tax() || is_tag() || is_category() ) { 99 // Suffix the Taxonomy label to the Term Name 100 $tax = get_taxonomy( get_queried_object()->taxonomy ); 101 $tax_label = $tax->labels->singular_name ?? $tax->label; 102 103 $title['title'] .= " $sep $tax_label"; 104 } 105 106 return $title; 73 107 } 74 108 … … 824 858 825 859 /** 826 * Create a nicely formatted and more specific title element text for output827 * in head of document, based on current view.828 *829 * @global $paged830 * @global $page831 *832 *833 * @param string $title Default title text for current view.834 * @param string $sep Optional separator.835 * @return string The filtered title.836 */837 function wptv_wp_title( $title, $sep ) {838 if ( is_feed() ) {839 return $title;840 }841 842 global $paged, $page;843 844 // Add the site name.845 $title .= get_bloginfo( 'name', 'display' );846 847 // Add the site description for the home/front page.848 $site_description = get_bloginfo( 'description', 'display' );849 if ( $site_description && ( is_home() || is_front_page() ) ) {850 $title = "$title $sep $site_description";851 }852 853 // Add a page number if necessary.854 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {855 $title = "$title $sep " . sprintf( __( 'Page %s', 'wptv' ), max( $paged, $page ) );856 }857 858 return $title;859 }860 add_filter( 'wp_title', 'wptv_wp_title', 10, 2 );861 862 /**863 860 * Append the slide URL to the excerpt 864 861 * -
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/header.php
r6374 r8371 15 15 <head> 16 16 <meta charset="<?php bloginfo( 'charset' ); ?>"> 17 <title><?php wp_title( '|', true, 'right' ); ?></title>18 17 19 18 <link rel="alternate" type="application/rss+xml" title="<?php esc_attr_e( 'WordPress.tv RSS Feed', 'wptv' ); ?>" href="https://wordpress.tv/feed/" />
Note: See TracChangeset
for help on using the changeset viewer.