-
Notifications
You must be signed in to change notification settings - Fork 6
/
members-post-type.php
197 lines (167 loc) · 5.12 KB
/
members-post-type.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/*
Plugin Name: Members post type
Version: 1.0.10
Plugin URI: http://www.beapi.fr
Description: Manage members on WordPress as post type. Implement: post type, authentification, role, clone from WP.
Author: BE API Technical team
Author URI: https://beapi.fr/
Domain Path: languages
Network: false
Text Domain: mpt
TODO:
Custom Role API
Custom metabox for taxonomy
Custom Post Status
Pending
Unconfirmed
Widget
AJAX Mode
Social integration
Facebook / Twitter / Google+
Security
Login lock (http://plugins.svn.wordpress.org/simple-login-lockdown/trunk/)
Force HTTPs ?
+ Reset all password
+ New random password (https://github.com/soulseekah/Random-New-User-Passwords-for-WordPress)
Content restriction via roles
Browse as
----
Copyright 2017 BE API Technical team ([email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
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. See the
GNU General Public License for if ( mpt_is_member_logged_in() ) {
18
r more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
// Plugin constants
define('MPT_VERSION', '1.0.10');
define('MPT_CPT_NAME', 'member');
define('MPT_TAXO_NAME', 'members-role');
// Plugin URL and PATH
define( 'MPT_URL', plugin_dir_url( __FILE__ ) );
define( 'MPT_DIR', plugin_dir_path( __FILE__ ) );
// Used to guarantee unique hash cookies
if ( ! defined( 'COOKIEHASH' ) ) {
$siteurl = home_url( '/' );
if ( $siteurl ) {
define( 'COOKIEHASH', md5( $siteurl ) );
} else {
define( 'COOKIEHASH', '' );
}
}
// Auth constants
if ( ! defined( 'MPT_AUTH_COOKIE' ) ) {
define( 'MPT_AUTH_COOKIE', 'mpt_wordpress_' . constant( 'COOKIEHASH' ) );
}
if ( ! defined( 'MPT_SECURE_AUTH_COOKIE' ) ) {
define( 'MPT_SECURE_AUTH_COOKIE', 'mpt_wordpress_sec_' . constant( 'COOKIEHASH' ) );
}
if ( ! defined( 'MPT_LOGGED_IN_COOKIE' ) ) {
define( 'MPT_LOGGED_IN_COOKIE', 'mpt_wordpress_logged_in_' . constant( 'COOKIEHASH' ) );
}
// Function for easy load files
function _mpt_load_files( $dir, $files, $prefix = '' ) {
foreach ( $files as $file ) {
if ( is_file( MPT_DIR . $dir . $prefix . $file . ".php" ) ) {
require_once( MPT_DIR . $dir . $prefix . $file . ".php" );
}
}
}
// Plugin functions
_mpt_load_files( 'functions/', array(
'api',
'template' ) );
// Plugin client classes
_mpt_load_files( 'classes/', array(
'main',
'plugin',
'content-permissions',
'post-type', 'private-website',
'security', 'shortcode',
'taxonomy',
'widget'
), 'class-');
// Plugin helper classes
_mpt_load_files( 'classes/helpers/', array(
'member-auth',
'member-utility',
'options',
'nonces'
), 'class-');
// Plugin model classes
_mpt_load_files( 'classes/models/', array(
'member',
'roles',
'role'
), 'class-' );
// Plugin admin classes
if ( is_admin() ) {
_mpt_load_files( 'classes/admin/', array(
'content-permissions',
'main',
'post-type',
'taxonomy',
'settings-main',
'users-to-members',
'welcome-message'
), 'class-' );
// Load class for API settings
if ( ! class_exists( 'WeDevs_Settings_API' ) ) {
require_once( MPT_DIR . 'libraries/wordpress-settings-api-class/class.settings-api.php' );
}
}
// Plugin activate/desactive hooks
register_activation_hook( __FILE__, array( 'MPT_Plugin', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'MPT_Plugin', 'deactivate' ) );
add_action( 'plugins_loaded', 'init_mpt_plugin' );
function init_mpt_plugin() {
// Client
new MPT_Main();
new MPT_Post_Type();
new MPT_Taxonomy();
new MPT_Content_Permissions();
new MPT_Private_Website();
new MPT_Shortcode();
new MPT_Security();
if( is_admin() ) {
// Class admin
new MPT_Admin_Content_Permissions();
new MPT_Admin_Main();
new MPT_Admin_Post_Type();
new MPT_Admin_Taxonomy();
new MPT_Admin_Users_To_Members();
new MPT_Admin_Welcome_Message();
/**
* Handle import/export feature :
* - mpt_admin_use_import
* - mpt_admin_use_export
* To deactivate feature, declare the hook in a mu-plugin to be before "plugins_loaded"
*
* @since 0.6.0
* @author Maxime CULEA
*/
foreach( array( 'import', 'export' ) as $feature ) {
if( ! apply_filters( 'mpt_admin_use_' . $feature, true ) ) {
continue;
}
_mpt_load_files( 'classes/admin/', array( $feature ), 'class-' );
$class = 'MPT_Admin_' . ucfirst( $feature );
new $class;
}
}
// Widget
add_action( 'widgets_init', create_function( '', 'return register_widget("MPT_Widget");' ) );
}