本文整理汇总了PHP中cmb2_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP cmb2_dir函数的具体用法?PHP cmb2_dir怎么用?PHP cmb2_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cmb2_dir函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cmb2_autoload_classes
/**
* Autoloads files with CMB2 classes when needed
* @since 1.0.0
* @param string $class_name Name of the class being requested
*/
function cmb2_autoload_classes($class_name)
{
if (0 !== strpos($class_name, 'CMB2')) {
return;
}
include_once cmb2_dir("includes/{$class_name}.php");
}
示例2: cmb2_autoload_classes
/**
* Autoloads files with CMB2 classes when needed
* @since 1.0.0
* @param string $class_name Name of the class being requested
*/
function cmb2_autoload_classes($class_name)
{
if (class_exists($class_name, false) || false === strpos($class_name, 'CMB2_')) {
return;
}
$file = cmb2_dir("includes/{$class_name}.php");
if (file_exists($file)) {
@(include_once $file);
}
}
示例3: cmb2_autoload_classes
/**
* Autoloads files with CMB2 classes when needed
* @since 1.0.0
* @param string $class_name Name of the class being requested
*/
function cmb2_autoload_classes($class_name)
{
if (0 !== strpos($class_name, 'CMB2')) {
return;
}
$path = 'includes';
if ('CMB2_Type' === $class_name || 0 === strpos($class_name, 'CMB2_Type_')) {
$path .= '/types';
}
include_once cmb2_dir("{$path}/{$class_name}.php");
}
示例4: url
/**
* Defines the url which is used to load local resources.
* This may need to be filtered for local Window installations.
* If resources do not load, please check the wiki for details.
* @since 1.0.1
* @return string URL to CMB resources
*/
public function url($path = '')
{
if ($this->url) {
return $this->url . $path;
}
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
// Windows
$content_dir = str_replace('/', DIRECTORY_SEPARATOR, WP_CONTENT_DIR);
$content_url = str_replace($content_dir, WP_CONTENT_URL, cmb2_dir());
$cmb2_url = str_replace(DIRECTORY_SEPARATOR, '/', $content_url);
} else {
$cmb2_url = str_replace(array(WP_CONTENT_DIR, WP_PLUGIN_DIR), array(WP_CONTENT_URL, WP_PLUGIN_URL), cmb2_dir());
}
/**
* Filter the CMB location url
*
* @param string $cmb2_url Currently registered url
*/
$this->url = trailingslashit(apply_filters('cmb2_meta_box_url', set_url_scheme($cmb2_url), CMB2_VERSION));
return $this->url . $path;
}
示例5: test_url_set
public function test_url_set()
{
$cmb2_url = str_replace(array(WP_CONTENT_DIR, WP_PLUGIN_DIR), array(WP_CONTENT_URL, WP_PLUGIN_URL), cmb2_dir());
$this->assertEquals(cmb2_utils()->url(), $cmb2_url);
}
示例6: cmb2_dir
<?php
/**
* Helper function to provide directory path to CMB
* @since 2.0.0
* @param string $path Path to append
* @return string Directory with optional path appended
*/
function cmb2_dir($path = '')
{
return trailingslashit(dirname(__FILE__)) . $path;
}
require_once cmb2_dir('includes/helper-functions.php');
$meta_boxes_config = apply_filters('cmb2_meta_boxes', array());
foreach ((array) $meta_boxes_config as $meta_box) {
$cmb = new CMB2($meta_box);
if ($cmb->prop('hookup')) {
$hookup = new CMB2_hookup($cmb);
}
}
/**
* Create meta boxes
*/
class CMB2
{
/**
* Current field's ID
* @var string
* @since 2.0.0
*/
protected $cmb_id = '';
示例7: url
/**
* Defines the url which is used to load local resources.
* This may need to be filtered for local Window installations.
* If resources do not load, please check the wiki for details.
* @since 1.0.1
* @return string URL to CMB2 resources
*/
public function url($path = '')
{
if ($this->url) {
return $this->url . $path;
}
$cmb2_url = self::get_url_from_dir(cmb2_dir());
/**
* Filter the CMB location url
*
* @param string $cmb2_url Currently registered url
*/
$this->url = trailingslashit(apply_filters('cmb2_meta_box_url', $cmb2_url, CMB2_VERSION));
return $this->url . $path;
}