public function init() { global $sitepress; $tax_get = filter_input(INPUT_GET, 'taxonomy'); require ICL_PLUGIN_PATH . '/menu/term-taxonomy-menus/wpml-term-language-filter.class.php'; if (($trid = filter_input(INPUT_GET, 'trid')) && ($source_lang = filter_input(INPUT_GET, 'source_lang')) && get_taxonomy($tax_get) !== false) { $translations = $sitepress->get_element_translations($trid, 'tax_' . $this->taxonomy); if (isset($translations[$_GET['lang']]) && !empty($translations[$_GET['lang']]->term_id)) { wp_redirect(get_edit_term_link($translations[$_GET['lang']]->term_id, $tax_get)); exit; } else { add_action('admin_notices', array($this, '_tax_adding')); } } $term_lang_filter = new WPML_Term_Language_Filter(icl_get_setting('default_language')); if ($this->taxonomy === 'category') { add_action('edit_category_form', array($this, 'wpml_edit_term_form')); } else { add_action('add_tag_form', array($this, 'wpml_edit_term_form')); add_action('edit_tag_form', array($this, 'wpml_edit_term_form')); } add_action('admin_print_scripts-edit-tags.php', array($this, 'js_scripts_tags')); add_filter('wp_dropdown_cats', array($this, 'wp_dropdown_cats_select_parent'), 10, 2); add_action('admin_footer', array($term_lang_filter, 'terms_language_filter')); }
/** * @param string $request_uri * @param string $http_host * * @return array (WPML_Redirection|string)[] containing the actual redirect helper object at the 0 index and the language code of the currently * queried url at the 1 index */ function _wpml_get_redirect_helper($request_uri, $http_host) { global $wpml_url_converter; $lang_neg_type = icl_get_setting('language_negotiation_type'); $language_code = $wpml_url_converter->get_language_from_url($http_host . $request_uri); switch ($lang_neg_type) { case 1: global $wpml_url_filters; if ($wpml_url_filters->frontend_uses_root() !== false) { require ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php'; $redirect_helper = new WPML_RootPage_Redirect_By_Subdir(icl_get_setting('urls'), $request_uri, $http_host); } else { require ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-redirect-by-subdir.class.php'; $redirect_helper = new WPML_Redirect_By_Subdir(icl_get_setting('urls'), $request_uri, $http_host); } break; case 2: require ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-redirect-by-domain.class.php'; $redirect_helper = new WPML_Redirect_By_Domain(icl_get_setting('language_domains'), $request_uri, $http_host); break; case 3: default: $redirect_helper = new WPML_Redirect_By_Param(icl_get_setting('taxonomies_sync_option', array()), $language_code, $request_uri); } return array($redirect_helper, $language_code); }
/** * * @return WPML_Redirection * */ function _wpml_get_redirect_helper() { global $wpml_url_converter, $wpml_request_handler, $wpml_language_resolution, $sitepress; $lang_neg_type = wpml_get_setting_filter(false, 'language_negotiation_type'); switch ($lang_neg_type) { case 1: global $wpml_url_filters; if ($wpml_url_filters->frontend_uses_root() !== false) { require_once ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-rootpage-redirect-by-subdir.class.php'; $redirect_helper = new WPML_RootPage_Redirect_By_Subdir(wpml_get_setting_filter(array(), 'urls'), $wpml_request_handler, $wpml_url_converter, $wpml_language_resolution); } else { require_once ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-redirect-by-subdir.class.php'; $redirect_helper = new WPML_Redirect_By_Subdir($wpml_url_converter, $wpml_request_handler, $wpml_language_resolution); } break; case 2: require_once ICL_PLUGIN_PATH . '/inc/request-handling/redirection/wpml-redirect-by-domain.class.php'; $wp_api = new WPML_WP_API(); $redirect_helper = new WPML_Redirect_By_Domain(icl_get_setting('language_domains'), $wp_api, $wpml_request_handler, $wpml_url_converter, $wpml_language_resolution); break; case 3: default: $redirect_helper = new WPML_Redirect_By_Param(icl_get_setting('taxonomies_sync_option', array()), $wpml_url_converter, $wpml_request_handler, $wpml_language_resolution, $sitepress); $redirect_helper->init_hooks(); } return $redirect_helper; }
public function register_string($context, $name, $value, $allow_empty_value = false) { global $wpdb; /* cpt slugs - do not register them when scanning themes and plugins * if name starting from 'URL slug: ' * and context is different from 'WordPress' */ if (substr($name, 0, 10) === 'URL slug: ' && 'WordPress' !== $context) { return false; } // if the default language is not set up return without doing anything if (!icl_get_setting('existing_content_language_verified')) { return false; } $translation = $this->string_from_registered($name, $context); if ($translation === $value) { return false; } list($name, $context) = $this->truncate_name_and_context($name, $context); $language = $this->language; $query = $wpdb->prepare("SELECT id, value, status FROM {$wpdb->prefix}icl_strings WHERE context=%s AND name=%s", $context, $name); $res = $wpdb->get_row($query); if ($res) { $string_id = $res->id; /* * If Sticky Links plugin is active and set to change links in Strings, * we need to process $value and change links into sticky before comparing * with saved in DB $res->value. * Otherwise after every String Translation screen refresh status of this string * will be changed into 'needs update' */ $alp_settings = get_option('alp_settings'); if (!empty($alp_settings['sticky_links_strings']) && $alp_settings['sticky_links_strings'] && defined('WPML_STICKY_LINKS_VERSION')) { // sticky links plugin is active? require_once ICL_PLUGIN_PATH . '/inc/absolute-links/absolute-links.class.php'; $absolute_links_object = new AbsoluteLinks(); $alp_broken_links = array(); $value = $absolute_links_object->_process_generic_text($value, $alp_broken_links); } $update_string = array(); if ($value != $res->value) { $update_string['value'] = $value; } if (!empty($update_string)) { $wpdb->update($wpdb->prefix . 'icl_strings', $update_string, array('id' => $string_id)); $wpdb->update($wpdb->prefix . 'icl_string_translations', array('status' => ICL_TM_NEEDS_UPDATE), array('string_id' => $string_id)); icl_update_string_status($string_id); } } else { $string_id = $this->save_string($value, $allow_empty_value, $language, $context, $name); } global $WPML_Sticky_Links; if (defined('WPML_TM_PATH') && !empty($WPML_Sticky_Links) && $WPML_Sticky_Links->settings['sticky_links_strings']) { require_once WPML_TM_PATH . '/inc/translation-proxy/wpml-pro-translation.class.php'; WPML_Pro_Translation::_content_make_links_sticky($string_id, 'string', false); } $this->name_cache[$name . $context] = $value; return $string_id; }
public function __construct($user_id, $user_is_admin, $language_pairs, $current_lang, $active_languages) { $this->language_pairs = $language_pairs; $this->current_lang = $current_lang; $this->active_langs = $active_languages; $this->editor_is_default = icl_get_setting('doc_translation_method'); add_action('wpml_cache_clear', array($this, 'init'), 11, 0); }
/** * * Get information about language pairs (including translators). Works only for ICL as a Translation Service * * @return array */ public static function get_language_pairs() { $icl_lang_status = icl_get_setting('icl_lang_status', array()); if (!empty($icl_lang_status)) { return $icl_lang_status; } $translator_status = self::get_icl_translator_status(); $language_pairs = $translator_status['icl_lang_status']; return $language_pairs; }
function apply_include_filters() { if (icl_get_setting('language_domains')) { add_filter('plugins_url', 'filter_include_url'); //so plugin includes get the correct path add_filter('template_directory_uri', 'filter_include_url'); //js includes get correct path add_filter('stylesheet_directory_uri', 'filter_include_url'); //style.css gets included right } }
/** * * Get information about language pairs (including translators). Works only for ICL as a Translation Service * * @return array */ public static function get_language_pairs() { $icl_lang_status = icl_get_setting('icl_lang_status', array()); if (!empty($icl_lang_status)) { $missing_translators = false; foreach ($icl_lang_status as $lang) { if (empty($lang['translators'])) { $missing_translators = true; break; } } if (!$missing_translators) { return $icl_lang_status; } } $translator_status = self::get_icl_translator_status(); return $translator_status['icl_lang_status']; }
function loaded() { parent::loaded(); if ($this->passed_dependencies()) { if (icl_get_setting('setup_complete')) { $this->add_admin_hooks(); $this->add_global_hooks(); if (is_admin()) { $this->run_db_update(); if (get_option('wpml-package-translation-refresh-required', true)) { add_action('init', array($this, 'refresh_packages'), 999, 0); update_option('wpml-package-translation-refresh-required', false); } } $this->package_translation_active = true; } } }
?> <label> <input type="radio" name="icl_untranslated_blog_posts" <?php echo $icl_only_translated_posts_checked; ?> value="0"/> <?php _e('Only translated posts.', 'sitepress'); ?> </label> </p> <p> <label> <?php $icl_all_posts_checked = checked(1, icl_get_setting('show_untranslated_blog_posts', 0), false); ?> <input type="radio" name="icl_untranslated_blog_posts" <?php echo $icl_all_posts_checked; ?> value="1"/> <?php _e('All posts (display translation if it exists or posts in default language otherwise).', 'sitepress'); ?> </label> </p> <div id="icl_untranslated_blog_posts_help" style="display: none"> <?php _e("Please note that this setting affects only blog posts queried by the main loop in a theme's index.php template.", "sitepress");
private function prepopulate_translations($lang) { global $wpdb; $existing_lang_verified = icl_get_setting('existing_content_language_verified'); if (!empty($existing_lang_verified)) { return; } icl_cache_clear(); // case of icl_sitepress_settings accidentally lost // if there's at least one translation do not initialize the languages for elements $one_translation = $wpdb->get_var($wpdb->prepare("SELECT translation_id FROM {$wpdb->prefix}icl_translations WHERE language_code<>%s", $lang)); if ($one_translation) { return; } $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}icl_translations"); $wpdb->query($wpdb->prepare("\n\t\t\tINSERT INTO {$wpdb->prefix}icl_translations(element_type, element_id, trid, language_code, source_language_code)\n\t\t\tSELECT CONCAT('post_',post_type), ID, ID, %s, NULL FROM {$wpdb->posts} WHERE post_status IN ('draft', 'publish','schedule','future','private', 'pending')\n\t\t\t", $lang)); $maxtrid = 1 + $wpdb->get_var("SELECT MAX(trid) FROM {$wpdb->prefix}icl_translations"); global $wp_taxonomies; $taxonomies = array_keys((array) $wp_taxonomies); foreach ($taxonomies as $tax) { $element_type = 'tax_' . $tax; $insert_query = "\n\t\t\t\tINSERT INTO {$wpdb->prefix}icl_translations(element_type, element_id, trid, language_code, source_language_code)\n\t\t\t\tSELECT %s, term_taxonomy_id, %d+term_taxonomy_id, %s, NULL FROM {$wpdb->term_taxonomy} WHERE taxonomy = %s\n\t\t\t\t"; $insert_prepare = $wpdb->prepare($insert_query, array($element_type, $maxtrid, $lang, $tax)); $wpdb->query($insert_prepare); $maxtrid = 1 + $wpdb->get_var("SELECT MAX(trid) FROM {$wpdb->prefix}icl_translations"); } $wpdb->query($wpdb->prepare("\n\t\t\tINSERT INTO {$wpdb->prefix}icl_translations(element_type, element_id, trid, language_code, source_language_code)\n\t\t\tSELECT 'comment', comment_ID, {$maxtrid}+comment_ID, %s, NULL FROM {$wpdb->comments}\n\t\t\t", $lang)); $wpdb->update($wpdb->prefix . 'icl_languages', array('active' => '1'), array('code' => $lang)); }
public function build_content_mcs() { /** * included by menu translation-management.php * * @uses TranslationManagement */ global $sitepress, $iclTranslationManagement; $doc_translation_method = isset($iclTranslationManagement->settings['doc_translation_method']) ? intval($iclTranslationManagement->settings['doc_translation_method']) : ICL_TM_TMETHOD_MANUAL; ?> <ul class="wpml-navigation-links js-wpml-navigation-links"> <li><a href="#ml-content-setup-sec-1"><?php _e('How to translate posts and pages', 'wpml-translation-management'); ?> </a></li> <li><a href="#ml-content-setup-sec-2"><?php _e('Posts and pages synchronization', 'wpml-translation-management'); ?> </a></li> <li> <a href="#ml-content-setup-sec-3"><?php _e('Translated documents options', 'wpml-translation-management'); ?> </a> </li> <?php if (defined('WPML_ST_VERSION')) { ?> <li> <a href="#ml-content-setup-sec-4"><?php _e('Custom posts slug translation options', 'wpml-string-translation'); ?> </a> </li> <?php } ?> <li> <a href="#ml-content-setup-sec-5"><?php _e('Translation pickup mode', 'wpml-translation-management'); ?> </a> </li> <?php if (defined('WPML_XLIFF_EMBED_VERSION')) { ?> <li><a href="#ml-content-setup-sec-5-1"><?php _e('XLIFF file options', 'wpml-xliff'); ?> </a></li> <?php } ?> <li> <a href="#ml-content-setup-sec-6"><?php _e('Custom fields translation', 'wpml-translation-management'); ?> </a> </li> <?php $custom_posts = array(); $this->post_types = $sitepress->get_translatable_documents(true); foreach ($this->post_types as $k => $v) { if (!in_array($k, array('post', 'page'))) { $custom_posts[$k] = $v; } } global $wp_taxonomies; $custom_taxonomies = array_diff(array_keys((array) $wp_taxonomies), array('post_tag', 'category', 'nav_menu', 'link_category', 'post_format')); ?> <?php if ($custom_posts) { ?> <li><a href="#ml-content-setup-sec-7"><?php _e('Custom posts', 'wpml-translation-management'); ?> </a> </li> <?php } ?> <?php if ($custom_taxonomies) { ?> <li><a href="#ml-content-setup-sec-8"><?php _e('Custom taxonomies', 'wpml-translation-management'); ?> </a> </li> <?php } ?> <?php if (!empty($iclTranslationManagement->admin_texts_to_translate) && function_exists('icl_register_string')) { ?> <li> <a href="#ml-content-setup-sec-9"><?php _e('Admin Strings to Translate', 'wpml-translation-management'); ?> </a> </li> <?php } ?> </ul> <div class="wpml-section wpml-section-notice"> <div class="updated below-h2"> <p> <?php _e("WPML can read a configuration file that tells it what needs translation in themes and plugins. The file is named wpml-config.xml and it's placed in the root folder of the plugin or theme.", 'wpml-translation-management'); ?> </p> <p> <a href="https://wpml.org/?page_id=5526"><?php _e('Learn more', 'wpml-translation-management'); ?> </a> </p> </div> </div> <div class="wpml-section" id="ml-content-setup-sec-1"> <div class="wpml-section-header"> <h3><?php _e('How to translate posts and pages', 'wpml-translation-management'); ?> </h3> </div> <div class="wpml-section-content"> <form id="icl_doc_translation_method" name="icl_doc_translation_method" action=""> <?php wp_nonce_field('icl_doc_translation_method_nonce', '_icl_nonce'); ?> <ul class="t_method"> <li> <label> <input type="radio" name="t_method" value="<?php echo ICL_TM_TMETHOD_MANUAL; ?> " <?php if (!$doc_translation_method) { ?> checked="checked"<?php } ?> /> <?php _e('Create translations manually', 'wpml-translation-management'); ?> </label> </li> <li> <label> <input type="radio" name="t_method" value="<?php echo ICL_TM_TMETHOD_EDITOR; ?> " <?php if ($doc_translation_method) { ?> checked="checked"<?php } ?> /> <?php _e('Use the translation editor', 'wpml-translation-management'); ?> </label> </li> </ul> <p id="tm_block_retranslating_terms"><label> <input name="tm_block_retranslating_terms" value="1" <?php checked(icl_get_setting('tm_block_retranslating_terms'), "1"); ?> type="checkbox"/> <?php _e('Block translating taxonomy terms (from the Translation Editor) that have already been translated.', 'wpml-translation-management'); ?> </label> </p> <p> <label> <input name="how_to_translate" value="1" <?php checked(icl_get_setting('hide_how_to_translate'), false); ?> type="checkbox"/> <?php _e('Show translation instructions in the list of pages', 'wpml-translation-management'); ?> </label> </p> <p> <a href="https://wpml.org/?page_id=3416" target="_blank"><?php _e('Learn more about the different translation options', 'wpml-translation-management'); ?> </a> </p> <p class="buttons-wrap"> <span class="icl_ajx_response" id="icl_ajx_response_dtm"></span> <input type="submit" class="button-primary" value="<?php _e('Save', 'wpml-translation-management'); ?> "/> </p> </form> </div> <!-- .wpml-section-content --> </div> <!-- .wpml-section --> <?php include ICL_PLUGIN_PATH . '/menu/_posts_sync_options.php'; ?> <div class="wpml-section" id="ml-content-setup-sec-3"> <div class="wpml-section-header"> <h3><?php _e('Translated documents options', 'wpml-translation-management'); ?> </h3> </div> <div class="wpml-section-content"> <form name="icl_tdo_options" id="icl_tdo_options" action=""> <?php wp_nonce_field('icl_tdo_options_nonce', '_icl_nonce'); ?> <div class="wpml-section-content-inner"> <h4> <?php _e('Document status', 'wpml-translation-management'); ?> </h4> <ul> <li> <label> <input type="radio" name="icl_translated_document_status" value="0" <?php checked(icl_get_setting('translated_document_status'), false); ?> /> <?php _e('Draft', 'wpml-translation-management'); ?> </label> </li> <li> <label> <input type="radio" name="icl_translated_document_status" value="1" <?php checked(icl_get_setting('translated_document_status'), true); ?> /> <?php _e('Same as the original document', 'wpml-translation-management'); ?> </label> </li> </ul> <p class="explanation-text"> <?php _e("Choose if translations should be published when received. Note: If Publish is selected, the translation will only be published if the original node is published when the translation is received.", 'wpml-translation-management'); ?> </p> </div> <div class="wpml-section-content-inner"> <h4> <?php _e('Page URL', 'wpml-translation-management'); ?> </h4> <ul> <li> <label><input type="radio" name="icl_translated_document_page_url" value="auto-generate" <?php if (empty($sitepress_settings['translated_document_page_url']) || $sitepress_settings['translated_document_page_url'] == 'auto-generate') { ?> checked="checked"<?php } ?> /> <?php _e('Auto-generate from title (default)', 'wpml-translation-management'); ?> </label> </li> <li> <label><input type="radio" name="icl_translated_document_page_url" value="translate" <?php if ($sitepress_settings['translated_document_page_url'] == 'translate') { ?> checked="checked"<?php } ?> /> <?php _e('Translate (this will include the slug in the translation and not create it automatically from the title)', 'wpml-translation-management'); ?> </label> </li> <li> <label><input type="radio" name="icl_translated_document_page_url" value="copy-encoded" <?php if ($sitepress_settings['translated_document_page_url'] == 'copy-encoded') { ?> checked="checked"<?php } ?> /> <?php _e('Copy from original language if translation language uses encoded URLs', 'wpml-translation-management'); ?> </label> </li> </ul> </div> <div class="wpml-section-content-inner"> <p class="buttons-wrap"> <span class="icl_ajx_response" id="icl_ajx_response_tdo"></span> <input type="submit" class="button-primary" value="<?php _e('Save', 'wpml-translation-management'); ?> "/> </p> </div> </form> </div> <!-- .wpml-section-content --> </div> <!-- .wpml-section --> <?php if (defined('WPML_ST_VERSION')) { include WPML_ST_PATH . '/menu/_slug-translation-options.php'; } ?> <div class="wpml-section" id="ml-content-setup-sec-5"> <div class="wpml-section-header"> <h3><?php _e('Translation pickup mode', 'wpml-translation-management'); ?> </h3> </div> <div class="wpml-section-content"> <form id="icl_translation_pickup_mode" name="icl_translation_pickup_mode" action=""> <?php wp_nonce_field('set_pickup_mode_nonce', '_icl_nonce'); ?> <p> <?php echo __('How should the site receive completed translations from Translation Service?', 'wpml-translation-management'); ?> </p> <p> <label> <input type="radio" name="icl_translation_pickup_method" value="<?php echo ICL_PRO_TRANSLATION_PICKUP_XMLRPC; ?> " <?php if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) { ?> checked="checked"<?php } ?> /> <?php echo __('Translation Service will deliver translations automatically using XML-RPC', 'wpml-translation-management'); ?> </label> </p> <p> <label> <input type="radio" name="icl_translation_pickup_method" value="<?php echo ICL_PRO_TRANSLATION_PICKUP_POLLING; ?> " <?php if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) { ?> checked="checked"<?php } ?> /> <?php _e('The site will fetch translations manually', 'wpml-translation-management'); ?> </label> </p> <p class="buttons-wrap"> <span class="icl_ajx_response" id="icl_ajx_response_tpm"></span> <input class="button-primary" name="save" value="<?php _e('Save', 'wpml-translation-management'); ?> " type="submit"/> </p> <?php $this->build_content_dashboard_fetch_translations_box(); ?> </form> </div> <!-- .wpml-section-content --> </div> <!-- .wpml-section --> <?php if (defined('WPML_XLIFF_EMBED_VERSION')) { include WPML_TM_PATH . '/menu/xliff-options.php'; } $this->build_content_mcs_custom_fields(); include ICL_PLUGIN_PATH . '/menu/_custom_types_translation.php'; ?> <?php if (!empty($iclTranslationManagement->admin_texts_to_translate) && function_exists('icl_register_string')) { //available only with the String Translation plugin ?> <div class="wpml-section" id="ml-content-setup-sec-9"> <div class="wpml-section-header"> <h3><?php _e('Admin Strings to Translate', 'wpml-translation-management'); ?> </h3> </div> <div class="wpml-section-content"> <table class="widefat"> <thead> <tr> <th colspan="3"> <?php _e('Admin Strings', 'wpml-translation-management'); ?> </th> </tr> </thead> <tbody> <tr> <td> <?php foreach ($iclTranslationManagement->admin_texts_to_translate as $option_name => $option_value) { $iclTranslationManagement->render_option_writes($option_name, $option_value); } ?> <br/> <p><a class="button-secondary" href="<?php echo admin_url('admin.php?page=' . WPML_ST_FOLDER . '/menu/string-translation.php'); ?> "><?php _e('Edit translatable strings', 'wpml-translation-management'); ?> </a> </p> </td> </tr> </tbody> </table> </div> <!-- .wpml-section-content --> </div> <!-- .wpml-section --> <?php } }
function wpml_maybe_setup_post_edit() { global $pagenow, $sitepress, $post_edit_screen; if ($pagenow === 'post.php' || $pagenow === 'post-new.php' || $pagenow === 'edit.php' || defined('DOING_AJAX')) { require ICL_PLUGIN_PATH . '/menu/wpml-post-edit-screen.class.php'; $post_edit_screen = new WPML_Post_Edit_Screen(icl_get_setting('language_negotiation_type')); add_action('admin_head', array($sitepress, 'post_edit_language_options')); } }
/** * @param string $key * @param string $sub_key * @param mixed|false $default * * @return bool|mixed * @since 3.1 * @deprecated 3.2 use 'wpml_sub_setting' filter instead */ function icl_get_sub_setting($key, $sub_key, $default = false) { $parent = icl_get_setting($key, array()); return isset($parent[$sub_key]) ? $parent[$sub_key] : $default; }
/** * * Sets the language of frontend requests to false, if they are not for * a hidden or active language code. The handling of permissions in case of * hidden languages is done in \SitePress::init. * * @param string $lang * * @return bool|string */ private function filter_for_legal_langs($lang) { $this->maybe_reload(); if ($lang === 'all' && is_admin()) { return 'all'; } if (!isset($this->hidden_lang_codes[$lang]) && !isset($this->active_language_codes[$lang])) { $lang = $this->default_lang ? $this->default_lang : icl_get_setting('default_language'); } return $lang; }
function admin_menu_setup() { if (!icl_get_setting('setup_complete')) { return; } $top_page = apply_filters('icl_menu_main_page', ICL_PLUGIN_FOLDER . '/menu/languages.php'); add_submenu_page($top_page, __('WP Menus Sync', 'sitepress'), __('WP Menus Sync', 'sitepress'), 'wpml_manage_wp_menus_sync', ICL_PLUGIN_FOLDER . '/menu/menus-sync.php'); }
/** * Checks if a given post_type is currently translated * * @param string $post_type name/slug of a post_type * @return bool true if the post_type is currently set to being translatable in WPML */ function is_post_type_translated($post_type) { return in_array($post_type, array('post', 'page', 'nav_menu_item'), true) || in_array($post_type, array_keys(array_filter(icl_get_setting('custom_posts_sync_option', array())))); }
} include_once ICL_PLUGIN_PATH . '/inc/functions-network.php'; if (get_option('_wpml_inactive', false) && isset($wpmu_sitewide_plugins[ICL_PLUGIN_FOLDER . '/sitepress.php'])) { wpml_set_plugin_as_inactive(); return; } } if (!wp_next_scheduled('update_wpml_config_index')) { //Set cron job to update WPML config index file from CDN wp_schedule_event(time(), 'daily', 'update_wpml_config_index'); } /** @var WPML_Post_Translation $wpml_post_translations */ global $sitepress, $wpdb, $wpml_url_filters, $wpml_post_translations, $wpml_term_translations, $wpml_url_converter, $wpml_language_resolution, $wpml_slug_filter; $sitepress = new SitePress(); new WPML_Global_AJAX($sitepress); wpml_load_query_filter(icl_get_setting('setup_complete')); $wpml_url_filters = new WPML_URL_Filters($wpml_post_translations, $wpml_url_converter, $sitepress); wpml_load_request_handler(is_admin(), $wpml_language_resolution->get_active_language_codes(), $sitepress->get_default_language()); require ICL_PLUGIN_PATH . '/inc/url-handling/wpml-slug-filter.class.php'; $wpml_slug_filter = new WPML_Slug_Filter($wpdb, $sitepress, $wpml_post_translations); /** @var array $sitepress_settings */ $sitepress_settings = $sitepress->get_settings(); wpml_load_term_filters(); wpml_maybe_setup_post_edit(); require ICL_PLUGIN_PATH . '/modules/cache-plugins-integration/cache-plugins-integration.php'; require ICL_PLUGIN_PATH . '/inc/wp-login-filters.php'; require ICL_PLUGIN_PATH . '/inc/plugins-integration.php'; if (is_admin()) { activate_installer($sitepress); if ($sitepress->get_setting('setup_complete')) { setup_admin_menus();
private function default_language() { $this->default_language = $this->default_language ? $this->default_language : icl_get_setting('default_language'); return $this->default_language; }
$element_lang_code = $res->language_code; } else { $element_lang_code = $current_language; $translation_id = $sitepress->set_element_language_details($element_id, $icl_element_type, null, $element_lang_code); //get trid of $translation_id $trid = $wpdb->get_var($wpdb->prepare("SELECT trid FROM {$wpdb->prefix}icl_translations WHERE translation_id=%d", array($translation_id))); } } else { $trid = isset($_GET['trid']) ? intval($_GET['trid']) : false; $element_lang_code = isset($_GET['lang']) ? strip_tags($_GET['lang']) : $current_language; } $translations = false; if ($trid) { $translations = $sitepress->get_element_translations($trid, $icl_element_type); } $active_languages = $sitepress->get_active_languages(); $selected_language = $element_lang_code ? $element_lang_code : $default_language; $source_language = isset($_GET['source_lang']) ? strip_tags(filter_input(INPUT_GET, 'source_lang', FILTER_SANITIZE_FULL_SPECIAL_CHARS)) : false; $untranslated_ids = $sitepress->get_elements_without_translations($icl_element_type, $selected_language, $default_language); $dropdown = new WPML_Taxonomy_Element_Language_Dropdown(); $dropdown->add_language_selector_to_page($active_languages, $selected_language, (array) $translations, $element_id, $icl_element_type); if (icl_get_setting('setup_complete')) { require ICL_PLUGIN_PATH . '/menu/wpml-translation-selector.class.php'; $selector = new WPML_Translation_Selector($sitepress, $default_language, $source_language, $element_id); $selector->add_translation_of_selector_to_page($trid, $sitepress->get_current_language(), $selected_language, $untranslated_ids); } $sitepress->add_translate_options($trid, $active_languages, $selected_language, empty($translations) ? array() : $translations, $icl_element_type); ?> </div></div></div></div></div>
/** * @param $element * @param $option_key * @param $readonly_config_key * @param $always_true_types * * @return bool|mixed */ private function is_translated_element($element, $option_key, $readonly_config_key, $always_true_types) { $ret = false; if (is_scalar($element)) { if (in_array($element, $always_true_types)) { $ret = true; } else { $translation_management_options = icl_get_setting('translation-management'); $element_settings = icl_get_sub_setting($option_key, $element); if (isset($element_settings)) { $ret = icl_get_sub_setting($option_key, $element); } elseif (isset($translation_management_options[$readonly_config_key][$element]) && $translation_management_options[$readonly_config_key][$element] == 1) { $ret = true; } else { $ret = false; } } } return $ret; }
/** * Returns WPML root path if set and used. */ public function wpml_root_path() { $settings = icl_get_setting('urls', array()); return $this->is_default_language_in_directory() && isset($settings['show_on_root']) && $settings['show_on_root'] == 'html_file' && !empty($settings['root_html_file_path']) ? $settings['root_html_file_path'] : null; }
icl_save_settings(); break; case 'toggle_show_translations': icl_set_setting('show_translations_flag', intval(!icl_get_setting('show_translations_flag', false))); icl_save_settings(); break; case 'icl_messages': //TODO: handle with Translation Proxy if (!icl_get_setting('icl_disable_reminders')) { break; } exit; case 'icl_help_links': if (isset($iclq) && $iclq) { $links = $iclq->get_help_links(); $lang = icl_get_setting('admin_default_language'); if (!isset($links['resources'][$lang])) { $lang = 'en'; } if (isset($links['resources'][$lang])) { $output = '<ul>'; foreach ($links['resources'][$lang]['resource'] as $resource) { if (isset($resource['attr'])) { $title = $resource['attr']['title']; $url = $resource['attr']['url']; $icon = $resource['attr']['icon']; $icon_width = $resource['attr']['icon_width']; $icon_height = $resource['attr']['icon_height']; } else { $title = $resource['title']; $url = $resource['url'];
static function fill_languages() { global $wpdb, $sitepress, $sitepress_settings; $languages_codes = icl_get_languages_codes(); $lang_locales = icl_get_languages_locales(); $table_name = $wpdb->prefix . 'icl_languages'; if (!self::create_languages()) { return false; } if (!self::languages_table_is_complete()) { //First truncate the table $active_languages = $sitepress !== null && $sitepress_settings !== null && icl_get_setting('setup_complete') ? $sitepress->get_active_languages() : array(); $wpdb->hide_errors(); $sql = "TRUNCATE " . $table_name; $truncate_result = $wpdb->query($sql); $wpdb->show_errors(); if (false !== $truncate_result) { foreach (self::get_languages_names() as $key => $val) { $language_code = $languages_codes[$key]; if (strpos($key, 'Norwegian Bokm') === 0) { $key = 'Norwegian Bokmål'; $language_code = 'nb'; } // exception for norwegian $default_locale = isset($lang_locales[$language_code]) ? $lang_locales[$language_code] : ''; $args = array('english_name' => $key, 'code' => $language_code, 'major' => $val['major'], 'active' => isset($active_languages[$language_code]) ? 1 : 0, 'default_locale' => $default_locale, 'tag' => $language_code); if ($wpdb->insert($table_name, $args) === false) { return false; } } } } return true; }
public function get_root_page_id() { $urls = icl_get_setting('urls'); return isset($urls['root_page']) && !empty($urls['directory_for_default_language']) && isset($urls['show_on_root']) && $urls['show_on_root'] === 'page' ? $root_id = $urls['root_page'] : false; }
<ul> <?php if (!defined('WPML_ST_VERSION')) { $icl_st_note = __("WPML's String Translation module lets you translate the theme, plugins and admin texts. To install it, go to your WPML account, click on Downloads and get WPML String Translation.", 'sitepress'); $st_disabled = 'disabled="disabled" '; } else { $st_disabled = ''; } $td_value = icl_get_setting('gettext_theme_domain_name'); $theme_localization_load_textdomain = icl_get_setting('theme_localization_load_textdomain'); if (!empty($theme_localization_load_textdomain)) { $ltd_checked = 'checked="checked" '; } else { $ltd_checked = ''; } $theme_localization_type = icl_get_setting('theme_localization_type'); ?> <li><label><input <?php echo $st_disabled; ?> type="radio" name="icl_theme_localization_type" value="1" <?php if ($theme_localization_type == 1) { ?> checked="checked"<?php } ?> /> <?php _e('Translate by WPML.', 'sitepress'); ?> </label> <?php
public function frontend_uses_root() { $urls = icl_get_setting('urls'); return isset($urls['root_page']) && isset($urls['show_on_root']) && !empty($urls['directory_for_default_language']) && ($urls['show_on_root'] === 'page' || $urls['show_on_root'] === 'html_file'); }
function wpcf_wpml_warnings_init() { if (!defined('WPML_ST_PATH') || !class_exists('ICL_AdminNotifier')) { return; } /** * check is configuration done?! */ global $sitepress, $sitepress_settings; if (function_exists('icl_get_setting') && icl_get_setting('st')) { return; } /** * do that only when version of WPML is lower then 3.2 */ if (defined('ICL_SITEPRESS_VERSION') && version_compare(ICL_SITEPRESS_VERSION, '3.2', '<')) { if (isset($sitepress_settings['st']) && $sitepress->get_default_language() != $sitepress_settings['st']['strings_language']) { wp_types_default_language_warning(); } elseif (isset($sitepress_settings['st']) && $sitepress_settings['st']['strings_language'] != 'en') { wp_types_st_language_warning(); } else { ICL_AdminNotifier::removeMessage('wp_types_default_language_warning'); ICL_AdminNotifier::removeMessage('wp_types_st_language_warning'); } } }
public static function uses_html_root() { $urls = icl_get_setting('urls'); return isset($urls['root_page']) && isset($urls['show_on_root']) && $urls['show_on_root'] === 'html_file'; }
function bpml_is_langauge_as_param() { return icl_get_setting('language_negotiation_type', false) == 3; }