Commit Graph

62 Commits

Author SHA1 Message Date
Sergey Biryukov
5e6d8f584d Docs: Adjust @since note in shortcode_parse_atts() for consistency with similar notes.
See #47863.

git-svn-id: https://develop.svn.wordpress.org/trunk@46465 602fd350-edb4-49c9-b593-d223f7449a82
2019-10-12 02:48:26 +00:00
Jake Spurlock
1f5525d2ff Shortcodes: Improve handling from shortcode_parse_attts().
Ensure consistency between `shortcode_parse_attts()` when being used directly.

Props mauteri, birgire, SergeyBiryukov, kadamwhite, whyisjake.
Fixes #47863.



git-svn-id: https://develop.svn.wordpress.org/trunk@46369 602fd350-edb4-49c9-b593-d223f7449a82
2019-10-01 03:41:58 +00:00
John Blackbourn
6bd7097626 Docs: Docblock corrections and improvements, mostly related to various pre_* filters.
See #47110


git-svn-id: https://develop.svn.wordpress.org/trunk@46232 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-21 17:40:58 +00:00
Sergey Biryukov
00b03f2a6f I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.

git-svn-id: https://develop.svn.wordpress.org/trunk@45932 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-03 00:39:13 +00:00
Sergey Biryukov
ae8a620efb General: First pass at replacing Codex URLs with a corresponding HelpHub or DevHub article.
Props ianbelanger, tobifjellner, SergeyBiryukov.
See #47771.

git-svn-id: https://develop.svn.wordpress.org/trunk@45674 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-25 22:44:48 +00:00
Sergey Biryukov
e26a5d64d1 Docs: Correct parameter name in strip_shortcodes_tagnames filter DocBlock.
Props uttam007.
Fixes #44691.

git-svn-id: https://develop.svn.wordpress.org/trunk@43549 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-02 15:12:56 +00:00
Sergey Biryukov
32f5aacba7 Coding Standards: Fix code indent in unescape_invalid_shortcodes().
Props joelcj91, GaryJ.
Fixes #43346.

git-svn-id: https://develop.svn.wordpress.org/trunk@42738 602fd350-edb4-49c9-b593-d223f7449a82
2018-02-25 16:35:58 +00:00
Gary Pendergast
8f95800d52 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00
Gary Pendergast
209ede72de General: Add inline PHPCS options to leave regex indentation.
We have a handful of super long regexen that are written over multiple lines, as a collection of strings concatenated together. Each string is indented appropriately for the regex, but PHPCS doesn't recognised this, so defaults to removing the extra whitespace.

Disabling the `Squiz.Strings.ConcatenationSpacing.PaddingFound` rule for these blocks stops the extra whitespace from being removed.

See #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42249 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-28 04:23:11 +00:00
Gary Pendergast
574821573a 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@42228 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-26 23:56:25 +00:00
Drew Jaynes
7157569a72 Docs: Fix a typo in the DocBlock description for add_shortcode() introduced in [41281].
Props grapplerulrich.
See #37222.


git-svn-id: https://develop.svn.wordpress.org/trunk@41286 602fd350-edb4-49c9-b593-d223f7449a82
2017-08-20 20:37:47 +00:00
Drew Jaynes
1eb7fadef4 Docs: Clarify that the second parameter passed to a shortcode callback is the shortcode content or null, rather than the content the shortcode was found in.
See #37222.


git-svn-id: https://develop.svn.wordpress.org/trunk@41283 602fd350-edb4-49c9-b593-d223f7449a82
2017-08-20 19:55:24 +00:00
Drew Jaynes
c93159d69c Shortcodes: Rename the $func parameter for add_shortcode() to $callback to improve clarity.
See #37222. See #41017.


git-svn-id: https://develop.svn.wordpress.org/trunk@41282 602fd350-edb4-49c9-b593-d223f7449a82
2017-08-20 19:47:20 +00:00
Drew Jaynes
b90eb22176 Docs: Improve documentation for add_shortcode() by:
* Removing inline examples already listed in the Code Reference
* Improving the summary and description to explain how tag conflicts are handled
* Supplement the docs for the `$func` parameter by describing the three arguments passed to a shortcode callback.

