当前位置: 首页>>代码示例>>PHP>>正文


PHP Settings::getSubdomain方法代码示例

本文整理汇总了PHP中Settings::getSubdomain方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getSubdomain方法的具体用法?PHP Settings::getSubdomain怎么用?PHP Settings::getSubdomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings::getSubdomain方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addArrangementShortcode

 /**
  * Add the [recras-arrangement] shortcode
  *
  * @param array $attributes
  *
  * @return string
  */
 public static function addArrangementShortcode($attributes)
 {
     if (!isset($attributes['id'])) {
         return __('Error: no ID set', Plugin::TEXT_DOMAIN);
     }
     if (!ctype_digit($attributes['id'])) {
         return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
     }
     if (!isset($attributes['show'])) {
         return __('Error: "show" option not set', Plugin::TEXT_DOMAIN);
     }
     if (!in_array($attributes['show'], self::getValidOptions())) {
         return __('Error: invalid "show" option', Plugin::TEXT_DOMAIN);
     }
     $subdomain = Settings::getSubdomain($attributes);
     if (!$subdomain) {
         return Plugin::getNoSubdomainError();
     }
     $json = get_transient('recras_' . $subdomain . '_arrangement_' . $attributes['id']);
     if ($json === false) {
         try {
             $json = Http::get($subdomain, 'arrangementen/' . $attributes['id']);
         } catch (\Exception $e) {
             return $e->getMessage();
         }
         set_transient('recras_' . $subdomain . '_arrangement_' . $attributes['id'], $json, 86400);
     }
     switch ($attributes['show']) {
         case 'description':
             return $json->uitgebreide_beschrijving;
         case 'duration':
             return self::getDuration($json);
         case 'image_url':
             return $json->image_filename;
         case 'location':
             return self::getLocation($json);
         case 'persons':
             return '<span class="recras-persons">' . $json->aantal_personen . '</span>';
         case 'price_pp_excl_vat':
             return Price::format($json->prijs_pp_exc);
         case 'price_pp_incl_vat':
             return Price::format($json->prijs_pp_inc);
         case 'price_total_excl_vat':
             return Price::format($json->prijs_totaal_exc);
         case 'price_total_incl_vat':
             return Price::format($json->prijs_totaal_inc);
         case 'program':
         case 'programme':
             $startTime = isset($attributes['starttime']) ? $attributes['starttime'] : '00:00';
             $showHeader = !isset($attributes['showheader']) || Settings::parseBoolean($attributes['showheader']);
             return self::generateProgramme($json->programma, $startTime, $showHeader);
         case 'title':
             return '<span class="recras-title">' . $json->arrangement . '</span>';
         default:
             return __('Error: unknown option', Plugin::TEXT_DOMAIN);
     }
 }
开发者ID:recras,项目名称:recras-wordpress-plugin,代码行数:64,代码来源:Arrangement.php

示例2: addBookingShortcode

 /**
  * Add the [recras-booking] shortcode
  *
  * @param array $attributes
  *
  * @return string
  */
 public static function addBookingShortcode($attributes)
 {
     if (isset($attributes['id']) && !ctype_digit($attributes['id'])) {
         return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
     }
     $subdomain = Settings::getSubdomain($attributes);
     if (!$subdomain) {
         return Plugin::getNoSubdomainError();
     }
     $arrangementID = isset($attributes['id']) ? $attributes['id'] : null;
     return self::generateIframe($subdomain, $arrangementID);
 }
开发者ID:recras,项目名称:recras-wordpress-plugin,代码行数:19,代码来源:OnlineBooking.php

