Commit Graph

212 Commits

Author SHA1 Message Date
Sergey Biryukov 16b8d91baa I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.

Includes minor code layout fixes.

Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!

Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926


git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 17:13:59 +00:00
Sergey Biryukov b1847ef3e2 Menus: In `wp_setup_nav_menu_item()` and `Walker_Nav_Menu_Edit::start_el()`, check if the post or term associated with the menu item still exists to avoid a PHP notice.
If the associated post or term no longer exists, mark the menu item as invalid.

Props mehulkaklotar, kamrankhorsandi, cristiano.zanca, SergeyBiryukov.
Fixes #31703.
Built from https://develop.svn.wordpress.org/trunk@45891


git-svn-id: http://core.svn.wordpress.org/trunk@45702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-25 21:32:59 +00:00
Sergey Biryukov c26f1c5d90 Taxonomy: Fix deprecated calls to `get_terms()`.
The taxonomy should be passed as part of `$args`, rather than as its own argument.

Props sgastard, mukesh27, SergeyBiryukov.
Fixes #47819.
Built from https://develop.svn.wordpress.org/trunk@45723


git-svn-id: http://core.svn.wordpress.org/trunk@45534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-03 03:35:56 +00:00
Sergey Biryukov 4b460d0f80 Coding Standards: Fix WPCS issues in [45655].
See #47723.
Built from https://develop.svn.wordpress.org/trunk@45656


git-svn-id: http://core.svn.wordpress.org/trunk@45467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-17 19:22:56 +00:00
Sergey Biryukov f7c4398ea9 Menus: Trim whitespace from custom link URLs.
Props majemedia, SergeyBiryukov.
Fixes #47723.
Built from https://develop.svn.wordpress.org/trunk@45655


git-svn-id: http://core.svn.wordpress.org/trunk@45466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-17 18:45:58 +00:00
desrosj 7cb9a98a5b Nav Menus: Fix a PHP 7.3 error when switching themes.
When switching themes, `wp_map_nav_menu_locations()` is used to ensure nav menus are placed in the relevant menu location. Occasionally, menus are registered to locations with numeric slugs, rather than strings. `wp_map_nav_menu_locations()` assumed it would be the latter, and ran `stripos()` on those numeric slugs. This behavior is deprecated in PHP 7.3.

As this is the last PHP 7.3 error in unit tests, this commit also removes PHP 7.3 from Travis' `allowed_failures` list.

Props pento, desrosj, jorbin.

Merges [43899] to trunk.

See #45018.
Built from https://develop.svn.wordpress.org/trunk@44167


git-svn-id: http://core.svn.wordpress.org/trunk@43997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 05:16:52 +00:00
Gary Pendergast 56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


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


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Sergey Biryukov 8393519ade Menus: Remove `$_menu_item_sort_prop` global reference from `wp_get_nav_menu_items()`, unused since [38928].
Props PieWP, welcher.
Fixes #40947.
Built from https://develop.svn.wordpress.org/trunk@42634


git-svn-id: http://core.svn.wordpress.org/trunk@42463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-01 15:42:31 +00:00
Gary Pendergast aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Gary Pendergast c90cfa3b50 General: Fix some precision alignment formatting warnings.
The WPCS `WordPress.WhiteSpace.PrecisionAlignment` rule throws warnings for a bunch of code that will likely cause issues for `wpcbf`. Fixing these manually beforehand gives us better auto-fixed results later.

See #41057.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-26 23:57:55 +00:00
Konstantin Obenland db00af7cc2 Menus: Add `menu-$i` slugs to mapping groups
Helps to future proof the feature.
Also orders slugs by popularity to optimize mapping time.

