Make WordPress Core


Ignore:
Timestamp:
08/25/2012 04:53:32 PM (12 years ago)
Author:
lancewillett
Message:

Twenty Twelve: review and clarify code commenting and documentation. Props jorbin and obenland. See #21675.

File:
1 edited

Legend:

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

    r21611 r21617  
    11<?php
    22/**
    3  * 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
     3 * Twenty Twelve functions and definitions.
     4 *
     5 * Sets up the theme and provides some helper functions, which are used
     6 * in the theme as custom template tags. Others are attached to action and
    77 * 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.
    118 *
    129 * When using a child theme (see http://codex.wordpress.org/Theme_Development and
     
    2724
    2825/**
    29  * Set the content width based on the theme's design and stylesheet.
     26 * Sets up the content width value based on the theme's design and stylesheet.
    3027 */
    3128if ( ! isset( $content_width ) )
     
    3330
    3431/**
    35  * Sets up theme defaults and registers support for various WordPress features.
     32 * Sets up theme defaults and registers the various WordPress features that
     33 * Twenty Twelve supports.
    3634 *
    3735 * @uses load_theme_textdomain() For translation/localization support.
    38  * @uses add_theme_support() To add support for post thumbnails, automatic feed links, custom headers
    39  *  and backgrounds, and post formats.
     36 * @uses add_editor_style() To add a Visual Editor stylesheet.
     37 * @uses add_theme_support() To add support for post thumbnails, automatic feed links,
     38 *  custom background, and post formats.
    4039 * @uses register_nav_menu() To add support for navigation menus.
    4140 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
     
    4645    global $twentytwelve_options;
    4746
    48     /**
    49      * Make Twenty Twelve available for translation.
     47    /*
     48     * Makes Twenty Twelve available for translation.
     49     *
    5050     * Translations can be added to the /languages/ directory.
    5151     * If you're building a theme based on Twenty Twelve, use a find and replace
     
    6161    add_editor_style();
    6262
    63     // Add default posts and comments RSS feed links to <head>.
     63    // Adds RSS feed links to <head> for posts and comments.
    6464    add_theme_support( 'automatic-feed-links' );
    6565
    66     // Add support for a variety of post formats
     66    // This theme supports a variety of post formats.
    6767    add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote' ) );
    6868
     
    7070    register_nav_menu( 'primary', __( 'Primary Menu', 'twentytwelve' ) );
    7171
    72     // Add support for custom background.
     72    /*
     73     * This theme supports custom background color and image, and here
     74     * we also set up the default background color.
     75     */
    7376    add_theme_support( 'custom-background', array(
    7477        'default-color' => 'e6e6e6',
    7578    ) );
    7679
    77     // Add custom image size for featured image use, displayed on "standard" posts.
     80    // This theme uses a custom image size for featured images, displayed on "standard" posts.
    7881    add_theme_support( 'post-thumbnails' );
    7982    set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop
     
    8285
    8386/**
    84  * Add support for a custom header image.
     87 * Adds support for a custom header image.
    8588 */
    8689require( get_template_directory() . '/inc/custom-header.php' );
    8790
    8891/**
    89  * Enqueue scripts and styles for front-end.
     92 * Enqueues scripts and styles for front-end.
    9093 *
    9194 * @since Twenty Twelve 1.0
     
    9497    global $twentytwelve_options;
    9598
    96     /**
    97      * Add JavaScript to pages with the comment form to support
     99    /*
     100     * Adds JavaScript to pages with the comment form to support
    98101     * sites with threaded comments (when in use).
    99102     */
     
    101104        wp_enqueue_script( 'comment-reply' );
    102105
    103     /**
    104      * JavaScript for handling navigation menus and the resized
    105      * styles for small screen sizes.
     106    /*
     107     * Adds JavaScript for handling the navigation menu hide-and-show behavior.
    106108     */
    107109    wp_enqueue_script( 'twentytwelve-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120824', true );
    108110
    109     /**
    110      * Load special font CSS file.
     111    /*
     112     * Loads our special font CSS file.
    111113     * Depends on Theme Options setting.
    112114     */
     
    115117        wp_enqueue_style( 'twentytwelve-fonts', $twentytwelve_options->custom_fonts_url(), array(), null );
    116118
    117     /**
    118      * Load our main CSS file.
     119    /*
     120     * Loads our main stylesheet.
    119121     */
    120122    wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );
    121123
    122     /**
    123      * Load HTML5 shiv for older IE version support for HTML5 elements.
     124    /*
     125     * Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions.
    124126     * Ideally, should load after main CSS file.
    125      *
    126127     * See html5.js link in header.php.
    127128     *
     
    165166
    166167/**
    167  * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
     168 * Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link.
    168169 *
    169170 * @since Twenty Twelve 1.0
     
    176177
    177178/**
    178  * Register our single widget area.
     179 * Registers our main widget area and the homepage widget areas.
    179180 *
    180181 * @since Twenty Twelve 1.0
     
    214215
    215216/**
    216  * Count the number of footer sidebars to enable dynamic classes for the footer
     217 * Counts the number of footer sidebars to enable dynamic classes for the footer.
    217218 *
    218219 * @since Twenty Twelve 1.0
     
    229230if ( ! function_exists( 'twentytwelve_content_nav' ) ) :
    230231/**
    231  * Display navigation to next/previous pages when applicable.
     232 * Displays navigation to next/previous pages when applicable.
    232233 *
    233234 * @since Twenty Twelve 1.0
     
    365366 *
    366367 * @since Twenty Twelve 1.0
     368 *
     369 * @param array Existing class values.
     370 * @return array Filtered class values.
    367371 */
    368372function twentytwelve_body_class( $classes ) {
     
    385389
    386390/**
    387  * Adjust $content width for full-width and single image attachment templates
    388  * and when there are no active widgets in the sidebar.
     391 * Adjusts content_width value for full-width and single image attachment
     392 * templates, and when there are no active widgets in the sidebar.
    389393 *
    390394 * @since Twenty Twelve 1.0
Note: See TracChangeset for help on using the changeset viewer.