Commit Graph

249 Commits

Author SHA1 Message Date
Weston Ruter cb8173e053 Customize: Dismiss all autosaved auto-drafts for user and not just the one suggested when dismissing restoration notification.
Amends [41597].
See #39896.

Built from https://develop.svn.wordpress.org/trunk@41603


git-svn-id: http://core.svn.wordpress.org/trunk@41438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-26 20:33:46 +00:00
Weston Ruter 1a7616ad54 Customize: Extend changesets to support autosave revisions with restoration notifications, and introduce a new default linear history mode for saved changesets (with a filter for opt-in to changeset branching).
* Autosaved changes made on top of `auto-draft` changesets get written on top of the `auto-draft` itself, similar to how autosaves for posts will overwrite post drafts.
* Autosaved changes made to saved changesets (e.g. `draft`, `future`) will be placed into an autosave revision for that changeset and that user.
* Opening the Customizer will now prompt the user to restore their most recent auto-draft changeset; if notification is dismissed or ignored then the auto-draft will be marked as dismissed and will not be prompted to user in a notification again.
* Customizer will no longer automatically supply the `changeset_uuid` param in the `customize.php` URL when branching changesets are not active.
* If user closes Customizer explicitly via clicking on X link, then autosave auto-draft/autosave will be dismissed so as to not be prompted again.
* If there is a changeset already saved as a `draft` or `future` (UI is forthcoming) then this changeset will now be autoloaded for the user to keep making additional changes. This is the linear model for changesets.
* To restore the previous behavior of the Customizer where each session started a new changeset, regardless of whether or not there was an existing changeset saved, there is now a `customize_changeset_branching` hook which can be filtered to return `true`.
* `wp.customize.requestChangesetUpdate()` now supports a second with options including `autosave`, `title`, and `date`.
* The window `blur` event for `customize.php` has been replaced with a `visibilitychange` event to reduce autosave requests when clicking into preview window.
* Adds `autosaved` and `branching` args to `WP_Customize_Manager`.
* The `changeset_uuid` param for `WP_Customize_Manager` is extended to recognize a `false` value which causes the Customizer to defer identifying the UUID until `after_setup_theme` in the new `WP_Customize_Manager::establish_loaded_changeset()` method.
* A new `customize_autosaved` query parameter can now be supplied which is passed into the `autosaved` arg in `WP_Customize_Manager`; this option is an opt-in to source data from the autosave revision, allowing a user to restore autosaved changes.

Props westonruter, dlh, sayedwp, JoshuaWold, melchoyce.
See #39896.

Built from https://develop.svn.wordpress.org/trunk@41597


git-svn-id: http://core.svn.wordpress.org/trunk@41430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-26 07:38:45 +00:00
Andrea Fercia d1948f623a Accessibility: CodeMirror editing areas minor improvements.
- properly labels all the code editor areas (Theme/Plugin, Custom HTML widget, Additional CSS), whether CodeMirror is enabled or disabled
- adds `role="textbox"` and `aria-multiline="true"` to the CodeMirror editing area to allow assistive technologies properly identify it as a textarea
- standardizes the "keyboard trap" help text across the admin and keeps it as a list for better readability
- use the Help text elements as target for `aria-describedby`, to make screen readers read out the help text when focusing the editors
- fixes the `aria-expanded` attribute usage in the Customizer "Additional CSS" help toggle
- moves focus to the CodeMirror editing area when clicking on the associated label
- in the Plugin editor screen: changes a `<big>` element to `<h2>` for better semantics and consistency with the Theme editor screen
- also, removes a few textdomain leftovers, see `better-code-editing` and `default`

Props westonruter, melchoyce, afercia.
Fixes #41872.

Built from https://develop.svn.wordpress.org/trunk@41586