Props grapplerulrich for the initial patch.
Fixes #37222.


git-svn-id: https://develop.svn.wordpress.org/trunk@41281 602fd350-edb4-49c9-b593-d223f7449a82
2017-08-20 19:43:58 +00:00
Sergey Biryukov
e4bfc8ca90 Shortcodes: Allow using single quotes for empty value attributes.
Props enrico.sorcinelli.
Fixes #37304.

git-svn-id: https://develop.svn.wordpress.org/trunk@41026 602fd350-edb4-49c9-b593-d223f7449a82
2017-07-11 00:53:33 +00:00
Drew Jaynes
a6b883434b Docs: Fix alignment of the $output parameter in the hook doc for the do_shortcode_tag filter.
See #41017.


git-svn-id: https://develop.svn.wordpress.org/trunk@40937 602fd350-edb4-49c9-b593-d223f7449a82
2017-06-25 07:04:22 +00:00
dd32
298b0d0676 Shortcodes: Clarify the docs for pre_do_shortcode_tag and do_shortcode_tag.
Props dhanendran.
Fixes #39294.


git-svn-id: https://develop.svn.wordpress.org/trunk@39665 602fd350-edb4-49c9-b593-d223f7449a82
2017-01-03 03:57:03 +00:00
Drew Jaynes
0587033b4a Docs: Add a missing changelog entry for the point where the $tagnames parameter was added to get_shortcode_regex().
Props keesiemeijer.
Fixes #38914.


git-svn-id: https://develop.svn.wordpress.org/trunk@39351 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-23 17:34:10 +00:00
Aaron D. Campbell
73a1aed2cd Shortcodes: Add new strip_shortcodes_tagnames filter.
With the new `strip_shortcodes_tagnames` filter you can specify which shortcodes are stripped by `strip_shortcodes()`. The default is all registered shortcodes.

Props DylanAuty, orvils, swissspidy.
Fixes #37767.



git-svn-id: https://develop.svn.wordpress.org/trunk@38877 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-23 14:24:26 +00:00
Gary Pendergast
7e4e9f1ce7 Shortcodes: Add a do_shortcode_tag filter.
The addition of the `pre_do_shortcode_tag` in [38506] allows plugins to short-circuit the shortcode execution process, which is particularly helpful for caching expensive shortcodes.

The `do_shortcode_tag` is the corresponding part of that system - when a shortcode hasn't been executed previously, there needs to be a clean method of populating the cache.

Props flixos90.
Fixes #32790.



git-svn-id: https://develop.svn.wordpress.org/trunk@38713 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-04 00:38:45 +00:00
Gary Pendergast
6d59b289a9 Shortcodes: Add the pre_do_shortcode_tag filter.
This filter allows the shortcode generation process to be short-circuited, so expensive short codes can be cached and returned immediately.

Props ideag.
Fixes #37906.



git-svn-id: https://develop.svn.wordpress.org/trunk@38506 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-02 00:09:42 +00:00
Sergey Biryukov
9853789382 Docs: Fix typo in wp-includes/shortcodes.php file description.
Props ixkaito.
Fixes #37175.

