Commit Graph

79 Commits

Author SHA1 Message Date
Weston Ruter
5dae1386aa Customize: Ensure that a setting (especially a multidimensional one) can still be previewed when the post value to preview is set after preview() is invoked.
* Introduce `customize_post_value_set_{$setting_id}` and `customize_post_value_set` actions which are done when `WP_Customize_Manager::set_post_value()` is called.
* Clear the `preview_applied` flag for aggregated multidimensional settings when a post value is set. This ensures the new value is used instead of a previously-cached previewed value.
* Move `$is_preview` property from subclasses to `WP_Customize_Setting` parent class.
* Deferred preview: Ensure that when `preview()` short-circuits due to not being applicable that it will be called again later when the post value is set.
* Populate post value for updated-widget with the (unsanitized) JS-value in `WP_Customize_Widgets::call_widget_update()` so that value will be properly sanitized when accessed in `WP_Customize_Manager::post_value()`.

Includes unit tests with assertions to check the reported issues and validate the fixes.

Fixes defect introduced in [35007].
See #32103.
Fixes #34738.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-21 02:52:27 +00:00
Scott Taylor
21d74f5b1d Customize: move WP_Customize_Setting subclasses to wp-includes/customize, they load in the exact same place.
See #34432.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-24 18:11:24 +00:00
Weston Ruter
d7e13544ea Customizer: Prevent nav_menu_item settings from becoming dirty when their controls are set up.
Since `wp_setup_nav_menu_item()` returns the `classes` property as an array but the Customizer manages the value as a string, the setting needs to initially export the value as a string. This prevents the `classes` property type change from causing the setting to get marked as dirty even though nothing changed. This is a regression from [34788].

See #34111.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-20 22:45:29 +00:00
Weston Ruter
c77bb38b3d Customizer: Allow new option settings to not be saved as autoloaded by passing an autoload arg value of false.
The `autoload` argument value is passed along to `update_option()` which has accepted an `$autoload` parameter since [31628].

Props westonruter, dlh.
See #26394.
Fixes #33499.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-20 21:19:25 +00:00
Weston Ruter
6d9d18315d Customizer: Implement indicators for invalid nav menu items.
The same indicator on the nav menus admin page is now present for nav menu items in the Customizer. When a menu item is present for a post type that is no longer registered, the menu item will appear with the indicator.

Props kucrut, westonruter.
Fixes #33665.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-20 19:08:25 +00:00
Weston Ruter
1fe64b1c65 Customizer: Fix scalability performance problem for previewing multidimensional settings.
As the number of multidimensional settings (serialized options and theme mods) increase for a given ID base (e.g. a widget of a certain type), the number of calls to the `multidimensional` methods on `WP_Customize_Setting` increase exponentially, and the time for the preview to refresh grows in time exponentially as well.

To improve performance, this change reduces the number of filters needed to preview the settings off of a multidimensional root from N to 1. This improves performance from `O(n^2)` to `O(n)`, but the linear increase is so low that the performance is essentially `O(1)` in comparison. This is achieved by introducing the concept of an "aggregated multidimensional" setting, where the root value of the multidimensional serialized setting value gets cached in a static array variable shared across all settings.

Also improves performance by only adding preview filters if there is actually a need to do so: there is no need to add a filter if there is an initial value and if there is no posted value for a given setting (if it is not dirty).

Fixes #32103.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 09:06:25 +00:00
Weston Ruter
0b93819465 Customizer: Ensure WP_Customize_Setting::update() returns boolean value.
Adds unit tests for `WP_Customize_Setting::save()` (and `WP_Customize_Setting::update()`), along with the actions `customize_update_{$type}`, and `customize_save_{$id_base}` which they trigger.

Fixes #34140.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-05 21:58:24 +00:00
Scott Taylor
44dace3487 Add Customizer docs.
Props ericlewis.
See #33503.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-05 19:53:24 +00:00
Weston Ruter
bf9d1485ee Customizer: Ensure that all existing menus are shown in the Custom Menu widget's dropdown.
* Ensure that a Custom Menu widget selecting a newly-inserted menu gets updated to use the new menu ID upon Save & Publish.
* Dynamically update the visibility of the Custom Menu widget's "no menus" message when the number of menus changes between 0 and 1+.
* Send all dirty Customized settings in `update-widget` Ajax request and `preview()` them so that the widget update/form callbacks have access to any data dependencies in the current Customizer session (such as newly created unsaved menus).
* Update link in Custom Menu widget to point to Menus panel as opposed to Menus admin page, when in the Customizer.
* Fix an issue with extra space at top immediately after creating new menu.
* Fix doubled `update-widget` Ajax requests when changing select dropdown; prevent initial from being aborted.
* Add missing `wp_get_nav_menus()` hooks to preview Customizer updates/inserts for `nav_menu` settings; includes tests.
* Update `wp_get_nav_menu_object()` to allow a menu object to be passed in (and thus passed through).

