當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TGMPA_Utils類代碼示例

本文整理匯總了PHP中TGMPA_Utils的典型用法代碼示例。如果您正苦於以下問題:PHP TGMPA_Utils類的具體用法?PHP TGMPA_Utils怎麽用?PHP TGMPA_Utils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TGMPA_Utils類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 /**
  * Add individual plugin to our collection of plugins.
  *
  * If the required keys are not set or the plugin has already
  * been registered, the plugin is not added.
  *
  * @since 2.0.0
  *
  * @param array|null $plugin Array of plugin arguments or null if invalid argument.
  * @return null Return early if incorrect argument.
  */
 public function register($plugin)
 {
     if (empty($plugin['slug']) || empty($plugin['name'])) {
         return;
     }
     if (empty($plugin['slug']) || !is_string($plugin['slug']) || isset($this->plugins[$plugin['slug']])) {
         return;
     }
     $defaults = array('name' => '', 'slug' => '', 'source' => 'repo', 'required' => false, 'version' => '', 'force_activation' => false, 'force_deactivation' => false, 'external_url' => '', 'is_callable' => '');
     // Prepare the received data.
     $plugin = wp_parse_args($plugin, $defaults);
     // Standardize the received slug.
     $plugin['slug'] = $this->sanitize_key($plugin['slug']);
     // Forgive users for using string versions of booleans or floats for version number.
     $plugin['version'] = (string) $plugin['version'];
     $plugin['source'] = empty($plugin['source']) ? 'repo' : $plugin['source'];
     $plugin['required'] = TGMPA_Utils::validate_bool($plugin['required']);
     $plugin['force_activation'] = TGMPA_Utils::validate_bool($plugin['force_activation']);
     $plugin['force_deactivation'] = TGMPA_Utils::validate_bool($plugin['force_deactivation']);
     // Enrich the received data.
     $plugin['file_path'] = $this->_get_plugin_basename_from_slug($plugin['slug']);
     $plugin['source_type'] = $this->get_plugin_source_type($plugin['source']);
     // Set the class properties.
     $this->plugins[$plugin['slug']] = $plugin;
     $this->sort_order[$plugin['slug']] = $plugin['name'];
     // Should we add the force activation hook ?
     if (true === $plugin['force_activation']) {
         $this->has_forced_activation = true;
     }
     // Should we add the force deactivation hook ?
     if (true === $plugin['force_deactivation']) {
         $this->has_forced_deactivation = true;
     }
 }
開發者ID:Stylize,項目名稱:Fuel,代碼行數:45,代碼來源:TGM_Plugin_Activation.php

示例2: validate_bool

 /**
  * Helper function: Validate a value as boolean
  *
  * @since 2.5.0
  *
  * @static
  *
  * @param mixed $value Arbitrary value.
  * @return bool
  */
 public static function validate_bool($value)
 {
     if (!isset(self::$has_filters)) {
         self::$has_filters = extension_loaded('filter');
     }
     if (self::$has_filters) {
         return filter_var($value, FILTER_VALIDATE_BOOLEAN);
     } else {
         return self::emulate_filter_bool($value);
     }
 }
開發者ID:GvarimAZA,項目名稱:website,代碼行數:21,代碼來源:class-tgm-plugin-activation.php


注:本文中的TGMPA_Utils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。