Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 204 lines (165 sloc) 6.193 kB
2cf6214 Importing the Members plugin files and folders.
greenshady authored
1 <?php
2 /**
3 * Plugin Name: Members
4 * Plugin URI: http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin
5 * Description: A user, role, and content management plugin for controlling permissions and access. A plugin for making WordPress a more powerful <acronym title="Content Management System">CMS</acronym>.
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
6 * Version: 0.2 Beta 3
2cf6214 Importing the Members plugin files and folders.
greenshady authored
7 * Author: Justin Tadlock
8 * Author URI: http://justintadlock.com
9 *
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
10 * The members plugin was created because the WordPress community is lacking a solid permissions
11 * plugin that is both open source and works completely within the confines of the APIs in WordPress.
12 * But, the plugin is so much more than just a plugin to control permissions. It is meant to extend
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
13 * WordPress by making user, role, and content management as simple as using WordPress itself.
2cf6214 Importing the Members plugin files and folders.
greenshady authored
14 *
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
15 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
16 * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
17 * that you can use any other version of the GPL.
18 *
19 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
20 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
2cf6214 Importing the Members plugin files and folders.
greenshady authored
21 *
22 * @package Members
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
23 * @version 0.2.0
24 * @author Justin Tadlock <justin@justintadlock.com>
ed4bd90 Members v.0.2. Beta.
greenshady authored
25 * @copyright Copyright (c) 2009 - 2011, Justin Tadlock
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
26 * @link http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin
27 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
2cf6214 Importing the Members plugin files and folders.
greenshady authored
28 */
29
30 /**
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
31 * @since 0.2.0
2cf6214 Importing the Members plugin files and folders.
greenshady authored
32 */
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
33 class Members_Load {
34
35 /**
ed4bd90 Members v.0.2. Beta.
greenshady authored
36 * PHP4 constructor method. This will be removed once the plugin only supports WordPress 3.2,
37 * which is the version that drops PHP4 support.
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
38 *
39 * @since 0.2.0
40 */
41 function Members_Load() {
42 $this->__construct();
43 }
44
45 /**
46 * PHP5 constructor method.
47 *
48 * @since 0.2.0
49 */
50 function __construct() {
ed4bd90 Members v.0.2. Beta.
greenshady authored
51
52 /* Set the constants needed by the plugin. */
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
53 add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
ed4bd90 Members v.0.2. Beta.
greenshady authored
54
55 /* Internationalize the text strings used. */
56 add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
57
58 /* Load the functions files. */
59 add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
60
61 /* Load the admin files. */
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
62 add_action( 'plugins_loaded', array( &$this, 'admin' ), 4 );
f6b0d6d Beta 2.
greenshady authored
63
64 /* Register activation hook. */
65 register_activation_hook( __FILE__, array( &$this, 'activation' ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
66 }
67
68 /**
69 * Defines constants used by the plugin.
70 *
71 * @since 0.2.0
72 */
73 function constants() {
74
ed4bd90 Members v.0.2. Beta.
greenshady authored
75 /* Set the version number of the plugin. */
76 define( 'MEMBERS_VERSION', '0.2.0' );
77
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
78 /* Set constant path to the members plugin directory. */
ed4bd90 Members v.0.2. Beta.
greenshady authored
79 define( 'MEMBERS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
80
81 /* Set constant path to the members plugin URL. */
ed4bd90 Members v.0.2. Beta.
greenshady authored
82 define( 'MEMBERS_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
83
84 /* Set the constant path to the members includes directory. */
85 define( 'MEMBERS_INCLUDES', MEMBERS_DIR . trailingslashit( 'includes' ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
86
ed4bd90 Members v.0.2. Beta.
greenshady authored
87 /* Set the constant path to the members admin directory. */
88 define( 'MEMBERS_ADMIN', MEMBERS_DIR . trailingslashit( 'admin' ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
89 }
90
91 /**
92 * Loads the initial files needed by the plugin.
93 *
94 * @since 0.2.0
95 */
ed4bd90 Members v.0.2. Beta.
greenshady authored
96 function includes() {
97
98 /* Load the plugin functions file. */
99 require_once( MEMBERS_INCLUDES . 'functions.php' );
100
101 /* Load the deprecated functions file. */
102 require_once( MEMBERS_INCLUDES . 'deprecated.php' );
103
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
104 /* Load the admin bar functions. */
105 require_once( MEMBERS_INCLUDES . 'admin-bar.php' );
106
ed4bd90 Members v.0.2. Beta.
greenshady authored
107 /* Load the functions related to capabilities. */
108 require_once( MEMBERS_INCLUDES . 'capabilities.php' );
109
110 /* Load the content permissions functions. */
111 require_once( MEMBERS_INCLUDES . 'content-permissions.php' );
112
113 /* Load the private site functions. */
114 require_once( MEMBERS_INCLUDES . 'private-site.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
115
ed4bd90 Members v.0.2. Beta.
greenshady authored
116 /* Load the shortcodes functions file. */
117 require_once( MEMBERS_INCLUDES . 'shortcodes.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
118
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
119 /* Load the template functions. */
120 require_once( MEMBERS_INCLUDES . 'template.php' );
121
ed4bd90 Members v.0.2. Beta.
greenshady authored
122 /* Load the widgets functions file. */
123 require_once( MEMBERS_INCLUDES . 'widgets.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
124 }
125
126 /**
127 * Loads the translation files.
128 *
129 * @since 0.2.0
130 */
ed4bd90 Members v.0.2. Beta.
greenshady authored
131 function i18n() {
132
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
133 /* Load the translation of the plugin. */
134 load_plugin_textdomain( 'members', false, 'members/languages' );
135 }
136
137 /**
138 * Loads the admin functions and files.
139 *
140 * @since 0.2.0
141 */
142 function admin() {
143
ed4bd90 Members v.0.2. Beta.
greenshady authored
144 /* Only load files if in the WordPress admin. */
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
145 if ( is_admin() ) {
146
ed4bd90 Members v.0.2. Beta.
greenshady authored
147 /* Load the main admin file. */
148 require_once( MEMBERS_ADMIN . 'admin.php' );
149
150 /* Load the plugin settings. */
151 require_once( MEMBERS_ADMIN . 'settings.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
152 }
153 }
f6b0d6d Beta 2.
greenshady authored
154
155 /**
156 * Method that runs only when the plugin is activated.
157 *
158 * @since 0.2.0
159 */
160 function activation() {
161
162 /* Get the administrator role. */
163 $role =& get_role( 'administrator' );
164
165 /* If the administrator role exists, add required capabilities for the plugin. */
166 if ( !empty( $role ) ) {
167
168 /* Role management capabilities. */
169 $role->add_cap( 'list_roles' );
170 $role->add_cap( 'create_roles' );
171 $role->add_cap( 'delete_roles' );
172 $role->add_cap( 'edit_roles' );
173
174 /* Content permissions capabilities. */
175 $role->add_cap( 'retrict_content' );
176 }
177
178 /**
179 * If the administrator role does not exist for some reason, we have a bit of a problem
180 * because this is a role management plugin and requires that someone actually be able to
181 * manage roles. So, we're going to create a custom role here. The site administrator can
182 * assign this custom role to any user they wish to work around this problem. We're only
183 * doing this for single-site installs of WordPress. The 'super admin' has permission to do
184 * pretty much anything on a multisite install.
185 */
186 elseif ( empty( $role ) && !is_multisite() ) {
187
188 /* Add the 'members_role_manager' role with limited capabilities. */
189 add_role(
190 'members_role_manager',
191 _x( 'Role Manager', 'role', 'members' ),
192 array(
193 'read' => true,
194 'list_roles' => true,
195 'edit_roles' => true
196 )
197 );
198 }
199 }
2cf6214 Importing the Members plugin files and folders.
greenshady authored
200 }
201
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
202 $members_load = new Members_Load();
203
2cf6214 Importing the Members plugin files and folders.
greenshady authored
204 ?>
Something went wrong with that request. Please try again.