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
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../classes
File: class-wpml-xmlrpc.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* @author OnTheGo Systems
[3] Fix | Delete
*/
[4] Fix | Delete
class WPML_XMLRPC extends WPML_SP_User {
[5] Fix | Delete
private $xmlrpc_call_methods_for_save_post;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* WPML_XMLRPC constructor.
[9] Fix | Delete
*
[10] Fix | Delete
* @param SitePress $sitepress
[11] Fix | Delete
*/
[12] Fix | Delete
public function __construct( SitePress $sitepress ) {
[13] Fix | Delete
parent::__construct( $sitepress );
[14] Fix | Delete
$this->xmlrpc_call_methods_for_save_post = array( 'wp.newPost', 'wp.editPost', 'wp.newPage', 'wp.editPage' );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
public function init_hooks() {
[18] Fix | Delete
add_action( 'xmlrpc_call_success_mw_newPost', array( $this, 'meta_weblog_xmlrpc_post_update_action' ), 10, 2 );
[19] Fix | Delete
add_action( 'xmlrpc_call_success_mw_editPost', array( $this, 'meta_weblog_xmlrpc_post_update_action' ), 10, 2 );
[20] Fix | Delete
add_action( 'xmlrpc_call', array( $this, 'xmlrpc_call' ) );
[21] Fix | Delete
add_filter( 'xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
function get_languages( $args ) {
[25] Fix | Delete
list( $blog_id, $username, $password ) = $args;
[26] Fix | Delete
[27] Fix | Delete
if ( ! $this->sitepress->get_wp_api()->get_wp_xmlrpc_server()->login( $username, $password ) ) {
[28] Fix | Delete
return $this->sitepress->get_wp_api()->get_wp_xmlrpc_server()->error;
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
if ( ! defined( 'WP_ADMIN' ) ) {
[32] Fix | Delete
define( 'WP_ADMIN', true ); // hack - allow to force display language
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
return $this->sitepress->get_active_languages( true );
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
public function get_post_trid( $args ) {
[39] Fix | Delete
list( $blog_id, $username, $password, $element_id ) = $args;
[40] Fix | Delete
[41] Fix | Delete
if ( ! $this->sitepress->get_wp_api()->get_wp_xmlrpc_server()->login( $username, $password ) ) {
[42] Fix | Delete
return $this->sitepress->get_wp_api()->get_wp_xmlrpc_server()->error;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
$post_element = new WPML_Post_Element( $element_id, $this->sitepress );
[46] Fix | Delete
[47] Fix | Delete
return $post_element->get_trid();
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* @param int $post_ID
[52] Fix | Delete
* @param array $args
[53] Fix | Delete
*
[54] Fix | Delete
* @throws \UnexpectedValueException
[55] Fix | Delete
* @throws \InvalidArgumentException
[56] Fix | Delete
*/
[57] Fix | Delete
public function meta_weblog_xmlrpc_post_update_action( $post_ID, $args ) {
[58] Fix | Delete
$custom_fields = array();
[59] Fix | Delete
if ( array_key_exists( 'custom_fields', $args[3] ) ) {
[60] Fix | Delete
foreach ( $args[3]['custom_fields'] as $cf ) {
[61] Fix | Delete
$custom_fields[ $cf['key'] ] = $cf['value'];
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
$post_language_code = $this->sitepress->get_default_language();
[65] Fix | Delete
$trid = false;
[66] Fix | Delete
if ( array_key_exists( '_wpml_language', $custom_fields ) ) {
[67] Fix | Delete
$post_language_code = $custom_fields['_wpml_language'];
[68] Fix | Delete
}
[69] Fix | Delete
if ( array_key_exists( '_wpml_trid', $custom_fields ) ) {
[70] Fix | Delete
$trid = $custom_fields['_wpml_trid'];
[71] Fix | Delete
}
[72] Fix | Delete
$post_type = 'post';
[73] Fix | Delete
if ( array_key_exists( 'post_type', $args[3] ) ) {
[74] Fix | Delete
$post_type = $args[3]['post_type'];
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
$this->set_post_language( $post_ID, $post_type, $post_language_code, $trid );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
public function save_post_action( $pidd, $post ) {
[81] Fix | Delete
$post_language_code = get_post_meta( $pidd, '_wpml_language', true );
[82] Fix | Delete
$post_language_code = $post_language_code ? $post_language_code : $this->sitepress->get_default_language();
[83] Fix | Delete
[84] Fix | Delete
$trid = get_post_meta( $pidd, '_wpml_trid', true );
[85] Fix | Delete
$trid = $trid ? $trid : false;
[86] Fix | Delete
[87] Fix | Delete
$this->set_post_language( $pidd, $post->post_type, $post_language_code, $trid );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* @param int $post_ID
[92] Fix | Delete
* @param string $post_type
[93] Fix | Delete
* @param string $post_language_code
[94] Fix | Delete
* @param int|bool $trid
[95] Fix | Delete
*
[96] Fix | Delete
* @throws \InvalidArgumentException
[97] Fix | Delete
* @throws \UnexpectedValueException
[98] Fix | Delete
*/
[99] Fix | Delete
private function set_post_language( $post_ID, $post_type, $post_language_code, $trid = false ) {
[100] Fix | Delete
if ( $post_language_code && $this->sitepress->is_translated_post_type( $post_type ) ) {
[101] Fix | Delete
$wpml_translations = new WPML_Translations( $this->sitepress );
[102] Fix | Delete
$post_element = new WPML_Post_Element( $post_ID, $this->sitepress );
[103] Fix | Delete
if ( $post_language_code ) {
[104] Fix | Delete
$wpml_translations->set_language_code( $post_element, $post_language_code );
[105] Fix | Delete
}
[106] Fix | Delete
if ( $trid ) {
[107] Fix | Delete
$wpml_translations->set_trid( $post_element, $trid );
[108] Fix | Delete
}
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
public function xmlrpc_call( $action ) {
[113] Fix | Delete
if ( in_array( $action, $this->xmlrpc_call_methods_for_save_post, true ) ) {
[114] Fix | Delete
add_action( 'save_post', array( $this, 'save_post_action' ), 10, 2 );
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
public function xmlrpc_methods( $methods ) {
[119] Fix | Delete
/**
[120] Fix | Delete
* Parameters:
[121] Fix | Delete
* - int blog_id
[122] Fix | Delete
* - string username
[123] Fix | Delete
* - string password
[124] Fix | Delete
* - int post_id
[125] Fix | Delete
* Returns:
[126] Fix | Delete
* - struct
[127] Fix | Delete
* - int trid
[128] Fix | Delete
*/
[129] Fix | Delete
$methods['wpml.get_post_trid'] = array( $this, 'get_post_trid' );
[130] Fix | Delete
/**
[131] Fix | Delete
* Parameters:
[132] Fix | Delete
* - int blog_id
[133] Fix | Delete
* - string username
[134] Fix | Delete
* - string password
[135] Fix | Delete
* Returns:
[136] Fix | Delete
* - struct
[137] Fix | Delete
* - array active languages
[138] Fix | Delete
*/
[139] Fix | Delete
$methods['wpml.get_languages'] = array( $this, 'get_languages' );
[140] Fix | Delete
[141] Fix | Delete
return apply_filters( 'wpml_xmlrpc_methods', $methods );
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function