Props westonruter, adamsilverstein.
Fixes #32814.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-29 16:03:24 +00:00
Aaron Jorbin
d8eaaf66df Use explicit variable variable syntax
PHP7 introduces a backwards compatable change to variable varibale syntax that requires us to use curly brackets to maintain the syntax between php5 and php7.  For more info, see https://wiki.php.net/rfc/uniform_variable_syntax#semantic_differences_in_existing_syntax for the semantic differences.  

Props ocean90
Fixes #31982


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


git-svn-id: http://core.svn.wordpress.org/trunk@33394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-26 18:04:26 +00:00
Weston Ruter
d5ce83c94c Customizer: Introduce customize_nav_menu_available_item_types and customize_nav_menu_available_items filters.
Allows for new available menu item types/objects to be registered in addition to filtering the available items that are returned for each menu item type/object.

Props valendesigns, imath, westonruter.
See #32832.
Fixes #32708.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-22 20:29:25 +00:00
Weston Ruter
c5bd85552e Customizer: Improve performance of menus by caching results of wp_setup_nav_menu_item() calls.
Also fixes property list in phpdoc for `wp_setup_nav_menu_item()`.

Fixes #32769.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-14 07:09:24 +00:00
Drew Jaynes
c6cff377e7 Fix syntax and add missing @access tags to a variety of methods and properties in WP_Customize_Nav_Menu_Item_Setting added in 4.3.
See [32806]. See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:01:25 +00:00
Weston Ruter
912b434198 Customizer: Fix saving menus with empty names or names that are already used.
Adds validation for initially-supplied nav menu name, blocking empty names from being supplied. If later an empty name is supplied and the nav menu is saved, the name "(unnamed)" will be supplied instead and supplied back to the client. If a name is supplied for the menu which is currently used by another menu, then the name conflict is resolved by adding a numerical counter similar to how `post_name` conflicts are resolved. Includes unit tests.

Fixes #32760.


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


git-svn-id: http://core.svn.wordpress.org/trunk@33042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-03 20:47:25 +00:00
Dominik Schilling
759bcdbad1 Customizer: Escape original title of menu items.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32893


git-svn-id: http://core.svn.wordpress.org/trunk@32864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-20 19:55:25 +00:00
Scott Taylor
88743c7cd7 Add missing access modifiers in class-wp-customize-setting.php.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:08:26 +00:00
Scott Taylor
5e994cd6a1 Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:01:25 +00:00
Dominik Schilling
62e3a0c15c Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.

props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806


git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 22:08:26 +00:00
Aaron Jorbin
36e593a46c Restore [32732] as it wasn't the actual cause of test failures as those failures where fixed separately.
See #32732


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


git-svn-id: http://core.svn.wordpress.org/trunk@32738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 18:56:26 +00:00
Aaron Jorbin
3d2f8542ac Revert [32732] since it is causing the tests to break
See #32732


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


git-svn-id: http://core.svn.wordpress.org/trunk@32737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 18:43:25 +00:00
Scott Taylor
740b92853d WP_Customize_Setting::is_current_blog_previewed() should only return false, not false or void. The one invocation of the method only loosely checks the return value.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-12 17:29:26 +00:00
Scott Taylor
bd8fafea54 Use void instead of null where appropriate when pipe-delimiting @return types. If a @return only contains void, remove it.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-24 05:40:25 +00:00
Scott Taylor
082bfab426 Clean up @global doc blocks/imports for class-wp-customizer-*.php and friends.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-22 05:06:25 +00:00
Scott Taylor
b2bbbf9759 In class-wp-customize-*, clarify/add some @param/@return blocks. Disambiguate some functions that are trying to return the void response of another function they call internally.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-21 22:05:24 +00:00
Drew Jaynes
d483e3a32a Add missing @access tags to two DocBlocks in WP_Customize_Setting.
See [31707]. See #31888.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-05 15:17:27 +00:00
Dominik Schilling
953cf28ac6 Customizer: Return the original value when filtering theme mods/options and the current blog has changed.
props westonruter.
fixes #31428.
Built from https://develop.svn.wordpress.org/trunk@31707


