예제 #1
0
 /**
  * This function hooks all the remaining Nelio components to WordPress.
  *
  * It's a callback of the `init` action, and the reason its hooks are not
  * in the `NelioABController::init` method is because it ends up using a
  * WordPress function that is not available until this point.
  *
  * @return void
  *
  * @see self::init
  * @see self::can_visitor_be_in_experiment
  *
  * @since 2.0.10
  */
 public function do_init()
 {
     // We do not perform AB Testing for certain visitors:
     if (!$this->can_visitor_be_in_experiment()) {
         add_action('wp_enqueue_scripts', array(&$this, 'add_js_for_compatibility'), 10);
         return;
     }
     // Custom Permalinks Support: making sure that we are not redirected while
     // loading an alternative...
     require_once NELIOAB_UTILS_DIR . '/custom-permalinks-support.php';
     if (NelioABCustomPermalinksSupport::is_plugin_active()) {
         NelioABCustomPermalinksSupport::prevent_template_redirect();
     }
     // If we're previewing a page alternative, it may be the case that it's an
     // alternative of the landing page. Let's make sure the "page_on_front"
     // option is properly updated:
     if (isset($_GET['preview']) || isset($_GET['nelioab_show_heatmap'])) {
         add_filter('option_page_on_front', array(&$this, 'fix_page_on_front'));
     }
     // Add support for Google Analytics. Make sure GA tracking scripts are loaded
     // after Nelio's.
     require_once NELIOAB_UTILS_DIR . '/google-analytics-support.php';
     NelioABGoogleAnalyticsSupport::move_google_analytics_after_nelio();
     add_action('wp_enqueue_scripts', array(&$this, 'register_tracking_script'));
     add_action('wp_enqueue_scripts', array(&$this, 'load_tracking_script'), 99);
     add_action('pre_get_posts', array(&$this, 'save_main_query'));
     // LOAD ALL CONTROLLERS
     // Controller for changing a page using its alternatives:
     /** @var $aux NelioABAlternativeExperimentController */
     $aux = $this->controllers['alt-exp'];
     $aux->hook_to_wordpress();
 }