Changeset 13403 for trunk/wp-admin/custom-header.php
- Timestamp:
- 02/25/2010 07:18:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-header.php
r13339 r13403 33 33 */ 34 34 var $admin_image_div_callback; 35 36 var $default_headers = array(); 35 37 36 38 /** … … 134 136 remove_theme_mods(); 135 137 } 138 139 if ( isset($_POST['default-header']) ) { 140 $this->process_default_headers(); 141 if ( isset($this->default_headers[$_POST['default-header']]) ) 142 set_theme_mod('header_image', esc_url($this->default_headers[$_POST['default-header']]['url'])); 143 } 144 } 145 146 /** 147 * Process the default headers 148 * 149 * @since 3.0.0 150 */ 151 function process_default_headers() { 152 global $_wp_default_headers; 153 154 if ( !empty($this->headers) ) 155 return; 156 157 if ( !isset($_wp_default_headers) ) 158 return; 159 160 $this->default_headers = $_wp_default_headers; 161 foreach ( array_keys($this->default_headers) as $header ) { 162 $this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ); 163 $this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], get_template_directory_uri(), get_stylesheet_directory_uri() ); 164 } 165 } 166 167 /** 168 * Display UI for selecting one of several default headers. 169 * 170 * @since 3.0.0 171 */ 172 function show_default_header_selector() { 173 echo '<table id="available-headers" cellspacing="0" cellpadding="0">'; 174 175 $headers = array_keys($this->default_headers); 176 $table = array(); 177 $rows = ceil(count($headers) / 3); 178 for ( $row = 1; $row <= $rows; $row++ ) { 179 for ( $col = 1; $col <= 3; $col++ ) { 180 $table[$row][$col] = array_shift($headers); 181 } 182 } 183 184 foreach ( $table as $row => $cols ) { 185 echo '<tr>'; 186 foreach ( $cols as $col => $header_key ) { 187 if ( !$header_key ) 188 continue; 189 $class = array('available-theme'); 190 if ( $row == 1 ) $class[] = 'top'; 191 if ( $col == 1 ) $class[] = 'left'; 192 if ( $row == $rows ) $class[] = 'bottom'; 193 if ( $col == 3 ) $class[] = 'right'; 194 if ( !isset($this->headers[$header_key])) 195 echo '<td class="' . join(' ', $class) . '">'; 196 $header_thumbnail = $this->default_headers[$header_key]['thumbnail_url']; 197 $header_url = $this->default_headers[$header_key]['url']; 198 $header_desc = $this->default_headers[$header_key]['description']; 199 echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_header_image(), false) . ' />'; 200 echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" /></label>'; 201 echo '</td>'; 202 } 203 echo '</tr>'; 204 } 205 echo '</table>'; 136 206 } 137 207 … … 285 355 */ 286 356 function step_1() { 357 $this->process_default_headers(); 287 358 if ( isset($_GET['updated']) && $_GET['updated'] ) { ?> 288 359 <div id="message" class="updated"> … … 294 365 <?php screen_icon(); ?> 295 366 <h2><?php _e('Your Header Image'); ?></h2> 367 <?php 368 if ( get_theme_mod('header_image') || empty($this->default_headers) ) : 369 ?> 296 370 <p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p> 297 371 <?php … … 311 385 <input type="button" class="button" value="<?php esc_attr_e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> 312 386 <input type="button" class="button" value="<?php esc_attr_e('Select a Text Color'); ?>" id="pickcolor" /><input type="button" class="button" value="<?php esc_attr_e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" /> 313 <?php wp_nonce_field('custom-header') ?>387 <?php wp_nonce_field('custom-header'); ?> 314 388 <input type="hidden" name="textcolor" id="textcolor" value="#<?php esc_attr(header_textcolor()) ?>" /><input name="submit" type="submit" class="button" value="<?php esc_attr_e('Save Changes'); ?>" /></form> 315 389 <?php } ?> … … 317 391 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"> </div> 318 392 </div> 393 <?php 394 else: 395 echo '<p>' . __('Choose one of these cool headers, or upload your own image below.') . '</p>'; 396 echo '<form method="post" action="' . admin_url('themes.php?page=custom-header&updated=true') . '">'; 397 wp_nonce_field('custom-header'); 398 $this->show_default_header_selector(); 399 echo '<input type="submit" class="button" value="' . esc_attr__('Save Your Choice') . '" />'; 400 echo '</form>'; 401 echo '</div>'; 402 endif; 403 ?> 319 404 <div class="wrap"> 320 405 <h2><?php _e('Upload New Header Image'); ?></h2><p><?php _e('Here you can upload a custom header image to be shown at the top of your blog instead of the default one. On the next screen you will be able to crop the image.'); ?></p>
Note: See TracChangeset
for help on using the changeset viewer.