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


PHP Actions::on方法代码示例

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


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

示例1: __construct

 /**
  * 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);
 }
开发者ID:aklatzke,项目名称:spartan,代码行数:13,代码来源:AjaxRouter.php

示例2: init

 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;
 }
开发者ID:aklatzke,项目名称:spartan,代码行数:20,代码来源:Song.php

示例3: adminRoute

 /**
  * 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;
 }
开发者ID:aklatzke,项目名称:spartan,代码行数:26,代码来源:Route.php

示例4: Utils

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);
开发者ID:aklatzke,项目名称:spartan,代码行数:31,代码来源:autoload.php

示例5: loadCompiledTemplate

<?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');
开发者ID:aklatzke,项目名称:spartan,代码行数:14,代码来源:function-extensions.php


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