See #39692.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-25 22:29:49 +00:00
Weston Ruter fce310e744 Menus: Don't prime nav menu items cache if a persistent cache is being used.
Amends [14560].
Props david.binda.
See #12734.
Fixes #41662.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41816 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-23 22:40:50 +00:00
Weston Ruter bd9d1d9178 Customize: Allow post/page stubs to be edited in WP Admin as "customization drafts" when changeset is saved as draft or scheduled.
* Update stubs to have draft status when changeset is saved as draft, instead of preventing auto-draft garbage collection by giving them a far-future `post_date`.
* Show notice in publish metabox when editing a customization draft indicating that it will be published automatically with its changeset; a link to Customizer is included.
* Include a new "Customization Draft" display post state in the post list table.
* Disconnect stubs from their changesets when they are updated with a status other than "Draft".
* Trash customization drafts when their related changeset is trashed or deleted.
* Add a `_customize_changeset_uuid` postmeta to stubs to link them with their associated changeset.
* Include `customize_changeset_uuid` as context when requesting to insert a new auto-draft.

Props westonruter, melchoyce.
See #39896, #39752, #34923.
Fixes #42220.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-17 20:15:52 +00:00
Konstantin Obenland b17b035009 Menus: Limit mapping to registered locations
Weeds out orphaned locations, so their information will not continue to be mapped to future themes.

Fixes #42121.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-10 17:08:48 +00:00
Konstantin Obenland 756c052ccb Menus: Add `social` as tertiary mapping group
Allows mapping of all social menus that include the term `social` in their slug.

See #39692.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-09 21:23:47 +00:00
Sergey Biryukov 2f0f46cb84 Menus: Introduce `wp_get_nav_menu_name()` to retrieve the name of a navigation menu as set in the admin.
Props markoheijnen, christophherr, SpencerFinnell, wojtek.szkutnik, sagarprajapati, welcher, SergeyBiryukov.
Fixes #13910.
Built from https://develop.svn.wordpress.org/trunk@41766


git-svn-id: http://core.svn.wordpress.org/trunk@41600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 01:38:46 +00:00
Konstantin Obenland e183d59acb Map nav menu locations on theme switch
This will send nav menu locations through three levels of mapping:
1. If both themes have only one location, that gets mapped.
2. If both themes have locations with the same slug, they get mapped.
3. Locations that (even partially) match slugs from a similar kind of menu location will get mapped.

Menu locations are mapped for Live Previews in the Customizer and during theme switches.

Props westonruter, obenland, welcher, melchoyce.
Fixes #39692.


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


git-svn-id: http://core.svn.wordpress.org/trunk@41077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-09 21:04:47 +00:00
Drew Jaynes 36759db92e Docs: Clarify accepted types and values for `$menu` parameters in several contexts:
* `wp_nav_menu()`
* `wp_get_nav_menu_object()` and its filter `wp_get_nav_menu_object`
* `is_nav_menu()`
* `wp_delete_nav_menu()`
* `wp_get_nav_menu_items()`

Props dimadin.
Fixes #38166.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40819 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-30 04:49:40 +00:00
Drew Jaynes de7499f88f Docs: Add full documentation for arguments accepted by `wp_get_nav_menu_items()`.
Also provide differentiation between arguments as passed to `get_posts()` vs used for ordering outputted menu items.

By and large, arguments in the `$args` array are intended to directly affect how nav_menu_item posts are retrieved. When the default ARRAY_A is used for 'output', the 'order' and 'orderby' arguments are essentially ignored, instead giving preference to a hard-coded order of 'ASC' and an orderby value derived from the non-get_posts() argument 'output_key'.

Fixes #15533.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-25 19:37:39 +00:00
Weston Ruter d8f94986b2 Customize: Keep alive auto-drafts created for page/post stubs when parent changeset is updated, and delete when changeset is garbage-collected.
Props utkarshpatel, westonruter.
See #31089.
Fixes #39715.

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


git-svn-id: http://core.svn.wordpress.org/trunk@40539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-16 05:37:44 +00:00
John Blackbourn d327c92e4b Docs: Add and correct `@since` docs for a variety of functions and methods.
Props keesiemeijer, chris_dev
Fixes #39343, #39357, #39344
See #39130

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


git-svn-id: http://core.svn.wordpress.org/trunk@39578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-27 09:21:44 +00:00
Dominik Schilling 7cce73a634 General: Introduce a `wp_list_sort()` helper function, v2.
In addition to `wp_list_filter()` for filtering a list of objects, and `wp_list_pluck()` for plucking a certain field out of each object in a list, this new function can be used for sorting a list of objects by specific fields. These functions are now all contained within the new `WP_List_Util()` class and `wp_list_sort()` is used in various parts of core for sorting lists.

