Commit Graph

2022 Commits

Author SHA1 Message Date
Aaron Jorbin 4484e2d2c3 Formatting: Allow KSES custom elements with hyphens
The W3C Custom Elements spec (http://www.w3.org/TR/custom-elements/#concepts) allows you to use your own custom DOM elements/tags. One of the main requirements is that the tag name "must contain a U+002D HYPHEN-MINUS character". This adjusts KSES to allow it.

Fixes #34105.
Props batmoo.



git-svn-id: https://develop.svn.wordpress.org/trunk@38511 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-02 04:16:00 +00:00
Aaron Jorbin 43ca412094 Toolbar: Add unit tests for edit links.
When there is no post ID, there should be no edit link. This adds unit tests for it.

Fixes #22247.
Props akibjorklund.


git-svn-id: https://develop.svn.wordpress.org/trunk@38508 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-02 03:51:01 +00:00
Gary Pendergast 4afafbde25 Database: Find the correct table names in `DELETE` queries with table aliases
Previously, `wpdb::get_table_from_query()` would not find the correct table name in the query `DELETE a FROM table a`, due to not recognising the table alias immediately after the `DELETE` as correct syntax.

Fixes #37660.



git-svn-id: https://develop.svn.wordpress.org/trunk@38507 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-02 00:18:49 +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
Gary Pendergast 5b85aa163f Smilies: Add the `smilies` filter.
This new filter allows the smilies array to be modified with a filter, instead of having to directly access the global.

Props mte90, jorbin.
Fixes #35905.



git-svn-id: https://develop.svn.wordpress.org/trunk@38504 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-01 23:59:59 +00:00
Boone Gorges 78df32df4e Query: 'orderby=include' should support comma-separated lists.
[30052] assumed that 'include' would be an array.

Props TimothyBlynJacobs.
Fixes #37904.

git-svn-id: https://develop.svn.wordpress.org/trunk@38500 602fd350-edb4-49c9-b593-d223f7449a82
2016-09-01 16:50:47 +00:00
John Blackbourn f5bb93e4ac Role/Capability: Add two missing meta capabilities to the caps tests.
See #32394


git-svn-id: https://develop.svn.wordpress.org/trunk@38482 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-31 21:33:44 +00:00
Scott Taylor cba0e2c8f7 Bootstrap: do not go gentle into that good night r38411, r38412, and parts of r38389.
See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38470 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-31 16:30:48 +00:00
John Blackbourn 84c2742175 HTTP API: Revert changes to `wp_parse_url()` while PHP 5.2 errors are investigated.
See #36356


git-svn-id: https://develop.svn.wordpress.org/trunk@38456 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-31 00:23:26 +00:00
Scott Taylor 7ca480cc4e OEmbed: add unit tests. `@group external-oembed` is not run by default.
Props johnbillion, wonderboymusic.
See #32360.


git-svn-id: https://develop.svn.wordpress.org/trunk@38454 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 18:54:53 +00:00
John Blackbourn 7734c6ac24 HTTP API: Separate the test for `wp_parse_url()` with `-1` as its component into a separate test, so the remaining tests can use strict type checking. This helps avoid gotches with the potentially empty values (ie. `null`) that we're testing for.
See #36356


git-svn-id: https://develop.svn.wordpress.org/trunk@38453 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 18:30:51 +00:00
John Blackbourn 8a6568945a HTTP API: The tests for `wp_parse_url()` can't be strict on type because this causes the tests to fail on PHP 5.2 which, bizarrely, returns the results of `parse_url()` (when called with a `$component` parameter) in a different order to later PHP versions.
Fixes #36356


git-svn-id: https://develop.svn.wordpress.org/trunk@38452 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 17:48:06 +00:00
John Blackbourn 48f389015e HTTP API: Add a `$component` parameter to `wp_parse_url()` to give it parity with PHP's `parse_url()` function.
Fixes #36356
Props jrf


git-svn-id: https://develop.svn.wordpress.org/trunk@38449 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 16:35:33 +00:00
Pascal Birchler 19b838af8b Script Loader: Properly adjust tests missed in [38443].
See #37800.

git-svn-id: https://develop.svn.wordpress.org/trunk@38447 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 14:50:14 +00:00
Boone Gorges 2fc4e48d07 Comments: Don't do direct SQL query when fetching decendants.
The SQL query was built using the clauses compiled when querying for
top-level comments. But in cases where the top-level comment query
results are already in the cache, the SQL clauses are not built, and
so are unavailable for `fill_descendants()`. Instead, we call
`get_comments()`, using modified versions of the parameters passed
to the main `WP_Comment_Query` class.

Props Akeif, Rarst for testing.
Fixes #37696.

git-svn-id: https://develop.svn.wordpress.org/trunk@38446 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 14:48:00 +00:00
Boone Gorges f80068e75b Tests: Require `Basic_Object` and `Basic_Subclass` files earlier in call stack.
This ensures compatibility with third-party tools using these classes
in their test suites, after [38285].

Props DylanAuty, Frank Klein, TimothyBlynJacobs.
Fixes #37523.

git-svn-id: https://develop.svn.wordpress.org/trunk@38445 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 14:32:04 +00:00
Boone Gorges caf0e90b30 Tests: Add docblocks for `Basic_Object` and `Basic_Subclass` classes.
Props DylanAuty.
See #37523.

git-svn-id: https://develop.svn.wordpress.org/trunk@38444 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 14:31:56 +00:00
Boone Gorges 53016dd3aa Remove unnecessary uniqueness check in `get_attachment_taxonomies()`.
Running the taxonomy array through `array_unique()` is unnecessary
when the function returns objects, because the associative keys already
ensure uniqueness.

This also fixes a bug when running `get_attachment_taxonomies()` in
HHVM, which doesn't like casting objects to strings for the purposes
of `array_unique()`.

Props swissspidy.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38437 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-30 03:06:06 +00:00
Weston Ruter 7105787ced Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.

Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.

For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/

Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.


git-svn-id: https://develop.svn.wordpress.org/trunk@38436 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 22:58:32 +00:00
Joe McGill 142fefb269 Post Thumbnails: Prevent post thumbnail previews from spilling into other images.
After [38118], when previewing a page with a secondary loop, all post
thumbnails would be filtered to display the post thumbnail for the
page being previewed. This ensures `_wp_preview_post_thumbnail_filter()`
is only applied if the `$post_id` of the post meta being filtered is
equal to the post or page being previewed.

Props swisspidy, joemcgill.
Fixes #37697.

git-svn-id: https://develop.svn.wordpress.org/trunk@38433 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 12:24:09 +00:00
Dion Hulse e916b9e14c HTTP: Accept non-string values in cookies, fixing a regression since 4.5.
Props swissspidy.
Fixes #37768 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@38430 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 02:41:56 +00:00
Dion Hulse 7f2a81061a HTTP: Handle an edgecase within the URI parsing library included in Requests, where if a double slash exists at the start of the path the URL is passed to cURL malformed.
Props flixos90 for initial patch.
Fixes #37733 for trunk.


git-svn-id: https://develop.svn.wordpress.org/trunk@38429 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-29 02:32:48 +00:00
John Blackbourn a03376e798 Security: Trigger a `_doing_it_wrong()` when `check_ajax_referer()` is called without its first parameter. This brings it inline with `check_admin_referer()`.
Fixes #36361


git-svn-id: https://develop.svn.wordpress.org/trunk@38420 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 17:14:52 +00:00
John Blackbourn c786774d21 Themes: Introduce tests for the theme template hierarchy.
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38419 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 16:18:51 +00:00
John Blackbourn 58956ecf2d Permalinks: Correct an invalid peramstructure tag in a test.
Fixes #37858


git-svn-id: https://develop.svn.wordpress.org/trunk@38417 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 12:52:23 +00:00
Pascal Birchler 9701c29b90 Bootstrap: Fix failing external HTTP tests after [38411].
When testing the transports, the transport name needs to be capitalized for the class name to be correct (`WP_Http_Curl` vs. `WP_Http_curl` ).

See #36335.

git-svn-id: https://develop.svn.wordpress.org/trunk@38416 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 10:33:24 +00:00
John Blackbourn 7bb34dc5d9 Query: Add and improve tests for query conditionals on the front page and home page.
See #37851


git-svn-id: https://develop.svn.wordpress.org/trunk@38413 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-28 02:01:53 +00:00
Scott Taylor 4225e71a6b 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@38411 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 22:31:11 +00:00
John Blackbourn 551fa31b5a Media: Add a `$wp_error` parameter to `wp_insert_attachment()` to give it parity with `wp_insert_post()`.
Fixes #37813
Props grapplerulrich, mrahmadawais


git-svn-id: https://develop.svn.wordpress.org/trunk@38408 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 17:24:58 +00:00
John Blackbourn f59a3b54c8 Build/Test tools: Ensure the `Tests_Query_Conditionals` tests set up the environment correctly before re-registering initial taxonomies.
Fixes #37851


git-svn-id: https://develop.svn.wordpress.org/trunk@38407 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 17:02:54 +00:00
John Blackbourn 417de45c08 Build/Test Tools: Add support for `is_front_page()` to `assertQueryTrue()` and assert that all the tested conditions are supported by the method.
Fixes #37849


git-svn-id: https://develop.svn.wordpress.org/trunk@38405 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 15:27:35 +00:00
John Blackbourn 52acaaad50 Themes: Remove failing tests introduced in [38390].
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38403 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 14:52:56 +00:00
Dion Hulse e353179ce5 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


git-svn-id: https://develop.svn.wordpress.org/trunk@38402 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 14:36:42 +00:00
Peter Wilson b8f88aa597 Unit tests: Enforce $args object in `wp_nav_menu()` & `Walker_Nav_Menu`.
WordPress always* passes $args to filters as an array of arugments. A exception is made in `wp_nav_menu()` and the associated walker where these are passed to filters as an object, this has been the case for seven years (since [13368]).

These new tests enforce the use of an object in these filters to ensure backward compatibility is maintained.

See #24587.


git-svn-id: https://develop.svn.wordpress.org/trunk@38400 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 11:27:17 +00:00
Scott Taylor 388690382c 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@38399 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 09:15:01 +00:00
Scott Taylor 02319efa71 Unit Tests:
* Automatically delete objects that we were created during `wpSetUpBeforeClass` - posts, comments, terms (except 1), and user (except 1)
* The amount of leftover data between tests was breathtaking - use the new function: `_delete_all_data()`
* Commit database transactions for all `TestCase`s, not just those that implement `wpSetUpBeforeClass` and `wpTearDownAfterClass`
* The tests run 10-20 seconds faster now

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38398 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 08:35:16 +00:00
johnbillion 8139765b1f Themes: Begin introducing unit tests for the expected theme template hierarchy. More to come.
See #14310


git-svn-id: https://develop.svn.wordpress.org/trunk@38390 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 22:19:16 +00:00
Scott Taylor db0e1ed0af Unit Tests: after r38303, replace usage of `global $_wp_additional_image_sizes` with `wp_get_additional_image_sizes()`.
See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38383 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 20:50:24 +00:00
John Blackbourn e795f6da1d Build/Test Tools: Remove many unnecessary calls to `rand_str()` which can, in theory, fail at random. Static strings are much more appropriate.
See #37371


git-svn-id: https://develop.svn.wordpress.org/trunk@38382 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 20:21:30 +00:00
Boone Gorges 6eaa56f3d4 Don't improperly cast IDs when fetching post, user, or term objects.
Blindly casting passed IDs to integers can generate false positives
when the ID is cast to `1`.

Props deeptiboddapati.
Fixes #37738.

git-svn-id: https://develop.svn.wordpress.org/trunk@38381 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 19:08:23 +00:00
John Blackbourn 5e71c349af Role/Capability: Only users who can manage options should be able to trash/delete the page for posts or the front page, as they are the only users who can restore it or subsequently alter the "Front page displays" setting.
Fixes #37580
Props JakePT


git-svn-id: https://develop.svn.wordpress.org/trunk@38378 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 18:22:28 +00:00
Boone Gorges ff0386b5c1 Use shared fixture in `comment_exists()` tests.
Props Frank Klein.
Fixes #37842.

git-svn-id: https://develop.svn.wordpress.org/trunk@38372 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 17:41:51 +00:00
Scott Taylor a02d79cf73 Site Icon: There is no good reason for `class-wp-site-icon.php` to drop a global instance of itself whenever the file is loaded. The lone use of the `global` instance of `WP_Site_Icon` is in an AJAX action that provides virtually no way to override - the file is loaded immediately before the `global` is used.
Let us remove the `$wp_site_icon` global. I will fall on the sword if this comes back to bite us (waiting with bated breath).

See #37699.


git-svn-id: https://develop.svn.wordpress.org/trunk@38355 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-25 19:08:38 +00:00
Scott Taylor 5e1193272f Taxonomy: in `get_terms()`, do not assume that legacy args are being passed when the only params are top-level `meta_*` values. Add keys in `WP_Term_Query::__construct()`.
Adds unit tests.

Props flixos90, boonebgorges.
Fixes #37568.


git-svn-id: https://develop.svn.wordpress.org/trunk@38337 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 14:44:19 +00:00
Boone Gorges 74b912705d Tests: Fix incorrect variable name from [38330].
See #37630.

git-svn-id: https://develop.svn.wordpress.org/trunk@38331 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 13:48:13 +00:00
Boone Gorges b93e0739a9 Tests: Attachment `create()` method should match signature of other `create()` methods.
Legacy argument format continues to be accepted.

Props bcole808.
See #37630.

git-svn-id: https://develop.svn.wordpress.org/trunk@38330 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 13:42:36 +00:00
Scott Taylor e878e8156b Media: fix unit test after [38296].
https://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages

Fixes #36246.


git-svn-id: https://develop.svn.wordpress.org/trunk@38302 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-22 04:16:29 +00:00
Scott Taylor 081e51d94b Media: use `wp_get_attachment_metadata()` instead of `get_post_meta()` where appropriate.
Adds unit test.

Props JorritSchippers.
Fixes #36246.


git-svn-id: https://develop.svn.wordpress.org/trunk@38296 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-21 06:14:37 +00:00
Boone Gorges 29a5d46701 Allow attachment taxonomies to be fetched as objects.
By adding the `$output` parameter to `get_attachment_taxonomies()`, the
function signature matches that of `get_object_taxonomies()`. The change
also allows for more consistent behavior when passing `output=objects`
to `get_object_taxonomies()` for the 'attachment' object type, since
the `$output` parameter is now passed through the function stack.

Props codemovement.pk.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38292 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 17:34:13 +00:00
Boone Gorges 773eb46bf8 Introduce tests for `get_attachment_taxonomies()`.
See #37368.

git-svn-id: https://develop.svn.wordpress.org/trunk@38291 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-20 17:24:12 +00:00