| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: WP-Members |
| 4 |
Plugin URI: https://rocketgeek.com |
| 5 |
Description: WP access restriction and user registration. For more information on plugin features, refer to <a href="https://rocketgeek.com/plugins/wp-members/docs/">the online Users Guide</a>. A <a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/">Quick Start Guide</a> is also available. WP-Members(tm) is a trademark of butlerblog.com. |
| 6 |
Version: 3.5.5 |
| 7 |
Author: Chad Butler |
| 8 |
Author URI: https://butlerblog.com/ |
| 9 |
Text Domain: wp-members |
| 10 |
Domain Path: /i18n/languages/ |
| 11 |
License: GPLv3 |
| 12 |
*/ |
| 13 |
|
| 14 |
/* |
| 15 |
Copyright (c) 2006-2026 Chad Butler |
| 16 |
|
| 17 |
The name WP-Members(tm) is a trademark of butlerblog.com |
| 18 |
|
| 19 |
This program is free software; you can redistribute it and/or modify |
| 20 |
it under the terms of the GNU General Public License, version 3, as |
| 21 |
published by the Free Software Foundation. |
| 22 |
|
| 23 |
This program is distributed in the hope that it will be useful, |
| 24 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 |
GNU General Public License for more details. |
| 27 |
|
| 28 |
You should have received a copy of the GNU General Public License |
| 29 |
along with this program; if not, write to the Free Software |
| 30 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 31 |
|
| 32 |
You may also view the license here: |
| 33 |
http://www.gnu.org/licenses/gpl.html |
| 34 |
*/ |
| 35 |
|
| 36 |
/* |
| 37 |
A NOTE ABOUT LICENSE: |
| 38 |
|
| 39 |
While this plugin is freely available and open-source under the GPL3 |
| 40 |
license, that does not mean it is "public domain." You are free to modify |
| 41 |
and redistribute as long as you comply with the license. Any derivative |
| 42 |
work MUST be GPL licensed and available as open source. You also MUST give |
| 43 |
proper attribution to the original author, copyright holder, and trademark |
| 44 |
owner. This means you cannot change two lines of code and claim copyright |
| 45 |
of the entire work as your own. The GPL3 license requires that if you |
| 46 |
modify this code, you must clearly indicate what section(s) you have |
| 47 |
modified and you may only claim copyright of your modifications and not |
| 48 |
the body of work. If you are unsure or have questions about how a |
| 49 |
derivative work you are developing complies with the license, copyright, |
| 50 |
trademark, or if you do not understand the difference between |
| 51 |
open source and public domain, contact the original author at: |
| 52 |
https://rocketgeek.com/contact/. |
| 53 |
*/ |
| 54 |
|
| 55 |
// Exit if accessed directly. |
| 56 |
if ( ! defined( 'ABSPATH' ) ) { |
| 57 |
exit(); |
| 58 |
} |
| 59 |
|
| 60 |
// Initialize constants. |
| 61 |
define( 'WPMEM_VERSION', '3.5.5' ); |
| 62 |
define( 'WPMEM_DB_VERSION', '2.4.3' ); |
| 63 |
define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) ); // @todo Fairly certain this is obsolete. |
| 64 |
|
| 65 |
// Initialize the plugin. |
| 66 |
add_action( 'after_setup_theme', 'wpmem_init', 10 ); |
| 67 |
|
| 68 |
// Install the plugin. |
| 69 |
register_activation_hook( __FILE__, 'wpmem_install' ); |
| 70 |
|
| 71 |
// Run deactivation. |
| 72 |
register_deactivation_hook( __FILE__, 'wpmem_deactivate' ); |
| 73 |
|
| 74 |
|
| 75 |
/** |
| 76 |
* Initialize WP-Members. |
| 77 |
* |
| 78 |
* The initialization function contains much of what was previously just |
| 79 |
* loaded in the main plugin file. It has been moved into this function |
| 80 |
* in order to allow action hooks for loading the plugin and initializing |
| 81 |
* its features and options. |
| 82 |
* |
| 83 |
* @since 2.9.0 |
| 84 |
* @since 3.1.6 Dependencies now loaded by object. |
| 85 |
* |
| 86 |
* @global object $wpmem The WP-Members object class. |
| 87 |
*/ |
| 88 |
function wpmem_init() { |
| 89 |
|
| 90 |
// Set the object as global. |
| 91 |
global $wpmem; |
| 92 |
|
| 93 |
/** |
| 94 |
* Fires before initialization of plugin options. |
| 95 |
* |
| 96 |
* @since 2.9.0 |
| 97 |
*/ |
| 98 |
do_action( 'wpmem_pre_init' ); |
| 99 |
|
| 100 |
/** |
| 101 |
* Load initial dependencies. |
| 102 |
*/ |
| 103 |
require_once 'includes/vendor/rocketgeek-utilities/loader.php'; |
| 104 |
require_once 'includes/class-wp-members.php'; |
| 105 |
|
| 106 |
// Invoke the WP_Members class. |
| 107 |
$wpmem = new WP_Members(); |
| 108 |
|
| 109 |
/** |
| 110 |
* Fires after initialization of plugin options. |
| 111 |
* |
| 112 |
* @since 2.9.0 |
| 113 |
*/ |
| 114 |
do_action( 'wpmem_after_init' ); |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Install the plugin options. |
| 119 |
* |
| 120 |
* @since 2.5.2 |
| 121 |
* @since 3.1.1 Added rollback. |
| 122 |
* @since 3.1.6 Removed rollback. |
| 123 |
* |
| 124 |
* @param |
| 125 |
*/ |
| 126 |
function wpmem_install() { |
| 127 |
|
| 128 |
/** |
| 129 |
* Load the install file. |
| 130 |
*/ |
| 131 |
require_once( 'includes/install.php' ); |
| 132 |
|
| 133 |
// Multisite requires different install process. |
| 134 |
if ( is_multisite() ) { |
| 135 |
|
| 136 |
// If it is multisite, install options for each blog. |
| 137 |
global $wpdb; |
| 138 |
$blogs = $wpdb->get_results( $wpdb->prepare( |
| 139 |
"SELECT blog_id |
| 140 |
FROM {$wpdb->blogs} |
| 141 |
WHERE site_id = %d |
| 142 |
AND spam = '0' |
| 143 |
AND deleted = '0' |
| 144 |
AND archived = '0'", |
| 145 |
$wpdb->siteid |
| 146 |
) ); |
| 147 |
$original_blog_id = get_current_blog_id(); |
| 148 |
foreach ( $blogs as $blog_id ) { |
| 149 |
switch_to_blog( $blog_id->blog_id ); |
| 150 |
wpmem_do_install(); |
| 151 |
} |
| 152 |
switch_to_blog( $original_blog_id ); |
| 153 |
|
| 154 |
} else { |
| 155 |
|
| 156 |
// Single site install. |
| 157 |
wpmem_do_install(); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
/** |
| 163 |
* Runs downgrade steps in install function. |
| 164 |
* |
| 165 |
* @since 3.1.1 |
| 166 |
*/ |
| 167 |
function wpmem_deactivate() { |
| 168 |
include_once( 'includes/install.php' ); |
| 169 |
wpmem_plugin_deactivate(); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
add_action( 'wp_insert_site', 'wpmem_mu_new_site' ); |
| 174 |
/** |
| 175 |
* Install default plugin options for a newly added blog in multisite. |
| 176 |
* |
| 177 |
* @since 2.9.3 |
| 178 |
* @since 3.2.7 Updated to wp_insert_site (wpmu_new_blog is deprecated). |
| 179 |
* |
| 180 |
* @param $new_site |
| 181 |
*/ |
| 182 |
function wpmem_mu_new_site( $new_site ) { |
| 183 |
|
| 184 |
/** |
| 185 |
* Load the install file. |
| 186 |
*/ |
| 187 |
require_once( 'includes/install.php' ); |
| 188 |
|
| 189 |
// Switch to the new blog. |
| 190 |
switch_to_blog( $new_site->id ); |
| 191 |
|
| 192 |
// Run the WP-Members install. |
| 193 |
wpmem_do_install(); |
| 194 |
|
| 195 |
// Switch back to the current blog. |
| 196 |
restore_current_blog(); |
| 197 |
} |
| 198 |
|
| 199 |
// End of file. |