Make WordPress Core

Changeset 16720


Ignore:
Timestamp:
12/04/2010 09:59:35 AM (14 years ago)
Author:
nacin
Message:

Introduce remove_custom_background(). see #14903.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/theme.php

    r16711 r16720  
    14751475   
    14761476    $callback = get_theme_support( 'custom-header' );
    1477     remove_action( 'wp_head', $callback['callback'] );
     1477    remove_action( 'wp_head', $callback[0]['callback'] );
    14781478    _remove_theme_support( 'custom-header' );
    14791479    remove_theme_support( 'custom-header-uploads' );
     
    15841584 * @param callback $admin_image_div_callback Output a custom background image div on the custom background administration screen. Optional.
    15851585 */
    1586 function add_custom_background($header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '') {
    1587     if ( isset($GLOBALS['custom_background']) )
     1586function add_custom_background( $header_callback = '', $admin_header_callback = '', $admin_image_div_callback = '' ) {
     1587    if ( isset( $GLOBALS['custom_background'] ) )
    15881588        return;
    15891589
    1590     if ( empty($header_callback) )
     1590    if ( empty( $header_callback ) )
    15911591        $header_callback = '_custom_background_cb';
    15921592
    1593     add_action('wp_head', $header_callback);
    1594 
    1595     add_theme_support( 'custom-background' );
     1593    add_action( 'wp_head', $header_callback );
     1594
     1595    add_theme_support( 'custom-background', array( 'callback' => $header_callback ) );
    15961596
    15971597    if ( ! is_admin() )
    15981598        return;
    1599     require_once(ABSPATH . 'wp-admin/custom-background.php');
    1600     $GLOBALS['custom_background'] =& new Custom_Background($admin_header_callback, $admin_image_div_callback);
    1601     add_action('admin_menu', array(&$GLOBALS['custom_background'], 'init'));
     1599    require_once( ABSPATH . 'wp-admin/custom-background.php' );
     1600    $GLOBALS['custom_background'] =& new Custom_Background( $admin_header_callback, $admin_image_div_callback );
     1601    add_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) );
     1602}
     1603
     1604/**
     1605 * Remove custom background support.
     1606 *
     1607 * @since 3.1.0
     1608 * @see add_custom_background()
     1609 *
     1610 * @return bool Whether support was removed.
     1611 */
     1612function remove_custom_background() {
     1613    if ( ! current_theme_supports( 'custom-background' ) )
     1614        return false;
     1615   
     1616    $callback = get_theme_support( 'custom-background' );
     1617    remove_action( 'wp_head', $callback[0]['callback'] );
     1618    _remove_theme_support( 'custom-background' );
     1619
     1620    if ( is_admin() ) {
     1621        remove_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) );
     1622        unset( $GLOBALS['custom_background'] );
     1623    }
     1624
     1625    return true;
    16021626}
    16031627
     
    17271751
    17281752/**
    1729  * Removes theme support internally, ignorant of the blacklist.
     1753 * Do not use. Removes theme support internally, ignorant of the blacklist.
    17301754 *
    17311755 * @access private
Note: See TracChangeset for help on using the changeset viewer.