Changeset 42343 for trunk/src/wp-admin/includes/comment.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/comment.php
r37914 r42343 33 33 } 34 34 35 return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments 35 return $wpdb->get_var( 36 $wpdb->prepare( 37 "SELECT comment_post_ID FROM $wpdb->comments 36 38 WHERE comment_author = %s AND $date_field = %s", 37 39 stripslashes( $comment_author ), 38 40 stripslashes( $comment_date ) 39 ) ); 41 ) 42 ); 40 43 } 41 44 … … 46 49 */ 47 50 function edit_comment() { 48 if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) 49 wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); 50 51 if ( isset( $_POST['newcomment_author'] ) ) 51 if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) { 52 wp_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) ); 53 } 54 55 if ( isset( $_POST['newcomment_author'] ) ) { 52 56 $_POST['comment_author'] = $_POST['newcomment_author']; 53 if ( isset( $_POST['newcomment_author_email'] ) ) 57 } 58 if ( isset( $_POST['newcomment_author_email'] ) ) { 54 59 $_POST['comment_author_email'] = $_POST['newcomment_author_email']; 55 if ( isset( $_POST['newcomment_author_url'] ) ) 60 } 61 if ( isset( $_POST['newcomment_author_url'] ) ) { 56 62 $_POST['comment_author_url'] = $_POST['newcomment_author_url']; 57 if ( isset( $_POST['comment_status'] ) ) 63 } 64 if ( isset( $_POST['comment_status'] ) ) { 58 65 $_POST['comment_approved'] = $_POST['comment_status']; 59 if ( isset( $_POST['content'] ) ) 66 } 67 if ( isset( $_POST['content'] ) ) { 60 68 $_POST['comment_content'] = $_POST['content']; 61 if ( isset( $_POST['comment_ID'] ) ) 69 } 70 if ( isset( $_POST['comment_ID'] ) ) { 62 71 $_POST['comment_ID'] = (int) $_POST['comment_ID']; 63 64 foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) { 65 if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { 72 } 73 74 foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) { 75 if ( ! empty( $_POST[ 'hidden_' . $timeunit ] ) && $_POST[ 'hidden_' . $timeunit ] != $_POST[ $timeunit ] ) { 66 76 $_POST['edit_date'] = '1'; 67 77 break; … … 69 79 } 70 80 71 if ( ! empty( $_POST['edit_date'] ) ) {72 $aa = $_POST['aa'];73 $mm = $_POST['mm'];74 $jj = $_POST['jj'];75 $hh = $_POST['hh'];76 $mn = $_POST['mn'];77 $ss = $_POST['ss'];78 $jj = ($jj > 31 ) ? 31 : $jj;79 $hh = ($hh > 23 ) ? $hh -24 : $hh;80 $mn = ($mn > 59 ) ? $mn -60 : $mn;81 $ss = ($ss > 59 ) ? $ss -60 : $ss;81 if ( ! empty( $_POST['edit_date'] ) ) { 82 $aa = $_POST['aa']; 83 $mm = $_POST['mm']; 84 $jj = $_POST['jj']; 85 $hh = $_POST['hh']; 86 $mn = $_POST['mn']; 87 $ss = $_POST['ss']; 88 $jj = ( $jj > 31 ) ? 31 : $jj; 89 $hh = ( $hh > 23 ) ? $hh - 24 : $hh; 90 $mn = ( $mn > 59 ) ? $mn - 60 : $mn; 91 $ss = ( $ss > 59 ) ? $ss - 60 : $ss; 82 92 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 83 93 } … … 95 105 */ 96 106 function get_comment_to_edit( $id ) { 97 if ( ! $comment = get_comment($id) )107 if ( ! $comment = get_comment( $id ) ) { 98 108 return false; 99 100 $comment->comment_ID = (int) $comment->comment_ID; 109 } 110 111 $comment->comment_ID = (int) $comment->comment_ID; 101 112 $comment->comment_post_ID = (int) $comment->comment_post_ID; 102 113 … … 111 122 $comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content ); 112 123 113 $comment->comment_author = format_to_edit( $comment->comment_author );124 $comment->comment_author = format_to_edit( $comment->comment_author ); 114 125 $comment->comment_author_email = format_to_edit( $comment->comment_author_email ); 115 $comment->comment_author_url = format_to_edit( $comment->comment_author_url );116 $comment->comment_author_url = esc_url($comment->comment_author_url);126 $comment->comment_author_url = format_to_edit( $comment->comment_author_url ); 127 $comment->comment_author_url = esc_url( $comment->comment_author_url ); 117 128 118 129 return $comment; … … 133 144 134 145 $single = false; 135 if ( ! is_array($post_id) ) {146 if ( ! is_array( $post_id ) ) { 136 147 $post_id_array = (array) $post_id; 137 $single = true;148 $single = true; 138 149 } else { 139 150 $post_id_array = $post_id; 140 151 } 141 $post_id_array = array_map( 'intval', $post_id_array);142 $post_id_in = "'" . implode("', '", $post_id_array) . "'";152 $post_id_array = array_map( 'intval', $post_id_array ); 153 $post_id_in = "'" . implode( "', '", $post_id_array ) . "'"; 143 154 144 155 $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A ); 145 156 146 157 if ( $single ) { 147 if ( empty( $pending) )158 if ( empty( $pending ) ) { 148 159 return 0; 149 else 150 return absint($pending[0]['num_comments']); 160 } else { 161 return absint( $pending[0]['num_comments'] ); 162 } 151 163 } 152 164 … … 154 166 155 167 // Default to zero pending for all posts in request 156 foreach ( $post_id_array as $id ) 157 $pending_keyed[$id] = 0; 158 159 if ( !empty($pending) ) 160 foreach ( $pending as $pend ) 161 $pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']); 168 foreach ( $post_id_array as $id ) { 169 $pending_keyed[ $id ] = 0; 170 } 171 172 if ( ! empty( $pending ) ) { 173 foreach ( $pending as $pend ) { 174 $pending_keyed[ $pend['comment_post_ID'] ] = absint( $pend['num_comments'] ); 175 } 176 } 162 177 163 178 return $pending_keyed; … … 181 196 */ 182 197 function enqueue_comment_hotkeys_js() { 183 if ( 'true' == get_user_option( 'comment_shortcuts' ) ) 198 if ( 'true' == get_user_option( 'comment_shortcuts' ) ) { 184 199 wp_enqueue_script( 'jquery-table-hotkeys' ); 200 } 185 201 } 186 202
Note: See TracChangeset
for help on using the changeset viewer.