public function set_ls_options()
 {
     $ls_opt_keys = array('icl_lso_link_empty', 'icl_lso_flags', 'icl_lso_native_lang', 'icl_lso_display_lang');
     foreach ($ls_opt_keys as $option_key) {
         if (!isset($this->ls_options[$option_key]) || false === (bool) $this->ls_options[$option_key]) {
             $this->ls_options[$option_key] = 0;
         }
         icl_set_setting($option_key, $this->ls_options[$option_key], true);
     }
 }
Esempio n. 2
0
/**
 * SitePress Template functions
 * @package wpml-core
 */
function wpml_site_uses_icl()
{
    global $wpdb;
    $setting = 'site_does_not_use_icl';
    if (icl_get_setting($setting, false)) {
        return false;
    }
    $cache = new WPML_WP_Cache('wpml-checks');
    $found = false;
    $site_uses_icl = $cache->get('site_uses_icl', $found);
    if (!$found) {
        $site_uses_icl = false;
        $table_exists = $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}icl_translation_status'");
        if ($table_exists) {
            $icl_job_count_query = "SELECT rid\n\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_translation_status\n\t\t\t\t\t\t\tWHERE translation_service = 'icanlocalize'\n\t\t\t\t\t\t\tLIMIT 1;";
            $site_uses_icl = (bool) $wpdb->get_var($icl_job_count_query);
        }
        $cache->set('site_uses_icl', $site_uses_icl);
    }
    if (icl_get_setting('setup_complete', false) && !$site_uses_icl) {
        icl_set_setting($setting, true, true);
    }
    return $site_uses_icl;
}
Esempio n. 3
0
function wpml_reload_active_languages_setting($override = false)
{
    global $wpdb, $sitepress_settings;
    if ((bool) $sitepress_settings === true && ($override || wpml_get_setting_filter(false, 'setup_complete'))) {
        $active_languages = $wpdb->get_col("\tSELECT code\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$wpdb->prefix}icl_languages\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE active = 1");
        $sitepress_settings['active_languages'] = $active_languages;
        icl_set_setting('active_languages', $active_languages, true);
    } else {
        $active_languages = array();
    }
    return (array) $active_languages;
}
Esempio n. 4
0
     icl_set_setting('theme_localization_load_textdomain', $theme_localization_load_td, true);
     $filtered_textdomain_value = filter_input(INPUT_POST, 'textdomain_value');
     icl_set_setting('gettext_theme_domain_name', $filtered_textdomain_value, true);
     if ($theme_localization_type == 1) {
         icl_st_scan_theme_files();
     } elseif ($theme_localization_type == 2) {
         $parent_theme = get_template_directory();
         $child_theme = get_stylesheet_directory();
         $languages_folders = array();
         if ($found_folder = icl_tf_determine_mo_folder($parent_theme)) {
             $languages_folders['parent'] = $found_folder;
         }
         if ($parent_theme != $child_theme && ($found_folder = icl_tf_determine_mo_folder($child_theme))) {
             $languages_folders['child'] = $found_folder;
         }
         icl_set_setting('theme_language_folders', $languages_folders, true);
     }
     echo '1|' . $theme_localization_type;
     break;
 case 'icl_ct_user_pref':
     $users = $wpdb->get_col("SELECT id FROM {$wpdb->users}");
     foreach ($users as $uid) {
         if (isset($_POST['icl_enable_comments_translation'][$uid])) {
             update_user_meta($uid, 'icl_enable_comments_translation', 1);
         } else {
             delete_user_meta($uid, 'icl_enable_comments_translation');
         }
         if (isset($_POST['icl_enable_replies_translation'][$uid])) {
             update_user_meta($uid, 'icl_enable_replies_translation', 1);
         } else {
             delete_user_meta($uid, 'icl_enable_replies_translation');
Esempio n. 5
0
                 }
                 $output .= '<a href="' . $url . '">' . $title . '</a></li>';
             }
             $output .= '</ul>';
             echo '1|' . $output;
         } else {
             echo '0|';
         }
     }
     break;
 case 'icl_show_sidebar':
     icl_set_setting('icl_sidebar_minimized', $_POST['state'] == 'hide' ? 1 : 0);
     icl_save_settings();
     break;
 case 'icl_promote_form':
     icl_set_setting('promote_wpml', @intval($_POST['icl_promote']));
     icl_save_settings();
     echo '1|';
     break;
 case 'save_translator_note':
     update_post_meta($_POST['post_id'], '_icl_translator_note', $_POST['note']);
     break;
 case 'icl_st_track_strings':
     foreach ($_POST['icl_st'] as $k => $v) {
         $iclsettings['st'][$k] = $v;
     }
     if (isset($iclsettings)) {
         $this->save_settings($iclsettings);
     }
     echo 1;
     break;
Esempio n. 6
0
 private function set_initial_default_category($initial_lang)
 {
     global $wpdb;
     $blog_default_cat = get_option('default_category');
     $blog_default_cat_tax_id = $wpdb->get_var($wpdb->prepare("\tSELECT term_taxonomy_id\n\t                FROM {$wpdb->term_taxonomy}\n\t                WHERE term_id=%d\n\t                  AND taxonomy='category'", $blog_default_cat));
     icl_set_setting('default_categories', array($initial_lang => $blog_default_cat_tax_id), true);
 }
