git-svn-id: http://core.svn.wordpress.org/trunk@22502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3797b7e18c
commit
15a749c6fd
|
@ -106,7 +106,7 @@ class Custom_Background {
|
|||
);
|
||||
|
||||
add_thickbox();
|
||||
wp_enqueue_script('media-upload');
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('custom-background');
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
}
|
||||
|
@ -269,7 +269,9 @@ if ( get_background_image() ) {
|
|||
?>
|
||||
<p>
|
||||
<label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br />
|
||||
<a id="choose-from-library-link" class="button thickbox" href="<?php echo esc_url( $image_library_url ); ?>"><?php _e( 'Choose Image' ); ?></a>
|
||||
<a id="choose-from-library-link" class="button"
|
||||
data-choose="<?php esc_attr_e( 'Choose a Background Image' ); ?>"
|
||||
data-update="<?php esc_attr_e( 'Set as background' ); ?>"><?php _e( 'Choose Image' ); ?></a>
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(function($) {
|
||||
|
||||
$(document).ready(function() {
|
||||
var bgImage = $("#custom-background-image");
|
||||
var bgImage = $("#custom-background-image"),
|
||||
frame;
|
||||
|
||||
$('#background-color').wpColorPicker({
|
||||
change: function( event, ui ) {
|
||||
|
@ -19,6 +19,45 @@
|
|||
$('input[name="background-repeat"]').change(function() {
|
||||
bgImage.css('background-repeat', $(this).val());
|
||||
});
|
||||
});
|
||||
|
||||
$('#choose-from-library-link').click( function( event ) {
|
||||
var $el = $(this);
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
frame = wp.media({
|
||||
title: $el.data('choose'),
|
||||
library: {
|
||||
type: 'image'
|
||||
}
|
||||
});
|
||||
|
||||
frame.toolbar.on( 'activate:select', function() {
|
||||
frame.toolbar.view().add({
|
||||
select: {
|
||||
style: 'primary',
|
||||
text: $el.data('update'),
|
||||
|
||||
click: function() {
|
||||
var attachment = frame.state().get('selection').first();
|
||||
$.post( ajaxurl, {
|
||||
action: 'set-background-image',
|
||||
attachment_id: attachment.id,
|
||||
size: 'full'
|
||||
}, function() {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
frame.state('library');
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
|
@ -501,7 +501,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
) );
|
||||
|
||||
$scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 );
|
||||
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker' ), false, 1 );
|
||||
$scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 );
|
||||
$scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue