Changeset 47122 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/ajax-actions.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r47088 r47122 23 23 $response = array(); 24 24 25 // screen_idis the same as $current_screen->id and the JS global 'pagenow'.25 // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'. 26 26 if ( ! empty( $_POST['screen_id'] ) ) { 27 27 $screen_id = sanitize_key( $_POST['screen_id'] ); … … 273 273 $return = array(); 274 274 275 // Check the type of request 276 // Current allowed values are `add` and `search` 275 // Check the type of request. 276 // Current allowed values are `add` and `search`. 277 277 if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { 278 278 $type = $_REQUEST['autocomplete_type']; … … 281 281 } 282 282 283 // Check the desired field for value 284 // Current allowed values are `user_email` and `user_login` 283 // Check the desired field for value. 284 // Current allowed values are `user_email` and `user_login`. 285 285 if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { 286 286 $field = $_REQUEST['autocomplete_field']; … … 289 289 } 290 290 291 // Exclude current users of this blog 291 // Exclude current users of this blog. 292 292 if ( isset( $_REQUEST['site_id'] ) ) { 293 293 $id = absint( $_REQUEST['site_id'] ); … … 434 434 $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : ''; 435 435 436 // JS didn't send us everything we need to know. Just die with success message 436 // JS didn't send us everything we need to know. Just die with success message. 437 437 if ( ! $total || ! $per_page || ! $page || ! $url ) { 438 438 $time = time(); … … 483 483 } 484 484 485 // Only do the expensive stuff on a page-break, and about 1 other time per page 485 // Only do the expensive stuff on a page-break, and about 1 other time per page. 486 486 if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { 487 487 $post_id = 0; … … 601 601 $checked_categories[] = $cat_id; 602 602 603 if ( $parent ) { // Do these all at once in a second 603 if ( $parent ) { // Do these all at once in a second. 604 604 continue; 605 605 } … … 627 627 } 628 628 629 if ( $parent ) { // Foncy - replace the parent and all its children 629 if ( $parent ) { // Foncy - replace the parent and all its children. 630 630 $parent = get_term( $parent, $taxonomy->name ); 631 631 $term_id = $parent->term_id; 632 632 633 while ( $parent->parent ) { // get the top parent633 while ( $parent->parent ) { // Get the top parent. 634 634 $parent = get_term( $parent->parent, $taxonomy->name ); 635 635 if ( is_wp_error( $parent ) ) { … … 717 717 $r = wp_untrash_comment( $comment ); 718 718 719 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { // undo trash, not in trash 719 // Undo trash, not in trash. 720 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { 720 721 $delta = 1; 721 722 } … … 733 734 $r = wp_unspam_comment( $comment ); 734 735 735 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { // undo spam, not in spam 736 // Undo spam, not in spam. 737 if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { 736 738 $delta = 1; 737 739 } … … 742 744 } 743 745 744 if ( $r ) { // Decide if we need to send back '1' or a more complicated response including page links and comment counts 746 if ( $r ) { 747 // Decide if we need to send back '1' or a more complicated response including page links and comment counts. 745 748 _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); 746 749 } … … 990 993 } 991 994 992 // Decide if we need to send back '1' or a more complicated response including page links and comment counts 995 // Decide if we need to send back '1' or a more complicated response including page links and comment counts. 993 996 _wp_ajax_delete_comment_response( $comment->comment_ID ); 994 997 wp_die( 0 ); … … 1162 1165 } 1163 1166 1164 // We need raw tag names here, so don't filter the output 1167 // We need raw tag names here, so don't filter the output. 1165 1168 $return = wp_generate_tag_cloud( 1166 1169 $tags, … … 1289 1292 1290 1293 if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { 1291 kses_remove_filters(); // start with a clean slate1292 kses_init_filters(); // set up the filters1294 kses_remove_filters(); // Start with a clean slate. 1295 kses_init_filters(); // Set up the filters. 1293 1296 remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); 1294 1297 add_filter( 'pre_comment_content', 'wp_filter_kses' ); … … 1479 1482 $_menu_item = reset( $_menu_items ); 1480 1483 1481 // Restore the missing menu item properties 1484 // Restore the missing menu item properties. 1482 1485 $menu_item_data['menu-item-description'] = $_menu_item->description; 1483 1486 } … … 1499 1502 $menu_obj = wp_setup_nav_menu_item( $menu_obj ); 1500 1503 $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title; 1501 $menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items1504 $menu_obj->label = $menu_obj->title; // Don't show "(pending)" in ajax-added items. 1502 1505 $menu_items[] = $menu_obj; 1503 1506 } … … 1549 1552 if ( $post->post_status == 'auto-draft' ) { 1550 1553 $post_data = array(); 1551 $post_data['action'] = 'draft'; // Warning fix 1554 $post_data['action'] = 'draft'; // Warning fix. 1552 1555 $post_data['post_ID'] = $pid; 1553 1556 $post_data['post_type'] = $post->post_type; … … 1609 1612 1610 1613 if ( ! $meta ) { 1611 wp_die( 0 ); // if meta doesn't exist1614 wp_die( 0 ); // If meta doesn't exist. 1612 1615 } 1613 1616 … … 1732 1735 1733 1736 if ( is_array( $hidden ) ) { 1734 $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); // postboxes that are always shown 1737 // Postboxes that are always shown. 1738 $hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); 1735 1739 update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true ); 1736 1740 } … … 2621 2625 */ 2622 2626 function wp_ajax_set_post_thumbnail() { 2623 $json = ! empty( $_REQUEST['json'] ); // New-style request 2627 $json = ! empty( $_REQUEST['json'] ); // New-style request. 2624 2628 2625 2629 $post_ID = intval( $_POST['post_id'] ); … … 3227 3231 } else { 3228 3232 $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; 3229 $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized 3233 $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized. 3230 3234 3231 3235 if ( ! empty( $url ) ) { … … 3288 3292 3289 3293 if ( $check_embed !== $fallback ) { 3290 // TinyMCE view for [embed] will parse this 3294 // TinyMCE view for [embed] will parse this. 3291 3295 $html = '[embed]' . $src . '[/embed]'; 3292 3296 } elseif ( $link_text ) { … … 3328 3332 $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); 3329 3333 3330 // screen_idis the same as $current_screen->id and the JS global 'pagenow'.3334 // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'. 3331 3335 if ( ! empty( $_POST['screen_id'] ) ) { 3332 3336 $screen_id = sanitize_key( $_POST['screen_id'] ); … … 3393 3397 do_action( 'heartbeat_tick', $response, $screen_id ); 3394 3398 3395 // Send the current time according to the server 3399 // Send the current time according to the server. 3396 3400 $response['server_time'] = time(); 3397 3401 … … 3736 3740 } 3737 3741 3738 // the embed shortcode requires a post3742 // The embed shortcode requires a post. 3739 3743 if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { 3740 3744 if ( 'embed' === $shortcode ) {
Note: See TracChangeset
for help on using the changeset viewer.