WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/06/2012 11:04:56 PM (6 years ago)
Author:
nacin
Message:

Freshen up the docs in functions.php. Remove is_admin() check from twentytwelve_enqueue_scripts(). Remove function_exists() wrappers from functions that are hooked in. Kill locale.php handling. see #19978.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r19842 r19844  
    22/**
    33 * Twenty Twelve functions and definitions
     4 *
     5 * Sets up the theme and provides some helper functions. Some helper functions
     6 * are used in the theme as custom template tags. Others are attached to action and
     7 * filter hooks in WordPress to change core functionality.
     8 *
     9 * The first function, twentytwelve_setup(), sets up the theme by registering support
     10 * for various features in WordPress, such as a custom background and a navigation menu.
     11 *
     12 * When using a child theme (see http://codex.wordpress.org/Theme_Development and
     13 * http://codex.wordpress.org/Child_Themes), you can override certain functions
     14 * (those wrapped in a function_exists() call) by defining them first in your child theme's
     15 * functions.php file. The child theme's functions.php file is included before the parent
     16 * theme's file, so the child theme functions would be used.
     17 *
     18 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
     19 * to a filter or action hook.
     20 *
     21 * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
    422 *
    523 * @package WordPress
     
    826 */
    927
    10 // Set the content width based on the theme's design and stylesheet.
     28/**
     29 * Set the content width based on the theme's design and stylesheet.
     30 */
    1131if ( ! isset( $content_width ) )
    1232    $content_width = 584;
    1333
    14 add_action( 'wp_enqueue_scripts', 'twentytwelve_enqueue_scripts' );
    15 
    16 if ( ! function_exists( 'twentytwelve_enqueue_scripts' ) ) :
    17 /**
    18 * Add theme styles and scripts here
    19 */
    20 function twentytwelve_enqueue_scripts() {
    21 
    22     if ( ! is_admin() ) {
    23         wp_enqueue_style(
    24             'twentytwelve-style',
    25             get_bloginfo( 'stylesheet_url' )
    26         );
    27     }
    28 
    29 }
    30 endif; // twentytwelve_enqueue_scripts
    31 
    32 // Tell WordPress to run twentytwelve_setup() when the 'after_setup_theme' hook is run.
     34/**
     35 * Tell WordPress to run twentytwelve_setup() when the 'after_setup_theme' hook is run.
     36 */
    3337add_action( 'after_setup_theme', 'twentytwelve_setup' );
    3438
     
    5357    load_theme_textdomain( 'twentytwelve', get_template_directory() . '/languages' );
    5458
    55     $locale = get_locale();
    56     $locale_file = get_template_directory() . "/languages/$locale.php";
    57     if ( is_readable( $locale_file ) )
    58         require_once( $locale_file );
    59 
    6059    // Add default posts and comments RSS feed links to <head>.
    6160    add_theme_support( 'automatic-feed-links' );
     
    6766    add_custom_background();
    6867}
    69 endif; // twentytwelve_setup
    70 
    71 // Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
     68endif;
     69
     70/**
     71 * Enqueues the theme's stylesheet.
     72 *
     73 * The wp_enqueue_scripts hook is meant for both styles and scripts, and only
     74 * fires on the frontend.
     75 *
     76 * @since Twenty Twelve 1.0
     77 */
     78function twentytwelve_enqueue_scripts() {
     79    wp_enqueue_style( 'twentytwelve-style', get_bloginfo( 'stylesheet_url' ) );
     80}
     81add_action( 'wp_enqueue_scripts', 'twentytwelve_enqueue_scripts' );
     82
     83/**
     84 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
     85 *
     86 * @since Twenty Twelve 1.0
     87 */
    7288function twentytwelve_page_menu_args( $args ) {
    7389    $args['show_home'] = true;
     
    7793
    7894/**
    79  * Register our sidebars and widgetized areas. Also register the default Epherma widget.
     95 * Register our single widget area.
    8096 *
    8197 * @since Twenty Twelve 1.0
     
    94110
    95111if ( ! function_exists( 'twentytwelve_content_nav' ) ) :
    96 // Display navigation to next/previous pages when applicable
     112/**
     113 * Display navigation to next/previous pages when applicable
     114 *
     115 * @since Twenty Twelve 1.0
     116 */
    97117function twentytwelve_content_nav( $nav_id ) {
    98118    global $wp_query;
     
    106126    <?php endif;
    107127}
    108 endif; // twentytwelve_content_nav
     128endif;
    109129
    110130if ( ! function_exists( 'twentytwelve_comment' ) ) :
     
    161181                    <br />
    162182                <?php endif; ?>
    163 
    164183            </footer>
    165184
     
    175194    endswitch;
    176195}
    177 endif; // ends check for twentytwelve_comment()
     196endif;
    178197
    179198if ( ! function_exists( 'twentytwelve_posted_on' ) ) :
    180199/**
    181200 * Prints HTML with meta information for the current post-date/time and author.
    182  * Create your own twentytwelve_posted_on to override in a child theme
     201 *
     202 * Create your own twentytwelve_posted_on() to override in a child theme.
    183203 *
    184204 * @since Twenty Twelve 1.0
Note: See TracChangeset for help on using the changeset viewer.