コード例 #1
0
ファイル: helper-functions.php プロジェクト: jrajalu/myxon
/**
 * 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
0
ファイル: helper-functions.php プロジェクト: emzo/Recipe-Hero
/**
 * 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
0
ファイル: helper-functions.php プロジェクト: jrfnl/CMB2
/**
 * 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
0
ファイル: CMB2_Utils.php プロジェクト: kps3/wordpress-base
 /**
  * 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
0
ファイル: test-cmb-core.php プロジェクト: Makenrro/repos
 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
0
ファイル: CMB2.php プロジェクト: jasonHalsey/qandc_blog-child
<?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
0
 /**
  * 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;
 }