git-svn-id: http://core.svn.wordpress.org/trunk@41419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-24 16:00:46 +00:00
Weston Ruter f0b5c39bde Customize: Introduce extensible code editor Customizer control for CodeMirror.
* Adds `WP_Customize_Code_Editor_Control` and `wp.customize.CodeEditorControl()`.
* Control respects user preference for syntax highlighting, showing a textarea when user opts out.
* Code editor control takes the ad hoc code for Additional CSS and makes it reusable and extensible, for Additional CSS in core and plugins to use (such as Jetpack).
* Replace `settings` arg in `wp_enqueue_code_editor()` with separate args for `codemirror`, `csslint`, `jshint`, and `htmlhint`.
* Prefix `codemirror` script and style handles with `wp-` to prevent collisions, as also the object is exported as `wp.CodeMirror` in JS.
* Reduce indent size in Customizer code editor instances and Custom HTML widget to use tab size of 2 instead of 4 to save on space.

See #12423, #38707, #35395.
Fixes #41897.

Built from https://develop.svn.wordpress.org/trunk@41558


git-svn-id: http://core.svn.wordpress.org/trunk@41391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-21 23:04:45 +00:00
Weston Ruter 800ad7bd04 Customize: Let media control button labels better automatically reflect the specified MIME type.
Props Christian1012, celloexpressions, westonruter.
Fixes #38796.

Built from https://develop.svn.wordpress.org/trunk@41550


git-svn-id: http://core.svn.wordpress.org/trunk@41383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-20 21:24:46 +00:00
Dominik Schilling 12694b6b92 Customize: Ensure valid themes in the preview.
Built from https://develop.svn.wordpress.org/trunk@41397


git-svn-id: http://core.svn.wordpress.org/trunk@41230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 08:39:45 +00:00
Weston Ruter f6a26be345 Customize: Add notifications API to sections and panels.
* Adds a `notifications` property to instances of `wp.customize.Panel` and `wp.customize.Section`.
* Adds a `setupNotifications()` method to `Panel`, `Section`, and `Control`.
* Adds a `getNotificationsContainerElement()` method to the `Panel` and `Section` classes, like `Control` has.
* Replace hard-coded notification in header media section with a notification.
* Limit rendering notifications to panels and sections that are expanded, and to controls that have an expanded section.

See #34893, #35210, #38778.
Fixes #38794.

Built from https://develop.svn.wordpress.org/trunk@41390


git-svn-id: http://core.svn.wordpress.org/trunk@41223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 05:40:44 +00:00
Weston Ruter 3abea17301 Customize: Add `wp_is_uuid()` validation function with optional second `$version=4` parameter to enforce v4 random UUIDs.
Props jonathanbardo.
Fixes #39778.

Built from https://develop.svn.wordpress.org/trunk@41388


git-svn-id: http://core.svn.wordpress.org/trunk@41221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-18 23:04:44 +00:00
Weston Ruter 90bedf8f9d Editor: Add CodeMirror-powered code editor with syntax highlighting, linting, and auto-completion.
* Code editor is integrated into the Theme/Plugin Editor, Additional CSS in Customizer, and Custom HTML widget. Code editor is not yet integrated into the post editor, and it may not be until accessibility concerns are addressed.
* The CodeMirror component in the Custom HTML widget is integrated in a similar way to TinyMCE being integrated into the Text widget, adopting the same approach for integrating dynamic JavaScript-initialized fields.
* Linting is performed for JS, CSS, HTML, and JSON via JSHint, CSSLint, HTMLHint, and JSONLint respectively. Linting is not yet supported for PHP.
* When user lacks `unfiltered_html` the capability, the Custom HTML widget will report any Kses-invalid elements and attributes as errors via a custom Kses rule for HTMLHint.
* When linting errors are detected, the user will be prevented from saving the code until the errors are fixed, reducing instances of broken websites.
* The placeholder value is removed from Custom CSS in favor of a fleshed-out section description which now auto-expands when the CSS field is empty. See #39892.
* The CodeMirror library is included as `wp.CodeMirror` to prevent conflicts with any existing `CodeMirror` global.
* An `wp.codeEditor.initialize()` API in JS is provided to convert a `textarea` into CodeMirror, with a `wp_enqueue_code_editor()` function in PHP to manage enqueueing the assets and settings needed to edit a given type of code.
* A user preference is added to manage whether or not "syntax highlighting" is enabled. The feature is opt-out, being enabled by default.
* Allowed file extensions in the theme and plugin editors have been updated to include formats which CodeMirror has modes for: `conf`, `css`, `diff`, `patch`, `html`, `htm`, `http`, `js`, `json`, `jsx`, `less`, `md`, `php`, `phtml`, `php3`, `php4`, `php5`, `php7`, `phps`, `scss`, `sass`, `sh`, `bash`, `sql`, `svg`, `xml`, `yml`, `yaml`, `txt`.

