Commit Graph

279 Commits

Author SHA1 Message Date
Andrew Nacin e7e922b356 Theme Customizer: As customize.php without a theme parameter defaults to the current theme, update wp_customize_url() to make $stylesheet optional and update references for the current theme.
see #19910, #20751, #20575.



git-svn-id: https://develop.svn.wordpress.org/trunk@20934 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-26 15:32:05 +00:00
Daryl Koopersmith e0fc4ce778 Hide 'Customize' toolbar item when customizer is not supported. fixes #20751, see #19910.
Removes script queue check for 'customize-loader' from wp_customize_support_script(), because we may want to check for customize-support on a page without the loader.


git-svn-id: https://develop.svn.wordpress.org/trunk@20918 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 22:26:00 +00:00
Daryl Koopersmith c88445c82d Theme Customizer: Improve default background property handling. see #20600, #19910.
If the custom background default wp-head-callback (_custom_background_cb) is used, we use postMessage for all custom background properties. Otherwise, we use full refreshes.

When using postMessage, the preview recalculates the custom background CSS block, allowing it to omit CSS values when they are not present and fall back on the original CSS.


git-svn-id: https://develop.svn.wordpress.org/trunk@20908 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 18:41:22 +00:00
Andrew Nacin 85eb57bd89 Preview by default the registered default image for custom backgrounds. props mfields, billerickson.
If there is a default color registered, show a 'Default' action rather than a 'Clear' action, as clearing the value would simply return to the default.

Make current_theme_supports() accept a second argument for 'custom-background' requests, the same as get_theme_support(). Missed in earlier changes, see #20249.

fixes #20734, fixes #18041.



git-svn-id: https://develop.svn.wordpress.org/trunk@20901 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 17:58:57 +00:00
Daryl Koopersmith b1a672cdfa Theme Customizer: Add CORS checks to the initial check for customize support. Prevents flash of customize links on large pages. see #20582, #19910.
Add wp_customize_support_script(), to quickly alter the body class based on whether customize is supported.


git-svn-id: https://develop.svn.wordpress.org/trunk@20893 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-25 00:15:12 +00:00
Daryl Koopersmith 779749b437 Theme Customizer: Fix hash-based loader fallbacks. see #20736, #19910, [20886].
git-svn-id: https://develop.svn.wordpress.org/trunk@20890 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-24 22:45:27 +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 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
Andrew Nacin aba958e81c Customize API shuffling.
* Rename WP_Customize to WP_Customize_Manager.
 * Move customize-controls.php to wp-admin/customize.php.
 * Make customize.php the formal entry point, rather than admin.php?customize=on.
 * Rename is_current_theme_active() to is_theme_active().
 * Add getters for the theme, settings, controls, and sections properties.
 * Allow customize.php (no ?theme=) to load the active theme. Not used yet.
see #20736.



git-svn-id: https://develop.svn.wordpress.org/trunk@20852 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-23 17:56:42 +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
Andrew Nacin bd4441edc6 display_header_text() should only return true if the theme mod value is not 'blank'. An empty string is valid -- there is no requirement for it to be truthy. see #18887. see #20600.
git-svn-id: https://develop.svn.wordpress.org/trunk@20772 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-11 19:55:07 +00:00
Andrew Nacin dd57074aed Make admin-head-callback optional for custom headers. Reverts part of [20684]. fixes #20603.
git-svn-id: https://develop.svn.wordpress.org/trunk@20712 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-03 13:30:55 +00:00
Andrew Nacin bf5decbacf Require both wp-head-callback and admin-head-callback for custom header theme support. fixes #20603.
git-svn-id: https://develop.svn.wordpress.org/trunk@20684 602fd350-edb4-49c9-b593-d223f7449a82
2012-05-02 15:16:48 +00:00
Andrew Nacin e55d1f54e2 Undeprecate require_if_theme_supports() for themes using it for legitimate reasons. see [20610]. props scribu, jkudish. fixes #20556.
git-svn-id: https://develop.svn.wordpress.org/trunk@20642 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-30 02:02:11 +00:00
Andrew Nacin 98f553c3b2 Deprecate require_if_theme_supports(). Always require post-thumbnail-template.php. fixes #20556. fixes #20409.
git-svn-id: https://develop.svn.wordpress.org/trunk@20610 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-27 04:54:36 +00:00
Andrew Nacin 60e9ca67ec Initialize the WP_Customize class in a prefixed global. props mattonomics. fixes #20465.
git-svn-id: https://develop.svn.wordpress.org/trunk@20600 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-25 21:30:02 +00:00
Andrew Nacin 23755473ac If a cached theme root is no longer registered, skip it. Assume the cache is out of date. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20551 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-20 13:22:54 +00:00
Andrew Nacin 66bea4d318 Always return a WP_Theme object from wp_get_theme(). If we can't find the theme root, assume the default theme root. (Which will probably result in a WP_Theme object that returns false for the exists() method, which is fine.) see #20361.
git-svn-id: https://develop.svn.wordpress.org/trunk@20524 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-19 03:33:42 +00:00
Daryl Koopersmith e5a53305a2 Theme Customizer: Remove unused 'template' argument from wp_customize_url. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20520 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-18 20:57:06 +00:00
Andrew Nacin bfae415dd9 Move to admin.php?customize=on&theme=$stylesheet, rather than juggling both template and stylesheet values. see #19910.
Combine the setup_theme() and customize_previewing() methods. Remove the set_template() and set_stylesheet() methods. Add set_theme() method to WP_Customize to store the working WP_Theme object. We will use this for the stylesheet and template.

