Changeset 14907 for trunk/wp-admin/custom-header.php
- Timestamp:
- 05/25/2010 10:05:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-header.php
r14626 r14907 100 100 $step = $this->step(); 101 101 102 if ( 1 == $step)102 if ( ( 1 == $step || 3 == $step ) && $this->header_text() ) 103 103 wp_enqueue_script('farbtastic'); 104 104 elseif ( 2 == $step ) 105 wp_enqueue_script(' jcrop');105 wp_enqueue_script('imgareaselect'); 106 106 } 107 107 … … 114 114 $step = $this->step(); 115 115 116 if ( 1 == $step)116 if ( ( 1 == $step || 3 == $step ) && $this->header_text() ) 117 117 wp_enqueue_style('farbtastic'); 118 118 elseif ( 2 == $step ) 119 wp_enqueue_style('jcrop'); 119 wp_enqueue_style('imgareaselect'); 120 } 121 122 /** 123 * Check if header text is allowed 124 * 125 * @since 3.0.0 126 */ 127 function header_text() { 128 if ( defined( 'NO_HEADER_TEXT' ) && NO_HEADER_TEXT ) 129 return false; 130 131 return true; 120 132 } 121 133 … … 129 141 return; 130 142 131 if ( isset( $_POST['textcolor'] ) ) { 132 check_admin_referer('custom-header'); 133 if ( 'blank' == $_POST['textcolor'] ) { 134 set_theme_mod('header_textcolor', 'blank'); 143 if ( empty( $_POST ) ) 144 return; 145 146 $this->updated = true; 147 148 if ( isset( $_POST['resetheader'] ) ) { 149 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 150 remove_theme_mod( 'header_image' ); 151 return; 152 } 153 154 if ( isset( $_POST['resettext'] ) ) { 155 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 156 remove_theme_mod('header_textcolor'); 157 return; 158 } 159 160 if ( isset( $_POST['removeheader'] ) ) { 161 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 162 set_theme_mod( 'header_image', '' ); 163 return; 164 } 165 166 if ( isset( $_POST['text-color'] ) ) { 167 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 168 $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); 169 if ( 'blank' == $_POST['text-color'] ) { 170 set_theme_mod( 'header_textcolor', 'blank' ); 135 171 } else { 136 $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text color']);172 $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); 137 173 if ( strlen($color) == 6 || strlen($color) == 3 ) 138 174 set_theme_mod('header_textcolor', $color); … … 140 176 } 141 177 142 if ( isset($_POST['resetheader']) ) {143 check_admin_referer('custom-header');144 remove_theme_mods();145 }146 147 178 if ( isset($_POST['default-header']) ) { 148 check_admin_referer( 'custom-header');179 check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); 149 180 $this->process_default_headers(); 150 181 if ( isset($this->default_headers[$_POST['default-header']]) ) … … 180 211 */ 181 212 function show_default_header_selector() { 182 echo '<table id="available-headers" cellspacing="0" cellpadding="0">'; 183 184 $headers = array_keys($this->default_headers); 185 $table = array(); 186 $rows = ceil(count($headers) / 3); 187 for ( $row = 1; $row <= $rows; $row++ ) { 188 for ( $col = 1; $col <= 3; $col++ ) { 189 $table[$row][$col] = array_shift($headers); 190 } 191 } 192 193 foreach ( $table as $row => $cols ) { 194 echo '<tr>'; 195 foreach ( $cols as $col => $header_key ) { 196 if ( !$header_key ) 197 continue; 198 $class = array('available-header'); 199 if ( $row == 1 ) $class[] = 'top'; 200 if ( $col == 1 ) $class[] = 'left'; 201 if ( $row == $rows ) $class[] = 'bottom'; 202 if ( $col == 3 ) $class[] = 'right'; 203 if ( !isset($this->headers[$header_key])) 204 echo '<td class="' . join(' ', $class) . '">'; 205 $header_thumbnail = $this->default_headers[$header_key]['thumbnail_url']; 206 $header_url = $this->default_headers[$header_key]['url']; 207 $header_desc = $this->default_headers[$header_key]['description']; 208 echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_header_image(), false) . ' />'; 209 echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" /></label>'; 210 echo '</td>'; 211 } 212 echo '</tr>'; 213 } 214 echo '</table>'; 213 echo '<div id="available-headers">'; 214 foreach ( $this->default_headers as $header_key => $header ) { 215 $header_thumbnail = $header['thumbnail_url']; 216 $header_url = $header['url']; 217 $header_desc = $header['description']; 218 echo '<div class="default-header">'; 219 echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_theme_mod( 'header_image' ), false) . ' />'; 220 echo '<img src="' . $header_thumbnail . '" alt="' . esc_attr($header_desc) .'" title="' . esc_attr($header_desc) .'" /></label>'; 221 echo '</div>'; 222 } 223 echo '<div class="clear"></div></div>'; 215 224 } 216 225 … … 222 231 function js() { 223 232 $step = $this->step(); 224 if ( 1 == $step)233 if ( ( 1 == $step || 3 == $step ) && $this->header_text() ) 225 234 $this->js_1(); 226 235 elseif ( 2 == $step ) … … 229 238 230 239 /** 231 * Display Javascript based on Step 1 .240 * Display Javascript based on Step 1 and 3. 232 241 * 233 242 * @since 2.6.0 … … 235 244 function js_1() { ?> 236 245 <script type="text/javascript"> 237 var buttons = ['#name', '#desc', '#pickcolor', '#defaultcolor']; 246 /* <![CDATA[ */ 247 var text_objects = ['#name', '#desc', '#text-color-row']; 238 248 var farbtastic; 249 var default_color = '#<?php echo HEADER_TEXTCOLOR; ?>'; 250 var old_color = null; 239 251 240 252 function pickColor(color) { 241 253 jQuery('#name').css('color', color); 242 254 jQuery('#desc').css('color', color); 243 jQuery('#text color').val(color);255 jQuery('#text-color').val(color); 244 256 farbtastic.setColor(color); 257 } 258 259 function toggle_text(s) { 260 if (jQuery(s).attr('id') == 'showtext' && jQuery('#text-color').val() != 'blank') 261 return; 262 263 if (jQuery(s).attr('id') == 'hidetext' && jQuery('#text-color').val() == 'blank') 264 return; 265 266 if (jQuery('#text-color').val() == 'blank') { 267 //Show text 268 if (old_color == '#blank') 269 old_color = default_color; 270 271 jQuery( text_objects.toString() ).show(); 272 jQuery('#text-color').val(old_color); 273 jQuery('#name').css('color', old_color); 274 jQuery('#desc').css('color', old_color); 275 pickColor(old_color); 276 } else { 277 //Hide text 278 jQuery( text_objects.toString() ).hide(); 279 old_color = jQuery('#text-color').val(); 280 jQuery('#text-color').val('blank'); 281 } 245 282 } 246 283 247 284 jQuery(document).ready(function() { 248 285 jQuery('#pickcolor').click(function() { 249 jQuery('#color PickerDiv').show();286 jQuery('#color-picker').show(); 250 287 }); 251 288 252 jQuery(' #hidetext').click(function() {253 toggle_text( );289 jQuery('input[name="hidetext"]').click(function() { 290 toggle_text(this); 254 291 }); 255 292 256 farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { pickColor(color); }); 257 pickColor('#<?php echo get_theme_mod('header_textcolor', HEADER_TEXTCOLOR); ?>'); 258 259 <?php if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?> 293 jQuery('#defaultcolor').click(function() { 294 pickColor(default_color); 295 jQuery('#text-color').val(default_color) 296 }); 297 298 jQuery('#text-color').keyup(function() { 299 var _hex = jQuery('#text-color').val(); 300 var hex = _hex; 301 if ( hex[0] != '#' ) 302 hex = '#' + hex; 303 hex = hex.replace(/[^#a-fA-F0-9]+/, ''); 304 if ( hex != _hex ) 305 jQuery('#text-color').val(hex); 306 if ( hex.length == 4 || hex.length == 7 ) 307 pickColor( hex ); 308 }); 309 310 jQuery(document).mousedown(function(){ 311 jQuery('#color-picker').each( function() { 312 var display = jQuery(this).css('display'); 313 if (display == 'block') 314 jQuery(this).fadeOut(2); 315 }); 316 }); 317 318 farbtastic = jQuery.farbtastic('#color-picker', function(color) { pickColor(color); }); 319 <?php if ( $color = get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) ) { ?> 320 pickColor('#<?php echo $color; ?>'); 321 <?php } ?> 322 323 <?php if ( 'blank' == get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) { ?> 260 324 toggle_text(); 261 325 <?php } ?> 262 });263 264 jQuery(document).mousedown(function(){265 // Make the picker disappear, since we're using it in an independant div266 hide_picker();267 });268 269 function colorDefault() {270 pickColor('#<?php echo HEADER_TEXTCOLOR; ?>');271 }272 273 function hide_picker(what) {274 var update = false;275 jQuery('#colorPickerDiv').each(function(){276 var id = jQuery(this).attr('id');277 if (id == what) {278 return;279 }280 var display = jQuery(this).css('display');281 if (display == 'block') {282 jQuery(this).fadeOut(2);283 }284 326 }); 285 }286 287 function toggle_text(force) {288 if (jQuery('#textcolor').val() == 'blank') {289 //Show text290 jQuery( buttons.toString() ).show();291 jQuery('#textcolor').val('<?php echo HEADER_TEXTCOLOR; ?>');292 jQuery('#hidetext').val('<?php _e('Hide Text'); ?>');293 }294 else {295 //Hide text296 jQuery( buttons.toString() ).hide();297 jQuery('#textcolor').val('blank');298 jQuery('#hidetext').val('<?php _e('Show Text'); ?>');299 }300 }301 302 303 304 327 </script> 305 328 <?php … … 313 336 function js_2() { ?> 314 337 <script type="text/javascript"> 338 /* <![CDATA[ */ 315 339 function onEndCrop( coords ) { 316 340 jQuery( '#x1' ).val(coords.x); 317 341 jQuery( '#y1' ).val(coords.y); 318 jQuery( '#x2' ).val(coords.x2);319 jQuery( '#y2' ).val(coords.y2);320 342 jQuery( '#width' ).val(coords.w); 321 343 jQuery( '#height' ).val(coords.h); 322 344 } 323 345 324 // with a supplied ratio325 346 jQuery(document).ready(function() { 326 347 var xinit = <?php echo HEADER_IMAGE_WIDTH; ?>; … … 329 350 var ximg = jQuery('#upload').width(); 330 351 var yimg = jQuery('#upload').height(); 331 332 //set up default values333 jQuery( '#x1' ).val(0);334 jQuery( '#y1' ).val(0);335 jQuery( '#x2' ).val(xinit);336 jQuery( '#y2' ).val(yinit);337 jQuery( '#width' ).val(xinit);338 jQuery( '#height' ).val(yinit);339 352 340 353 if ( yimg < yinit || ximg < xinit ) { … … 348 361 } 349 362 350 jQuery('#upload').Jcrop({ 351 aspectRatio: ratio, 352 setSelect: [ 0, 0, xinit, yinit ], 353 onSelect: onEndCrop 363 jQuery('#upload').imgAreaSelect({ 364 handles: true, 365 keys: true, 366 aspectRatio: xinit + ':' + yinit, 367 show: true, 368 x1: 0, 369 y1: 0, 370 x2: xinit, 371 y2: yinit, 372 maxHeight: <?php echo HEADER_IMAGE_HEIGHT; ?>, 373 maxWidth: <?php echo HEADER_IMAGE_WIDTH; ?>, 374 onInit: function () { 375 jQuery('#width').val(xinit); 376 jQuery('#height').val(yinit); 377 }, 378 onSelectChange: function(img, c) { 379 jQuery('#x1').val(c.x1); 380 jQuery('#y1').val(c.y1); 381 jQuery('#width').val(c.width); 382 jQuery('#height').val(c.height); 383 } 354 384 }); 355 385 }); 386 /* ]]> */ 356 387 </script> 357 388 <?php … … 365 396 function step_1() { 366 397 $this->process_default_headers(); 367 398 ?> 368 399 369 400 <div class="wrap"> 370 401 <?php screen_icon(); ?> 371 <h2><?php _e('Your Header Image'); ?></h2> 372 373 <?php 374 if ( isset($_GET['updated']) && $_GET['updated'] ) { ?> 402 <h2><?php _e('Custom Header'); ?></h2> 403 404 <?php if ( ! empty( $this->updated ) ) { ?> 375 405 <div id="message" class="updated"> 376 406 <p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p> 377 407 </div> 378 <?php }379 380 if ( get_theme_mod('header_image') || empty($this->default_headers) ) :381 ?>382 <p><?php _e('This is your header image. You can change the text color or upload and crop a new image.'); ?></p>383 <?php384 385 if ( $this->admin_image_div_callback ) {386 call_user_func($this->admin_image_div_callback);387 } else {388 ?>389 <div id="headimg" style="background-image: url(<?php esc_url(header_image()) ?>);">390 <h1><a onclick="return false;" href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>" id="name"><?php bloginfo('name'); ?></a></h1>391 <div id="desc"><?php bloginfo('description');?></div>392 </div>393 408 <?php } ?> 394 409 395 <?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?> 396 <form method="post" action="<?php echo admin_url('themes.php?page=custom-header&updated=true') ?>"> 397 <input type="button" class="button" value="<?php esc_attr_e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" /> 398 <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" /> 399 <?php wp_nonce_field('custom-header'); ?> 400 <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> 401 <?php } ?> 402 403 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"> </div> 404 </div> 405 <?php 406 else: 407 echo '<p>' . __('Choose one of these cool headers, or upload your own image below.') . '</p>'; 408 echo '<form method="post" action="' . admin_url('themes.php?page=custom-header&updated=true') . '">'; 409 wp_nonce_field('custom-header'); 410 $this->show_default_header_selector(); 411 echo '<input type="submit" class="button" value="' . esc_attr__('Save Changes') . '" />'; 412 echo '</form>'; 413 echo '</div>'; 414 endif; 415 ?> 416 <div class="wrap"> 417 <h3><?php _e('Upload New Header Image'); ?></h3><p><?php _e('Here you can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.'); ?> <?php printf(__('Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.'), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT); ?></p> 418 419 <form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo esc_attr(add_query_arg('step', 2)) ?>"> 420 <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /><input type="file" id="upload" name="import" /> 421 <input type="hidden" name="action" value="save" /> 422 <?php wp_nonce_field('custom-header') ?> 423 <p class="submit"> 424 <input type="submit" value="<?php esc_attr_e('Upload'); ?>" /> 425 </p> 426 </form> 427 428 </div> 429 430 <?php if ( get_theme_mod('header_image') || get_theme_mod('header_textcolor') ) : ?> 431 <div class="wrap"> 432 <h3><?php _e('Reset Header Image and Color'); ?></h3> 433 <form method="post" action="<?php echo esc_attr(add_query_arg('step', 1)) ?>"> 434 <?php 435 wp_nonce_field('custom-header'); 436 if ( !empty($this->default_headers) ) { 437 ?> 438 <p><?php _e('Use one of these cool headers.') ?></p> 439 <?php 440 $this->show_default_header_selector(); 441 ?> 442 <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e('Save Changes'); ?>" /> 443 <?php 444 } else { 445 ?> 446 <p><?php _e('This will restore the original header image and color. You will not be able to retrieve any customizations.') ?></p> 447 <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e('Restore Original Header'); ?>" /> 448 <?php } ?> 410 <h3><?php _e( 'Header Image' ) ?></h3> 411 <table class="form-table"> 412 <tbody> 413 414 415 <tr valign="top"> 416 <th scope="row"><?php _e( 'Preview' ); ?></th> 417 <td > 418 <?php if ( $this->admin_image_div_callback ) { 419 call_user_func( $this->admin_image_div_callback ); 420 } else { 421 ?> 422 <div id="headimg" style="max-width:<?php echo HEADER_IMAGE_WIDTH; ?>px;height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;background-image:url(<?php esc_url ( header_image() ) ?>);"> 423 <?php 424 if ( 'blank' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || '' == get_theme_mod('header_textcolor', HEADER_TEXTCOLOR) || ! $this->header_text() ) 425 $style = ' style="display:none;"'; 426 else 427 $style = ' style="color:#' . get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) . ';"'; 428 ?> 429 <h1><a id="name"<?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>"><?php bloginfo( 'name' ); ?></a></h1> 430 <div id="desc"<?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> 431 </div> 432 <?php } ?> 433 </td> 434 </tr> 435 436 <tr valign="top"> 437 <th scope="row"><?php _e( 'Upload Image' ); ?></th> 438 <td> 439 <p><?php _e( 'You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.' ); ?><br /> 440 <?php printf( __( 'Images of exactly <strong>%1$d x %2$d pixels</strong> will be used as-is.' ), HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); ?></p> 441 <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>"> 442 <p> 443 <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> 444 <input type="file" id="upload" name="import" /> 445 <input type="hidden" name="action" value="save" /> 446 <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ) ?> 447 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload' ); ?>" /> 448 </p> 449 </form> 450 </td> 451 </tr> 452 </tbody> 453 </table> 454 455 <form method="post" action="<?php echo esc_attr( add_query_arg( 'step', 1 ) ) ?>"> 456 <table class="form-table"> 457 <tbody> 458 <?php if ( ! empty( $this->default_headers ) ) : ?> 459 <tr valign="top"> 460 <th scope="row"><?php _e( 'Default Images' ); ?></th> 461 <td> 462 <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers.' ) ?></p> 463 <?php 464 $this->show_default_header_selector(); 465 ?> 466 </td> 467 </tr> 468 <?php endif; 469 470 if ( get_header_image() ) : ?> 471 <tr valign="top"> 472 <th scope="row"><?php _e( 'Remove Image' ); ?></th> 473 <td> 474 <p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p> 475 <input type="submit" class="button" name="removeheader" value="<?php esc_attr_e( 'Remove Header Image' ); ?>" /> 476 </td> 477 </tr> 478 <?php endif; 479 480 if ( defined( 'HEADER_IMAGE' ) ) : ?> 481 <tr valign="top"> 482 <th scope="row"><?php _e( 'Reset Image' ); ?></th> 483 <td> 484 <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p> 485 <input type="submit" class="button" name="resetheader" value="<?php esc_attr_e( 'Restore Original Header Image' ); ?>" /> 486 </td> 487 </tr> 488 <?php endif; ?> 489 </tbody> 490 </table> 491 492 <?php if ( $this->header_text() ) : ?> 493 <h3><?php _e( 'Header Text' ) ?></h3> 494 <table class="form-table"> 495 <tbody> 496 <tr valign="top" class="hide-if-no-js"> 497 <th scope="row"><?php _e( 'Display Text' ); ?></th> 498 <td> 499 <p> 500 <?php $hidetext = get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ); ?> 501 <label><input type="radio" value="1" name="hidetext" id="hidetext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? true : false ); ?> /> <?php _e( 'No' ); ?></label> 502 <label><input type="radio" value="0" name="hidetext" id="showtext"<?php checked( ( 'blank' == $hidetext || empty( $hidetext ) ) ? false : true ); ?> /> <?php _e( 'Yes' ); ?></label> 503 </p> 504 </td> 505 </tr> 506 507 <tr valign="top" id="text-color-row"> 508 <th scope="row"><?php _e( 'Text Color' ); ?></th> 509 <td> 510 <p> 511 <input type="text" name="text-color" id="text-color" value="#<?php echo esc_attr( get_theme_mod( 'header_textcolor', HEADER_TEXTCOLOR ) ); ?>" /> 512 <span class="description hide-if-js"><?php _e( 'If you want to hide header text, add <strong>#blank</strong> as text color.' );?></span> 513 <input type="button" class="button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color' ); ?>" id="pickcolor" /> 514 </p> 515 <div id="color-picker" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 516 </td> 517 </tr> 518 519 <?php if ( defined('HEADER_TEXTCOLOR') && get_theme_mod('header_textcolor') ) { ?> 520 <tr valign="top"> 521 <th scope="row"><?php _e('Reset Text Color'); ?></th> 522 <td> 523 <p><?php _e( 'This will restore the original header text. You will not be able to restore any customizations.' ) ?></p> 524 <input type="submit" class="button" name="resettext" value="<?php esc_attr_e( 'Restore Original Header Text' ); ?>" /> 525 </td> 526 </tr> 527 <?php } ?> 528 529 </tbody> 530 </table> 531 <?php endif; 532 533 wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?> 534 <p class="submit"><input type="submit" class="button-primary" name="save-header-options" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p> 449 535 </form> 450 536 </div> 451 <?php endif; 452 453 } 537 538 <?php } 454 539 455 540 /** … … 459 544 */ 460 545 function step_2() { 461 check_admin_referer('custom-header ');546 check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload'); 462 547 $overrides = array('test_form' => false); 463 548 $file = wp_handle_upload($_FILES['import'], $overrides); 464 549 465 550 if ( isset($file['error']) ) 466 die( $file['error']);551 wp_die( $file['error'], __( 'Image Upload Error' ) ); 467 552 468 553 $url = $file['url']; … … 507 592 508 593 <div class="wrap"> 509 510 < form method="post" action="<?php echo esc_attr(add_query_arg('step', 3)) ?>">511 512 < p><?php _e('Choose the part of the image you want to use as your header.'); ?></p>513 <div id="testWrap" style="position: relative">514 <img src="<?php echo $url; ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />515 </div> 516 517 <p class="submit">518 <input type="hidden" name="x1" id="x1" />519 <input type="hidden" name="y1" id="y1" /> 520 <input type="hidden" name="x2" id="x2" />521 <input type="hidden" name="y2" id="y2"/>522 <input type="hidden" name="width" id="width"/>523 <input type="hidden" name="height" id="height"/>524 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($id); ?>"/>525 <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr($oitar); ?>" />526 <?php wp_nonce_field('custom-header') ?>527 <input type="submit" value="<?php esc_attr_e('Crop Header'); ?>" />528 </p>529 594 <?php screen_icon(); ?> 595 <h2><?php _e( 'Crop Header Image' ); ?></h2> 596 597 <form method="post" action="<?php echo esc_attr(add_query_arg('step', 3)); ?>"> 598 <p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p> 599 <p class="hide-if-js"><strong><?php _e( 'You need Javascript to choose a part of the image.'); ?></strong></p> 600 601 <div id="crop_image" style="position: relative"> 602 <img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" /> 603 </div> 604 605 <p class="submit"> 606 <input type="hidden" name="x1" id="x1" value="0"/> 607 <input type="hidden" name="y1" id="y1" value="0"/> 608 <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>"/> 609 <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>"/> 610 <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $id ); ?>" /> 611 <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> 612 <?php wp_nonce_field( 'custom-header-crop-image' ) ?> 613 <input type="submit" value="<?php esc_attr_e( 'Crop Header' ); ?>" /> 614 </p> 530 615 </form> 531 616 </div> … … 539 624 */ 540 625 function step_3() { 541 check_admin_referer('custom-header ');626 check_admin_referer('custom-header-crop-image'); 542 627 if ( $_POST['oitar'] > 1 ) { 543 628 $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; … … 588 673 */ 589 674 function finished() { 590 $ _GET['updated'] = 1;591 675 $this->updated = true; 676 $this->step_1(); 592 677 } 593 678
Note: See TracChangeset
for help on using the changeset viewer.