Provides a consistent way to query `$wpdb->blogs` for `WP_Site` objects based on domain, path, site ID, network ID, and more.
Introduces and uses `update_site_cache()` and `_prime_site_caches()` to maintain a cached list of `WP_Site` objects for use in multiple queries.
Props spacedmonkey, flixos90, DrewAPicture, jeremyfelt, ocean90.
See #35791.
git-svn-id: https://develop.svn.wordpress.org/trunk@37477 602fd350-edb4-49c9-b593-d223f7449a82
When a setting is invalid, not only will it be blocked from being saved but all other settings will be blocked as well. This ensures that Customizer saves aren't partial but are more transactional. User will be displayed the error in a notification so that they can fix and re-attempt saving.
PHP changes:
* Introduces `WP_Customize_Setting::validate()`, `WP_Customize_Setting::$validate_callback`, and the `customize_validate_{$setting_id}` filter.
* Introduces `WP_Customize_Manager::validate_setting_values()` to do validation (and sanitization) for the setting values supplied, returning a list of `WP_Error` instances for invalid settings.
* Attempting to save settings that are invalid will result in the save being blocked entirely, with the errors being sent in the `customize_save_response`. Modifies `WP_Customize_Manager::save()` to check all settings for validity issues prior to calling their `save` methods.
* Introduces `WP_Customize_Setting::json()` for parity with the other Customizer classes. This includes exporting of the `type`.
* Modifies `WP_Customize_Manager::post_value()` to apply `validate` after `sanitize`, and if validation fails, to return the `$default`.
* Introduces `customize_save_validation_before` action which fires right before the validation checks are made prior to saving.
JS changes:
* Introduces `wp.customize.Notification` in JS which to represent `WP_Error` instances returned from the server when setting validation fails.
* Introduces `wp.customize.Setting.prototype.notifications`.
* Introduces `wp.customize.Control.prototype.notifications`, which are synced with a control's settings' notifications.
* Introduces `wp.customize.Control.prototype.renderNotifications()` to re-render a control's notifications in its notification area. This is called automatically when the notifications collection changes.
* Introduces `wp.customize.settingConstructor`, allowing custom setting types to be used in the same way that custom controls, panels, and sections can be made.
* Injects a notification area into existing controls which is populated in response to the control's `notifications` collection changing. A custom control can customize the placement of the notification area by overriding the new `getNotificationsContainerElement` method.
* When a save fails due to setting invalidity, the invalidity errors will be added to the settings to then populate in the controls' notification areas, and the first such invalid control will be focused.
Props westonruter, celloexpressions, mrahmadawais.
See #35210.
See #30937.
Fixes#34893.
git-svn-id: https://develop.svn.wordpress.org/trunk@37476 602fd350-edb4-49c9-b593-d223f7449a82
Introduce `ms_load_current_site_and_network`. This is used by core during the multisite bootstrap process to populate the `$current_site` and `$current_blog` globals based on a requested domain and path.
Return values from this function inform `ms-settings.php` as to whether a page view should continue, `ms_not_installed()` should fire, or a redirect to a new location should occur.
This was previously a procedural block in `ms-settings.php`. Wrapping this code and providing specific return values allows us to write tests that do not rely on the manual and repeated inclusion of `ms-settings.php`.
This should not be used by plugins or themes. Please.
See #34941.
git-svn-id: https://develop.svn.wordpress.org/trunk@37475 602fd350-edb4-49c9-b593-d223f7449a82
This prevents errors when an email address contains an apostrophe. See [29966]
for similar treatment of a related problem.
Props dcavins.
Fixes#36322.
git-svn-id: https://develop.svn.wordpress.org/trunk@37474 602fd350-edb4-49c9-b593-d223f7449a82
Use SVG images in supporting browsers, otherwise fall back to PNG images. Add the filters `emoji_svg_url` and `emoji_svg_ext`.
Introduces unit tests to check the Emoji CDN filters.
Fixes#36525
git-svn-id: https://develop.svn.wordpress.org/trunk@37471 602fd350-edb4-49c9-b593-d223f7449a82
When the options table is set to `utf8` instead of `utf8mb4`, emoji will be stripped from the blog name and description when they're saved. Instead of stripping them, they can be encode as HTML entities.
Fixes#36122.
git-svn-id: https://develop.svn.wordpress.org/trunk@37469 602fd350-edb4-49c9-b593-d223f7449a82
Given a site ID or site object, `get_site()` retrieves site data in the same vein as `get_post()` or `get_comment()`. This will allow for clean retrieval of sites from a primed cache when `WP_Site_Query` is implemented.
Adds a `WP_Site::to_array()` method to support multiple return types within `get_site()`.
Props spacedmonkey.
See #35791.
git-svn-id: https://develop.svn.wordpress.org/trunk@37468 602fd350-edb4-49c9-b593-d223f7449a82
Introduce the `network_edit_site_nav` function, which DRYs up the code used to display a common set of links at the top of "Edit Site" views.
Introduce the `network_edit_site_nav_links` filter, which allows plugins to modify the list of links displayed at the top of Edit Site views as a "tabbed" interface.
Props johnjamesjacoby, c3mdigital, Bueltge.
Fixes#15800.
git-svn-id: https://develop.svn.wordpress.org/trunk@37466 602fd350-edb4-49c9-b593-d223f7449a82
This allows the HTML5 `required` attribute to be added to the `select` element.
Props wzislam, pcarvalho.
Fixes#31909.
git-svn-id: https://develop.svn.wordpress.org/trunk@37465 602fd350-edb4-49c9-b593-d223f7449a82
Clicking on the Edit Menu button focuses on the corresponding nav menu section. Upon collapsing the nav menu section, the focus is returned to the Custom Menu widget instead of taking the user to the menus root panel. In this way, the back button behavior is modified once to serve as breadcrumb/history navigation. The Edit Menu button with the breadcrumb back button behavior greatly reduce the number of UI interactions needed to edit a menu referenced in a Custom Menu widget.
Props celloexpressions, westonruter.
Fixes#32683.
git-svn-id: https://develop.svn.wordpress.org/trunk@37437 602fd350-edb4-49c9-b593-d223f7449a82
This was mistakingly passing the Requests_Response object, which caused fatal errors with debugging tools.
See #33055.
git-svn-id: https://develop.svn.wordpress.org/trunk@37436 602fd350-edb4-49c9-b593-d223f7449a82
The `medium_large_size_w` and `medium_large_size_h` options were added to the
$whitelist_options['media'] in options.php in [35479], which causes both options
to be set to `0` when the media settings are changed. When this occurs, the
medium_large image size will no longer be created when an image is uploaded.
Since these options aren't meant to be updated via the settings UI, they can be
safely removed from the whitelist.
Fixes#36531.
git-svn-id: https://develop.svn.wordpress.org/trunk@37435 602fd350-edb4-49c9-b593-d223f7449a82
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.
Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.
Props ocean90.
Fixes#36835.
git-svn-id: https://develop.svn.wordpress.org/trunk@37431 602fd350-edb4-49c9-b593-d223f7449a82
Ensure connections are closed after usage to fix an issue with WP.com URLs used in the tests.
Resynched from GitHub at 95518ce.
See #33055.
git-svn-id: https://develop.svn.wordpress.org/trunk@37430 602fd350-edb4-49c9-b593-d223f7449a82
WordPress erroneously follows browser-style behaviour with 3xx redirects, where a POST to 302 becomes a GET. Requests instead follows the specification and keeps the same method. Requests also exposes a hook to allow changing the behaviour.
[37428] used the wrong method of adding this hook, now corrected.
See #33055.
git-svn-id: https://develop.svn.wordpress.org/trunk@37429 602fd350-edb4-49c9-b593-d223f7449a82
Requests is a library very similar to WP_HTTP, with a high level of unit test coverage, and has a common lineage and development team. It also supports parallel requests.
See #33055.
git-svn-id: https://develop.svn.wordpress.org/trunk@37428 602fd350-edb4-49c9-b593-d223f7449a82
Removes unnecessary wrapper elements and refactors class names to eliminate duplication of rule selectors.
Props celloexpressions.
Fixes#30618.
git-svn-id: https://develop.svn.wordpress.org/trunk@37426 602fd350-edb4-49c9-b593-d223f7449a82
This removes the `die()` call from `WP_Widget::widget()` and converts it to an abstract method.
`WP_Widgets` (later renamed to `WP_Widget`) was introduced in [10764] where the minimum PHP requirement was 4.3, thus no `abstract` was available.
Props johnbillion.
Fixes#35981.
git-svn-id: https://develop.svn.wordpress.org/trunk@37425 602fd350-edb4-49c9-b593-d223f7449a82
`$which` contains the location of the extra table nav markup: 'top' or 'bottom'.
Props martin.krcho.
Fixes#35307.
git-svn-id: https://develop.svn.wordpress.org/trunk@37422 602fd350-edb4-49c9-b593-d223f7449a82
Prevents a PHP warning by `WP_Filesystem_Direct::mkdir()` when installing a language pack which doesn't have subdirectories.
Props tfrommen.
Fixes#36570.
git-svn-id: https://develop.svn.wordpress.org/trunk@37421 602fd350-edb4-49c9-b593-d223f7449a82
`load_theme_textdomain()`, `load_plugin_textdomain()` and `load_muplugin_textdomain()` now try to load the .mo file from the `wp-content/languages` directory first. After the introduction of language packs, translation files are more likely to be located there.
Props swissspidy, sebastian.pisula.
Fixes#34213.
git-svn-id: https://develop.svn.wordpress.org/trunk@37414 602fd350-edb4-49c9-b593-d223f7449a82
The filter was being applied in `WP_Customize_Nav_Menu_Item_Setting::value()` but not in `WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item()`.
Props celloexpressions, westonruter.
Fixes#35203.
git-svn-id: https://develop.svn.wordpress.org/trunk@37405 602fd350-edb4-49c9-b593-d223f7449a82
Before PHP7 `split()` was throwing a deprecated notice, in PHP7 the function is completely removed and throws a fatal error.
Props achbed.
Fixes#20673.
git-svn-id: https://develop.svn.wordpress.org/trunk@37402 602fd350-edb4-49c9-b593-d223f7449a82
Markdown formatting is not supported in DocBlock summaries, per the inline documentation standards for PHP :-)
See #32246. See #36674.
git-svn-id: https://develop.svn.wordpress.org/trunk@37366 602fd350-edb4-49c9-b593-d223f7449a82
This icon was added to Dashicons in 4.3, but not applied to anything in our CSS.
Uses the more appropriate `dashicons-admin-multisite` when displaying the sites menu item.
Props Ipstenu, ocean90.
Fixes#36754.
git-svn-id: https://develop.svn.wordpress.org/trunk@37365 602fd350-edb4-49c9-b593-d223f7449a82
Rejoice, for your admins will feel more native to your surrounding computing environment and likely load faster, especially when offline, as they no longer have to talk to The Google Overlord.
At the time of introduction in 3.8, there were not good system fonts common to all platforms at the time. In the years since, Windows, Android, OS X, iOS, Firefox OS, and various flavors of Linux have all gotten their own (good) system UI fonts.
There will definitely be visual bugs, mainly around alignment and spacing; these should be documented and reported on the ticket and fixed more atomically so that our current and future selves have a better understanding of what happened and why.
The style remains registered, as it is almost certainly in use by themes and plugins.
props mattmiklic.
see #36753.
git-svn-id: https://develop.svn.wordpress.org/trunk@37361 602fd350-edb4-49c9-b593-d223f7449a82
The rewrite rule matching code in WP::parse_request() used an unclear variable `$request` to represent the requested path (e.g. "2016/05/03") as well as a deceptively named variable `$request_uri`, which actually represents the requested file when an install used PATHINFO links.
Those variables are replaced with `$requested_path` and `$requested_file` respectively for clarity.
Fixes#36674.
git-svn-id: https://develop.svn.wordpress.org/trunk@37356 602fd350-edb4-49c9-b593-d223f7449a82
Fixes warning related to a non-array argument for `array_merge()` in `WP_Customize_Widgets::customize_register()`.
See [37166].
See #36389.
Fixes#36660.
git-svn-id: https://develop.svn.wordpress.org/trunk@37352 602fd350-edb4-49c9-b593-d223f7449a82
Adds parity with setting instance being passed as second argument to `customize_sanitize_{$id}` and `customize_sanitize_js_{$id}`. Allows the actual ID of the (multidimensional) setting value being filtered to be inspected.
Props celloexpressions, westonruter.
Fixes#36452.
git-svn-id: https://develop.svn.wordpress.org/trunk@37350 602fd350-edb4-49c9-b593-d223f7449a82
Also adds a missing return description for `get_comment_author_email_link()`.
Props flixos90 for the initial patch.
Fixes#36571.
git-svn-id: https://develop.svn.wordpress.org/trunk@37349 602fd350-edb4-49c9-b593-d223f7449a82
Pressing Esc collapses any expanded widget or nav menu item controls, or any control that implements the expanding interface. Also improves alignment between `WidgetControl` and `MenuItemControl`, adding the `expanded` state and associated `expand`/`collapse` methods to nav menu items.
Props purcebr, celloexpressions, westonruter.
Fixes#22237.
git-svn-id: https://develop.svn.wordpress.org/trunk@37347 602fd350-edb4-49c9-b593-d223f7449a82
Also disables Save & Publish button while save request is open. After the save request completes, any settings changed during the request can then be saved via an additional click to the button.
Props chandrapatel, westonruter.
Fixes#32941.
git-svn-id: https://develop.svn.wordpress.org/trunk@37346 602fd350-edb4-49c9-b593-d223f7449a82
`get_page_uri()` can now be called without an argument, which will return the page URI for the current post in the loop.
Props pollett.
Fixes#26284.
git-svn-id: https://develop.svn.wordpress.org/trunk@37345 602fd350-edb4-49c9-b593-d223f7449a82
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.
Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.
See #32246.
git-svn-id: https://develop.svn.wordpress.org/trunk@37342 602fd350-edb4-49c9-b593-d223f7449a82
To improve accessibility on touch devices increase the size of the button in the collapsed view from 24×28 to 44×45 pixel.
Props celloexpressions.
Fixes#36093.
git-svn-id: https://develop.svn.wordpress.org/trunk@37341 602fd350-edb4-49c9-b593-d223f7449a82
`wp_register_plugin_realpath()` calls `dirname( $file );` to remove the basename. The basename must be included in the argument or the symlinked directory won't be registered.
Props andy.
Fixes#36709.
git-svn-id: https://develop.svn.wordpress.org/trunk@37331 602fd350-edb4-49c9-b593-d223f7449a82
Allows widgets to be registered which rely on dependency injection. Also will allow for new widget types to be created dynamically (e.g. a Recent Posts widget for each registered post type).
See #35990.
Props mdwheele, PeterRKnight, westonruter.
Fixes#28216.
git-svn-id: https://develop.svn.wordpress.org/trunk@37329 602fd350-edb4-49c9-b593-d223f7449a82
This allows a plugin to short circuit `get_blogs_of_user()` in cases where the default behavior of the function is unnecessary or slow. (e.g. A user is a member of thousands of sites.)
Props jsternberg.
See #31746, Fixes#36707.
git-svn-id: https://develop.svn.wordpress.org/trunk@37326 602fd350-edb4-49c9-b593-d223f7449a82
`WP_Query` discards most non-array date values ('year', 'monthnum', etc) by
casting to integer. Since [25138], the 'm' parameter has been handled
as a string; see #24884. However, the string-handling introduced in [25138]
blindly attempted to handle arrays and other non-scalar types as strings,
resulting in PHP notices and invalid MySQL syntax.
Props vortfu.
Fixes#36718.
git-svn-id: https://develop.svn.wordpress.org/trunk@37324 602fd350-edb4-49c9-b593-d223f7449a82
The issues occur in themes that register sidebars that reference a single format placeholder (`%1$s` and `%2$s`) multiple times, such as in the `id` and `class` attributes for `$before_widget`.
Props martin.krcho, westonruter.
Fixes#36473.
git-svn-id: https://develop.svn.wordpress.org/trunk@37322 602fd350-edb4-49c9-b593-d223f7449a82
Setting the background color on `body` is more flexible than on the `html` element. This patch assigns the background color to `body` instead of the `html` element.
Fixes#35314
git-svn-id: https://develop.svn.wordpress.org/trunk@37321 602fd350-edb4-49c9-b593-d223f7449a82
`is_user_spammy()` falls back to the current user if one is not provided. There is no current user during authentication, so the result is always `false`. Pass a user to fill the void.
Adds tests for `wp_authenticate_spam_check()`.
Props websupporter.
Fixes#36546.
git-svn-id: https://develop.svn.wordpress.org/trunk@37316 602fd350-edb4-49c9-b593-d223f7449a82
The “Name” column of the Users WP List Table is not sortable because this column displays a concatenation of two optional values, `first_name` and `last_name`. Even if WP_User_Query supported ordering queries in this manner, the resulting sequence would be chaotic.
Fixes#28064.
Props jesin, and rachelbaker.
git-svn-id: https://develop.svn.wordpress.org/trunk@37314 602fd350-edb4-49c9-b593-d223f7449a82
Allow the adding of post-thumbnail support for one or more post_types without unsetting any previously added post_types. This matches the behavior of other uses of `add_theme_support()` and the expectations of a function with a prefix of “add”.
To unset post-thumbnail support use `remove_theme_support()` instead.
Fixes#22080
Props alexkingorg, jmichaelward, and flixos90.
git-svn-id: https://develop.svn.wordpress.org/trunk@37308 602fd350-edb4-49c9-b593-d223f7449a82
Warns users that have added a new Comment or began editing an existing without saving their changes, before they press the “update” button which would wipe out their comment changes.
Fixes#32818.
Props polevaultweb.
git-svn-id: https://develop.svn.wordpress.org/trunk@37303 602fd350-edb4-49c9-b593-d223f7449a82
In particular, we want it to occur after shortcode handling. The smiley conversion routine doesn't have any concept of shortcode structure, so may inadvertantly replace a smiley with HTML inside a shortcode attribute, which will cause the shortcode to not be parsed correctly.
Props Unyson for the initial suggested fix.
Fixes#36306.
git-svn-id: https://develop.svn.wordpress.org/trunk@37298 602fd350-edb4-49c9-b593-d223f7449a82
Unicode 8 added `U+1F644`, "Face with Rolling Eyes", which matches our `:roll:` smiley. Continuing our ever present quest to rid the world of legacy smilies, we now translate that smiley into its emoji form.
Sadly, `:mrgreen:` remains sorely under-represented in the Unicode standard, I'm inclined to think that we should buy a voting membership of the Unicode Consortium, in order to rectify that situation. (Personally, I'm hoping for a green skin tone modifier.)
Fixes#36365.
git-svn-id: https://develop.svn.wordpress.org/trunk@37296 602fd350-edb4-49c9-b593-d223f7449a82
This is a partial revert of [35860], which has been causing un-catchable warnings to be generated on some server configurations.
Fixes#36629 for trunk.
See #21870.
git-svn-id: https://develop.svn.wordpress.org/trunk@37292 602fd350-edb4-49c9-b593-d223f7449a82
To improve the performance of `wp_upload_dir()` the result of `wp_mkdir_p()` was stored in a persistent cache, introduced in [36565]. But this becomes an issue when WordPress is scaled horizontally. You may end up caching a value for a server where the directory doesn't exist which will prevent further uploads on other servers because of the persistent cache.
The fix is to use a non-persistent cache.
Props azaozz, ocean90.
See #34359.
Fixes#36621.
git-svn-id: https://develop.svn.wordpress.org/trunk@37285 602fd350-edb4-49c9-b593-d223f7449a82
This is now more consistent with the generic `admin_print_scripts` and the dynamic `admin_print_scripts-$hook_suffix` hooks fired in `wp-admin/admin-header.php`.
Props tfrommen.
Fixes#34334.
git-svn-id: https://develop.svn.wordpress.org/trunk@37279 602fd350-edb4-49c9-b593-d223f7449a82
`wp_update_plugins()` and `wp_update_themes()` are both hooked into `upgrader_process_complete` with priority 10. But at this stage the caches in `get_plugins()`, `search_theme_directories()`, and `wp_get_themes()` aren't refreshed yet so both functions couldn't fetch any translations for the new plugin/theme.
To reset the caches, `wp_clean_themes_cache()` and `wp_clean_plugins_cache()` are now hooked into `upgrader_process_complete` with priority 9.
This is a follow-up to [34751].
See #34029.
Fixes#36383.
git-svn-id: https://develop.svn.wordpress.org/trunk@37272 602fd350-edb4-49c9-b593-d223f7449a82
The `get_the_terms()` wrapper provides cache support, and saves a database hit
on sites with a persistent cache backend.
Props spacedmonkey.
Fixes#36602.
git-svn-id: https://develop.svn.wordpress.org/trunk@37262 602fd350-edb4-49c9-b593-d223f7449a82
[37028] missed some logic to capture the base emoji skin tone, to compare to the modified emoji skin tone. This caused all browsers to report that they supported skin tone modifiers, regardless of whether they actually did.
Fixes#36604 for trunk.
git-svn-id: https://develop.svn.wordpress.org/trunk@37256 602fd350-edb4-49c9-b593-d223f7449a82
Adding the `singular` class per default to the list of body classes is breaking the layout of Twenty Eleven and other themes. Twenty Eleven adds the `.singular` class only to single pages if the page doesn't use specific page templates.
Props flixos90, swissspidy.
Fixes#36510.
git-svn-id: https://develop.svn.wordpress.org/trunk@37249 602fd350-edb4-49c9-b593-d223f7449a82
Because term XML nodes now include termmeta and can thus be much larger, this
changeset also includes adds some newlines and indentation to make the XML
easier to read.
Props Chouby.
See #34062.
git-svn-id: https://develop.svn.wordpress.org/trunk@37240 602fd350-edb4-49c9-b593-d223f7449a82
- makes the mobile preview/customize toggle a button
- changes the "Close" link hidden text from 'Cancel' to 'Close the Customizer and go back to the previous page'
- adds a missing `type="button"` attribute
- removes unnecessary `keydown` events and `preventDefault()`: buttons don't need a keydown event and when they have a `type="button"` attribute there's no default action to prevent
Props Cheffheid, afercia.
Fixes#31487.
git-svn-id: https://develop.svn.wordpress.org/trunk@37230 602fd350-edb4-49c9-b593-d223f7449a82
By passing the `force_default` argument to `get_avatar()` instead of using `preg_replace`, we make it easier for developers to override the output.
Props henry.wright.
Fixes#34744.
git-svn-id: https://develop.svn.wordpress.org/trunk@37227 602fd350-edb4-49c9-b593-d223f7449a82
When multisite is not configured, the `_site_transient()` and `_site_option()` functions fallback to `_option()` and store network "meta/options" in `wp_options`.
Previously, those calls to `_option()` did not explicitly set the `autoload` parameter and anything assigned as a transient or option at the network level would be set to `autoload` by default, even though autoload is not yet a concept at the network option level.
This changes that behavior and forces the `autoload` setting to `no`. If `autoload` is desired, the single site option functions should be used.
Props thomaswm.
Fixes#22846.
git-svn-id: https://develop.svn.wordpress.org/trunk@37223 602fd350-edb4-49c9-b593-d223f7449a82