_campaign'], FILTER_CALLBACK, array('options' => [$this, 'sanitizeUTM'])); if ($utmCampaign !== '') { $_SESSION['utm_tags']['campaign'] = $utmCampaign; setcookie("utm_campaign", $utmCampaign, strtotime('+30 days'), '/', esc_url_raw($_SERVER['HTTP_HOST'])); } } if (isset($_GET['utm_term'])) { $utmTerm = filter_var($_GET['utm_term'], FILTER_CALLBACK, array('options' => [$this, 'sanitizeUTM'])); if ($utmTerm !== '') { $_SESSION['utm_tags']['term'] = $utmTerm; setcookie("utm_term", $utmTerm, strtotime('+30 days'), '/', esc_url_raw($_SERVER['HTTP_HOST'])); } } if (isset($_GET['utm_content'])) { $utmContent = filter_var($_GET['utm_content'], FILTER_CALLBACK, array('options' => [$this, 'sanitizeUTM'])); if ($utmContent !== '') { $_SESSION['utm_tags']['content'] = $utmContent; setcookie("utm_content", $utmContent, strtotime('+30 days'), '/', esc_url_raw($_SERVER['HTTP_HOST'])); } } /** * Save referer in session */ if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== NULL) { $refererUrl = filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL); $siteUrl = home_url(); // Check if refer is not itself if (strpos($refererUrl, $siteUrl) === false) { $refererParsed = parse_url($refererUrl); $_SESSION['otys_referer'] = isset($refererParsed['host']) ? str_replace(['https://', 'http://', 'www.'], '', $refererParsed['host']) : NULL; } } } /** * Create custom ajax Actions * * @return void * @since 1.2.0 */ public function initCustomAjaxActions(): void { Hooks::addAction('wp_ajax_otys_vvc', '\Otys\OtysPlugin\Controllers\VacanciesController', 'trackView', 10, 1); Hooks::addAction('wp_ajax_nopriv_otys_vvc', '\Otys\OtysPlugin\Controllers\VacanciesController', 'trackView', 10, 1); } /** * Version checker. * This checker is responsible for breaking * * @return void * @since 1.2.6 */ public function versionCheck(): void { if (is_admin()) { $updater = new \Otys\OtysPlugin\Includes\Core\Updater(); $updater->check(); } } /** * Register rest calls */ public static function registerRest() { add_action('rest_api_init', function () { register_rest_route('otys/v1', '/apply', array( 'methods' => 'POST', 'callback' => ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesApplyController', 'restPost'], 'permission_callback' => '__return_true' )); register_rest_route('otys/v1', '/vacancy/analytics', array( 'methods' => 'POST', 'callback' => ['\Otys\OtysPlugin\Controllers\VacanciesDetailController', 'track'], 'permission_callback' => '__return_true' )); }); } /** * Register shortcodes * * @since 2.0.0 * @return void */ public static function registerShortcodes() { add_shortcode( 'otys-vacancies-list', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesListController', 'callback'] ); Hooks::addAction('template_redirect', VacanciesListController::class, 'filterStatusCode', 10, 0); add_shortcode( 'otys-vacancies-filters', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesFiltersController', 'callback'] ); add_shortcode( 'otys-vacancies-shortlist', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesShortlistController', 'callback'] ); add_shortcode( 'otys-vacancies-search', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesSearchController', 'callback'] ); Hooks::addAction('template_redirect', VacanciesSearchController::class, 'filterPost', 10, 0); add_shortcode( 'otys-vacancies-geo-search', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesGeoSearchController', 'callback'] ); add_shortcode( 'otys-vacancies-selected-filters', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesSelectedFiltersController', 'callback'] ); add_shortcode( 'otys-vacancies-apply', ['\Otys\OtysPlugin\Controllers\Shortcodes\VacanciesApplyController', 'callback'] ); add_shortcode( 'otys-interactions', ['\Otys\OtysPlugin\Controllers\Shortcodes\InteractionsController', 'callback'] ); } }