Commit Graph

51 Commits

Author SHA1 Message Date
Daryl Koopersmith 771ca21787 Theme Customizer: Ensure that JS color controls always use real color values, even if the server-side value is a hex value without a hash. fixes #20448, see #19910.
Adds WP_Customize_Setting->sanitize_js_callback and 'customize_sanitize_js_$settingID' filter, to filter values before they're passed to JS using WP_Customize_Setting->js_value().

Adds support for regular hex colors to the color picker.

Changes color methods:
* sanitize_hex_color() accepts 3 and 6 digit hex colors (with hashes) and the empty string.
* sanitize_hex_color_no_hash() accepts 3 and 6 digit hex colors (without hashes) and the empty string.
* maybe_hash_hex_color() ensures that a hex color has a hash, and otherwise leaves the value untouched.


git-svn-id: https://develop.svn.wordpress.org/trunk@20936 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-26 18:44:31 +00:00
Daryl Koopersmith 83c45f9d04 Theme Customizer: Fix IE8 drag/drop uploader incompatibility. see #20582, #19910.
Bind drag/drop support checks to individual plupload instances.
Add drag-over classes to wp.Uploader and corresponding styles to customize image controls.


git-svn-id: https://develop.svn.wordpress.org/trunk@20928 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-26 05:55:40 +00:00
Daryl Koopersmith 0847bf3b89 Theme Customizer: Add a signature to preview requests to be super-double-ultra-sure that the customizer generated the preview. Redirects can be sneaky. fixes #20507, see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20925 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-26 04:08:44 +00:00
Daryl Koopersmith b1e5b31c58 Theme Customizer: Improve background image control, add correct meta key to custom headers and backgrounds uploaded using the customizer. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20913 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 20:26:25 +00:00
Daryl Koopersmith d49df83c8c Theme Customizer: Improve activate and publish flow, make customizer states easier to track. fixes #20743, see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20899 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 17:42:06 +00:00
Daryl Koopersmith acdce48f5c Theme Customizer: Check for CORS support when the preview and admin urls are cross-domain. Add a fallback to the customize control frame, and check support there as well. see #20582, #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20886 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-24 21:13:21 +00:00
Daryl Koopersmith b0a9ad5216 Theme Customizer: Improve accuracy of identifying internal urls. see #20507, #19910.
The 'customize_preview_link' filter has been replaced by 'customize_allowed_urls'.
Improved accuracy when checking for wp-admin.
Improved accuracy when attempting to match the schemes of the control and preview frames.
Improved accuracy of internal link whitelist.


git-svn-id: https://develop.svn.wordpress.org/trunk@20882 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-24 19:17:49 +00:00
Daryl Koopersmith 4b9f6216e9 Theme Customizer: Change 'Return to...' link to 'Cancel' and move 'Save' button to header. props helenyhou, fixes #20692, see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20864 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-24 03:29:51 +00:00
Daryl Koopersmith dde6d026cf Theme Customizer: Properly handle redirects in the preview by setting wp_redirect_status to 200. props nacin, see #20507, #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20861 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-24 01:48:32 +00:00
Ryan Boren fd6d65117c Accordion for the customizer. Props markjaquith. fixes #20700
git-svn-id: https://develop.svn.wordpress.org/trunk@20837 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-21 19:53:22 +00:00
Daryl Koopersmith 0e3b3a7555 Theme Customizer: Add 'ready' event to customize-controls. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20816 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-17 00:00:57 +00:00
Daryl Koopersmith 5c77fcc30b Theme Customizer: Properly change state when theme is switched. fixes #20610, see #19910.
* Causes the Manage Themes page to refresh if the customizer is closed after the active theme is switched.
* Changes the text of the 'Save and Activate' button once the theme has been activated.
* Improves the naming of the customize control settings.
* Add events to customize.Loader and make callbacks more flexible.
* Makes the customize-loader l10n compatible with non-admin settings.
* Adds WP_Customize->is_current_theme_active().
* Minor style corrections, including jQuery.attr/prop changes.



