| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /** 2 * @output wp-admin/js/custom-header.js 3 */ 4 5 /* global isRtl */ 6 7 /** 8 * Initializes the custom header selection page. 9 * 10 * @since 3.5.0 11 * 12 * @deprecated 4.1.0 The page this is used on is never linked to from the UI. 13 * Setting a custom header is completely handled by the Customizer. 14 * 15 * @param {JQueryStatic} $ The jQuery object. 16 */ 17 (function($) { 18 var frame; 19 20 $( function() { 21 // Fetch available headers. 22 var $headers = $('.available-headers'); 23 24 // Apply jQuery.masonry once the images have loaded. 25 $headers.imagesLoaded( function() { 26 $headers.masonry({ 27 itemSelector: '.default-header', 28 isRTL: !! ( 'undefined' != typeof isRtl && isRtl ) 29 }); 30 }); 31 32 /** 33 * Opens the 'choose from library' frame and creates it if it doesn't exist. 34 * 35 * @since 3.5.0 36 * @deprecated 4.1.0 37 * 38 * @return {void} 39 */ 40 $('#choose-from-library-link').on( 'click', function( event ) { 41 var $el = $(this); 42 event.preventDefault(); 43 44 // If the media frame already exists, reopen it. 45 if ( frame ) { 46 frame.open(); 47 return; 48 } 49 50 // Create the media frame. 51 frame = wp.media.frames.customHeader = wp.media({ 52 // Set the title of the modal. 53 title: $el.data('choose'), 54 55 // Tell the modal to show only images. 56 library: { 57 type: 'image' 58 }, 59 60 // Customize the submit button. 61 button: { 62 // Set the text of the button. 63 text: $el.data('update'), 64 // Tell the button not to close the modal, since we're 65 // going to refresh the page when the image is selected. 66 close: false 67 } 68 }); 69 70 /** 71 * Updates the window location to include the selected attachment. 72 * 73 * @since 3.5.0 74 * @deprecated 4.1.0 75 * 76 * @return {void} 77 */ 78 frame.on( 'select', function() { 79 // Grab the selected attachment. 80 var attachment = frame.state().get('selection').first(), 81 link = $el.data('updateLink'); 82 83 // Tell the browser to navigate to the crop step. 84 window.location = link + '&file=' + attachment.id; 85 }); 86 87 frame.open(); 88 }); 89 }); 90 }(jQuery));
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Wed Sep 9 08:20:27 2026 | Cross-referenced by PHPXref |