Changeset 23330 for branches/3.5/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 01/22/2013 10:32:06 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.5/wp-includes/class-wp-xmlrpc-server.php
r22914 r23330 5310 5310 $pagelinkedto = str_replace('&', '&', $pagelinkedto); 5311 5311 5312 $pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto ); 5313 if ( ! $pagelinkedfrom ) 5314 return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) ); 5315 5312 5316 // Check if the page linked to is in our site 5313 5317 $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); 5314 5318 if ( !$pos1 ) 5315 return new IXR_Error(0, __('Is there no link to us?'));5319 return $this->pingback_error( 0, __( 'Is there no link to us?' ) ); 5316 5320 5317 5321 // let's find which post is linked to … … 5347 5351 if (! ($post_ID = $wpdb->get_var($sql)) ) { 5348 5352 // returning unknown error '0' is better than die()ing 5349 return new IXR_Error(0, '');5353 return $this->pingback_error( 0, '' ); 5350 5354 } 5351 5355 $way = 'from the fragment (title)'; … … 5353 5357 } else { 5354 5358 // TODO: Attempt to extract a post ID from the given URL 5355 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));5359 return $this->pingback_error( 33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); 5356 5360 } 5357 5361 $post_ID = (int) $post_ID; … … 5360 5364 5361 5365 if ( !$post ) // Post_ID not found 5362 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));5366 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); 5363 5367 5364 5368 if ( $post_ID == url_to_postid($pagelinkedfrom) ) 5365 return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.'));5369 return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); 5366 5370 5367 5371 // Check if pings are on 5368 5372 if ( !pings_open($post) ) 5369 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));5373 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); 5370 5374 5371 5375 // Let's check that the remote site didn't already pingback this entry 5372 5376 if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) ) 5373 return new IXR_Error( 48, __( 'The pingback has already been registered.' ) );5377 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); 5374 5378 5375 5379 // very stupid, but gives time to the 'from' server to publish ! … … 5377 5381 5378 5382 // Let's check the remote site 5379 $linea = wp_remote_ fopen( $pagelinkedfrom);5383 $linea = wp_remote_retrieve_body( wp_remote_get( $pagelinkedfrom, array( 'timeout' => 10, 'redirection' => 0 ) ) ); 5380 5384 if ( !$linea ) 5381 return new IXR_Error(16, __('The source URL does not exist.'));5385 return $this->pingback_error( 16, __( 'The source URL does not exist.' ) ); 5382 5386 5383 5387 $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto); … … 5391 5395 $title = $matchtitle[1]; 5392 5396 if ( empty( $title ) ) 5393 return new IXR_Error(32, __('We cannot find a title on that page.'));5397 return $this->pingback_error( 32, __('We cannot find a title on that page.' ) ); 5394 5398 5395 5399 $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need … … 5427 5431 5428 5432 if ( empty($context) ) // Link to target not found 5429 return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.'));5433 return $this->pingback_error( 17, __( 'The source URL does not contain a link to the target URL, and so cannot be used as a source.' ) ); 5430 5434 5431 5435 $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); … … 5474 5478 if ( !$post_ID ) { 5475 5479 // We aren't sure that the resource is available and/or pingback enabled 5476 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.'));5480 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); 5477 5481 } 5478 5482 … … 5481 5485 if ( !$actual_post ) { 5482 5486 // No such post = resource not found 5483 return new IXR_Error(32, __('The specified target URL does not exist.'));5487 return $this->pingback_error( 32, __('The specified target URL does not exist.' ) ); 5484 5488 } 5485 5489 … … 5497 5501 return $pingbacks; 5498 5502 } 5503 5504 protected function pingback_error( $code, $message ) { 5505 return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) ); 5506 } 5499 5507 }
Note: See TracChangeset
for help on using the changeset viewer.