function icl_sitepress_activate() { //if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'error_scrape'){ // return; //} global $wpdb; global $EZSQL_ERROR; require_once ICL_PLUGIN_PATH . '/inc/lang-data.inc'; //defines $langs_names $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 { // languages table $table_name = $wpdb->prefix . 'icl_languages'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = " \r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `code` VARCHAR( 7 ) NOT NULL ,\r\r\n `english_name` VARCHAR( 128 ) NOT NULL , \r\r\n `major` TINYINT NOT NULL DEFAULT '0', \r\r\n `active` TINYINT NOT NULL ,\r\r\n `default_locale` VARCHAR( 8 ),\r\r\n UNIQUE KEY `code` (`code`),\r\r\n UNIQUE KEY `english_name` (`english_name`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } //$langs_names is defined in ICL_PLUGIN_PATH . '/inc/lang-data.inc' foreach ($langs_names as $key => $val) { if (strpos($key, 'Norwegian Bokm') === 0) { $key = 'Norwegian Bokmål'; $lang_codes[$key] = 'nb'; } // exception for norwegian $default_locale = isset($lang_locales[$lang_codes[$key]]) ? $lang_locales[$lang_codes[$key]] : ''; @$wpdb->insert($wpdb->prefix . 'icl_languages', array('english_name' => $key, 'code' => $lang_codes[$key], 'major' => $val['major'], 'active' => 0, 'default_locale' => $default_locale)); } } // languages translations table $add_languages_translations = false; $table_name = $wpdb->prefix . 'icl_languages_translations'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `language_code` VARCHAR( 7 ) NOT NULL ,\r\r\n `display_language_code` VARCHAR( 7 ) NOT NULL , \r\r\n `name` VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL,\r\r\n UNIQUE(`language_code`, `display_language_code`) \r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } $add_languages_translations = true; } //else{ // this table will not be trucated on upgrade starting with WPML 1.7.3 // $add_languages_translations sticks to false; //if(!defined('ICL_PRESERVE_LANGUAGES_TRANSLATIONS') || !ICL_PRESERVE_LANGUAGES_TRANSLATIONS){ // mysql_query("TRUNCATE TABLE `{$table_name}`"); // $add_languages_translations = true; //} //} if ($add_languages_translations) { foreach ($langs_names as $lang => $val) { if (strpos($lang, 'Norwegian Bokm') === 0) { $lang = 'Norwegian Bokmål'; $lang_codes[$lang] = 'nb'; } foreach ($val['tr'] as $k => $display) { if (strpos($k, 'Norwegian Bokm') === 0) { $k = 'Norwegian Bokmål'; } if (!trim($display)) { $display = $lang; } if (!$wpdb->get_var("SELECT id FROM {$table_name} WHERE language_code='{$lang_codes[$lang]}' AND display_language_code='{$lang_codes[$k]}'")) { $wpdb->insert($wpdb->prefix . 'icl_languages_translations', array('language_code' => $lang_codes[$lang], 'display_language_code' => $lang_codes[$k], 'name' => $display)); } } } } // translations $table_name = $wpdb->prefix . 'icl_translations'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `translation_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `element_type` VARCHAR( 32 ) NOT NULL DEFAULT 'post_post',\r\r\n `element_id` BIGINT NULL DEFAULT NULL ,\r\r\n `trid` BIGINT NOT NULL ,\r\r\n `language_code` VARCHAR( 7 ) NOT NULL,\r\r\n `source_language_code` VARCHAR( 7 ),\r\r\n UNIQUE KEY `el_type_id` (`element_type`,`element_id`),\r\r\n UNIQUE KEY `trid_lang` (`trid`,`language_code`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // translation_status table $table_name = $wpdb->prefix . 'icl_translation_status'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `rid` bigint(20) NOT NULL AUTO_INCREMENT,\r\r\n `translation_id` bigint(20) NOT NULL,\r\r\n `status` tinyint(4) NOT NULL,\r\r\n `translator_id` bigint(20) NOT NULL,\r\r\n `needs_update` tinyint(4) NOT NULL,\r\r\n `md5` varchar(32) NOT NULL,\r\r\n `translation_service` varchar(16) NOT NULL,\r\r\n `translation_package` text NOT NULL,\r\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\r\n `links_fixed` tinyint(4) NOT NULL DEFAULT 0,\r\r\n `_prevstate` longtext,\r\r\n PRIMARY KEY (`rid`),\r\r\n UNIQUE KEY `translation_id` (`translation_id`)\r\r\n ) ENGINE=MyISAM {$charset_collate} \r\r\n "; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // translation jobs $table_name = $wpdb->prefix . 'icl_translate_job'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `job_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `rid` BIGINT UNSIGNED NOT NULL ,\r\r\n `translator_id` INT UNSIGNED NOT NULL ,\r\r\n `translated` TINYINT UNSIGNED NOT NULL DEFAULT 0,\r\r\n `manager_id` INT UNSIGNED NOT NULL ,\r\r\n `revision` INT UNSIGNED NULL,\r\r\n INDEX ( `rid` , `translator_id` )\r\r\n ) ENGINE = MYISAM ; \r\r\n "; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // translate table $table_name = $wpdb->prefix . 'icl_translate'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `tid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `job_id` BIGINT UNSIGNED NOT NULL ,\r\r\n `content_id` BIGINT UNSIGNED NOT NULL ,\r\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\r\r\n `field_type` VARCHAR( 128 ) NOT NULL ,\r\r\n `field_format` VARCHAR( 16 ) NOT NULL ,\r\r\n `field_translate` TINYINT NOT NULL ,\r\r\n `field_data` TEXT NOT NULL ,\r\r\n `field_data_translated` TEXT NOT NULL ,\r\r\n `field_finished` TINYINT NOT NULL DEFAULT 0,\r\r\n INDEX ( `job_id` )\r\r\n ) ENGINE = MYISAM ;\r\r\n "; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // languages locale file names $table_name = $wpdb->prefix . 'icl_locale_map'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `code` VARCHAR( 8 ) NOT NULL ,\r\r\n `locale` VARCHAR( 8 ) NOT NULL ,\r\r\n UNIQUE (`code` ,`locale`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // flags table $table_name = $wpdb->prefix . 'icl_flags'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `lang_code` VARCHAR( 10 ) NOT NULL ,\r\r\n `flag` VARCHAR( 32 ) NOT NULL ,\r\r\n `from_template` TINYINT NOT NULL DEFAULT '0',\r\r\n UNIQUE (`lang_code`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } $codes = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages"); foreach ($codes as $code) { if (!$code || $wpdb->get_var("SELECT lang_code FROM {$wpdb->prefix}icl_flags WHERE lang_code='{$code}'")) { continue; } if (!file_exists(ICL_PLUGIN_PATH . '/res/flags/' . $code . '.png')) { $file = 'nil.png'; } else { $file = $code . '.png'; } $wpdb->insert($wpdb->prefix . 'icl_flags', array('lang_code' => $code, 'flag' => $file, 'from_template' => 0)); } } /* general string translation */ $table_name = $wpdb->prefix . 'icl_strings'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\r\n `language` varchar(10) NOT NULL,\r\r\n `context` varchar(160) NOT NULL,\r\r\n `name` varchar(160) NOT NULL,\r\r\n `value` text NOT NULL,\r\r\n `status` TINYINT NOT NULL,\r\r\n PRIMARY KEY (`id`),\r\r\n UNIQUE KEY `context_name` (`context`,`name`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } $table_name = $wpdb->prefix . 'icl_string_translations'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\r\n `string_id` bigint(20) unsigned NOT NULL,\r\r\n `language` varchar(10) NOT NULL,\r\r\n `status` tinyint(4) NOT NULL,\r\r\n `value` text NULL DEFAULT NULL, \r\r\n `translator_id` bigint(20) unsigned DEFAULT NULL, \r\r\n `translation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\r\n PRIMARY KEY (`id`),\r\r\n UNIQUE KEY `string_language` (`string_id`,`language`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } $table_name = $wpdb->prefix . 'icl_string_status'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `rid` BIGINT NOT NULL ,\r\r\n `string_translation_id` BIGINT NOT NULL ,\r\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\r\r\n `md5` VARCHAR( 32 ) NOT NULL,\r\r\n INDEX ( `string_translation_id` )\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } $table_name = $wpdb->prefix . 'icl_string_positions'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\r\n `string_id` BIGINT NOT NULL ,\r\r\n `kind` TINYINT,\r\r\n `position_in_page` VARCHAR( 255 ) NOT NULL,\r\r\n INDEX ( `string_id` )\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } // message status table $table_name = $wpdb->prefix . 'icl_message_status'; if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) { $sql = "\r\r\n CREATE TABLE `{$table_name}` (\r\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\r\n `rid` bigint(20) unsigned NOT NULL,\r\r\n `object_id` bigint(20) unsigned NOT NULL,\r\r\n `from_language` varchar(10) NOT NULL,\r\r\n `to_language` varchar(10) NOT NULL,\r\r\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,\r\r\n `md5` varchar(32) NOT NULL,\r\r\n `object_type` varchar(64) NOT NULL,\r\r\n `status` smallint(6) NOT NULL,\r\r\n PRIMARY KEY (`id`),\r\r\n UNIQUE KEY `rid` (`rid`),\r\r\n KEY `object_id` (`object_id`)\r\r\n ) ENGINE=MyISAM {$charset_collate}"; $wpdb->query($sql); if ($e = mysql_error()) { throw new Exception($e); } } /* string translation - start */ $icl_translation_sql = "\r\r\n CREATE TABLE IF NOT EXISTS {$wpdb->prefix}icl_core_status (\r\r\n `id` BIGINT NOT NULL auto_increment,\r\r\n `rid` BIGINT NOT NULL,\r\r\n `module` VARCHAR( 16 ) NOT NULL ,\r\r\n `origin` VARCHAR( 64 ) NOT NULL ,\r\r\n `target` VARCHAR( 64 ) NOT NULL ,\r\r\n `status` SMALLINT NOT NULL,\r\r\n PRIMARY KEY ( `id` ) ,\r\r\n INDEX ( `rid` )\r\r\n ) ENGINE=MyISAM {$charset_collate}\r\r\n "; $wpdb->query($icl_translation_sql); if ($e = mysql_error()) { throw new Exception($e); } $icl_translation_sql = "\r\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_content_status` (\r\r\n `rid` BIGINT NOT NULL ,\r\r\n `nid` BIGINT NOT NULL ,\r\r\n `timestamp` DATETIME NOT NULL ,\r\r\n `md5` VARCHAR( 32 ) NOT NULL ,\r\r\n PRIMARY KEY ( `rid` ) ,\r\r\n INDEX ( `nid` )\r\r\n ) ENGINE=MyISAM {$charset_collate} \r\r\n "; mysql_query($icl_translation_sql); $wpdb->query($icl_translation_sql); if ($e = mysql_error()) { throw new Exception($e); } $icl_translation_sql = "\r\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_node` (\r\r\n `nid` BIGINT NOT NULL ,\r\r\n `md5` VARCHAR( 32 ) NOT NULL ,\r\r\n `links_fixed` TINYINT NOT NULL DEFAULT 0,\r\r\n PRIMARY KEY ( `nid` )\r\r\n ) ENGINE=MyISAM {$charset_collate} \r\r\n "; $wpdb->query($icl_translation_sql); if ($e = mysql_error()) { throw new Exception($e); } $icl_translation_sql = "\r\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_reminders` (\r\r\n `id` BIGINT NOT NULL ,\r\r\n `message` TEXT NOT NULL ,\r\r\n `url` TEXT NOT NULL ,\r\r\n `can_delete` TINYINT NOT NULL ,\r\r\n `show` TINYINT NOT NULL ,\r\r\n PRIMARY KEY ( `id` )\r\r\n ) ENGINE=MyISAM {$charset_collate} \r\r\n "; $wpdb->query($icl_translation_sql); if ($e = mysql_error()) { throw new Exception($e); } } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_ERROR); exit; } if (get_option('icl_sitepress_version')) { icl_plugin_upgrade(); } // 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; update_option('icl_sitepress_settings', $iclsettings); } }
function icl_sitepress_activate() { global $wpdb; $langs_names = icl_get_languages_names(); $lang_codes = icl_get_languages_codes(); $lang_locales = icl_get_languages_locales(); $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 { // languages table $table_name = $wpdb->prefix . 'icl_languages'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `code` VARCHAR( 7 ) NOT NULL ,\n `english_name` VARCHAR( 128 ) NOT NULL , \n `major` TINYINT NOT NULL DEFAULT '0', \n `active` TINYINT NOT NULL ,\n `default_locale` VARCHAR( 8 ),\n `tag` VARCHAR( 8 ),\n `encode_url` TINYINT( 1 ) NOT NULL DEFAULT 0,\n UNIQUE KEY `code` (`code`),\n UNIQUE KEY `english_name` (`english_name`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } foreach ($langs_names as $key => $val) { if (strpos($key, 'Norwegian Bokm') === 0) { $key = 'Norwegian Bokmål'; $lang_codes[$key] = 'nb'; } // exception for norwegian $default_locale = isset($lang_locales[$lang_codes[$key]]) ? $lang_locales[$lang_codes[$key]] : ''; $wpdb->insert($wpdb->prefix . 'icl_languages', array('english_name' => $key, 'code' => $lang_codes[$key], 'major' => $val['major'], 'active' => 0, 'default_locale' => $default_locale, 'tag' => str_replace('_', '-', $default_locale))); } } // languages translations table $add_languages_translations = false; $table_name = $wpdb->prefix . 'icl_languages_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` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `language_code` VARCHAR( 7 ) NOT NULL ,\n `display_language_code` VARCHAR( 7 ) NOT NULL , \n `name` VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL,\n UNIQUE(`language_code`, `display_language_code`) \n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } $add_languages_translations = true; } if ($add_languages_translations) { $languages_translation_sql = file_get_contents(ICL_PLUGIN_PATH . "/res/table-icl_languages_translation.sql"); $languages_translation_sql = sprintf($languages_translation_sql, $table_name); if ($wpdb->query($languages_translation_sql) === false) { throw new Exception($wpdb->last_error); } } // 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 \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 `translation_package` text 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( 128 ) 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); } } // 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( 8 ) NOT NULL ,\n UNIQUE (`code` ,`locale`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } // flags table $table_name = $wpdb->prefix . 'icl_flags'; if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n `lang_code` VARCHAR( 10 ) NOT NULL ,\n `flag` VARCHAR( 32 ) NOT NULL ,\n `from_template` TINYINT NOT NULL DEFAULT '0',\n UNIQUE (`lang_code`)\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } $codes = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages"); foreach ($codes as $code) { if (!$code || $wpdb->get_var("SELECT lang_code FROM {$wpdb->prefix}icl_flags WHERE lang_code='{$code}'")) { continue; } if (!file_exists(ICL_PLUGIN_PATH . '/res/flags/' . $code . '.png')) { $file = 'nil.png'; } else { $file = $code . '.png'; } $wpdb->insert($wpdb->prefix . 'icl_flags', array('lang_code' => $code, 'flag' => $file, 'from_template' => 0)); } } /* 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(160) NOT NULL,\n `name` varchar(160) NOT NULL,\n `value` text NOT NULL,\n `status` TINYINT NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `context_name` (`context`,`name`),\n KEY `language_context` (`language`, `context`)\n ) {$charset_collate}"; 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_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; } if (get_option('icl_sitepress_version')) { icl_plugin_upgrade(); } // 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(); }