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
Introduces the action `wp_after_insert_post` inside a wrapper function of the same name. This hook allows plugin developers to access a posts full data (including its terms and meta data) regardless of the workflow used to save it.
A new parameter is introduced to `wp_insert_post()` to indicate whether the hook should be fired within the function call or will be fired afterward.
Props aristath, Collizo4sky, danielbachhuber, joyously, kadamwhite, kraftbj, markparnell, mikeschroder, noisysocks, peterwilsoncc, SergeyBiryukov, talldanwp, thewebprincess, TimothyBlynJacobs.
Fixes#45114.
Built from https://develop.svn.wordpress.org/trunk@49172
git-svn-id: http://core.svn.wordpress.org/trunk@48934 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When modifying terms assigned to an object, replace full term recounts with incrementing/decrementing the count as appropriate. This provides a significant performance boost on sites with a high number of term/object relationships and/or posts.
Introduces the functions `wp_increment_term_count()`, `wp_decrement_term_count()`, `wp_modify_term_count_by()` and `wp_modify_term_count_by_now()` for updating the term count.
Introduces the function `_wp_prevent_term_counting()` for preventing double counting on posts that are about to transition.
Adds the parameter `update_count_by_callback` to `register_taxonomy()` to allow developers to use a custom callback for incrementing or decrementing a term count.
Props boonebgorges, davidbaumwald, hellofromTonya, johnbillion, lcyh78, mattoperry, peterwilsoncc, rebasaurus, whyisjake.
Fixes#40351.
Built from https://develop.svn.wordpress.org/trunk@49141
git-svn-id: http://core.svn.wordpress.org/trunk@48903 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This allows for edits to be made to a restored post before it goes live again. This also prevents scheduled posts being published unexpectedly if they are untrashed after their originally scheduled date.
The old behaviour of restoring untrashed posts to their original status can be reinstated using the `wp_untrash_post_set_previous_status()` helper function.
Also fixes an issue where the incorrect post ID gets passed to hooks if no post ID is passed to the function.
Props harrym, bananastalktome, jaredcobb, chriscct7, melchoyce, johnbillion, pankajmohale
Fixes#23022
Built from https://develop.svn.wordpress.org/trunk@49125
git-svn-id: http://core.svn.wordpress.org/trunk@48887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Transitioning posts from `auto-draft` to `publish` via `wp_publish_post()` could result in published posts without the default category or custom taxonomy default terms.
Props frank-klein, TimothyBlynJacobs, peterwilsoncc.
Fixes#51292.
Built from https://develop.svn.wordpress.org/trunk@49000
git-svn-id: http://core.svn.wordpress.org/trunk@48762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the labels for the reusable block post type were just “block”. The document settings tab in the block editor has been changed to use the post type label specified instead to be more specific. Changing the reusable block post type labels to “reusable block” prevents two “Block” tabs from showing in the editor.
Props desaiuditd, peterwilsoncc.
Fixes#50755.
Built from https://develop.svn.wordpress.org/trunk@48829
git-svn-id: http://core.svn.wordpress.org/trunk@48591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This ensures that the correct values are being compared when retrieving the result for custom post types.
Additionally, pass the `$post_type` parameter to `get_lastpostdate` and `get_lastpostmodified` filters.
Props mikaumoto, munyagu, donmhico, johnbillion, SergeyBiryukov.
Fixes#47777.
Built from https://develop.svn.wordpress.org/trunk@48631
git-svn-id: http://core.svn.wordpress.org/trunk@48393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This allows special pages to be denoted as such when editing a menu in the Customizer.
This applies to the Front Page, Posts Page, and Privacy Policy Page.
Follow-up to [47211], [47213], [47763].
Props dlh, whyisjake, SergeyBiryukov.
Fixes#46829. See #49374.
Built from https://develop.svn.wordpress.org/trunk@48619
git-svn-id: http://core.svn.wordpress.org/trunk@48381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When `wp_count_posts()` is cached, it does so with all statuses defaulted to 0. The problem is however, if this is called before all plugins have registered their desired statuses, they won't have that default.
Fixes#49685.
Props obliviousharmony, SergeyBiryukov.
Built from https://develop.svn.wordpress.org/trunk@48497
git-svn-id: http://core.svn.wordpress.org/trunk@48259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Move default term assignment from `wp_set_object_terms()` to `wp_insert_post()`.
* Make sure the passed taxonomy list overwrites the existing list if not empty.
* Remove the default term option on `unregister_taxonomy()`.
* Prevent deletion of the default term in `wp_delete_term()`.
Props enrico.sorcinelli, TimothyBlynJacobs.
See #43517.
Built from https://develop.svn.wordpress.org/trunk@48480
git-svn-id: http://core.svn.wordpress.org/trunk@48249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The new default_term argument is added to `register_taxonomy()` allowing a user to define the default term `name` and optionally `slug` and `description`.
Fixes#43517.
Props enrico.sorcinelli, SergeyBiryukov, desrosj, davidbaumwald, whyisjake.
Built from https://develop.svn.wordpress.org/trunk@48356
git-svn-id: http://core.svn.wordpress.org/trunk@48125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This allows for hooking into both the create and update events with a single callback, in the same way that is already possible for posts via the `save_post` and `save_post_{$post->post_type}` actions.
Props dlh.
Fixes#48416.
Built from https://develop.svn.wordpress.org/trunk@48314
git-svn-id: http://core.svn.wordpress.org/trunk@48083 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This further makes the function more consistent with `get_the_ID()` or `wp_get_post_parent_id()`, both returning `false` for a non-existing post.
Additionally, document that `get_post_thumbnail_id()` returns `0` if the thumbnail image is not set.
Follow-up to [47160].
Props theMikeD, dingo_d, netpassprodsr, SergeyBiryukov.
Fixes#49832. See #40096.
Built from https://develop.svn.wordpress.org/trunk@48310
git-svn-id: http://core.svn.wordpress.org/trunk@48079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The filter is the callback function added with `add_filter()`, therefore the hook passes a value to the filter, and the filter returns a value to change its behaviour.
The documentation is referring to the latter.
Props johnbillion.
See #49572, #16557.
Built from https://develop.svn.wordpress.org/trunk@48185
git-svn-id: http://core.svn.wordpress.org/trunk@47954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This solution extends the wp_insert_post_data filter to pass in addition to the slashed/sanitized/processed data, and the slashed/sanitized/unprocessed data, to also pass the initial slashed/unsanitized/unprocessed data which was passed into wp_insert_post(). This then allows plugins to have complete control over how sanitization is performed based on the post type.
Props westonruter, peterwilsoncc, sstoqnov, whyisjake, xknown.
Built from https://develop.svn.wordpress.org/trunk@47633
git-svn-id: http://core.svn.wordpress.org/trunk@47408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Introduces the filter `pre_delete_attachment` to allow developers to prevent or modify the deletion of attachments. This improves consistency with `wp_delete_post()` and `wp_trash_post()`.
Props joemcgill, peterwilsoncc.
Fixes#49597.
Built from https://develop.svn.wordpress.org/trunk@47448
git-svn-id: http://core.svn.wordpress.org/trunk@47235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This resolves PHP notices in a few places in core where this capability is checked.
Props Mte90, johnbillion, dipesh.kakadiya, jipmoors, bamadesigner, dd32, johnjamesjacoby, xedin.unknown, flixos90, SergeyBiryukov.
Fixes#30991.
Built from https://develop.svn.wordpress.org/trunk@47357
git-svn-id: http://core.svn.wordpress.org/trunk@47144 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This ensures that `wp_update_post()` does not unintentionally modify post tags if the post has several tags with the same name but different slugs.
Tags should only be modified if `tags_input` parameter was explicitly provided, and is different from the existing tags.
Props kaggdesign, SergeyBiryukov.
Fixes#45121.
Built from https://develop.svn.wordpress.org/trunk@47317
git-svn-id: http://core.svn.wordpress.org/trunk@47115 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[3525] allowed a difference up to 59 seconds between the post date/time and the current time to consider the post published instead of scheduled, but that didn't take start of a new minute into account.
Rapidly creating post fixtures in unit tests could encounter a one-second discrepancy between `current_time( 'mysql' )` and `gmdate( 'Y-m-d H:i:s' )`, returning values like `2019-12-16 23:43:00` vs. `2019-12-16 23:42:59`, respectively, and setting the post to a `future` status instead of `publish`.
[45851], while working as intended, made the issue somewhat more likely to occur.
This caused all sorts of occasional random failures in various tests on Travis, mostly on PHP 7.1.
Fixes#48145.
Built from https://develop.svn.wordpress.org/trunk@46968
git-svn-id: http://core.svn.wordpress.org/trunk@46768 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Expose a date_floating property on all status objects to permit clients (including the block editor) to make correct decisions about date handling for posts of varying status.
Props mnelson4, earnjam, kadamwhite, jnylen0, nerrad, pento.
See #39953.
Built from https://develop.svn.wordpress.org/trunk@46252
git-svn-id: http://core.svn.wordpress.org/trunk@46064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, the direct SQL query used to identify trackbacks in
`do_all_pings()` performed poorly, due to an unindexed query against the
`to_ping` column. We improve performance in two ways. First, we switch
to using a postmeta flag for posts that require trackbacks to be sent;
queries joining against the postmeta table that check only the `meta_key`
are generally quite fast. Second, we switch to the use of `WP_Query`,
making the query cacheable and filterable using standard methods.
Props dshanske, spacedmonkey, janw.oostendorp, mrmadhat, birgire.
Fixes#36824.
Built from https://develop.svn.wordpress.org/trunk@46178
git-svn-id: http://core.svn.wordpress.org/trunk@45990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Introduces `wp_get_original_image_path()` that retrieves the path to the originally uploaded image in all cases, and `big_image_size_threshold` filter to set the pixel value above which images will be scaled. The same value is used as max-width and max-height when scaling.
See #47873.
Built from https://develop.svn.wordpress.org/trunk@46076
git-svn-id: http://core.svn.wordpress.org/trunk@45888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* 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