Props westonruter, georgestephanis, obenland, melchoyce, pixolin, mizejewski, michelleweber, afercia, grahamarmfield, samikeijonen, rianrietveld, iseulde.
See #38707.
Fixes #12423, #39892.

Built from https://develop.svn.wordpress.org/trunk@41376


git-svn-id: http://core.svn.wordpress.org/trunk@41209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-13 06:08:47 +00:00
Weston Ruter d8f445bf0f Customize: Add global notifications area.
* Displays an error notification in the global area when a save attempt is rejected due to invalid settings. An error notification is also displayed when saving fails due to a network error or server error.
* Introduces `wp.customize.Notifications` subclass of `wp.customize.Values` to contain instances of `wp.customize.Notification` and manage their rendering into a container.
* Exposes the global notification area as `wp.customize.notifications` collection instance.
* Updates the `notifications` object on `Control` to use `Notifications` rather than `Values` and to re-use the rendering logic from the former. The old `Control#renderNotifications` method is deprecated.
* Allows notifications to be dismissed by instantiating them with a `dismissible` property.
* Allows `wp.customize.Notification` to be extended with custom templates and `render` functions.
* Triggers a `removed` event on `wp.customize.Values` instances _after_ a value has been removed from the collection.

Props delawski, westonruter, karmatosed, celloexpressions, Fab1en, melchoyce, Kelderic, afercia, adamsilverstein.
See #34893, #39896.
Fixes #35210, #31582, #37727, #37269.

Built from https://develop.svn.wordpress.org/trunk@41374


git-svn-id: http://core.svn.wordpress.org/trunk@41207 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-12 07:03:46 +00:00
Weston Ruter 3853a250f9 Customize: Align behavior of `WP_Customize_Manager::save_changeset_post()` with `wp_insert_post()` by setting status to `future` if supplied status is `publish` but date is future.
Props dlh.
Fixes #41336.

Built from https://develop.svn.wordpress.org/trunk@41372


git-svn-id: http://core.svn.wordpress.org/trunk@41205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-11 17:50:44 +00:00
Weston Ruter 203d220c6f Customize: Re-use homepage settings help tab text from Reading Options admin screen in description for corresponding Customizer section.
Also remove "Static" reference in template name, missed in [41363].

See #41829.

Built from https://develop.svn.wordpress.org/trunk@41364


git-svn-id: http://core.svn.wordpress.org/trunk@41197 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-10 17:08:43 +00:00
Weston Ruter a74e98d7be Customize: Rename "Static front page" to just "Homepage".
Props danieltj, melchoyce.
Fixes #41828.

Built from https://develop.svn.wordpress.org/trunk@41363


git-svn-id: http://core.svn.wordpress.org/trunk@41196 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-10 16:20:44 +00:00
Sergey Biryukov 3d6c0dc45a Docs: Remove "since since" and "one one" dittography from inline comments.
Fixes #41841.
Built from https://develop.svn.wordpress.org/trunk@41355


git-svn-id: http://core.svn.wordpress.org/trunk@41188 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-09 13:53:42 +00:00
Sergey Biryukov 098fed18b7 Docs: Remove "the the" dittography from inline comments.
Props Presskopp.
Fixes #41835.
Built from https://develop.svn.wordpress.org/trunk@41350


git-svn-id: http://core.svn.wordpress.org/trunk@41183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-08 18:21:42 +00:00
Weston Ruter 1afaf8c605 Customize: Prevent potential cache corruption when finding a secondary changeset post by UUID.
Props dlh.
Fixes #41738.

Built from https://develop.svn.wordpress.org/trunk@41321