This was previously committed in [38859] but got reverted in [38862] and [38863]. To fix the previous issues, `wp_list_sort()` supports now an additional argument to preserve array keys via `uasort()`.

Props flixos90, DrewAPicture, jorbin.
Fixes #37128.
Built from https://develop.svn.wordpress.org/trunk@38928


git-svn-id: http://core.svn.wordpress.org/trunk@38871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-25 21:26:32 +00:00
Dominik Schilling 6c8508023f Revert [38859] due to an incomplete implementation.
See https://core.trac.wordpress.org/ticket/37128#comment:27.
See #37128.
Built from https://develop.svn.wordpress.org/trunk@38863


git-svn-id: http://core.svn.wordpress.org/trunk@38806 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-21 17:01:32 +00:00
Pascal Birchler f54558e75b General: Introduce a `wp_list_sort()` helper function.
In addition to `wp_list_filter()` for filtering a list of objects, and `wp_list_pluck()` for plucking a certain field out of each object in a list, this new function can be used for sorting a list of objects by specific fields. These functions are now all contained within the new `WP_List_Util()` class and `wp_list_sort()` is used in various parts of core for sorting lists.

Props flixos90, DrewAPicture, jorbin.
Fixes #37128.
Built from https://develop.svn.wordpress.org/trunk@38859


git-svn-id: http://core.svn.wordpress.org/trunk@38802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-21 11:12:51 +00:00
Pascal Birchler ff411ed5f4 Menus: Do not show trashed posts in nav menus.
Trashed posts cannot be accessed by site visitors and thus should not be visible on the front end. By marking menu items of trashed posts as invalid, they are excluded from the output.

Props solarissmoke, swissspidy.
Fixes #19038.
Built from https://develop.svn.wordpress.org/trunk@38744


git-svn-id: http://core.svn.wordpress.org/trunk@38687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-07 16:50:29 +00:00
John Blackbourn 94c8ca0f2e Docs: Correct various documentation around `object` and `stdClass` types.
See #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@38310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 16:49:45 +00:00
Drew Jaynes eb7df1379b Docs: Improve the summaries and return descriptions for `get_registered_nav_menus()` and `get_nav_menu_locations()`.
Props rabmalin for the initial patch.
Fixes #37106.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-20 08:26:29 +00:00
Drew Jaynes 9cb5247392 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:50:28 +00:00
Drew Jaynes fe3b007fdd Docs: Remove inline `@see` tags from function, class, and method references in inline docs.
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.

Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-02 04:00:28 +00:00
Drew Jaynes f64b97c597 Menus: Avoid a notice when outputting a description for an existing archive menu item for a post type that doesn't.
Props bradyvercher.
See [36859]. Fixes #35324.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-08 18:25:26 +00:00
Aaron Jorbin d71a0600a6 Ensure Description is respected in post type archive menu items.
Tested scenarios include: using the default (which is the post type description), Setting a custom description for that individual menu item, and setting a custom description that is blank. Introduced in r35382.

Props Toro_Unit, mayukojpn, extendwings, jorbin.
Fixes #35324. See #16075.


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


git-svn-id: http://core.svn.wordpress.org/trunk@36826 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-05 22:57:26 +00:00
Dominik Schilling e5ea82d81a Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective).
Props obrienlabs, thewanderingbrit.
Fixes #34887.
Built from https://develop.svn.wordpress.org/trunk@36709


git-svn-id: http://core.svn.wordpress.org/trunk@36676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-25 12:53:27 +00:00
Weston Ruter 87a9bf2b37 Docs: Use markdown instead of HTML for `code` formatting.
Fixes phpdoc usage in [36622], [36608], [35724], [35307].

See #35898.
See #35869.
See #34738.
See #33552.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 19:18:27 +00:00
Weston Ruter aa9ef96a52 Customize: Prevent dropping backslashes from input on general settings and settings for nav menus and some widgets.
Ensures that intentional backslashes (e.g. "\o/") can be used in:

