{ return $term_object->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 'reset_pro_translation_configuration': $sitepress_settings = get_option('icl_sitepress_settings'); $sitepress_settings['content_translation_languages_setup'] = false; $sitepress_settings['content_translation_setup_complete'] = false; unset($sitepress_settings['content_translation_setup_wizard_step']); unset($sitepress_settings['site_id']); unset($sitepress_settings['access_key']); unset($sitepress_settings['translator_choice']); unset($sitepress_settings['icl_lang_status']); unset($sitepress_settings['icl_balance']); unset($sitepress_settings['icl_support_ticket_id']); unset($sitepress_settings['icl_current_session']); unset($sitepress_settings['last_get_translator_status_call']); unset($sitepress_settings['last_icl_reminder_fetch']);
function icl_sitepress_activate() { global $wpdb; $charset_collate = ''; if (method_exists($wpdb, 'has_cap') && $wpdb->has_cap('collation')) { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } try { SitePress_Setup::fill_languages(); SitePress_Setup::fill_languages_translations(); SitePress_Setup::fill_flags(); // translations $table_name = $wpdb->prefix . 'icl_translations'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `translation_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `element_type` VARCHAR( 36 ) NOT NULL DEFAULT 'post_post',\n `element_id` BIGINT NULL DEFAULT NULL ,\n `trid` BIGINT NOT NULL ,\n `language_code` VARCHAR( 7 ) NOT NULL,\n `source_language_code` VARCHAR( 7 ),\n UNIQUE KEY `el_type_id` (`element_type`,`element_id`),\n UNIQUE KEY `trid_lang` (`trid`,`language_code`),\n KEY `trid` (`trid`),\n KEY `id_type_language` (`element_id`, `element_type`, `language_code`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // translation_status table $table_name = $wpdb->prefix . 'icl_translation_status'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `rid` bigint(20) NOT NULL AUTO_INCREMENT,\n `translation_id` bigint(20) NOT NULL,\n `status` tinyint(4) NOT NULL,\n `translator_id` bigint(20) NOT NULL,\n `needs_update` tinyint(4) NOT NULL,\n `md5` varchar(32) NOT NULL,\n `translation_service` varchar(16) NOT NULL,\n `batch_id` int DEFAULT 0 NOT NULL,\n `translation_package` longtext NOT NULL,\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n `links_fixed` tinyint(4) NOT NULL DEFAULT 0,\n `_prevstate` longtext,\n PRIMARY KEY (`rid`),\n UNIQUE KEY `translation_id` (`translation_id`)\n ) {$charset_collate} \n "; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // translation jobs $table_name = $wpdb->prefix . 'icl_translate_job'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `job_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `rid` BIGINT UNSIGNED NOT NULL ,\n `translator_id` INT UNSIGNED NOT NULL ,\n `translated` TINYINT UNSIGNED NOT NULL DEFAULT 0,\n `manager_id` INT UNSIGNED NOT NULL ,\n `revision` INT UNSIGNED NULL,\n INDEX ( `rid` , `translator_id` )\n ) {$charset_collate} \n "; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // translate table $table_name = $wpdb->prefix . 'icl_translate'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `tid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `job_id` BIGINT UNSIGNED NOT NULL ,\n `content_id` BIGINT UNSIGNED NOT NULL ,\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n `field_type` VARCHAR( 160 ) NOT NULL ,\n `field_format` VARCHAR( 16 ) NOT NULL ,\n `field_translate` TINYINT NOT NULL ,\n `field_data` longtext NOT NULL ,\n `field_data_translated` longtext NOT NULL ,\n `field_finished` TINYINT NOT NULL DEFAULT 0,\n INDEX ( `job_id` )\n ) {$charset_collate}\n "; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // batches table $table_name = $wpdb->prefix . 'icl_translation_batches'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS {$wpdb->prefix}icl_translation_batches (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `batch_name` text NOT NULL,\n `tp_id` int NULL,\n `ts_url` text NULL,\n `last_update` DATETIME NULL,\n PRIMARY KEY (`id`)\n ) {$charset_collate}\n "; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // languages locale file names $table_name = $wpdb->prefix . 'icl_locale_map'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `code` VARCHAR( 7 ) NOT NULL ,\n `locale` VARCHAR( 35 ) NOT NULL ,\n UNIQUE (`code` ,`locale`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } /* general string translation */ $table_name = $wpdb->prefix . 'icl_strings'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` bigint(20) unsigned NOT NULL auto_increment,\n `language` varchar(7) NOT NULL,\n `context` varchar(" . WPML_STRING_TABLE_NAME_CONTEXT_LENGTH . ") CHARACTER SET UTF8 NOT NULL,\n `name` varchar(" . WPML_STRING_TABLE_NAME_CONTEXT_LENGTH . ") CHARACTER SET UTF8 NOT NULL,\n `value` text NOT NULL,\n `string_package_id` BIGINT unsigned NULL,\n `type` VARCHAR(40) NOT NULL DEFAULT 'LINE',\n `title` VARCHAR(160) NULL,\n `status` TINYINT NOT NULL,\n `gettext_context` TEXT NOT NULL,\n `domain_name_context_md5` VARCHAR(32) CHARACTER SET LATIN1 NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `uc_domain_name_context_md5` (`domain_name_context_md5`),\n KEY `language_context` (`language`, `context`)\n ) {$charset_collate}\n "; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } $table_name = $wpdb->prefix . 'icl_string_translations'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` bigint(20) unsigned NOT NULL auto_increment,\n `string_id` bigint(20) unsigned NOT NULL,\n `language` varchar(10) NOT NULL,\n `status` tinyint(4) NOT NULL,\n `value` text NULL DEFAULT NULL, \n `translator_id` bigint(20) unsigned DEFAULT NULL, \n `translation_service` varchar(16) DEFAULT '' NOT NULL,\n `batch_id` int DEFAULT 0 NOT NULL,\n `translation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`),\n UNIQUE KEY `string_language` (`string_id`,`language`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } $table_name = $wpdb->prefix . 'icl_string_status'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `rid` BIGINT NOT NULL ,\n `string_translation_id` BIGINT NOT NULL ,\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\n `md5` VARCHAR( 32 ) NOT NULL,\n INDEX ( `string_translation_id` )\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } $table_name = $wpdb->prefix . 'icl_string_positions'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `string_id` BIGINT NOT NULL ,\n `kind` TINYINT,\n `position_in_page` VARCHAR( 255 ) NOT NULL,\n INDEX ( `string_id` )\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // message status table $table_name = $wpdb->prefix . 'icl_message_status'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` bigint(20) unsigned NOT NULL auto_increment,\n `rid` bigint(20) unsigned NOT NULL,\n `object_id` bigint(20) unsigned NOT NULL,\n `from_language` varchar(10) NOT NULL,\n `to_language` varchar(10) NOT NULL,\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,\n `md5` varchar(32) NOT NULL,\n `object_type` varchar(64) NOT NULL,\n `status` smallint(6) NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `rid` (`rid`),\n KEY `object_id` (`object_id`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } /* string translation - start */ $icl_translation_sql = "\n CREATE TABLE IF NOT EXISTS {$wpdb->prefix}icl_core_status (\n `id` BIGINT NOT NULL auto_increment,\n `rid` BIGINT NOT NULL,\n `module` VARCHAR( 16 ) NOT NULL ,\n `origin` VARCHAR( 64 ) NOT NULL ,\n `target` VARCHAR( 64 ) NOT NULL ,\n `status` SMALLINT NOT NULL,\n PRIMARY KEY ( `id` ) ,\n INDEX ( `rid` )\n ) {$charset_collate}\n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_content_status` (\n `rid` BIGINT NOT NULL ,\n `nid` BIGINT NOT NULL ,\n `timestamp` DATETIME NOT NULL ,\n `md5` VARCHAR( 32 ) NOT NULL ,\n PRIMARY KEY ( `rid` ) ,\n INDEX ( `nid` )\n ) {$charset_collate} \n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_node` (\n `nid` BIGINT NOT NULL ,\n `md5` VARCHAR( 32 ) NOT NULL ,\n `links_fixed` TINYINT NOT NULL DEFAULT 0,\n PRIMARY KEY ( `nid` )\n ) {$charset_collate} \n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_reminders` (\n `id` BIGINT NOT NULL ,\n `message` TEXT NOT NULL ,\n `url` TEXT NOT NULL ,\n `can_delete` TINYINT NOT NULL ,\n `show` TINYINT NOT NULL ,\n PRIMARY KEY ( `id` )\n ) {$charset_collate} \n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); exit; } // don't set the new version if a multi-step upgrade is in progress if (!defined('ICL_MULTI_STEP_UPGRADE')) { delete_option('icl_sitepress_version'); add_option('icl_sitepress_version', ICL_SITEPRESS_VERSION, '', true); } $iclsettings = get_option('icl_sitepress_settings'); if ($iclsettings === false) { $short_v = implode('.', array_slice(explode('.', ICL_SITEPRESS_VERSION), 0, 3)); $settings = array('hide_upgrade_notice' => $short_v); add_option('icl_sitepress_settings', $settings, '', true); } else { // reset ajx_health_flag $iclsettings['ajx_health_checked'] = 0; $iclsettings['just_reactivated'] = 1; update_option('icl_sitepress_settings', $iclsettings); } //Set new caps for all administrator role icl_enable_capabilities(); repair_el_type_collate(); do_action('wpml_activated'); }