git-svn-id: http://core.svn.wordpress.org/trunk@41152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-29 04:10:46 +00:00
John Blackbourn 28eda6f4bc General: Improve terminology used when referring to installations of WordPress and its extensions.
"Install" is not a noun, and while it might be acceptable to use the verb as a noun, it is not correct. Using the correct
noun, "installation", increases clarity, especially for non-native English speakers.

This change fixes the usage in user-facing text and in developer documentation.

Fixes #41620

Built from https://develop.svn.wordpress.org/trunk@41289


git-svn-id: http://core.svn.wordpress.org/trunk@41129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-22 11:52:48 +00:00
Weston Ruter 6428de97a7 Customize: Fix PHP warning raised when deleting a setting from changeset via passing `null` as params in `WP_Customize_Manager::save_changeset_post()`.
Props dlh.
Fixes #41621.

Built from https://develop.svn.wordpress.org/trunk@41243


git-svn-id: http://core.svn.wordpress.org/trunk@41083 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-12 21:21:48 +00:00
Weston Ruter a193916f46 Customize: Introduce `settings_previewed` arg and getter on `WP_Customize_Manager` which controls whether `WP_Customize_Setting::preview()` should be called on settings.
The `settings_previewed` property eliminates the need for the Customizer components from having to look at global `doing_ajax` state. This is in particular needed when saving settings, as some settings will short-circuit the update operation if they detect no changes are introduced. This is also needed for low-level integrations with the Customizer, such as in REST API endpoints under development.

Props stubgo, westonruter, utkarshpatel for testing.
See #38900.
Fixes #39221.

Built from https://develop.svn.wordpress.org/trunk@41205


git-svn-id: http://core.svn.wordpress.org/trunk@41045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-02 05:35:41 +00:00
Drew Jaynes 0860bb2771 Docs: Remove `@access` notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

Built from https://develop.svn.wordpress.org/trunk@41162


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Weston Ruter 6b907d8437 Customize: Prevent edge case fatal error when attempting to save changes to a changeset that had previously been corrupted.
Check return value of `WP_Customize_Manager::get_changeset_post_data()` and return if error instead of assuming it is an array.

Amends [38810].
See #30937.
Fixes #41252.

Built from https://develop.svn.wordpress.org/trunk@41012


git-svn-id: http://core.svn.wordpress.org/trunk@40862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-06 07:05:43 +00:00
Weston Ruter e8e5a71a85 Docs: Improve phpdoc for `WP_Customize_Manager`, `WP_Customize_Control`, `WP_Customize_Setting`, and `WP_Customize_Selective_Refresh`.
Props 4nickpick, sagarprajapati, ketuchetan, BharatKambariya, mrahmadawais, westonruter.
Fixes #39671.

Built from https://develop.svn.wordpress.org/trunk@40804


git-svn-id: http://core.svn.wordpress.org/trunk@40662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-19 20:25:41 +00:00
Dominik Schilling 3d10fef22d Customize: Igore invalid customization sessions.
Built from https://develop.svn.wordpress.org/trunk@40704


git-svn-id: http://core.svn.wordpress.org/trunk@40567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-16 12:07:43 +00:00
Andrea Fercia 274596b8ef Accessibility: Add "(opens in a new window)" screen reader text to the "News-Nearby Events" dashboard widget footer links.
- standardizes similar messages in core to always use `(opens in a new window)`
- adds translators comments
- hides the dashicons with `aria-hidden="true"`, see #40428

Fixes #40733.

Built from https://develop.svn.wordpress.org/trunk@40643


git-svn-id: http://core.svn.wordpress.org/trunk@40504 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 22:47:41 +00:00
Weston Ruter 5f771393a3 Customize: Use `is_header_video_active()` as `active_callback` for `external_header_video` control instead of `is_front_page()`.
Use the same `active_callback` as was supplied previously for the `header_video` control in [39240] where this instance was missed.

Amends [39240].
Props pratikshrestha.
See #38738.
Fixes #40308.

Built from https://develop.svn.wordpress.org/trunk@40379


git-svn-id: http://core.svn.wordpress.org/trunk@40286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-05 23:10:42 +00:00
Sergey Biryukov e8c4b8c8e7 Docs: Add an entry for `$pagenow` global in `WP_Customize_Manager::setup_theme()`.
Props mt8.biz.
Fixes #40297.
Built from https://develop.svn.wordpress.org/trunk@40349


