Commit Graph

239 Commits

Author SHA1 Message Date
Weston Ruter
47c555f8ed Customize: Add codemirror deferred object to CodeEditorControl which is resolved when CodeMirror is initialized.
CodeMirror gets initialized once the control's containing section is expanded. The deferred will be rejected if user preference for syntax highlighting is disabled.
Also move jsdoc from `wp.customize.Control` to intended `wp.customize.Control#initialize()`.

See #41897, #12423.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-20 21:48:46 +00:00
Weston Ruter
81c87e7d5e Code Editor: Improve ability to create Customizer CodeEditorControl instances in JS, lessening PHP dependencies.
Allow `CodeEditorControl` to be instantiated with a `editor_settings` param which is merged with `wp.codeEditor.defaultSettings`.

Also:

* Turn redundant "CSS Code" control label into screen reader text for Additional CSS.
* Remove `code-editor` as script dependency for `custom-html-widgets` since enqueueing is determined by `wp_enqueue_code_editor()`.
* Remove useless exporting of `code_type` param to JS in `WP_Customize_Code_Editor_Control`.
* Add `disabled` class to Custom HTML widget's Save button when linting errors are present.
* Remove redundant `span` inside CodeEditorControl's `label`.

See #41897, #12423, #41872.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-20 16:39:48 +00:00
Weston Ruter
a402312a8d Customize: Prevent using default template for a base control when it has content rendered on the server.
Also prevent invalid `type` attribute from being added to a `select` element.

See #30738.
Fixes #42286.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41786 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-20 03:30:46 +00:00
Weston Ruter
ea21ad6cc1 Customize: Prevent re-highlighting "Add Items" button after available nav menu items pane has already been opened.
Amends [41930].
Props bpayton.
See #42114.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-19 18:38:47 +00:00
Weston Ruter
d695648084 Customize: Fix rendering issues in theme browsing when opening theme details or performing search in Safari.
Props sayedwp.
See #37661.
Fixes #42052.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-19 17:57:47 +00:00
Weston Ruter
b1a9139b46 Customize: Prevent drawing attention to save button if status unchanged from publish; account for changes to status/date when alerting about unsaved changes.
Also fix malformed ESLint directive from [41933].

Amends [41932].
See #39896, #42211.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-19 17:42:54 +00:00
Weston Ruter
20aad6b5c5 Customize: Consistently use input_attrs as control param key in JS instead of inputAttrs.
See #30738, #41897.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-19 03:25:47 +00:00
Weston Ruter
f8d16c8aed Customize: Move control's fallback selection of default content template to renderContent method to align with sections and panels.
* Only use default control content template when a more specific template doesn't exist.
* Remove extraneous whitespace from being output in `WP_Customize_Control::render()` method.
* Move Custom Header template printing to `customize_controls_print_footer_scripts` action.

See #30738.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41769 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-19 03:04:49 +00:00
Weston Ruter
ed686152f5 Customize: Draw attention to save button after collapsing the publish settings section when the changeset status or date had been changed.
Props bpayton, westonruter.
See #42114, #39896.
Fixes #42211.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41766 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-18 23:06:49 +00:00
Weston Ruter
b65d6eb680 Customize: Draw attention to "Add Items" button after creating a new menu.
Introduce `wp.customize.utils.highlightButton()` and `wp.customize.Menus.MenuSection#highlightNewItemButton()`.

Props bpayton, melchoyce, afercia, westonruter.
Fixes #42114.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-18 22:00:50 +00:00
Konstantin Obenland
d8f98b3649 Customize: Unstick filter pane in Theme selector
Prevents the filter pane from blocking the view of theme search results when it's open.
Users are now able to just scroll to view results.

Props rclations.
Fixes #42212.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-18 15:11:46 +00:00
Weston Ruter
862e8c1807 Customize: Use keydown instead of keyup for listening for enter key to add page stub via dropdown-pages control.
Fixes issue with Japanese input.

