Changeset 23713
- Timestamp:
- 03/15/2013 05:09:12 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentytwelve/functions.php
r23572 r23713 84 84 85 85 /** 86 * Enqueues scripts and styles for front-end. 87 * 88 * @since Twenty Twelve 1.0 89 */ 90 function twentytwelve_scripts_styles() { 91 global $wp_styles; 92 93 /* 94 * Adds JavaScript to pages with the comment form to support 95 * sites with threaded comments (when in use). 96 */ 97 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) 98 wp_enqueue_script( 'comment-reply' ); 99 100 /* 101 * Adds JavaScript for handling the navigation menu hide-and-show behavior. 102 */ 103 wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0', true ); 104 105 /* 106 * Loads our special font CSS file. 107 * 108 * The use of Open Sans by default is localized. For languages that use 109 * characters not supported by the font, the font can be disabled. 110 * 111 * To disable in a child theme, use wp_dequeue_style() 112 * function mytheme_dequeue_fonts() { 113 * wp_dequeue_style( 'twentytwelve-fonts' ); 114 * } 115 * add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 ); 116 */ 86 * Returns the Google font stylesheet URL if available. 87 * 88 * The use of Open Sans by default is localized. For languages that use 89 * characters not supported by the font, the font can be disabled. 90 * 91 * @since Twenty Twelve 1.2 92 * 93 * @return string Font stylesheet or empty string if disabled. 94 */ 95 function twentytwelve_get_font_url() { 96 $font_url = ''; 117 97 118 98 /* translators: If there are characters in your language that are not supported 119 99 by Open Sans, translate this to 'off'. Do not translate into your own language. */ 120 100 if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) ) { 121 101 $subsets = 'latin,latin-ext'; 122 102 123 103 /* translators: To add an additional Open Sans character subset specific to your language, translate 124 104 this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */ 125 105 $subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'twentytwelve' ); 126 106 … … 137 117 'subset' => $subsets, 138 118 ); 139 wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null);119 $font_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ); 140 120 } 121 122 return $font_url; 123 } 124 125 /** 126 * Enqueues scripts and styles for front-end. 127 * 128 * @since Twenty Twelve 1.0 129 */ 130 function twentytwelve_scripts_styles() { 131 global $wp_styles; 132 133 /* 134 * Adds JavaScript to pages with the comment form to support 135 * sites with threaded comments (when in use). 136 */ 137 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) 138 wp_enqueue_script( 'comment-reply' ); 139 140 /* 141 * Adds JavaScript for handling the navigation menu hide-and-show behavior. 142 */ 143 wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0', true ); 144 145 $font_url = twentytwelve_get_font_url(); 146 if ( ! empty( $font_url ) ) 147 wp_enqueue_style( 'twentytwelve-fonts', esc_url_raw( $font_url ), array(), null ); 141 148 142 149 /* … … 152 159 } 153 160 add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' ); 161 162 /** 163 * Adds additional stylesheets to the TinyMCE editor if needed. 164 * 165 * @uses twentytwelve_get_font_url() To get the Google Font stylesheet URL. 166 * 167 * @since Twenty Twelve 1.2 168 * 169 * @param string $mce_css CSS path to load in TinyMCE. 170 * @return string 171 */ 172 function twentytwelve_mce_css( $mce_css ) { 173 $font_url = twentytwelve_get_font_url(); 174 175 if ( empty( $font_url ) ) 176 return $mce_css; 177 178 if ( ! empty( $mce_css ) ) 179 $mce_css .= ','; 180 181 $mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) ); 182 183 return $mce_css; 184 } 185 add_filter( 'mce_css', 'twentytwelve_mce_css' ); 154 186 155 187 /**
Note: See TracChangeset
for help on using the changeset viewer.