Example #1
0
<?php

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
Kanban_Template::init();
class Kanban_Template
{
    // the instance of this object
    private static $instance;
    // the list of kanban-related URL's
    static $page_slugs = array('board' => array('style' => array('bootstrap' => "%sbootstrap/css/bootstrap.min.css", 'board' => '%scss/board.css'), 'script' => array('jquery' => "%sjs/jquery-1.11.3.min.js", 'jquery-ui' => "%sjs/jquery-ui.min.js", 'bootstrap' => "%sbootstrap/js/bootstrap.min.js", 'bootstrap-growl' => "%sjs/jquery.bootstrap-growl.min.js", 'autoresize' => "%sjs/jquery.textarea.autoresize.min.js", 'same-height' => "%sjs/jquery.same-height.min.js", 't' => "%sjs/t.min.js", 'board-modal-projects' => "%sjs/board-modal-projects.min.js", 'board-sidebar-header' => "%sjs/board-sidebar-header.min.js", 'board-search' => "%sjs/board-search.min.js", 'board-filter' => "%sjs/board-filter.min.js", 'board-view' => "%sjs/board-view.min.js", 'board-task' => "%sjs/board-task.min.js", 'board' => "%sjs/board.min.js")), 'login' => array('style' => array('bootstrap' => "%sbootstrap/css/bootstrap.min.css")));
    static function init()
    {
        self::$page_slugs = apply_filters(sprintf('%s_Template_init', Kanban::get_instance()->settings->basename), self::$page_slugs);
        add_action('init', array(__CLASS__, 'protect_slug'));
        add_filter('template_include', array(__CLASS__, 'template_chooser'), 99);
    }
    /**
     * make sure only authenticated users can see our pages
     */
    static function protect_slug()
    {
        // only protect pages with our slug
        if (strpos($_SERVER['REQUEST_URI'], sprintf('/%s/', Kanban::$slug)) === FALSE) {
            return;
        }
        // admins can see anything
        // if ( current_user_can('manage_options') ) return;
        // get my id, and allowed id's