term_taxonomy_id; } $action = filter_input(INPUT_GET, 'debug_action', FILTER_SANITIZE_STRING); $nonce = filter_input(INPUT_GET, 'nonce', FILTER_SANITIZE_STRING); if ( ! $action ) { $action = filter_input( INPUT_POST, 'debug_action', FILTER_SANITIZE_STRING ); $nonce = filter_input( INPUT_POST, 'nonce', FILTER_SANITIZE_STRING ); } $otgs_twig_cache_disable_key = '_otgs_twig_cache_disabled'; if ( defined( 'WPML_Templates_Factory::OTGS_TWIG_CACHE_DISABLED_KEY' ) ) { $otgs_twig_cache_disable_key = WPML_Templates_Factory::OTGS_TWIG_CACHE_DISABLED_KEY; } if ( isset( $action ) && wp_verify_nonce( $nonce, $action ) ) { ob_end_clean(); global $wpdb; switch ( $action ) { case 'otgs_twig_cache_enable': $new_value = false; if ( array_key_exists( 'new_value', $_POST ) ) { $new_value = (bool) $_POST['new_value']; } update_option( $otgs_twig_cache_disable_key, $new_value, 'no' ); exit; 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(); $cache_directory = new WPML_Cache_Directory( new WPML_WP_API() ); $cache_directory->remove(); exit; case 'ghost_clean': // clean the icl_translations table $orphans = $wpdb->get_col( " SELECT t.translation_id, t.element_type 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 ) ) { $upgrade_args_set = array(); foreach( $orphans as $orphan ) { $upgrade_args = array( 'translation_id' => $orphan, 'context' => 'post' ); $upgrade_args_set[] = $upgrade_args; do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'before_delete' ) ) ); } $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); foreach( $upgrade_args_set as $upgrade_args ) { do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'after_delete' ) ) ); } } $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 ) ) { $upgrade_args_set = array(); foreach( $orphans as $orphan ) { $upgrade_args = array( 'translation_id' => $orphan, 'context' => 'comment' ); $upgrade_args_set[] = $upgrade_args; do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'before_delete' ) ) ); } $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); foreach( $upgrade_args_set as $upgrade_args ) { do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'after_delete' ) ) ); } } $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 ) ) { $upgrade_args_set = array(); foreach( $orphans as $orphan ) { $upgrade_args = array( 'translation_id' => $orphan, 'context' => 'tax' ); $upgrade_args_set[] = $upgrade_args; do_action( 'wpml_translation_update', $upgrade_args ); } $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); foreach( $upgrade_args_set as $upgrade_args ) { do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'after_delete' ) ) ); } } 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 ) ) { $upgrade_args_set = array(); foreach( $orphans as $orphan ) { $upgrade_args = array( 'translation_id' => $orphan, 'context' => 'tax' ); $upgrade_args_set[] = $upgrade_args; do_action( 'wpml_translation_update', $upgrade_args ); } $wpdb->query( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id IN (" . wpml_prepare_in( $orphans, '%d' ) . ")" ); foreach( $upgrade_args_set as $upgrade_args ) { do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'after_delete' ) ) ); } } } } // 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 ) { $upgrade_args = array( 'translation_id' => $e, 'context' => 'post' ); do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'before_delete' ) ) ); $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", $e ) ); do_action( 'wpml_translation_update', array_merge( $upgrade_args, array( 'type' => 'after_delete' ) ) ); } } } } 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': $old_el_type = 'post_' . sanitize_key ( filter_input ( INPUT_GET, 'old_value' ) ); $new_el_type = 'post_' . sanitize_key ( filter_input ( INPUT_GET, 'new_value' ) ); $wpdb->update ( $wpdb->prefix . 'icl_translations', array( 'element_type' => $new_el_type ), array( 'element_type' => $old_el_type ) ); do_action( 'wpml_translation_update', array( 'type' => 'element_type_update', 'element_type' => $new_el_type, 'context' => 'post' ) ); exit; case 'link_taxonomy': $new_el_type = 'tax_' . $_GET[ 'new_value' ]; $old_el_type = 'tax_' . $_GET[ 'old_value' ]; $wpdb->update( $wpdb->prefix . 'icl_translations', array( 'element_type' => $new_el_type ), array( 'element_type' => $old_el_type ) ); do_action( 'wpml_translation_update', array( 'type' => 'element_type_update', 'element_type' => $new_el_type, 'content' => 'tax' ) ); exit; case 'icl_fix_terms_count': global $sitepress; remove_filter('get_terms_args', array($sitepress, 'get_terms_args_filter')); $has_get_term_filter = remove_filter('get_term', array($sitepress,'get_term_adjust_id'), 1); 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')); if ( $has_get_term_filter ) { add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 ); } add_filter('get_terms_args', array($sitepress, 'get_terms_args_filter'), 10, 2); exit; case 'icl_remove_st_db_cache_logs' : delete_option( 'wpml-st-persist-errors' ); 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(); } } ?>
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 '
' . $post_type . ' | '; if ( isset( $translatable_posts[ $post_type ] ) ) { echo '' . __( 'linked to: ', 'sitepress' ) . $translatable_posts[ $post_type ]->labels->name . ' | '; } else { echo ''; echo ''; echo ' | '; } echo '
$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 '
' . $tax . ' | '; if ( in_array( $tax, $translatable_taxs ) ) { echo '' . __( 'linked to: ', 'sitepress' ) . $wp_taxonomies[ $tax ]->labels->name . ' | '; } else { echo ''; echo ''; echo ' | '; } 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 '