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(); SitePress_Setup::fill_flags(); 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': $updated_items = WPML\Troubleshooting\AssignTranslationStatusToDuplicates::run(); 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; $has_get_terms_args_filter = 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 ); $has_terms_clauses_filter = 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 ); } } if ( $has_terms_clauses_filter ) { add_filter( 'terms_clauses', array( $sitepress, 'terms_clauses' ), 10, 3 ); } if ( $has_get_term_filter ) { add_filter( 'get_term', array( $sitepress, 'get_term_adjust_id' ), 1, 1 ); } if ( $has_get_terms_args_filter ) { 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(); } } ?>

' . __( '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 '

'; _e( 'If you are using the Advanced Translation Editor, you will lose the translations that are in progress, as well as the existing translation memory and glossary. You will also lose access to purchases, invoices, and history related to your work with the Advanced Translation Editor.', 'sitepress' ); echo '

'; echo '

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