diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
commit | 0e41b5d52fdc6af6442816b5f465c9db9f84e126 (patch) | |
tree | e139a90049b158d4eed892d1662ee7f5c358fa31 /wp-admin/includes/ajax-actions.php | |
parent | Adding upstream version 6.5.5+dfsg1. (diff) | |
download | wordpress-upstream/6.6.1+dfsg1.tar.xz wordpress-upstream/6.6.1+dfsg1.zip |
Adding upstream version 6.6.1+dfsg1.upstream/6.6.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-admin/includes/ajax-actions.php')
-rw-r--r-- | wp-admin/includes/ajax-actions.php | 66 |
1 files changed, 35 insertions, 31 deletions
diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 30aab70..62feaff 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -148,7 +148,7 @@ function wp_ajax_ajax_tag_search() { * Require $term_search_min_chars chars for matching (default: 2) * ensure it's a non-negative, non-zero integer. */ - if ( ( 0 == $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { + if ( ( 0 === $term_search_min_chars ) || ( strlen( $search ) < $term_search_min_chars ) ) { wp_die(); } @@ -192,7 +192,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'yes' ); + update_option( 'can_compress_scripts', 0, true ); } wp_die( 0 ); } @@ -205,10 +205,10 @@ function wp_ajax_wp_compression_test() { $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP ); $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."'; - if ( 1 == $_GET['test'] ) { + if ( '1' === $_GET['test'] ) { echo $test_str; wp_die(); - } elseif ( 2 == $_GET['test'] ) { + } elseif ( '2' === $_GET['test'] ) { if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) { wp_die( -1 ); } @@ -231,7 +231,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'yes' ); + update_option( 'can_compress_scripts', 0, true ); } } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); @@ -239,7 +239,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 1 ); } else { - update_option( 'can_compress_scripts', 1, 'yes' ); + update_option( 'can_compress_scripts', 1, true ); } } } @@ -274,7 +274,7 @@ function wp_ajax_imgedit_preview() { * * @since 3.1.0 * - * @global WP_Embed $wp_embed + * @global WP_Embed $wp_embed WordPress Embed object. */ function wp_ajax_oembed_cache() { $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); @@ -513,7 +513,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { } // Only do the expensive stuff on a page-break, and about 1 other time per page. - if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { + if ( 0 === $total % $per_page || 1 === mt_rand( 1, $per_page ) ) { $post_id = 0; // What type of comment count are we looking for? $status = 'all'; @@ -733,13 +733,13 @@ function wp_ajax_delete_comment() { $status = wp_get_comment_status( $comment ); $delta = -1; - if ( isset( $_POST['trash'] ) && 1 == $_POST['trash'] ) { + if ( isset( $_POST['trash'] ) && '1' === $_POST['trash'] ) { if ( 'trash' === $status ) { wp_die( time() ); } $r = wp_trash_comment( $comment ); - } elseif ( isset( $_POST['untrash'] ) && 1 == $_POST['untrash'] ) { + } elseif ( isset( $_POST['untrash'] ) && '1' === $_POST['untrash'] ) { if ( 'trash' !== $status ) { wp_die( time() ); } @@ -750,13 +750,13 @@ function wp_ajax_delete_comment() { if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) { $delta = 1; } - } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { + } elseif ( isset( $_POST['spam'] ) && '1' === $_POST['spam'] ) { if ( 'spam' === $status ) { wp_die( time() ); } $r = wp_spam_comment( $comment ); - } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) { + } elseif ( isset( $_POST['unspam'] ) && '1' === $_POST['unspam'] ) { if ( 'spam' !== $status ) { wp_die( time() ); } @@ -767,7 +767,7 @@ function wp_ajax_delete_comment() { if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) { $delta = 1; } - } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { + } elseif ( isset( $_POST['delete'] ) && '1' === $_POST['delete'] ) { $r = wp_delete_comment( $comment ); } else { wp_die( -1 ); @@ -1000,7 +1000,7 @@ function wp_ajax_dim_comment() { $current = wp_get_comment_status( $comment ); - if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) { + if ( isset( $_POST['new'] ) && $_POST['new'] === $current ) { wp_die( time() ); } @@ -1339,7 +1339,7 @@ function wp_ajax_replyto_comment( $action ) { $_POST['_wp_unfiltered_html_comment'] = ''; } - if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { + if ( wp_create_nonce( 'unfiltered-html-comment' ) !== $_POST['_wp_unfiltered_html_comment'] ) { kses_remove_filters(); // Start with a clean slate. kses_init_filters(); // Set up the filters. remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); @@ -1384,7 +1384,7 @@ function wp_ajax_replyto_comment( $action ) { if ( ! empty( $_POST['approve_parent'] ) ) { $parent = get_comment( $comment_parent ); - if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID == $comment_post_id ) { + if ( $parent && '0' === $parent->comment_approved && (int) $parent->comment_post_ID === $comment_post_id ) { if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) { wp_die( -1 ); } @@ -1482,8 +1482,12 @@ function wp_ajax_edit_comment() { wp_die( $updated->get_error_message() ); } - $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; - $checkbox = ( isset( $_POST['checkbox'] ) && true == $_POST['checkbox'] ) ? 1 : 0; + $position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1'; + /* + * Checkbox is used to differentiate between the Edit Comments screen (1) + * and the Comments section on the Edit Post screen (0). + */ + $checkbox = ( isset( $_POST['checkbox'] ) && '1' === $_POST['checkbox'] ) ? 1 : 0; $wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) ); $comment = get_comment( $comment_id ); @@ -1699,7 +1703,7 @@ function wp_ajax_add_meta() { wp_die( -1 ); } - if ( $meta->meta_value != $value || $meta->meta_key != $key ) { + if ( $meta->meta_value !== $value || $meta->meta_key !== $key ) { $u = update_metadata_by_mid( 'post', $mid, $value, $key ); if ( ! $u ) { wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). @@ -1797,7 +1801,7 @@ function wp_ajax_closed_postboxes() { $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -1828,7 +1832,7 @@ function wp_ajax_hidden_columns() { check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -1983,7 +1987,7 @@ function wp_ajax_meta_box_order() { $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( sanitize_key( $page ) != $page ) { + if ( sanitize_key( $page ) !== $page ) { wp_die( 0 ); } @@ -2412,7 +2416,7 @@ function wp_ajax_save_widget() { foreach ( (array) $wp_registered_widget_updates as $name => $control ) { - if ( $name == $id_base ) { + if ( $name === $id_base ) { if ( ! is_callable( $control['callback'] ) ) { continue; } @@ -2742,7 +2746,7 @@ function wp_ajax_set_post_thumbnail() { check_ajax_referer( "set_post_thumbnail-$post_id" ); } - if ( '-1' == $thumbnail_id ) { + if ( -1 === $thumbnail_id ) { if ( delete_post_thumbnail( $post_id ) ) { $return = _wp_post_thumbnail_html( null, $post_id ); $json ? wp_send_json_success( $return ) : wp_die( $return ); @@ -2926,7 +2930,7 @@ function wp_ajax_wp_remove_post_lock() { $active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) ); - if ( get_current_user_id() != $active_lock[1] ) { + if ( get_current_user_id() !== $active_lock[1] ) { wp_die( 0 ); } @@ -2951,7 +2955,7 @@ function wp_ajax_wp_remove_post_lock() { function wp_ajax_dismiss_wp_pointer() { $pointer = $_POST['pointer']; - if ( sanitize_key( $pointer ) != $pointer ) { + if ( sanitize_key( $pointer ) !== $pointer ) { wp_die( 0 ); } @@ -3323,7 +3327,7 @@ function wp_ajax_send_attachment_to_editor() { // If this attachment is unattached, attach it. Primarily a back compat thing. $insert_into_post_id = (int) $_POST['post_id']; - if ( 0 == $post->post_parent && $insert_into_post_id ) { + if ( 0 === $post->post_parent && $insert_into_post_id ) { wp_update_post( array( 'ID' => $id, @@ -3381,7 +3385,7 @@ function wp_ajax_send_attachment_to_editor() { * @since 3.5.0 * * @global WP_Post $post Global post object. - * @global WP_Embed $wp_embed + * @global WP_Embed $wp_embed WordPress Embed object. */ function wp_ajax_send_link_to_editor() { global $post, $wp_embed; @@ -3733,8 +3737,8 @@ function wp_ajax_query_themes() { * * @since 4.0.0 * - * @global WP_Post $post Global post object. - * @global WP_Embed $wp_embed Embed API instance. + * @global WP_Post $post Global post object. + * @global WP_Embed $wp_embed WordPress Embed object. * @global WP_Scripts $wp_scripts * @global int $content_width */ @@ -4024,7 +4028,7 @@ function wp_ajax_crop_image() { $wp_site_icon = new WP_Site_Icon(); // Skip creating a new attachment if the attachment is a Site Icon. - if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) == $context ) { + if ( get_post_meta( $attachment_id, '_wp_attachment_context', true ) === $context ) { // Delete the temporary cropped file, we don't need it. wp_delete_file( $cropped ); |