Esempio n. 1
0
 function add($path_alias, $path, $template = true)
 {
     if ($template) {
         $this->paths[$path_alias] = new TplPath(rtrim(WXP::DS($path), DIRECTORY_SEPARATOR));
     } else {
         $this->paths[$path_alias] = $path;
     }
     return $this;
 }
 function plugin_template_override()
 {
     /*
      * if the content template is included from a directory that
      * is not the theme directory, its more than likely that a plugin defined it
      * and we don't want our theme to override the plugin, so we'll set the
      * content_template back to the plugin's
      * 
      */
     $orig_tpl = WXP::DS(view_var("wxp_default_render_path"));
     $tpl_dir = WXP::DS(get_template_directory());
     $ss_dir = WXP::DS(get_stylesheet_directory());
     $override = view_var("wxp_allow_plugin_template_override");
     if (strpos($orig_tpl, $tpl_dir) === false && strpos($orig_tpl, $ss_dir) === false && $override === true) {
         $this->View->add("wxp_content_template", $orig_tpl);
         //let plugin template be single column, just incase
         //it includes its own sidebar (like Woocommerce)
         //$this->Elements->set_layout("one");
     }
 }
$dir = dirname(dirname(__FILE__));
/*************************************************
 * WXP DIRECTORY
 ************************************************/
define("WXPDIR", "{$dir}{$ds}src{$ds}WXP{$ds}");
/*************************************************
 * INCLUDES
 ************************************************/
require WXPDIR . "WXP.php";
require WXPDIR . WXP::DS("Generator/Generator.php");
/*************************************************
 * CONSTANTS
 ************************************************/
define("TPLDIR", WXP::DS(dirname(dirname($dir))));
define("BUILDPATH", WXPDIR . WXP::DS("/Generator/paths/"));
define("TPLCONTENTSPATH", WXPDIR . WXP::DS("/Generator/templates/"));
/**
 * generates vendor or child theme starter directories
 * 
 * @param string $root_path
 * @param array $build
 * @param callable $callbacks
 */
function generate($root_path, $mkdir = false, $build, $callbacks = array())
{
    $g = new Generator($root_path, $mkdir);
    return $g->build($build, $callbacks);
}
/**
 * checks if is $varname is valid variable name. 
 * 
});
/************************************************
 * WP Utilities/Helpers
 ************************************************/
require_once locate_template('/lib/cleanup.php');
// Cleanup
require_once locate_template('/lib/relative-urls.php');
// Root relative URLs
/***********************************************
 * WP UI COMPONENTS
 * - widgets, sidebars, nav etc...
 **********************************************/
require WXP::DS("lib\\WXP\\Theme\\ui\\comments.php");
require WXP::DS("lib\\WXP\\Theme\\ui\\gallery.php");
require WXP::DS("lib\\WXP\\Theme\\ui\\nav.php");
require WXP::DS("lib\\WXP\\Theme\\ui\\sidebar.php");
require WXP::DS("lib\\WXP\\Theme\\ui\\widgets.php");
/************************************************
 * THE OPTIONS TREE FRAMEWORK
 ***********************************************/
add_filter('ot_theme_mode', '__return_true');
//add_filter( 'ot_show_pages', '__return_false' );
//add_filter( 'ot_show_options_ui', '__return_false');
//add_filter( 'ot_show_docs', '__return_true' );
require trailingslashit(get_template_directory()) . 'lib/option-tree/ot-loader.php';
add_filter("WXP.DomRouter.on.allow", function ($orig, $param) {
    return $orig;
}, 10, 2);
add_filter("WXP.DomRouter.on.disallow.return", function ($orig, $obj) {
    return $obj;
}, 10, 2);
 /**
  * todo 
  * 
  * function register_vendor
  * function register_plugin
  */
 function include_config_files($themes)
 {
     foreach ($themes as $theme => $path) {
         $config_path = $path->to('config') . DIRECTORY_SEPARATOR;
         //allow developer to replace config paths,
         //if false is returned, don't include it
         $scripts = $config_path . WXP::DS("config\\scripts.php");
         $this->include_path($scripts, "WXP.{$theme}.include_scripts", function () use($scripts) {
             add_action("wp_enqueue_scripts", function () use($scripts) {
                 require $scripts;
             });
         });
         //load init file if exist
         $hooks = $config_path . WXP::DS("config/init.php");
         $this->include_path($hooks, "WXP.{$theme}.include_init");
         //load hooks file if exist
         $hooks = $config_path . WXP::DS("config/hooks.php");
         $this->include_path($hooks, "WXP.{$theme}.include_hooks");
         //load dom routes if exist
         $domRoutes = $config_path . WXP::DS("config/dom-routes.php");
         $this->include_path($domRoutes, "WXP.{$theme}.include_dom_routes");
         //load options file if exists
         $theme_options = $config_path . WXP::DS("config/options.php");
         $this->include_path($theme_options, "WXP.{$theme}.include_theme_options");
         //load meta boxes file if exists
         $meta_boxes = $config_path . WXP::DS("config/meta-boxes.php");
         $this->include_path($meta_boxes, "WXP.{$theme}.include_meta_boxes");
         //load paths if set
         $t_paths = $config_path . WXP::DS("config/paths.php");
         $this->include_path($t_paths, "WXP.{$theme}.include_template_paths");
     }
 }
<?php

/*
Plugin Name: WP Expressive Dom Router
Plugin URI: http://www.designplug.net
Description: Create Cleaner and Scalable views with WXP DomRouter. WXP DomRouter provides an organized way to handle your queries and other business logic, and make variables accessible in wordpress templates. Wordpress body classes provide a ton of information about the current page that WXP DomRouter allows Theme developers make use of for determining what content should be loaded on each page.
Version: 0.1.0
Author: Ric Anthony Lee
Author URI: http://www.facebook.com/theleecode
License: MIT
*/
use WXP\WXP;
use WXP\Bootstrap;
$ds = DIRECTORY_SEPARATOR;
require 'WXP' . $ds . 'src' . $ds . 'WXP' . $ds . 'WXP.php';
require WXP::DS('WXP/src/WXP/Autoloader.php');
require WXP::DS('WXP/src/WXP/Action.php');
require WXP::DS('WXP/src/WXP/TemplatePath.php');
require WXP::DS('WXP/src/WXP/Path.php');
require WXP::DS('WXP/src/WXP/Bootstrap.php');
require WXP::DS('WXP/src/WXP/DomRouter.php');
require WXP::DS('WXP/src/WXP/Options.php');
require WXP::DS('WXP/src/WXP/Controller.php');
require WXP::DS('WXP/src/WXP/View.php');
require WXP::DS('WXP/src/WXP/helpers.php');
require WXP::DS('WXP/src/WXP/Observer.php');
/*****************************************************
 * Begin Routing
 *****************************************************/
new Bootstrap();