Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-xmlrpc-server.php

    r23330 r22914  
    53105310        $pagelinkedto = str_replace('&', '&', $pagelinkedto);
    53115311
    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 
    53165312        // Check if the page linked to is in our site
    53175313        $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home')));
    53185314        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?'));
    53205316
    53215317        // let's find which post is linked to
     
    53515347                if (! ($post_ID = $wpdb->get_var($sql)) ) {
    53525348                    // returning unknown error '0' is better than die()ing
    5353                     return $this->pingback_error( 0, '' );
     5349                    return new IXR_Error(0, '');
    53545350                }
    53555351                $way = 'from the fragment (title)';
     
    53575353        } else {
    53585354            // 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.'));
    53605356        }
    53615357        $post_ID = (int) $post_ID;
     
    53645360
    53655361        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.'));
    53675363
    53685364        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.'));
    53705366
    53715367        // Check if pings are on
    53725368        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.'));
    53745370
    53755371        // Let's check that the remote site didn't already pingback this entry
    53765372        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.' ) );
    53785374
    53795375        // very stupid, but gives time to the 'from' server to publish !
     
    53815377
    53825378        // 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 );
    53845380        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.'));
    53865382
    53875383        $linea = apply_filters('pre_remote_source', $linea, $pagelinkedto);
     
    53955391        $title = $matchtitle[1];
    53965392        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.'));
    53985394
    53995395        $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
     
    54315427
    54325428        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.'));
    54345430
    54355431        $pagelinkedfrom = str_replace('&', '&amp;', $pagelinkedfrom);
     
    54785474        if ( !$post_ID ) {
    54795475            // 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&#8217;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&#8217;t exist, or it is not a pingback-enabled resource.'));
    54815477        }
    54825478
     
    54855481        if ( !$actual_post ) {
    54865482            // 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.'));
    54885484        }
    54895485
     
    55015497        return $pingbacks;
    55025498    }
    5503 
    5504     protected function pingback_error( $code, $message ) {
    5505         return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) );
    5506     }
    55075499}
Note: See TracChangeset for help on using the changeset viewer.