예제 #1
0
 /**
  * Constructor
  * @param string $routeKey
  * @param closure $action
  */
 public function __construct($routeKey, $action)
 {
     $this->routeKey = $routeKey;
     $this->action = $action;
     # run with top priority
     Actions::on("wp_ajax_nopriv_{$routeKey}", array($this, 'processRequest'), 0);
     Actions::on("wp_ajax_{$routeKey}", array($this, 'processRequest'), 0);
 }
예제 #2
0
파일: Song.php 프로젝트: aklatzke/spartan
 public function init()
 {
     # these option settings are the wordpress default settings - you can
     # freely change or add anything that a normal CPT would have as an option
     $options = array('description' => __('Song'), 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'query_var' => true, 'menu_icon' => 'dashicons-book-alt', 'menu_position' => 47, 'capability_type' => 'post', 'hierarchical' => true, 'supports' => array('title', 'thumbnail'), 'taxonomies' => array('category', 'post_tag'), 'has_archive' => 'all/songs');
     # these are the "labels" option when declaring a custom post type,
     # broken out here so that it's not a mess
     $labels = array('name' => __('Song', 'bonestheme'), 'singular_name' => __('Song', 'bonestheme'), 'all_items' => __('Manage Song ', 'bonestheme'), 'add_new' => __('Add New', 'bonestheme'), 'add_new_item' => __('Add New Song', 'bonestheme'), 'edit' => __('Edit', 'bonestheme'), 'edit_item' => __('Edit Song', 'bonestheme'), 'new_item' => __('New Song', 'bonestheme'), 'view_item' => __('View Song', 'bonestheme'), 'search_items' => __('Search Song', 'bonestheme'), 'not_found' => __("No Song found.", 'bonestheme'), 'not_found_in_trash' => __('Nothing found in Trash', 'bonestheme'), 'parent_item_colon' => '');
     # the post type will initialize automatically when both of these
     # are set
     $this->labels($labels)->options($options);
     # Add categories to this post type
     Actions::on('init', function () {
         register_taxonomy_for_object_type('category', 'song');
     });
     # initialize the static custom fields for this post type
     $this->initializeFields();
     $this->registerFilters();
     return $this;
 }
예제 #3
0
파일: Route.php 프로젝트: aklatzke/spartan
 /**
  * Matches an admin route by regex and adds a menu item
  * @param  string [ Regular Expression ] $routeRegex
  * @param  string $name
  * @param  string $queryVars
  * @param  Closure $callback
  * @param  Array  $options - array of options for add_menu_page
  * @return null
  */
 public function adminRoute($routeRegex, $name, $queryVars, $callback, $options = array())
 {
     $defaults = array('capability' => 'administrator', 'page_title' => $name, 'menu_title' => $name, 'menu_slug' => $name . '_route', 'icon_url' => '', 'position' => 1);
     $options = (object) array_merge($defaults, $options);
     $this->match($routeRegex, $options->menu_slug, $queryVars, function ($input) use($options) {
         $input['routeAlias'] = true;
         $var = Utils::cacheSet('matchData', json_encode($input));
         Utils::redirect('/wp-admin/admin.php?page=' . $options->menu_slug);
     }, false, true);
     Actions::on('admin_menu', function () use($callback, $options) {
         $input = json_decode(Utils::cacheGet('matchData'));
         add_menu_page($options->page_title, $options->menu_title, $options->capability, $options->menu_slug, function () use($input, $callback) {
             return call_user_func($callback, $input);
         }, $options->icon_url, $options->position);
     });
     return null;
 }
예제 #4
0
require "classes/PostOutput.php";
# \Mailer simplifies the mail class
require "classes/Mailer.php";
require "classes/BaseController.php";
require "classes/Router.php";
# Input handling
require "classes/InputRepository.php";
require "classes/Input.php";
# creates a singleton app object so that we don't have to keep reinstating the
# global variable
require "classes/App.php";
App::start();
App::instance()->autoload(dirname(__FILE__));
App::set('router', new Evo\Router());
App::set('utils', new Utils());
App::set('output', new Evo\PostOutput());
App::set('mailer', new Evo\Mailer());
require "includes/routes.php";
require "includes/endpoints.php";
$loader = new josegonzalez\Dotenv\Loader($_SERVER["DOCUMENT_ROOT"] . "/.env");
$loader->parse()->toEnv();
#-----------------------------------------
# Load static assets for the frontend and admin
# You can use these same utility functions to load
#----------------------------------------
App::module('utils')->registerAdminJavascript(Utils::getThemeAsset('/modules/example/assets/js/es5.js'));
# Some default action setup
Actions::on('parse_request', function ($queryVars) {
    # populate the input singleton
    Input::populate($queryVars);
}, 0, 4);
예제 #5
0
<?php

use AKL\Mason;
App::alias('Album', 'album');
App::alias('Song', 'song');
function loadCompiledTemplate($intended)
{
    $contents = file_get_contents($intended);
    $target = get_template_directory() . '/tmp/mason/';
    require_once get_template_directory() . '/includes/mason/template-map.php';
    Mason::build($intended, $target . basename(str_replace(".php", "", $intended)));
    return $target . basename($intended);
}
Actions::on("template_include", 'loadCompiledTemplate');