You are here

public function InstapageCmsPluginDrupal8Connector::getSiteURL in Instapage plugin 8.3

Same name and namespace in other branches
  1. 7.3 core/connectors/InstapageCmsPluginDrupal8Connector.php \InstapageCmsPluginDrupal8Connector::getSiteURL()

Gets the site base URL.

Parameters

bool $protocol Value returned with protocol or not.:

Return value

string Site base URL. With protocol or not.

4 calls to InstapageCmsPluginDrupal8Connector::getSiteURL()
InstapageCmsPluginDrupal8Connector::getAjaxURL in core/connectors/InstapageCmsPluginDrupal8Connector.php
Gets the AJAX URL.
InstapageCmsPluginDrupal8Connector::getHomeURL in core/connectors/InstapageCmsPluginDrupal8Connector.php
Gets the site home URL.
InstapageCmsPluginDrupal8Connector::getPostSlugs in core/connectors/InstapageCmsPluginDrupal8Connector.php
Gets the list of slugs used by Drupal 8 posts.
InstapageCmsPluginDrupal8Connector::isProhibitedPostSlug in core/connectors/InstapageCmsPluginDrupal8Connector.php
Checks if given slug is prohibited in terms of publishing a landing page. If it's free - will return false. Otherwise an array with slug details will be returned

File

core/connectors/InstapageCmsPluginDrupal8Connector.php, line 361

Class

InstapageCmsPluginDrupal8Connector
Class that utilizes native Drupal 8 functions to perform actions like remote requests and DB operations.

Code

public function getSiteURL($protocol = true) {
  $url = $_SERVER['HTTP_HOST'];
  if ($protocol) {
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
      $url = 'https://' . $url;
    }
    else {
      $url = 'http://' . $url;
    }
  }
  if (isset($_SERVER['PHP_SELF'])) {
    $directory = ltrim(dirname($_SERVER['PHP_SELF']), DIRECTORY_SEPARATOR);
    if (!empty($directory)) {
      $url .= $directory;
    }
  }
  return $url;
}