* Site title
* Site description
* Nav menu name
* Custom Menu widget title
* Tag Cloud widget title
* Text widget body if can't `unfiltered_html`

The latter three are also fixed on the widgets admin page.

Fixes #35898.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36589 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 01:02:26 +00:00
Weston Ruter b206327acb Customize: Fix previewing and updating of nav menu items containing slashed/slashable characters.
Prevents slashes from being added when a user without `unfiltered_html` previews a nav menu item containing an apostrophe or some other slashable character, and prevents the loss of an intentional slash (e.g. "\o/") when saving a nav menu item, regardless of capability.

Fixes #35869.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-22 00:14:25 +00:00
Drew Jaynes f3aeb0def3 Docs: Update several function DocBlock summaries in wp-includes/nav-menu.php to use third-person singular verbs.
Also removes some unnecessary capitalizations.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-07 02:18:26 +00:00
Eric Lewis fd99c1705e Docs: Nav menu location functions relate to nav menu locations, not nav menus.
Fixes #35471.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-17 01:43:26 +00:00
Dominik Schilling 0b6c5744dc Nav Menus: Apply the `the_title` filter on original post titles in `wp_setup_nav_menu_item()`.
The filter is already used in `Walker_Nav_Menu_Checklist` and `Walker_Nav_Menu_Edit`. This ensures that titles are consistent across the admin and front end.

Fixes #35317.
Built from https://develop.svn.wordpress.org/trunk@36174


git-svn-id: http://core.svn.wordpress.org/trunk@36141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-05 16:27:26 +00:00
Dion Hulse 1d19b930fc Nav Menus: Avoid a PHP Notice when a menu contains a now unregistered post type archive.
Props kucrut.
Fixes #34449 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-26 04:05:25 +00:00
Drew Jaynes bc4a65a036 Docs: Clarify the summary and add missing parameter notations to the DocBlock for `_wp_delete_tax_menu_item()`.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-16 23:11:25 +00:00
Sergey Biryukov 55a7ba2ec7 Don't use `<strong>` in translatable string in `wp-includes/nav-menu.php`.
Add translator commment.

Props ramiy.
Fixes #34505.
Built from https://develop.svn.wordpress.org/trunk@35452


git-svn-id: http://core.svn.wordpress.org/trunk@35416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-30 08:57:26 +00:00
Scott Taylor dc1e85a540 Nav Menus: show custom post type Archive item at the top of the `View All` tab for the post type on the legacy Nav Menu screen.
Props aaroncampbell, DrewAPicture, seanchayes, hlashbrooke, paulwilde, ericlewis, raulillana
See #16075.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-24 17:46:25 +00:00
Drew Jaynes a3ead57e90 Introduce the `wp_add_nav_menu_item` action, fired immediately after a new nav menu item has been added.
This hook can be leveraged both for the legacy menus interface and the menus integration in the Customizer, as both use the containing function, `wp_update_nav_menu_item()`.

Props MikeHansenMe, tyxla.
Fixes #30983.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-02 06:46:24 +00:00
Scott Taylor ef87172270 `foreach` is a statement, not a function.
See #33491.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Boone Gorges 2c9e81349c When splitting a shared 'nav_menu' term, ensure that nav items and theme locations are retained.
Props boonebgorges, dd32.
Fixes #33187.
Built from https://develop.svn.wordpress.org/trunk@33611


git-svn-id: http://core.svn.wordpress.org/trunk@33578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-12 14:07:26 +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 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 4e74b792fa Fix the parameter description syntax in the hook docs for the `wp_get_nav_menu_object` filter, added in 4.3.
See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:45:24 +00:00
Dominik Schilling f127478bde Customizer: Improve handling of posts with no title.
Use the `#%d (no title)` string as a fallback which is already used on the nav menus screen.
Add a translator comment to all occurrences of the `#%d (no title)` string.

see #32576.
Built from https://develop.svn.wordpress.org/trunk@32892