git-svn-id: http://core.svn.wordpress.org/trunk@40256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-29 11:41:46 +00:00
Weston Ruter 85b4cddebf Customize: Extend auto-draft life of a `customize_changeset` post whenever modified.
Keep bumping the date for the auto-draft to preserve it from garbage-collection via `wp_delete_auto_drafts()` after 7 days.

See #30937.
Fixes #39713.

Built from https://develop.svn.wordpress.org/trunk@40041


git-svn-id: http://core.svn.wordpress.org/trunk@39978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-02-05 06:39:41 +00:00
Weston Ruter a44f8db73d Customize: Always enqueue `customize-preview` stylesheet in the customizer preview to style selective refresh and visual edit shortcuts.
Enqueues the style along with the `customize-preview` script in the manager instead of via the `widgets` and `nav_menus` components, ensuring that the stylesheet is loaded for users who cannot manage widgets or nav menus.

Props dlh.
See #27403.
Fixes #39498.

Built from https://develop.svn.wordpress.org/trunk@39951


git-svn-id: http://core.svn.wordpress.org/trunk@39888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-26 03:47:41 +00:00
Weston Ruter 3e6c892f89 Customize: Allow custom post types to be used in starter content.
Changes `WP_Customize_Nav_Menus::insert_auto_draft_post()` so it can be invoked for a `post_type` that is not registered (yet).

See #38615, #38114.
Fixes #39610.

Built from https://develop.svn.wordpress.org/trunk@39924


git-svn-id: http://core.svn.wordpress.org/trunk@39861 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-19 00:01:46 +00:00
Dion Hulse 9f381dbea6 Customizer: Don't query for postmeta for Custom CSS (for not-current-themes) and Customizer Changeset posts.
Props dlh.
Fixes #39194.

Built from https://develop.svn.wordpress.org/trunk@39692


git-svn-id: http://core.svn.wordpress.org/trunk@39632 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-05 08:12:42 +00:00
Weston Ruter a366e58135 Customize: Trim whitespace for URLs supplied for `external_header_video` to prevent `esc_url_raw()` from making them invalid.
Props tyxla.
See #38172.
Fixes #39125.

Built from https://develop.svn.wordpress.org/trunk@39560


git-svn-id: http://core.svn.wordpress.org/trunk@39500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-10 07:00:45 +00:00
Weston Ruter c68f1de5f8 Customize: Use selected user language for edit shortcuts in preview instead of site language.
Props ocean90.
Fixes #39009.

Built from https://develop.svn.wordpress.org/trunk@39545


git-svn-id: http://core.svn.wordpress.org/trunk@39485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-08 19:32:59 +00:00
Weston Ruter 3b37903106 Customize: Defer populating `post_name` for `auto-draft` posts in customized state until posts are published.
The ultimate `post_name` is stored in postmeta until the post is published. The `get_page_by_path()` function does not exclude `auto-draft` posts. Revert changes to `wp_unique_post_slug()` from [39411] which excluded `auto-draft` posts.

Props westonruter, dlh for testing, helen for testing.
See #38114, #38928.
Fixes #39078.

Built from https://develop.svn.wordpress.org/trunk@39506


git-svn-id: http://core.svn.wordpress.org/trunk@39446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-05 19:33:42 +00:00
Weston Ruter c9b8a5dbbb Customize: Ensure `textarea` for Custom CSS displays as code (in LTR) when an RTL language is active.
See #35395.
Fixes #39085.

Built from https://develop.svn.wordpress.org/trunk@39499


git-svn-id: http://core.svn.wordpress.org/trunk@39439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-05 13:55:42 +00:00
Helen Hou-Sandí a5e9954f1d Custom CSS: Change the help link to something better for users.
fixes #39015.

Built from https://develop.svn.wordpress.org/trunk@39466


git-svn-id: http://core.svn.wordpress.org/trunk@39406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-03 05:11:42 +00:00
Weston Ruter 01fe6a2fac Customize: Fix posts limit query arg for `WP_Query` from incorrect `number` to `posts_per_page`.
Props dlh.
Fixes #39022.

