Changeset 45583 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 07/01/2019 12:50:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r45507 r45583 670 670 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 671 671 672 if ( ! $comment = get_comment( $id ) ) { 672 $comment = get_comment( $id ); 673 if ( ! $comment ) { 673 674 wp_die( time() ); 674 675 } … … 779 780 780 781 check_ajax_referer( "delete-meta_$id" ); 781 if ( ! $meta = get_metadata_by_mid( 'post', $id ) ) { 782 $meta = get_metadata_by_mid( 'post', $id ); 783 if ( ! $meta ) { 782 784 wp_die( 1 ); 783 785 } … … 907 909 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; 908 910 909 if ( ! $comment = get_comment( $id ) ) { 911 $comment = get_comment( $id ); 912 if ( ! $comment ) { 910 913 $x = new WP_Ajax_Response( 911 914 array( … … 1011 1014 $tag = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); 1012 1015 1013 if ( ! $tag || is_wp_error( $tag ) || ( ! $tag = get_term( $tag['term_id'], $taxonomy ) ) ) { 1016 if ( $tag && ! is_wp_error( $tag ) ) { 1017 $tag = get_term( $tag['term_id'], $taxonomy ); 1018 } 1019 1020 if ( ! $tag || is_wp_error( $tag ) ) { 1014 1021 $message = __( 'An error has occurred. Please reload the page and try again.' ); 1015 1022 if ( is_wp_error( $tag ) && $tag->get_error_message() ) { … … 1491 1498 } 1492 1499 1493 if ( ! $mid = add_meta( $pid ) ) { 1500 $mid = add_meta( $pid ); 1501 if ( ! $mid ) { 1494 1502 wp_die( __( 'Please provide a custom field value.' ) ); 1495 1503 } … … 1497 1505 wp_die( 0 ); 1498 1506 } 1499 } elseif ( ! $mid = add_meta( $pid ) ) { 1500 wp_die( __( 'Please provide a custom field value.' ) ); 1507 } else { 1508 $mid = add_meta( $pid ); 1509 if ( ! $mid ) { 1510 wp_die( __( 'Please provide a custom field value.' ) ); 1511 } 1501 1512 } 1502 1513 … … 1520 1531 wp_die( __( 'Please provide a custom field name.' ) ); 1521 1532 } 1522 if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) { 1533 $meta = get_metadata_by_mid( 'post', $mid ); 1534 if ( ! $meta ) { 1523 1535 wp_die( 0 ); // if meta doesn't exist 1524 1536 } … … 1529 1541 } 1530 1542 if ( $meta->meta_value != $value || $meta->meta_key != $key ) { 1531 if ( ! $u = update_metadata_by_mid( 'post', $mid, $value, $key ) ) { 1543 $u = update_metadata_by_mid( 'post', $mid, $value, $key ); 1544 if ( ! $u ) { 1532 1545 wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). 1533 1546 } … … 1571 1584 wp_die( -1 ); 1572 1585 } 1573 if ( ! $user_id = edit_user() ) { 1586 $user_id = edit_user(); 1587 if ( ! $user_id ) { 1574 1588 wp_die( 0 ); 1575 1589 } elseif ( is_wp_error( $user_id ) ) { … … 1625 1639 } 1626 1640 1627 if ( ! $user = wp_get_current_user() ) { 1641 $user = wp_get_current_user(); 1642 if ( ! $user ) { 1628 1643 wp_die( -1 ); 1629 1644 } … … 1654 1669 } 1655 1670 1656 if ( ! $user = wp_get_current_user() ) { 1671 $user = wp_get_current_user(); 1672 if ( ! $user ) { 1657 1673 wp_die( -1 ); 1658 1674 } … … 1808 1824 } 1809 1825 1810 if ( ! $user = wp_get_current_user() ) { 1826 $user = wp_get_current_user(); 1827 if ( ! $user ) { 1811 1828 wp_die( -1 ); 1812 1829 } … … 1876 1893 check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); 1877 1894 1878 if ( ! isset( $_POST['post_ID'] ) || ! ( $post_ID = (int) $_POST['post_ID'] )) {1895 if ( ! isset( $_POST['post_ID'] ) || ! (int) $_POST['post_ID'] ) { 1879 1896 wp_die(); 1880 1897 } 1898 1899 $post_ID = (int) $_POST['post_ID']; 1881 1900 1882 1901 if ( 'page' == $_POST['post_type'] ) { … … 1890 1909 } 1891 1910 1892 if ( $last = wp_check_post_lock( $post_ID ) ) { 1911 $last = wp_check_post_lock( $post_ID ); 1912 if ( $last ) { 1893 1913 $last_user = get_userdata( $last ); 1894 1914 $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); … … 1992 2012 } 1993 2013 1994 if ( ! isset( $_POST['tax_ID'] ) || ! ( $id = (int) $_POST['tax_ID'] )) {2014 if ( ! isset( $_POST['tax_ID'] ) || ! (int) $_POST['tax_ID'] ) { 1995 2015 wp_die( -1 ); 1996 2016 } 2017 2018 $id = (int) $_POST['tax_ID']; 1997 2019 1998 2020 if ( ! current_user_can( 'edit_term', $id ) ) { … … 2237 2259 } 2238 2260 2239 if ( $form = $wp_registered_widget_controls[ $widget_id ] ) { 2261 $form = $wp_registered_widget_controls[ $widget_id ]; 2262 if ( $form ) { 2240 2263 call_user_func_array( $form['callback'], $form['params'] ); 2241 2264 } … … 2389 2412 } 2390 2413 2391 if ( ! $attachment = wp_prepare_attachment_for_js( $attachment_id ) ) { 2414 $attachment = wp_prepare_attachment_for_js( $attachment_id ); 2415 if ( ! $attachment ) { 2392 2416 wp_die(); 2393 2417 } … … 2599 2623 } 2600 2624 2601 if ( $last_id = get_post_meta( $post_id, '_edit_last', true ) ) { 2625 $last_id = get_post_meta( $post_id, '_edit_last', true ); 2626 if ( $last_id ) { 2602 2627 $last_user = get_userdata( $last_id ); 2603 2628 /* translators: 1: display_name of last user, 2: date of last edit, 3: time of last edit. */ … … 2621 2646 } 2622 2647 $post_id = (int) $_POST['post_ID']; 2623 if ( ! $post = get_post( $post_id ) ) { 2648 $post = get_post( $post_id ); 2649 if ( ! $post ) { 2624 2650 wp_die( 0 ); 2625 2651 } … … 2685 2711 } 2686 2712 2687 if ( ! $id = absint( $_REQUEST['id'] ) ) { 2713 $id = absint( $_REQUEST['id'] ); 2714 if ( ! $id ) { 2688 2715 wp_send_json_error(); 2689 2716 } 2690 2717 2691 if ( ! $post = get_post( $id ) ) { 2718 $post = get_post( $id ); 2719 if ( ! $post ) { 2692 2720 wp_send_json_error(); 2693 2721 } … … 2701 2729 } 2702 2730 2703 if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) { 2731 $attachment = wp_prepare_attachment_for_js( $id ); 2732 if ( ! $attachment ) { 2704 2733 wp_send_json_error(); 2705 2734 } … … 2787 2816 } 2788 2817 2789 if ( ! $id = absint( $_REQUEST['id'] ) ) { 2818 $id = absint( $_REQUEST['id'] ); 2819 if ( ! $id ) { 2790 2820 wp_send_json_error(); 2791 2821 } … … 2870 2900 } 2871 2901 2872 if ( ! $id = absint( $_REQUEST['id'] ) ) { 2902 $id = absint( $_REQUEST['id'] ); 2903 if ( ! $id ) { 2873 2904 wp_send_json_error(); 2874 2905 } … … 2907 2938 } 2908 2939 2909 if ( ! $attachment = wp_prepare_attachment_for_js( $id ) ) { 2940 $attachment = wp_prepare_attachment_for_js( $id ); 2941 if ( ! $attachment ) { 2910 2942 wp_send_json_error(); 2911 2943 } … … 2924 2956 } 2925 2957 2926 if ( ! $post_id = absint( $_REQUEST['post_id'] ) ) { 2958 $post_id = absint( $_REQUEST['post_id'] ); 2959 if ( ! $post_id ) { 2927 2960 wp_send_json_error(); 2928 2961 } … … 2944 2977 continue; 2945 2978 } 2946 if ( ! $attachment = get_post( $attachment_id ) ) { 2979 $attachment = get_post( $attachment_id ); 2980 if ( ! $attachment ) { 2947 2981 continue; 2948 2982 } … … 2978 3012 $id = intval( $attachment['id'] ); 2979 3013 2980 if ( ! $post = get_post( $id ) ) { 3014 $post = get_post( $id ); 3015 if ( ! $post ) { 2981 3016 wp_send_json_error(); 2982 3017 } … … 2988 3023 if ( current_user_can( 'edit_post', $id ) ) { 2989 3024 // If this attachment is unattached, attach it. Primarily a back compat thing. 2990 if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) { 3025 $insert_into_post_id = intval( $_POST['post_id'] ); 3026 if ( 0 == $post->post_parent && $insert_into_post_id ) { 2991 3027 wp_update_post( 2992 3028 array( … … 3053 3089 check_ajax_referer( 'media-send-to-editor', 'nonce' ); 3054 3090 3055 if ( ! $src = wp_unslash( $_POST['src'] ) ) { 3091 $src = wp_unslash( $_POST['src'] ); 3092 if ( ! $src ) { 3056 3093 wp_send_json_error(); 3057 3094 } … … 3061 3098 } 3062 3099 3063 if ( ! $src = esc_url_raw( $src ) ) { 3100 $src = esc_url_raw( $src ); 3101 if ( ! $src ) { 3064 3102 wp_send_json_error(); 3065 3103 } 3066 3104 3067 if ( ! $link_text = trim( wp_unslash( $_POST['link_text'] ) ) ) { 3105 $link_text = trim( wp_unslash( $_POST['link_text'] ) ); 3106 if ( ! $link_text ) { 3068 3107 $link_text = wp_basename( $src ); 3069 3108 } … … 3088 3127 // Figure out what filter to run: 3089 3128 $type = 'file'; 3090 if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) 3091 && ( 'audio' == $ext_type || 'video' == $ext_type ) ) { 3129 $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ); 3130 if ( $ext ) { 3131 $ext_type = wp_ext2type( $ext ); 3132 if ( 'audio' == $ext_type || 'video' == $ext_type ) { 3092 3133 $type = $ext_type; 3134 } 3093 3135 } 3094 3136 … … 3111 3153 } 3112 3154 3113 $response = $data = array(); 3155 $response = array(); 3156 $data = array(); 3114 3157 $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); 3115 3158 … … 3193 3236 require ABSPATH . 'wp-admin/includes/revision.php'; 3194 3237 3195 if ( ! $post = get_post( (int) $_REQUEST['post_id'] ) ) { 3238 $post = get_post( (int) $_REQUEST['post_id'] ); 3239 if ( ! $post ) { 3196 3240 wp_send_json_error(); 3197 3241 } … … 3202 3246 3203 3247 // Really just pre-loading the cache here. 3204 if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) ) { 3248 $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ); 3249 if ( ! $revisions ) { 3205 3250 wp_send_json_error(); 3206 3251 }
Note: See TracChangeset
for help on using the changeset viewer.