Props miyauchi.
Amends [38906].
See #34923.
Fixes #42233.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-16 07:57:48 +00:00
Weston Ruter
2e184426c0 Customize: Add 'save-request-params' event on wp.customize for plugins to inject/modify params in save requests.
Allows feature plugins, for example, to supply a `customize_changeset_title` param instead of having to wrap `wp.customize.previewer.query`.

Props dlh.
Fixes #42206.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-15 22:42:48 +00:00
Weston Ruter
24d304a0a1 Customize: Fix positioning of device-previewed window when publish settings are open.
* Update date control padding.
* Collapse publish settings section when opening panes for available widgets or nav menus.
* Remove save and cog buttons in mobile preview only mode.
* Move definition of `wp.customize.previewedDevice` to `wp.customize.state('previewedDevice')` for centralization, maintaining old alias.
* Remove unused CSS because the section is inside form now.

Props sayedwp, westonruter.
See #39896.
Fixes #42027, #42199.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-13 21:21:55 +00:00
Weston Ruter
39a2308a94 Customize: Prevent showing confirmation dialog when leaving Customizer after previewing theme switch without making any changes.
Fixes #42173.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-12 05:17:49 +00:00
Weston Ruter
434e3aba82 Customize: Add changeset locking in Customizer to prevent users from overriding each other's changes.
* Customization locking is checked when changesets are saved and when heartbeat ticks.
* Lock is lifted immediately upon a user closing the Customizer.
* Heartbeat is introduced into Customizer.
* Changes made to user after it was locked by another user are stored as an autosave revision for restoration.
* Lock notification displays link to preview the other user's changes on the frontend.
* A user loading a locked Customizer changeset will be presented with an option to take over.
* Autosave revisions attached to a published changeset are converted into auto-drafts so that they will be presented to users for restoration.
* Focus constraining is improved in overlay notifications.
* Escape key is stopped from propagating in overlay notifications, and it dismisses dismissible overlay notifications.
* Introduces `changesetLocked` state which is used to disable the Save button and suppress the AYS dialog when leaving the Customizer.
* Fixes bug where users could be presented with each other's autosave revisions.

Props sayedwp, westonruter, melchoyce.
See #31436, #31897, #39896.
Fixes #42024.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-12 04:01:46 +00:00
Weston Ruter
43801ded60 Customize: Make sure saved state is initially false when restoring autosave revision so that Save button will be enabled.
Amends [41597].
Props sayedwp.
See #39896.
Fixes #42143.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-11 05:57:48 +00:00
Weston Ruter
7b0dbf49fc Customize: Improve behavior and extensibility of theme loading and searching.
* Introduce `WP_Customize_Themes_Section::$filter_type`, which has built-in functionality for `local` and `remote` filtering. When this set to `local`, all themes are assumed to be loaded from Ajax when the section is first loaded, and subsequent searching/filtering is applied to the loaded collection of themes within the section. This is how the core "Installed" section behaves - third-party sources with limited numbers of themes may consider leveraging this implementation. When this is set to `remote`, searching and filtering always triggers a new remote query via Ajax. The core "WordPress.org" section uses this approach, as it has over 5000 themes to search.
* Refactor `filterSearch()` to accept a raw term string as input. This enables a feature filter to be used on a section where `filter_type` is `local`.
* Refactor `filter()` on a theme control to check for an array of terms. Also sort the results by the number of matches. Rather than searching for an exact match, this will now search for each word in a search distinctly, allowing things like tags to rank in search results more accurately.
* Split `loadControls()` into two functions for themes section JS: `loadThemes()` to initiate and manage an Ajax request and `loadControls()` to create theme controls based on the results of the Ajax call. If third-party sections need to change the way controls are loaded, such as by using a custom control subclass of `WP_Customize_Theme_Control`, this allows them to use the core logic for managing the Ajax call and only override the actual control-creation process.
* Introduce `customize_load_themes` filter to facilitate loading themes from third-party sources (or modifying the results of the core sections).
* Bring significant improvements to the installed themes search filter.

