function __construct()
 {
     do_action('wpml_before_startup');
     global $wpdb, $pagenow;
     $this->settings = get_option('icl_sitepress_settings');
     //@tODO: To remove in WPML 3.5
     //@since 3.1
     if (is_admin() && !$this->get_setting('icl_capabilities_verified')) {
         icl_enable_capabilities();
         $this->settings = get_option('icl_sitepress_settings');
     }
     // set up current user early
     // no authentication
     if (defined('LOGGED_IN_COOKIE') && isset($_COOKIE[LOGGED_IN_COOKIE])) {
         list($username) = explode('|', $_COOKIE[LOGGED_IN_COOKIE]);
         $user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_login = %s", array($username)));
     } else {
         $user_id = 0;
     }
     $this->current_user = new WP_User($user_id);
     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['icl_action'])) {
         require_once ABSPATH . WPINC . '/pluggable.php';
         if ($_GET['icl_action'] == 'reminder_popup') {
             add_action('init', array($this, 'reminders_popup'));
         } elseif ($_GET['icl_action'] == 'dismiss_help') {
             $this->settings['dont_show_help_admin_notice'] = true;
             $this->save_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'));
     }
     add_action('plugins_loaded', array($this, 'initialize_cache'), 0);
     add_action('plugins_loaded', array($this, 'init'), 1);
     add_action('init', array($this, 'on_wp_init'), 1);
     add_action('admin_print_scripts', array($this, 'js_scripts_setup'));
     add_action('admin_print_styles', array($this, 'css_setup'));
     // 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'));
     //add_filter('tag_template', array($this, 'load_taxonomy_template'));
     if ($this->settings['existing_content_language_verified'] && ($this->settings['setup_complete'] || !empty($_GET['page']) && $this->settings['setup_wizard_step'] == 3 && $_GET['page'] == ICL_PLUGIN_FOLDER . '/menu/languages.php')) {
         // Post/page language box
         if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') {
             add_action('admin_head', array($this, 'post_edit_language_options'));
         }
         //For when it will be possible to add custom bulk actions
         //add_action( 'bulk_actions-edit-post', array( $this, 'bulk_actions' ) );
         // Post/page save actions
         add_action('save_post', array($this, 'save_post_actions'), 100, 2);
         add_action('updated_post_meta', array($this, 'update_post_meta'), 100, 4);
         add_action('added_post_meta', array($this, 'update_post_meta'), 100, 4);
         add_action('updated_postmeta', array($this, 'update_post_meta'), 100, 4);
         // ajax
         add_action('added_postmeta', array($this, 'update_post_meta'), 100, 4);
         // ajax
         add_action('delete_postmeta', array($this, 'delete_post_meta'));
         // ajax
         // Post/page delete actions
         //            add_action('delete_post', array($this,'delete_post_actions'));
         add_action('before_delete_post', array($this, 'before_delete_post_actions'));
         add_action('deleted_post', array($this, 'deleted_post_actions'));
         add_action('wp_trash_post', array($this, 'trash_post_actions'));
         add_action('untrashed_post', array($this, 'untrashed_post_actions'));
         add_filter('posts_join', array($this, 'posts_join_filter'), 10, 2);
         add_filter('posts_where', array($this, 'posts_where_filter'), 10, 2);
         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_action('loop_start', array($this, 'loop_start'), 10);
         add_filter('the_posts', array($this, 'the_posts'), 10);
         add_filter('get_pages', array($this, 'get_pages'), 100, 2);
         // Filter links to the root page
         add_filter('page_link', array('WPML_Root_Page', 'filter_root_permalink'), 10, 2);
         add_filter('the_preview', array('WPML_Root_Page', 'front_page_id_filter'), 10, 2);
         if ($pagenow == 'edit.php') {
             add_action('admin_footer', array($this, 'language_filter'));
             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'));
         // posts and pages links filters
         add_filter('post_link', array($this, 'permalink_filter'), 1, 2);
         add_filter('post_type_link', array($this, 'permalink_filter'), 1, 2);
         add_filter('page_link', array($this, 'permalink_filter'), 1, 2);
         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();
         // The delete filter only ensures the synchronizing of delete actions beween translations of a term.
         add_action('delete_term', array('WPML_Terms_Translations', 'delete_term_filter'), 1, 3);
         add_filter('pre_term_slug', array('WPML_Terms_Translations', 'pre_term_slug_filter'), 10, 2);
         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_get_post_parent_id_by_lang', array('WPML_Post_Edit_Ajax', 'wpml_get_post_parent_id_by_lang'));
         add_action('wp_ajax_wpml_get_taxonomy_terms_json', array('WPML_Post_Edit_Ajax', 'wpml_get_taxonomy_terms_json'));
         add_action('wp_ajax_wpml_save_term', array('WPML_Post_Edit_Ajax', 'wpml_save_term'));
         add_action('wp_ajax_wpml_remove_terms_from_post', array('WPML_Post_Edit_Ajax', 'wpml_remove_terms_from_post'));
         add_action('wp_ajax_wpml_switch_post_language', array('WPML_Post_Edit_Ajax', 'wpml_switch_post_language'));
         add_action('wp_ajax_wpml_before_switch_post_language', array('WPML_Post_Edit_Ajax', 'wpml_before_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_translated_taxonomies', array('WPML_Post_Edit_Ajax', 'wpml_get_translated_taxonomies'));
         add_action('wp_ajax_wpml_get_translations_table_data', array('WPML_Post_Edit_Ajax', 'wpml_get_translations_table_data'));
         add_action('wp_ajax_wpml_get_post_permalink', array('WPML_Post_Edit_Ajax', 'wpml_get_post_permalink'));
         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'));
         add_action('wp_ajax_wpml_tt_save_labels_translation', array('WPML_Taxonomy_Translation', 'save_labels_translation'));
         // 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);
         add_action('after-category-table', array('WPML_Terms_Translations', 'category_display_action'), 1, 1);
         // custom hook for adding the language selector to the template
         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'));
         add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 1, 3);
         // 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'));
         add_filter('wp_unique_post_slug', array($this, 'wp_unique_post_slug'), 100, 5);
         add_filter('home_url', array($this, 'home_url'), 1, 4);
         // language negotiation
         add_action('query_vars', array($this, 'query_vars'));
         add_filter('language_attributes', array($this, 'language_attributes'));
         add_action('locale', array($this, 'locale'));
         if (isset($_GET['____icl_validate_domain'])) {
             echo '<!--' . get_home_url() . '-->';
             exit;
         }
         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('option_sticky_posts', array($this, 'option_sticky_posts'));
         add_filter('request', array($this, 'request_filter'));
         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();
         if (is_admin() || defined('XMLRPC_REQUEST') || preg_match('#wp-comments-post\\.php$#', $_SERVER['REQUEST_URI'])) {
             global $iclTranslationManagement, $ICL_Pro_Translation;
             $iclTranslationManagement = new TranslationManagement();
             $ICL_Pro_Translation = new ICL_Pro_Translation();
         }
         add_action('wp_login', array($this, 'reset_admin_language_cookie'));
         if ($this->settings['seo']['canonicalization_duplicates']) {
             add_action('template_redirect', array($this, 'setup_canonical_urls'), 100);
         }
         add_action('init', array($this, '_taxonomy_languages_menu'), 99);
         //allow hooking in
         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'));
     if (is_admin() && $pagenow == 'index.php') {
         add_action('icl_dashboard_widget_notices', array($this, 'print_translatable_custom_content_status'));
     }
     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('get_pagenum_link', array($this, 'get_pagenum_link'));
     add_action('switch_blog', array($this, 'init_settings'));
     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'));
     add_action('plugins_loaded', array($this, 'load_dependencies'), 10000);
     do_action('wpml_after_startup');
 }
Esempio n. 2
0
 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');
 }
