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


PHP TGMPA_Utils::validate_bool方法代码示例

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


在下文中一共展示了TGMPA_Utils::validate_bool方法的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:GvarimAZA,项目名称:website,代码行数:45,代码来源:class-tgm-plugin-activation.php

示例2: 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);
     if (!empty($plugin['alt'])) {
         $args = array_merge($plugin, array('name' => $plugin['alt_name'], 'slug' => $this->sanitize_key($plugin['alt']), 'available_separately' => true, 'alt' => '', 'free' => $this->sanitize_key($plugin['slug']), 'source_type' => 'external', 'external_url' => $plugin['info_link'], 'description' => $plugin['alt_description']));
         $this->register($args);
     }
     // 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']);
     if (!empty($plugin['source']) && preg_match('|^/|', $plugin['source']) && !file_exists($plugin['source'])) {
         $plugin['available_separately'] = true;
     }
     if (!empty($plugin['available_separately'])) {
         $item['source'] = __('Available Separately', 'sociallyviral');
     }
     // 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:bigpopakap,项目名称:clickworthy,代码行数:55,代码来源:plugin-activation.php


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