Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 81 lines (66 sloc) 2.449 kb
43e4a8a The great renaming.
saxmatt authored
1 <?php
b650b07 Move trackbacks to new comment function.
saxmatt authored
2 $doing_trackback = 1;
3 require('./wp-config.php');
4 include_once (ABSPATH . WPINC . '/functions-post.php');
5
6 function trackback_response($error = 0, $error_message = '') {
7 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
8 if ($error) {
9 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
10 echo "<response>\n";
11 echo "<error>1</error>\n";
12 echo "<message>$error_message</message>\n";
13 echo "</response>";
14 } else {
15 echo '<?xml version="1.0" encoding="utf-8"?'.">\n";
16 echo "<response>\n";
17 echo "<error>0</error>\n";
18 echo "</response>";
19 }
20 die();
21 }
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
22
23 // trackback is done by a POST
24 $request_array = 'HTTP_POST_VARS';
b650b07 Move trackbacks to new comment function.
saxmatt authored
25 if (!$tb_id) {
26 $tb_id = explode('/', $_SERVER['REQUEST_URI']);
27 $tb_id = intval($tb_id[count($tb_id)-1]);
28 }
10c6b7e Changed to superglobals, and eliminated $use_cache (since we always do).
saxmatt authored
29 $tb_url = $_POST['url'];
30 $title = $_POST['title'];
31 $excerpt = $_POST['excerpt'];
32 $blog_name = $_POST['blog_name'];
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
33
b650b07 Move trackbacks to new comment function.
saxmatt authored
34 if ( !$doing_trackback) {
44e890f index.php now handles feeds and trackbacks.
rboren authored
35 $doing_trackback = 1;
b650b07 Move trackbacks to new comment function.
saxmatt authored
36 require('./wp-blog-header.php');
44e890f index.php now handles feeds and trackbacks.
rboren authored
37 }
6d55b31 Clean feed and trackback URLs.
rboren authored
38
b650b07 Move trackbacks to new comment function.
saxmatt authored
39 if ( is_single() )
6d55b31 Clean feed and trackback URLs.
rboren authored
40 $tb_id = $posts[0]->ID;
b650b07 Move trackbacks to new comment function.
saxmatt authored
41
42 if ( !$tb_id)
43 trackback_response(1, 'I really need an ID for this to work.');
08709cf Non-trackback requests to wp-trackback.php now redirect to the post.
saxmatt authored
44
45 if (empty($title) && empty($tb_url) && empty($blog_name)) {
46 // If it doesn't look like a trackback at all...
47 header('Location: ' . get_permalink($tb_id));
b650b07 Move trackbacks to new comment function.
saxmatt authored
48 exit;
43e4a8a The great renaming.
saxmatt authored
49 }
50
b650b07 Move trackbacks to new comment function.
saxmatt authored
51 if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
52 header('Content-Type: text/xml; charset=' . get_option('blog_charset') );
43e4a8a The great renaming.
saxmatt authored
53
25ae03e Giant commit, sorry mailing list people. Move all table names to new …
saxmatt authored
54 $pingstatus = $wpdb->get_var("SELECT ping_status FROM $wpdb->posts WHERE ID = $tb_id");
43e4a8a The great renaming.
saxmatt authored
55
56 if ('closed' == $pingstatus)
57 trackback_response(1, 'Sorry, trackbacks are closed for this item.');
58
b650b07 Move trackbacks to new comment function.
saxmatt authored
59 $title = strip_tags( htmlspecialchars( $title ) );
60 $title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
43e4a8a The great renaming.
saxmatt authored
61 $excerpt = strip_tags($excerpt);
b650b07 Move trackbacks to new comment function.
saxmatt authored
62 $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252) . '...' : $excerpt;
43e4a8a The great renaming.
saxmatt authored
63 $blog_name = htmlspecialchars($blog_name);
b650b07 Move trackbacks to new comment function.
saxmatt authored
64 $blog_name = (strlen($blog_name) > 250) ? substr($blog_name, 0, 250) . '...' : $blog_name;
43e4a8a The great renaming.
saxmatt authored
65
b650b07 Move trackbacks to new comment function.
saxmatt authored
66 $comment_post_id = $tb_id;
67 $commment_author = $blog_name;
68 $comment_author_email = '';
43e4a8a The great renaming.
saxmatt authored
69 $comment_author_url = $tb_url;
b650b07 Move trackbacks to new comment function.
saxmatt authored
70 $comment_content = "<strong>$title</strong>\n\n$excerpt";
71 $comment_type = 'trackback';
43e4a8a The great renaming.
saxmatt authored
72
b650b07 Move trackbacks to new comment function.
saxmatt authored
73 $commentdata = compact('comment_post_id', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type');
43e4a8a The great renaming.
saxmatt authored
74
b650b07 Move trackbacks to new comment function.
saxmatt authored
75 wp_new_comment($commentdata);
43e4a8a The great renaming.
saxmatt authored
76
b650b07 Move trackbacks to new comment function.
saxmatt authored
77 trackback_response(0);
78 do_action('trackback_post', $wpdb->insert_id);
43e4a8a The great renaming.
saxmatt authored
79
80 }
81 ?>
Something went wrong with that request. Please try again.