-
Notifications
You must be signed in to change notification settings - Fork 0
/
cheesepress.php
executable file
·126 lines (107 loc) · 3.51 KB
/
cheesepress.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/**
* CheesePress Framework
*
* Main page for CheesePress Framework
*
* @package CheesePress
* @author Ben Klein <[email protected]>
* @license GPL-2.0+
* @link http://cheesepressframework.com
* @copyright 2014 Ben Klein
*
* @wordpress-plugin
* Plugin Name: CheesePress Framework
* Plugin URI: http://cheesepressframework.com
* Description: CheesePress Framework main script
* Version: 0.0.1
* Author: Ben Klein
* Author URI:
* Text Domain: cheesepress
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
* GitHub Plugin URI:
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/*----------------------------------------------------------------------------*
* Public-Facing Functionality
*----------------------------------------------------------------------------*/
require_once( plugin_dir_path( __FILE__ ) . '/class-cheesepress.php' );
require_once( plugin_dir_path( __FILE__ ) . '/vendor/autoload.php' );
ActiveRecord\Config::initialize(function($cfg)
{
$cfg->set_model_directory(plugin_dir_path( __FILE__ ) . '/models');
$cfg->set_connections(
array(
'wordpress' => 'mysql://'.DB_USER.':'.DB_PASSWORD.'@'.DB_HOST.'/' . DB_NAME
)
);
});
ActiveRecord\Config::initialize(function($cfg)
{
$cfg->set_default_connection('wordpress');
});
/*
* Register hooks that are fired when the plugin is activated or deactivated.
* When the plugin is deleted, the uninstall.php file is loaded.
*/
register_activation_hook( __FILE__, array( 'CheesePress', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'CheesePress', 'deactivate' ) );
add_action( 'plugins_loaded', array( 'CheesePress', 'get_instance' ) );
// Declare your custom types below:
add_action( 'init', 'create_custom_post_type' );
function create_custom_post_type() {
register_post_type( 'mycustom',
array(
'labels' => array(
'name' => __( 'My Customs' ),
'singular_name' => __( 'My Custom' )
),
'public' => true,
'has_archive' => false,
)
);
}
/*----------------------------------------------------------------------------*
* Dashboard and Administrative Functionality
*----------------------------------------------------------------------------*/
/*
* @TODO:
*
* If you want to include Ajax within the dashboard, change the following
* conditional to:
*
* if ( is_admin() ) {
* ...
* }
*
* The code below is intended to to give the lightest footprint possible.
*/
if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
require_once( plugin_dir_path( __FILE__ ) . 'admin/class-cheesepress-admin.php' );
add_action( 'plugins_loaded', array( 'CheesePress_Admin', 'get_instance' ) );
}
// custom url routes and churro methods
if( file_exists(WP_PLUGIN_DIR.'/cheesepress/controllers/_config.php') )
require WP_PLUGIN_DIR.'/cheesepress/controllers/_config.php';
// Churro needs to extend Custom
if( !class_exists('Custom_Churro') ){
class Custom_Churro{
static public function Routes(){
return array();
}
}
}
// base class
require plugin_dir_path( __FILE__ ) . 'framework/_class_Churro.php';
// get this thing going as early as possible.
if( is_admin() ){
add_action( 'admin_menu', 'Churro::Bootstrap' );
register_activation_hook( __FILE__, 'Churro::Activation' );
} else {
add_action( 'parse_request', 'Churro::Bootstrap' );
}