function fn_twigmo_before_dispatch() { if ($_SERVER['REQUEST_METHOD'] == 'POST' || AREA != 'C' || !fn_twg_is_updated() || !TwigmoConnector::frontendIsConnected() || empty($_SERVER['HTTP_USER_AGENT']) || defined('AJAX_REQUEST') || $_REQUEST['dispatch'] == 'image.captcha') { return; } if (!isset($_SESSION['twg_state'])) { $_SESSION['twg_state'] = array(); } $state = $_SESSION['twg_state'] = fn_twg_get_frontend_state($_REQUEST, $_SESSION['twg_state'], TwigmoSettings::get()); if (!$state['twg_is_used']) { return; } if (fn_twg_use_https_for_customer() && !defined('HTTPS')) { fn_redirect(Registry::get('config.https_location') . '/' . Registry::get('config.current_url')); } $local_jsurl = Registry::get('config.twg.jsurl'); $template = $local_jsurl ? 'mobile_index_dev.tpl' : 'mobile_index.tpl'; Registry::set('runtime.root_template', 'addons/twigmo/' . $template); Registry::set('runtime.inside_scripts', 1); $view = fn_twg_get_view_object(); $view->assign('urls', TwigmoConnector::getMobileScriptsUrls($local_jsurl)); $view->assign('repo_revision', TwigmoSettings::get('repo_revision')); $view->assign('twg_state', $state); fn_twg_assign_google_template(); if ($state['theme_editor_mode']) { header("X-Frame-Options: "); } }