Built from https://develop.svn.wordpress.org/trunk@39434


git-svn-id: http://core.svn.wordpress.org/trunk@39374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-02 16:18:43 +00:00
Weston Ruter 71d5ba249b Customize: Reuse existing non-auto-draft posts and existing auto-draft posts in the customized state with matching slugs when applying starter content.
* Updates `wp_unique_post_slug()` to ignore `auto-draft` posts. Prevents publishing multiple posts that have the same slugs from starter content.
* Fixes fatal error when attempting to save an header_image setting from a non-admin context.
* Fixes substituting attachment symbols in options and theme mods.
* Fixes applying starter content for header images and background images.

See #38114.
Fixes #38928.

Built from https://develop.svn.wordpress.org/trunk@39411


git-svn-id: http://core.svn.wordpress.org/trunk@39351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-02 00:25:41 +00:00
Weston Ruter 5e7d9a49fd Customize: Reject a changeset update when a non-future date is provided and also ensure that a published changeset always gets set to the current date/time.
* Also moves checks from `customize_save` Ajax handler to the underlying `WP_Customize_Manager::save_changeset_post()` call which plugins may invoke directly.
* Ensures that `customize_save_response` filter is always passed an array, with error code available as `code`.

Props utkarshpatel, westonruter, sayedwp.
See #30937.
Fixes #38943.

Built from https://develop.svn.wordpress.org/trunk@39409


git-svn-id: http://core.svn.wordpress.org/trunk@39349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-02 00:02:44 +00:00
Helen Hou-Sandí 70fc99e323 Theme starter content: Add support for featured images and page templates.
Featured image support means that attachments can now be imported. Media can be sideloaded from within theme or plugin directories. Like other posts, attachments are auto-drafts until customizer changes are published, and are not duplicated when they already exist in the customized state. Attachment IDs can be used for any number of purposes, much like post IDs. Twenty Seventeen now includes 3 images used as featured images to best showcase the multi-section homepage setup.

As featured image IDs are stored in post meta, it also made sense to add support for page templates. Twenty Seventeen does not include any such templates, but the functionality can be quite important for displaying themes to their best effect.

props westonruter, helen, flixos90.
fixes #38615.

Built from https://develop.svn.wordpress.org/trunk@39346


git-svn-id: http://core.svn.wordpress.org/trunk@39286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-23 09:53:33 +00:00
Weston Ruter 6b5d960453 Customize: Clean up docs and code style for customize changes in 4.7.
* Adds missing `resolve`/`fail` for promise returned by `loadThemePreview`.
* Adds missing jsdoc blocks and tags.
* Adds missing phpdoc and makes corrections.

See #37770.
Fixes #38908.

Built from https://develop.svn.wordpress.org/trunk@39345


git-svn-id: http://core.svn.wordpress.org/trunk@39285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-23 06:05:32 +00:00
Weston Ruter 3284f9a989 Customize: Remove iframe-specific behaviors from customize preview when previewing on frontend and not contained inside iframe.
* Strip out `customize_messenger_channel` from preview window URL when not contained in iframe.
* Allow interacting with unpreviewable links and forms when previewing customized state on frontend.

See #30937.
Fixes #38867.

Built from https://develop.svn.wordpress.org/trunk@39332


git-svn-id: http://core.svn.wordpress.org/trunk@39272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-21 16:56:30 +00:00
Weston Ruter 3c7e23297e Customize: Ensure that `WP_Customize_Manager::save_changeset_post()` returns `setting_validities` even for supplied values that are unchanged from values in changeset.
Check setting existence and authorization via `WP_Customize_Manager::validate_setting_values()` even for `null` values to account for custom params being added to settings, preventing failures from being silently ignored.

See #38705, #30937.
Fixes #38865.

Built from https://develop.svn.wordpress.org/trunk@39320


git-svn-id: http://core.svn.wordpress.org/trunk@39260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-19 22:39:33 +00:00
Weston Ruter 2cabe7aef1 Customize: Add unit tests for importing theme starter content.
Props welcher, westonruter.
See #38114, #38533, #38615.
Fixes #38540.

