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


PHP Timber::dirname方法代码示例

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


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

示例1: testTwigLoadsFromAlternateDirName

 function testTwigLoadsFromAlternateDirName()
 {
     Timber::$dirname = array('foo', 'views');
     if (!file_exists(get_template_directory() . '/foo')) {
         mkdir(get_template_directory() . '/foo', 0777, true);
     }
     copy(__DIR__ . '/assets/single-foo.twig', get_template_directory() . '/foo/single-foo.twig');
     $str = Timber::compile('single-foo.twig');
     $this->assertEquals('I am single-foo', trim($str));
 }
开发者ID:aauroux,项目名称:timber,代码行数:10,代码来源:test-timber-loader.php

示例2: function

<?php

if (!class_exists('Timber')) {
    add_action('admin_notices', function () {
        echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url(admin_url('plugins.php#timber')) . '">' . esc_url(admin_url('plugins.php')) . '</a></p></div>';
    });
    return;
}
Timber::$dirname = array('templates', 'views');
class StarterSite extends TimberSite
{
    function __construct()
    {
        add_theme_support('post-formats');
        add_theme_support('post-thumbnails');
        add_theme_support('menus');
        add_filter('timber_context', array($this, 'add_to_context'));
        add_filter('get_twig', array($this, 'add_to_twig'));
        add_action('init', array($this, 'register_post_types'));
        add_action('init', array($this, 'register_taxonomies'));
        parent::__construct();
    }
    function register_post_types()
    {
        //this is where you can register custom post types
    }
    function register_taxonomies()
    {
        //this is where you can register custom taxonomies
    }
    function add_to_context($context)
开发者ID:darbymanning,项目名称:Family-Church,代码行数:31,代码来源:functions.php

示例3: Timber

Description: The WordPress Timber Library allows you to write themes using the power Twig templates.
Plugin URI: http://timber.upstatement.com
Author: Jared Novack + Upstatement
Version: 0.22.2
Author URI: http://upstatement.com/
*/
global $wp_version;
global $timber;
// we look for Composer files first in the plugins dir.
// then in the wp-content dir (site install).
// and finally in the current themes directories.
if (file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') || file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') || file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') || file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') || file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php')) {
    require_once $composer_autoload;
}
$timber = new Timber();
Timber::$dirname = 'views';
/**
 * Timber Class.
 *
 * Main class called Timber for this plugin.
 *
 * Usage:
 *  $posts = Timber::get_posts();
 *  $posts = Timber::get_posts('post_type = article')
 *  $posts = Timber::get_posts(array('post_type' => 'article', 'category_name' => 'sports')); // uses wp_query format.
 *  $posts = Timber::get_posts(array(23,24,35,67), 'InkwellArticle');
 *
 *  $context = Timber::get_context(); // returns wp favorites!
 *  $context['posts'] = $posts;
 *  Timber::render('index.twig', $context);
 */
开发者ID:Butterwell,项目名称:timber,代码行数:31,代码来源:timber.php