git-svn-id: http://core.svn.wordpress.org/trunk@32863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-20 19:50:26 +00:00
Dominik Schilling df11970e18 Nav menus: Introduce a `wp_get_nav_menu_object` filter in `wp_get_nav_menu_object()` to filter the retrieved nav_menu term.
props westonruter.
fixes #32629.
Built from https://develop.svn.wordpress.org/trunk@32764


git-svn-id: http://core.svn.wordpress.org/trunk@32735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 17:37:25 +00:00
Dominik Schilling 55f3b68c75 Nav Menus: Update `wp_setup_nav_menu_item()` to stop overriding empty properties from supplied `$menu_item`.
Update docs for `WP_Post` constructor to indicate that `WP_Post|object` can be the supplied param, as opposed to just `WP_Post`.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 10:53:25 +00:00
Dominik Schilling 792295d077 Nav menus: Apply the `wp_get_nav_menu_items` filter also on an empty list of menu items.
props westonruter.
fixes #32631.
Built from https://develop.svn.wordpress.org/trunk@32748


git-svn-id: http://core.svn.wordpress.org/trunk@32719 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-13 14:38:25 +00:00
Dominik Schilling 33c1c76001 Nav menu: Introduce a `has_nav_menu` filter in `has_nav_menu()` to filter whether a nav menu is assigned to a specified location.
props westonruter.
fixes #32630.
Built from https://develop.svn.wordpress.org/trunk@32746


git-svn-id: http://core.svn.wordpress.org/trunk@32717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-13 14:15:25 +00:00
Scott Taylor cb0b0b109d Fix doc blocks for `nav-menu*.php` files.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-26 22:10:25 +00:00
Boone Gorges fbf16573ee When priming the cache for taxonomy term nav items, don't fetch term descendants.
Descending the term tree causes unnecessary database queries when priming the
cache for a term with many descendants.

Fixes #31724.
Built from https://develop.svn.wordpress.org/trunk@32294


git-svn-id: http://core.svn.wordpress.org/trunk@32265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-24 18:58:27 +00:00
Helen Hou-Sandí 296dba2804 Nav menus: Return to calling links "Custom Links".
It was like this before 3.6 and got a bit lost during that development cycle. Also uses the terminology more consistently in the nav menu UI.

props tyxla.
fixes #31344.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31729 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-12 06:15:27 +00:00
Sergey Biryukov 6221fc86a3 Fix a typo in `wp_update_nav_menu_item` hook documentation.
props tyxla.
fixes #31338.
Built from https://develop.svn.wordpress.org/trunk@31521


git-svn-id: http://core.svn.wordpress.org/trunk@31502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-23 16:51:25 +00:00
Scott Taylor 60b0cd7943 The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs. 

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Drew Jaynes 4fd64b94d7 4.1 Docs Audit: Formatting, line-wrap, and other fixes for the `wp_get_nav_menus()` DocBlock.
See #30469.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 12:15:23 +00:00
Sergey Biryukov aad05ece16 Set min-height for menu item title. Add a fallback for empty-titled items.
props philiparthurmoore.
fixes #30283.
Built from https://develop.svn.wordpress.org/trunk@30500


git-svn-id: http://core.svn.wordpress.org/trunk@30489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 05:57:22 +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
Drew Jaynes 96fb9e36a2 Fix the `$location` parameter type in the `unregister_nav_menu()` DocBlock.
`$location` is a string, not an array.

Props ipm-frommen.
Fixes #30098.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-25 13:43:18 +00:00
Drew Jaynes cdf9456b79 Clarify inline documentation for the `_is_valid_nav_menu_item()` and `wp_get_nav_menu_items()` in wp-includes/nav-menu.php.
Props morganestes for the initial patch.
Fixes #29914.

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


git-svn-id: http://core.svn.wordpress.org/trunk@29628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-10 17:14:19 +00:00
Drew Jaynes bf52618636 Update documentation for `wp_get_nav_menus()` to reflect that the default value for the the 'orderby' argument was changed from 'none' to 'name' in 4.1.
Props curtjen.
Fixes #29460.

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


