rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -135,8 +135,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
$published_statuses = array( 'publish', 'future' );
// Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
/*
* Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
* Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
*/
if ( isset( $post_data['post_status'] )
&& ( in_array( $post_data['post_status'], $published_statuses, true )
&& ! current_user_can( $ptype->cap->publish_posts ) )
@@ -169,6 +171,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
}
}
if ( isset( $post_data['edit_date'] ) && 'false' === $post_data['edit_date'] ) {
$post_data['edit_date'] = false;
}
if ( ! empty( $post_data['edit_date'] ) ) {
$aa = $post_data['aa'];
$mm = $post_data['mm'];
@@ -664,6 +670,15 @@ function bulk_edit_posts( $post_data = null ) {
// Prevent wp_insert_post() from overwriting post format with the old data.
unset( $post_data['tax_input']['post_format'] );
// Reset post date of scheduled post to be published.
if (
in_array( $post->post_status, array( 'future', 'draft' ), true ) &&
'publish' === $post_data['post_status']
) {
$post_data['post_date'] = current_time( 'mysql' );
$post_data['post_date_gmt'] = '';
}
$post_id = wp_update_post( $post_data );
update_post_meta( $post_id, '_edit_last', get_current_user_id() );
$updated[] = $post_id;
@@ -677,6 +692,16 @@ function bulk_edit_posts( $post_data = null ) {
}
}
/**
* Fires after processing the post data for bulk edit.
*
* @since 6.3.0
*
* @param int[] $updated An array of updated post IDs.
* @param array $shared_post_data Associative array containing the post data.
*/
do_action( 'bulk_edit_posts', $updated, $shared_post_data );
return array(
'updated' => $updated,
'skipped' => $skipped,
@@ -1010,11 +1035,10 @@ function get_meta_keys() {
global $wpdb;
$keys = $wpdb->get_col(
"
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
ORDER BY meta_key"
"SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
ORDER BY meta_key"
);
return $keys;
@@ -1126,7 +1150,7 @@ function _fix_attachment_links( $post ) {
$url_id = (int) $url_match[2];
$rel_id = (int) $rel_match[1];
if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos( $url_match[0], $site_url ) === false ) {
if ( ! $url_id || ! $rel_id || $url_id != $rel_id || ! str_contains( $url_match[0], $site_url ) ) {
continue;
}
@@ -1421,8 +1445,10 @@ function get_sample_permalink( $post, $title = null, $name = null ) {
$post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
}
// If the user wants to set a new name -- override the current one.
// Note: if empty name is supplied -- use the title instead, see #6072.
/*
* If the user wants to set a new name -- override the current one.
* Note: if empty name is supplied -- use the title instead, see #6072.
*/
if ( ! is_null( $name ) ) {
$post->post_name = sanitize_title( $name ? $name : $title, $post->ID );
}
@@ -1516,7 +1542,7 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null )
}
// Permalinks without a post/page name placeholder don't have anything to edit.
if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
if ( ! str_contains( $permalink, '%postname%' ) && ! str_contains( $permalink, '%pagename%' ) ) {
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
if ( false !== $view_link ) {
@@ -1555,11 +1581,11 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null )
* @since 2.9.0
* @since 4.4.0 Added `$post` parameter.
*
* @param string $return Sample permalink HTML markup.
* @param int $post_id Post ID.
* @param string $new_title New sample permalink title.
* @param string $new_slug New sample permalink slug.
* @param WP_Post $post Post object.
* @param string $return Sample permalink HTML markup.
* @param int $post_id Post ID.
* @param string|null $new_title New sample permalink title.
* @param string|null $new_slug New sample permalink slug.
* @param WP_Post $post Post object.
*/
$return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post );
@@ -1756,7 +1782,7 @@ function _admin_notice_post_locked() {
}
$sendback = wp_get_referer();
if ( $locked && $sendback && false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) {
$sendback_text = __( 'Go back' );
} else {
@@ -2051,8 +2077,10 @@ function wp_autosave( $post_data ) {
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked.
return edit_post( wp_slash( $post_data ) );
} else {
// Non-drafts or other users' drafts are not overwritten.
// The autosave is stored in a special post revision for each user.
/*
* Non-drafts or other users' drafts are not overwritten.
* The autosave is stored in a special post revision for each user.
*/
return wp_create_post_autosave( wp_slash( $post_data ) );
}
}
@@ -2178,6 +2206,7 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
* of a block relevant for client registration.
*
* @since 5.0.0
* @since 6.3.0 Added `selectors` field.
*
* @return array An associative array of registered block data.
*/
@@ -2192,6 +2221,7 @@ function get_block_editor_server_block_settings() {
'attributes' => 'attributes',
'provides_context' => 'providesContext',
'uses_context' => 'usesContext',
'selectors' => 'selectors',
'supports' => 'supports',
'category' => 'category',
'styles' => 'styles',
@@ -2436,7 +2466,7 @@ function the_block_editor_meta_box_post_form_hidden_fields( $post ) {
$classic_elements = wp_html_split( $classic_output );
$hidden_inputs = '';
foreach ( $classic_elements as $element ) {
if ( 0 !== strpos( $element, '<input ' ) ) {
if ( ! str_starts_with( $element, '<input ' ) ) {
continue;
}