Esempio n. 3
0
function icl_sitepress_activate()
{
    global $wpdb;
    $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 {
        SitePress_Setup::fill_languages();
        SitePress_Setup::fill_languages_translations();
        SitePress_Setup::fill_flags();
        // 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                KEY `id_type_language` (`element_id`, `element_type`, `language_code`)\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                 `batch_id` int DEFAULT 0 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( 160 ) 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);
            }
        }
        // batches table
        $table_name = $wpdb->prefix . 'icl_translation_batches';
        if (0 !== strcasecmp($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'"), $table_name)) {
            $sql = "\r\n                 CREATE TABLE IF NOT EXISTS {$wpdb->prefix}icl_translation_batches (\r\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n                  `batch_name` text NOT NULL,\r\n                  `tp_id` int NULL,\r\n                  `ts_url` text NULL,\r\n                  `last_update` DATETIME NULL,\r\n                  PRIMARY KEY (`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);
            }
        }
        /* 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(" . WPML_STRING_TABLE_NAME_CONTEXT_LENGTH . ") CHARACTER SET UTF8 NOT NULL,\r\n                  `name` varchar(" . WPML_STRING_TABLE_NAME_CONTEXT_LENGTH . ") CHARACTER SET UTF8 NOT NULL,\r\n                  `value` text NOT NULL,\r\n                  `string_package_id` BIGINT unsigned NULL,\r\n                  `type` VARCHAR(40) NOT NULL DEFAULT 'LINE',\r\n                  `title` VARCHAR(160) 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_service` varchar(16) DEFAULT '' NOT NULL,\r\n                  `batch_id` int DEFAULT 0 NOT 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;
    }
    // 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();
    //Set cron job to update WPML config index file from CDN
    wp_schedule_event(time(), 'daily', 'update_wpml_config_index');
    do_action('wpml_activated');
}
Esempio n. 4
0
 function __construct()
 {
     global $wpdb, $pagenow;
     $this->settings = get_option('icl_sitepress_settings');
     //TODO: To remove in WPML 3.5
     //@since 3.1
     if (is_admin() && !$this->get_setting('icl_capabilities_verified')) {
         icl_enable_capabilities();
         $this->settings = get_option('icl_sitepress_settings');
     }
     // set up current user early
     // no authentication
     if (defined('LOGGED_IN_COOKIE') && isset($_COOKIE[LOGGED_IN_COOKIE])) {
         list($username) = explode('|', $_COOKIE[LOGGED_IN_COOKIE]);
         $user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE user_login = %s", array($username)));
     } else {
         $user_id = 0;
     }
     $this->current_user = new WP_User($user_id);
     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['icl_action'])) {
         require_once ABSPATH . WPINC . '/pluggable.php';
         if ($_GET['icl_action'] == 'reminder_popup') {
             add_action('init', array($this, 'reminders_popup'));
         } elseif ($_GET['icl_action'] == 'dismiss_help') {
             $this->settings['dont_show_help_admin_notice'] = true;
             $this->save_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'));
     }
     add_action('plugins_loaded', array($this, 'initialize_cache'), 0);
     add_action('plugins_loaded', array($this, 'init'), 1);
     add_action('init', array($this, 'on_wp_init'), 1);
     add_action('admin_print_scripts', array($this, 'js_scripts_setup'));
     add_action('admin_print_styles', array($this, 'css_setup'));
     // 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'));
     //add_filter('tag_template', array($this, 'load_taxonomy_template'));
     if ($this->settings['existing_content_language_verified']) {
         // Post/page language box
         if ($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') {
             add_action('admin_head', array($this, 'post_edit_language_options'));
         }
         //For when it will be possible to add custom bulk actions
         //add_action( 'bulk_actions-edit-post', array( $this, 'bulk_actions' ) );
         // Post/page save actions
         add_action('save_post', array($this, 'save_post_actions'), 10, 2);
         //post/page delete taxonomy
         add_action('deleted_term_relationships', array($this, 'deleted_term_relationships'), 10, 2);
         add_action('updated_post_meta', array($this, 'update_post_meta'), 100, 4);
         add_action('added_post_meta', array($this, 'update_post_meta'), 100, 4);
         add_action('updated_postmeta', array($this, 'update_post_meta'), 100, 4);
         // ajax
         add_action('added_postmeta', array($this, 'update_post_meta'), 100, 4);
         // ajax
         add_action('delete_postmeta', array($this, 'delete_post_meta'));
         // ajax
         // filter user taxonomy input
         add_filter('pre_post_tax_input', array($this, 'validate_taxonomy_input'));
         // Post/page delete actions
         //            add_action('delete_post', array($this,'delete_post_actions'));
         add_action('before_delete_post', array($this, 'before_delete_post_actions'));
         add_action('deleted_post', array($this, 'deleted_post_actions'));
         add_action('wp_trash_post', array($this, 'trash_post_actions'));
         add_action('untrashed_post', array($this, 'untrashed_post_actions'));
         add_filter('posts_join', array($this, 'posts_join_filter'), 10, 2);
         add_filter('posts_where', array($this, 'posts_where_filter'), 10, 2);
         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_action('loop_start', array($this, 'loop_start'), 10);
         add_filter('the_posts', array($this, 'the_posts'), 10);
         add_filter('get_pages', array($this, 'get_pages'), 100, 2);
         if ($pagenow == 'edit.php') {
             add_action('admin_footer', array($this, 'language_filter'));
         }
         add_filter('get_pages', array($this, 'exclude_other_language_pages2'));
         add_filter('wp_dropdown_pages', array($this, 'wp_dropdown_pages'));
         // posts and pages links filters
         add_filter('post_link', array($this, 'permalink_filter'), 1, 2);
         add_filter('post_type_link', array($this, 'permalink_filter'), 1, 2);
         add_filter('page_link', array($this, 'permalink_filter'), 1, 2);
         add_filter('get_comment_link', array($this, 'get_comment_link_filter'));
         //Taxonomies
         if (version_compare(preg_replace('#-RC[0-9]+(-[0-9]+)?$#', '', $GLOBALS['wp_version']), '3.1', '<')) {
             add_filter('category_link', array($this, 'category_permalink_filter'), 1, 2);
             add_filter('tag_link', array($this, 'tax_permalink_filter'), 1, 2);
         }
         add_filter('term_link', array($this, 'tax_permalink_filter'), 1, 2);
         add_action('create_term', array($this, 'create_term'), 1, 2);
         add_action('edit_term', array($this, 'create_term'), 1, 2);
         add_action('delete_term', array($this, 'delete_term'), 1, 3);
         add_action('get_term', array($this, 'get_term_filter'), 1, 2);
         add_filter('get_terms_args', array($this, 'get_terms_args_filter'));
         // filters terms by language
         add_filter('terms_clauses', array($this, 'terms_clauses'), 10, 4);
         add_filter('list_terms_exclusions', array($this, 'exclude_other_terms'), 1, 2);
         // allow adding terms with the same name in different languages
         add_filter("pre_term_name", array($this, 'pre_term_name'), 1, 2);
         // allow adding categories with the same name in different languages
         add_action('admin_init', array($this, 'pre_save_category'));
         //Hooking to 'option_{taxonomy}_children' to translate taxonomy children
         //			global $wp_taxonomies;
         //			foreach ( $wp_taxonomies as $tax_key => $tax ) {
         //				if ( $this->is_translated_taxonomy( $tax_key ) && is_taxonomy_hierarchical($tax_key) ) {
         //					add_filter("option_{$tax_key}_children", array($this, 'option_taxonomy_children'), 10 );
         //					add_filter("pre_update_option_{$tax_key}_children", array($this, 'pre_update_option_taxonomy_children'), 10, 2 );
         //				}
         //			}
         add_filter('get_edit_term_link', array($this, 'get_edit_term_link'), 1, 4);
         // 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);
         add_filter('the_category', array($this, 'the_category_name_filter'));
         add_filter('get_terms', array($this, 'get_terms_filter'));
         add_filter('get_the_terms', array($this, 'get_the_terms_filter'), 10, 3);
         add_filter('single_cat_title', array($this, 'the_category_name_filter'));
         add_filter('term_links-category', array($this, 'the_category_name_filter'));
         add_filter('term_links-post_tag', array($this, 'the_category_name_filter'));
         add_filter('tags_to_edit', array($this, 'the_category_name_filter'));
         add_filter('single_tag_title', array($this, 'the_category_name_filter'));
         // custom hook for adding the language selector to the template
         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'));
         add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 1, 3);
         // 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'));
         add_filter('wp_unique_post_slug', array($this, 'wp_unique_post_slug'), 100, 5);
         add_filter('home_url', array($this, 'home_url'), 1, 4);
         // language negotiation
         add_action('query_vars', array($this, 'query_vars'));
         add_filter('language_attributes', array($this, 'language_attributes'));
         add_action('locale', array($this, 'locale'));
         if (isset($_GET['____icl_validate_domain'])) {
             echo '<!--' . get_home_url() . '-->';
             exit;
         }
         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('option_sticky_posts', array($this, 'option_sticky_posts'));
         add_filter('request', array($this, 'request_filter'));
         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
         // adjust queried categories and tags ids according to the language
         if ($this->settings['auto_adjust_ids']) {
             add_action('parse_query', array($this, 'parse_query'));
             add_action('wp_list_pages_excludes', array($this, 'adjust_wp_list_pages_excludes'));
             if (!is_admin()) {
                 add_filter('get_term', array($this, 'get_term_adjust_id'), 1, 1);
                 add_filter('category_link', array($this, 'category_link_adjust_id'), 1, 2);
                 add_filter('get_terms', array($this, 'get_terms_adjust_ids'), 1, 3);
                 add_filter('get_pages', array($this, 'get_pages_adjust_ids'), 1, 2);
             }
         }
         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();
         if (is_admin() || defined('XMLRPC_REQUEST') || preg_match('#wp-comments-post\\.php$#', $_SERVER['REQUEST_URI'])) {
             global $iclTranslationManagement, $ICL_Pro_Translation;
             $iclTranslationManagement = new TranslationManagement();
             $ICL_Pro_Translation = new ICL_Pro_Translation();
         }
         add_action('wp_login', array($this, 'reset_admin_language_cookie'));
         if ($this->settings['seo']['canonicalization_duplicates']) {
             add_action('template_redirect', array($this, 'setup_canonical_urls'), 100);
         }
         add_filter('taxonomy_template', array($this, 'slug_template'));
         add_filter('category_template', array($this, 'slug_template'));
         add_action('init', array($this, '_taxonomy_languages_menu'), 99);
         //allow hooking in
         if ($this->settings['seo']['head_langs']) {
             add_action('wp_head', array($this, 'head_langs'));
         }
     }
     //end if the initial language is set - existing_content_language_verified
     add_action('wp_dashboard_setup', array($this, 'dashboard_widget_setup'));
     if (is_admin() && $pagenow == 'index.php') {
         add_action('icl_dashboard_widget_notices', array($this, 'print_translatable_custom_content_status'));
     }
     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('get_pagenum_link', array($this, 'get_pagenum_link'));
 }
Esempio n. 5
0
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();
}