summaryrefslogtreecommitdiffstats
path: root/wp-admin/includes/post.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:22 +0000
commitfc0a79914946dac00ccd51b1aacffe267de7210e (patch)
tree1403384efbfe8f8776ff60aaa40f7d535c02c822 /wp-admin/includes/post.php
parentReleasing progress-linux version 6.5.5+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-fc0a79914946dac00ccd51b1aacffe267de7210e.tar.xz
wordpress-fc0a79914946dac00ccd51b1aacffe267de7210e.zip
Merging upstream version 6.6.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-admin/includes/post.php')
-rw-r--r--wp-admin/includes/post.php82
1 files changed, 42 insertions, 40 deletions
diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php
index a313324..2102064 100644
--- a/wp-admin/includes/post.php
+++ b/wp-admin/includes/post.php
@@ -72,7 +72,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
}
}
- if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] != $post_data['user_ID'] )
+ if ( isset( $post_data['user_ID'] ) && ( $post_data['post_author'] !== $post_data['user_ID'] )
&& ! current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( $update ) {
@@ -165,7 +165,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
}
foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) {
- if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) {
+ if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] !== $post_data[ $timeunit ] ) {
$post_data['edit_date'] = '1';
break;
}
@@ -375,7 +375,7 @@ function edit_post( $post_data = null ) {
continue;
}
- if ( $meta->post_id != $post_id ) {
+ if ( (int) $meta->post_id !== $post_id ) {
continue;
}
@@ -402,7 +402,7 @@ function edit_post( $post_data = null ) {
continue;
}
- if ( $meta->post_id != $post_id ) {
+ if ( (int) $meta->post_id !== $post_id ) {
continue;
}
@@ -516,7 +516,7 @@ function bulk_edit_posts( $post_data = null ) {
}
}
- if ( -1 == $post_data['_status'] ) {
+ if ( '-1' === $post_data['_status'] ) {
$post_data['post_status'] = null;
unset( $post_data['post_status'] );
} else {
@@ -550,7 +550,7 @@ function bulk_edit_posts( $post_data = null ) {
);
foreach ( $reset as $field ) {
- if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || -1 == $post_data[ $field ] ) ) {
+ if ( isset( $post_data[ $field ] ) && ( '' === $post_data[ $field ] || '-1' === $post_data[ $field ] ) ) {
unset( $post_data[ $field ] );
}
}
@@ -1084,7 +1084,7 @@ function get_post_meta_by_id( $mid ) {
*
* @global wpdb $wpdb WordPress database abstraction object.
*
- * @param int $postid A post ID.
+ * @param int $post_id A post ID.
* @return array[] {
* Array of meta data arrays for the given post ID.
*
@@ -1098,7 +1098,7 @@ function get_post_meta_by_id( $mid ) {
* }
* }
*/
-function has_meta( $postid ) {
+function has_meta( $post_id ) {
global $wpdb;
return $wpdb->get_results(
@@ -1106,7 +1106,7 @@ function has_meta( $postid ) {
"SELECT meta_key, meta_value, meta_id, post_id
FROM $wpdb->postmeta WHERE post_id = %d
ORDER BY meta_key,meta_id",
- $postid
+ $post_id
),
ARRAY_A
);
@@ -1139,7 +1139,7 @@ function update_meta( $meta_id, $meta_key, $meta_value ) {
* @since 2.3.0
* @access private
*
- * @param int|object $post Post ID or post object.
+ * @param int|WP_Post $post Post ID or post object.
* @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success.
*/
function _fix_attachment_links( $post ) {
@@ -1199,9 +1199,9 @@ function _fix_attachment_links( $post ) {
* @return string[] An array of all the statuses for the supplied post type.
*/
function get_available_post_statuses( $type = 'post' ) {
- $stati = wp_count_posts( $type );
+ $statuses = wp_count_posts( $type );
- return array_keys( get_object_vars( $stati ) );
+ return array_keys( get_object_vars( $statuses ) );
}
/**
@@ -1217,9 +1217,11 @@ function wp_edit_posts_query( $q = false ) {
if ( false === $q ) {
$q = $_GET;
}
- $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
- $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
- $post_stati = get_post_stati();
+
+ $q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
+ $q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
+
+ $post_statuses = get_post_stati();
if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types(), true ) ) {
$post_type = $q['post_type'];
@@ -1231,7 +1233,7 @@ function wp_edit_posts_query( $q = false ) {
$post_status = '';
$perm = '';
- if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati, true ) ) {
+ if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_statuses, true ) ) {
$post_status = $q['post_status'];
$perm = 'readable';
}
@@ -1402,7 +1404,7 @@ function wp_edit_attachments_query( $q = false ) {
* @return string Space-separated string of class names.
*/
function postbox_classes( $box_id, $screen_id ) {
- if ( isset( $_GET['edit'] ) && $_GET['edit'] == $box_id ) {
+ if ( isset( $_GET['edit'] ) && $_GET['edit'] === $box_id ) {
$classes = array( '' );
} elseif ( get_user_option( 'closedpostboxes_' . $screen_id ) ) {
$closed = get_user_option( 'closedpostboxes_' . $screen_id );
@@ -1461,7 +1463,7 @@ function get_sample_permalink( $post, $title = null, $name = null ) {
$original_filter = $post->filter;
// Hack: get_permalink() would return plain permalink for drafts, so we will fake that our post is published.
- if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ), true ) ) {
+ if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ), true ) ) {
$post->post_status = 'publish';
$post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
}
@@ -1575,7 +1577,7 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null )
// Encourage a pretty permalink setting.
if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' )
- && ! ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID )
+ && ! ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID )
) {
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __( 'Change Permalink Structure' ) . "</a></span>\n";
}
@@ -1711,7 +1713,7 @@ function wp_check_post_lock( $post ) {
$lock = explode( ':', $lock );
$time = $lock[0];
- $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
+ $user = isset( $lock[1] ) ? (int) $lock[1] : (int) get_post_meta( $post->ID, '_edit_last', true );
if ( ! get_userdata( $user ) ) {
return false;
@@ -1720,7 +1722,7 @@ function wp_check_post_lock( $post ) {
/** This filter is documented in wp-admin/includes/ajax-actions.php */
$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
- if ( $time && $time > time() - $time_window && get_current_user_id() != $user ) {
+ if ( $time && $time > time() - $time_window && get_current_user_id() !== $user ) {
return $user;
}
@@ -1750,7 +1752,7 @@ function wp_set_post_lock( $post ) {
$user_id = get_current_user_id();
- if ( 0 == $user_id ) {
+ if ( 0 === $user_id ) {
return false;
}
@@ -1827,7 +1829,7 @@ function _admin_notice_post_locked() {
if ( $locked ) {
$query_args = array();
if ( get_post_type_object( $post->post_type )->public ) {
- if ( 'publish' === $post->post_status || $user->ID != $post->post_author ) {
+ if ( 'publish' === $post->post_status || $user->ID !== (int) $post->post_author ) {
// Latest content is in autosave.
$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
$query_args['preview_id'] = $post->ID;
@@ -2079,7 +2081,7 @@ function post_preview() {
$is_autosave = false;
- if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author
+ if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
&& ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status )
) {
$saved_post_id = edit_post();
@@ -2154,7 +2156,7 @@ function wp_autosave( $post_data ) {
$post_data['post_category'] = explode( ',', $post_data['catslist'] );
}
- if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author
+ if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() === (int) $post->post_author
&& ( 'auto-draft' === $post->post_status || 'draft' === $post->post_status )
) {
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked.
@@ -2179,19 +2181,19 @@ function redirect_post( $post_id = '' ) {
if ( isset( $_POST['save'] ) || isset( $_POST['publish'] ) ) {
$status = get_post_status( $post_id );
- if ( isset( $_POST['publish'] ) ) {
- switch ( $status ) {
- case 'pending':
- $message = 8;
- break;
- case 'future':
- $message = 9;
- break;
- default:
- $message = 6;
- }
- } else {
- $message = 'draft' === $status ? 10 : 1;
+ switch ( $status ) {
+ case 'pending':
+ $message = 8;
+ break;
+ case 'future':
+ $message = 9;
+ break;
+ case 'draft':
+ $message = 10;
+ break;
+ default:
+ $message = isset( $_POST['publish'] ) ? 6 : 1;
+ break;
}
$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
@@ -2343,7 +2345,7 @@ function get_block_editor_server_block_settings() {
*
* @global WP_Post $post Global post object.
* @global WP_Screen $current_screen WordPress current screen object.
- * @global array $wp_meta_boxes
+ * @global array $wp_meta_boxes Global meta box state.
*/
function the_block_editor_meta_boxes() {
global $post, $current_screen, $wp_meta_boxes;
@@ -2406,7 +2408,7 @@ function the_block_editor_meta_boxes() {
$meta_boxes = (array) $wp_meta_boxes[ $current_screen->id ][ $location ][ $priority ];
foreach ( $meta_boxes as $meta_box ) {
- if ( false == $meta_box || ! $meta_box['title'] ) {
+ if ( false === $meta_box || ! $meta_box['title'] ) {
continue;
}