git-svn-id: http://core.svn.wordpress.org/trunk@31688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-10 23:05:27 +00:00
Dominik Schilling
b96a624cb9 Customizer: Fix previewing and applying widgets when previewing another theme.
* Unset `wp_get_sidebars_widgets()`' non-admin cache var `$_wp_sidebars_widgets` in Customize theme preview.
* Add `WP_Customize_Setting::$dirty` so that settings can be initially-dirty when the Customizer loads.
* Mark `old_sidebars_widgets_data` setting initially-dirty.
* Mark all `sidebars_widgets` settings as initially-dirty during theme switch.

props westonruter.
see #31484.
Built from https://develop.svn.wordpress.org/trunk@31705


git-svn-id: http://core.svn.wordpress.org/trunk@31686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-10 22:39:28 +00:00
Drew Jaynes
26f8fbd705 Add a missing file header and clean up class DocBlocks in wp-includes/class-wp-customize-setting.php.
* Adds a file header separate from the `WP_Customize_Setting` class block
* Fixes formatting for the `WP_Customize_Setting`, `WP_Customize_Filter_Setting`, `WP_Customize_Header_Image_Setting`, and `WP_Customize_Background_Image_Setting` class DocBlocks.

See #31446.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31524 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-25 08:18:26 +00:00
Dominik Schilling
3aea5f144b Customizer: Introduce an API to create WP_Customize_Settings for dynamically-created settings.
* Introduce WP_Customize_Manager::add_dynamic_settings() to register dynamically-created settings.
* Introduce `customize_dynamic_setting_args` filter to pass an array of args to a dynamic setting's constructor.
* Add unit tests for WP_Customize_Manager and WP_Customize_Widgets.
* See WP_Customize_Widgets as an example.

props westonruter.
fixes #30936.
Built from https://develop.svn.wordpress.org/trunk@31370


git-svn-id: http://core.svn.wordpress.org/trunk@31351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-08 23:11:25 +00:00
Dominik Schilling
9d162f0945 Ensure that WP_Customize_Setting::value() returns default value for setting if not dirty.
There was regression introduced by #28580 where only changed (dirty) settings now are POST'ed to the Customizer preview.

* Allow WP_Customize_Manager::post_value() to accept a second $default argument.
* Introduce WP_Customize_Manager::unsanitized_post_values() for accessing previously-private member variable _post_values.
* Do require_once instead of require for Customizer classes.
* Add unit tests for WP_Customize_Manager and WP_Customize_Setting.

props westonruter.
fixes #30988.
Built from https://develop.svn.wordpress.org/trunk@31329


