function wpml_tm_load_ui() { if (version_compare(ICL_SITEPRESS_VERSION, '3.3.1', '>=')) { global $sitepress, $wpdb, $WPML_Translation_Management; $core_translation_management = wpml_load_core_tm(); $tm_loader = new WPML_TM_Loader(); $WPML_Translation_Management = new WPML_Translation_Management($sitepress, $tm_loader, $core_translation_management); $WPML_Translation_Management->load(); $wpml_wp_api = new WPML_WP_API(); $TranslationProxy = new WPML_Translation_Proxy_API(); new WPML_TM_Troubleshooting_Reset_Pro_Trans_Config($sitepress, $TranslationProxy, $wpml_wp_api, $wpdb); new WPML_TM_Troubleshooting_Clear_TS($wpml_wp_api); } }
static function get_custom_fields_translation_settings($translation_actions = array(0)) { $iclTranslationManagement = wpml_load_core_tm(); $section = 'custom_fields_translation'; $result = array(); $tm_settings = $iclTranslationManagement->settings; if (isset($tm_settings[$section])) { foreach ($tm_settings[$section] as $meta_key => $translation_type) { if (in_array($translation_type, $translation_actions)) { $result[] = $meta_key; } } } return $result; }
/** * @return WPML_TM_Mail_Notification */ function wpml_tm_init_mail_notifications() { global $wpml_tm_mailer, $sitepress, $wpdb, $iclTranslationManagement, $wpml_translation_job_factory; if (!isset($wpml_tm_mailer)) { require WPML_TM_PATH . '/inc/local-translation/wpml-tm-mail-notification.class.php'; $blog_translators = new WPML_TM_Blog_Translators($wpdb); $iclTranslationManagement = $iclTranslationManagement ? $iclTranslationManagement : wpml_load_core_tm(); if (empty($iclTranslationManagement->settings)) { $iclTranslationManagement->init(); } $settings = isset($iclTranslationManagement->settings['notification']) ? $iclTranslationManagement->settings['notification'] : array(); $wpml_tm_mailer = new WPML_TM_Mail_Notification($sitepress, $wpdb, $wpml_translation_job_factory, $blog_translators, $settings); } $wpml_tm_mailer->init(); return $wpml_tm_mailer; }
function wpml_tm_load_ui() { require_once WPML_TM_PATH . '/menu/basket-tab/sitepress-table-basket.class.php'; require_once WPML_TM_PATH . '/menu/dashboard/wpml-tm-dashboard.class.php'; require_once WPML_TM_PATH . '/menu/wpml-tm-menus.class.php'; require_once WPML_TM_PATH . '/menu/wpml-translator-settings.class.php'; if (version_compare(ICL_SITEPRESS_VERSION, '3.3.1', '>=')) { global $sitepress, $wpdb, $WPML_Translation_Management; $core_translation_management = wpml_load_core_tm(); $tm_loader = new WPML_TM_Loader(); $wpml_tp_translator = new WPML_TP_Translator(); $WPML_Translation_Management = new WPML_Translation_Management($sitepress, $tm_loader, $core_translation_management, $wpml_tp_translator); $WPML_Translation_Management->load(); if (is_admin()) { $wpml_wp_api = new WPML_WP_API(); $TranslationProxy = new WPML_Translation_Proxy_API(); new WPML_TM_Troubleshooting_Reset_Pro_Trans_Config($sitepress, $TranslationProxy, $wpml_wp_api, $wpdb); new WPML_TM_Troubleshooting_Clear_TS($wpml_wp_api); new WPML_TM_Promotions($wpml_wp_api); } } }
private function duplicate_comments($master_post_id, $translated_id) { global $sitepress; remove_filter('comments_clauses', array($sitepress, 'comments_clauses'), 10); $comments_on_master = get_comments(array('post_id' => $master_post_id)); $comments_on_translation = get_comments(array('post_id' => $translated_id, 'status' => 'any')); add_filter('comments_clauses', array($sitepress, 'comments_clauses'), 10, 2); foreach ($comments_on_translation as $comment) { wp_delete_comment($comment->comment_ID, true); clean_comment_cache($comment->comment_ID); } $iclTranslationManagement = wpml_load_core_tm(); foreach ($comments_on_master as $comment) { $iclTranslationManagement->duplication_insert_comment($comment->comment_ID); clean_comment_cache($comment->comment_ID); } wp_update_comment_count_now($master_post_id); wp_update_comment_count_now($translated_id); }
/** * Build or update duplicated posts from a master post. * To be used only for admin backend actions * @see $iclTranslationManagement in \SitePress:: __construct * * @param int $master_post_id The ID of the post to duplicate from. * The ID can be that of a post, page or custom post * Master post doesn't need to be in the default language. * * @uses SitePress * @uses TranslationManagement * @since 3.2 * @use \SitePress::api_hooks */ function wpml_admin_make_post_duplicates_action($master_post_id) { $post = get_post($master_post_id); $post_type = $post->post_type; if ($post->post_status == 'auto-draft' || $post->post_type == 'revision') { return; } global $sitepress; $iclTranslationManagement = wpml_load_core_tm(); if ($sitepress->is_translated_post_type($post_type)) { $iclTranslationManagement->make_duplicates_all($master_post_id); } }
function __construct() { do_action('wpml_before_startup'); global $pagenow, $sitepress_settings, $wpdb, $wpml_post_translations, $wpml_term_translations; $this->wpml_helper = new WPML_Helper($wpdb); parent::__construct($wpdb); $this->locale_utils = new WPML_Locale($wpdb, $this); $sitepress_settings = get_option('icl_sitepress_settings'); $this->settings =& $sitepress_settings; $this->always_translatable_post_types = array('post', 'page'); $this->always_translatable_taxonomies = array('category', 'post_tag'); //TODO: [WPML 3.5] To remove in WPML 3.5 //@since 3.1 if (is_admin() && !$this->get_setting('icl_capabilities_verified')) { icl_enable_capabilities(); $sitepress_settings = get_option('icl_sitepress_settings'); } if (is_null($pagenow) && is_multisite()) { include ICL_PLUGIN_PATH . '/inc/hacks/vars-php-multisite.php'; } if (false != $this->settings) { $this->verify_settings(); } if (isset($_GET['page']) && $_GET['page'] == ICL_PLUGIN_FOLDER . '/menu/troubleshooting.php' && isset($_GET['debug_action'])) { ob_start(); } if (isset($_REQUEST['icl_ajx_action'])) { add_action('init', array($this, 'ajax_setup'), 15); } add_action('admin_footer', array($this, 'icl_nonces')); // Process post requests if (!empty($_POST)) { add_action('init', array($this, 'process_forms')); } $this->initialize_cache(); $this->flags = new WPML_Flags($wpdb); add_action('plugins_loaded', array($this, 'init'), 1); add_action('wp_loaded', array($this, 'maybe_set_this_lang')); add_action('init', array($this, 'on_wp_init'), 1); add_action('switch_blog', array($this, 'init_settings'), 10, 1); // Administration menus add_action('admin_menu', array($this, 'administration_menu')); add_action('admin_menu', array($this, 'administration_menu2'), 30); add_action('init', array($this, 'plugin_localization')); if ($this->get_setting('existing_content_language_verified') && ($this->get_setting('setup_complete') || !empty($_GET['page']) && $this->get_setting('setup_wizard_step') == 3 && $_GET['page'] == ICL_PLUGIN_FOLDER . '/menu/languages.php')) { // Post/page language box add_filter('comment_feed_join', array($this, 'comment_feed_join')); add_filter('comments_clauses', array($this, 'comments_clauses'), 10, 2); // Allow us to filter the Query vars before the posts query is being built and executed add_filter('pre_get_posts', array($this, 'pre_get_posts')); add_filter('the_posts', array($this, 'the_posts'), 10); if ($pagenow == 'edit.php') { add_action('quick_edit_custom_box', array('WPML_Terms_Translations', 'quick_edit_terms_removal'), 10, 2); } add_filter('get_pages', array($this, 'exclude_other_language_pages2')); add_filter('wp_dropdown_pages', array($this, 'wp_dropdown_pages')); add_filter('get_comment_link', array($this, 'get_comment_link_filter')); // filter the saving of terms so that the taxonomy_ids of translated terms are correctly adjusted across taxonomies add_action('created_term_translation', array('WPML_Terms_Translations', 'sync_ttid_action'), 10, 3); // filters terms by language for the term/tag-box autoselect if (isset($_GET['action']) && $_GET['action'] == 'ajax-tag-search' || isset($_POST['action']) && $_POST['action'] == 'get-tagcloud') { add_filter('get_terms', array('WPML_Terms_Translations', 'get_terms_filter'), 10, 2); } $this->set_term_filters_and_hooks(); add_action('parse_query', array($this, 'parse_query')); // The delete filter only ensures the synchronizing of delete actions between translations of a term. add_action('delete_term', array($this, 'delete_term'), 1, 3); add_action('set_object_terms', array('WPML_Terms_Translations', 'set_object_terms_action'), 10, 6); // AJAX Actions for the post edit screen add_action('wp_ajax_wpml_save_term', array('WPML_Post_Edit_Ajax', 'wpml_save_term')); add_action('wp_ajax_wpml_switch_post_language', array('WPML_Post_Edit_Ajax', 'wpml_switch_post_language')); add_action('wp_ajax_wpml_set_post_edit_lang', array('WPML_Post_Edit_Ajax', 'wpml_set_post_edit_lang')); add_action('wp_ajax_wpml_get_default_lang', array('WPML_Post_Edit_Ajax', 'wpml_get_default_lang')); //AJAX Actions for the taxonomy translation screen add_action('wp_ajax_wpml_get_table_taxonomies', array('WPML_Taxonomy_Translation_Table_Display', 'wpml_get_table_taxonomies')); add_action('wp_ajax_wpml_get_terms_and_labels_for_taxonomy_table', array('WPML_Taxonomy_Translation_Table_Display', 'wpml_get_terms_and_labels_for_taxonomy_table')); // Ajax Action for the updating of term names on the troubleshooting page add_action('wp_ajax_wpml_update_term_names_troubleshoot', array('WPML_Troubleshooting_Terms_Menu', 'wpml_update_term_names_troubleshoot')); // short circuit get default category add_filter('pre_option_default_category', array($this, 'pre_option_default_category')); add_filter('update_option_default_category', array($this, 'update_option_default_category'), 1, 2); // custom hook for adding the language selector to the template //@deprecated see 'wpml_add_language_selector' action in $this->api_hooks();) add_action('icl_language_selector', array($this, 'language_selector')); // front end js add_action('wp_head', array($this, 'front_end_js')); add_action('wp_head', array($this, 'rtl_fix')); add_action('admin_print_styles', array($this, 'rtl_fix')); add_action('restrict_manage_posts', array($this, 'restrict_manage_posts')); // adjacent posts links add_filter('get_previous_post_join', array($this, 'get_adjacent_post_join')); add_filter('get_next_post_join', array($this, 'get_adjacent_post_join')); add_filter('get_previous_post_where', array($this, 'get_adjacent_post_where')); add_filter('get_next_post_where', array($this, 'get_adjacent_post_where')); // feeds links add_filter('feed_link', array($this, 'feed_link')); // commenting links add_filter('post_comments_feed_link', array($this, 'post_comments_feed_link')); add_filter('trackback_url', array($this, 'trackback_url')); add_filter('user_trailingslashit', array($this, 'user_trailingslashit'), 1, 2); // date based archives add_filter('year_link', array($this, 'archives_link')); add_filter('month_link', array($this, 'archives_link')); add_filter('day_link', array($this, 'archives_link')); add_filter('getarchives_join', array($this, 'getarchives_join')); add_filter('getarchives_where', array($this, 'getarchives_where')); add_filter('pre_option_home', array($this, 'pre_option_home')); if (!is_admin()) { add_filter('attachment_link', array($this, 'attachment_link_filter'), 10, 2); } // Filter custom type archive link (since WP 3.1) add_filter('post_type_archive_link', array($this, 'post_type_archive_link_filter'), 10, 2); add_filter('author_link', array($this, 'author_link')); // language negotiation add_action('query_vars', array($this, 'query_vars')); add_filter('language_attributes', array($this, 'language_attributes')); add_filter('locale', array($this, 'locale'), 10, 1); add_filter('pre_option_page_on_front', array($this, 'pre_option_page_on_front')); add_filter('pre_option_page_for_posts', array($this, 'pre_option_page_for_posts')); add_filter('pre_option_sticky_posts', array($this, 'option_sticky_posts'), 10, 2); add_action('wp_head', array($this, 'set_wp_query')); add_action('show_user_profile', array($this, 'show_user_options')); add_action('personal_options_update', array($this, 'save_user_options')); // column with links to translations (or add translation) - low priority add_action('init', array($this, 'configure_custom_column'), 1010); // accommodate Types init@999 if (!is_admin()) { add_action('wp_head', array($this, 'meta_generator_tag')); } require_once ICL_PLUGIN_PATH . '/inc/wp-nav-menus/iclNavMenu.class.php'; new iclNavMenu($this, $wpdb, $wpml_post_translations, $wpml_term_translations); if (is_admin() || defined('XMLRPC_REQUEST') || preg_match('#wp-comments-post\\.php$#', $_SERVER['REQUEST_URI'])) { global $iclTranslationManagement; $iclTranslationManagement = wpml_load_core_tm(); } add_action('wp_login', array($this, 'reset_admin_language_cookie')); if ($this->settings['seo']['head_langs']) { add_action('wp_head', array($this, 'head_langs')); } /** * add extra debug information */ add_filter('icl_get_extra_debug_info', array($this, 'add_extra_debug_info')); } //end if the initial language is set - existing_content_language_verified add_action('wp_dashboard_setup', array($this, 'dashboard_widget_setup')); add_filter('core_version_check_locale', array($this, 'wp_upgrade_locale')); if ($pagenow === 'post.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit' && isset($_GET['post'])) { add_action('init', '_icl_trash_restore_prompt'); } add_action('init', array($this, 'js_load'), 2); // enqueue scripts - higher priority add_filter('url_to_postid', array($this, 'url_to_postid')); //cron job to update WPML config index file from CDN add_action('update_wpml_config_index', array($this, 'update_wpml_config_index_event')); //update WPML config files add_action('wp_ajax_update_wpml_config_index', array($this, 'update_wpml_config_index_event_ajax')); add_action('after_switch_theme', array($this, 'update_wpml_config_index_event')); add_action('activated_plugin', array($this, 'update_wpml_config_index_event')); add_action('core_upgrade_preamble', array($this, 'update_index_screen')); add_shortcode('wpml_language_selector_widget', 'icl_language_selector'); add_shortcode('wpml_language_selector_footer', 'icl_language_selector_footer'); add_filter('get_search_form', array($this, 'get_search_form_filter')); $this->api_hooks(); add_action('wpml_loaded', array($this, 'load_dependencies'), 10000); do_action('wpml_after_startup'); }
private static function update_tm_settings($config, $section_singular, $section_plural) { $config['wpml-config'] = array_filter($config['wpml-config']); if (!isset($config['wpml-config'][$section_plural]) || !isset($config['wpml-config'][$section_plural][$section_singular])) { return false; } $iclTranslationManagement = wpml_load_core_tm(); $read_only_section = $section_plural . '_readonly_config'; self::sync_settings($config, $section_singular, $section_plural, $read_only_section); // taxonomies - check what's been removed if (!empty($iclTranslationManagement->settings[$read_only_section])) { $config_values = array(); foreach ($config['wpml-config'][$section_plural][$section_singular] as $config_value) { $config_values[$config_value['value']] = $config_value['attr']['translate']; } foreach ($iclTranslationManagement->settings[$read_only_section] as $key => $translation_option) { if (!isset($config_values[$key])) { unset($iclTranslationManagement->settings[$read_only_section][$key]); } } $iclTranslationManagement->save_settings(); } }
/** * @param $post_id * @param $taxonomy * Synchronizes a posts taxonomy term's languages with the posts language for all translations of the post. * */ public static function sync_post_and_taxonomy_terms_language($post_id, $taxonomy) { global $sitepress; $post = get_post($post_id); $post_type = $post->post_type; $post_trid = $sitepress->get_element_trid($post_id, 'post_' . $post_type); $post_translations = $sitepress->get_element_translations($post_trid, 'post_' . $post_type); $terms_from_original_post = wp_get_post_terms($post_id, $taxonomy); $is_original = true; if ($sitepress->get_original_element_id($post_id, 'post_' . $post_type) != $post_id) { $is_original = false; } foreach ($post_translations as $post_language => $translated_post) { $translated_post_id = $translated_post->element_id; if (!$translated_post_id) { continue; } $terms_from_translated_post = wp_get_post_terms($translated_post_id, $taxonomy); if ($is_original) { /** @var $iclTranslationManagement TranslationManagement */ $iclTranslationManagement = wpml_load_core_tm(); $duplicates = $iclTranslationManagement->get_duplicates($post_id); if (in_array($translated_post_id, $duplicates)) { $terms = array_merge($terms_from_original_post, $terms_from_translated_post); } else { $terms = $terms_from_translated_post; } } else { $terms = $terms_from_translated_post; } foreach ((array) $terms as $term) { $term_original_tax_id = $term->term_taxonomy_id; $original_term_language_object = $sitepress->get_element_language_details($term_original_tax_id, 'tax_' . $term->taxonomy); if ($original_term_language_object && isset($original_term_language_object->language_code)) { $original_term_language = $original_term_language_object->language_code; } else { $original_term_language = $post_language; } if ($original_term_language != $post_language) { $term_trid = $sitepress->get_element_trid($term_original_tax_id, 'tax_' . $term->taxonomy); $translated_terms = $sitepress->get_element_translations($term_trid, 'tax_' . $term->taxonomy, false, false, true); $term_id = $term->term_id; wp_remove_object_terms($translated_post_id, (int) $term_id, $taxonomy); if (isset($translated_terms[$post_language])) { $term_in_correct_language = $translated_terms[$post_language]; wp_set_post_terms($translated_post_id, array((int) $term_in_correct_language->term_id), $taxonomy, true); } if (isset($term->term_taxonomy_id)) { wp_update_term_count($term->term_taxonomy_id, $taxonomy); } } wp_update_term_count($term_original_tax_id, $taxonomy); } } }
/** * Load \TranslationManagement class. */ public function load_core_tm() { $iclTranslationManagement = wpml_load_core_tm(); }
public function get_tm_instance() { return wpml_load_core_tm(); }
function __construct(&$networking) { wpml_load_core_tm(); $this->networking = $networking; }