Commit Graph

187 Commits

Author SHA1 Message Date
Sergey Biryukov
641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
95f5cecd77 Docs: Expand @return value description for wp_nav_menu().
See #48303.
Built from https://develop.svn.wordpress.org/trunk@47097


git-svn-id: http://core.svn.wordpress.org/trunk@46897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-21 20:13:05 +00:00
John Blackbourn
3caaa40fc6 Docs: Switch more docs over to typed array notation, plus some fixes.
See #48303, #41756

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


git-svn-id: http://core.svn.wordpress.org/trunk@46393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-26 21:09:04 +00:00
Sergey Biryukov
4b3df8e846 Code Modernisation: Replace call_user_func_array() in wp-includes/nav-menu-template.php with a dynamic function call.
Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46134


git-svn-id: http://core.svn.wordpress.org/trunk@45946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-15 11:31:57 +00:00
Sergey Biryukov
7f7480cb2a Docs: Add missing description for $wp_query and $wp_the_query globals.
Props mukesh27.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45739


git-svn-id: http://core.svn.wordpress.org/trunk@45550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:59:56 +00:00
Sergey Biryukov
b1e34ccc1f Docs: Add missing description for $wp_rewrite global.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45735


git-svn-id: http://core.svn.wordpress.org/trunk@45546 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:19:56 +00:00
Gary Pendergast
4803fc405e Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-includes.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Sergey Biryukov
7d74080b80 Privacy: Introduce Privacy Policy page helpers:
* `is_privacy_policy()` template tag
* `privacy-policy.php` template
* `.privacy-policy` body class
* `.menu-item-privacy-policy` menu item class

Props garrett-eclipse, birgire, xkon, Clorith.
Fixes #44005.
Built from https://develop.svn.wordpress.org/trunk@44966


git-svn-id: http://core.svn.wordpress.org/trunk@44797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-21 19:48:50 +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
0e39cef343 Menus: When checking if a Custom Link matches the current URL to add the current-menu-item class, check for decoded URL as well.
Props soulseekah, campusboy1987.
Fixes #43401.
Built from https://develop.svn.wordpress.org/trunk@42732


git-svn-id: http://core.svn.wordpress.org/trunk@42562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-24 13:44: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
Sergey Biryukov
d8c50c7a12 Menus: Make sure current-menu-parent and current-menu-ancestor classes are properly set for parent items of post type archive submenu items.
Props mrwweb, ajoah, welcher.
Fixes #39800.
Built from https://develop.svn.wordpress.org/trunk@41008


git-svn-id: http://core.svn.wordpress.org/trunk@40858 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-05 21:31:44 +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
Adam Silverstein
8b60430aee Customizer: Fix an issue with menu classes in the customizer preview.
In customizer preview, strip changeset uuid in menu urls before comparing with current url to determine menu item classes.

In the customizer, menu items now contain a changeset uuid as part of their urls. Strip the changeset uuid off the url before comparing with current url (which lacks the changeset uuid).

Props priyankabehera155, jipmoors.
Fixes #39758.


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


git-svn-id: http://core.svn.wordpress.org/trunk@40521 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-12 20:35:43 +00:00
Sergey Biryukov
59d33e90da Docs: Correct @return value type for wp_nav_menu().
Props chesio.
Fixes #39890.
Built from https://develop.svn.wordpress.org/trunk@40062


git-svn-id: http://core.svn.wordpress.org/trunk@39999 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-02-16 16:09:43 +00:00
Gary Pendergast
fe86e61f0b Menus: Add the menu-item-home class to the static front page item.
When a site is using a static front page, and that page is in a menu, it isn't given the CSS class `menu-item-home`, contrary to the developer documentation.

An incorrect solution was originally added in [35272], and is now gone. Let us never speak of it again.

Props mdgl, adamsilverstein, welcher, pento.
Fixes #35272.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 01:58:30 +00:00
Gary Pendergast
efaf9bae66 Menus: Add the menu-item-home class to the static front page.
When a site is using a static front page, and that page is in a menu, it isn't given the CSS class `menu-item-home`, contrary to the developer documentation.

