term_taxonomy_id; } $action = filter_input(INPUT_GET, 'debug_action', FILTER_SANITIZE_STRING); $nonce = filter_input(INPUT_GET, 'nonce', FILTER_SANITIZE_STRING); if ( isset( $action) && wp_verify_nonce($nonce, $action) ) { ob_end_clean(); global $wpdb; switch ( $action ) { case 'fix_languages': SitePress_Setup::fill_languages(); SitePress_Setup::fill_languages_translations(); icl_cache_clear(); exit; case 'icl_fix_collation': repair_el_type_collate(); exit; case 'cache_clear': icl_cache_clear(); exit; case 'ghost_clean': // clean the icl_translations table $orphans = $wpdb->get_col( " SELECT t.translation_id FROM {$wpdb->prefix}icl_translations t LEFT JOIN {$wpdb->posts} p ON t.element_id = p.ID WHERE t.element_id IS NOT NULL AND t.element_type LIKE 'post\\_%' AND p.ID IS NULL " ); if ( !empty( $orphans ) ) { $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); } $orphans = $wpdb->get_col( " SELECT t.translation_id FROM {$wpdb->prefix}icl_translations t LEFT JOIN {$wpdb->comments} c ON t.element_id = c.comment_ID WHERE t.element_type = 'comment' AND c.comment_ID IS NULL " ); if ( false === $orphans ) { echo $wpdb->last_result; } if ( !empty( $orphans ) ) { $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); } $orphans = $wpdb->get_col( " SELECT t.translation_id FROM {$wpdb->prefix}icl_translations t LEFT JOIN {$wpdb->term_taxonomy} p ON t.element_id = p.term_taxonomy_id WHERE t.element_id IS NOT NULL AND t.element_type LIKE 'tax\\_%' AND p.term_taxonomy_id IS NULL" ); if ( !empty( $orphans ) ) { $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); } global $wp_taxonomies; if ( is_array( $wp_taxonomies ) ) { foreach ( $wp_taxonomies as $t => $v ) { $orphans = $wpdb->get_col( " SELECT t.translation_id FROM {$wpdb->prefix}icl_translations t LEFT JOIN {$wpdb->term_taxonomy} p ON t.element_id = p.term_taxonomy_id WHERE t.element_type = 'tax_{$t}' AND p.taxonomy <> '{$t}' " ); if ( !empty( $orphans ) ) { $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); } } } // remove ghost translations // get unlinked rids $rids = $wpdb->get_col( "SELECT rid FROM {$wpdb->prefix}icl_translation_status WHERE translation_id NOT IN (SELECT translation_id FROM {$wpdb->prefix}icl_translations)" ); if ( $rids ) { $jids = $wpdb->get_col( "SELECT job_id FROM {$wpdb->prefix}icl_translate_job WHERE rid IN (" . wpml_prepare_in( $rids, '%d' ) . ")" ); if ( $jids ) { $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translate WHERE job_id IN (" . wpml_prepare_in( $jids, '%d' ) . ")" ); $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translate_job WHERE job_id IN (" . wpml_prepare_in( $jids, '%d' ) . ")" ); $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translation_status WHERE rid IN (" . wpml_prepare_in( $rids, '%d' ) . ")" ); } } // remove any duplicates in icl_translations $trs = $wpdb->get_results( "SELECT element_id, GROUP_CONCAT(translation_id) AS tids FROM {$wpdb->prefix}icl_translations WHERE element_id > 0 AND element_type LIKE 'post\\_%' GROUP BY element_id" ); foreach ( $trs as $r ) { $exp = explode( ',', $r->tids ); if ( count( $exp ) > 1 ) { $maxtid = max( $exp ); foreach ( $exp as $e ) { if ( $e != $maxtid ) { $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", $e ) ); } } } } exit; break; case 'assign_translation_status_to_duplicates': global $sitepress, $iclTranslationManagement; $active_languages = $sitepress->get_active_languages(); $duplicated_posts_sql = "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key='_icl_lang_duplicate_of' AND meta_value<>'' GROUP BY meta_value;"; $duplicated_posts = $wpdb->get_col( $duplicated_posts_sql ); $updated_items = 0; foreach ( $duplicated_posts as $original_post_id ) { $element_type = 'post_' . get_post_type( $original_post_id ); $trid = $sitepress->get_element_trid( $original_post_id, $element_type ); $element_language_details = $sitepress->get_element_translations( $trid, $element_type ); $item_updated = false; foreach ( $active_languages as $code => $active_language ) { if ( ! isset( $element_language_details[ $code ] ) ) { continue; } $element_translation = $element_language_details[ $code ]; if ( ! isset( $element_translation ) || $element_translation->original ) { continue; } $translation = $iclTranslationManagement->get_element_translation( $element_translation->element_id, $code, $element_type ); if ( ! $translation ) { $status_helper = wpml_get_post_status_helper(); $status_helper->set_status( $element_translation->element_id, ICL_TM_DUPLICATE ); $item_updated = true; } } if ( $item_updated ) { $updated_items ++; } if ( $updated_items >= 20 ) { break; } } echo json_encode( array( 'updated' => $updated_items ) ); exit; case 'icl_ts_add_missing_language': global $iclTranslationManagement; $iclTranslationManagement->add_missing_language_information(); exit; case 'link_post_type': $wpdb->update ( $wpdb->prefix . 'icl_translations', array( 'element_type' => 'post_' . sanitize_key ( filter_input ( INPUT_GET, 'new_value' ) ) ), array( 'element_type' => 'post_' . sanitize_key ( filter_input ( INPUT_GET, 'old_value' ) ) ) ); exit; case 'link_taxonomy': $wpdb->update( $wpdb->prefix . 'icl_translations', array( 'element_type' => 'tax_' . $_GET[ 'new_value' ] ), array( 'element_type' => 'tax_' . $_GET[ 'old_value' ] ) ); exit; case 'icl_fix_terms_count': global $sitepress; remove_filter('get_terms_args', array($sitepress, 'get_terms_args_filter')); remove_filter('get_term', array($sitepress,'get_term_adjust_id')); remove_filter('terms_clauses', array($sitepress,'terms_clauses')); foreach ( get_taxonomies( array(), 'names' ) as $taxonomy ) { $terms_objects = get_terms( $taxonomy, 'hide_empty=0' ); if ( $terms_objects ) { $term_taxonomy_ids = array_map( 'get_term_taxonomy_id_from_term_object', $terms_objects ); wp_update_term_count( $term_taxonomy_ids, $taxonomy, true ); } } add_filter('terms_clauses', array($sitepress,'terms_clauses')); add_filter('get_term', array($sitepress,'get_term_adjust_id')); add_filter('get_terms_args', array($sitepress, 'get_terms_args_filter'), 10, 2); exit; } } /* DEBUG ACTION */ global $sitepress; if ( wp_verify_nonce( (string)filter_input( INPUT_POST, 'icl_reset_allnonce' ), 'icl_reset_all' ) ) { if ( $_POST[ 'icl-reset-all' ] == 'on' ) { icl_reset_wpml(); echo ''; exit(); } } ?>

' . __( 'WPML Settings', 'sitepress' ) . ''; echo '

' . __( 'WPML settings', 'sitepress' ) . '

'; echo ''; ?>


















get_translatable_documents(); $res = $wpdb->get_col( $wpdb->prepare("SELECT DISTINCT element_type FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s", array( wpml_like_escape('post_') . '%' ) ) ); echo ''; foreach ( $res as $row ) { $post_type = preg_replace( '#^post_#', '', $row ); if ( $post_type == 'nav_menu_item' ) continue; echo ''; echo ''; if ( isset( $translatable_posts[ $post_type ] ) ) { echo ''; } else { echo ''; } echo ''; } echo '
' . $post_type . '' . __( 'linked to: ', 'sitepress' ) . $translatable_posts[ $post_type ]->labels->name . ''; echo ''; echo '
'; echo '
'; echo __( 'Note: if you edited the custom post declaration you may need to re-configure WPML to mark it as translatable.', 'sitepress' ); ?>



$post_type ) { $translatable_taxs = array_merge( $translatable_taxs, $sitepress->get_translatable_taxonomies( true, $name ) ); } $translatable_taxs = array_unique( $translatable_taxs ); $res = $wpdb->get_col( $wpdb->prepare("SELECT DISTINCT element_type FROM {$wpdb->prefix}icl_translations WHERE element_type LIKE %s", array( wpml_like_escape('tax_') . '%' ) ) ); echo ''; foreach ( $res as $row ) { $tax = preg_replace( '#^tax_#', '', $row ); if ( $tax == 'link_category' || $tax == 'nav_menu' ) continue; echo ''; echo ''; if ( in_array( $tax, $translatable_taxs ) ) { echo ''; } else { echo ''; } echo ''; } echo '
' . $tax . '' . __( 'linked to: ', 'sitepress' ) . $wp_taxonomies[ $tax ]->labels->name . ''; echo ''; echo '
'; echo '
'; echo __( 'Note: if you edited the custom taxonomy declaration you may need to re-configure WPML to mark it as translatable.', 'sitepress' ); ?>



' . __( 'Reset', 'sitepress' ) . ''; ?>

'; wp_nonce_field( 'icl_reset_all', 'icl_reset_allnonce' ); echo '

'; _e( "The 'Reset' action will deactivate the WPML plugin after it deletes the WPML tables (tables with the 'icl_' prefix) from the database. The action will NOT delete any content (posts, taxonomy terms etc.). It only affects translation and language information that WPML associates with each content type.", 'sitepress' ); echo '

'; echo '

'; _e( "Please note that all translations you have sent to remote translation services will be lost if you reset WPML's data. They cannot be recovered later.", 'sitepress' ); echo '

'; echo '

'; echo ''; echo ''; ?>