Esempio n. 7
0
 /**
  * @param string $key
  * @param mixed  $value
  * @param bool   $save_now	Immediately update the settings record in the DB
  *
  * @since 3.1
  */
 function set_setting($key, $value, $save_now = false)
 {
     icl_set_setting($key, $value, $save_now);
 }
Esempio n. 8
0
        <?php 
} else {
    ?>
            <a href="https://wpml.org/?cat=48"><?php 
    _e('Learn more', 'sitepress');
    ?>
</a>
        <?php 
}
?>
    </p>
    <?php 
if ($upgrade_lines[$short_v]['dismiss']) {
    ?>
        <span title="<?php 
    _e('Stop showing this message', 'sitepress');
    ?>
" id="icl_dismiss_upgrade_notice" class="notice-dismiss"><span class="screen-reader-text"><?php 
    _e('Dismiss', 'sitepress');
    ?>
</span></span>
        <?php 
    wp_nonce_field('dismiss_upgrade_notice_nonce', '_icl_nonce_dun');
} else {
    // set the hide settings so it's shown only one
    icl_set_setting('hide_upgrade_notice', implode('.', array_slice(explode('.', ICL_SITEPRESS_VERSION), 0, 3)));
    icl_save_settings();
}
?>
</div>
 private function set_initial_default_category($initial_lang)
 {
     $blog_default_cat = get_option('default_category');
     $blog_default_cat_tax_id = $this->wpdb->get_var($this->wpdb->prepare("\tSELECT term_taxonomy_id\n\t                FROM {$this->wpdb->term_taxonomy}\n\t                WHERE term_id=%d\n\t                  AND taxonomy='category'", $blog_default_cat));
     if ($initial_lang !== 'en') {
         $this->rename_default_category_of_initial_language($initial_lang, $blog_default_cat);
     }
     icl_set_setting('default_categories', array($initial_lang => $blog_default_cat_tax_id), true);
 }
Esempio n. 10
0
<?php

/**
 * @package wpml-core
 * @used-by Sitepress::ajax_setup
 */
global $wpdb, $sitepress, $sitepress_settings;
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 16 Aug 1980 05:00:00 GMT");
$request = filter_input(INPUT_POST, 'icl_ajx_action', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$request = $request ? $request : filter_input(INPUT_GET, 'icl_ajx_action', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
switch ($request) {
    case 'health_check':
        icl_set_setting('ajx_health_checked', true, true);
        exit;
    case 'get_original_comment':
        $comment_id = filter_input(INPUT_POST, 'comment_id', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
        $trid = $this->get_element_trid($comment_id, 'comment');
        $res = $wpdb->get_row($wpdb->prepare(" SELECT element_id, language_code\n                  FROM {$wpdb->prefix}icl_translations\n                  WHERE trid=%d\n                    AND element_type='comment'\n                    AND element_id <> %d ", $trid, $comment_id));
        $original_cid = $res->element_id;
        $comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->comments}\n                                                                  WHERE comment_ID = %d", $original_cid));
        $comment->language_code = $res->language_code;
        if (isset($IclCommentsTranslation) && $res->language_code == $IclCommentsTranslation->user_language) {
            $comment->translated_version = 1;
        } else {
            $comment->translated_version = 0;
            $comment->anchor_text = __('Back to translated version', 'sitepress');
        }
        echo wp_json_encode($comment);
        exit;
 public function enqueue_migration_in_tp()
 {
     global $sitepress;
     remove_filter('otgs_translation_get_services', 'filter_tp_services');
     $site_id = $sitepress->get_setting('site_id');
     $access_key = $sitepress->get_setting('access_key');
     $delivery = wpml_get_setting_filter(false, 'translation_pickup_method');
     $delivery = $delivery === 'polling' ? 'polling' : 'xmlrpc';
     $service = TranslationProxy_Service::get_service($this->get_icl_service_id());
     $params = array('project' => array('ts_accesskey' => $access_key, 'external_id' => $site_id, 'delivery_method' => $delivery, 'url' => get_option('siteurl'), 'name' => get_option('blogname'), 'description' => get_option('blogdescription'), 'suid' => isset($service->suid) ? $service->suid : ""));
     $project = false;
     $error_data = false;
     try {
         $response = TranslationProxy_Api::proxy_request('/projects/migrate.json', $params, 'POST');
         if (isset($response->project)) {
             $project = (array) $response->project;
             $project_index = $this->icl_project_hash_key();
             $projects = TranslationProxy::get_translation_projects();
             $projects[$project_index] = $project;
             icl_set_setting('icl_translation_projects', $projects, true);
             icl_set_setting('translation_service', TranslationProxy_Service::get_service($this->get_icl_service_id()), true);
         }
     } catch (Exception $e) {
         $error_data = $params;
     }
     if (!$error_data) {
         $this->move_finished_jobs_to_batch();
         if (defined('ICL_DEBUG_MODE') && ICL_DEBUG_MODE) {
             $this->regenerate_wrong_service_data();
         }
     }
     return array($project, $error_data);
 }
function _make_wpml_setup_complete()
{
    icl_set_setting('setup_complete', 1, true);
}