Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 210 lines (169 sloc) 6.383 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>.
a224100 Make sure the $settings are all returned instead of only things specific...
greenshady authored
6 * Version: 0.3 Alpha
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
a224100 Make sure the $settings are all returned instead of only things specific...
greenshady authored
23 * @version 0.3.0 Alpha
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
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. */
a224100 Make sure the $settings are all returned instead of only things specific...
greenshady authored
76 define( 'MEMBERS_VERSION', '0.3.0' );
ed4bd90 Members v.0.2. Beta.
greenshady authored
77
32a381f Final version 0.2 code updates?
greenshady authored
78 /* Set the database version number of the plugin. */
79 define( 'MEMBERS_DB_VERSION', 2 );
80
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
81 /* Set constant path to the members plugin directory. */
ed4bd90 Members v.0.2. Beta.
greenshady authored
82 define( 'MEMBERS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
83
84 /* Set constant path to the members plugin URL. */
ed4bd90 Members v.0.2. Beta.
greenshady authored
85 define( 'MEMBERS_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
86
87 /* Set the constant path to the members includes directory. */
88 define( 'MEMBERS_INCLUDES', MEMBERS_DIR . trailingslashit( 'includes' ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
89
ed4bd90 Members v.0.2. Beta.
greenshady authored
90 /* Set the constant path to the members admin directory. */
91 define( 'MEMBERS_ADMIN', MEMBERS_DIR . trailingslashit( 'admin' ) );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
92 }
93
94 /**
95 * Loads the initial files needed by the plugin.
96 *
97 * @since 0.2.0
98 */
ed4bd90 Members v.0.2. Beta.
greenshady authored
99 function includes() {
100
101 /* Load the plugin functions file. */
102 require_once( MEMBERS_INCLUDES . 'functions.php' );
103
32a381f Final version 0.2 code updates?
greenshady authored
104 /* Load the update functionality. */
105 require_once( MEMBERS_INCLUDES . 'update.php' );
106
ed4bd90 Members v.0.2. Beta.
greenshady authored
107 /* Load the deprecated functions file. */
108 require_once( MEMBERS_INCLUDES . 'deprecated.php' );
109
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
110 /* Load the admin bar functions. */
111 require_once( MEMBERS_INCLUDES . 'admin-bar.php' );
112
ed4bd90 Members v.0.2. Beta.
greenshady authored
113 /* Load the functions related to capabilities. */
114 require_once( MEMBERS_INCLUDES . 'capabilities.php' );
115
116 /* Load the content permissions functions. */
117 require_once( MEMBERS_INCLUDES . 'content-permissions.php' );
118
119 /* Load the private site functions. */
120 require_once( MEMBERS_INCLUDES . 'private-site.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
121
ed4bd90 Members v.0.2. Beta.
greenshady authored
122 /* Load the shortcodes functions file. */
123 require_once( MEMBERS_INCLUDES . 'shortcodes.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
124
8f53525 Bug fixes, new admin bar stuff, and few other awesome bits of code.
greenshady authored
125 /* Load the template functions. */
126 require_once( MEMBERS_INCLUDES . 'template.php' );
127
ed4bd90 Members v.0.2. Beta.
greenshady authored
128 /* Load the widgets functions file. */
129 require_once( MEMBERS_INCLUDES . 'widgets.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
130 }
131
132 /**
133 * Loads the translation files.
134 *
135 * @since 0.2.0
136 */
ed4bd90 Members v.0.2. Beta.
greenshady authored
137 function i18n() {
138
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
139 /* Load the translation of the plugin. */
140 load_plugin_textdomain( 'members', false, 'members/languages' );
141 }
142
143 /**
144 * Loads the admin functions and files.
145 *
146 * @since 0.2.0
147 */
148 function admin() {
149
ed4bd90 Members v.0.2. Beta.
greenshady authored
150 /* Only load files if in the WordPress admin. */
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
151 if ( is_admin() ) {
152
ed4bd90 Members v.0.2. Beta.
greenshady authored
153 /* Load the main admin file. */
154 require_once( MEMBERS_ADMIN . 'admin.php' );
155
156 /* Load the plugin settings. */
157 require_once( MEMBERS_ADMIN . 'settings.php' );
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
158 }
159 }
f6b0d6d Beta 2.
greenshady authored
160
161 /**
162 * Method that runs only when the plugin is activated.
163 *
164 * @since 0.2.0
165 */
166 function activation() {
167
168 /* Get the administrator role. */
169 $role =& get_role( 'administrator' );
170
171 /* If the administrator role exists, add required capabilities for the plugin. */
172 if ( !empty( $role ) ) {
173
174 /* Role management capabilities. */
175 $role->add_cap( 'list_roles' );
176 $role->add_cap( 'create_roles' );
177 $role->add_cap( 'delete_roles' );
178 $role->add_cap( 'edit_roles' );
179
180 /* Content permissions capabilities. */
0a08977 Code cleanup, some multisite support, and fix 'restrict_content' capabil...
greenshady authored
181 $role->add_cap( 'restrict_content' );
f6b0d6d Beta 2.
greenshady authored
182 }
183
184 /**
185 * If the administrator role does not exist for some reason, we have a bit of a problem
186 * because this is a role management plugin and requires that someone actually be able to
187 * manage roles. So, we're going to create a custom role here. The site administrator can
188 * assign this custom role to any user they wish to work around this problem. We're only
189 * doing this for single-site installs of WordPress. The 'super admin' has permission to do
190 * pretty much anything on a multisite install.
191 */
192 elseif ( empty( $role ) && !is_multisite() ) {
193
194 /* Add the 'members_role_manager' role with limited capabilities. */
195 add_role(
196 'members_role_manager',
197 _x( 'Role Manager', 'role', 'members' ),
198 array(
199 'read' => true,
200 'list_roles' => true,
201 'edit_roles' => true
202 )
203 );
204 }
205 }
2cf6214 Importing the Members plugin files and folders.
greenshady authored
206 }
207
88de694 Add the Members_Load class to initialize the plugin.
greenshady authored
208 $members_load = new Members_Load();
209
2cf6214 Importing the Members plugin files and folders.
greenshady authored
210 ?>
Something went wrong with that request. Please try again.