Props celloexpressions.
Amends [41648].
See #37661.
Fixes #42049.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-10 07:09:52 +00:00
Weston Ruter
ef1c95ff91 Customize: Constrain focus when overlay notification is displayed.
* Restore previously-focused element when overlay notifications are dismissed.
* Allow notifications to be dismissed via keyboard.

Amends [41667].
See #42110, #35210, #39896.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-10 03:34:53 +00:00
Weston Ruter
598e5f400e Customize: Add jsdoc for api.panel, api.section, api.control, and api.notifications collections.
Props shramee, westonruter.
Fixes #39930.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-09 18:56:55 +00:00
Weston Ruter
35b5c9e762 Customize: Eliminate use of customize-loader in core so Customizer is opened consistently in top window.
* Open the door for future browser history feature in #28536, which is currently not feasible when customize-loader is used.
* Remove customizer-loader from being used on admin screens for Dashboard, Themes, non-shiny theme install/update.
* Keep the customize-loader functionality available for plugins, for the time being. It may become deprecated.
* Ensure `return` param in customizer links in Themes screen update to reflect `search` updated by `pushState`.
* Persist `return` when reloading Customizer due to theme switch, autosave restoration, or changeset trashing.
* Use `location.replace()` instead of changing `location.href` when trashing.
* Hide theme browser while Themes screen is loading when there is a `search` to prevent flash of unfiltered themes.
* Use throttling instead of debouncing when searching themes to ensure that screen is updated immediately on page load.
* Fix encoding and decoding of `search` param between URL and search field.
* Add support for dismissing autosaves when closing customize-loader, when it is used by plugins.
* Skip sending changeset UUID to customize-loader for population in browser location if changeset branching is not enabled.

See #28536.
Fixes #40254.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-09 16:04:48 +00:00
Weston Ruter
a01ae9a8c3 Customize: Fix confusion related to visibility of Themes panel with drafted/scheduled changesets.
* Prevent autoloading an existing draft/future changeset when theme not active.
* Add missing notifications container to Themes panel.
* Remove deactivation of themes panel when selected status is not publish.
* Show notification in Themes panel when themes cannot be previewed and disable preview buttons.
* Reject installTheme call when theme preview not available.
* Return promise from installTheme and eliminate use of global events in favor of promises.

Props westonruter, melchoyce, zoonini.
See #37661, #39896.
Fixes #42126.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-07 06:00:54 +00:00
Weston Ruter
b6297d1866 Customize: Prevent color default control type from overriding template for ColorControl.
Amends [41771].
See #30738.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 14:36:57 +00:00
Weston Ruter
9d6134a88c Customize: Add default control template for standard input types.
Re-use default template instead of introducing custom one for the Discard Changes button.

See #30738.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 02:56:47 +00:00
Weston Ruter
275f4713a5 Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.

This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.

