Changeset 53719
- Timestamp:
- 07/19/2022 02:00:35 PM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r53715 r53719 1147 1147 function get_trackback_url() { 1148 1148 if ( get_option( 'permalink_structure' ) ) { 1149 $t b_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' );1149 $trackback_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' ); 1150 1150 } else { 1151 $t b_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID();1151 $trackback_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID(); 1152 1152 } 1153 1153 … … 1157 1157 * @since 2.2.0 1158 1158 * 1159 * @param string $t b_url The trackback URL.1160 */ 1161 return apply_filters( 'trackback_url', $t b_url );1159 * @param string $trackback_url The trackback URL. 1160 */ 1161 return apply_filters( 'trackback_url', $trackback_url ); 1162 1162 } 1163 1163 -
trunk/src/wp-trackback.php
r53131 r53719 27 27 function trackback_response( $error = 0, $error_message = '' ) { 28 28 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) ); 29 29 30 if ( $error ) { 30 31 echo '<?xml version="1.0" encoding="utf-8"?' . ">\n"; … … 46 47 47 48 if ( ! isset( $_GET['tb_id'] ) || ! $_GET['tb_id'] ) { 48 $ tb_id = explode( '/', $_SERVER['REQUEST_URI'] );49 $ tb_id = (int) $tb_id[ count( $tb_id ) - 1 ];49 $post_id = explode( '/', $_SERVER['REQUEST_URI'] ); 50 $post_id = (int) $post_id[ count( $post_id ) - 1 ]; 50 51 } 51 52 52 $t b_url= isset( $_POST['url'] ) ? $_POST['url'] : '';53 $charset = isset( $_POST['charset'] ) ? $_POST['charset'] : '';53 $trackback_url = isset( $_POST['url'] ) ? $_POST['url'] : ''; 54 $charset = isset( $_POST['charset'] ) ? $_POST['charset'] : ''; 54 55 55 56 // These three are stripslashed here so they can be properly escaped after mb_convert_encoding(). … … 82 83 83 84 if ( is_single() || is_page() ) { 84 $ tb_id = $posts[0]->ID;85 $post_id = $posts[0]->ID; 85 86 } 86 87 87 if ( ! isset( $ tb_id ) || ! (int) $tb_id ) {88 if ( ! isset( $post_id ) || ! (int) $post_id ) { 88 89 trackback_response( 1, __( 'I really need an ID for this to work.' ) ); 89 90 } 90 91 91 if ( empty( $title ) && empty( $t b_url ) && empty( $blog_name ) ) {92 if ( empty( $title ) && empty( $trackback_url ) && empty( $blog_name ) ) { 92 93 // If it doesn't look like a trackback at all. 93 wp_redirect( get_permalink( $ tb_id ) );94 wp_redirect( get_permalink( $post_id ) ); 94 95 exit; 95 96 } 96 97 97 if ( ! empty( $t b_url ) && ! empty( $title ) ) {98 if ( ! empty( $trackback_url ) && ! empty( $title ) ) { 98 99 /** 99 100 * Fires before the trackback is added to a post. … … 101 102 * @since 4.7.0 102 103 * 103 * @param int $ tb_idPost ID related to the trackback.104 * @param string $t b_urlTrackback URL.105 * @param string $charset Character Set.106 * @param string $title Trackback Title.107 * @param string $excerpt Trackback Excerpt.108 * @param string $blog_name Blog Name.104 * @param int $post_id Post ID related to the trackback. 105 * @param string $trackback_url Trackback URL. 106 * @param string $charset Character set. 107 * @param string $title Trackback title. 108 * @param string $excerpt Trackback excerpt. 109 * @param string $blog_name Blog name. 109 110 */ 110 do_action( 'pre_trackback_post', $ tb_id, $tb_url, $charset, $title, $excerpt, $blog_name );111 do_action( 'pre_trackback_post', $post_id, $trackback_url, $charset, $title, $excerpt, $blog_name ); 111 112 112 113 header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) ); 113 114 114 if ( ! pings_open( $ tb_id ) ) {115 if ( ! pings_open( $post_id ) ) { 115 116 trackback_response( 1, __( 'Sorry, trackbacks are closed for this item.' ) ); 116 117 } … … 119 120 $excerpt = wp_html_excerpt( $excerpt, 252, '…' ); 120 121 121 $comment_post_ ID = (int) $tb_id;122 $comment_post_id = (int) $post_id; 122 123 $comment_author = $blog_name; 123 124 $comment_author_email = ''; 124 $comment_author_url = $t b_url;125 $comment_author_url = $trackback_url; 125 126 $comment_content = "<strong>$title</strong>\n\n$excerpt"; 126 127 $comment_type = 'trackback'; 127 128 128 $dupe = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $comment_post_ID, $comment_author_url ) ); 129 $dupe = $wpdb->get_results( 130 $wpdb->prepare( 131 "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", 132 $comment_post_id, 133 $comment_author_url 134 ) 135 ); 136 129 137 if ( $dupe ) { 130 138 trackback_response( 1, __( 'There is already a ping from that URL for this post.' ) ); 131 139 } 132 140 133 $commentdata = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type' ); 141 $commentdata = array( 142 'comment_post_ID' => $comment_post_id, 143 ); 144 145 $commentdata += compact( 146 'comment_author', 147 'comment_author_email', 148 'comment_author_url', 149 'comment_content', 150 'comment_type' 151 ); 134 152 135 153 $result = wp_new_comment( $commentdata ); … … 149 167 */ 150 168 do_action( 'trackback_post', $trackback_id ); 169 151 170 trackback_response( 0 ); 152 171 }
Note: See TracChangeset
for help on using the changeset viewer.