Commit Graph

56 Commits

Author SHA1 Message Date
Sergey Biryukov 6742d0d7a6 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47808 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-16 18:40:52 +00:00
Sergey Biryukov 0b4e2c4604 Coding Standards: Use strict type check for `in_array()` and `array_search()` where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@47550 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-05 03:00:44 +00:00
Sergey Biryukov cfc3b57488 Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-29 00:43:23 +00:00
Sergey Biryukov 4c2ee4e9ff Docs: In various `@return` tags, list the expected type first, instead of `false`.
Follow-up to [46696].

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47060 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-11 18:30:58 +00:00
John Blackbourn 3cdee7a705 Docs: Further improve documentation of known return types, plus other docs fixes.
See #48303


git-svn-id: https://develop.svn.wordpress.org/trunk@46661 602fd350-edb4-49c9-b593-d223f7449a82
2019-11-05 21:25:53 +00:00
Gary Pendergast 4503f93961 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45590 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 23:41:16 +00:00
Gary Pendergast a75d153eee 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
John Blackbourn e207cdf2bb Docs: Document more parameters and properties using typed array notation.
See #41756


git-svn-id: https://develop.svn.wordpress.org/trunk@42876 602fd350-edb4-49c9-b593-d223f7449a82
2018-03-25 19:32:24 +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
Weston Ruter 18a231bad6 Embeds: Improve consistency of update and refresh logic for oEmbed caching between `oembed_cache` and post meta.
* Allow updating oEmbed cache during `parse-embed` requests for non-post editors (such as widgets).
* Update any existing `oembed_cache` post when `usecache` and TTL has passed.
* Do not overwrite a previously valid cache with `{{unknown}}`.

Props dlh.
See #34115.
Fixes #42310.


git-svn-id: https://develop.svn.wordpress.org/trunk@42009 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-24 23:09:43 +00:00
Weston Ruter 6e74a9bf23 Embeds: Cache oEmbeds in an `oembed_cache` custom post type instead of postmeta when there is no global `$post`.
Add processing of embeds to rich Text widget.

Props swissspidy, westonruter, ocean90, johnbillion.
See #40854, #39994, #40935.
Fixes #34115.


git-svn-id: https://develop.svn.wordpress.org/trunk@41651 602fd350-edb4-49c9-b593-d223f7449a82
2017-09-30 01:14:34 +00:00
Drew Jaynes b4d81bd654 Docs: Remove `@access` notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.


git-svn-id: https://develop.svn.wordpress.org/trunk@41162 602fd350-edb4-49c9-b593-d223f7449a82
2017-07-27 00:40:27 +00:00
Scott Taylor 1b292c965a Embed: `wp-settings.php` loads `class-wp-embed.php`, which currently produces side effects. Move the `global` instantiation to `wp-settings.php`. `WP_Embed` is then in a file by itself.
See #37827.


git-svn-id: https://develop.svn.wordpress.org/trunk@38362 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 09:52:18 +00:00
Drew Jaynes 5cf0ef170a Docs: Standardize capitalization of Ajax throughout core documentation per the core spelling guide.
Ajax, while considered an acronym for Asynchronous JavaScript and XML, is most commonly capitalized only in the first character.

Part props ocean90.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@38028 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-10 00:50:21 +00:00
Andrew Ozz 245709dcd1 Auto-embedding:
- We already match URLs on their own line, add another regex to match URLs in their own paragraphs.
- Always exclude the `\s<>"` characters when matching.
- Add more unit tests.

Props iseulde, azaozz.
Fixes #25387.

git-svn-id: https://develop.svn.wordpress.org/trunk@37627 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-02 21:23:43 +00:00
Drew Jaynes b208dae5e6 Docs: Apply inline `@see` tags to hooks referenced in DocBlocks for core classes.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

See #36921.


git-svn-id: https://develop.svn.wordpress.org/trunk@37539 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-23 18:53:05 +00:00
Drew Jaynes c49afe285c Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.