git-svn-id: http://core.svn.wordpress.org/trunk@31310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-03 10:15:21 +00:00
Scott Taylor
0a511680f4 Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value. Constructors do not have meaningful return values, anything that is returned from here is discarded.
See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-10 06:54:23 +00:00
Scott Taylor
905f35f289 In Customizer classes:
* `public final function` methods should be `final public function` - confusing Hack and aligns with PSR2
* Some methods were missing access modifiers

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 06:02:24 +00:00
Scott Taylor
a215b8801d Improve various @param docs for src/wp-includes/class-wp-customize*.php.
See #30224.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 23:33:23 +00:00
Drew Jaynes
bffe95d34c Docs Formatting: Backtick-escape inline code for all remaining dynamic hook docs in wp-includes/*.
Affects DocBlocks for the following hooks:
* `auth_post_meta_{$meta_key}`
* `term_links-$taxonomy`
* `customize_render_control_ . $this->id`
* `customize_render_panel_{$this->id}`
* `customize_render_section_{$this->id}`
* `customize_preview_{$this->id}`
* `customize_save_ . $this->id_data[ 'base' ]`
* `customize_update_ . $this->type`
* `customize_value_ . $this->id_data[ 'base' ]`
* `customize_sanitize_js_{$this->id}`
* `comment_form_field_{$name}`
* `comment_{$old_status}_to_{$new_status}`
* `comment_{$new_status}_{$comment->comment_type}`
* `extra_{$context}_headers`
* `get_template_part_{$slug}`
* `get_the_generator_{$type}`
* `get_{$adjacent}_post_join`
* `get_{$adjacent}_post_where`
* `get_{$adjacent}_post_sort`
* `{$adjacent}_post_rel_link`
* `{$adjacent}_post_link`
* `{$adjacent}_image_link`
* `blog_option_{$option}`
* `$permastructname . _rewrite_rules`
* `{$type}_template`
* `theme_mod_{$name}`
* `pre_set_theme_mod_$name`
* `current_theme_supports-{$feature}`
* `get_user_option_{$option}`
* `edit_user_{$field}`
* `pre_user_{$field}`
* `user_{$field}`

See #30552.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:10:23 +00:00
Drew Jaynes
21a521db09 4.1 Docs Audit: Fix DocBlock formatting for the customize_preview_{$this->type} hook.
See #30469.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 11:13:24 +00:00
Drew Jaynes
f8657d5890 Remove redundant and erroneous @uses tag from most core inline documentation.
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.

Fixes #30191.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 01:05:24 +00:00
Dominik Schilling
bc982b39c1 Customizer: Introduce customize_preview_$setting->type action to handle multiple settings of the same type.
props celloexpressions.
fixes #29165.
Built from https://develop.svn.wordpress.org/trunk@29948


git-svn-id: http://core.svn.wordpress.org/trunk@29697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-17 21:21:19 +00:00
Dominik Schilling
8ecb461bed Correct the documentation for the customize_save_* action.
props celloexpressions.
see #29165.
Built from https://develop.svn.wordpress.org/trunk@29509


git-svn-id: http://core.svn.wordpress.org/trunk@29286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-15 19:49:15 +00:00
Sergey Biryukov
c6ef7d05e0 Allow for easier adding of custom class variables when extending WP_Customize_Section or WP_Customize_Setting.
props rhurling.
fixes #27315.
Built from https://develop.svn.wordpress.org/trunk@28827


git-svn-id: http://core.svn.wordpress.org/trunk@28631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-24 22:56:14 +00:00
Sergey Biryukov
8b4b3697e0 Pass WP_Customize_Setting instance to 'customize_save_*' action.
props danielbachhuber.
fixes #27979.
Built from https://develop.svn.wordpress.org/trunk@28769


git-svn-id: http://core.svn.wordpress.org/trunk@28582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-17 23:58:16 +00:00
Sergey Biryukov
f0a3d5cfa8 Pass WP_Customize_Setting instance to 'customize_preview_*' and 'customize_update_*' actions.
props dustyn, DrewAPicture.
fixes #27979.
Built from https://develop.svn.wordpress.org/trunk@28767


git-svn-id: http://core.svn.wordpress.org/trunk@28580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-17 23:35:15 +00:00
Scott Taylor
3c209b6f56 Add missing access modifiers to methods/members in WP_Customize_*.
See #27881, #22234.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 05:45:16 +00:00
Scott Taylor
73b102bd84 In wp-includes/class-wp-customize-setting.php, break is unreachable after return.
See #27882.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28147 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 18:34:14 +00:00
Drew Jaynes
5ac55b9b1a Inline documentation for hooks in wp-includes/class-wp-customize-setting.php.
Props kpdesign for the cleanup.
Fixes #27295

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


git-svn-id: http://core.svn.wordpress.org/trunk@27279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-06 14:04:13 +00:00
Andrew Nacin
f31ac162f5 Update the Customizer API inline docs.
props ericlewis.
fixes #27065.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-04 20:21:14 +00:00
Drew Jaynes
cb8951b0b3 Remove all @package and @subpackage PHPDoc tags not at the file- or class-levels in core.
See #27200.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-25 17:14:14 +00:00
Ryan Boren
15a06a35ab Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().
see #WP21767


git-svn-id: http://core.svn.wordpress.org/trunk@23591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 16:30:38 +00:00
Ryan Boren
43a7e695e9 Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:28:40 +00:00
Ryan Boren
cc5ed3a485 Change all core API to expect unslashed rather than slashed arguments.
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.

Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.

Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.

Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.

Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.

Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.

Plugins should use wp_unslash() on data being passed to core API.

Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.

Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.

Remove many no longer necessary calls to $wpdb->escape() and esc_sql().

In wp_get_referer() and wp_get_original_referer(), return unslashed data.

Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.

Switch several queries over to prepare().

Expect something to break.

Props alexkingorg
see #21767


git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-14 22:51:06 +00:00
Ryan Boren
06ee370814 Pinking shears
git-svn-id: http://core.svn.wordpress.org/trunk@22634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-17 15:11:29 +00:00