git-svn-id: https://develop.svn.wordpress.org/trunk@37865 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-26 10:14:08 +00:00
Drew Jaynes
d11f7ed391 Docs: Standardize filter docs in remaining wp-includes/* files to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.


git-svn-id: https://develop.svn.wordpress.org/trunk@37518 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 18:49:05 +00:00
Dion Hulse
a1cd9049d9 Shortcodes: = is a reserved character in shortcode names, mark it as such.
This allows for shortcodes such as `[shortcode=attribute]` to work, which while never intentionally supported were widely used in the pre-shortcode days.

Props aaroncampbell.
Fixes #34939 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@36097 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-26 04:45:26 +00:00
Drew Jaynes
34bb276504 Docs: Add a missing summary, parameter, and return notations to the DocBlock for strip_shortcode_tag().
Introduced in [18952].

See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@35982 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-16 23:22:33 +00:00
Sergey Biryukov
2c19fe4549 Use correct placeholders in translator comments added in [35542].
See #34249.

git-svn-id: https://develop.svn.wordpress.org/trunk@35543 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-05 21:04:56 +00:00
Drew Jaynes
999bfcb205 I18N: Add translator comments to three _doing_it_wrong() messages added for 4.3 and 4.4.
Also adds a full-stop to an invalid taxonomy message introduced in [34745] and later modified in [35428] for `wp_insert_post()`.

Props pavelevap.
Fixes #34249.


git-svn-id: https://develop.svn.wordpress.org/trunk@35542 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-05 20:55:28 +00:00
Gary Pendergast
9b47d5fcd6 Shortcodes: Tweak the error messages added in [34745].
See #34090.



git-svn-id: https://develop.svn.wordpress.org/trunk@35428 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-29 10:31:31 +00:00
John Blackbourn
ba7dc01639 Abstract the shortcode attribute parsing regex into its own function, update the JavaScript counterpart, and introduce a test to ensure they do not diverge again.
Fixes #34191
Props miqrogroove, johnbillion


git-svn-id: https://develop.svn.wordpress.org/trunk@34933 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-08 03:11:59 +00:00
Helen Hou-Sandi
b1b51495f3 Shortcodes: Pass the name as context for shortcode_atts_{$shortcode}.
props mattheu.
fixes #34167.


git-svn-id: https://develop.svn.wordpress.org/trunk@34868 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-06 14:33:27 +00:00
Scott Taylor
5a24a0a4f8 Shortcodes/Formatting: Add PCRE Performance Testing
* Move pattern from `wptexturize()` into a separate function.
* Move pattern from `wp_html_split()` into a separate function.
* Beautify code for `wp_html_split()`.
* Remove unnecessary instances of `/s` modifier in patterns that don't use dots.
* Add `tests/phpunit/data/formatting/whole-posts.php` for testing larger strings.
* Add function `benchmark_pcre_backtracking()`.
* Add tests for `wp_html_split()`.
* Add tests for `wptexturize()`.
* Add tests for `get_shortcode_regex()`.

Props miqrogroove.
Fixes #34121.


git-svn-id: https://develop.svn.wordpress.org/trunk@34761 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 04:25:40 +00:00
Scott Taylor
e0b34f44a3 Shortcodes: Fix PCRE performance bugs in get_shortcode_regexp() and related to wptexturize(), do_shortcode(), and strip_shortcodes()
Alters unit tests.

Props miqrogroove.
Fixes #33517.


git-svn-id: https://develop.svn.wordpress.org/trunk@34747 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 18:04:13 +00:00
Scott Taylor
1b70f27b04 Shortcodes: prevent registration of invalid shortcode names.
Adds unit tests.

Props miqrogroove.
Fixes #34090.


git-svn-id: https://develop.svn.wordpress.org/trunk@34745 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 17:33:58 +00:00
Scott Taylor
3c50d18785 Shortcodes: clarify the @return docs for shortcode_parse_atts().
Props miqrogroove.
See #23307.


git-svn-id: https://develop.svn.wordpress.org/trunk@34744 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 17:31:58 +00:00
Nikolay Bachiyski
c430a82236 Shortcodes: don't allow unclosed HTML elements in attributes
git-svn-id: https://develop.svn.wordpress.org/trunk@34134 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 22:35:22 +00:00
Scott Taylor
3b8c5529cb foreach is a statement, not a function.
See #33491.


git-svn-id: https://develop.svn.wordpress.org/trunk@33734 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-25 20:27:56 +00:00
Dominik Schilling (ocean90)
0ec540b946 Pinking shears.
git-svn-id: https://develop.svn.wordpress.org/trunk@33627 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-17 21:38:24 +00:00
ocean90
239759914f Shortcodes: Trim whitespace after sanitizing the shortcode output.
props Ankit K Gupta, obenland, miqrogroove.
fixes #33259.

git-svn-id: https://develop.svn.wordpress.org/trunk@33600 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-09 20:48:02 +00:00
Dion Hulse
7a35bff916 Fix do_shortcode('<[shortcode]') edge case.
Props miqrogroove.
Merges [33499] trunk.
See #33116.


git-svn-id: https://develop.svn.wordpress.org/trunk@33594 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-07 02:49:31 +00:00
Scott Taylor
4f814ec9ae Protect newlines inside of CDATA. This was breaking things, notably inline JS that used comments for HTML standards compat.
* Tokenize newlines in `WP_Embed::autoembed()` before running `->autoembed_callback()`
* Tokenize newlines with placeholders in `wpautop()` 
* Introduce `wp_html_split()` to DRY the RegEx from `wp_replace_in_html_tags()` and `do_shortcodes_in_html_tags()`

Adds unit tests.

Props miqrogroove, kitchin, azaozz.
Fixes #33106.


git-svn-id: https://develop.svn.wordpress.org/trunk@33469 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-28 23:02:04 +00:00
Gary Pendergast
7b41adf712 Shortcodes: Improve the reliablity of shortcodes inside HTML tags.
Props miqrogroove.

See #15694.



git-svn-id: https://develop.svn.wordpress.org/trunk@33359 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-22 05:14:50 +00:00
John Blackbourn
063637755b Allow shortcode parameter names (attributes) to contain dashes.
Props aaroncampbell, tyxla, izem
Fixes #9405


git-svn-id: https://develop.svn.wordpress.org/trunk@33118 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-07 23:58:49 +00:00
Scott Taylor
ee4e5c4b35 Check is_callable() in do_shortcode_tag(), not add_shortcode().
Add a `_doing_it_wrong()` in `do_shortcode_tag()` when `is_callable()` is `false`.

Props aaroncampbell.
See #32445.


git-svn-id: https://develop.svn.wordpress.org/trunk@32867 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-19 21:32:31 +00:00
Scott Taylor
a3f2743f9a Add missing doc blocks to shortcodes.php.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32624 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-27 19:39:00 +00:00
Dominik Schilling (ocean90)
b0d6757918 Use HTTPS URLs for codex.wordpress.org.
see #27115.

git-svn-id: https://develop.svn.wordpress.org/trunk@32116 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-12 21:28:58 +00:00
Drew Jaynes (DrewAPicture)
032ec0d24a Remove a stray period introduced in [31242].
Props SergeyBiryukov.
See #31048.


git-svn-id: https://develop.svn.wordpress.org/trunk@31245 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-19 08:46:24 +00:00
Drew Jaynes (DrewAPicture)
73780fdd32 Add more complete documentation for parameters, globals, and return values to the DocBlocks for remove_shortcode(), shortcode_exists(), and do_shortcode().
Props SergeyBiryukov.
Fixes #31048.


git-svn-id: https://develop.svn.wordpress.org/trunk@31243 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-19 08:39:10 +00:00
Drew Jaynes (DrewAPicture)
596412fb0b Ensure both parameters and the return for has_shortcode() are fully documented.
Props cais, SergeyBiryukov
See #31048.


git-svn-id: https://develop.svn.wordpress.org/trunk@31242 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-19 08:35:05 +00:00
Scott Taylor
865185903b There are some random add_action() and add_filter() calls littered around some files in wp-includes/. These should be moved to wp-includes/default-filters.php with the rest of the registered hooks. It seems like this was the best practice for awhile and then we randomly stopped. This file loads way before any of the includes, so the hooks will be registered for any request that loads WordPress, even SHORTINIT - a lot of the hooks registered won't run anyways (that's already the case).
See #30947.


git-svn-id: https://develop.svn.wordpress.org/trunk@31168 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 16:39:39 +00:00
Scott Taylor
da9057fd6d Use && instead of and in the 3 places where and was used.
See #30799.


git-svn-id: https://develop.svn.wordpress.org/trunk@31099 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-08 21:11:46 +00:00