git-svn-id: http://core.svn.wordpress.org/trunk@29565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-29 23:35:17 +00:00
Sergey Biryukov 504d4ad5eb Change the default orderby value in wp_get_nav_menus() to 'name'.
props voldemortensen, igmoweb.
fixes #29460.
Built from https://develop.svn.wordpress.org/trunk@29792


git-svn-id: http://core.svn.wordpress.org/trunk@29564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-29 15:45:16 +00:00
Sergey Biryukov f84cbb4ba8 Use get_registered_nav_menus() in has_nav_menu().
props voldemortensen.
fixes #29461.
Built from https://develop.svn.wordpress.org/trunk@29717


git-svn-id: http://core.svn.wordpress.org/trunk@29491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-07 10:04:16 +00:00
Scott Taylor 69b0077edf `return false` in `has_nav_menu()` if the `$location` does not exist in the `$_wp_registered_nav_menus` global.
Props SergeyBiryukov.
Fixes #27735.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-26 00:57:15 +00:00
Scott Taylor 7b83df547d Simplify the setting of `$args['include']` in `wp_get_nav_menu_items()`.
Props UmeshSingla.
Fixes #28515.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28629 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-24 17:17:14 +00:00
Sergey Biryukov 7214648764 Correct @return value for wp_create_nav_menu() and wp_delete_nav_menu().
props Tmeister.
fixes #27745.
Built from https://develop.svn.wordpress.org/trunk@28242


