function __construct() { $this->allowed_flag_mime_types = array('gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'svg' => 'image/svg+xml'); wp_enqueue_script('edit-languages', ICL_PLUGIN_URL . '/res/js/languages/edit-languages.js', array('jquery', 'sitepress-scripts'), ICL_SITEPRESS_VERSION, true); $this->max_file_size = 100000; $lang_codes = icl_get_languages_codes(); $this->built_in_languages = array_values($lang_codes); if ($this->is_delete_language_action()) { $lang_id = (int) $_GET['id']; $this->delete_language($lang_id); } // Set upload dir $wp_upload_dir = wp_upload_dir(); $this->upload_dir = $wp_upload_dir['basedir'] . '/flags'; if (!is_dir($this->upload_dir)) { $this->is_writable = is_writable($wp_upload_dir['basedir']); if ($this->is_writable) { try { mkdir($this->upload_dir); } catch (Exception $ex) { $this->set_errors(__('Upload directory cannot be created. Check your permissions.', 'sitepress')); } } else { $this->set_errors(__('Upload dir is not writable', 'sitepress')); } } $this->is_writable = is_writable($this->upload_dir); $this->migrate(); $this->get_active_languages(); // Trigger save. if (isset($_POST['icl_edit_languages_action']) && $_POST['icl_edit_languages_action'] === 'update') { if (wp_verify_nonce($_POST['_wpnonce'], 'icl_edit_languages')) { $this->update(); } } }
function __construct() { $this->allowed_flag_mime_types = array('gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'svg' => 'image/svg+xml'); wp_enqueue_script('edit-languages', ICL_PLUGIN_URL . '/res/js/languages/edit-languages.js', array('jquery', 'sitepress-scripts'), ICL_SITEPRESS_VERSION, true); $this->max_file_size = 100000; $lang_codes = icl_get_languages_codes(); $this->built_in_languages = array_values($lang_codes); if (isset($_GET['action']) && $_GET['action'] == 'delete-language' && wp_create_nonce('delete-language' . (int) $_GET['id']) == $_GET['icl_nonce']) { $lang_id = (int) $_GET['id']; $this->delete_language($lang_id); } // Set upload dir $wp_upload_dir = wp_upload_dir(); $this->upload_dir = $wp_upload_dir['basedir'] . '/flags'; if (!is_dir($this->upload_dir)) { $this->is_writable = is_writable($wp_upload_dir['basedir']); if ($this->is_writable) { try { mkdir($this->upload_dir); } catch (Exception $ex) { $this->error(__('Upload directory cannot be created. Check your permissions.', 'sitepress')); } } else { $this->error(__('Upload dir is not writable', 'sitepress')); } } $this->is_writable = is_writable($this->upload_dir); $this->migrate(); $this->get_active_languages(); // Trigger save. if (isset($_POST['icl_edit_languages_action']) && $_POST['icl_edit_languages_action'] == 'update') { if (wp_verify_nonce($_POST['_wpnonce'], 'icl_edit_languages')) { $this->update(); } } ?> <div class="wrap"> <div id="icon-wpml" class="icon32"><br /></div> <h2><?php _e('Edit Languages', 'sitepress'); ?> </h2> <div id="icl_edit_languages_info"> <?php _e('This table allows you to edit languages for your site. Each row represents a language. <br /><br /> For each language, you need to enter the following information: <ul> <li><strong>Code:</strong> a unique value that identifies the language. Once entered, the language code cannot be changed.</li> <li><strong>Translations:</strong> the way the language name will be displayed in different languages.</li> <li><strong>Flag:</strong> the flag to display next to the language (optional). You can either upload your own flag or use one of WPML\'s built in flag images.</li> <li><strong>Default locale:</strong> This determines the locale value for this language. You should check the name of WordPress localization file to set this correctly.</li> </ul>', 'sitepress'); ?> </div> <?php if ($this->error) { echo ' <div class="below-h2 error"><p>' . $this->error . '</p></div>'; } if ($this->message) { echo ' <div class="below-h2 updated"><p>' . $this->message . '</p></div>'; } ?> <br /> <?php $this->edit_table(); ?> <div class="icl_error_text icl_edit_languages_show" style="display: none; margin:10px;"><p><?php _e('Please note: language codes cannot be changed after adding languages. Make sure you enter the correct code.', 'sitepress'); ?> </p></div> </div> <?php }
if (!isset($_POST['icl_remember_language']) || $_POST['icl_remember_language'] < 24) { $_POST['icl_remember_language'] = 24; } $iclsettings['automatic_redirect'] = @intval($_POST['icl_automatic_redirect']); $iclsettings['remember_language'] = @intval($_POST['icl_remember_language']); $this->save_settings($iclsettings); echo '1|'; break; case 'icl_troubleshooting_more_options': $iclsettings['troubleshooting_options'] = $_POST['troubleshooting_options']; $this->save_settings($iclsettings); echo '1|'; break; case 'reset_languages': $langs_names = icl_get_languages_names(); $lang_codes = icl_get_languages_codes(); $lang_locales = icl_get_languages_locales(); $active = $wpdb->get_col("SELECT code FROM {$wpdb->prefix}icl_languages WHERE active = 1"); $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_languages`"); // @since 3.1.5 - mysql_* function deprecated in php 5.5+ $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_languages_translations`"); $wpdb->query("TRUNCATE TABLE `{$wpdb->prefix}icl_flags`"); 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)); }
function __construct() { $langs_names = icl_get_languages_names(); $lang_codes = icl_get_languages_codes(); $lang_locales = icl_get_languages_locales(); $this->built_in_languages = array_values($lang_codes); if (isset($_GET['action']) && $_GET['action'] == 'delete-language' && wp_create_nonce('delete-language' . @intval($_GET['id'])) == $_GET['icl_nonce']) { $lang_id = @intval($_GET['id']); $this->delete_language($lang_id); } // Set upload dir $wp_upload_dir = wp_upload_dir(); $this->upload_dir = $wp_upload_dir['basedir'] . '/flags'; if (!is_dir($this->upload_dir)) { if (!mkdir($this->upload_dir)) { $this->error(__('Upload directory cannot be created. Check your permissions.', 'sitepress')); } } if (!($this->is_writable = is_writable($this->upload_dir))) { $this->error(__('Upload dir is not writable', 'sitepress')); } $this->migrate(); $this->get_active_languages(); // Trigger save. if (isset($_POST['icl_edit_languages_action']) && $_POST['icl_edit_languages_action'] == 'update') { if (wp_verify_nonce($_POST['_wpnonce'], 'icl_edit_languages')) { $this->update(); } } add_action('admin_footer', array(&$this, 'scripts')); ?> <div class="wrap"> <div id="icon-wpml" class="icon32"><br /></div> <h2><?php _e('Edit Languages', 'sitepress'); ?> </h2> <div id="icl_edit_languages_info"> <?php _e('This table allows you to edit languages for your site. Each row represents a language. <br /><br /> For each language, you need to enter the following information: <ul> <li><strong>Code:</strong> a unique value that identifies the language. Once entered, the language code cannot be changed.</li> <li><strong>Translations:</strong> the way the language name will be displayed in different languages.</li> <li><strong>Flag:</strong> the flag to display next to the language (optional). You can either upload your own flag or use one of WPML\'s built in flag images.</li> <li><strong>Default locale:</strong> This determines the locale value for this language. You should check the name of WordPress localization file to set this correctly.</li> </ul>', 'sitepress'); ?> </div> <?php if ($this->error) { echo ' <div class="below-h2 error"><p>' . $this->error . '</p></div>'; } if ($this->message) { echo ' <div class="below-h2 updated"><p>' . $this->message . '</p></div>'; } ?> <br /> <?php $this->edit_table(); ?> <div class="icl_error_text icl_edit_languages_show" style="display: none; margin:10px;"><p><?php _e('Please note: language codes cannot be changed after adding languages. Make sure you enter the correct code.', 'sitepress'); ?> </p></div> </div> <?php }
static function fill_languages_translations() { global $wpdb; $languages_codes = icl_get_languages_codes(); $table_name = $wpdb->prefix . 'icl_languages_translations'; if (!self::create_languages_translations()) { return false; } if (!self::languages_table_is_complete()) { //First truncate the table $wpdb->hide_errors(); $sql = "TRUNCATE " . $table_name; $truncate_result = $wpdb->query($sql); $wpdb->show_errors(); if (false !== $truncate_result) { $index = 1; $insert_sql_parts = array(); $languages = self::get_languages_names(); if ($languages) { foreach ($languages as $lang => $val) { if (strpos($lang, 'Norwegian Bokm') === 0) { $lang = 'Norwegian Bokmål'; $languages_codes[$lang] = 'nb'; } foreach ($val['tr'] as $k => $display) { if (strpos($k, 'Norwegian Bokm') === 0) { $k = 'Norwegian Bokmål'; } if (!trim($display)) { $display = $lang; } $inserts_language_data = array('id' => $index, 'language_code' => $languages_codes[$lang], 'display_language_code' => $languages_codes[$k], 'name' => $display); $insert_sql_parts[] = $wpdb->prepare('(%d, %s, %s, %s)', $inserts_language_data); $index++; } } $insert_sql = implode(",\n", $insert_sql_parts); $insert_sql = "INSERT INTO {$table_name} (id, language_code, display_language_code, name) VALUES " . $insert_sql; if ($wpdb->query($insert_sql) === false) { return false; } } } } return true; }
static function fill_languages_translations() { global $wpdb; $languages_codes = icl_get_languages_codes(); $table_name = $wpdb->prefix . 'icl_languages_translations'; if (!self::create_languages_translations()) { return false; } if (!self::languages_table_is_complete()) { //First truncate the table $wpdb->hide_errors(); $sql = "TRUNCATE " . $table_name; $truncate_result = $wpdb->query($sql); $wpdb->show_errors(); if ($truncate_result) { $languages_names = self::get_languages_names(); foreach ($languages_names as $lang => $val) { if (strpos($lang, 'Norwegian Bokm') === 0) { $lang = 'Norwegian Bokmål'; $languages_codes[$lang] = 'nb'; } foreach ($val['tr'] as $k => $display) { if (strpos($k, 'Norwegian Bokm') === 0) { $k = 'Norwegian Bokmål'; } if (!trim($display)) { $display = $lang; } $sql = $wpdb->prepare("SELECT id FROM {$table_name} WHERE language_code=%s AND display_language_code=%s", array($languages_codes[$lang], $languages_codes[$k])); if (!$wpdb->get_var($sql)) { $args = array('language_code' => $languages_codes[$lang], 'display_language_code' => $languages_codes[$k], 'name' => $display); if ($wpdb->insert($wpdb->prefix . 'icl_languages_translations', $args) === false) { return false; } } } } } } return true; }
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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `code` VARCHAR( 7 ) NOT NULL ,\r\n `english_name` VARCHAR( 128 ) NOT NULL , \r\n `major` TINYINT NOT NULL DEFAULT '0', \r\n `active` TINYINT NOT NULL ,\r\n `default_locale` VARCHAR( 8 ),\r\n `tag` VARCHAR( 8 ),\r\n `encode_url` TINYINT( 1 ) NOT NULL DEFAULT 0,\r\n UNIQUE KEY `code` (`code`),\r\n UNIQUE KEY `english_name` (`english_name`)\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `language_code` VARCHAR( 7 ) NOT NULL ,\r\n `display_language_code` VARCHAR( 7 ) NOT NULL , \r\n `name` VARCHAR( 255 ) CHARACTER SET utf8 NOT NULL,\r\n UNIQUE(`language_code`, `display_language_code`) \r\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } $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 (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) { $sql = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `translation_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `element_type` VARCHAR( 36 ) NOT NULL DEFAULT 'post_post',\r\n `element_id` BIGINT NULL DEFAULT NULL ,\r\n `trid` BIGINT NOT NULL ,\r\n `language_code` VARCHAR( 7 ) NOT NULL,\r\n `source_language_code` VARCHAR( 7 ),\r\n UNIQUE KEY `el_type_id` (`element_type`,`element_id`),\r\n UNIQUE KEY `trid_lang` (`trid`,`language_code`),\r\n KEY `trid` (`trid`)\r\n \r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `rid` bigint(20) NOT NULL AUTO_INCREMENT,\r\n `translation_id` bigint(20) NOT NULL,\r\n `status` tinyint(4) NOT NULL,\r\n `translator_id` bigint(20) NOT NULL,\r\n `needs_update` tinyint(4) NOT NULL,\r\n `md5` varchar(32) NOT NULL,\r\n `translation_service` varchar(16) NOT NULL,\r\n `translation_package` text NOT NULL,\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n `links_fixed` tinyint(4) NOT NULL DEFAULT 0,\r\n `_prevstate` longtext,\r\n PRIMARY KEY (`rid`),\r\n UNIQUE KEY `translation_id` (`translation_id`)\r\n ) {$charset_collate} \r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `job_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `rid` BIGINT UNSIGNED NOT NULL ,\r\n `translator_id` INT UNSIGNED NOT NULL ,\r\n `translated` TINYINT UNSIGNED NOT NULL DEFAULT 0,\r\n `manager_id` INT UNSIGNED NOT NULL ,\r\n `revision` INT UNSIGNED NULL,\r\n INDEX ( `rid` , `translator_id` )\r\n ) {$charset_collate} \r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `tid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `job_id` BIGINT UNSIGNED NOT NULL ,\r\n `content_id` BIGINT UNSIGNED NOT NULL ,\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\r\n `field_type` VARCHAR( 128 ) NOT NULL ,\r\n `field_format` VARCHAR( 16 ) NOT NULL ,\r\n `field_translate` TINYINT NOT NULL ,\r\n `field_data` longtext NOT NULL ,\r\n `field_data_translated` longtext NOT NULL ,\r\n `field_finished` TINYINT NOT NULL DEFAULT 0,\r\n INDEX ( `job_id` )\r\n ) {$charset_collate}\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `code` VARCHAR( 7 ) NOT NULL ,\r\n `locale` VARCHAR( 8 ) NOT NULL ,\r\n UNIQUE (`code` ,`locale`)\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `lang_code` VARCHAR( 10 ) NOT NULL ,\r\n `flag` VARCHAR( 32 ) NOT NULL ,\r\n `from_template` TINYINT NOT NULL DEFAULT '0',\r\n UNIQUE (`lang_code`)\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\n `language` varchar(7) NOT NULL,\r\n `context` varchar(160) NOT NULL,\r\n `name` varchar(160) NOT NULL,\r\n `value` text NOT NULL,\r\n `status` TINYINT NOT NULL,\r\n PRIMARY KEY (`id`),\r\n UNIQUE KEY `context_name` (`context`,`name`),\r\n KEY `language_context` (`language`, `context`)\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\n `string_id` bigint(20) unsigned NOT NULL,\r\n `language` varchar(10) NOT NULL,\r\n `status` tinyint(4) NOT NULL,\r\n `value` text NULL DEFAULT NULL, \r\n `translator_id` bigint(20) unsigned DEFAULT NULL, \r\n `translation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n PRIMARY KEY (`id`),\r\n UNIQUE KEY `string_language` (`string_id`,`language`)\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `rid` BIGINT NOT NULL ,\r\n `string_translation_id` BIGINT NOT NULL ,\r\n `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,\r\n `md5` VARCHAR( 32 ) NOT NULL,\r\n INDEX ( `string_translation_id` )\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r\n `string_id` BIGINT NOT NULL ,\r\n `kind` TINYINT,\r\n `position_in_page` VARCHAR( 255 ) NOT NULL,\r\n INDEX ( `string_id` )\r\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 = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` bigint(20) unsigned NOT NULL auto_increment,\r\n `rid` bigint(20) unsigned NOT NULL,\r\n `object_id` bigint(20) unsigned NOT NULL,\r\n `from_language` varchar(10) NOT NULL,\r\n `to_language` varchar(10) NOT NULL,\r\n `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,\r\n `md5` varchar(32) NOT NULL,\r\n `object_type` varchar(64) NOT NULL,\r\n `status` smallint(6) NOT NULL,\r\n PRIMARY KEY (`id`),\r\n UNIQUE KEY `rid` (`rid`),\r\n KEY `object_id` (`object_id`)\r\n ) {$charset_collate}"; if ($wpdb->query($sql) === false) { throw new Exception($wpdb->last_error); } } /* string translation - start */ $icl_translation_sql = "\r\n CREATE TABLE IF NOT EXISTS {$wpdb->prefix}icl_core_status (\r\n `id` BIGINT NOT NULL auto_increment,\r\n `rid` BIGINT NOT NULL,\r\n `module` VARCHAR( 16 ) NOT NULL ,\r\n `origin` VARCHAR( 64 ) NOT NULL ,\r\n `target` VARCHAR( 64 ) NOT NULL ,\r\n `status` SMALLINT NOT NULL,\r\n PRIMARY KEY ( `id` ) ,\r\n INDEX ( `rid` )\r\n ) {$charset_collate}\r\n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_content_status` (\r\n `rid` BIGINT NOT NULL ,\r\n `nid` BIGINT NOT NULL ,\r\n `timestamp` DATETIME NOT NULL ,\r\n `md5` VARCHAR( 32 ) NOT NULL ,\r\n PRIMARY KEY ( `rid` ) ,\r\n INDEX ( `nid` )\r\n ) {$charset_collate} \r\n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_node` (\r\n `nid` BIGINT NOT NULL ,\r\n `md5` VARCHAR( 32 ) NOT NULL ,\r\n `links_fixed` TINYINT NOT NULL DEFAULT 0,\r\n PRIMARY KEY ( `nid` )\r\n ) {$charset_collate} \r\n "; if ($wpdb->query($icl_translation_sql) === false) { throw new Exception($wpdb->last_error); } $icl_translation_sql = "\r\n CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}icl_reminders` (\r\n `id` BIGINT NOT NULL ,\r\n `message` TEXT NOT NULL ,\r\n `url` TEXT NOT NULL ,\r\n `can_delete` TINYINT NOT NULL ,\r\n `show` TINYINT NOT NULL ,\r\n PRIMARY KEY ( `id` )\r\n ) {$charset_collate} \r\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(); }