Projects : mp-wp : mp-wp_genesis
1 | <?php |
2 | /** |
3 | * Send blog links to pingomatic.com to update. |
4 | * |
5 | * You can disable this feature by deleting the option 'use_linksupdate' or |
6 | * setting the option to false. If no links exist, then no links are sent. |
7 | * |
8 | * Snoopy is included, but is not used. Fsockopen() is used instead to send link |
9 | * URLs. |
10 | * |
11 | * @package WordPress |
12 | * @subpackage Administration |
13 | */ |
14 | |
15 | /** Load WordPress Bootstrap */ |
16 | require_once('../wp-load.php'); |
17 | |
18 | if ( !get_option('use_linksupdate') ) |
19 | wp_die(__('Feature disabled.')); |
20 | |
21 | $link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links"); |
22 | |
23 | if ( !$link_uris ) |
24 | wp_die(__('No links')); |
25 | |
26 | $link_uris = urlencode( join( $link_uris, "\n" ) ); |
27 | |
28 | $query_string = "uris=$link_uris"; |
29 | |
30 | $options = array(); |
31 | $options['timeout'] = 30; |
32 | $options['body'] = $query_string; |
33 | |
34 | $options['headers'] = array( |
35 | 'content-type' => 'application/x-www-form-urlencoded; charset='.get_option('blog_charset'), |
36 | 'content-length' => strlen( $query_string ), |
37 | ); |
38 | |
39 | $response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options); |
40 | |
41 | if ( is_wp_error( $response ) ) |
42 | wp_die(__('Request Failed.')); |
43 | |
44 | if ( $response['response']['code'] != 200 ) |
45 | wp_die(__('Request Failed.')); |
46 | |
47 | $body = str_replace(array("\r\n", "\r"), "\n", $response['body']); |
48 | $returns = explode("\n", $body); |
49 | |
50 | foreach ($returns as $return) : |
51 | $time = substr($return, 0, 19); |
52 | $uri = preg_replace('/(.*?) | (.*?)/', '$2', $return); |
53 | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_updated = %s WHERE link_url = %s", $time, $uri) ); |
54 | endforeach; |
55 | |
56 | ?> |