forked from justintadlock/custom-content-portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportfolio.php
147 lines (123 loc) · 4.26 KB
/
portfolio.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/**
* Plugin Name: Custom Content Portfolio
* Plugin URI: http://themehybrid.com/plugins/custom-content-portfolio
* Description: Portfolio manager for WordPress. This plugin allows you to manage, edit, and create new portfolio items in an unlimited number of portfolios.
* Version: 0.1
* Author: Justin Tadlock
* Author URI: http://justintadlock.com
*
* The Custom Content Portfolio plugin was created to solve the problem of theme developers continuing
* to incorrectly add custom post types to handle portfolios within their themes. This plugin allows
* any theme developer to build a "portfolio" theme without having to code the functionality. This
* gives more time for design and makes users happy because their data isn't lost when they switch to
* a new theme. Oh, and, this plugin lets creative folk put together a portfolio of their work on
* their site.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
* that you can use any other version of the GPL.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @package CustomContentPortfolio
* @version 0.1.0
* @since 0.1.0
* @author Justin Tadlock <[email protected]>
* @copyright Copyright (c) 2013, Justin Tadlock
* @link http://themehybrid.com/plugins/custom-content-portfolio
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
class Custom_Content_Portfolio {
/**
* PHP5 constructor method.
*
* @since 0.1.0
* @access public
* @return void
*/
public function __construct() {
/* Set the constants needed by the plugin. */
add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
/* Internationalize the text strings used. */
add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
/* Load the functions files. */
add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
/* Load the admin files. */
add_action( 'plugins_loaded', array( &$this, 'admin' ), 4 );
/* Register activation hook. */
register_activation_hook( __FILE__, array( &$this, 'activation' ) );
}
/**
* Defines constants used by the plugin.
*
* @since 0.1.0
* @access public
* @return void
*/
public function constants() {
/* Set constant path to the plugin directory. */
define( 'CCP_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
/* Set the constant path to the plugin directory URI. */
define( 'CCP_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
/* Set the constant path to the includes directory. */
define( 'CCP_INCLUDES', CCP_DIR . trailingslashit( 'includes' ) );
/* Set the constant path to the admin directory. */
define( 'CCP_ADMIN', CCP_DIR . trailingslashit( 'admin' ) );
}
/**
* Loads the initial files needed by the plugin.
*
* @since 0.1.0
* @access public
* @return void
*/
public function includes() {
require_once( CCP_INCLUDES . 'functions.php' );
require_once( CCP_INCLUDES . 'meta.php' );
require_once( CCP_INCLUDES . 'post-types.php' );
require_once( CCP_INCLUDES . 'taxonomies.php' );
}
/**
* Loads the translation files.
*
* @since 0.1.0
* @access public
* @return void
*/
public function i18n() {
/* Load the translation of the plugin. */
load_plugin_textdomain( 'custom-content-portfolio', false, 'custom-content-portfolio/languages' );
}
/**
* Loads the admin functions and files.
*
* @since 0.1.0
* @access public
* @return void
*/
public function admin() {
if ( is_admin() )
require_once( CCP_ADMIN . 'admin.php' );
}
/**
* Method that runs only when the plugin is activated.
*
* @since 0.1.0
* @access public
* @return void
*/
function activation() {
/* Get the administrator role. */
$role =& get_role( 'administrator' );
/* If the administrator role exists, add required capabilities for the plugin. */
if ( !empty( $role ) ) {
$role->add_cap( 'manage_portfolio' );
$role->add_cap( 'create_portfolio_items' );
$role->add_cap( 'edit_portfolio_items' );
}
}
}
new Custom_Content_Portfolio();
?>