Props christophherr.
Fixes #35272.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-24 00:32:32 +00:00
Peter Wilson
6cdab630cd Menus: Improve documentation of new $item_spacing argument.
Adds `@since` tags for and improves description of the new `$item_spacing` argument added to `wp_nav_menu()`, `wp_list_pages()`, and `wp_page_menu()` in [38523].

Props johnbillion for copy.
See #35206.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-08 05:32:03 +00:00
John Blackbourn
8bec516c18 Menus: Correct the docblocks for Walker_Nav_Menu, wp_nav_menu(), and walk_nav_menu_tree().
This corrects the parameter type for the `$args` and `$item` parameters passed throughout these functions, class methods, and hooks.

See #24587
See #35206
See #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@38502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-07 16:15:30 +00:00
Peter Wilson
4131900722 Menus: Add white space option to wp_nav_menu() and wp_list_pages().
Adds an `item_spacing` option to the arguments array for the functions `wp_nav_menu()`, `wp_list_pages()`, and `wp_page_menu()`. `item_spacing` is a boolean accepting either `preserve` or `discard`.

Previously, certain CSS choices could result in a site's layout changing if `wp_nav_menu()` fell back to the default `wp_list_pages()` due to differences in the whitespace within the HTML. The new argument ensures a function outputs consistant HTML while maintaining backward compatibility.

Fixes #35206.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-06 09:06:31 +00:00
Scott Taylor
a3ffebce30 Bootstrap: do not go gentle into that good night r38411, r38412, and parts of r38389.
See #36335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 16:31:29 +00:00
Scott Taylor
390ceba6c7 Bootstrap: after r38409 and r38410, revert r38402 which reverted r38399.
This fixes the paths in `wp-vendor/` that were including `src`. I want to drop this in so we can find out what else will break.

See #36335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 22:32:37 +00:00
Dion Hulse
0e31a46161 Bootstrap: Revert [38399] as it's broken /build/ and subsequently core.svn.wordpress.org.
The generated classmaps reference `/src/` files and operates in the assumption that the base directory is one level above `wp-settings.php`, which it isn't after our build processes are run.

See #36335

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


git-svn-id: http://core.svn.wordpress.org/trunk@38343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 14:37:32 +00:00
Scott Taylor
6a529648cf Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.
* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 09:15:29 +00:00
John Blackbourn
f189b72b22 Docs: Alignment after [38369].
See #37770

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


git-svn-id: http://core.svn.wordpress.org/trunk@38311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-26 16:51:28 +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
5415629ad2 Nav Menus: Move the Walker_Nav_Menu class to its own file.
The new class-walker-nav-menu.php file is loaded in nav-menu-template.php for backward compatibility purposes.

Fixes #37035. See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-06 15:18:31 +00:00
Drew Jaynes
2c7f5217cd Docs: Relocate some @see tags and add missing @access tags to method and property DocBlocks in Walker_Nav_Menu.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-06 05:47:27 +00:00
Drew Jaynes
16b51fb44d Docs: Reformat several parameter descriptions in Walker_Nav_Menu to directly reference wp_nav_menu() rather than use inline @see tags.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-06 05:45:28 +00:00
Drew Jaynes
318f745808 Docs: Correct DocBlock descriptions for the $before, $after, $link_before, and $link_after arguments for wp_nav_menu().
* `$before` falls before the link markup starts
* `$after` falls after the link markup ends
* `$link_before` falls before the link text
* `$link_after` falls after the link text

Props wp_smith for the initial patch.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-25 16:17:27 +00:00
Drew Jaynes
9193013158 Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

Fixes #36921.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 19:02:28 +00:00
Drew Jaynes
e78209267f Docs: Standardize filter docs in wp-includes/nav-menu-template.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:28:27 +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
Konstantin Obenland
6c54bf4dcb Menus: Bring back line break between menu items.
While removing line breaks was great for all use cases except justified menu
items, it broke menus with justified menu items.
Reverts [34321].

