Make WordPress Core

Changeset 16674


Ignore:
Timestamp:
12/02/2010 12:16:35 AM (14 years ago)
Author:
nacin
Message:

Introduce remove_custom_image_header(). see #14903.

File:
1 edited

Legend:

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

    r16660 r16674  
    14451445 * @param callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional.
    14461446 */
    1447 function add_custom_image_header($header_callback, $admin_header_callback, $admin_image_div_callback = '') {
    1448     if ( ! empty($header_callback) )
     1447function add_custom_image_header( $header_callback, $admin_header_callback, $admin_image_div_callback = '' ) {
     1448    if ( ! empty( $header_callback ) )
    14491449        add_action('wp_head', $header_callback);
    14501450
    1451     add_theme_support( 'custom-header' );
     1451    add_theme_support( 'custom-header', array( 'callback' => $header_callback ) );
    14521452    add_theme_support( 'custom-header-uploads' );
    14531453
    14541454    if ( ! is_admin() )
    14551455        return;
    1456     require_once(ABSPATH . 'wp-admin/custom-header.php');
    1457     $GLOBALS['custom_image_header'] =& new Custom_Image_Header($admin_header_callback, $admin_image_div_callback);
    1458     add_action('admin_menu', array(&$GLOBALS['custom_image_header'], 'init'));
     1456
     1457    global $custom_image_header;
     1458
     1459    require_once( ABSPATH . 'wp-admin/custom-header.php' );
     1460    $custom_image_header = new Custom_Image_Header( $admin_header_callback, $admin_image_div_callback );
     1461    add_action( 'admin_menu', array( &$custom_image_header, 'init' ) );
     1462}
     1463
     1464/**
     1465 * Remove image header support.
     1466 *
     1467 * @since 3.1.0
     1468 * @see add_custom_image_header()
     1469 *
     1470 * @return bool Whether support was removed.
     1471 */
     1472function remove_custom_image_header() {
     1473    if ( ! current_theme_supports( 'custom-header' ) )
     1474        return false;
     1475   
     1476    $callback = get_theme_support( 'custom-header' );
     1477    remove_action( 'wp_head', $callback['callback'] );
     1478    _remove_theme_support( 'custom-header' );
     1479    remove_theme_support( 'custom-header-uploads' );
     1480
     1481    if ( ! is_admin() )
     1482        return;
     1483
     1484    global $custom_image_header;
     1485
     1486    remove_action( 'admin_menu', array( &$custom_image_header, 'init' ) );
     1487
     1488    unset( $GLOBALS['custom_image_header'] );
     1489    return true;
    14591490}
    14601491
     
    16951726    if ( in_array( $feature, array( 'custom-background', 'custom-header', 'editor-style', 'widgets', 'menus' ) ) )
    16961727        return false;
    1697 
     1728    return _remove_theme_support( $feature );
     1729}
     1730
     1731/**
     1732 * Removes theme support internally, ignorant of the blacklist.
     1733 *
     1734 * @access private
     1735 * @since 3.1.0
     1736 */
     1737function _remove_theme_support( $feature ) {
    16981738    global $_wp_theme_features;
    16991739
Note: See TracChangeset for help on using the changeset viewer.