WordPress.org

Make WordPress Core

Changeset 12890


Ignore:
Timestamp:
01/28/2010 07:00:16 PM (12 years ago)
Author:
ryan
Message:

Send user back to main custom header page after cropping and setting image. Add support for a custom image div callback for greather theme flexibility. Props dphiffer. see #11855

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-header.php

    r12752 r12890  
    2626
    2727    /**
     28     * Callback for header div.
     29     *
     30     * @var callback
     31     * @since unknown
     32     * @access private
     33     */
     34    var $admin_image_div_callback;
     35
     36    /**
    2837     * PHP4 Constructor - Register administration header callback.
    2938     *
    3039     * @since unknown
    3140     * @param callback $admin_header_callback
     41     * @param callback $admin_image_div_callback Optional custom image div output callback.
    3242     * @return Custom_Image_Header
    3343     */
    34     function Custom_Image_Header($admin_header_callback) {
     44    function Custom_Image_Header($admin_header_callback, $admin_image_div_callback = '') {
    3545        $this->admin_header_callback = $admin_header_callback;
     46        $this->admin_image_div_callback = $admin_image_div_callback;
    3647    }
    3748
     
    268279     */
    269280    function step_1() {
    270         if ( $_GET['updated'] ) { ?>
     281        if ( isset($_GET['updated']) && $_GET['updated'] ) { ?>
    271282<div id="message" class="updated">
    272 <p><?php _e('Header updated.') ?></p>
     283<p><?php printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url()); ?></p>
    273284</div>
    274285        <?php } ?>
     
    278289<h2><?php _e('Your Header Image'); ?></h2>
    279290<p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>
    280 
     291<?php
     292
     293if ( $this->admin_image_div_callback ) {
     294  call_user_func($this->admin_image_div_callback);
     295} else {
     296?>
    281297<div id="headimg" style="background-image: url(<?php esc_url(header_image()) ?>);">
    282298<h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>
    283299<div id="desc"><?php bloginfo('description');?></div>
    284300</div>
     301<?php } ?>
     302
    285303<?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?>
    286304<form method="post" action="<?php echo admin_url('themes.php?page=custom-header&amp;updated=true') ?>">
     
    456474     */
    457475    function finished() {
    458         ?>
    459 <div class="wrap">
    460 <h2><?php _e('Header complete!'); ?></h2>
    461 
    462 <p><?php _e('Visit your site and you should see the new header now.'); ?></p>
    463 
    464 </div>
    465         <?php
     476        $_GET['updated'] = 1;
     477      $this->step_1();
    466478    }
    467479
  • trunk/wp-includes/theme.php

    r12733 r12890  
    12991299 *
    13001300 * @param callback $header_callback Call on 'wp_head' action.
    1301  * @param callback $admin_header_callback Call on administration panels.
    1302  */
    1303 function add_custom_image_header($header_callback, $admin_header_callback) {
     1301 * @param callback $admin_header_callback Call on custom header administration screen.
     1302 * @param callback $admin_image_div_callback Output a custom header image div on the custom header administration screen. Optional.
     1303 */
     1304function add_custom_image_header($header_callback, $admin_header_callback, $admin_image_div_callback = '') {
    13041305    if ( ! empty($header_callback) )
    13051306        add_action('wp_head', $header_callback);
     
    13081309        return;
    13091310    require_once(ABSPATH . 'wp-admin/custom-header.php');
    1310     $GLOBALS['custom_image_header'] =& new Custom_Image_Header($admin_header_callback);
     1311    $GLOBALS['custom_image_header'] =& new Custom_Image_Header($admin_header_callback, $admin_image_div_callback);
    13111312    add_action('admin_menu', array(&$GLOBALS['custom_image_header'], 'init'));
    13121313}
Note: See TracChangeset for help on using the changeset viewer.