Also adds default `type` lookups for Panel and Section instances. See #30741.

Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 02:22:49 +00:00
Weston Ruter
f5bc1d1f52 Customize: Allow controls to be created with pre-instantiated Setting object(s), or even with plain Value object(s).
* Allow passing settings in keyed object (e.g. `settings: { default: 'id' }  ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.

Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 20:02:49 +00:00
Weston Ruter
55ba2f5e53 Customize: Fix theme details modal by updating logic in getPreviousTheme and getNextTheme to not rely on DOM traversal and manually constructing control IDs.
Amends [41726].
See #42083, #37661.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41573 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 16:49:46 +00:00
Weston Ruter
f8c6040ff5 Customize: Improve usability of Customize JS API.
* Eliminate need to pass both ID and instance in calls to `Values#add()` for panels, sections, controls, settings, partials, and notifications.
* Eliminate need to supply `content` param when constructing a `Control`.
* Unwrap the `options.params` object passed in constructors to just pass a flat `options`. (Back-compat is maintained.)
* Add support for `templateId` param for `Control` to override which template is used for the content.
* Remove unused `previewer` being supplied in `Control` instances.
* Rename `classes` to `containerClasses` on `Notification`.
* Automatically supply `instanceNumber` to improve stable sorting.
* Use `api.Notifications` for notifications in settings instead of `api.Value`.

See #30741.
Fixes #42083.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 06:48:46 +00:00
Andrea Fercia
a452e2259b Customize: Fix invalid HTML and aria-describedby values.
- fixes invalid HTML and duplicate IDs
- as per the Accessibility coding standards, all new code must use explicitly associated form labels
- properly escapes a few HTML attributes

Props celloexpressions, afercia.
Fixes #42054.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41543 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 15:44:46 +00:00
Weston Ruter
8d79246606 Customize: Add button in Publish Settings to discard unsaved changes (including drafted and scheduled), reverting Customizer to the last published state.
Props westonruter, melchoyce.
Amends [41667].
See #39896, #21666.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 00:22:49 +00:00
Weston Ruter
d8d8a01134 Customize: Fix jumping behavior upon scrolling up when a sticky header has its description expanded.
Props delawski.
See #34343, #41879.
Fixes #41850.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 18:55:47 +00:00
Weston Ruter
a83e4eb40e Customize: Fix WP_Customize_Date_Time_Control to be re-usable for plugins and custom settings.
* Allow time fields to be omitted by constructing with `timeIncluded` as `false`.
* Ensure `reportValidity` is only called on a control when it is in an expanded section.
* Rename "ampm" to "meridian".
* Improve accessibility and fix HTML validation and style issues for both the date/time control and the preview link control.
* Fix styling of dropdowns and clean CSS.
* Improve accessibility of nav menus component.

Props westonruter, afercia, sayedwp, melchoyce.
Amends [41626].
See #39896.
Fixes #42022.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41504 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 04:12:47 +00:00
Weston Ruter
728e44ab5a Customize: Add infrastructure for trashing/reverting of unpublished changes; introduce full-screen OverlayNotification for trashing and theme install/preview.
* Introduce a new `wp.customize.previewer.trash()` JS API to trash the current changeset, along with logic to `WP_Customize_Manager` to handle deleting changeset drafts.
* Add `trashing` to `wp.customize.state` which is then used to update the UI.
* UI for trashing is pending design feedback. One possibility is to add a new trash button to Publish Settings section that invokes `wp.customize.previewer.trash()`.
* Improve logic for managing the visibility and disabled states for publish buttons.
* Prevent attempting `requestChangesetUpdate` while processing and bump processing while doing `save`.
* Update `changeset_date` state only if sent in save response.
* Merge `ThemesSection#loadThemePreview()` into `ThemesPanel#loadThemePreview()`.
* Remove unused `autosaved` state.
* Start autosaving and prompting at beforeunload after a change first happens. This is key for theme previews since even if a user did not make any changes, there were still dirty settings which would get stored in an auto-draft unexpectedly.
* Allow `Notification` to accept additional `classes` to be added to `container`.
* Introduce `OverlayNotification` and use for theme installing, previewing, and trashing. Such overlay notifications take over the entire window.

Props westonruter, celloexpressions.
See #37661, #39896, #21666, #35210.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 03:37:46 +00:00
Weston Ruter
e90b5ee669 Customize: Remove unused JS variables to fix JSHint.
Amends [41649].
See #37661, #39896.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-29 22:04:47 +00:00
Weston Ruter
57044ac71e Customize: Improve interactions between the Themes panel and Publish Settings section.
* Deactivate the Themes panel immediately after changing selected status to non-publish.
* Animate publish settings button into view with publish button when collapsing Themes panel.
* Deactivate publish settings section and hide publish settings button entirely when customizer state is clean.
* Harden access of Themes panel in case it was removed by plugin.
* Fix throttling of `renderScreenshots` calls in `ThemesSection`.

Amends [41648], [41626].
See #37661, #39896, #34843.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-29 21:52:45 +00:00
Weston Ruter
76f590b99b Customize: Introduce a new experience for discovering, installing, and previewing themes within the customizer.
Unify the theme-browsing and theme-customization experiences by introducing a comprehensive theme browser and installer directly accessible in the customizer. Replaces the customizer theme switcher with a full-screen panel for discovering/browsing and installing themes available on WordPress.org. Themes can now be installed and previewed directly in the customizer without entering the wp-admin context. Also includes an extensible framework for browsing and installing themes from other sources.

Also includes CSS auto-prefixing added via `grunt precommit:css`.

For details, see: https://make.wordpress.org/core/2016/10/03/feature-proposal-a-new-experience-for-discovering-installing-and-previewing-themes-in-the-customizer/

Previously [38813] but reverted in [39140].
Fixes #37661, #34843, #38666.
Props celloexpressions, folletto, westonruter, karmatosed, melchoyce, afercia.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-29 20:13:50 +00:00
Weston Ruter
8043c2d8e5 Customize: Introduce drafting and scheduling for Customizer changesets.
* Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
* Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
* Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
* Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
* Introduces an `outer` section type (`wp.customize.OuterSection` in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
* Introduces `WP_Customize_Date_Time_Control` in PHP and `wp.customize.DateTimeControl` in JS for managing a date/time value.
* Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
* Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
* Starts a new changeset if attempting to save a changeset that was previously publish.
* Adds `force` arg to `requestChangesetUpdate()` to force an update request even when there are no pending changes.
* Adds utils methods for `getCurrentTimestamp` and `getRemainingTime`.
* Adds new state values for `selectedChangesetStatus`, `changesetDate`, `selectedChangesetDate`.
* Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
* Adds getter methods for `autosaved` and `branching` parameters, with the latter applying the `customize_changeset_branching` filter.
* Call to `establish_loaded_changeset` on the fly when `changeset_uuid()` is called if no changeset UUID was specififed.
* De-duplicates logic for dismissing auto-draft changesets.
* Includes unit tests.

Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 22:25:46 +00:00
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
58761c1ff2 Customize: Remove unnecessary call to refresh() a CodeMirror instance upon focus in Code Editor control.
This also fixes an issue with the cursor not being set in the expected location with an `inputStyle=contenteditable`.

Props afercia.
See #41897.
Fixes #41900.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-23 18:46:49 +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
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
d544ac92f0 Customize: Show notification error with "Your homepage displays" control when homepage and posts page are set to be the same (but not empty).
* Show global error notiafication when saving is blocked due to client-side setting invalidity.
* Refactor `wp.customize.Notifications#render()` to ensure a notification re-renders if its `message` or data changes but its `code` does not.

Props MatheusGimenez, sixhours, westonruter, karmatosed, aocean90, zoonini, michelleweber, melchoyce.
See #35210.
Fixes #21492.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-19 00:46:45 +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
f54cc32a6d Customize: Add rightward-facing back button to Themes section header to improve navigation (since the section slides in from the left).
Also serves to prototype for an upward-facing arrow in this location for a Publish Settings section.

Props melchoyce, westonruter.
See #39896, #40278, #21666.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-11 05:23:48 +00:00
Andrew Ozz
dcc372e098 Customizer: improve setting the TinyMCE modals z-index.
Props westonruter, greuben.
See #41158.
Built from https://develop.svn.wordpress.org/trunk@40995


git-svn-id: http://core.svn.wordpress.org/trunk@40845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-03 21:18:44 +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
Weston Ruter
2353930f90 Customize: Wait for processing state to clear before starting to captureSettingModifiedDuringSave.
See #32941.
Fixes #40729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40488 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 06:42:43 +00:00