Changeset 22502
- Timestamp:
- 11/09/2012 11:37:24 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-background.php
r22470 r22502 107 107 108 108 add_thickbox(); 109 wp_enqueue_ script('media-upload');109 wp_enqueue_media(); 110 110 wp_enqueue_script('custom-background'); 111 111 wp_enqueue_style('wp-color-picker'); … … 270 270 <p> 271 271 <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> 272 <a id="choose-from-library-link" class="button thickbox" href="<?php echo esc_url( $image_library_url ); ?>"><?php _e( 'Choose Image' ); ?></a> 272 <a id="choose-from-library-link" class="button" 273 data-choose="<?php esc_attr_e( 'Choose a Background Image' ); ?>" 274 data-update="<?php esc_attr_e( 'Set as background' ); ?>"><?php _e( 'Choose Image' ); ?></a> 273 275 </p> 274 276 </form> -
trunk/wp-admin/js/custom-background.js
r22030 r22502 1 1 (function($) { 2 3 2 $(document).ready(function() { 4 var bgImage = $("#custom-background-image"); 3 var bgImage = $("#custom-background-image"), 4 frame; 5 5 6 6 $('#background-color').wpColorPicker({ … … 20 20 bgImage.css('background-repeat', $(this).val()); 21 21 }); 22 23 $('#choose-from-library-link').click( function( event ) { 24 var $el = $(this); 25 26 event.preventDefault(); 27 28 if ( frame ) { 29 frame.open(); 30 return; 31 } 32 33 frame = wp.media({ 34 title: $el.data('choose'), 35 library: { 36 type: 'image' 37 } 38 }); 39 40 frame.toolbar.on( 'activate:select', function() { 41 frame.toolbar.view().add({ 42 select: { 43 style: 'primary', 44 text: $el.data('update'), 45 46 click: function() { 47 var attachment = frame.state().get('selection').first(); 48 $.post( ajaxurl, { 49 action: 'set-background-image', 50 attachment_id: attachment.id, 51 size: 'full' 52 }, function() { 53 window.location.reload(); 54 }); 55 } 56 } 57 }); 58 }); 59 60 frame.state('library'); 61 }); 22 62 }); 23 24 63 })(jQuery); -
trunk/wp-includes/script-loader.php
r22494 r22502 502 502 503 503 $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); 504 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker' ), false, 1 );504 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); 505 505 $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); 506 506 }
Note: See TracChangeset
for help on using the changeset viewer.