Props wp-architect.
Fixes #35107.


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


git-svn-id: http://core.svn.wordpress.org/trunk@36046 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-24 00:21:27 +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
John Blackbourn
51667f882a Add a nav_menu_item_title filter for filtering nav menu item titles.
Fixes #33447
Props paulwilde

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


git-svn-id: http://core.svn.wordpress.org/trunk@34630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 18:41:26 +00:00
Scott Taylor
d6774f0f6d Nav Menus: in wp_nav_menu(), $container is already bound to a list of allowed tags. PHP, being its whimsical self, while return true if someone sets $container to true via in_array( true, [ 'div', 'nav' ] ). Check that $container is a string before the in_array() check. 'true' does not pass.
Props shedonist for the original patch.
Fixes #32464.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-27 18:13:24 +00:00
John Blackbourn
aa35e473f7 callback is not a valid type in PHP, PSR-5, or phpDocumentor. callable should be used instead.
Fixes #34032

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


git-svn-id: http://core.svn.wordpress.org/trunk@34530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 23:58:25 +00:00
John Blackbourn
cb740147be Add $depth as a parameter in the nav_menu_item_args filter.
Fixes #29417

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


git-svn-id: http://core.svn.wordpress.org/trunk@34471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 17:59:24 +00:00
Drew Jaynes
90f61eff52 Docs: Add a summary to the hook doc for the nav_menu_item_args filter, introduced in [34471].
Fixes #29417.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 05:09:24 +00:00
Scott Taylor
0c1f92e301 Nav Menus: Add a 'nav_menu_item_args' filter to Walker_Nav_Menu::start_el().
Props bjornjohansen.
Fixes #29417.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 03:17:24 +00:00
Konstantin Obenland
8d8252aa89 Menus: Remove whitespace between nav menu items.
Avoids CSS hacks like floating menu items or setting the parent element's
font-size to 0 in order to display nav menus horizontally.

Props jjeaton.
Fixes #27762.


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


git-svn-id: http://core.svn.wordpress.org/trunk@34285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-19 11:40:26 +00:00
Sergey Biryukov
78d43de7e4 Avoid PHP notices in redirect_canonical() and _wp_menu_item_classes_by_context() if $_SERVER['HTTP_HOST'] is not set.
fixes #32229.
Built from https://develop.svn.wordpress.org/trunk@33775


git-svn-id: http://core.svn.wordpress.org/trunk@33743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-28 03:31:20 +00:00
Weston Ruter
2678bd9225 Customizer: Restore default fallback_cb arg for wp_nav_menu() calls in customizer preview.
Props ocean90, westonruter.
Fixes #33218.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-04 21:57:25 +00:00
Dion Hulse
ffb1de37ae Ensure that Custom Links in menu's are marked as current regardless of their scheme.
Props McGuive7, marsjaninzmarsa.
Fixes #32221

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


git-svn-id: http://core.svn.wordpress.org/trunk@33074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-07 09:57:26 +00:00
Sergey Biryukov
52db28396c Customizer: Avoid PHP notices after [32806].
props adamsilverstein, westonruter.
fixes #32781.
Built from https://develop.svn.wordpress.org/trunk@33035


git-svn-id: http://core.svn.wordpress.org/trunk@33006 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-01 19:08:24 +00:00
Scott Taylor
0cc29d8bb7 In wp_nav_menu(), ensure that the $menu arg is populated when passed to filters.
Props greuben, chriscct7.
Fixes #16594.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32774 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-16 20:33:25 +00:00
Dominik Schilling
8dcd236ba3 Nav menus: Reset the fallback_cb default argument in wp_nav_menu in case of a Customizer preview.
props westonruter.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32763


git-svn-id: http://core.svn.wordpress.org/trunk@32734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 17:14:24 +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