diff --git src/wp-admin/js/dashboard.js src/wp-admin/js/dashboard.js
index a6b56c37ef..c180623fea 100644
|
|
|
2 | 2 | var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; |
3 | 3 | window.wp = window.wp || {}; |
4 | 4 | |
| 5 | /** |
| 6 | * Dashboard widget functionality. |
| 7 | * |
| 8 | * @since 2.7.0 |
| 9 | */ |
5 | 10 | jQuery(document).ready( function($) { |
6 | 11 | var welcomePanel = $( '#welcome-panel' ), |
7 | 12 | welcomePanelHide = $('#wp_welcome_panel-hide'), |
8 | 13 | updateWelcomePanel; |
9 | 14 | |
| 15 | /** |
| 16 | * Save the visibility of the welcome panel. |
| 17 | * |
| 18 | * @since 3.3.0 |
| 19 | * |
| 20 | * @param {boolean} visible Should it be visible or not. |
| 21 | * |
| 22 | * @returns {void} |
| 23 | */ |
10 | 24 | updateWelcomePanel = function( visible ) { |
11 | 25 | $.post( ajaxurl, { |
12 | 26 | action: 'update-welcome-panel', |
… |
… |
jQuery(document).ready( function($) { |
15 | 29 | }); |
16 | 30 | }; |
17 | 31 | |
| 32 | // Unhide the welcome panel if the Welcome Option checkbox is checked. |
18 | 33 | if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) { |
19 | 34 | welcomePanel.removeClass('hidden'); |
20 | 35 | } |
21 | 36 | |
| 37 | // Hide the welcome panel when the dismiss button or close button is clicked. |
22 | 38 | $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) { |
23 | 39 | e.preventDefault(); |
24 | 40 | welcomePanel.addClass('hidden'); |
… |
… |
jQuery(document).ready( function($) { |
26 | 42 | $('#wp_welcome_panel-hide').prop('checked', false); |
27 | 43 | }); |
28 | 44 | |
| 45 | // Set welcome panel visibility based on Welcome Option checkbox value. |
29 | 46 | welcomePanelHide.click( function() { |
30 | 47 | welcomePanel.toggleClass('hidden', ! this.checked ); |
31 | 48 | updateWelcomePanel( this.checked ? 1 : 0 ); |
32 | 49 | }); |
33 | 50 | |
34 | | // These widgets are sometimes populated via ajax |
| 51 | // These widgets can be populated via ajax. |
35 | 52 | ajaxWidgets = ['dashboard_primary']; |
36 | 53 | |
| 54 | /** |
| 55 | * Trigger widget updates via AJAX. |
| 56 | * |
| 57 | * @since 2.7.0 |
| 58 | * |
| 59 | * @param {string} el Optional. Widget to fetch or none to update all. |
| 60 | * |
| 61 | * @returns {void} |
| 62 | */ |
37 | 63 | ajaxPopulateWidgets = function(el) { |
| 64 | /** |
| 65 | * Fetch the latest representation of the widget via Ajax and show it. |
| 66 | * |
| 67 | * @param {int} i Number of half-seconds to use as the timeout. |
| 68 | * @param {string} id ID of the element which is going to be checked for changes. |
| 69 | * |
| 70 | * @returns {void} |
| 71 | */ |
38 | 72 | function show(i, id) { |
39 | 73 | var p, e = $('#' + id + ' div.inside:visible').find('.widget-loading'); |
| 74 | // If the element is found in the dom, queue to load latest representation. |
40 | 75 | if ( e.length ) { |
41 | 76 | p = e.parent(); |
42 | 77 | setTimeout( function(){ |
| 78 | // Request the widget content. |
43 | 79 | p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() { |
| 80 | // Hide the parent and slide it out for visual fancyness. |
44 | 81 | p.hide().slideDown('normal', function(){ |
45 | 82 | $(this).css('display', ''); |
46 | 83 | }); |
… |
… |
jQuery(document).ready( function($) { |
49 | 86 | } |
50 | 87 | } |
51 | 88 | |
| 89 | // If we have received a specific element to fetch, check if it is valid. |
52 | 90 | if ( el ) { |
53 | 91 | el = el.toString(); |
| 92 | // If the element is available as AJAX widget, show it. |
54 | 93 | if ( $.inArray(el, ajaxWidgets) !== -1 ) { |
| 94 | // Show element without any delay. |
55 | 95 | show(0, el); |
56 | 96 | } |
57 | 97 | } else { |
| 98 | // Walk through all ajaxWidgets, loading them after each other. |
58 | 99 | $.each( ajaxWidgets, show ); |
59 | 100 | } |
60 | 101 | }; |
| 102 | |
| 103 | // Initially populate ajax widgets. |
61 | 104 | ajaxPopulateWidgets(); |
62 | 105 | |
| 106 | // Register ajax widgets as postbox toggles. |
63 | 107 | postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } ); |
64 | 108 | |
65 | | /* QuickPress */ |
| 109 | /** |
| 110 | * Control the Quick Press (Quick Draft) widget. |
| 111 | * |
| 112 | * @since 2.7.0 |
| 113 | * |
| 114 | * @returns {void} |
| 115 | */ |
66 | 116 | quickPressLoad = function() { |
67 | 117 | var act = $('#quickpost-action'), t; |
68 | 118 | |
| 119 | // Enable the submit buttons. |
69 | 120 | $( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false ); |
70 | 121 | |
71 | 122 | t = $('#quick-press').submit( function( e ) { |
72 | 123 | e.preventDefault(); |
| 124 | |
| 125 | // Show a spinner. |
73 | 126 | $('#dashboard_quick_press #publishing-action .spinner').show(); |
| 127 | |
| 128 | // Disable the submit button to prevent duplicate submissions. |
74 | 129 | $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true); |
75 | 130 | |
| 131 | // Post the entered data to save it. |
76 | 132 | $.post( t.attr( 'action' ), t.serializeArray(), function( data ) { |
77 | 133 | // Replace the form, and prepend the published post. |
78 | 134 | $('#dashboard_quick_press .inside').html( data ); |
79 | 135 | $('#quick-press').removeClass('initial-form'); |
80 | 136 | quickPressLoad(); |
81 | 137 | highlightLatestPost(); |
| 138 | |
| 139 | // Focus the title to allow for quickly drafting another post. |
82 | 140 | $('#title').focus(); |
83 | 141 | }); |
84 | 142 | |
| 143 | /** |
| 144 | * @summary Highlights the latest post for one second. |
| 145 | * |
| 146 | * @returns {void} |
| 147 | */ |
85 | 148 | function highlightLatestPost () { |
86 | 149 | var latestPost = $('.drafts ul li').first(); |
87 | 150 | latestPost.css('background', '#fffbe5'); |
… |
… |
jQuery(document).ready( function($) { |
91 | 154 | } |
92 | 155 | } ); |
93 | 156 | |
| 157 | // Change the QuickPost action to the publish value. |
94 | 158 | $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } ); |
95 | 159 | |
| 160 | /** |
| 161 | * Use the 'screen-reader-text' class to hide the label when entering a value. |
| 162 | * Apply it when the input is not empty or the input has focus. |
| 163 | * |
| 164 | * @summary Adds accessibility context to inputs. |
| 165 | * |
| 166 | * @returns {void} |
| 167 | */ |
96 | 168 | $('#title, #tags-input, #content').each( function() { |
97 | 169 | var input = $(this), prompt = $('#' + this.id + '-prompt-text'); |
98 | 170 | |
… |
… |
jQuery(document).ready( function($) { |
124 | 196 | }; |
125 | 197 | quickPressLoad(); |
126 | 198 | |
| 199 | // Enable the dragging functionality of the widgets. |
127 | 200 | $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' ); |
128 | 201 | |
| 202 | /** |
| 203 | * Adjust the height of the textarea based on the content. |
| 204 | * |
| 205 | * @since 3.6.0 |
| 206 | * |
| 207 | * @returns {void} |
| 208 | */ |
129 | 209 | function autoResizeTextarea() { |
| 210 | // When IE8 or older is used to render this document, exit. |
130 | 211 | if ( document.documentMode && document.documentMode < 9 ) { |
131 | 212 | return; |
132 | 213 | } |
… |
… |
jQuery(document).ready( function($) { |
137 | 218 | var clone = $('.quick-draft-textarea-clone'), |
138 | 219 | editor = $('#content'), |
139 | 220 | editorHeight = editor.height(), |
140 | | // 100px roughly accounts for browser chrome and allows the |
141 | | // save draft button to show on-screen at the same time. |
| 221 | /* |
| 222 | * 100px roughly accounts for browser chrome and allows the |
| 223 | * save draft button to show on-screen at the same time. |
| 224 | */ |
142 | 225 | editorMaxHeight = $(window).height() - 100; |
143 | 226 | |
144 | | // Match up textarea and clone div as much as possible. |
145 | | // Padding cannot be reliably retrieved using shorthand in all browsers. |
| 227 | /* |
| 228 | * Match up textarea and clone div as much as possible. |
| 229 | * Padding cannot be reliably retrieved using shorthand in all browsers. |
| 230 | */ |
146 | 231 | clone.css({ |
147 | 232 | 'font-family': editor.css('font-family'), |
148 | 233 | 'font-size': editor.css('font-size'), |
… |
… |
jQuery(document).ready( function($) { |
156 | 241 | 'display': 'none' |
157 | 242 | }); |
158 | 243 | |
159 | | // propertychange is for IE < 9 |
| 244 | // The 'propertychange' is used in IE < 9. |
160 | 245 | editor.on('focus input propertychange', function() { |
161 | 246 | var $this = $(this), |
162 | | // is to ensure that the height of a final trailing newline is included. |
| 247 | // Add a non-breaking space to ensure that the height of a trailing newline is included. |
163 | 248 | textareaContent = $this.val() + ' ', |
164 | | // 2px is for border-top & border-bottom |
| 249 | // Add 2px to compensate for border-top & border-bottom. |
165 | 250 | cloneHeight = clone.css('width', $this.css('width')).text(textareaContent).outerHeight() + 2; |
166 | 251 | |
167 | | // Default to having scrollbars |
| 252 | // Default to show a vertical scrollbar, if needed. |
168 | 253 | editor.css('overflow-y', 'auto'); |
169 | 254 | |
170 | | // Only change the height if it has indeed changed and both heights are below the max. |
| 255 | // Only change the height if it has changed and both heights are below the max. |
171 | 256 | if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) { |
172 | 257 | return; |
173 | 258 | } |
174 | 259 | |
175 | | // Don't allow editor to exceed height of window. |
176 | | // This is also bound in CSS to a max-height of 1300px to be extra safe. |
| 260 | /* |
| 261 | * Don't allow editor to exceed the height of the window. |
| 262 | * This is also bound in CSS to a max-height of 1300px to be extra safe. |
| 263 | */ |
177 | 264 | if ( cloneHeight > editorMaxHeight ) { |
178 | 265 | editorHeight = editorMaxHeight; |
179 | 266 | } else { |
180 | 267 | editorHeight = cloneHeight; |
181 | 268 | } |
182 | 269 | |
183 | | // No scrollbars as we change height, not for IE < 9 |
| 270 | // Disable scrollbars because we adjust the height to the content. |
184 | 271 | editor.css('overflow', 'hidden'); |
185 | 272 | |
186 | 273 | $this.css('height', editorHeight + 'px'); |
… |
… |
jQuery( function( $ ) { |
195 | 282 | var communityEventsData = window.communityEventsData || {}, |
196 | 283 | app; |
197 | 284 | |
| 285 | /** |
| 286 | * Global Community Events class. |
| 287 | * |
| 288 | * @since 4.8.0 |
| 289 | * |
| 290 | * @global |
| 291 | * @class |
| 292 | */ |
198 | 293 | app = window.wp.communityEvents = { |
199 | 294 | initialized: false, |
200 | 295 | model: null, |
… |
… |
jQuery( function( $ ) { |
203 | 298 | * Initializes the wp.communityEvents object. |
204 | 299 | * |
205 | 300 | * @since 4.8.0 |
| 301 | * |
| 302 | * @returns {void} |
206 | 303 | */ |
207 | 304 | init: function() { |
208 | 305 | if ( app.initialized ) { |
… |
… |
jQuery( function( $ ) { |
233 | 330 | |
234 | 331 | $container.on( 'click', '.community-events-toggle-location, .community-events-cancel', app.toggleLocationForm ); |
235 | 332 | |
| 333 | /** |
| 334 | * Filter events based on entered location. |
| 335 | * |
| 336 | * @returns {void} |
| 337 | */ |
236 | 338 | $container.on( 'submit', '.community-events-form', function( event ) { |
237 | 339 | var location = $.trim( $( '#community-events-location' ).val() ); |
238 | 340 | |
… |
… |
jQuery( function( $ ) { |
267 | 369 | * |
268 | 370 | * @param {event|string} action 'show' or 'hide' to specify a state; |
269 | 371 | * or an event object to flip between states. |
| 372 | * |
| 373 | * @returns {void} |
270 | 374 | */ |
271 | 375 | toggleLocationForm: function( action ) { |
272 | 376 | var $toggleButton = $( '.community-events-toggle-location' ), |
… |
… |
jQuery( function( $ ) { |
309 | 413 | * |
310 | 414 | * @since 4.8.0 |
311 | 415 | * |
312 | | * @param {object} requestParams |
| 416 | * @param {object} requestParams REST API Request parameters object. |
| 417 | * |
| 418 | * @returns {void} |
313 | 419 | */ |
314 | 420 | getEvents: function( requestParams ) { |
315 | 421 | var initiatedBy, |
… |
… |
jQuery( function( $ ) { |
362 | 468 | * @param {Object} templateParams The various parameters that will get passed to wp.template. |
363 | 469 | * @param {string} initiatedBy 'user' to indicate that this was triggered manually by the user; |
364 | 470 | * 'app' to indicate it was triggered automatically by the app itself. |
| 471 | * |
| 472 | * @returns {void} |
365 | 473 | */ |
366 | 474 | renderEventsTemplate: function( templateParams, initiatedBy ) { |
367 | 475 | var template, |
diff --git src/wp-includes/class-wp-comment-query.php src/wp-includes/class-wp-comment-query.php
index 34255953f5..cdbe0d7792 100644
|
|
class WP_Comment_Query { |
471 | 471 | * @since 4.4.0 |
472 | 472 | * |
473 | 473 | * @global wpdb $wpdb WordPress database abstraction object. |
474 | | * |
475 | | * @return int|array A single count of comment IDs if a count query. An array of comment IDs if a full query. |
476 | 474 | */ |
477 | 475 | protected function get_comment_ids() { |
478 | 476 | global $wpdb; |
diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index b50772b99c..17e3fed1cb 100644
|
|
if ( ! function_exists( 'wp_rand' ) ) : |
2358 | 2358 | * |
2359 | 2359 | * @global string $rnd_value |
2360 | 2360 | * @staticvar string $seed |
2361 | | * @staticvar bool $use_random_int_functionality |
| 2361 | * @staticvar bool $external_rand_source_available |
2362 | 2362 | * |
2363 | 2363 | * @param int $min Lower limit for the generated number |
2364 | 2364 | * @param int $max Upper limit for the generated number |