Use the WP_Theme display() method when preparing headers for display, not get() or the deprecate properties.



git-svn-id: https://develop.svn.wordpress.org/trunk@20496 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-17 21:43:47 +00:00
Daryl Koopersmith bb5254fe36 Theme Customizer: Integrate with browser history. Use window.history by default, with window.onhashchange as a fallback. fixes #20337, see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20488 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-16 23:07:23 +00:00
Andrew Nacin 266a785f77 Theme Customizer: Stick to wp_customize_url() instead of wp_customize_href(). Switch argument order so it is stylesheet-template. (Template is hypothetically optional, but the function will not support that.) see #19910.
Move to ->display('Name'), as ->get('Name') is a raw, untranslated version of the header.



git-svn-id: https://develop.svn.wordpress.org/trunk@20477 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-16 14:36:47 +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 955ca76116 Replace all instances of thickbox theme preview with the theme customizer. fixes #20404.
* Use theme customizer in theme install/update screens.
* Separate the customize loader from the customizer. Use wp_customize_loader() to include the loader script and markup.
* Deprecated: wp-admin/js/theme-preview.js is now no longer used by core.

git-svn-id: https://develop.svn.wordpress.org/trunk@20419 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-10 02:25:03 +00:00
Andrew Nacin 6e3ed8bbf9 Internally cache themes inside wp_get_themes() by theme_root as well as stylesheet, to avoid conflicts with future calls to wp_get_themes(). Always return only the last stylesheet found, as before. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20375 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-05 20:38:42 +00:00
Andrew Nacin f9a131231d Always return a WP_Theme object from wp_get_theme(). Check \$theme->exists() or \$theme->errors() to confirm the requested theme actually exists. see #20361.
git-svn-id: https://develop.svn.wordpress.org/trunk@20363 602fd350-edb4-49c9-b593-d223f7449a82
2012-04-05 01:05:49 +00:00
Peter Westwood efdcdfdf36 Avoid fatal errors in check_theme_switched() if we fail to get a WP_Theme object for the old theme. Fixes #20334.
git-svn-id: https://develop.svn.wordpress.org/trunk@20330 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-30 15:13:12 +00:00
Andrew Nacin 09f946105d Clear theme cache after editing. Reduce default cache persistence to 1800. (Could go lower.) see #20331.
git-svn-id: https://develop.svn.wordpress.org/trunk@20328 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-30 14:39:05 +00:00
Andrew Nacin ef6be74a33 Introduce WP_Theme->exists() to check if the queried theme actually exists. WP_Theme->exists() is a subset of errors() -- a theme with errors may still exist, but a theme that does not exist has an error of theme_not_found. wp_get_theme() now returns false if the theme does not exist. Improve scandir() and get_files() logic. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20312 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-29 02:59:48 +00:00
Andrew Nacin f9d787fae1 Deprecate get_theme_data(). Use wp_get_theme() instead. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20269 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-23 10:21:24 +00:00
Andrew Nacin b7e526d2ce Introduce display_header_text(). props chipbennett for initial patch. see #18887.
git-svn-id: https://develop.svn.wordpress.org/trunk@20240 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-21 18:48:57 +00:00
Andrew Nacin 1872a4a8fc WP_Theme::get_allowed_on_network() doesn't take a blog_id argument. props duck_. Restore static declaration accidentally removed in [20193]. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20238 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-21 17:32:28 +00:00
Andrew Nacin 67f21026b9 Callbacks for custom headers and custom backgrounds registered through add_theme_support() are now wp-head-callback, admin-head-callback, and admin-preview-callback. see #19910.
git-svn-id: https://develop.svn.wordpress.org/trunk@20231 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-21 03:36:17 +00:00
Andrew Nacin 1c04dd0576 In new add_theme_support() logic, fix logic inversion, define HEADER_IMAGE in a simpler way, and force args to be an array. see #20249.
git-svn-id: https://develop.svn.wordpress.org/trunk@20221 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-20 20:34:49 +00:00
Andrew Nacin 4642f9d093 Deprecate add_custom_image_header(), remove_custom_image_header(), add_custom_background(), remove_custom_background(). Replacements are add_theme_support() and remove_theme_support(). see #20249.
git-svn-id: https://develop.svn.wordpress.org/trunk@20218 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-19 21:14:41 +00:00
Andrew Nacin 43cd1ca516 The word 'support' does not have a overly long 'p'. see #20249.
git-svn-id: https://develop.svn.wordpress.org/trunk@20214 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-19 18:00:27 +00:00
Andrew Nacin ad5a3736e6 Fix copy-paste issue. see #20249.
git-svn-id: https://develop.svn.wordpress.org/trunk@20213 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-19 17:15:30 +00:00
Andrew Nacin 070a9e5c59 Introduce new registration methods for custom headers and custom backgrounds. Backwards compatible, but old methods will be deprecated. see #20249. see #17242.
Custom header: Use add_theme_support('custom-header', $args) instead of add_custom_image_header(). Deprecates all use of constants.
 * HEADER_TEXTCOLOR is now (string) 'default-text-color'.
 * NO_HEADER_TEXT is nowi ! (bool) 'header-text'.
 * HEADER_IMAGE_WIDTH (and _HEIGHT) are now (int) 'width' and 'height'.
 * HEADER_IMAGE is now (string) 'default-image'.
 * The 3.4 arguments 'suggested-width' and 'suggested-height' are now just 'width' and 'height' (they are "suggested" when flex-width and flex-height are set).
 * Callback arguments for add_custom_image_header() can now be passed to add_theme_support().

