Commit Graph

99 Commits

Author SHA1 Message Date
Sergey Biryukov 37ce09349a Coding Standards: Use strict comparison in `wp-includes/bookmark-template.php`.
Follow-up to [3880].

Props aristath, poena, afercia, SergeyBiryukov.
See #60700.
Built from https://develop.svn.wordpress.org/trunk@57859


git-svn-id: http://core.svn.wordpress.org/trunk@57360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-03-20 12:49:10 +00:00
Sergey Biryukov 84e9601e5a Code Modernization: Replace usage of `substr()` with `str_starts_with()` and `str_ends_with()`.
`str_starts_with()` and `str_ends_with()` were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).

WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.

This commit uses `str_starts_with()` and `str_ends_with()` in core files where appropriate:
* `$needle === substr( $string, 0, $length )`, where `$length` is the length of `$needle`, is replaced with `str_starts_with( $haystack, $needle )`.
* `$needle === substr( $string, $offset )`, where `$offset` is negative and the absolute value of `$offset` is the length of `$needle`, is replaced with `str_ends_with( $haystack, $needle )`.

This aims to make the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987], [55988].

Props Soean, spacedmonkey, Clorith, ocean90, azaozz, sabernhardt, SergeyBiryukov.
Fixes #58220.
Built from https://develop.svn.wordpress.org/trunk@55990


git-svn-id: http://core.svn.wordpress.org/trunk@55502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:57:24 +00:00
Sergey Biryukov 2ec23a82ed Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.

While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.

Follow-up to [52039], [52040], [52326].

Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703


git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 15:45:22 +00:00
audrasjb a33fd9fc55 Docs: Use third-person singular verbs for function descriptions in Bookmark related files, as per docblock standards.
This changeset updates `bookmark.php` and `bookmark-template.php` files.

See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-23 22:57:12 +00:00
hellofromTonya 85fedc53ba General: Add "noopener" to `wp_list_bookmarks()` output.
In the bookmarks walker `_walk_bookmarks()`, add a `'noopener'` to the bookmark's `rel` attribute when there's `target` attribute.

Adds a new test class for `wp_list_bookmarks()` and tests for this change.

Follow-up to [3880], [10712].

Props birgire, costdev, hellofromTonya, mukesh27 , sergeybiryukov, tw2113.
Fixes #53839.
Built from https://develop.svn.wordpress.org/trunk@52061


git-svn-id: http://core.svn.wordpress.org/trunk@51653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 23:06:58 +00:00
Sergey Biryukov 0f9170b82d Docs: Clarify that the `$class` argument of `wp_list_bookmarks()` can accept an array.
Follow-up to [32906].

See #51855, #51800.
Built from https://develop.svn.wordpress.org/trunk@49688


git-svn-id: http://core.svn.wordpress.org/trunk@49411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-24 12:29:07 +00:00
Sergey Biryukov 0e3147c40e Coding Standards: Replace alias PHP functions with the canonical names.
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning.

This replaces all uses of the following:
* `join()` with `implode()`
* `sizeof()` with `count()`
* `is_writeable()` with `is_writable()`
* `doubleval()` with a `(float)` cast

In part, this is a follow-up to #47746.

Props jrf.
See #50767.
Built from https://develop.svn.wordpress.org/trunk@49193


git-svn-id: http://core.svn.wordpress.org/trunk@48955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-18 17:27:06 +00:00
John Blackbourn 57a3f803ae Docs: First pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48586


git-svn-id: http://core.svn.wordpress.org/trunk@48348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 20:01:04 +00:00
Sergey Biryukov e13c363b17 Docs: Capitalize "ID", when referring to a post ID, term ID, etc. in a more consistent way.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48104


git-svn-id: http://core.svn.wordpress.org/trunk@47873 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:02:12 +00:00
Sergey Biryukov 7932193708 Coding Standards: Use strict comparison where static strings are involved.
This reduces the number of `WordPress.PHP.StrictComparisons.LooseComparison` issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47808


git-svn-id: http://core.svn.wordpress.org/trunk@47584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 18:42:12 +00:00
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 dd4d98a368 Docs: In various `@return` tags, list the expected type first, instead of `false`.
Follow-up to [46696].

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


git-svn-id: http://core.svn.wordpress.org/trunk@46860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-11 18:32:05 +00:00
Sergey Biryukov e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
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 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 18bd01985b Coding Standards: Rename `$r` variable used with `wp_parse_args()` to `$parsed_args` for clarity.
Props freewebmentor.
Fixes #45059.
Built from https://develop.svn.wordpress.org/trunk@45667


git-svn-id: http://core.svn.wordpress.org/trunk@45478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-25 00:48:58 +00:00
Sergey Biryukov c77e771c84 Date/Time: Replace all instances of `date()` with `gmdate()`.
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

`gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.
Built from https://develop.svn.wordpress.org/trunk@45424


git-svn-id: http://core.svn.wordpress.org/trunk@45235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-05-26 00:12:54 +00:00
Gary Pendergast 97aef0e336 Docs: Remove duplicate docblocks for the `pre_user_login` and `link_category` filters.
Props coffee2code.
Fixes #45308.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-16 05:29:49 +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 dd185824cd Docs: Fix typo in `_walk_bookmarks()` DocBlock.
Props abhijitrakas.
Fixes #44242.
Built from https://develop.svn.wordpress.org/trunk@43319


git-svn-id: http://core.svn.wordpress.org/trunk@43148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-27 08:36:23 +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
Drew Jaynes b7fc55237d Docs: Standardize filter docs in wp-includes/bookmark-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@37494


git-svn-id: http://core.svn.wordpress.org/trunk@37462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:24:28 +00:00
Scott Taylor 744cc75cd1 Sanitize the class passed to `wp_list_bookmarks()` and allow passing an array.
Props ryan, obenland.
Fixes #23150.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-22 20:55:28 +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
Drew Jaynes 8f6188ae53 Ensure inline code is markdown-escaped as such, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Two arguments in `_walk_bookmarks()`
* A code snippet in the class header for `WP_Roles`
* A code snippet in the class header for `WP_HTTP_Proxy`
* Inline code fixes in the summary and a parameter description for `WP_oEmbed::discover()`
* An argument description in `_WP_Editors::parse_settings()`
* Inline code fixes in the summary and a parameter description the `embed_oembed_discover` hook.

Props rarst.
See #30473.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 04:42:22 +00:00
Drew Jaynes dcccc6af4a Add indentation for the hash notation missed in [29108].
See #28841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-11 22:59:16 +00:00
Drew Jaynes 805e0fa692 Convert default arguments documentation for `_walk_bookmarks()` and `wp_list_bookmarks()` into hash notations.
Props coffee2code for the initial patch.
See #28841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-11 22:54:14 +00:00
Scott Taylor 5d72cd4949 In `wp_list_bookmarks()`, `$categorize` should now be `$r['categorize]`.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28327 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 05:11:14 +00:00
Scott Taylor 54321f4c6e Eliminate use of `extract()` in `get_media_item()`.
To test, fire open the old media in the console: `tb_show('Old Media is Weird', 'media-upload.php?type=image&TB_iframe=true&post_id=0');`	
	
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 02:45:15 +00:00
Scott Taylor 9d6eeca015 Eliminate use of `extract()` in `wp_list_bookmarks()`.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 02:18:16 +00:00
Scott Taylor 748765c5ad Eliminate use of `extract()` in `_walk_bookmarks()`.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28231 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 02:05:15 +00:00
Andrew Nacin 803d4ff54d Remove old links_recently_updated_* DB options that never had a UI.
fixes #27649.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27746 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-03 03:10:15 +00:00
Drew Jaynes 7c38bb38b7 Use a docs-specific variable for the `link_category` hook docs in wp-admin/bookmarks-template.php.
See #25364.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-18 16:58:13 +00:00
Drew Jaynes 9577cc4640 Inline documentation for hooks in wp-includes/bookmark-template.php.
Props vinod dalvi, kpdesign.
Fixes #25364.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-20 23:09:09 +00:00
Ryan Boren efcc9adf34 In wp_list_bookmarks(), don't stomp the categorize argument. Fixes categorized display in the links widget.
fixes #22216


git-svn-id: http://core.svn.wordpress.org/trunk@22910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-28 23:19:03 +00:00
Andrew Nacin 30d4885613 Avoid notices with [22426]. props pross. fixes #22420.
git-svn-id: http://core.svn.wordpress.org/trunk@22565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-14 05:09:23 +00:00
Andrew Nacin 5e4cb3af70 Display links if no link categories exist. props MikeHansenMe. fixes #22216.
git-svn-id: http://core.svn.wordpress.org/trunk@22426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-07 19:25:18 +00:00
Andrew Nacin 557d9313a7 Introduce constants to allow for easier expression of time periods in seconds. Adds MINUTE_IN_SECONDS, HOUR_IN_SECONDS, DAY_IN_SECONDS, WEEK_IN_SECONDS, YEAR_IN_SECONDS. props nbachiyski, SergeyBiryukov. fixes #20987.
git-svn-id: http://core.svn.wordpress.org/trunk@21996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-25 05:26:19 +00:00
markjaquith d65e49c9f3 Bunch of PHPDoc corrections and cleanups. props c3mdigital. props SergeyBiryukov. fixes #21149
git-svn-id: http://core.svn.wordpress.org/trunk@21241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-07-09 05:03:53 +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 059d7225fb Refresh deprecated bookmark functions. Props filosofo. fixes #10920
git-svn-id: http://svn.automattic.com/wordpress/trunk@12525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-12-23 18:49:22 +00:00
ryan 8513b29792 Prophylactic escapes
git-svn-id: http://svn.automattic.com/wordpress/trunk@11838 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-08-18 16:05:07 +00:00
markjaquith 3ebf837ced Deprecate sanitize_url() and clean_url() in favor of esc_url_raw() and esc_url()
git-svn-id: http://svn.automattic.com/wordpress/trunk@11383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-05-18 16:00:33 +00:00
markjaquith 6c2ffddf31 _a(), _ea(), _xa(), attr() are now esc_attr__(), esc_attr_e(), esc_attr_x(), esc_attr() -- still short, but less cryptic. see #9650
git-svn-id: http://svn.automattic.com/wordpress/trunk@11204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-05-05 19:43:53 +00:00
azaozz 154896f99d Add a space between image and name in bookmark-template.php, props sivel, fixes #8608
git-svn-id: http://svn.automattic.com/wordpress/trunk@11184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-05-05 02:23:40 +00:00
ryan 2d489767bb s/attribute_escape/attr/. see #9650
git-svn-id: http://svn.automattic.com/wordpress/trunk@11109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-04-28 05:58:45 +00:00
ryan 2b430c9751 Links widget options. Props DD32. see #9196
git-svn-id: http://svn.automattic.com/wordpress/trunk@10712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2009-03-04 23:49:21 +00:00
ryan 9fd20b9893 Update _walk_bookmarks phpdoc. Props brh and sivel. fixes #8607 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@10207 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2008-12-16 07:54:17 +00:00
ryan e89192b1a8 Strip trailing whitespace
git-svn-id: http://svn.automattic.com/wordpress/trunk@10150 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2008-12-09 18:03:31 +00:00