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-translate-independently.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class WPML_Translate_Independently {
[2] Fix | Delete
[3] Fix | Delete
public function __construct() {
[4] Fix | Delete
$this->init();
[5] Fix | Delete
}
[6] Fix | Delete
[7] Fix | Delete
public function init() {
[8] Fix | Delete
add_action( 'wpml_scripts_setup', array( $this, 'localize_scripts' ), PHP_INT_MAX );
[9] Fix | Delete
add_action( 'wp_ajax_check_duplicate', array( $this, 'wpml_translate_independently' ) );
[10] Fix | Delete
add_filter( 'tiny_mce_before_init', array( $this, 'add_tiny_mce_change_detection' ), 999, 1 );
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
public function wpml_translate_independently() {
[14] Fix | Delete
$post_id = isset( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : null;
[15] Fix | Delete
$nonce = isset( $_POST['icl_duplciate_nonce'] ) ? sanitize_text_field( $_POST['icl_duplciate_nonce'] ) : '';
[16] Fix | Delete
[17] Fix | Delete
if ( wp_verify_nonce( $nonce, 'icl_check_duplicates' ) || null === $post_id ) {
[18] Fix | Delete
if ( delete_post_meta( $post_id, '_icl_lang_duplicate_of' ) ) {
[19] Fix | Delete
wp_send_json_success( true );
[20] Fix | Delete
} else {
[21] Fix | Delete
wp_send_json_error( false );
[22] Fix | Delete
}
[23] Fix | Delete
} else {
[24] Fix | Delete
wp_send_json_error( false );
[25] Fix | Delete
}
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
public function localize_scripts() {
[29] Fix | Delete
$success = _x( 'You are updating a duplicate post.', '1/2 Confirm to make duplicated translations independent', 'sitepress' ) . "\n";
[30] Fix | Delete
$success .= _x( 'To not lose your changes, WPML will set this post to be translated independently.', '2/2 Confirm to make duplicated translations independent', 'sitepress' ) . "\n";
[31] Fix | Delete
$duplicate_data = array(
[32] Fix | Delete
'icl_duplicate_message' => $success,
[33] Fix | Delete
'icl_duplicate_fail' => __( 'Unable to remove relationship!', 'sitepress' ),
[34] Fix | Delete
);
[35] Fix | Delete
[36] Fix | Delete
$post = isset( $_GET['post'] ) ? filter_var( $_GET['post'], FILTER_SANITIZE_NUMBER_INT ) : '';
[37] Fix | Delete
if ( $post && '' !== get_post_meta( $post, '_icl_lang_duplicate_of', true ) ) {
[38] Fix | Delete
$duplicate_data['duplicate_post_nonce'] = wp_create_nonce( 'icl_check_duplicates' );
[39] Fix | Delete
$duplicate_data['duplicate_post'] = $post;
[40] Fix | Delete
$duplicate_data['wp_classic_editor_changed'] = false;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
wp_localize_script( 'sitepress-post-edit', 'icl_duplicate_data', $duplicate_data );
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Add callback to detect post editor change.
[48] Fix | Delete
* @param array $initArray
[49] Fix | Delete
*
[50] Fix | Delete
* @return array
[51] Fix | Delete
*/
[52] Fix | Delete
public function add_tiny_mce_change_detection( $initArray ) {
[53] Fix | Delete
$initArray['setup'] = 'function(ed) {
[54] Fix | Delete
ed.on(\'change\', function() {
[55] Fix | Delete
icl_duplicate_data.wp_classic_editor_changed = true;
[56] Fix | Delete
});
[57] Fix | Delete
}';
[58] Fix | Delete
return $initArray;
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function