git-svn-id: https://develop.svn.wordpress.org/trunk@37492 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 18:14:19 +00:00
Drew Jaynes 520ed6b725 Docs: Remove/replace invalid inline `@link` tags in DocBlocks in wp-includes/*.
Fixes #36910.


git-svn-id: https://develop.svn.wordpress.org/trunk@37487 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 17:39:00 +00:00
Dominik Schilling (ocean90) 39ddaa65cc Docs: Correct grammar when referring to "a URL" vs "an URL" in several places.
Fixes #36218.

git-svn-id: https://develop.svn.wordpress.org/trunk@36970 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-12 12:38:48 +00:00
Gary Pendergast 99180a09ba Embeds: Remove the `allow_insecure_embeds` filter.
This reverts [35640]. On further reflection, it really didn't do what it said it did.

Fixes #34588.



git-svn-id: https://develop.svn.wordpress.org/trunk@35702 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-19 05:01:07 +00:00
Gary Pendergast 1824468e8f Embeds: Add the `allow_insecure_embeds` filter.
This allows a site to disable non-SSL embeds.

Fixes #34588.



git-svn-id: https://develop.svn.wordpress.org/trunk@35640 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-16 00:22:16 +00:00
Gary Pendergast 43bd3d46c9 Embeds: Add oEmbed provider support.
For the past 6 years, WordPress has operated as an oEmbed consumer, allowing users to easily embed content from other sites. By adding oEmbed provider support, this allows any oEmbed consumer to embed posts from WordPress sites.

In addition to creating an oEmbed provider, WordPress' oEmbed consumer code has been enhanced to work with any site that provides oEmbed data (as long as it matches some strict security rules), and provides a preview from within the post editor.

For security, embeds appear within a sandboxed iframe - the iframe content is a template that can be styled or replaced entirely by the theme on the provider site.

Props swissspidy, pento, melchoyce, netweb, pfefferle, johnbillion, extendwings, davidbinda, danielbachhuber, SergeyBiryukov, afercia

Fixes #32522.



git-svn-id: https://develop.svn.wordpress.org/trunk@34903 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-07 10:35:18 +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
Scott Taylor f629e70da3 `WP_Embed::maybe_run_ajax_cache()` doesn't hook to pages, because it only happens on `'edit_form_advanced'`, not `'edit_page_form'`. Make sure it runs for pages as well. This was probably not intentional, see [29557].
Fixes #32418.


git-svn-id: https://develop.svn.wordpress.org/trunk@33642 602fd350-edb4-49c9-b593-d223f7449a82
2015-08-19 05:39:31 +00:00
Andrew Ozz 35acd9abf8 Use the `embed_maybe_make_link` filter to test WP_Embed::autoembed().
See #33106.

git-svn-id: https://develop.svn.wordpress.org/trunk@33470 602fd350-edb4-49c9-b593-d223f7449a82
2015-07-29 00:01:22 +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
Scott Taylor 46752a491e When calling `unset()`, it is unnecessary to immediately precede it with a call to `isset()`.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32545 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-22 05:46:47 +00:00
Scott Taylor 06ea5c78be Clean up doc blocks for `class-wp-embed.php`.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32544 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-22 05:14:30 +00:00
Scott Taylor 625e7135f3 After [32258], restore the parts of [31620] and [31626] that weren't changes to the UI, but were improvements to existing code.
* Use `wp.shortcode()` instead of manually constructing a shortcode in `views/embed/link`
* In `WP_Embed`, store the last URL and last set of attributes requested in class properties
* `wp_ajax_parse_embed()`, allow `[embed]`s to have attributes. Return `attr` in the response.

See #31139.


git-svn-id: https://develop.svn.wordpress.org/trunk@32330 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-30 21:39:52 +00:00
Andrew Ozz 925682e2d1 Revert editing of video embed parameters in the media modal, [31620] and [31626] for now. Plan on revisiting in 4.3.
Props iseulde. Fixes #31139, fixes #32006.

git-svn-id: https://develop.svn.wordpress.org/trunk@32258 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-21 22:40:23 +00:00
Scott Taylor 4726669b3f Allow inline editing of `width` and `height` parameters while previewing an embed in the media modal:
* Use `wp.shortcode()` instead of manually constructing a shortcode in `views/embed/link`
* Allow a URL to transition to a shortcode (and vice versa) when returning an embed to TinyMCE
* In `WP_Embed`, store the last URL and last set of attributes requested in class properties
* `wp_ajax_parse_embed()`, allow `[embed]`s to have attributes. Return `attr` in the response.

This is a first pass to allow broad testing with recent MCE view changes. 

See #31139.


git-svn-id: https://develop.svn.wordpress.org/trunk@31620 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 05:59:10 +00:00
Sergey Biryukov 4fdc7c7a0b Don't force newlines around URLs in WP_Embed::autoembed().
props chipx86, sgrant.
fixes #23776.

git-svn-id: https://develop.svn.wordpress.org/trunk@31066 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-07 07:50:58 +00:00
Scott Taylor 47f2c42528 Inline `<script>`s that are only printed in the admin for pages that are served with the HTML5 doctype absolutely do not need `CDATA` comments.
Props tw2113 for the initial patch.
See #18788.


git-svn-id: https://develop.svn.wordpress.org/trunk@31034 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-03 05:45:17 +00:00
Scott Taylor f6f12912e2 Improve some docs for `@param`. Remove an unneeded `$wpdb` global import.
See #30799.


git-svn-id: https://develop.svn.wordpress.org/trunk@30979 602fd350-edb4-49c9-b593-d223f7449a82
2014-12-20 20:55:21 +00:00
Scott Taylor 4d46475b3d Improve various `@param` docs for `src/wp-includes/*`.
See #30224.


git-svn-id: https://develop.svn.wordpress.org/trunk@30681 602fd350-edb4-49c9-b593-d223f7449a82
2014-12-01 01:33:34 +00:00
Drew Jaynes (DrewAPicture) ccc5f88887 Ensure inline code is markdown-escaped as such, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Backtick-escapes a `<link>` tag in a parameter description for the `embed_oembed_discover` hook
* Inline code fixes in the summary and return description for `WP_List_Table::get_table_classes()`
* Removes HTML markup from the summary for `WP_List_Table::display_rows_or_placeholder()`
* Backtick-escapes a `<tr>` tag in a parameter description for `WP_Users_List_Table::single_row()`
* Converts non-DocBlocks into multi-line comments in `WP_Dependencies::do_items()`
* Removes HTML markup from the summary for the `comment_form_top` hook.
* Inline code and snippet fixes in the description for `wp_get_schedules()`

Props rarst for the initial patch.
See #30473.


git-svn-id: https://develop.svn.wordpress.org/trunk@30537 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-24 04:57:17 +00:00
Drew Jaynes (DrewAPicture) f843741d33 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@30536 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-24 04:41:15 +00:00
Scott Taylor 31df6204d0 Fix the return docs for `WP_Embed->maybe_make_link()`.
See #30224.


git-svn-id: https://develop.svn.wordpress.org/trunk@30178 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-03 02:26:34 +00:00
Drew Jaynes (DrewAPicture) 3cc10d77a0 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@30105 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 01:04:55 +00:00
Mark Jaquith 7063377539 Use HTTPS URLs for core.trac.wordpress.org
see #27115

git-svn-id: https://develop.svn.wordpress.org/trunk@29788 602fd350-edb4-49c9-b593-d223f7449a82
2014-09-29 13:27:55 +00:00
Andrew Nacin ca32a2d410 Pinking shears.
git-svn-id: https://develop.svn.wordpress.org/trunk@29707 602fd350-edb4-49c9-b593-d223f7449a82
2014-09-04 15:22:58 +00:00
Sergey Biryukov 41a2e31b43 Don't limit WP_Embed::cache_oembed() to posts and pages.
props bordoni, helen.
fixes #28639.

git-svn-id: https://develop.svn.wordpress.org/trunk@29557 602fd350-edb4-49c9-b593-d223f7449a82
2014-08-20 19:31:46 +00:00
Drew Jaynes (DrewAPicture) 8feaba4ca2 Clean up some missing `@access` tags and other tweaks for 4.0.0-functionality docs.
See #28885.


git-svn-id: https://develop.svn.wordpress.org/trunk@29455 602fd350-edb4-49c9-b593-d223f7449a82
2014-08-09 19:31:35 +00:00
Drew Jaynes (DrewAPicture) 1a2da86366 Inline documentation cleanup for 4.0 audit.
Document the first parameter, `$time`, in the 'oembed_ttl' filter, added in [28972].

See #14759 and #28885.


git-svn-id: https://develop.svn.wordpress.org/trunk@29160 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-14 00:43:51 +00:00
Helen Hou-Sandi 3adcda996b Improve oEmbed caching. Introduces the concept of a TTL for oEmbed caches and a filter for `oembed_ttl`.
We will no longer replace previously valid oEmbed responses with an `{{unknown}}` cache value. When this happens due to reaching a rate limit or a service going down, it is data loss, and is not acceptable. This means that oEmbed caches for a post are no longer deleted indiscriminately every time that post is saved.

oEmbed continues to be cached in post meta, with the addition of a separate meta key containing the timestamp of the last retrieval, which is used to avoid re-requesting a recently cached oEmbed response. By default, we consider a valued cached in the past day to be fresh. This can greatly reduce the number of outbound requests, especially in cases where a post containing multiple embeds is saved frequently.

The TTL used to determine whether or not to request a response can be filtered using `oembed_ttl`, thus allowing for the possibility of respecting the optional oEmbed response parameter `cache_age` or altering the period of time a cached value is considered to be fresh.

Now that oEmbeds are previewed in the visual editor as well as the media modal, oEmbed caches are often populated before a post is saved or published. By pre-populating and avoiding having to re-request that response, we also greatly reduce the chances of a stampede happening when a published post is visible before oEmbed caching is complete.

As it previously stood, a stampede was extremely likely to happen, as the AJAX caching was only triggered when `$_GET['message']` was 1. The published message is 6. We now trigger the caching every time `$_GET['message']` is present on the edit screen, as we are able to avoid triggering so many HTTP requests overall.

props markjaquith. fixes #14759. see #17210.


git-svn-id: https://develop.svn.wordpress.org/trunk@28972 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-03 16:44:15 +00:00
Sergey Biryukov 4176aa347e Pass $url parameter to wp_embed_defaults() and 'embed_defaults' filter.
props wpsmith, sabreuse, jacobdubail.
fixes #20151.

git-svn-id: https://develop.svn.wordpress.org/trunk@28923 602fd350-edb4-49c9-b593-d223f7449a82
2014-06-30 11:15:33 +00:00
Andrew Ozz df6eb733eb Secure embeds in the editor (first run):
- When the user pastes an embeddable http URL, try to get the https embed.
- If an embed provider doesn't support ssl embeds, show a placeholder/error message.
- Revise the way we return error messages.
See #28195, #28507.

git-svn-id: https://develop.svn.wordpress.org/trunk@28919 602fd350-edb4-49c9-b593-d223f7449a82
2014-06-30 05:48:16 +00:00
Scott Taylor 3b060c1931 Read the `src` attribute for the `[embed]` shortcode if the shortcode's body is empty.
These work:
`[embed src="https://www.youtube.com/watch?v=ZqD-LPOWIT0"]`
`[embed src="https://www.youtube.com/watch?v=ZqD-LPOWIT0"][/embed]`

If you do:
`[embed src="https://www.youtube.com/watch?v=ZqD-LPOWIT0"]http://any-other-url.com[/embed]`

... "http://any-other-url.com" will be the URL that is parsed.

Props kovshenin, aaroncampbell for making initial patches.
Fixes #24456.



git-svn-id: https://develop.svn.wordpress.org/trunk@28559 602fd350-edb4-49c9-b593-d223f7449a82
2014-05-23 18:05:24 +00:00
Scott Taylor 26af443ade Add access modifiers to methods/members in `WP_Embed`.
See #27881, #22234.


git-svn-id: https://develop.svn.wordpress.org/trunk@28510 602fd350-edb4-49c9-b593-d223f7449a82
2014-05-19 05:46:56 +00:00