git-svn-id: https://develop.svn.wordpress.org/trunk@20802 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-16 05:55:54 +00:00
Daryl Koopersmith 1a2375b4ee Theme Customizer: Clarify wp.customize.Values API by removing Values.pass and all methods that passed through to the wp.customize.Value objects it contained. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20798 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-15 22:14:46 +00:00
Daryl Koopersmith 476314ad8b Theme Customizer: Add a fallback UI for browsers that do not support drag and drop upload. see #19910, #20452, #20582.
git-svn-id: https://develop.svn.wordpress.org/trunk@20761 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-10 00:15:53 +00:00
Daryl Koopersmith 971dc88583 Uploader & Theme Customizer: Refresh uploader flash/silverlight shims when the mouse enters the browse button. Add class to body based on uploader's drag/drop support. Properly assign customize image uploader containers (so flash shims are positioned correctly when scrolled). see #19910, #20452, #20582.
git-svn-id: https://develop.svn.wordpress.org/trunk@20758 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-09 21:26:19 +00:00
Daryl Koopersmith 7739e9186d Theme Customizer: Maintain scrolled position when preview performs a full refresh. Allow wp.customize.Messenger to send/receive falsy values. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20745 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-09 00:23:05 +00:00
Daryl Koopersmith 320916cc53 Theme Customizer: Add cross-domain handling for when the admin and front-end are different origins. Handles both ajax and postMessage calls. props rboren, mdawaffe, nacin. see #20507, #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20741 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-08 20:13:34 +00:00
Daryl Koopersmith 7fde7c1904 Theme Customizer: Use a internal global _wpCustomizeSettings object for wp.customize.settings to prevent script race conditions in IE (which blocked interaction with the preview). see #20582, #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20737 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-07 20:03:39 +00:00
Daryl Koopersmith 3540b301af Theme Customizer: Migrate to an ajax-based solution for refreshing the preview and saving. see #20507, #19910.
* Use ajax-based saving, add saving indicator.
* Use ajax-based refreshing instead of form targets.
* Instead of using hidden inputs with prefixed names to track the canonical data, use the values stored in wp.customize. Encode the values as JSON before sending to avoid bugs with ids that contain square brackets (PHP mangles POST values with nested brackets).
* Use wp.customize.Previewer solely for the purpose of previewing; move the postMessage connection with the parent frame and other unrelated code snippets into the 'ready' handler.


git-svn-id: https://develop.svn.wordpress.org/trunk@20645 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-30 15:46:17 +00:00
Daryl Koopersmith 092d648b8a Theme Customizer: Add statuses to the color and image controls. see #19910.
Move the color control from the switch statement to WP_Customize_Color_Control.
Markup improvements.


git-svn-id: https://develop.svn.wordpress.org/trunk@20598 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-25 21:03:29 +00:00
Daryl Koopersmith dfd80ddc57 Theme Customizer: For clarity, wp.customize.Setting.method to wp.customize.Setting.transport. Add WP_Customize_Setting->transport to allow setting the transport method via PHP. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20585 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-25 16:04:51 +00:00
Daryl Koopersmith e2bbb75ba5 Theme Customizer: Improve image picker control. see #19910.
Overhauled image pickers:
* Add support for drag and drop uploads to image controls.
* Improve the 'uploaded' tab in image controls: automatically add images uploaded during the current session, hide the tab when no uploaded images exist.
* Move the header image control to the WP_Customize_Header_Image_Control class. Remove wp_customize_print_uploaded_headers() and wp_customize_print_uploaded_headers() functions.
* Abstract the dropdown functionality from the color picker to the .dropdown class.
* In wp.Uploader, unset element keys if passed an empty jQuery collection.



git-svn-id: https://develop.svn.wordpress.org/trunk@20545 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-20 02:39:55 +00:00
Daryl Koopersmith ae95c22e27 Remove 'visibility' parameter from WP_Customize_Control. Handle control visibility in JS instead. see #19910.
* Have the header text color picker display only when header_textcolor != 'blank'



