You are here

public static function InstapageCmsPluginHelper::isCustomParamPresent in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/InstapageCmsPluginHelper.php \InstapageCmsPluginHelper::isCustomParamPresent()

Checks if one of the custom params, stored in plugin's settings, are present in curent URL.

Return value

boolean

3 calls to InstapageCmsPluginHelper::isCustomParamPresent()
InstapageCmsPluginDrupal7Connector::isHtmlReplaceNecessary in core/connectors/InstapageCmsPluginDrupal7Connector.php
Checks if there is a need to replace content of CMS with a landing page. Prevents content replacement on admin/login pages.
InstapageCmsPluginDrupal8Connector::isHtmlReplaceNecessary in core/connectors/InstapageCmsPluginDrupal8Connector.php
Checks if there is a need to replace content of CMS with a landing page. Prevents content replacement on admin/login pages.
InstapageCmsPluginWPConnector::isHtmlReplaceNecessary in core/connectors/InstapageCmsPluginWPConnector.php
Checks if there is a need to replace content of CMS with a landing page. Prevents content replacement on admin/login pages.

File

core/InstapageCmsPluginHelper.php, line 213

Class

InstapageCmsPluginHelper
Helper containing commonly used static functions.

Code

public static function isCustomParamPresent() {
  $slug = self::extractSlug(InstapageCmsPluginConnector::getHomeUrl());
  $defaultExcludedParams = array(
    's' => null,
    'post_type' => null,
    'preview' => 'true',
  );
  $customParamsOption = explode('|', stripslashes(self::getOption('customParams', '')));
  $customParams = array();
  $paramArr = null;
  $key = null;
  $value = null;
  foreach ($customParamsOption as $param) {
    $paramArr = explode('=', $param);
    $key = isset($paramArr[0]) ? $paramArr[0] : null;
    $value = isset($paramArr[1]) ? str_replace('"', '', $paramArr[1]) : null;
    $customParams[$key] = $value;
  }
  if (count($customParams)) {
    $excludedParams = array_merge($defaultExcludedParams, $customParams);
  }
  foreach ($excludedParams as $key => $value) {
    $isDefaultParam = array_key_exists($key, $defaultExcludedParams) ? true : false;
    if (!empty($key) && $value == null && (isset($_GET[$key]) || !$isDefaultParam && strpos($slug, $key) !== false) || !empty($key) && $value !== null && isset($_GET[$key]) && $_GET[$key] == $value) {
      return true;
    }
  }
  return false;
}