Skip to content
This repository
Newer
Older
100644 198 lines (161 sloc) 6.014 kb
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
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>.
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
6 * Version: 0.2 Beta 2
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
13 * WordPress by making user, role, and content management as simple as using the system altogether.
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
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
23 * @version 0.2.0
24 * @author Justin Tadlock <justin@justintadlock.com>
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
25 * @copyright Copyright (c) 2009 - 2011, 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 /**
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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.
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
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() {
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
51
52 /* Set the constants needed by the plugin. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
53 add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
62 add_action( 'plugins_loaded', array( &$this, 'admin' ), 4 );
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
63
64 /* Register activation hook. */
65 register_activation_hook( __FILE__, array( &$this, 'activation' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
66 }
67
68 /**
69 * Defines constants used by the plugin.
70 *
71 * @since 0.2.0
72 */
73 function constants() {
74
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
75 /* Set the version number of the plugin. */
76 define( 'MEMBERS_VERSION', '0.2.0' );
77
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
78 /* Set constant path to the members plugin directory. */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
79 define( 'MEMBERS_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
80
81 /* Set constant path to the members plugin URL. */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
86
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
87 /* Set the constant path to the members admin directory. */
88 define( 'MEMBERS_ADMIN', MEMBERS_DIR . trailingslashit( 'admin' ) );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
89 }
90
91 /**
92 * Loads the initial files needed by the plugin.
93 *
94 * @since 0.2.0
95 */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
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
104 /* Load the functions related to capabilities. */
105 require_once( MEMBERS_INCLUDES . 'capabilities.php' );
106
107 /* Load the content permissions functions. */
108 require_once( MEMBERS_INCLUDES . 'content-permissions.php' );
109
110 /* Load the private site functions. */
111 require_once( MEMBERS_INCLUDES . 'private-site.php' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
112
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
113 /* Load the shortcodes functions file. */
114 require_once( MEMBERS_INCLUDES . 'shortcodes.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 widgets functions file. */
117 require_once( MEMBERS_INCLUDES . 'widgets.php' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
118 }
119
120 /**
121 * Loads the translation files.
122 *
123 * @since 0.2.0
124 */
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
125 function i18n() {
126
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
127 /* Load the translation of the plugin. */
128 load_plugin_textdomain( 'members', false, 'members/languages' );
129 }
130
131 /**
132 * Loads the admin functions and files.
133 *
134 * @since 0.2.0
135 */
136 function admin() {
137
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
138 /* Only load files if in the WordPress admin. */
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
139 if ( is_admin() ) {
140
ed4bd907 » greenshady
2011-05-26 Members v.0.2. Beta.
141 /* Load the main admin file. */
142 require_once( MEMBERS_ADMIN . 'admin.php' );
143
144 /* Load the plugin settings. */
145 require_once( MEMBERS_ADMIN . 'settings.php' );
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
146 }
147 }
f6b0d6d3 » greenshady
2011-06-01 Beta 2.
148
149 /**
150 * Method that runs only when the plugin is activated.
151 *
152 * @since 0.2.0
153 */
154 function activation() {
155
156 /* Get the administrator role. */
157 $role =& get_role( 'administrator' );
158
159 /* If the administrator role exists, add required capabilities for the plugin. */
160 if ( !empty( $role ) ) {
161
162 /* Role management capabilities. */
163 $role->add_cap( 'list_roles' );
164 $role->add_cap( 'create_roles' );
165 $role->add_cap( 'delete_roles' );
166 $role->add_cap( 'edit_roles' );
167
168 /* Content permissions capabilities. */
169 $role->add_cap( 'retrict_content' );
170 }
171
172 /**
173 * If the administrator role does not exist for some reason, we have a bit of a problem
174 * because this is a role management plugin and requires that someone actually be able to
175 * manage roles. So, we're going to create a custom role here. The site administrator can
176 * assign this custom role to any user they wish to work around this problem. We're only
177 * doing this for single-site installs of WordPress. The 'super admin' has permission to do
178 * pretty much anything on a multisite install.
179 */
180 elseif ( empty( $role ) && !is_multisite() ) {
181
182 /* Add the 'members_role_manager' role with limited capabilities. */
183 add_role(
184 'members_role_manager',
185 _x( 'Role Manager', 'role', 'members' ),
186 array(
187 'read' => true,
188 'list_roles' => true,
189 'edit_roles' => true
190 )
191 );
192 }
193 }
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
194 }
195
88de6945 » greenshady
2010-11-28 Add the Members_Load class to initialize the plugin.
196 $members_load = new Members_Load();
197
2cf62146 » greenshady
2010-11-25 Importing the Members plugin files and folders.
198 ?>
Something went wrong with that request. Please try again.