git-svn-id: https://develop.svn.wordpress.org/trunk@20506 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-18 17:13:31 +00:00
Daryl Koopersmith fc4837eb62 Theme Customizer: Improve markup/styles for opened color picker. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20504 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-18 14:32:05 +00:00
Daryl Koopersmith c7c8d0a2d6 Theme Customizer: Improve color picker toggle styles and markup. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20497 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-17 22:58:58 +00:00
Daryl Koopersmith a43958baeb Theme Customizer: Allow the customize iframe to be accessed directly (with full feature support). see #19910.
* Move the 'Return to Manage Themes' and 'Collapse Sidebar' actions from themes.php to customize-controls.php.
* Create a postMessage connection between themes.php and customize-controls.php.
* Allow the theme customizer to be accessed directly (independent of themes.php and the customize loader).
* Add wp_customize_href() and wp_customize_url().
* Remove wp_customize_loader(). To include the loader, use wp_enqueue_script( 'customize-loader' ).
* The theme customizer now requires postMessage browser support.
* Add .hide-if-customize and .hide-if-no-customize CSS classes.
* Clean up customize-preview.js.

git-svn-id: https://develop.svn.wordpress.org/trunk@20476 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-16 14:02:28 +00:00
Daryl Koopersmith 9218ead840 Theme Customizer: Improve data binding in wp.customize.Value and wp.customize.Values. see #19910.
* Replace the convoluted wp.customize.Value.link method with a simple shortcut for direct binding.
* Add wp.customize.Value.sync for bidirectional linking.
* Add wp.customize.Value.setter for handling compound values (instead of using wp.customize.Value.link).

git-svn-id: https://develop.svn.wordpress.org/trunk@20344 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-03 22:04:40 +00:00
Daryl Koopersmith bdee6c8e15 Theme Customizer: Move upload and image controls to subclasses. see #19910.
Instead of grouping together every control parameter into a single  array and passing them all to the JS, use subclasses with custom parameters to implement additional PHP functionality and the  parameter to send only the necessary variables to the JavaScript control.

Replaces WP_Customize_Control->control_params with WP_Customize_Control->json and WP_Customize_Control->to_json(). The to_json() method refreshes the json array passed to the JavaScript control (set to control.param by default).

Creates WP_Customize_Upload_Control and WP_Customize_Image_Control.

git-svn-id: https://develop.svn.wordpress.org/trunk@20319 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-29 06:35:54 +00:00
Daryl Koopersmith d5f5376394 Theme Customizer: Properly bind the 'upload new' and 'remove image' actions in the image picker. see #19910.
This occurred because we weren't calling UploadControl.ready (where the actions are declared and the uploader is initialized) in ImageControl.ready.

git-svn-id: https://develop.svn.wordpress.org/trunk@20301 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-28 09:33:32 +00:00
Daryl Koopersmith ea85772eb6 Theme Customizer: Sanitize selectors by transforming square brackets into dashes. see #19910.
This both better conforms to the CSS spec and prevents bugs from occurring in JavaScript selector engines.

git-svn-id: https://develop.svn.wordpress.org/trunk@20299 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-28 09:10:29 +00:00
Daryl Koopersmith 1a03f9af0d Theme Customizer: Fix postMessage for background_color. The method parameter affects settings, not controls. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20297 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-28 08:55:25 +00:00
Daryl Koopersmith 2ca07cdf2a Create WP_Customize_Control to separate the process of rendering a control from fetching, previewing, and saving its values. see #19910.
Many-to-many mapping between settings and controls.
* Settings and controls have been separated in both the PHP (WP_Customize_Setting, WP_Customize_Control) and the JS (wp.customize.Setting, wp.customize.Control).
* While most settings are tied to a single control, some require multiple controls. The 'header_textcolor' control is a good example: to hide the header text, header_textcolor is set to 'blank'.

Add 'Display Header Text' control.

A handful of miscellaneous bugfixes along the way.

Notes:
* Controls should be separated out a bit more; juggling type-specific arguments in the switch statement is rather inelegant.
* Page dropdowns are currently inactive and need to be re-linked.

