Skip to content
This repository
Newer
Older
100644 204 lines (163 sloc) 6.217 kb
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
1 <?php
2 /**
3 * Plugin Name: Members
40687109 »
2013-10-25 Update the plugin URI.
4 * Plugin URI: http://themehybrid.com/plugins/members
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
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>.
91a73e45 »
2013-10-25 Version bump to 0.2.4.
6 * Version: 0.2.4
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
7 * Author: Justin Tadlock
8 * Author URI: http://justintadlock.com
9 *
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
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
8f535257 » greenshady
2011-06-02 Bug fixes, new admin bar stuff, and few other awesome bits of code.
13 * WordPress by making user, role, and content management as simple as using WordPress itself.
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
14 *
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
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.
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
21 *
22 * @package Members
a6d12894 »
2013-10-25 Version bump to 0.2.4-alpha.
23 * @version 0.2.4
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
24 * @author Justin Tadlock <justin@justintadlock.com>
f946ba65 »
2013-09-27 Version bump to 0.2.3.
25 * @copyright Copyright (c) 2009 - 2013, Justin Tadlock
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
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
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
28 */
29
30 /**
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
31 * @since 0.2.0
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
32 */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
33 class Members_Load {
34
35 /**
36 * PHP5 constructor method.
37 *
38 * @since 0.2.0
39 */
40 function __construct() {
8e4e247a »
2012-10-11 PHP 5.4 fix for creating object error.
41 global $members;
42
43 /* Set up an empty class for the global $members object. */
44 $members = new stdClass;
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
45
46 /* Set the constants needed by the plugin. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
47 add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
48
49 /* Internationalize the text strings used. */
50 add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
51
52 /* Load the functions files. */
53 add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
54
55 /* Load the admin files. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
56 add_action( 'plugins_loaded', array( &$this, 'admin' ), 4 );
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
57
58 /* Register activation hook. */
59 register_activation_hook( __FILE__, array( &$this, 'activation' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
60 }
61
62 /**
63 * Defines constants used by the plugin.
64 *
65 * @since 0.2.0
66 */
67 function constants() {
68
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
69 /* Set the version number of the plugin. */
a6d12894 »
2013-10-25 Version bump to 0.2.4-alpha.
70 define( 'MEMBERS_VERSION', '0.2.4' );
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
71
32a381f9 » greenshady
2011-06-13 Final version 0.2 code updates?
72 /* Set the database version number of the plugin. */
73 define( 'MEMBERS_DB_VERSION', 2 );
74
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
75 /* Set constant path to the members plugin directory. */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
76 define( 'MEMBERS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
77
78 /* Set constant path to the members plugin URL. */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
79 define( 'MEMBERS_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
80
81 /* Set the constant path to the members includes directory. */
82 define( 'MEMBERS_INCLUDES', MEMBERS_DIR . trailingslashit( 'includes' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
83
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
84 /* Set the constant path to the members admin directory. */
85 define( 'MEMBERS_ADMIN', MEMBERS_DIR . trailingslashit( 'admin' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
86 }
87
88 /**
89 * Loads the initial files needed by the plugin.
90 *
91 * @since 0.2.0
92 */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
93 function includes() {
94
95 /* Load the plugin functions file. */
96 require_once( MEMBERS_INCLUDES . 'functions.php' );
97
32a381f9 » greenshady
2011-06-13 Final version 0.2 code updates?
98 /* Load the update functionality. */
99 require_once( MEMBERS_INCLUDES . 'update.php' );
100
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
101 /* Load the deprecated functions file. */
102 require_once( MEMBERS_INCLUDES . 'deprecated.php' );
103
8f535257 » greenshady
2011-06-02 Bug fixes, new admin bar stuff, and few other awesome bits of code.
104 /* Load the admin bar functions. */
105 require_once( MEMBERS_INCLUDES . 'admin-bar.php' );
106
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
115
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
116 /* Load the shortcodes functions file. */
117 require_once( MEMBERS_INCLUDES . 'shortcodes.php' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
118
8f535257 » greenshady
2011-06-02 Bug fixes, new admin bar stuff, and few other awesome bits of code.
119 /* Load the template functions. */
120 require_once( MEMBERS_INCLUDES . 'template.php' );
121
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
122 /* Load the widgets functions file. */
123 require_once( MEMBERS_INCLUDES . 'widgets.php' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
124 }
125
126 /**
127 * Loads the translation files.
128 *
129 * @since 0.2.0
130 */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
131 function i18n() {
132
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
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
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
144 /* Only load files if in the WordPress admin. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
145 if ( is_admin() ) {
146
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
152 }
153 }
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
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. */
30f337e1 »
2013-09-27 No need for `&` to pass by reference.
163 $role = get_role( 'administrator' );
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
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. */
0a089775 » greenshady
2011-06-08 Code cleanup, some multisite support, and fix 'restrict_content' capa…
175 $role->add_cap( 'restrict_content' );
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
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 }
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
200 }
201
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
202 $members_load = new Members_Load();
203
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
204 ?>
Something went wrong with that request. Please try again.