Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-xmlrpc-server.php
public function mt_getRecentPostTitles( $args ) {
[6500] Fix | Delete
$this->escape( $args );
[6501] Fix | Delete
[6502] Fix | Delete
$username = $args[1];
[6503] Fix | Delete
$password = $args[2];
[6504] Fix | Delete
if ( isset( $args[3] ) ) {
[6505] Fix | Delete
$query = array( 'numberposts' => absint( $args[3] ) );
[6506] Fix | Delete
} else {
[6507] Fix | Delete
$query = array();
[6508] Fix | Delete
}
[6509] Fix | Delete
[6510] Fix | Delete
$user = $this->login( $username, $password );
[6511] Fix | Delete
if ( ! $user ) {
[6512] Fix | Delete
return $this->error;
[6513] Fix | Delete
}
[6514] Fix | Delete
[6515] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6516] Fix | Delete
do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this );
[6517] Fix | Delete
[6518] Fix | Delete
$posts_list = wp_get_recent_posts( $query );
[6519] Fix | Delete
[6520] Fix | Delete
if ( ! $posts_list ) {
[6521] Fix | Delete
$this->error = new IXR_Error( 500, __( 'Either there are no posts, or something went wrong.' ) );
[6522] Fix | Delete
return $this->error;
[6523] Fix | Delete
}
[6524] Fix | Delete
[6525] Fix | Delete
$recent_posts = array();
[6526] Fix | Delete
[6527] Fix | Delete
foreach ( $posts_list as $entry ) {
[6528] Fix | Delete
if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
[6529] Fix | Delete
continue;
[6530] Fix | Delete
}
[6531] Fix | Delete
[6532] Fix | Delete
$post_date = $this->_convert_date( $entry['post_date'] );
[6533] Fix | Delete
$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
[6534] Fix | Delete
[6535] Fix | Delete
$recent_posts[] = array(
[6536] Fix | Delete
'dateCreated' => $post_date,
[6537] Fix | Delete
'userid' => $entry['post_author'],
[6538] Fix | Delete
'postid' => (string) $entry['ID'],
[6539] Fix | Delete
'title' => $entry['post_title'],
[6540] Fix | Delete
'post_status' => $entry['post_status'],
[6541] Fix | Delete
'date_created_gmt' => $post_date_gmt,
[6542] Fix | Delete
);
[6543] Fix | Delete
}
[6544] Fix | Delete
[6545] Fix | Delete
return $recent_posts;
[6546] Fix | Delete
}
[6547] Fix | Delete
[6548] Fix | Delete
/**
[6549] Fix | Delete
* Retrieves the list of all categories on a blog.
[6550] Fix | Delete
*
[6551] Fix | Delete
* @since 1.5.0
[6552] Fix | Delete
*
[6553] Fix | Delete
* @param array $args {
[6554] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[6555] Fix | Delete
*
[6556] Fix | Delete
* @type int $0 Blog ID (unused).
[6557] Fix | Delete
* @type string $1 Username.
[6558] Fix | Delete
* @type string $2 Password.
[6559] Fix | Delete
* }
[6560] Fix | Delete
* @return array|IXR_Error
[6561] Fix | Delete
*/
[6562] Fix | Delete
public function mt_getCategoryList( $args ) {
[6563] Fix | Delete
$this->escape( $args );
[6564] Fix | Delete
[6565] Fix | Delete
$username = $args[1];
[6566] Fix | Delete
$password = $args[2];
[6567] Fix | Delete
[6568] Fix | Delete
$user = $this->login( $username, $password );
[6569] Fix | Delete
if ( ! $user ) {
[6570] Fix | Delete
return $this->error;
[6571] Fix | Delete
}
[6572] Fix | Delete
[6573] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[6574] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
[6575] Fix | Delete
}
[6576] Fix | Delete
[6577] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6578] Fix | Delete
do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this );
[6579] Fix | Delete
[6580] Fix | Delete
$categories_struct = array();
[6581] Fix | Delete
[6582] Fix | Delete
$cats = get_categories(
[6583] Fix | Delete
array(
[6584] Fix | Delete
'hide_empty' => 0,
[6585] Fix | Delete
'hierarchical' => 0,
[6586] Fix | Delete
)
[6587] Fix | Delete
);
[6588] Fix | Delete
if ( $cats ) {
[6589] Fix | Delete
foreach ( $cats as $cat ) {
[6590] Fix | Delete
$struct = array();
[6591] Fix | Delete
$struct['categoryId'] = $cat->term_id;
[6592] Fix | Delete
$struct['categoryName'] = $cat->name;
[6593] Fix | Delete
[6594] Fix | Delete
$categories_struct[] = $struct;
[6595] Fix | Delete
}
[6596] Fix | Delete
}
[6597] Fix | Delete
[6598] Fix | Delete
return $categories_struct;
[6599] Fix | Delete
}
[6600] Fix | Delete
[6601] Fix | Delete
/**
[6602] Fix | Delete
* Retrieves post categories.
[6603] Fix | Delete
*
[6604] Fix | Delete
* @since 1.5.0
[6605] Fix | Delete
*
[6606] Fix | Delete
* @param array $args {
[6607] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[6608] Fix | Delete
*
[6609] Fix | Delete
* @type int $0 Post ID.
[6610] Fix | Delete
* @type string $1 Username.
[6611] Fix | Delete
* @type string $2 Password.
[6612] Fix | Delete
* }
[6613] Fix | Delete
* @return array|IXR_Error
[6614] Fix | Delete
*/
[6615] Fix | Delete
public function mt_getPostCategories( $args ) {
[6616] Fix | Delete
$this->escape( $args );
[6617] Fix | Delete
[6618] Fix | Delete
$post_id = (int) $args[0];
[6619] Fix | Delete
$username = $args[1];
[6620] Fix | Delete
$password = $args[2];
[6621] Fix | Delete
[6622] Fix | Delete
$user = $this->login( $username, $password );
[6623] Fix | Delete
if ( ! $user ) {
[6624] Fix | Delete
return $this->error;
[6625] Fix | Delete
}
[6626] Fix | Delete
[6627] Fix | Delete
if ( ! get_post( $post_id ) ) {
[6628] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[6629] Fix | Delete
}
[6630] Fix | Delete
[6631] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[6632] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
[6633] Fix | Delete
}
[6634] Fix | Delete
[6635] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6636] Fix | Delete
do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
[6637] Fix | Delete
[6638] Fix | Delete
$categories = array();
[6639] Fix | Delete
$catids = wp_get_post_categories( (int) $post_id );
[6640] Fix | Delete
// First listed category will be the primary category.
[6641] Fix | Delete
$isPrimary = true;
[6642] Fix | Delete
foreach ( $catids as $catid ) {
[6643] Fix | Delete
$categories[] = array(
[6644] Fix | Delete
'categoryName' => get_cat_name( $catid ),
[6645] Fix | Delete
'categoryId' => (string) $catid,
[6646] Fix | Delete
'isPrimary' => $isPrimary,
[6647] Fix | Delete
);
[6648] Fix | Delete
$isPrimary = false;
[6649] Fix | Delete
}
[6650] Fix | Delete
[6651] Fix | Delete
return $categories;
[6652] Fix | Delete
}
[6653] Fix | Delete
[6654] Fix | Delete
/**
[6655] Fix | Delete
* Sets categories for a post.
[6656] Fix | Delete
*
[6657] Fix | Delete
* @since 1.5.0
[6658] Fix | Delete
*
[6659] Fix | Delete
* @param array $args {
[6660] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[6661] Fix | Delete
*
[6662] Fix | Delete
* @type int $0 Post ID.
[6663] Fix | Delete
* @type string $1 Username.
[6664] Fix | Delete
* @type string $2 Password.
[6665] Fix | Delete
* @type array $3 Categories.
[6666] Fix | Delete
* }
[6667] Fix | Delete
* @return true|IXR_Error True on success.
[6668] Fix | Delete
*/
[6669] Fix | Delete
public function mt_setPostCategories( $args ) {
[6670] Fix | Delete
$this->escape( $args );
[6671] Fix | Delete
[6672] Fix | Delete
$post_id = (int) $args[0];
[6673] Fix | Delete
$username = $args[1];
[6674] Fix | Delete
$password = $args[2];
[6675] Fix | Delete
$categories = $args[3];
[6676] Fix | Delete
[6677] Fix | Delete
$user = $this->login( $username, $password );
[6678] Fix | Delete
if ( ! $user ) {
[6679] Fix | Delete
return $this->error;
[6680] Fix | Delete
}
[6681] Fix | Delete
[6682] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6683] Fix | Delete
do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
[6684] Fix | Delete
[6685] Fix | Delete
if ( ! get_post( $post_id ) ) {
[6686] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[6687] Fix | Delete
}
[6688] Fix | Delete
[6689] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[6690] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
[6691] Fix | Delete
}
[6692] Fix | Delete
[6693] Fix | Delete
$catids = array();
[6694] Fix | Delete
foreach ( $categories as $cat ) {
[6695] Fix | Delete
$catids[] = $cat['categoryId'];
[6696] Fix | Delete
}
[6697] Fix | Delete
[6698] Fix | Delete
wp_set_post_categories( $post_id, $catids );
[6699] Fix | Delete
[6700] Fix | Delete
return true;
[6701] Fix | Delete
}
[6702] Fix | Delete
[6703] Fix | Delete
/**
[6704] Fix | Delete
* Retrieves an array of methods supported by this server.
[6705] Fix | Delete
*
[6706] Fix | Delete
* @since 1.5.0
[6707] Fix | Delete
*
[6708] Fix | Delete
* @return array
[6709] Fix | Delete
*/
[6710] Fix | Delete
public function mt_supportedMethods() {
[6711] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6712] Fix | Delete
do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this );
[6713] Fix | Delete
[6714] Fix | Delete
return array_keys( $this->methods );
[6715] Fix | Delete
}
[6716] Fix | Delete
[6717] Fix | Delete
/**
[6718] Fix | Delete
* Retrieves an empty array because we don't support per-post text filters.
[6719] Fix | Delete
*
[6720] Fix | Delete
* @since 1.5.0
[6721] Fix | Delete
*/
[6722] Fix | Delete
public function mt_supportedTextFilters() {
[6723] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6724] Fix | Delete
do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this );
[6725] Fix | Delete
[6726] Fix | Delete
/**
[6727] Fix | Delete
* Filters the MoveableType text filters list for XML-RPC.
[6728] Fix | Delete
*
[6729] Fix | Delete
* @since 2.2.0
[6730] Fix | Delete
*
[6731] Fix | Delete
* @param array $filters An array of text filters.
[6732] Fix | Delete
*/
[6733] Fix | Delete
return apply_filters( 'xmlrpc_text_filters', array() );
[6734] Fix | Delete
}
[6735] Fix | Delete
[6736] Fix | Delete
/**
[6737] Fix | Delete
* Retrieves trackbacks sent to a given post.
[6738] Fix | Delete
*
[6739] Fix | Delete
* @since 1.5.0
[6740] Fix | Delete
*
[6741] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[6742] Fix | Delete
*
[6743] Fix | Delete
* @param int $post_id
[6744] Fix | Delete
* @return array|IXR_Error
[6745] Fix | Delete
*/
[6746] Fix | Delete
public function mt_getTrackbackPings( $post_id ) {
[6747] Fix | Delete
global $wpdb;
[6748] Fix | Delete
[6749] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6750] Fix | Delete
do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
[6751] Fix | Delete
[6752] Fix | Delete
$actual_post = get_post( $post_id, ARRAY_A );
[6753] Fix | Delete
[6754] Fix | Delete
if ( ! $actual_post ) {
[6755] Fix | Delete
return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
[6756] Fix | Delete
}
[6757] Fix | Delete
[6758] Fix | Delete
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
[6759] Fix | Delete
[6760] Fix | Delete
if ( ! $comments ) {
[6761] Fix | Delete
return array();
[6762] Fix | Delete
}
[6763] Fix | Delete
[6764] Fix | Delete
$trackback_pings = array();
[6765] Fix | Delete
foreach ( $comments as $comment ) {
[6766] Fix | Delete
if ( 'trackback' === $comment->comment_type ) {
[6767] Fix | Delete
$content = $comment->comment_content;
[6768] Fix | Delete
$title = substr( $content, 8, ( strpos( $content, '</strong>' ) - 8 ) );
[6769] Fix | Delete
$trackback_pings[] = array(
[6770] Fix | Delete
'pingTitle' => $title,
[6771] Fix | Delete
'pingURL' => $comment->comment_author_url,
[6772] Fix | Delete
'pingIP' => $comment->comment_author_IP,
[6773] Fix | Delete
);
[6774] Fix | Delete
}
[6775] Fix | Delete
}
[6776] Fix | Delete
[6777] Fix | Delete
return $trackback_pings;
[6778] Fix | Delete
}
[6779] Fix | Delete
[6780] Fix | Delete
/**
[6781] Fix | Delete
* Sets a post's publish status to 'publish'.
[6782] Fix | Delete
*
[6783] Fix | Delete
* @since 1.5.0
[6784] Fix | Delete
*
[6785] Fix | Delete
* @param array $args {
[6786] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[6787] Fix | Delete
*
[6788] Fix | Delete
* @type int $0 Post ID.
[6789] Fix | Delete
* @type string $1 Username.
[6790] Fix | Delete
* @type string $2 Password.
[6791] Fix | Delete
* }
[6792] Fix | Delete
* @return int|IXR_Error
[6793] Fix | Delete
*/
[6794] Fix | Delete
public function mt_publishPost( $args ) {
[6795] Fix | Delete
$this->escape( $args );
[6796] Fix | Delete
[6797] Fix | Delete
$post_id = (int) $args[0];
[6798] Fix | Delete
$username = $args[1];
[6799] Fix | Delete
$password = $args[2];
[6800] Fix | Delete
[6801] Fix | Delete
$user = $this->login( $username, $password );
[6802] Fix | Delete
if ( ! $user ) {
[6803] Fix | Delete
return $this->error;
[6804] Fix | Delete
}
[6805] Fix | Delete
[6806] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6807] Fix | Delete
do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
[6808] Fix | Delete
[6809] Fix | Delete
$postdata = get_post( $post_id, ARRAY_A );
[6810] Fix | Delete
if ( ! $postdata ) {
[6811] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[6812] Fix | Delete
}
[6813] Fix | Delete
[6814] Fix | Delete
if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
[6815] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
[6816] Fix | Delete
}
[6817] Fix | Delete
[6818] Fix | Delete
$postdata['post_status'] = 'publish';
[6819] Fix | Delete
[6820] Fix | Delete
// Retain old categories.
[6821] Fix | Delete
$postdata['post_category'] = wp_get_post_categories( $post_id );
[6822] Fix | Delete
$this->escape( $postdata );
[6823] Fix | Delete
[6824] Fix | Delete
return wp_update_post( $postdata );
[6825] Fix | Delete
}
[6826] Fix | Delete
[6827] Fix | Delete
/*
[6828] Fix | Delete
* Pingback functions.
[6829] Fix | Delete
* Specs on www.hixie.ch/specs/pingback/pingback
[6830] Fix | Delete
*/
[6831] Fix | Delete
[6832] Fix | Delete
/**
[6833] Fix | Delete
* Retrieves a pingback and registers it.
[6834] Fix | Delete
*
[6835] Fix | Delete
* @since 1.5.0
[6836] Fix | Delete
*
[6837] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[6838] Fix | Delete
*
[6839] Fix | Delete
* @param array $args {
[6840] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[6841] Fix | Delete
*
[6842] Fix | Delete
* @type string $0 URL of page linked from.
[6843] Fix | Delete
* @type string $1 URL of page linked to.
[6844] Fix | Delete
* }
[6845] Fix | Delete
* @return string|IXR_Error
[6846] Fix | Delete
*/
[6847] Fix | Delete
public function pingback_ping( $args ) {
[6848] Fix | Delete
global $wpdb;
[6849] Fix | Delete
[6850] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[6851] Fix | Delete
do_action( 'xmlrpc_call', 'pingback.ping', $args, $this );
[6852] Fix | Delete
[6853] Fix | Delete
$this->escape( $args );
[6854] Fix | Delete
[6855] Fix | Delete
$pagelinkedfrom = str_replace( '&amp;', '&', $args[0] );
[6856] Fix | Delete
$pagelinkedto = str_replace( '&amp;', '&', $args[1] );
[6857] Fix | Delete
$pagelinkedto = str_replace( '&', '&amp;', $pagelinkedto );
[6858] Fix | Delete
[6859] Fix | Delete
/**
[6860] Fix | Delete
* Filters the pingback source URI.
[6861] Fix | Delete
*
[6862] Fix | Delete
* @since 3.6.0
[6863] Fix | Delete
*
[6864] Fix | Delete
* @param string $pagelinkedfrom URI of the page linked from.
[6865] Fix | Delete
* @param string $pagelinkedto URI of the page linked to.
[6866] Fix | Delete
*/
[6867] Fix | Delete
$pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto );
[6868] Fix | Delete
[6869] Fix | Delete
if ( ! $pagelinkedfrom ) {
[6870] Fix | Delete
return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) );
[6871] Fix | Delete
}
[6872] Fix | Delete
[6873] Fix | Delete
// Check if the page linked to is on our site.
[6874] Fix | Delete
$pos1 = strpos( $pagelinkedto, str_replace( array( 'http://www.', 'http://', 'https://www.', 'https://' ), '', get_option( 'home' ) ) );
[6875] Fix | Delete
if ( ! $pos1 ) {
[6876] Fix | Delete
return $this->pingback_error( 0, __( 'Is there no link to us?' ) );
[6877] Fix | Delete
}
[6878] Fix | Delete
[6879] Fix | Delete
/*
[6880] Fix | Delete
* Let's find which post is linked to.
[6881] Fix | Delete
* FIXME: Does url_to_postid() cover all these cases already?
[6882] Fix | Delete
* If so, then let's use it and drop the old code.
[6883] Fix | Delete
*/
[6884] Fix | Delete
$urltest = parse_url( $pagelinkedto );
[6885] Fix | Delete
$post_id = url_to_postid( $pagelinkedto );
[6886] Fix | Delete
if ( $post_id ) {
[6887] Fix | Delete
// $way
[6888] Fix | Delete
} elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
[6889] Fix | Delete
// The path defines the post_ID (archives/p/XXXX).
[6890] Fix | Delete
$blah = explode( '/', $match[0] );
[6891] Fix | Delete
$post_id = (int) $blah[1];
[6892] Fix | Delete
} elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) {
[6893] Fix | Delete
// The query string defines the post_ID (?p=XXXX).
[6894] Fix | Delete
$blah = explode( '=', $match[0] );
[6895] Fix | Delete
$post_id = (int) $blah[1];
[6896] Fix | Delete
} elseif ( isset( $urltest['fragment'] ) ) {
[6897] Fix | Delete
// An #anchor is there, it's either...
[6898] Fix | Delete
if ( (int) $urltest['fragment'] ) {
[6899] Fix | Delete
// ...an integer #XXXX (simplest case),
[6900] Fix | Delete
$post_id = (int) $urltest['fragment'];
[6901] Fix | Delete
} elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {
[6902] Fix | Delete
// ...a post ID in the form 'post-###',
[6903] Fix | Delete
$post_id = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
[6904] Fix | Delete
} elseif ( is_string( $urltest['fragment'] ) ) {
[6905] Fix | Delete
// ...or a string #title, a little more complicated.
[6906] Fix | Delete
$title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
[6907] Fix | Delete
$sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
[6908] Fix | Delete
$post_id = $wpdb->get_var( $sql );
[6909] Fix | Delete
if ( ! $post_id ) {
[6910] Fix | Delete
// Returning unknown error '0' is better than die()'ing.
[6911] Fix | Delete
return $this->pingback_error( 0, '' );
[6912] Fix | Delete
}
[6913] Fix | Delete
}
[6914] Fix | Delete
} else {
[6915] Fix | Delete
// TODO: Attempt to extract a post ID from the given URL.
[6916] Fix | Delete
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
[6917] Fix | Delete
}
[6918] Fix | Delete
$post_id = (int) $post_id;
[6919] Fix | Delete
[6920] Fix | Delete
$post = get_post( $post_id );
[6921] Fix | Delete
[6922] Fix | Delete
if ( ! $post ) { // Post not found.
[6923] Fix | Delete
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
[6924] Fix | Delete
}
[6925] Fix | Delete
[6926] Fix | Delete
if ( url_to_postid( $pagelinkedfrom ) == $post_id ) {
[6927] Fix | Delete
return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
[6928] Fix | Delete
}
[6929] Fix | Delete
[6930] Fix | Delete
// Check if pings are on.
[6931] Fix | Delete
if ( ! pings_open( $post ) ) {
[6932] Fix | Delete
return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
[6933] Fix | Delete
}
[6934] Fix | Delete
[6935] Fix | Delete
// Let's check that the remote site didn't already pingback this entry.
[6936] Fix | Delete
if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_id, $pagelinkedfrom ) ) ) {
[6937] Fix | Delete
return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
[6938] Fix | Delete
}
[6939] Fix | Delete
[6940] Fix | Delete
/*
[6941] Fix | Delete
* The remote site may have sent the pingback before it finished publishing its own content
[6942] Fix | Delete
* containing this pingback URL. If that happens then it won't be immediately possible to fetch
[6943] Fix | Delete
* the pinging post; adding a small delay reduces the likelihood of this happening.
[6944] Fix | Delete
*
[6945] Fix | Delete
* While there are more robust methods than calling `sleep()` here (because `sleep()` merely
[6946] Fix | Delete
* mitigates the risk of requesting the remote post before it's available), this is effective
[6947] Fix | Delete
* enough for most cases and avoids introducing more complexity into this code.
[6948] Fix | Delete
*
[6949] Fix | Delete
* One way to improve the reliability of this code might be to add failure-handling to the remote
[6950] Fix | Delete
* fetch and retry up to a set number of times if it receives a 404. This could also handle 401 and
[6951] Fix | Delete
* 403 responses to differentiate the "does not exist" failure from the "may not access" failure.
[6952] Fix | Delete
*/
[6953] Fix | Delete
sleep( 1 );
[6954] Fix | Delete
[6955] Fix | Delete
$remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
[6956] Fix | Delete
[6957] Fix | Delete
/** This filter is documented in wp-includes/class-wp-http.php */
[6958] Fix | Delete
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom );
[6959] Fix | Delete
[6960] Fix | Delete
// Let's check the remote site.
[6961] Fix | Delete
$http_api_args = array(
[6962] Fix | Delete
'timeout' => 10,
[6963] Fix | Delete
'redirection' => 0,
[6964] Fix | Delete
'limit_response_size' => 153600, // 150 KB
[6965] Fix | Delete
'user-agent' => "$user_agent; verifying pingback from $remote_ip",
[6966] Fix | Delete
'headers' => array(
[6967] Fix | Delete
'X-Pingback-Forwarded-For' => $remote_ip,
[6968] Fix | Delete
),
[6969] Fix | Delete
);
[6970] Fix | Delete
[6971] Fix | Delete
$request = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
[6972] Fix | Delete
$remote_source = wp_remote_retrieve_body( $request );
[6973] Fix | Delete
$remote_source_original = $remote_source;
[6974] Fix | Delete
[6975] Fix | Delete
if ( ! $remote_source ) {
[6976] Fix | Delete
return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
[6977] Fix | Delete
}
[6978] Fix | Delete
[6979] Fix | Delete
/**
[6980] Fix | Delete
* Filters the pingback remote source.
[6981] Fix | Delete
*
[6982] Fix | Delete
* @since 2.5.0
[6983] Fix | Delete
*
[6984] Fix | Delete
* @param string $remote_source Response source for the page linked from.
[6985] Fix | Delete
* @param string $pagelinkedto URL of the page linked to.
[6986] Fix | Delete
*/
[6987] Fix | Delete
$remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto );
[6988] Fix | Delete
[6989] Fix | Delete
// Work around bug in strip_tags():
[6990] Fix | Delete
$remote_source = str_replace( '<!DOC', '<DOC', $remote_source );
[6991] Fix | Delete
$remote_source = preg_replace( '/[\r\n\t ]+/', ' ', $remote_source ); // normalize spaces
[6992] Fix | Delete
$remote_source = preg_replace( '/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/', "\n\n", $remote_source );
[6993] Fix | Delete
[6994] Fix | Delete
preg_match( '|<title>([^<]*?)</title>|is', $remote_source, $matchtitle );
[6995] Fix | Delete
$title = isset( $matchtitle[1] ) ? $matchtitle[1] : '';
[6996] Fix | Delete
if ( empty( $title ) ) {
[6997] Fix | Delete
return $this->pingback_error( 32, __( 'A title on that page cannot be found.' ) );
[6998] Fix | Delete
}
[6999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function