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