本文整理汇总了PHP中icl_sitepress_activate函数的典型用法代码示例。如果您正苦于以下问题:PHP icl_sitepress_activate函数的具体用法?PHP icl_sitepress_activate怎么用?PHP icl_sitepress_activate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了icl_sitepress_activate函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_essential_globals
/**
* Loads global variables providing functionality that is used throughout the plugin.
*
* @global $wpml_language_resolution
* @global $wpml_slug_filter
* @global WPML_Term_Translation $wpml_term_translations
*/
function load_essential_globals()
{
global $wpml_language_resolution, $wpml_term_translations;
$wpml_languages = array();
$settings = get_option('icl_sitepress_settings');
if ((bool) $settings === false) {
icl_sitepress_activate();
}
$active_language_codes = isset($settings['active_languages']) ? $settings['active_languages'] : array();
$active_language_codes = (bool) $active_language_codes === true ? $active_language_codes : wpml_reload_active_languages_setting();
$wpml_languages['active_languages'] = $active_language_codes;
$default_lang_code = isset($settings['default_language']) ? $settings['default_language'] : false;
$wpml_language_resolution = new WPML_Language_Resolution($active_language_codes, $default_lang_code);
$admin = is_admin();
wpml_load_post_translation($admin, $settings, $active_language_codes, $default_lang_code);
$wpml_term_translations = new WPML_Term_Translation();
$domain_validation = filter_input(INPUT_GET, '____icl_validate_domain') ? 1 : false;
$domain_validation = filter_input(INPUT_GET, '____icl_validate_directory') ? 2 : $domain_validation;
$url_converter = load_wpml_url_converter($settings, $domain_validation, $default_lang_code);
if ($domain_validation) {
echo wpml_validate_host($_SERVER['REQUEST_URI'], $url_converter, $domain_validation === 2);
exit;
}
wpml_load_request_handler($admin, $active_language_codes, $default_lang_code);
if ($admin) {
wpml_load_admin_files();
}
}
示例2: icl_wpmu_new_blog
function icl_wpmu_new_blog($blog_id){
$wpmu_sitewide_plugins = (array) maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );
if(isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER.'/'.basename(__FILE__)])){
require ICL_PLUGIN_PATH . '/inc/sitepress-schema.php';
switch_to_blog($blog_id);
icl_sitepress_activate();
restore_current_blog();
remove_action('admin_footer', 'icl_display_errors_stack');
}
}
示例3: load_essential_globals
/**
* Loads global variables providing functionality that is used throughout the plugin.
*
* @global $wpml_language_resolution
* @global $wpml_slug_filter
* @global WPML_Term_Translation $wpml_term_translations
*/
function load_essential_globals()
{
global $wpml_language_resolution, $wpml_term_translations, $wpdb;
$wpml_languages = array();
$settings = get_option('icl_sitepress_settings');
if ((bool) $settings === false) {
icl_sitepress_activate();
} else {
if (isset($settings['setup_complete']) && $settings['setup_complete']) {
$active_plugins = get_option('active_plugins');
$wpmu_sitewide_plugins = (array) maybe_unserialize(get_site_option('active_sitewide_plugins'));
if (in_array(trailingslashit(ICL_PLUGIN_FOLDER) . 'sitepress.php', $active_plugins, true) === false && in_array(trailingslashit(ICL_PLUGIN_FOLDER) . 'sitepress.php', array_keys($wpmu_sitewide_plugins), true) === false) {
// The plugin has just be reactivated.
// reset ajx_health_flag
// set the just_reactivated flag so any posts created while
// WPML was not activate will get the default language
// https://onthegosystems.myjetbrains.com/youtrack/issue/wpmlcore-1924
$settings['ajx_health_checked'] = 0;
$settings['just_reactivated'] = 1;
update_option('icl_sitepress_settings', $settings);
}
}
}
$active_language_codes = isset($settings['active_languages']) ? $settings['active_languages'] : array();
$active_language_codes = (bool) $active_language_codes === true ? $active_language_codes : wpml_reload_active_languages_setting();
$wpml_languages['active_languages'] = $active_language_codes;
$default_lang_code = isset($settings['default_language']) ? $settings['default_language'] : false;
$wpml_language_resolution = new WPML_Language_Resolution($active_language_codes, $default_lang_code);
$admin = is_admin();
wpml_load_post_translation($admin, $settings);
$wpml_term_translations = new WPML_Term_Translation($wpdb);
$domain_validation = filter_input(INPUT_GET, '____icl_validate_domain') ? 1 : false;
$domain_validation = filter_input(INPUT_GET, '____icl_validate_directory') ? 2 : $domain_validation;
$url_converter = load_wpml_url_converter($settings, $domain_validation, $default_lang_code);
if ($domain_validation) {
echo wpml_validate_host($_SERVER['REQUEST_URI'], $url_converter, $domain_validation === 2);
exit;
}
if ($admin) {
wpml_load_admin_files();
}
}
示例4: define
define('ICL_ICON16', ICL_PLUGIN_URL . '/res/img/icon16.png');
if (defined('WP_ADMIN')) {
require ICL_PLUGIN_PATH . '/inc/php-version-check.php';
if (defined('PHP_VERSION_INCOMPATIBLE')) {
return;
}
}
require ICL_PLUGIN_PATH . '/inc/not-compatible-plugins.php';
if (!empty($icl_ncp_plugins)) {
return;
}
if (function_exists('is_multisite') && is_multisite()) {
$wpmu_sitewide_plugins = (array) maybe_unserialize(get_site_option('active_sitewide_plugins'));
if (false === get_option('icl_sitepress_version', false) && isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/' . basename(__FILE__)])) {
require_once ICL_PLUGIN_PATH . '/inc/sitepress-schema.php';
icl_sitepress_activate();
}
include_once ICL_PLUGIN_PATH . '/inc/functions-network.php';
if (get_option('_wpml_inactive', false) && isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) {
define('ICL_PLUGIN_INACTIVE', true);
return;
}
}
require ICL_PLUGIN_PATH . '/inc/constants.php';
require ICL_PLUGIN_PATH . '/inc/icl-admin-notifier.php';
require_once ICL_PLUGIN_PATH . '/inc/wpml-translation-tree.class.php';
require_once ICL_PLUGIN_PATH . '/inc/wpml-term-translations.class.php';
require_once ICL_PLUGIN_PATH . '/inc/wpml-post-edit-ajax.class.php';
require_once ICL_PLUGIN_PATH . '/inc/functions-troubleshooting.php';
require_once ICL_PLUGIN_PATH . '/menu/wpml-troubleshooting-terms-menu.class.php';
require_once ICL_PLUGIN_PATH . '/inc/sitepress-schema.php';
示例5: icl_upgrade_2_0_0_steps
function icl_upgrade_2_0_0_steps($step, $stepper)
{
global $wpdb, $sitepress, $wp_post_types, $sitepress_settings;
if (!isset($sitepress)) {
$sitepress = new SitePress();
}
$TranslationManagement = new TranslationManagement();
$default_language = $sitepress->get_default_language();
define('ICL_TM_DISABLE_ALL_NOTIFICATIONS', true);
// make sure no notifications are being sent
//if(defined('icl_upgrade_2_0_0_runonce')){
// return;
//}
//define('icl_upgrade_2_0_0_runonce', true);
// fix source_language_code
// assume that the lowest element_id is the source language
ini_set('max_execution_time', 300);
$post_types = array_keys($wp_post_types);
foreach ($post_types as $pt) {
$types[] = 'post_' . $pt;
}
$temp_upgrade_data = get_option('icl_temp_upgrade_data', array('step' => 0, 'offset' => 0));
switch ($step) {
case 1:
// if the tables are missing, call the plugin activation routine
$table_name = $wpdb->prefix . 'icl_translation_status';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
icl_sitepress_activate();
}
$wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_type` `element_type` VARCHAR( 32 ) NOT NULL DEFAULT 'post_post'");
$wpdb->query("ALTER TABLE `{$wpdb->prefix}icl_translations` CHANGE `element_id` `element_id` BIGINT( 20 ) NULL DEFAULT NULL ");
// fix source_language_code
// all source documents must have null
if (isset($types)) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = NULL\n\t\t\t\t\tWHERE element_type IN('" . join("','", $types) . "') AND source_language_code = '' AND language_code=%s", $default_language));
// get translated documents with missing source language
$res = $wpdb->get_results($wpdb->prepare("\n\t\t\t\t\tSELECT translation_id, trid, language_code\n\t\t\t\t\tFROM {$wpdb->prefix}icl_translations\n\t\t\t\t\tWHERE (source_language_code = '' OR source_language_code IS NULL)\n\t\t\t\t\t\tAND element_type IN('" . join("','", $types) . "')\n\t\t\t\t\t\tAND language_code <> %s\n\t\t\t\t\t\t", $default_language));
foreach ($res as $row) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}icl_translations SET source_language_code = %s WHERE translation_id=%d", $default_language, $row->translation_id));
}
}
$temp_upgrade_data['step'] = 2;
update_option('icl_temp_upgrade_data', $temp_upgrade_data);
return array('message' => __('Processing translations...', 'sitepress'));
break;
case 2:
$limit = 100;
$offset = $temp_upgrade_data['offset'];
$processing = FALSE;
//loop existing translations
if (isset($types)) {
$res = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}icl_translations\n WHERE element_type IN(" . wpml_prepare_in($types) . " )\n AND source_language_code IS NULL LIMIT %d OFFSET %d", array($limit, $offset)));
foreach ($res as $row) {
$processing = TRUE;
// grab translations
$translations = $sitepress->get_element_translations($row->trid, $row->element_type);
$md5 = 0;
$table_name = $wpdb->prefix . 'icl_node';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") == $table_name) {
list($md5, $links_fixed) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\tSELECT md5, links_fixed FROM {$wpdb->prefix}icl_node\n\t\t\t\t\t\t\tWHERE nid = %d\n\t\t\t\t\t\t", $row->element_id), ARRAY_N);
}
if (!$md5) {
$md5 = $TranslationManagement->post_md5($row->element_id);
}
$translation_package = $TranslationManagement->create_translation_package($row->element_id);
foreach ($translations as $lang => $t) {
if (!$t->original) {
// determine service and status
$service = 'local';
$needs_update = 0;
list($rid, $status, $current_md5) = $wpdb->get_row($wpdb->prepare("\n\t\t\t\t\t\t\t\tSELECT c.rid, n.status , c.md5\n\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_content_status c\n\t\t\t\t\t\t\t\t\tJOIN {$wpdb->prefix}icl_core_status n ON c.rid = n.rid\n\t\t\t\t\t\t\t\tWHERE c.nid = %d AND target = %s\n\t\t\t\t\t\t\t\tORDER BY rid DESC\n\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t", $row->element_id, $lang), ARRAY_N);
$translator_id = false;
if ($rid) {
if ($current_md5 != $md5) {
$needs_update = 1;
}
if ($status == 3) {
$status = 10;
} else {
$status = 2;
}
$service = 'icanlocalize';
foreach ($sitepress_settings['icl_lang_status'] as $lpair) {
if ($lpair['from'] == $row->language_code && $lpair['to'] == $lang && isset($lpair['translators'][0]['id'])) {
$translator_id = $lpair['translators'][0]['id'];
break;
}
}
} else {
$status = 10;
$translator_id = $wpdb->get_var($wpdb->prepare("SELECT post_author FROM {$wpdb->posts} WHERE ID=%d", $t->element_id));
$tlp = get_user_meta($translator_id, $wpdb->prefix . 'language_pairs', true);
$tlp[$row->language_code][$lang] = 1;
$TranslationManagement->edit_translator($translator_id, $tlp);
}
// add translation_status record
list($newrid) = $TranslationManagement->update_translation_status(array('translation_id' => $t->translation_id, 'status' => $status, 'translator_id' => $translator_id, 'needs_update' => $needs_update, 'md5' => $md5, 'translation_service' => $service, 'translation_package' => serialize($translation_package), 'links_fixed' => intval(isset($links_fixed) ? $links_fixed : 0)));
$job_id = $TranslationManagement->add_translation_job($newrid, $translator_id, $translation_package);
if ($job_id && $status == 10) {
$post = get_post($t->element_id);
//.........这里部分代码省略.........
示例6: icl_plugin_upgrade
//.........这里部分代码省略.........
if (!isset($comment_translations[$row->comment_ID]['language_code'])) {
$nexttrid = 1 + $wpdb->get_var("SELECT MAX(trid) FROM {$wpdb->prefix}icl_translations");
$wpdb->insert($wpdb->prefix . 'icl_translations', array('element_type' => 'comment', 'element_id' => $row->comment_ID, 'trid' => $nexttrid, 'language_code' => $iclsettings['default_language']));
}
}
break;
}
}
if ($mig_debug) {
fwrite($mig_debug, "Upgraded to 1.4.0.1 \n");
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.5.0', '<')) {
if ($mig_debug) {
fwrite($mig_debug, "Upgrading to 1.5.0 \n");
}
if (!isset($iclsettings['icl_lang_sel_config'])) {
$iclsettings['icl_lang_sel_config'] = array('font-current-normal' => ICL_LANG_SEL_BLUE_FONT_CURRENT_NORMAL, 'font-current-hover' => ICL_LANG_SEL_BLUE_FONT_CURRENT_HOVER, 'background-current-normal' => ICL_LANG_SEL_BLUE_BACKGROUND_CURRENT_NORMAL, 'background-current-hover' => ICL_LANG_SEL_BLUE_BACKGROUND_CURRENT_HOVER, 'font-other-normal' => ICL_LANG_SEL_BLUE_FONT_OTHER_NORMAL, 'font-other-hover' => ICL_LANG_SEL_BLUE_FONT_OTHER_HOVER, 'background-other-normal' => ICL_LANG_SEL_BLUE_BACKGROUND_OTHER_NORMAL, 'background-other-hover' => ICL_LANG_SEL_BLUE_BACKGROUND_OTHER_HOVER, 'border' => ICL_LANG_SEL_BLUE_BORDER);
}
$iclsettings['upgrade_flags']['1.5'] = true;
update_option('icl_sitepress_settings', $iclsettings);
mysql_query("DELETE FROM {$wpdb->prefix}icl_translations WHERE element_type='comment' AND element_id = 0");
if ($mig_debug) {
fwrite($mig_debug, "Upgraded to 1.5.0 \n");
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.6.0', '<')) {
if ($mig_debug) {
fwrite($mig_debug, "Upgrading to 1.6.0 \n");
}
// force icl_string_positions table creation
$table_name = $wpdb->prefix . 'icl_string_positions';
if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") != $table_name) {
icl_sitepress_activate();
}
$iclsettings['st']['track_strings'] = 1;
$iclsettings['st']['hl_color'] = '#FFFF00';
update_option('icl_sitepress_settings', $iclsettings);
if ($mig_debug) {
fwrite($mig_debug, "Upgraded to 1.6.0 \n");
}
}
if (get_option('icl_sitepress_version') && version_compare(get_option('icl_sitepress_version'), '1.7.0', '<')) {
if ($mig_debug) {
fwrite($mig_debug, "Upgrading to 1.7.0 \n");
}
$iclsettings['sync_ping_status'] = 1;
$iclsettings['sync_comment_status'] = 1;
$iclsettings['sync_sticky_flag'] = 1;
$iclsettings['sync_page_template'] = 1;
$iclsettings['auto_adjust_ids'] = 0;
update_option('icl_sitepress_settings', $iclsettings);
// get tags with missing language_code value in icl_translations
$tags = $wpdb->get_col("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE language_code=''");
if (!empty($tags)) {
$res = $wpdb->get_results("\r\n SELECT r.object_id, r.term_taxonomy_id, t.language_code \r\n FROM {$wpdb->term_relationships} r \r\n JOIN {$wpdb->posts} p ON r.object_id = p.ID\r\n JOIN {$wpdb->prefix}icl_translations t ON p.ID = t.element_id AND t.element_type='post'\r\n WHERE term_taxonomy_id IN (" . join(",", $tags) . ")");
foreach ($res as $row) {
$wpdb->update($wpdb->prefix . 'icl_translations', array('language_code' => $row->language_code), array('element_id' => $row->term_taxonomy_id, 'element_type' => 'tag'));
}
}
// set the rest to default language
$wpdb->update($wpdb->prefix . 'icl_translations', array('language_code' => $sitepress_settings['default_language']), array('element_type' => 'tag', 'language_code' => ''));
if ($mig_debug) {
fwrite($mig_debug, "Upgraded to 1.7.0 \n");
}
}