/**
  * Initial setup handler.
  *
  * @global	$wpdb wpdb WordPress Database Wrapper
  * @global	$pagenow string Current Page Wrapper
  * @return void
  */
 public function setup()
 {
     global $pagenow;
     $this->link_table = $this->wpdb->base_prefix . 'multilingual_linked';
     $this->plugin_dir_path = $this->plugin_data->plugin_dir_path;
     $this->plugin_file_path = $this->plugin_data->plugin_file_path;
     $this->plugin_data->module_manager = new Mlp_Module_Manager('state_modules');
     $this->plugin_data->site_manager = new Mlp_Module_Manager('inpsyde_multilingual');
     $this->plugin_data->link_table = $this->link_table;
     $this->plugin_data->content_relations = new Mlp_Content_Relations($this->wpdb, $this->plugin_data->site_relations, $this->link_table);
     $this->plugin_data->language_api = new Mlp_Language_Api($this->plugin_data, 'mlp_languages', $this->plugin_data->site_relations, $this->plugin_data->content_relations, $this->wpdb);
     $this->plugin_data->assets = new Mlp_Assets($this->plugin_data->locations);
     $this->load_assets();
     Mlp_Helpers::$link_table = $this->link_table;
     Mlp_Helpers::insert_dependency('site_relations', $this->plugin_data->site_relations);
     Mlp_Helpers::insert_dependency('language_api', $this->plugin_data->language_api);
     Mlp_Helpers::insert_dependency('plugin_data', $this->plugin_data);
     $this->plugin_data->freeze();
     // no changes allowed anymore
     require 'functions.php';
     // This check prevents the use of this plugin in a not-setted blog
     if ('admin-post.php' != $pagenow && 'admin-ajax.php' != $pagenow && !is_network_admin() && !array_key_exists(get_current_blog_id(), get_site_option('inpsyde_multilingual', array()))) {
         return;
     }
     // The Plugins Basename
     // used by features/class-Multilingual_Press_Auto_Update.php only
     self::$plugin_base_name = $this->plugin_data->plugin_base_name;
     // The Plugins URL
     self::$plugin_url = $this->plugin_data->plugin_uri;
     // The Plugins Name
     self::$plugin_name = $this->plugin_data->plugin_name;
     // Textdomain Path
     self::$textdomainpath = $this->plugin_data->text_domain_path;
     // Hooks and filters
     add_action('inpsyde_mlp_loaded', array($this, 'load_plugin_textdomain'), 1);
     // Load modules
     $this->load_features();
     /**
      * Kick-Off Init
      * @return  Void
      */
     do_action('inpsyde_mlp_init', $this->plugin_data);
     // Enqueue scripts
     add_action('admin_enqueue_scripts', array($this, 'admin_scripts'));
     // Cleanup upon blog delete
     add_filter('delete_blog', array($this, 'delete_blog'), 10, 2);
     // Checkup blog cleanup
     add_filter('admin_head', array($this, 'checkup_blog_message'));
     add_filter('wp_ajax_checkup_blogs', array($this, 'checkup_blog'));
     // Check for errors
     add_filter('all_admin_notices', array($this, 'check_for_user_errors_admin_notice'));
     add_action('wp_loaded', array($this, 'late_load'), 0);
     /**
      * Everything loaded
      * @param   Inpsyde_Property_List_Interface
      */
     do_action('inpsyde_mlp_loaded', $this->plugin_data);
     if (is_admin()) {
         if ($this->plugin_data->module_manager->has_modules()) {
             $this->load_module_settings_page();
         }
         if ($this->plugin_data->site_manager->has_modules()) {
             $this->load_site_settings_page();
         }
         new Mlp_Network_Site_Settings_Controller($this->plugin_data);
         new Mlp_Network_New_Site_Controller($this->plugin_data->language_api, $this->plugin_data->site_relations);
     } else {
         // frontend-hooks
         $hreflang = new Mlp_Hreflang_Header_Output($this->plugin_data->language_api);
         add_action('template_redirect', array($hreflang, 'http_header'));
         add_action('wp_head', array($hreflang, 'wp_head'));
     }
 }
 /**
  * init function to register all used hooks,
  * load class files and set parameters
  * such as the database table
  *
  * @access  public
  * @since   0.1
  * @uses	add_filter, get_site_option, is_multisite, is_super_admin,
  * 			do_action, apply_filters
  * @global	$wpdb | WordPress Database Wrapper
  * @global	$pagenow | Current Page Wrapper
  * @return  void
  */
 public function __construct()
 {
     global $pagenow;
     // This check prevents using this plugin not in a multisite
     if (function_exists('is_multisite') && !is_multisite() && is_super_admin()) {
         add_filter('admin_notices', array($this, 'error_msg_no_multisite'));
         return;
     }
     // This check prevents the use of this plugin in a not-setted blog
     if ('admin-post.php' != $pagenow && 'admin-ajax.php' != $pagenow && !is_network_admin() && !array_key_exists(get_current_blog_id(), get_site_option('inpsyde_multilingual', array()))) {
         return;
     }
     // The Plugins Basename
     self::$plugin_base_name = plugin_basename(__FILE__);
     // The Plugins URL
     self::$plugin_url = $this->get_plugin_header('PluginURI');
     // The Plugins Name
     self::$plugin_name = $this->get_plugin_header('Name');
     // Textdomain Path
     self::$textdomainpath = $this->get_domain_path();
     global $wpdb;
     // Show database errors
     // (only for development)
     $wpdb->show_errors();
     // Set linked elements table
     $this->link_table = $wpdb->base_prefix . 'multilingual_linked';
     // Load classes
     $this->include_files();
     // Kick-Off Init
     do_action('inpsyde_mlp_init');
     // Hooks and filters
     add_filter('init', array($this, 'load_plugin_textdomain'));
     // Enqueue scripts
     add_filter('admin_enqueue_scripts', array($this, 'admin_scripts'));
     add_filter('wp_enqueue_scripts', array($this, 'wp_styles'));
     // AJAX hooks for the tab form and the meta boxes
     add_filter('wp_ajax_tab_form', array($this, 'draw_blog_settings_form'));
     add_filter('wp_ajax_save_multilang_settings', array($this, 'update_blog_settings'));
     add_filter('wp_ajax_get_metabox_content', array($this, 'ajax_get_metabox_content'));
     // Context help of the plugin
     add_filter('contextual_help', array($this, 'context_help'), 10, 3);
     // Cleanup upon blog delete
     add_filter('delete_blog', array($this, 'delete_blog'), 10, 2);
     // Checkup blog cleanup
     add_filter('admin_head', array($this, 'checkup_blog_message'));
     add_filter('wp_ajax_checkup_blogs', array($this, 'checkup_blog'));
     // Check for errors
     add_filter('all_admin_notices', array($this, 'check_for_user_errors_admin_notice'));
     // Load modules
     $this->load_modules();
     if (TRUE == $this->check_for_user_errors()) {
         return;
     }
     // Does another plugin offer its own save method?
     $external_save_method = apply_filters('mlp_external_save_method', FALSE);
     if (!$external_save_method) {
         add_filter('save_post', array($this, 'save_post'), 10, 2);
     }
     // Add the meta box
     $get_metabox_handler = apply_filters('mlp_get_metabox_handler', array($this, 'add_meta_boxes'));
     add_filter('add_meta_boxes', $get_metabox_handler);
     // Everything loaded
     do_action('inpsyde_mlp_loaded');
 }