git-svn-id: https://develop.svn.wordpress.org/trunk@20295 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-28 04:14:09 +00:00
Daryl Koopersmith d8513a5ebb Theme Customizer: Add 'choose image' functionality to image controls. Rough first pass, using header images as an example. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20290 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-25 21:18:32 +00:00
Daryl Koopersmith e0773710ec Theme Customizer: First pass at image controls. Use header_image as the initial case. Add a 'removed' control param for upload/image controls to map 'removed' to a value other than the empty string. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20278 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-24 04:35:13 +00:00
Daryl Koopersmith b0f973d884 Theme Customizer: Add WP_Customizer_Setting->control_params, and wp.customize.Control.params to allow settings to pass arbitrary parameters to controls. Add the 'context' parameter to wp.customize.UploadControl. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20276 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-24 01:02:29 +00:00
Daryl Koopersmith c41689115f Theme Customizer: Change 'Random Image' control to be a proper 'Header Image' control. First step to integrating header images. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20274 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-23 22:43:00 +00:00
Daryl Koopersmith 95ab797033 Theme Customizer: Add background repeat, position, and attachment settings. Change visibility parameter to accept a string or array( , ). see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20263 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-22 08:07:44 +00:00
Daryl Koopersmith f28d57454f Theme Customizer: Only show uploader 'remove' links when there is an image to remove. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20261 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-22 07:30:44 +00:00
Daryl Koopersmith 7dc476bd8b Theme Customizer: Add a WP_Customize_Setting->visibility parameter to show/hide a control based upon the value of another control. Also shifts rendering the setting wrapper element into WP_Customize_Setting->render() and adds WP_Customize_Setting->render_content(). see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20260 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-22 07:17:26 +00:00
Daryl Koopersmith f561219e0b Theme Customizer: Ensure background_color and background_image exist instead of blindly attempting to access their controls. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20259 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-22 07:03:44 +00:00
Daryl Koopersmith 44880bceb5 Theme Customizer: Plupload does not support objects in its multipart_params setting (which causes exceptions in Firefox). Use multidimensional keys to circumnavigate this issue. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20253 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-22 03:58:06 +00:00
Daryl Koopersmith d254551dd7 Theme Customizer: First pass for upload controls, using background image as an example. Add a wrapper for Plupload that allows for custom upload UIs. see #19910.
wp.Uploader is a wrapper that provides a simple way to upload an attachment (using the wp_ajax_upload_attachment handler). It is intentionally decoupled from the UI. When an upload succeeds, it will receive the attachment information (id, url, meta, etc) as a JSON response. If the upload fails, the wrapper handles both WordPress and plupload errors through a single handler.

As todos, we should add drag classes for the uploader dropzone and account for the rough 100mb filesize limit in most browsers. The UI for the customizer upload controls could be improved as well.

git-svn-id: https://develop.svn.wordpress.org/trunk@20179 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-15 04:14:05 +00:00
Daryl Koopersmith 21e5a2e69e Theme Customizer: Add a Control object to better encapsulate different UI elements and make it easy to switch between hard refreshes and postMessage. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20128 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-06 22:48:07 +00:00
Daryl Koopersmith e11e5445e9 Theme Customizer: First pass at using postMessage for background color. Fix instance where preview.targetWindow would become inaccurate. Initialize setting values in customize-preview.js. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20123 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-06 02:49:02 +00:00
Daryl Koopersmith e841432c7c Theme Customizer: Ensure color pickers initialize to the correct color. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20121 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-06 02:14:27 +00:00
Daryl Koopersmith c7769fabfd Theme Customizer: Add working color pickers. First pass. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20120 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-06 02:03:50 +00:00
Daryl Koopersmith b908add2c2 Theme Customizer: Improve form markup. Make the theme title/author a section. Prevent section arrows from blocking clicks. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20106 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-04 02:06:11 +00:00
Daryl Koopersmith fff67f819c Theme Customizer: Bind the preview iframe load event when triggering refresh instead of when creating the iframe. see #19910.
The loaded event should only fire when we've actually triggered a refresh. If loaded is bound when the iframe is created, sometimes the blank iframe will fire a 'load' event before a refresh is triggered (this occurred with relative frequency in firefox). By binding the loaded event in the refresh function, we prevent this from occurring.

git-svn-id: https://develop.svn.wordpress.org/trunk@20049 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 22:24:46 +00:00
Daryl Koopersmith 0d1e599420 Theme Customizer: Don't switch themes and update settings when the enter key is pressed. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20035 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 06:28:02 +00:00
Daryl Koopersmith 78bf972b68 Improve page loads in the theme customizer by layering loading iframes. Automate refreshing, but debounce multiple refresh events to prevent hammering the server with requests. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20031 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 01:17:21 +00:00