Built from https://develop.svn.wordpress.org/trunk@39276


git-svn-id: http://core.svn.wordpress.org/trunk@39216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-17 08:18:32 +00:00
Joe McGill 5ef714db18 Themes: Improve a11y and extendability of custom video headers.
This adds play/pause controls to video headers, along with voice
assistance, using `wp.a11y.speak`, to make custom video headers more
accessible. To make styling the play/pause button easier for themes,
CSS has been omitted from the default implementation.

This also includes a refactor of the `wp.customHeader` code to introduce
a `BaseHandler` class, which can be extended by plugins and themes to modify
or enhance the default video handlers.

Props davidakennedy, afercia, bradyvercher, joemcgill, adamsilverstein, rianrietveld.
Fixes #38678.
Built from https://develop.svn.wordpress.org/trunk@39272


git-svn-id: http://core.svn.wordpress.org/trunk@39212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 23:26:31 +00:00
Weston Ruter 7db38b916a Customize: Allow URL for Codex link in Additional CSS section to be translated.
Props odysseygate, ocean90, westonruter.
See #35395.
Fixes #38823.

Built from https://develop.svn.wordpress.org/trunk@39268


git-svn-id: http://core.svn.wordpress.org/trunk@39208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-16 18:42:32 +00:00
Sergey Biryukov ec0043c279 I18N: Remove `<code>` tags from translatable strings in `wp-includes/class-wp-customize-manager.php`.
Props ramiy.
Fixes #38802.
Built from https://develop.svn.wordpress.org/trunk@39254


git-svn-id: http://core.svn.wordpress.org/trunk@39194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 20:54:30 +00:00
Weston Ruter 8efc416f64 Customize: Allow starter content to apply in a new theme when switching from another theme containing changes.
* Ensure that starter content can apply from theme B after previewing starter content in theme A.
* Introduce new `starter_content` flag in changeset setting params which is used to capture whether a value is starter content and thus can be overridden.
* Create changeset up-front with `starter_content` flags instead of waiting for `AUTOSAVE_INTERVAL`.
* Eliminate instantiation of settings for widget instances in favor of directly calling `sanitize_widget_js_instance`. This eliminates issues with looking for widgets before they are registered.
* Ensure that non-placeholders (inline arrays instead of string references) can be supplied in starter content.
* Re-use auto-draft posts as starter content across theme switches.
* Introduce `starter_content` param for `WP_Customize_Manager::save_changeset_post()` which is `false` except when starter content is being loaded on a `fresh_site`.

See #38114.
Fixes #38541.

Built from https://develop.svn.wordpress.org/trunk@39241


git-svn-id: http://core.svn.wordpress.org/trunk@39181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 09:03:32 +00:00
Peter Wilson 11998b4169 Themes: Remove front page restriction from video header functions.
Adds a callback for determining when video headers should be displayed in themes supporting custom headers. By default, video headers are only displayed on the front page of a site.

Theme authors may set a custom callback by passing `'video-active-callback' => 'mytheme_video_active_callback'` as an argument. The default callback is `is_front_page()`.

This introduces the new function `is_header_video_active()` - returns `true` on pages that should display video headers. The return value can be filtered using the new filter of the same name.

Props flixos90, bradyvercher, peterwilsoncc, joemcgill.
Fixes #38738.

Built from https://develop.svn.wordpress.org/trunk@39240


git-svn-id: http://core.svn.wordpress.org/trunk@39180 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 07:16:33 +00:00
Weston Ruter de0835dead Customize: Only show video header controls if previewing front page; show explanatory notice when controls are hidden.
Also include todo for the `header_video` control's `button_labels`. See #38796.

Props westonruter, joemcgill, celloexpressions.
Fixes #38778.

Built from https://develop.svn.wordpress.org/trunk@39237


git-svn-id: http://core.svn.wordpress.org/trunk@39177 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 03:47:30 +00:00
Weston Ruter 8e6753cead Customize: Use video-specific labels for buttons in Header Video media control.
See #38172.

Built from https://develop.svn.wordpress.org/trunk@39234


git-svn-id: http://core.svn.wordpress.org/trunk@39174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-15 00:22:30 +00:00