示例4: array

            return "desktop";
        } else {
            return "mobile";
        }
    }
}
if ($detect->isTablet()) {
    // If tablet
    array_unshift($template_array, $template_base . '/tablet');
} else {
    if (!$detect->isMobile()) {
        // If not tablet and not mobile
        array_unshift($template_array, $template_base . '/desktop', $template_base . '/tablet');
    }
}
Timber::$dirname = $template_array;
class StarterSite extends TimberSite
{
    function __construct()
    {
        load_theme_textdomain('nilslindstrom-theme', get_template_directory() . '/languages');
        add_theme_support('automatic-feed-links');
        add_theme_support('title-tag');
        add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption'));
        add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link'));
        add_theme_support('post-thumbnails');
        add_theme_support('menus');
        register_nav_menus(array('primary' => esc_html__('Primary', 'theme'), 'footer' => esc_html__('Footer', 'theme')));
        add_filter('timber_context', array($this, 'add_to_context'));
        add_filter('get_twig', array($this, 'add_to_twig'));
        add_action('init', array($this, 'register_post_types'));
开发者ID:adrianjonmiller,项目名称:hearts-being-healed,代码行数:31,代码来源:functions.php

示例5: PH_Projects

<?php

require_once __DIR__ . '/wp/acf-blog-options.php';
require_once __DIR__ . '/wp/acf-hacks.php';
if (class_exists('Timber')) {
    require_once 'wp/portfolio-entry.php';
    require_once 'wp/blades-site.php';
}
if (file_exists(__DIR__ . '/vendor/jarednova/mesh/mesh.php')) {
    require_once 'vendor/jarednova/mesh/mesh.php';
}
Timber::$dirname = array('views', 'pm-home');
require_once 'pm-home/PHProjects.php';
new PH_Projects();
ACFHacks::map_page_rule_to_slug(48, 'about');
ACFHacks::map_page_rule_to_slug(506, 'careers');
ACFHacks::map_page_rule_to_slug(2777, 'jobs');
ACFHacks::map_page_rule_to_slug(2995, 'drinks');
ACFHacks::map_page_rule_to_slug(4883, 'garage');
ACFHacks::map_page_rule_to_slug(4913, 'timber');
add_theme_support('menus');
add_theme_support('post-thumbnails');
add_filter('timber_context', function ($data) {
    $data['menu'] = new TimberMenu();
    global $post;
    if ($post && isset($post->ID)) {
        $maybe_title = get_post_meta($post->ID, 'custom_title_tag', true);
        if ($maybe_title) {
            $data['wp_title'] = $maybe_title;
        }
    }
开发者ID:JimCaignard,项目名称:blades,代码行数:31,代码来源:functions.php

示例6: header

<?php

if (WP_DEBUG) {
    header("Access-Control-Allow-Origin: *");
}
if (!class_exists("Timber")) {
    add_action("admin_notices", function () {
        echo "<div class=\"error\"><p>Timber is not activated. Make sure you activate the plugin in\n    <a href=\"" . esc_url(admin_url("plugins.php#timber")) . "\">" . esc_url(admin_url("plugins.php")) . "</a>.</p></div>";
    });
    return;
}
Timber::$dirname = "templates";
class MyTimberSite extends TimberSite
{
    function __construct()
    {
        add_theme_support("post-formats");
        add_theme_support("post-thumbnails");
        add_theme_support("menus");
        add_action("init", array($this, "register_post_types"));
        add_action("init", array($this, "register_taxonomies"));
        add_action("wp_enqueue_scripts", array($this, "enqueue_scripts"));
        add_filter("timber_context", array($this, "add_to_context"));
        add_filter("get_twig", array($this, "add_to_twig"));
        parent::__construct();
    }
    function register_post_types()
    {
        // This is where you can register custom post types
    }
    function register_taxonomies()
开发者ID:bearform,项目名称:wp-dev-kit,代码行数:31,代码来源:functions.php

示例7: function

/**
 * MANAGE TIMBER INITIALIZATION
 * * check whether Timber is activated
 * * configure custom TimberSite class
 * * initialize LegacyPartners instance
 * @note - Manage Timber context in add_to_context()
 * @note - Extend Twig instance in add_to_twig()
 */
if (!class_exists('Timber')) {
    add_action('admin_notices', function () {
        echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url(admin_url('plugins.php#timber')) . '">' . esc_url(admin_url('plugins.php')) . '</a></p></div>';
    });
    return;
}
Timber::$dirname = array('templates', 'templates/structures');
class LegacyParnters extends TimberSite
{
    function __construct()
    {
        add_theme_support('post-formats');
        add_theme_support('post-thumbnails');
        add_theme_support('menus');
        add_filter('timber_context', array($this, 'add_to_context'));
        add_filter('get_twig', array($this, 'add_to_twig'));
        add_action('init', array($this, 'register_post_types'));
        add_action('init', array($this, 'register_taxonomies'));
        parent::__construct();
    }
    function add_to_context($context)
    {
开发者ID:primarydesign,项目名称:legacy-partners,代码行数:30,代码来源:functions.php

示例8: StarterSite

<?php

if (!class_exists('Timber')) {
    add_action('admin_notices', function () {
        echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . esc_url(admin_url('plugins.php#timber')) . '">' . esc_url(admin_url('plugins.php')) . '</a></p></div>';
    });
    return;
}
Timber::$dirname = array('views');
class StarterSite extends TimberSite
{
    function __construct()
    {
        add_filter('timber_context', array($this, 'add_to_context'));
        parent::__construct();
    }
    function add_to_context($context)
    {
        $context['main_menu'] = new TimberMenu('primary_navigation');
        $context['site'] = $this;
        $context['options'] = get_fields('option');
        return $context;
    }
}
new StarterSite();
开发者ID:Dedato,项目名称:pianoles-rivera,代码行数:25,代码来源:timber.php

示例9: array

            // have a good config, lets update tranient values
            if (is_array($config) && count($errors) === 0) {
                set_transient('fg_config', $config, 0);
                set_transient('fg_config_timestamp', $filetime, 0);
            } else {
                //means an error in yaml settings. -- need a way to notify user it failed
                $config = $cache['config'];
            }
        } else {
            $config = $cache['config'];
        }
        //adding errors
        $config['ERRORS'] = $errors;
        $dirnameChildTheme = get_stylesheet_directory() . '/twig-templates';
        $dirnameTheme = get_template_directory() . '/twig-templates';
        Timber::$dirname = array('twig-templates');
        //setting up timber twig file locations
        // it will look in theme first, if it doesn't find it it will look in master
        $timberLocationsArray = array($dirnameChildTheme, $dirnameChildTheme . '/wp', $dirnameChildTheme . '/partials', $dirnameChildTheme . '/email', $dirnameChildTheme . '/form');
        // only merge if seperate;
        if ($dirnameChildTheme !== $dirnameTheme) {
            $timberLocationsArray = array_merge($timberLocationsArray, array($dirnameTheme, $dirnameTheme . '/wp', $dirnameTheme . '/partials', $dirnameTheme . '/email', $dirnameTheme . '/form'));
        }
        // adding filter to add twig locations
        $timberLocationsArray = apply_filters('fg_theme_master_twig_locations', $timberLocationsArray);
        Timber::$locations = $timberLocationsArray;
        return $config;
    };
});
$get_slideshow = function () {
    if (function_exists('rwmb_meta')) {
开发者ID:sturple,项目名称:fg-theme-master,代码行数:31,代码来源:functions.php

示例10:

<?php

// Timber::$cache = true;
Timber::$dirname = ['views', 'views/templates'];
require_once 'lumberjack/bootstrap.php';
开发者ID:Rareloop,项目名称:lumberjack,代码行数:5,代码来源:functions.php

示例11: template_render

<?php

namespace WPSW\ThemeSetup\Template;

use Yare\Yare;
$timber = new \Timber\Timber();
\Timber::$dirname = Yare::config('paths.template');
function template_render()
{
    //$app = new \Yare\App();
    //$app->run();
    $loader = \Yare\Autoloader::instance();
    pc($loader, 'loader');
    $ViewClass = $loader->view();
    $view = new $ViewClass();
    $view->render();
}
add_action('yare/template_render', __NAMESPACE__ . '\\template_render');
function add_to_twig($twig)
{
    $filters = Yare::config('theme.filters');
    foreach ($filters as $filter => $callback) {
        $twig->addFilter($filter, new \Twig_SimpleFilter($filter, $callback));
    }
    $functions = Yare::config('theme.functions');
    foreach ($functions as $function => $callback) {
        $twig->addFunction($function, new \Twig_SimpleFunction($function, $callback));
    }
    return $twig;
}
add_filter('get_twig', __NAMESPACE__ . '\\add_to_twig');
开发者ID:solutionworks,项目名称:theme-setup,代码行数:31,代码来源:templates.php


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