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.../menu
File: wpml-troubleshooting-terms-menu.class.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class WPML_Troubleshooting_Terms_Menu {
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Displays the admin notice informing about terms in the old format, using the language suffix.
[5] Fix | Delete
* The notice is displayed until it is either dismissed or the update button is pressed.
[6] Fix | Delete
*/
[7] Fix | Delete
public static function display_terms_with_suffix_admin_notice() {
[8] Fix | Delete
global $sitepress;
[9] Fix | Delete
if ( ! $sitepress->get_setting( 'taxonomy_names_checked' ) ) {
[10] Fix | Delete
$suffix_count = count( WPML_Terms_Translations::get_all_terms_with_language_suffix() );
[11] Fix | Delete
if ( $suffix_count > 0 ) {
[12] Fix | Delete
$message = '<p>';
[13] Fix | Delete
$message .= sprintf( __( "In this version of WPML, you can give your taxonomy terms the same name across multiple languages. You need to update %d taxonomy terms on your website so that they display the same name without any language suffixes.", "sitepress" ), $suffix_count );
[14] Fix | Delete
$message .= '</p>';
[15] Fix | Delete
if ( defined( 'ICL_PLUGIN_URL' ) ) {
[16] Fix | Delete
$message .= '<p><a href="' . admin_url( 'admin.php?page=' . WPML_PLUGIN_FOLDER . '/menu/troubleshooting.php#termsuffixupdate' ) . '"><button class="button-primary">Open terms update page</button></a>';
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
ICL_AdminNotifier::addMessage( "termssuffixnotice", $message, 'error', true, false, false, 'terms-suffix', true );
[20] Fix | Delete
}
[21] Fix | Delete
$sitepress->set_setting( 'taxonomy_names_checked', true, true );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
[25] Fix | Delete
//TODO: [WPML 3.3] the ICL_AdminNotifier class got improved and we should not call \ICL_AdminNotifier::displayMessages to display an admin notice
[26] Fix | Delete
ICL_AdminNotifier::displayMessages( 'terms-suffix' );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Returns the HTML for the display of all terms with a language suffix in the troubleshooting menu.
[31] Fix | Delete
* @return string
[32] Fix | Delete
*/
[33] Fix | Delete
public static function display_terms_with_suffix() {
[34] Fix | Delete
[35] Fix | Delete
$terms_to_display = WPML_Terms_Translations::get_all_terms_with_language_suffix();
[36] Fix | Delete
[37] Fix | Delete
$output = '';
[38] Fix | Delete
[39] Fix | Delete
if ( ! empty( $terms_to_display ) ) {
[40] Fix | Delete
[41] Fix | Delete
$output = '<div class="icl_cyan_box">';
[42] Fix | Delete
$output .= '<table class="widefat" id="icl-updated-term-names-table">';
[43] Fix | Delete
$output .= '<a name="termsuffixupdate"></a>';
[44] Fix | Delete
$output .= '<tr><h3>' . __( "Remove language suffixes from taxonomy names.", 'sitepress' ) . '</h3></tr>';
[45] Fix | Delete
[46] Fix | Delete
$output .= '<tr id="icl-updated-term-names-headings"><th></th><th>' . __( "Old Name", "sitepress" ) . '</th><th>' . __( "Updated Name", "sitepress" ) . '</th><th>' . __( "Affected Taxonomies", "sitepress" ) . '</th></tr>';
[47] Fix | Delete
[48] Fix | Delete
foreach ( $terms_to_display as $term_id => $term ) {
[49] Fix | Delete
[50] Fix | Delete
$updated_term_name = self::strip_language_suffix( $term[ 'name' ] );
[51] Fix | Delete
[52] Fix | Delete
$output .= '<tr class="icl-term-with-suffix-row"><td>';
[53] Fix | Delete
$output .= '<input type="checkbox" checked="checked" name="' . $updated_term_name . '" value="' . $term_id . '"/>';
[54] Fix | Delete
$output .= '</td>';
[55] Fix | Delete
$output .= '<td>' . $term[ 'name' ] . '</td>';
[56] Fix | Delete
$output .= '<td id="term_' . $term_id . '">' . $updated_term_name . '</td>';
[57] Fix | Delete
$output .= '<td>' . join( ', ', $term[ 'taxonomies' ] ) . '</td>';
[58] Fix | Delete
$output .= '</tr>';
[59] Fix | Delete
}
[60] Fix | Delete
$output .= '</table>';
[61] Fix | Delete
[62] Fix | Delete
$output .= '</br></br>';
[63] Fix | Delete
$output .= '<button id="icl-update-term-names" class="button-primary">' . __( 'Update term names', 'sitepress' ) . '</button>';
[64] Fix | Delete
$output .= '<button id="icl-update-term-names-done" class="button-primary" disabled="disabled" style="display:none;">' . __( 'All term names updated', 'sitepress' ) . '</button>';
[65] Fix | Delete
$output .= '</div>';
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
return $output;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* @param string $term_name
[73] Fix | Delete
* Strips a term off all language suffixes in the form @<lang_code> on it.
[74] Fix | Delete
*
[75] Fix | Delete
* @return string
[76] Fix | Delete
*/
[77] Fix | Delete
public static function strip_language_suffix( $term_name ) {
[78] Fix | Delete
global $wpdb;
[79] Fix | Delete
[80] Fix | Delete
$lang_codes = $wpdb->get_col( "SELECT code FROM {$wpdb->prefix}icl_languages" );
[81] Fix | Delete
[82] Fix | Delete
$new_name_parts = explode( ' @', $term_name );
[83] Fix | Delete
[84] Fix | Delete
$new_name_parts = array_filter( $new_name_parts );
[85] Fix | Delete
[86] Fix | Delete
$last_part = array_pop( $new_name_parts );
[87] Fix | Delete
[88] Fix | Delete
while ( in_array( $last_part, $lang_codes ) ) {
[89] Fix | Delete
$last_part = array_pop( $new_name_parts );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
$new_name = '';
[93] Fix | Delete
if ( ! empty( $new_name_parts ) ) {
[94] Fix | Delete
$new_name = join( ' @', $new_name_parts ) . ' @';
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
$new_name .= $last_part;
[98] Fix | Delete
[99] Fix | Delete
return $new_name;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Ajax handler for the troubleshoot page. Updates the term name on those terms given via the Ajax action.
[104] Fix | Delete
*/
[105] Fix | Delete
public static function wpml_update_term_names_troubleshoot() {
[106] Fix | Delete
global $wpdb;
[107] Fix | Delete
ICL_AdminNotifier::removeMessage( 'termssuffixnotice' );
[108] Fix | Delete
[109] Fix | Delete
$term_names = array();
[110] Fix | Delete
[111] Fix | Delete
$nonce = filter_input( INPUT_POST, '_icl_nonce', FILTER_SANITIZE_STRING );
[112] Fix | Delete
if ( !wp_verify_nonce( $nonce, 'update_term_names_nonce' ) ) {
[113] Fix | Delete
die( 'Wrong Nonce' );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
$request_post_terms = filter_input(INPUT_POST, 'terms');
[117] Fix | Delete
if ( $request_post_terms ) {
[118] Fix | Delete
$term_names = json_decode( stripcslashes( $request_post_terms ) );
[119] Fix | Delete
if ( ! is_object( $term_names ) ) {
[120] Fix | Delete
$term_names = array();
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
$updated = array();
[125] Fix | Delete
[126] Fix | Delete
foreach ( $term_names as $term_id => $new_name ) {
[127] Fix | Delete
$res = $wpdb->update( $wpdb->terms, array( 'name' => $new_name ), array( 'term_id' => $term_id ) );
[128] Fix | Delete
if ( $res ) {
[129] Fix | Delete
$updated[ ] = $term_id;
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
wp_send_json_success( $updated );
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function