示例3: addProductShortcode

 /**
  * Add the [recras-product] shortcode
  *
  * @param array $attributes
  *
  * @return string
  */
 public static function addProductShortcode($attributes)
 {
     if (!isset($attributes['id'])) {
         return __('Error: no ID set', Plugin::TEXT_DOMAIN);
     }
     if (!ctype_digit($attributes['id'])) {
         return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
     }
     if (!isset($attributes['show'])) {
         return __('Error: "show" option not set', Plugin::TEXT_DOMAIN);
     }
     if (!in_array($attributes['show'], self::getValidOptions())) {
         return __('Error: invalid "show" option', Plugin::TEXT_DOMAIN);
     }
     $subdomain = Settings::getSubdomain($attributes);
     if (!$subdomain) {
         return Plugin::getNoSubdomainError();
     }
     $products = self::getProducts($subdomain);
     if (!isset($products[$attributes['id']])) {
         return __('Error: product does not exist', Plugin::TEXT_DOMAIN);
     }
     $product = $products[$attributes['id']];
     switch ($attributes['show']) {
         case 'description':
             return '<span class="recras-description">' . $product->beschrijving . '</span>';
         case 'description_long':
             if ($product->uitgebreide_omschrijving) {
                 return '<span class="recras-description">' . $product->uitgebreide_omschrijving . '</span>';
             } else {
                 return '';
             }
         case 'duration':
             if ($product->duur) {
                 return '<span class="recras-duration">' . $product->duur . '</span>';
             } else {
                 return '';
             }
         case 'image_url':
             return $product->image_url;
         case 'minimum_amount':
             return '<span class="recras-amount">' . $product->minimum_aantal . '</span>';
         case 'price_excl_vat':
             return Price::format($product->prijs_exc);
         case 'price_incl_vat':
             return Price::format($product->prijs_inc);
         case 'title':
             return '<span class="recras-title">' . $product->weergavenaam . '</span>';
         default:
             return __('Error: unknown option', Plugin::TEXT_DOMAIN);
     }
 }
开发者ID:recras,项目名称:recras-wordpress-plugin,代码行数:59,代码来源:Products.php

示例4: addContactShortcode

 /**
  * Add the [recras-contact] shortcode
  *
  * @param array $attributes
  *
  * @return string
  */
 public static function addContactShortcode($attributes)
 {
     if (!isset($attributes['id'])) {
         return __('Error: no ID set', Plugin::TEXT_DOMAIN);
     }
     if (!ctype_digit($attributes['id'])) {
         return __('Error: ID is not a number', Plugin::TEXT_DOMAIN);
     }
     $subdomain = Settings::getSubdomain($attributes);
     if (!$subdomain) {
         return Plugin::getNoSubdomainError();
     }
     // Get basic info for the form
     $baseUrl = 'contactformulieren/' . $attributes['id'];
     $json = get_transient('recras_' . $subdomain . '_contactform_' . $attributes['id']);
     if ($json === false) {
         try {
             $json = Http::get($subdomain, $baseUrl);
         } catch (\Exception $e) {
             return $e->getMessage();
         }
         set_transient('recras_' . $subdomain . '_contactform_' . $attributes['id'], $json, 86400);
     }
     $formTitle = $json->naam;
     if (isset($attributes['showtitle']) && !Settings::parseBoolean($attributes['showtitle'])) {
         $formTitle = false;
     }
     $showLabels = !isset($attributes['showlabels']) || Settings::parseBoolean($attributes['showlabels']);
     $showPlaceholders = !isset($attributes['showplaceholders']) || Settings::parseBoolean($attributes['showplaceholders']);
     $element = 'dl';
     if (isset($attributes['element']) && in_array($attributes['element'], self::getValidElements())) {
         $element = $attributes['element'];
     }
     // Get fields for the form
     $json = get_transient('recras_' . $subdomain . '_contactform_' . $attributes['id'] . '_fields');
     if ($json === false) {
         try {
             $json = Http::get($subdomain, $baseUrl . '/velden');
         } catch (\Exception $e) {
             return $e->getMessage();
         }
         set_transient('recras_' . $subdomain . '_contactform_' . $attributes['id'] . '_fields', $json, 86400);
     }
     $formFields = $json;
     $arrangementID = null;
     if (isset($attributes['arrangement'])) {
         $arrangementID = (int) $attributes['arrangement'];
         // Check if the contact form supports setting an arrangement
         $fieldFound = false;
         foreach ($formFields as $field) {
             if ($field->soort_invoer === 'boeking.arrangement') {
                 $fieldFound = true;
             }
         }
         if (!$fieldFound) {
             return __('Error: arrangement is set, but contact form does not support arrangements', Plugin::TEXT_DOMAIN);
         }
     }
     $submitText = __('Send', Plugin::TEXT_DOMAIN);
     if (isset($attributes['submittext'])) {
         $submitText = $attributes['submittext'];
     }
     $redirect = isset($attributes['redirect']) ? $attributes['redirect'] : false;
     $options = ['arrangement' => $arrangementID, 'element' => $element, 'formTitle' => $formTitle, 'placeholders' => $showPlaceholders, 'redirect' => $redirect, 'showLabels' => $showLabels, 'subdomain' => $subdomain, 'submitText' => $submitText];
     return self::generateForm($attributes['id'], $formFields, $options);
 }
开发者ID:recras,项目名称:recras-wordpress-plugin,代码行数:73,代码来源:ContactForm.php


注:本文中的Settings::getSubdomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。