Custom background: Use add_theme_support('custom-background, $args) instead of add_custom_background(). Deprecates all use of constants.
 * BACKGROUND_COLOR is now (string) 'default-color'.
 * BACKGROUND_IMAGE is now (string) 'default-image'.
 * Callback arguments for add_custom_background() can now be passed to add_theme_support().

Inheritance: add_theme_support() arguments for custom headers and custom backgrounds is a first-one-wins situation. This is not an unusual paradigm for theming as a child theme (which is included first) overrides a parent theme.
 * Once an argument is explicitly set, it cannot be overridden. You must hook in earlier and set it first.
 * Any argument that is not explicitly set before WP is loaded will inherit the default value for that argument.
 * It is therefore possible for a child theme to pass minimal arguments as long as the parent theme specifies others that may be necessary.
 * Allows for a child theme to alter callbacks for <head> and preview (previously, calling add_custom_image_header more than once broke things).
 * The just-in-time bits ensure that arguments fall back to default values, that the values of all constants are considered (such as one defined after an old add_custom_image_header call), and that all constants are defined (so as to be backwards compatible).

get_theme_support(): Introduce new second argument, which headers and backgrounds leverage to return an argument. current_theme_supports() already supported checking the truthiness of the argument.
 * For example, get_theme_support( 'custom-header', 'width' ) will return the width specified during registration.
 * If you had wanted the default image, use get_theme_support( 'custom-header', 'default-image' ) instead of HEADER_IMAGE. 

Deprecate remove_custom_image_header(), remove_custom_background(). Use remove_theme_support('custom-header'), 'custom-background'.

Deprecate short-lived custom-header-uploads internal support; this is now (bool) 'uploads' for add_theme_support().

New 3.4 functions renamed or removed: Rename get_current_header_data() to get_custom_header(). Remove get_header_image_width() and _height() in favor of get_custom_header()->width and height.



git-svn-id: https://develop.svn.wordpress.org/trunk@20212 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-19 17:12:44 +00:00
Andrew Nacin e71167bbee Updates to WP_Theme, wp_get_themes(), and related deprecated functions, after [UT570] [UT578] [UT579]. see #20103.
* ['Template Files'] and ['Stylesheet Files'] need to return files from the parent theme as well.
 * Don't strip links from the Author header. Some themes rely on the previous behavior, such as to link multiple authors (Sandbox, for example.) Don't restore links to the Name, that's just a bad idea.
 * Ensure we are always passing around arrays in get_files/scandir.
 * Better inline doc for wp_get_themes() arguments.
 * Introduce a 'force' flag for search_theme_directories() to re-scan, rather than return the cache. We will use this to re-build the theme_roots transient in get_theme_roots(), but it is more helpful for unit tests. Since search_theme_directories() is cached, don't cache again in wp_get_themes(). (Again benefits testing.)
 * Handle duplicate theme names in the old get_themes() when two themes match (and neither are a default theme, which is already handled). wp_get_themes() will consider both names to be the same; this is just for back compat since get_themes() is keyed by name.
 * Include an old array key in wp_broken_themes().



git-svn-id: https://develop.svn.wordpress.org/trunk@20193 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-15 15:39:21 +00:00
Andrew Nacin 746cb153c1 Store stylesheet rather than theme name in the theme_switched option. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20163 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-08 21:22:24 +00:00
Andrew Nacin 9a484c5f35 Pass WP_Theme->get_theme_root_uri() to get_theme_root_uri(), thereby always triggering the theme_root_uri filter. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20162 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-08 18:18:10 +00:00
Andrew Nacin d501284378 Use correct variable. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20161 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-08 18:00:11 +00:00
Andrew Nacin 47dd0db830 In wp_get_themes() under multisite, filter out allowed themes before creating WP_Theme objects, rather than after. search_theme_directories() provides us the stylesheet of each theme which is all we need to do the proper intersection. This results in major performance gains on sites that have large numbers of themes unavailable to them. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20152 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-08 07:46:39 +00:00
Andrew Nacin 6cd720e183 Store relative-to-wp-content theme roots, as that is what get_theme_roots() should be receiving. see #20103.
Since search_theme_directories() now generates this and leverages this as a cache, convert absolute to relative on cache storage, and relative to absolute on cache retrieval.



git-svn-id: https://develop.svn.wordpress.org/trunk@20118 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-06 01:50:54 +00:00
Andrew Nacin 22f5bd4655 Cast $wp_theme_directories to array. This had been done in get_themes(). A must-loaded plugin could call these functions before the first theme root is ever added. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20116 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-05 17:30:09 +00:00
Andrew Ozz 5d4a0adebd Don't pass non-existing rtl stylesheet to TinyMCE, update phpdoc for add_editor_style(), see #19437
git-svn-id: https://develop.svn.wordpress.org/trunk@20059 602fd350-edb4-49c9-b593-d223f7449a82
2012-03-01 00:18:26 +00:00
Andrew Nacin b57da5a92a Strict comparisons for the $allowed arg for wp_get_themes(). Otherwise 'network' does == true. see #20103.
git-svn-id: https://develop.svn.wordpress.org/trunk@20053 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 23:04:25 +00:00
Andrew Nacin 6a4a8df204 Deprecate get_current_theme(). Use (string) wp_get_theme() to get the translated name of the theme. Keep the current_theme option for now. see #20103, see #20138.
git-svn-id: https://develop.svn.wordpress.org/trunk@20040 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 20:07:22 +00:00
Andrew Nacin 7253e53962 Update switch_theme() to use wp_get_theme(). see #20103, #20138.
git-svn-id: https://develop.svn.wordpress.org/trunk@20033 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-29 05:09:29 +00:00
Andrew Nacin 53a209a4ee Introduce WP_Theme, wp_get_themes(), and wp_get_theme() to replace get_themes(), get_theme(), get_theme_data(), current_theme_info(), and others.
* Getters and Helpers: Introduces a series of methods to allow for easy generation of headers for display, and other theme metadata, including page templates.
 * Screenshots: Handles support for multiple screenshots. (see # Additional screenshots must be PNG and start with screenshot-2.png, and be sequential to be counted. see #19816.
 * Error Handling: Broken themes have a WP_Error object attached to them.
 * Caching: Introduces a wp_cache_themes_persistently filter (also in [20020]) to enable persistent caching of all filesystem and sanitization operations normally handled by WP_Theme (and formerly get_file_data() and get_themes()). Themes are cached individually and across five different cache keys for different data pieces.
 * Compatibility: A WP_Theme object is backwards compatible with a theme's array formerly returned by get_themes() and get_theme(), and an stdClass object formerly returned by current_theme_info().
 * i18n/L10n: Theme headers are now localizable with proper Text Domain and Domain Path headers, like plugins. (Language packs may remove the requirement for headers.) For page templates, see #6007 (not fixed yet, but will be easy now). For headers, fixes #15858.
 * PHP and CSS files: New methods that fetch a list of theme files (for the theme editor) only on demand, rather than only loading them into memory. fixes #11214.

Functions deprecated:
 * get_themes(), get_allowed_themes() and get_broken_themes() -- use wp_get_themes()
 * get_theme() and current_theme_info() -- use wp_get_theme()
 * get_site_allowed_themes() -- use WP_Theme::get_allowed_on_network()
 * wpmu_get_blog_allowedthemes() -- use WP_theme::get_allowed_on_site()

see also [20016], [20018], [20019], [20020], [20021], [20022], [20025], [20026], [20027]. also fixes #19244.

see #20103.



git-svn-id: https://develop.svn.wordpress.org/trunk@20029 602fd350-edb4-49c9-b593-d223f7449a82
2012-02-28 21:24:44 +00:00