Code Modernization: Fix PHP 8 deprecation notices for optional function parameters declared before required parameters.
As it already was not possible to pass the required parameters without also passing the optional one anyway, removing the default value for the (not so) optional parameters should not affect backward compatibility. This change affects three functions in core: * `get_comment_delimited_block_content()` * `do_enclose()` * `_wp_delete_tax_menu_item()` Props jrf, ayeshrajans, desrosj. Fixes #50343. git-svn-id: https://develop.svn.wordpress.org/trunk@48794 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b9e5fa1077
commit
9c220ffaf7
@ -397,12 +397,13 @@ function strip_core_block_namespace( $block_name = null ) {
|
|||||||
*
|
*
|
||||||
* @since 5.3.1
|
* @since 5.3.1
|
||||||
*
|
*
|
||||||
* @param string $block_name Block name.
|
* @param string|null $block_name Block name. Null if the block name is unknown,
|
||||||
|
* e.g. Classic blocks have their name set to null.
|
||||||
* @param array $block_attributes Block attributes.
|
* @param array $block_attributes Block attributes.
|
||||||
* @param string $block_content Block save content.
|
* @param string $block_content Block save content.
|
||||||
* @return string Comment-delimited block content.
|
* @return string Comment-delimited block content.
|
||||||
*/
|
*/
|
||||||
function get_comment_delimited_block_content( $block_name = null, $block_attributes, $block_content ) {
|
function get_comment_delimited_block_content( $block_name, $block_attributes, $block_content ) {
|
||||||
if ( is_null( $block_name ) ) {
|
if ( is_null( $block_name ) ) {
|
||||||
return $block_content;
|
return $block_content;
|
||||||
}
|
}
|
||||||
|
@ -830,14 +830,16 @@ function wp_extract_urls( $content ) {
|
|||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was
|
* @since 5.3.0 The `$content` parameter was made optional, and the `$post` parameter was
|
||||||
* updated to accept a post ID or a WP_Post object.
|
* updated to accept a post ID or a WP_Post object.
|
||||||
|
* @since 5.6.0 The `$content` parameter is no longer optional, but passing `null` to skip it
|
||||||
|
* is still supported.
|
||||||
*
|
*
|
||||||
* @global wpdb $wpdb WordPress database abstraction object.
|
* @global wpdb $wpdb WordPress database abstraction object.
|
||||||
*
|
*
|
||||||
* @param string $content Post content. If `null`, the `post_content` field from `$post` is used.
|
* @param string|null $content Post content. If `null`, the `post_content` field from `$post` is used.
|
||||||
* @param int|WP_Post $post Post ID or post object.
|
* @param int|WP_Post $post Post ID or post object.
|
||||||
* @return null|bool Returns false if post is not found.
|
* @return null|bool Returns false if post is not found.
|
||||||
*/
|
*/
|
||||||
function do_enclose( $content = null, $post ) {
|
function do_enclose( $content, $post ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
// @todo Tidy this code and make the debug code optional.
|
// @todo Tidy this code and make the debug code optional.
|
||||||
|
@ -1054,11 +1054,11 @@ function _wp_delete_post_menu_item( $object_id = 0 ) {
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
* @access private
|
* @access private
|
||||||
*
|
*
|
||||||
* @param int $object_id Optional. The ID of the original object being trashed. Default 0.
|
* @param int $object_id The ID of the original object being trashed.
|
||||||
* @param int $tt_id Term taxonomy ID. Unused.
|
* @param int $tt_id Term taxonomy ID. Unused.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
*/
|
*/
|
||||||
function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) {
|
function _wp_delete_tax_menu_item( $object_id, $tt_id, $taxonomy ) {
|
||||||
$object_id = (int) $object_id;
|
$object_id = (int) $object_id;
|
||||||
|
|
||||||
$menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy );
|
$menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy );
|
||||||
|
@ -1569,7 +1569,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
|||||||
$this->assertArrayNotHasKey( 'https://api.w.org/action-publish', $links );
|
$this->assertArrayNotHasKey( 'https://api.w.org/action-publish', $links );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function check_post_data( $attachment, $data, $context = 'view', $links ) {
|
protected function check_post_data( $attachment, $data, $context = 'view', $links = array() ) {
|
||||||
parent::check_post_data( $attachment, $data, $context, $links );
|
parent::check_post_data( $attachment, $data, $context, $links );
|
||||||
|
|
||||||
$this->assertArrayNotHasKey( 'content', $data );
|
$this->assertArrayNotHasKey( 'content', $data );
|
||||||
|
Loading…
Reference in New Issue
Block a user