git-svn-id: http://core.svn.wordpress.org/trunk@28070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-02 11:59:14 +00:00
Drew Jaynes 513d8702f6 Inline documentation for hooks in wp-includes/nav-menu.php.
Props dustyf, kpdesign.
Fixes #27367.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-25 09:04:14 +00:00
Andrew Nacin 08db3b53c5 Explicitly assign menu term relationship rather than piggybacking on wp_insert_post() with the tax_input argument.
That argument currently depends on user context (see #19373).

Adds unit test for properly updating orphaned menu items.

props danielbachhuber.
fixes #27113.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-15 06:07:16 +00:00
Sergey Biryukov 19be701a86 Consistently return a WP_Error object in case of an error in wp_update_nav_menu_item().
props bootsz, ocean90.
fixes #21652.
Built from https://develop.svn.wordpress.org/trunk@27251


git-svn-id: http://core.svn.wordpress.org/trunk@27108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-25 00:51:13 +00:00
Andrew Nacin 635e50d9a1 Remove theme support for 'menus' in unregister_nav_menu() when there are no more menus.
props kovshenin.
fixes #26900.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-21 18:14:14 +00:00
Dominik Schilling 31d1f909a4 Nav Menu: Remove post/page items from the Nav Menu when the post/page is deleted.
This was broken through a change in [25163]. `_menu_item_object` in wp_get_associated_nav_menu_items() is not relevant for post types.
Adds unit tests.

props UmeshSingla for initial patch.
fixes #26795.
Built from https://develop.svn.wordpress.org/trunk@27150


git-svn-id: http://core.svn.wordpress.org/trunk@27017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-09 21:37:11 +00:00
Scott Taylor d7cc1f506a Introduce `wp_using_ext_object_cache()` - mimic `wp_suspend_cache_invalidation()` and discourage direct access to `$_wp_using_ext_object_cache`, cleaning up importing of globals in functions and provides function to modify that global. Loads the packaged object cache when an external cache hasn't been loaded or doesn't contain `wp_cache_init()`.
Fixes #21401.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 18:10:09 +00:00
Andrew Nacin 0d9fcbd841 Use get_nav_menu_locations() in wp_delete_nav_menu().
props nofearinc.
see #25064.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25168 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-31 01:39:09 +00:00
Scott Taylor eeb3b15936 Pass the taxonomy around to relevant nav menu actions to avoid arbitrarily deleting all items with `menu-item-type` of `taxonomy`. Adds unit test for `wp_get_associated_nav_menu_items()`.
Props garyc40, SergeyBiryukov.
Fixes #15264.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-29 16:45:10 +00:00
Mark Jaquith 92af914abe Keep the Nav Menu walker from blowing up the layout on empty-titled items.
fixes #23254. props cais, SergeyBiryukov.

git-svn-id: http://core.svn.wordpress.org/trunk@24560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-05 15:41:46 +00:00
Sergey Biryukov 4b174612ab Prevent menu items with '0' label from being removed on menu saving. props MikeHansenMe, kovshenin. fixes #23051.
git-svn-id: http://core.svn.wordpress.org/trunk@24235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-10 18:03:09 +00:00
Sergey Biryukov 15e919bd24 Use correct variable. fixes #24014. see #23119.
git-svn-id: http://core.svn.wordpress.org/trunk@23941 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-09 20:50:45 +00:00
Andrew Nacin 10d898ecbb Remove _wp_delete_nav_menu(). wp_delete_nav_menu() should instead remove the menu from theme locations, which was the only difference between the functions. see #23119.
git-svn-id: http://core.svn.wordpress.org/trunk@23897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-04 04:28:12 +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
Sergey Biryukov 87f2c02462 Ensure that get_nav_menu_locations() always returns an array. props JustinSainton for initial patch. fixes #23508.
git-svn-id: http://core.svn.wordpress.org/trunk@23550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 15:51:16 +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
Jon Cave ae96b842f9 Correctly associate new menu items with a menu when using wp_update_nav_menu_item()
wp_update_nav_menu_item() must pass tax_input to wp_insert_post() when creating items
otherwise the menu-item relationship isn't made.

See #22189.


git-svn-id: http://core.svn.wordpress.org/trunk@22399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-06 14:46:56 +00:00
Andrew Nacin 0ae808509c Optimize wp_update_nav_menu_item() for high performance. Only query items for a menu when we need them. Update items after updating its meta so the meta cache can be leveraged. see #22189.
git-svn-id: http://core.svn.wordpress.org/trunk@22235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-15 14:27:16 +00:00
Andrew Nacin 6c56e0573c Prime post term caches for nav menu items. Avoid doing so in frontend template functions as it remains unneeded there. see #22189.
git-svn-id: http://core.svn.wordpress.org/trunk@22233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-15 14:17:50 +00:00
ryan e3b46b25d3 Lose EOF ?>. Clean up EOF newlines. fixes #12307
git-svn-id: http://svn.automattic.com/wordpress/trunk@19712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-08 17:01:11 +00:00
ryan 07ff8b216b Use one space, not two, after trailing punctuation. fixes #19537
git-svn-id: http://svn.automattic.com/wordpress/trunk@19593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-12-13 23:45:31 +00:00
duck_ b225e5b626 Rescue those who created menu items before r18733. Trim menu item descriptions. See #16799.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-20 22:57:47 +00:00
duck_ bc3b3aed4d Make new nav menu items have a blank description and attr_title. See #16799.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-09-20 21:58:37 +00:00
nacin 61afb5def3 Check for WP_Error return values when using get_term_field() to set up nav menu items. fixes #17958 for trunk.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-07-11 19:03:04 +00:00
ryan 4bb54d8f68 Improvements to invalid menu item handling. Props ocean90. fixes #13958
git-svn-id: http://svn.automattic.com/wordpress/trunk@18277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-06-11 15:52:15 +00:00
ryan 46f63a6b1e Pinking shears
git-svn-id: http://svn.automattic.com/wordpress/trunk@18276 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-06-11 15:44:06 +00:00
nacin d648585363 Mark menu items tied to invalid taxonomies and post types as invalid. props ocean90, see #13958.
git-svn-id: http://svn.automattic.com/wordpress/trunk@18260 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2011-06-11 00:55:48 +00:00
nacin 148dac95df s/showposts/posts_per_page/
git-svn-id: http://svn.automattic.com/wordpress/trunk@15788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-10-13 05:25:00 +00:00
nacin 5a20c05d27 Phpdoc argument/@param cleanups. props duck_, see #14783.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-09-07 11:21:11 +00:00
nacin 9f1d1ba7fa Add unregister_nav_menu(). props jorbin, fixes #14001 for 3.1.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-07-22 20:50:11 +00:00
nacin f98fc6e766 Add missing filter to wp_get_nav_menu_items(). props filosofo, fixes #13858.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2010-06-14 20:50:55 +00:00