function archive()
 {
     /*
      * Since there are several archive pages, we should bind this action to the archive
      * class after the common to assign all default options for archive pages  
      */
     /*
      * set base variables
      */
     $this->View->add("wxp_content_template", WXP::get_path("#loop")->dir());
     /*
      * if posts exceed the amount of that allotted per page,
      * tell view to include the pager nav 
      */
     global $wp_query;
     if ($wp_query->max_num_pages > 1) {
         $this->View->add("paged_archive", true);
     }
     /*
      * include the error no posts template if the archive has no posts
      */
     if (!have_posts()) {
         $this->View->add("wxp_content_template", WXP::get_path("#error")->name("no-posts")->dir());
     }
 }
 function __construct()
 {
     $Options = apply_filters("WXP.get_options_object", new Options());
     $this->add_object("View", view_var("wxp_global_view"));
     $this->add_object("Options", new Observer("Options", $Options));
     $this->add_object("Path", WXP::get_template_paths());
 }
Esempio n. 3
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");
     }
 }
function wxp_include_view($path, $namespace)
{
    WXP::include_view($path, $namespace);
}
 /**
  * fires actions bound to body class routes
  */
 function route()
 {
     do_action("WXP.DomRoute.before");
     $body_class = get_body_class();
     //add 'common' to the body class array
     array_unshift($body_class, 'common');
     //apply filters to body classes
     $body_class = apply_filters("WXP.DomRoute.body_classes", $body_class);
     //return false if no routes set
     if (empty($this->routes)) {
         return false;
     }
     foreach ($this->routes as $route_hook => $actions) {
         //if $action has the class key that means an action
         //was bound to multiple classes and wont be fired unless
         //all of those classes are present
         if (isset($actions["class"])) {
             $found = true;
             foreach ($actions["class"] as $cls) {
                 $found = in_array($cls, $body_class);
                 if (!$found) {
                     break;
                 }
             }
             //if all classes are not found skip to next route
             if (!$found) {
                 continue;
             }
             //else if all classes are found set $actions with the value
             $actions = (array) $actions['action'];
         } else {
             if (!in_array($route_hook, $body_class)) {
                 continue;
             }
         }
         //fire actions if not in $called_callbacks array
         foreach ($actions as $action) {
             if (is_string($action) && isset($this->called_callbacks[$action])) {
                 //if value is set to true, that means the
                 //callback has been called already
                 //skip to next action
                 if ($this->called_callbacks[$action] === true) {
                     continue;
                 }
                 //else the callback has not been fired yet
                 //set value to true to prevent it from being fired
                 //again in another route
                 $this->called_callbacks[$action] = true;
             }
             //finally fire the callback/action
             WXP::call_target($action, array(View::getInstance()), true);
         }
     }
     do_action("WXP.DomRoute.after");
 }
$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);
Esempio n. 9
0
<?php

\WXP\WXP::render_view(view_var("wxp_global_view"));
 /**
  * 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();