WP-Members Membership Plugin - Version 3.2.5

Version Description

  • Fix user profile (admin/user) issue with tos field not displaying.
  • Fix [wpmem_logged_in] shortcode to pass product attribute.
  • Fix [wpmem_field] shortcode, checks if field is set to avoid undefined index error.
  • Fix do_excerpt() if post object is not set as an object.
  • Fix logic for displaying hidden posts based on product access.
  • Added message dialog to display in Customizer.
  • Added HTML5 "required" attribute to TOS checkbox.
  • Added redirect_to attribute to logout link.
  • Added $tag parameter to wpmem_{$tag}link and wpmem{$tag}_link_str filters.
  • Added id parameter to wpmem_register_form_args filter.
  • Added wpmem_email_send_args filter.
  • Added wpmem_is_user() function to API.
  • Added wpmem_do_shortcode() utility function in API.
  • Added wpmem_export_fields filter to user export function.
  • Added label attribute to field shortcode.
  • Added user profile tabs (jquery ui tabs).
  • Updated wpmem_form_date() API function.
  • Updated check product access to handle product as an array.
  • Updated to make a nonce a default for the registration form (reduces possibility of spam registrations).
  • Updated form field creation, $value is now optional.
  • Moved textdomain to load in main class file.
  • Removed possibility of using reCAPTCHA v1 which is totally obsolete.
  • Removed widget status message ("you are not logged in") for logged out state.
Download this release

Release Info

Developer cbutlerjr
Plugin Icon 128x128 WP-Members Membership Plugin
Version 3.2.5
Comparing to
See all releases

Code changes from version 3.2.4 to 3.2.5

admin/admin.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_admin
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_admin
admin/css/admin.css CHANGED
@@ -5,13 +5,12 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
- * Copyright (c) 2006-2018 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
- * @package WordPress
12
- * @subpackage WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
 
@@ -36,6 +35,8 @@
36
  #updatesettings label {
37
  float:left;
38
  width: 166px;
 
 
39
  }
40
 
41
  #addfieldform .add-field-indent,
@@ -81,4 +82,30 @@
81
  .select2-search-field,
82
  #_wpmem_products {
83
  width: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  }
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
+ * Copyright (c) 2006-2019 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
+ * @package WP-Members
 
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
 
35
  #updatesettings label {
36
  float:left;
37
  width: 166px;
38
+ clear: both;
39
+ display: block;
40
  }
41
 
42
  #addfieldform .add-field-indent,
82
  .select2-search-field,
83
  #_wpmem_products {
84
  width: 100%;
85
+ }
86
+
87
+ /** User Profile Tabs **/
88
+ #wpmem_user_profile_tabs {
89
+ padding: 0px;
90
+ background: none;
91
+ border-width: 0px;
92
+ }
93
+ #wpmem_user_profile_tabs .ui-tabs-nav {
94
+ padding-left: 0px;
95
+ background: transparent;
96
+ border-width: 0px 0px 1px 0px;
97
+ -moz-border-radius: 0px;
98
+ -webkit-border-radius: 0px;
99
+ border-radius: 0px;
100
+ }
101
+ #wpmem_user_profile_tabs .ui-tabs-panel {
102
+ background: #fff;
103
+ border-width: 0px 1px 1px 1px;
104
+ }
105
+ #wpmem_user_profile_tabs .ui-state-active {
106
+ border: 1px solid #006799;
107
+ background: #008ec2;
108
+ }
109
+ #wpmem_user_profile_tabs .ui-state-active a {
110
+ color: #fff;
111
  }
admin/dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_warnings
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_a_do_warnings
admin/includes/api.php CHANGED
@@ -4,12 +4,12 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @author Chad Butler
12
- * @copyright 2006-2018
13
  *
14
  * Functions included:
15
  * - wpmem_add_custom_email
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @author Chad Butler
12
+ * @copyright 2006-2019
13
  *
14
  * Functions included:
15
  * - wpmem_add_custom_email
admin/includes/class-wp-members-admin-api.php CHANGED
@@ -1,575 +1,591 @@
1
- <?php
2
- /**
3
- * The WP_Members Admin API Class.
4
- *
5
- * @package WP-Members
6
- * @subpackage WP_Members Admin API Object Class
7
- * @since 3.1.0
8
- */
9
-
10
- // Exit if accessed directly.
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit();
13
- }
14
-
15
- class WP_Members_Admin_API {
16
-
17
- /**
18
- * Container for tabs.
19
- *
20
- * @since 3.1.0
21
- * @access public
22
- * @var array
23
- */
24
- public $tabs = array();
25
-
26
- /**
27
- * Container for emails.
28
- *
29
- * @since 3.1.0
30
- * @access public
31
- * @var array
32
- */
33
- public $emails = array();
34
-
35
- /**
36
- * Container for dialogs.
37
- *
38
- * @since 3.1.1
39
- * @access public
40
- * @var array
41
- */
42
- public $dialogs = array();
43
-
44
- /**
45
- * Plugin initialization function.
46
- *
47
- * @since 3.1.0
48
- */
49
- function __construct() {
50
-
51
- // Load dependencies.
52
- $this->load_dependencies();
53
-
54
- // Load admin hooks.
55
- $this->load_hooks();
56
-
57
- // Load default tabs.
58
- $tabs = $this->default_tabs();
59
-
60
- // Load default emails.
61
- $emails = $this->default_emails();
62
-
63
- // Load default dialogs.
64
- $dialogs = $this->default_dialogs();
65
-
66
- global $wpmem;
67
- $wpmem->membership->admin = new WP_Members_Products_Admin();
68
- }
69
-
70
- /**
71
- * Load dependencies.
72
- *
73
- * @since 3.1.0
74
- * @since 3.1.1 Added tab-about.php.
75
- * @since 3.1.7 Loads all admin dependent files.
76
- */
77
- function load_dependencies() {
78
-
79
- include_once( WPMEM_PATH . 'admin/admin.php' );
80
- include_once( WPMEM_PATH . 'admin/users.php' );
81
- include_once( WPMEM_PATH . 'admin/includes/class-wp-members-user-search.php' );
82
- include_once( WPMEM_PATH . 'admin/includes/class-wp-members-products-admin.php' );
83
- include_once( WPMEM_PATH . 'admin/dialogs.php' );
84
- include_once( WPMEM_PATH . 'admin/post.php' );
85
- include_once( WPMEM_PATH . 'admin/includes/api.php' );
86
- require_once( WPMEM_PATH . 'inc/class-wp-members-user-profile.php' );
87
- include_once( WPMEM_PATH . 'admin/tab-fields.php' ); // Fields tab is used for field reorder (which is ! wpmem-settings).
88
- if ( 'wpmem-settings' == wpmem_get( 'page', false, 'get' ) ) {
89
- include_once( WPMEM_PATH . 'admin/tab-options.php' );
90
- include_once( WPMEM_PATH . 'admin/tab-emails.php' );
91
- include_once( WPMEM_PATH . 'admin/tab-captcha.php' );
92
- include_once( WPMEM_PATH . 'admin/tab-about.php' );
93
- include_once( WPMEM_PATH . 'admin/tab-dialogs.php' );
94
- include_once( WPMEM_PATH . 'admin/tab-dropins.php' );
95
- }
96
- }
97
-
98
- /**
99
- * Load admin.
100
- *
101
- * @since 3.1.0
102
- * @since 3.1.7 Loads all admin hooks.
103
- *
104
- * @global object $wpmem
105
- */
106
- function load_hooks() {
107
-
108
- global $wpmem;
109
-
110
- add_action( 'admin_enqueue_scripts', array( $this, 'dashboard_enqueue_scripts' ) );
111
- add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder' );
112
- add_action( 'user_new_form', 'wpmem_admin_add_new_user' );
113
- add_filter( 'plugin_action_links', array( $this, 'plugin_links' ), 10, 2 );
114
- add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
115
-
116
- add_action( 'wpmem_admin_do_tab', 'wpmem_a_options_tab', 1 );
117
- add_action( 'wpmem_admin_do_tab', 'wpmem_a_dialogs_tab', 10 );
118
- add_action( 'wpmem_admin_do_tab', 'wpmem_a_emails_tab', 15 );
119
- add_action( 'wpmem_admin_do_tab', 'wpmem_a_about_tab', 999, 1 );
120
-
121
- // If user has a role that cannot edit users, set profile actions for non-admins.
122
-
123
- // User actions and filters.
124
- add_action( 'user_edit_form_tag', array( 'WP_Members_User_Profile', 'add_multipart' ) );
125
- add_action( 'show_user_profile', array( 'WP_Members_User_Profile', 'profile' ) );
126
- add_action( 'edit_user_profile', array( 'WP_Members_User_Profile', 'profile' ) );
127
- add_action( 'profile_update', array( 'WP_Members_User_Profile', 'update' ) );
128
- if ( current_user_can( 'list_users' ) ) {
129
- add_action( 'admin_footer-users.php', 'wpmem_bulk_user_action' );
130
- add_action( 'load-users.php', 'wpmem_users_page_load' );
131
- add_action( 'admin_notices', 'wpmem_users_admin_notices' );
132
- add_filter( 'views_users', 'wpmem_users_views' );
133
- add_filter( 'manage_users_columns', 'wpmem_add_user_column' );
134
- add_filter( 'manage_users_custom_column', 'wpmem_add_user_column_content', 10, 3 );
135
- add_action( 'wpmem_post_register_data', 'wpmem_set_new_user_non_active' );
136
- add_action( 'wpmem_user_activated', 'wpmem_set_activated_user' );
137
- add_action( 'wpmem_user_deactivated', 'wpmem_set_deactivated_user' );
138
- add_filter( 'user_row_actions', 'wpmem_insert_activate_link', 10, 2 );
139
- add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_activate' ), 7 );
140
- add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_expiration' ), 8 );
141
- add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_ip' ), 9 );
142
- if ( 1 == $wpmem->enable_products ) {
143
- add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_product' ), 10 );
144
- }
145
- }
146
-
147
- // If user has a role that can edit posts, add the block/unblock meta boxes and custom post/page columns.
148
- if ( current_user_can( 'edit_posts' ) ) {
149
- // Post actions and filters.
150
- add_action( 'add_meta_boxes', 'wpmem_block_meta_add' );
151
- add_action( 'save_post', 'wpmem_block_meta_save' );
152
- add_filter( 'manage_posts_columns', 'wpmem_post_columns' );
153
- add_action( 'manage_posts_custom_column', 'wpmem_post_columns_content', 10, 2 );
154
- add_filter( 'manage_pages_columns', 'wpmem_post_columns' );
155
- add_action( 'manage_pages_custom_column', 'wpmem_post_columns_content', 10, 2 );
156
- add_action( 'admin_footer-edit.php', 'wpmem_bulk_posts_action' );
157
- add_action( 'load-edit.php', 'wpmem_posts_page_load' );
158
- add_action( 'admin_notices', 'wpmem_posts_admin_notices' );
159
- add_action( 'load-post.php', 'wpmem_load_tinymce' );
160
- add_action( 'load-post-new.php', 'wpmem_load_tinymce' );
161
- }
162
-
163
- if ( ! is_multisite() && current_user_can( 'manage_options' ) ) {
164
- add_action('wp_dashboard_setup', 'butlerblog_dashboard_widget');
165
- }
166
-
167
- } // End of load_hooks()
168
-
169
- /**
170
- * Display admin tabs.
171
- *
172
- * @since 3.1.0
173
- *
174
- * @param string $current The current tab being displayed (default: options).
175
- */
176
- function do_tabs( $current = 'options' ) {
177
-
178
- /**
179
- * Filter the admin tabs for the plugin settings page.
180
- *
181
- * @since 2.8.0
182
- *
183
- * @param array $tabs An array of the tabs to be displayed on the plugin settings page.
184
- */
185
- $this->tabs = apply_filters( 'wpmem_admin_tabs', $this->tabs );
186
-
187
- $links = array();
188
- foreach ( $this->tabs as $tab => $name ) {
189
- $link_args = array( 'page' => 'wpmem-settings', 'tab' => $tab );
190
- $link = add_query_arg( $link_args, admin_url( 'options-general.php' ) );
191
- $class = ( $tab == $current ) ? 'nav-tab nav-tab-active' : 'nav-tab';
192
- $links[] = sprintf( '<a class="%s" href="%s">%s</a>', $class, $link, $name );
193
- }
194
-
195
- echo '<h2 class="nav-tab-wrapper">';
196
- foreach ( $links as $link ) {
197
- echo $link;
198
- }
199
- echo '</h2>';
200
- }
201
-
202
- /**
203
- * Adds custom email dialog to the Emails tab.
204
- *
205
- * @since 3.1.0
206
- *
207
- * @param array $args Settings array for the email.
208
- */
209
- function do_email_input( $args ) { ?>
210
- <tr valign="top"><td colspan="2"><strong><?php echo esc_html( $args['heading'] ); ?></strong></td></tr>
211
- <tr valign="top">
212
- <th scope="row"><?php echo esc_html( $args['subject_label'] ); ?></th>
213
- <td><input type="text" name="<?php echo esc_attr( $args['subject_input'] ); ?>" size="80" value="<?php echo esc_attr( wp_unslash( $args['subject_value'] ) ); ?>"></td>
214
- </tr>
215
- <tr valign="top">
216
- <th scope="row"><?php echo esc_html( $args['body_label'] ); ?></th>
217
- <td><textarea name="<?php echo esc_attr( $args['body_input'] ); ?>" rows="12" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['body_value'] ) ); ?></textarea></td>
218
- </tr>
219
- <tr><td colspan="2"><hr /></td></tr><?php
220
- }
221
-
222
- /**
223
- * Saves custom email settings.
224
- *
225
- * @since 3.1.0
226
- *
227
- * @param array $args Settings array for the email.
228
- */
229
- function email_update( $args ) {
230
- $settings = array(
231
- 'subj' => sanitize_text_field( wpmem_get( $args['subject_input'] ) ),
232
- 'body' => wp_kses( wpmem_get( $args['body_input'] ), 'post' ),
233
- );
234
- update_option( $args['name'], $settings, true );
235
- $this->emails[ $args['name'] ]['subject_value'] = $settings['subj'];
236
- $this->emails[ $args['name'] ]['body_value'] = $settings['body'];
237
- return;
238
- }
239
-
240
- /**
241
- * Handles custom email settings.
242
- *
243
- * @since 3.1.0
244
- *
245
- * @param array $args Settings array for the email.
246
- * @return array $args
247
- */
248
- function add_email( $args ) {
249
-
250
- // Get saved settings.
251
- $settings = get_option( $args['name'] );
252
-
253
- $defaults = array(
254
- 'name' => $args['name'],
255
- 'heading' => __( 'Custom email', 'wp-members' ),
256
- 'subject_label' => __( 'Subject', 'wp-members' ),
257
- 'subject_input' => $args['name'] . '_subject',
258
- 'subject_value' => ( $settings ) ? $settings['subj'] : __( 'Subject', 'wp-members' ),
259
- 'body_label' => __( 'Body', 'wp-members' ),
260
- 'body_input' => $args['name'] . '_body',
261
- 'body_value' => ( $settings ) ? $settings['body'] : __( 'Your custom email message content.', 'wp-members' ),
262
- );
263
-
264
- // Merge args with settings.
265
- $args = wp_parse_args( $args, $defaults );
266
-
267
- $this->emails[ $args['name'] ] = $args;
268
-
269
- return $args;
270
- }
271
-
272
- /**
273
- * Adds dialogs to the Dialogs tab.
274
- *
275
- * @since 3.1.1
276
- *
277
- * @param array $args Settings array for the dialog.
278
- */
279
- function do_dialog_input( $args ) { ?>
280
- <tr valign="top">
281
- <th scope="row"><?php echo esc_html( $args['label'] ); ?></th>
282
- <td><textarea name="<?php echo esc_attr( $args['name'] . "_dialog" ); ?>" rows="3" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['value'] ) ); ?></textarea></td>
283
- </tr><?php
284
- }
285
-
286
- /**
287
- * Saves custom dialog settings.
288
- *
289
- * @since 3.1.1
290
- */
291
- function dialog_update() {
292
- $settings = array();
293
- foreach ( $this->dialogs as $dialog ) {
294
- if ( isset( $_POST[ $dialog['name'] . '_dialog' ] ) ) {
295
- $settings[ $dialog['name'] ] = wp_kses( $_POST[ $dialog['name'] . '_dialog' ], 'post' );
296
- }
297
- }
298
- update_option( 'wpmembers_dialogs', $settings, true );
299
- // Refresh settings
300
- $this->default_dialogs();
301
- return;
302
- }
303
-
304
- /**
305
- * Handles custom dialog settings.
306
- *
307
- * @since 3.1.1
308
- *
309
- * @param array $args Settings array for the dialog.
310
- * @return array $args
311
- */
312
- function add_dialog( $args ) {
313
- global $wpmem;
314
- if ( is_array( $args ) && isset( $args['label'] ) ) {
315
- $defaults = array(
316
- 'name' => $args['name'],
317
- 'label' => $args['label'],
318
- //'input' => $args['name'] . '_dialog',
319
- 'value' => $args['value'],
320
- //'value' => ( $args['value'] ) ? $args['value'] : $wpmem->get_text( $key ),
321
- );
322
-
323
- // Merge args with settings.
324
- $args = wp_parse_args( $args, $defaults );
325
-
326
- $this->dialogs[ $args['name'] ] = $args;
327
- }
328
-
329
- //return $args;
330
- }
331
-
332
- /**
333
- * Settings for default tabs.
334
- *
335
- * @since 3.1.0
336
- */
337
- function default_tabs() {
338
- $this->tabs = array(
339
- 'options' => 'WP-Members ' . __( 'Options', 'wp-members' ),
340
- 'fields' => __( 'Fields', 'wp-members' ),
341
- 'dialogs' => __( 'Dialogs', 'wp-members' ),
342
- 'emails' => __( 'Emails', 'wp-members' ),
343
- );
344
- }
345
-
346
- /**
347
- * Settings for default emails.
348
- *
349
- * @since 3.1.0
350
- */
351
- function default_emails() {
352
- global $wpmem;
353
-
354
- if ( $wpmem->mod_reg == 0 ) {
355
-
356
- $this->add_email( array(
357
- 'name' => 'wpmembers_email_newreg',
358
- 'heading' => __( "New Registration", 'wp-members' ),
359
- 'subject_input' => 'wpmembers_email_newreg_subj',
360
- 'body_input' => 'wpmembers_email_newreg_body',
361
- ) );
362
-
363
- } else {
364
-
365
- $this->add_email( array(
366
- 'name' => 'wpmembers_email_newmod',
367
- 'heading' => __( "Registration is Moderated", 'wp-members' ),
368
- 'subject_input' => 'wpmembers_email_newmod_subj',
369
- 'body_input' => 'wpmembers_email_newmod_body',
370
- ) );
371
- $this->add_email( array(
372
- 'name' => 'wpmembers_email_appmod',
373
- 'heading' => __( "Registration is Moderated, User is Approved", 'wp-members' ),
374
- 'subject_input' => 'wpmembers_email_appmod_subj',
375
- 'body_input' => 'wpmembers_email_appmod_body',
376
- ) );
377
- }
378
-
379
- $this->add_email( array(
380
- 'name' => 'wpmembers_email_repass',
381
- 'heading' => __( "Password Reset", 'wp-members' ),
382
- 'subject_input' => 'wpmembers_email_repass_subj',
383
- 'body_input' => 'wpmembers_email_repass_body',
384
- ) );
385
-
386
- $this->add_email( array(
387
- 'name' => 'wpmembers_email_getuser',
388
- 'heading' => __( "Retrieve Username", 'wp-members' ),
389
- 'subject_input' => 'wpmembers_email_getuser_subj',
390
- 'body_input' => 'wpmembers_email_getuser_body',
391
- ) );
392
-
393
- if ( $wpmem->notify == 1 ) {
394
- $this->add_email( array(
395
- 'name' => 'wpmembers_email_notify',
396
- 'heading' => __( "Admin Notification", 'wp-members' ),
397
- 'subject_input' => 'wpmembers_email_notify_subj',
398
- 'body_input' => 'wpmembers_email_notify_body',
399
- ) );
400
- }
401
-
402
- }
403
-
404
- /**
405
- * Settings for default dialogs.
406
- *
407
- * @since 3.1.1
408
- */
409
- function default_dialogs() {
410
- global $wpmem;
411
-
412
- /**
413
- * Filter the dialog array to add custom dialogs.
414
- *
415
- * @since 3.1.1
416
- *
417
- * @param array $dialog_array
418
- */
419
- $dialogs = apply_filters( 'wpmem_dialogs', get_option( 'wpmembers_dialogs' ) );
420
-
421
- $dialog_labels = array(
422
- 'restricted_msg' => __( "Restricted post (or page), displays above the login/registration form", 'wp-members' ),
423
- 'user' => __( "Username is taken", 'wp-members' ),
424
- 'email' => __( "Email is registered", 'wp-members' ),
425
- 'success' => __( "Registration completed", 'wp-members' ),
426
- 'editsuccess' => __( "User update", 'wp-members' ),
427
- 'pwdchangerr' => __( "Passwords did not match", 'wp-members' ),
428
- 'pwdchangesuccess' => __( "Password changes", 'wp-members' ),
429
- 'pwdreseterr' => __( "Username or email do not exist when trying to reset forgotten password", 'wp-members' ),
430
- 'pwdresetsuccess' => __( "Password reset", 'wp-members' ),
431
- );
432
-
433
- foreach ( $dialogs as $key => $val ) {
434
- if ( array_key_exists( $key, $dialog_labels ) ) {
435
- $dialogs[ $key ] = array(
436
- 'name' => $key,
437
- 'label' => $dialog_labels[ $key ],
438
- 'value' => $dialogs[ $key ],
439
- );
440
- }
441
- }
442
-
443
- foreach ( $dialogs as $val ) {
444
- $this->add_dialog( $val );
445
- }
446
- }
447
-
448
-
449
- /**
450
- * Get the current form.
451
- *
452
- * @since 3.1.2
453
- *
454
- * @todo Work on multi-form project for 3.1.2
455
- */
456
- function get_form( $form = 'default' ) {
457
- /*
458
- $current_form = ( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
459
- $wpmem_forms = get_option( 'wpmembers_forms' );
460
- $fields = $wpmem_forms[ $current_form ];
461
- $this->current_form = $current_form;
462
- $this->current_form_fields = $fields;
463
- */
464
- $this->current_form = sanitize_text_field( wpmem_get( 'form', $form, 'get' ) ); //( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
465
- global $wpmem;
466
- // Add numeric array form fields as associative
467
- //foreach( $wpmem->fields as $field ) {
468
- // $wpmem->fields[ $field[2] ] = $field;
469
- //}
470
- $this->current_form_fields = wpmem_fields();
471
- }
472
-
473
- /**
474
- * Build admin panel form action url.
475
- *
476
- * @since 3.1.8
477
- *
478
- * @global string $pagenow
479
- * @global string $plugin_page
480
- * @global object $wpmem The WP_Members Object.
481
- * @param mixed $args Array of additional arguments|boolean. Default: false.
482
- * @return string $url
483
- */
484
- function form_post_url( $args = false ) {
485
- global $pagenow, $plugin_page, $wpmem;
486
- $tab = sanitize_text_field( wpmem_get( 'tab', false, 'get' ) );
487
- $params = array( 'page' => $plugin_page );
488
- if ( $tab ) {
489
- $params['tab'] = $tab;
490
- }
491
- if ( $args ) {
492
- foreach( $args as $key => $val ) {
493
- $params[ $key ] = $val;
494
- }
495
- }
496
- $url = add_query_arg( $params, admin_url( $pagenow ) );
497
- return esc_url( $url );
498
- }
499
-
500
- /**
501
- * Enqueues the admin javascript and css files.
502
- *
503
- * Replaces wpmem_admin_enqueue_scripts().
504
- * Only loads the js and css on admin screens that use them.
505
- *
506
- * @since 3.1.7
507
- * @since 3.2.0 Moved into admin object, renamed dashboard_enqueue_scripts().
508
- * @since 3.2.1 Load js for post.php hook.
509
- *
510
- * @global object $wpmem
511
- * @param string $hook The admin screen hook being loaded.
512
- */
513
- function dashboard_enqueue_scripts( $hook ) {
514
- global $wpmem;
515
- if ( 'edit.php' == $hook || 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook || 'user-edit.php' == $hook || 'profile.php' == $hook ) {
516
- wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
517
- }
518
- if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook ) {
519
- wp_enqueue_script( 'wpmem-admin', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
520
- }
521
- if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products ) {
522
- wp_register_style( 'select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css', false, '4.0.5', 'all' );
523
- wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js', array( 'jquery' ), '4.0.5', true );
524
- wp_enqueue_style( 'select2css' );
525
- wp_enqueue_script( 'select2' );
526
- }
527
- }
528
-
529
- /**
530
- * Filter to add link to settings from plugin panel.
531
- *
532
- * @since 2.4.0
533
- * @since 3.2.0 Moved to admin API class, renamed from wpmem_admin_plugin_links().
534
- *
535
- * @param array $links
536
- * @param string $file
537
- * @return array $links
538
- */
539
- function plugin_links( $links, $file ) {
540
- static $wpmem_plugin;
541
- if ( ! $wpmem_plugin ) {
542
- $wpmem_plugin = plugin_basename( WPMEM_PATH . '/wp-members.php' );
543
- }
544
- if ( $file == $wpmem_plugin ) {
545
- $settings_link = '<a href="' . add_query_arg( 'page', 'wpmem-settings', 'options-general.php' ) . '">' . __( 'Settings', 'wp-members' ) . '</a>';
546
- $links = array_merge( array( $settings_link ), $links );
547
- }
548
- return $links;
549
- }
550
-
551
- /**
552
- * Returns an array of WordPress reserved terms.
553
- *
554
- * @since 3.0.2
555
- * @since 3.2.3 Moved to WP_Members_Admin_API class.
556
- *
557
- * @return array An array of WordPress reserved terms.
558
- */
559
- function wp_reserved_terms() {
560
- $reserved_terms = array( 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and', 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'customize_messenger_channel', 'customized', 'cpage', 'day', 'debug', 'error', 'exact', 'feed', 'fields', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name', 'nav_menu', 'nonce', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm', 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type', 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 'role', 's', 'search', 'second', 'sentence', 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id', 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'theme', 'type', 'w', 'withcomments', 'withoutcomments', 'year' );
561
-
562
- /**
563
- * Filter the array of reserved terms.
564
- *
565
- * @since 3.0.2
566
- *
567
- * @param array $reserved_terms
568
- */
569
- $reserved_terms = apply_filters( 'wpmem_wp_reserved_terms', $reserved_terms );
570
-
571
- return $reserved_terms;
572
- }
573
- } // End of WP_Members_Admin_API class.
574
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  // End of file.
1
+ <?php
2
+ /**
3
+ * The WP_Members Admin API Class.
4
+ *
5
+ * @package WP-Members
6
+ * @subpackage WP_Members Admin API Object Class
7
+ * @since 3.1.0
8
+ */
9
+
10
+ // Exit if accessed directly.
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit();
13
+ }
14
+
15
+ class WP_Members_Admin_API {
16
+
17
+ /**
18
+ * Container for tabs.
19
+ *
20
+ * @since 3.1.0
21
+ * @access public
22
+ * @var array
23
+ */
24
+ public $tabs = array();
25
+
26
+ /**
27
+ * Container for emails.
28
+ *
29
+ * @since 3.1.0
30
+ * @access public
31
+ * @var array
32
+ */
33
+ public $emails = array();
34
+
35
+ /**
36
+ * Container for dialogs.
37
+ *
38
+ * @since 3.1.1
39
+ * @access public
40
+ * @var array
41
+ */
42
+ public $dialogs = array();
43
+
44
+ /**
45
+ * Plugin initialization function.
46
+ *
47
+ * @since 3.1.0
48
+ */
49
+ function __construct() {
50
+
51
+ // Load dependencies.
52
+ $this->load_dependencies();
53
+
54
+ // Load admin hooks.
55
+ $this->load_hooks();
56
+
57
+ // Load default tabs.
58
+ $tabs = $this->default_tabs();
59
+
60
+ // Load default emails.
61
+ $emails = $this->default_emails();
62
+
63
+ // Load default dialogs.
64
+ $dialogs = $this->default_dialogs();
65
+
66
+ global $wpmem;
67
+ $wpmem->membership->admin = new WP_Members_Products_Admin();
68
+ }
69
+
70
+ /**
71
+ * Load dependencies.
72
+ *
73
+ * @since 3.1.0
74
+ * @since 3.1.1 Added tab-about.php.
75
+ * @since 3.1.7 Loads all admin dependent files.
76
+ */
77
+ function load_dependencies() {
78
+
79
+ include_once( WPMEM_PATH . 'admin/admin.php' );
80
+ include_once( WPMEM_PATH . 'admin/users.php' );
81
+ include_once( WPMEM_PATH . 'admin/includes/class-wp-members-user-search.php' );
82
+ include_once( WPMEM_PATH . 'admin/includes/class-wp-members-products-admin.php' );
83
+ include_once( WPMEM_PATH . 'admin/dialogs.php' );
84
+ include_once( WPMEM_PATH . 'admin/post.php' );
85
+ include_once( WPMEM_PATH . 'admin/includes/api.php' );
86
+ include_once( WPMEM_PATH . 'admin/tab-fields.php' ); // Fields tab is used for field reorder (which is ! wpmem-settings).
87
+ if ( 'wpmem-settings' == wpmem_get( 'page', false, 'get' ) ) {
88
+ include_once( WPMEM_PATH . 'admin/tab-options.php' );
89
+ include_once( WPMEM_PATH . 'admin/tab-emails.php' );
90
+ include_once( WPMEM_PATH . 'admin/tab-captcha.php' );
91
+ include_once( WPMEM_PATH . 'admin/tab-about.php' );
92
+ include_once( WPMEM_PATH . 'admin/tab-dialogs.php' );
93
+ include_once( WPMEM_PATH . 'admin/tab-dropins.php' );
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Load admin.
99
+ *
100
+ * @since 3.1.0
101
+ * @since 3.1.7 Loads all admin hooks.
102
+ *
103
+ * @global object $wpmem
104
+ */
105
+ function load_hooks() {
106
+
107
+ global $wpmem;
108
+
109
+ add_action( 'admin_enqueue_scripts', array( $this, 'dashboard_enqueue_scripts' ) );
110
+ add_action( 'wp_ajax_wpmem_a_field_reorder', 'wpmem_a_do_field_reorder' );
111
+ add_action( 'user_new_form', 'wpmem_admin_add_new_user' );
112
+ add_filter( 'plugin_action_links', array( $this, 'plugin_links' ), 10, 2 );
113
+ add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
114
+
115
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_options_tab', 1 );
116
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_dialogs_tab', 10 );
117
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_emails_tab', 15 );
118
+ add_action( 'wpmem_admin_do_tab', 'wpmem_a_about_tab', 999, 1 );
119
+
120
+ // If user has a role that cannot edit users, set profile actions for non-admins.
121
+
122
+ // User actions and filters.
123
+ add_action( 'user_edit_form_tag', array( 'WP_Members_User_Profile', 'add_multipart' ) );
124
+ add_action( 'show_user_profile', array( 'WP_Members_User_Profile', 'profile' ) );
125
+ add_action( 'edit_user_profile', array( 'WP_Members_User_Profile', 'profile' ) );
126
+ add_action( 'profile_update', array( 'WP_Members_User_Profile', 'update' ) );
127
+ add_action( 'edit_user_profile', array( 'WP_Members_User_Profile', '_profile_tabs' ), 99 );
128
+
129
+ if ( current_user_can( 'list_users' ) ) {
130
+ add_action( 'admin_footer-users.php', 'wpmem_bulk_user_action' );
131
+ add_action( 'load-users.php', 'wpmem_users_page_load' );
132
+ add_action( 'admin_notices', 'wpmem_users_admin_notices' );
133
+ add_filter( 'views_users', 'wpmem_users_views' );
134
+ add_filter( 'manage_users_columns', 'wpmem_add_user_column' );
135
+ add_filter( 'manage_users_custom_column', 'wpmem_add_user_column_content', 10, 3 );
136
+ add_action( 'wpmem_post_register_data', 'wpmem_set_new_user_non_active' );
137
+ add_action( 'wpmem_user_activated', 'wpmem_set_activated_user' );
138
+ add_action( 'wpmem_user_deactivated', 'wpmem_set_deactivated_user' );
139
+ add_filter( 'user_row_actions', 'wpmem_insert_activate_link', 10, 2 );
140
+ add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_activate' ), 7 );
141
+ add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_expiration' ), 8 );
142
+ add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_ip' ), 9 );
143
+ if ( 1 == $wpmem->enable_products ) {
144
+ add_action( 'wpmem_admin_after_profile', array( 'WP_Members_User_Profile', '_show_product' ), 10 );
145
+ }
146
+ }
147
+
148
+ // If user has a role that can edit posts, add the block/unblock meta boxes and custom post/page columns.
149
+ if ( current_user_can( 'edit_posts' ) ) {
150
+ // Post actions and filters.
151
+ add_action( 'add_meta_boxes', 'wpmem_block_meta_add' );
152
+ add_action( 'save_post', 'wpmem_block_meta_save' );
153
+ add_filter( 'manage_posts_columns', 'wpmem_post_columns' );
154
+ add_action( 'manage_posts_custom_column', 'wpmem_post_columns_content', 10, 2 );
155
+ add_filter( 'manage_pages_columns', 'wpmem_post_columns' );
156
+ add_action( 'manage_pages_custom_column', 'wpmem_post_columns_content', 10, 2 );
157
+ add_action( 'admin_footer-edit.php', 'wpmem_bulk_posts_action' );
158
+ add_action( 'load-edit.php', 'wpmem_posts_page_load' );
159
+ add_action( 'admin_notices', 'wpmem_posts_admin_notices' );
160
+ add_action( 'load-post.php', 'wpmem_load_tinymce' );
161
+ add_action( 'load-post-new.php', 'wpmem_load_tinymce' );
162
+ }
163
+
164
+ if ( ! is_multisite() && current_user_can( 'manage_options' ) ) {
165
+ add_action('wp_dashboard_setup', 'butlerblog_dashboard_widget');
166
+ }
167
+
168
+ } // End of load_hooks()
169
+
170
+ /**
171
+ * Display admin tabs.
172
+ *
173
+ * @since 3.1.0
174
+ *
175
+ * @param string $current The current tab being displayed (default: options).
176
+ */
177
+ function do_tabs( $current = 'options' ) {
178
+
179
+ /**
180
+ * Filter the admin tabs for the plugin settings page.
181
+ *
182
+ * @since 2.8.0
183
+ *
184
+ * @param array $tabs An array of the tabs to be displayed on the plugin settings page.
185
+ */
186
+ $this->tabs = apply_filters( 'wpmem_admin_tabs', $this->tabs );
187
+
188
+ $links = array();
189
+ foreach ( $this->tabs as $tab => $name ) {
190
+ $link_args = array( 'page' => 'wpmem-settings', 'tab' => $tab );
191
+ $link = add_query_arg( $link_args, admin_url( 'options-general.php' ) );
192
+ $class = ( $tab == $current ) ? 'nav-tab nav-tab-active' : 'nav-tab';
193
+ $links[] = sprintf( '<a class="%s" href="%s">%s</a>', $class, $link, $name );
194
+ }
195
+
196
+ echo '<h2 class="nav-tab-wrapper">';
197
+ foreach ( $links as $link ) {
198
+ echo $link;
199
+ }
200
+ echo '</h2>';
201
+ }
202
+
203
+ /**
204
+ * Adds custom email dialog to the Emails tab.
205
+ *
206
+ * @since 3.1.0
207
+ *
208
+ * @param array $args Settings array for the email.
209
+ */
210
+ function do_email_input( $args ) { ?>
211
+ <tr valign="top"><td colspan="2"><strong><?php echo esc_html( $args['heading'] ); ?></strong></td></tr>
212
+ <tr valign="top">
213
+ <th scope="row"><?php echo esc_html( $args['subject_label'] ); ?></th>
214
+ <td><input type="text" name="<?php echo esc_attr( $args['subject_input'] ); ?>" size="80" value="<?php echo esc_attr( wp_unslash( $args['subject_value'] ) ); ?>"></td>
215
+ </tr>
216
+ <tr valign="top">
217
+ <th scope="row"><?php echo esc_html( $args['body_label'] ); ?></th>
218
+ <td><textarea name="<?php echo esc_attr( $args['body_input'] ); ?>" rows="12" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['body_value'] ) ); ?></textarea></td>
219
+ </tr>
220
+ <tr><td colspan="2"><hr /></td></tr><?php
221
+ }
222
+
223
+ /**
224
+ * Saves custom email settings.
225
+ *
226
+ * @since 3.1.0
227
+ *
228
+ * @param array $args Settings array for the email.
229
+ */
230
+ function email_update( $args ) {
231
+ $settings = array(
232
+ 'subj' => sanitize_text_field( wpmem_get( $args['subject_input'] ) ),
233
+ 'body' => wp_kses( wpmem_get( $args['body_input'] ), 'post' ),
234
+ );
235
+ update_option( $args['name'], $settings, true );
236
+ $this->emails[ $args['name'] ]['subject_value'] = $settings['subj'];
237
+ $this->emails[ $args['name'] ]['body_value'] = $settings['body'];
238
+ return;
239
+ }
240
+
241
+ /**
242
+ * Handles custom email settings.
243
+ *
244
+ * @since 3.1.0
245
+ *
246
+ * @param array $args Settings array for the email.
247
+ * @return array $args
248
+ */
249
+ function add_email( $args ) {
250
+
251
+ // Get saved settings.
252
+ $settings = get_option( $args['name'] );
253
+
254
+ $defaults = array(
255
+ 'name' => $args['name'],
256
+ 'heading' => __( 'Custom email', 'wp-members' ),
257
+ 'subject_label' => __( 'Subject', 'wp-members' ),
258
+ 'subject_input' => $args['name'] . '_subject',
259
+ 'subject_value' => ( $settings ) ? $settings['subj'] : __( 'Subject', 'wp-members' ),
260
+ 'body_label' => __( 'Body', 'wp-members' ),
261
+ 'body_input' => $args['name'] . '_body',
262
+ 'body_value' => ( $settings ) ? $settings['body'] : __( 'Your custom email message content.', 'wp-members' ),
263
+ );
264
+
265
+ // Merge args with settings.
266
+ $args = wp_parse_args( $args, $defaults );
267
+
268
+ $this->emails[ $args['name'] ] = $args;
269
+
270
+ return $args;
271
+ }
272
+
273
+ /**
274
+ * Adds dialogs to the Dialogs tab.
275
+ *
276
+ * @since 3.1.1
277
+ *
278
+ * @param array $args Settings array for the dialog.
279
+ */
280
+ function do_dialog_input( $args ) { ?>
281
+ <tr valign="top">
282
+ <th scope="row"><?php echo esc_html( $args['label'] ); ?></th>
283
+ <td><textarea name="<?php echo esc_attr( $args['name'] . "_dialog" ); ?>" rows="3" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['value'] ) ); ?></textarea></td>
284
+ </tr><?php
285
+ }
286
+
287
+ /**
288
+ * Saves custom dialog settings.
289
+ *
290
+ * @since 3.1.1
291
+ */
292
+ function dialog_update() {
293
+ $settings = array();
294
+ foreach ( $this->dialogs as $dialog ) {
295
+ if ( isset( $_POST[ $dialog['name'] . '_dialog' ] ) ) {
296
+ $settings[ $dialog['name'] ] = wp_kses( $_POST[ $dialog['name'] . '_dialog' ], 'post' );
297
+ }
298
+ }
299
+ update_option( 'wpmembers_dialogs', $settings, true );
300
+ // Refresh settings
301
+ $this->default_dialogs();
302
+ return;
303
+ }
304
+
305
+ /**
306
+ * Handles custom dialog settings.
307
+ *
308
+ * @since 3.1.1
309
+ *
310
+ * @param array $args Settings array for the dialog.
311
+ * @return array $args
312
+ */
313
+ function add_dialog( $args ) {
314
+ global $wpmem;
315
+ if ( is_array( $args ) && isset( $args['label'] ) ) {
316
+ $defaults = array(
317
+ 'name' => $args['name'],
318
+ 'label' => $args['label'],
319
+ //'input' => $args['name'] . '_dialog',
320
+ 'value' => $args['value'],
321
+ //'value' => ( $args['value'] ) ? $args['value'] : $wpmem->get_text( $key ),
322
+ );
323
+
324
+ // Merge args with settings.
325
+ $args = wp_parse_args( $args, $defaults );
326
+
327
+ $this->dialogs[ $args['name'] ] = $args;
328
+ }
329
+
330
+ //return $args;
331
+ }
332
+
333
+ /**
334
+ * Settings for default tabs.
335
+ *
336
+ * @since 3.1.0
337
+ */
338
+ function default_tabs() {
339
+ $this->tabs = array(
340
+ 'options' => 'WP-Members ' . __( 'Options', 'wp-members' ),
341
+ 'fields' => __( 'Fields', 'wp-members' ),
342
+ 'dialogs' => __( 'Dialogs', 'wp-members' ),
343
+ 'emails' => __( 'Emails', 'wp-members' ),
344
+ );
345
+ }
346
+
347
+ /**
348
+ * Settings for default emails.
349
+ *
350
+ * @since 3.1.0
351
+ */
352
+ function default_emails() {
353
+ global $wpmem;
354
+
355
+ if ( $wpmem->mod_reg == 0 ) {
356
+
357
+ $this->add_email( array(
358
+ 'name' => 'wpmembers_email_newreg',
359
+ 'heading' => __( "New Registration", 'wp-members' ),
360
+ 'subject_input' => 'wpmembers_email_newreg_subj',
361
+ 'body_input' => 'wpmembers_email_newreg_body',
362
+ ) );
363
+
364
+ } else {
365
+
366
+ $this->add_email( array(
367
+ 'name' => 'wpmembers_email_newmod',
368
+ 'heading' => __( "Registration is Moderated", 'wp-members' ),
369
+ 'subject_input' => 'wpmembers_email_newmod_subj',
370
+ 'body_input' => 'wpmembers_email_newmod_body',
371
+ ) );
372
+ $this->add_email( array(
373
+ 'name' => 'wpmembers_email_appmod',
374
+ 'heading' => __( "Registration is Moderated, User is Approved", 'wp-members' ),
375
+ 'subject_input' => 'wpmembers_email_appmod_subj',
376
+ 'body_input' => 'wpmembers_email_appmod_body',
377
+ ) );
378
+ }
379
+
380
+ $this->add_email( array(
381
+ 'name' => 'wpmembers_email_repass',
382
+ 'heading' => __( "Password Reset", 'wp-members' ),
383
+ 'subject_input' => 'wpmembers_email_repass_subj',
384
+ 'body_input' => 'wpmembers_email_repass_body',
385
+ ) );
386
+
387
+ $this->add_email( array(
388
+ 'name' => 'wpmembers_email_getuser',
389
+ 'heading' => __( "Retrieve Username", 'wp-members' ),
390
+ 'subject_input' => 'wpmembers_email_getuser_subj',
391
+ 'body_input' => 'wpmembers_email_getuser_body',
392
+ ) );
393
+
394
+ if ( $wpmem->notify == 1 ) {
395
+ $this->add_email( array(
396
+ 'name' => 'wpmembers_email_notify',
397
+ 'heading' => __( "Admin Notification", 'wp-members' ),
398
+ 'subject_input' => 'wpmembers_email_notify_subj',
399
+ 'body_input' => 'wpmembers_email_notify_body',
400
+ ) );
401
+ }
402
+
403
+ }
404
+
405
+ /**
406
+ * Settings for default dialogs.
407
+ *
408
+ * @since 3.1.1
409
+ */
410
+ function default_dialogs() {
411
+ global $wpmem;
412
+
413
+ /**
414
+ * Filter the dialog array to add custom dialogs.
415
+ *
416
+ * @since 3.1.1
417
+ *
418
+ * @param array $dialog_array
419
+ */
420
+ $dialogs = apply_filters( 'wpmem_dialogs', get_option( 'wpmembers_dialogs' ) );
421
+
422
+ $dialog_labels = array(
423
+ 'restricted_msg' => __( "Restricted post (or page), displays above the login/registration form", 'wp-members' ),
424
+ 'user' => __( "Username is taken", 'wp-members' ),
425
+ 'email' => __( "Email is registered", 'wp-members' ),
426
+ 'success' => __( "Registration completed", 'wp-members' ),
427
+ 'editsuccess' => __( "User update", 'wp-members' ),
428
+ 'pwdchangerr' => __( "Passwords did not match", 'wp-members' ),
429
+ 'pwdchangesuccess' => __( "Password changes", 'wp-members' ),
430
+ 'pwdreseterr' => __( "Username or email do not exist when trying to reset forgotten password", 'wp-members' ),
431
+ 'pwdresetsuccess' => __( "Password reset", 'wp-members' ),
432
+ );
433
+
434
+ foreach ( $dialogs as $key => $val ) {
435
+ if ( array_key_exists( $key, $dialog_labels ) ) {
436
+ $dialogs[ $key ] = array(
437
+ 'name' => $key,
438
+ 'label' => $dialog_labels[ $key ],
439
+ 'value' => $dialogs[ $key ],
440
+ );
441
+ }
442
+ }
443
+
444
+ foreach ( $dialogs as $val ) {
445
+ $this->add_dialog( $val );
446
+ }
447
+ }
448
+
449
+
450
+ /**
451
+ * Get the current form.
452
+ *
453
+ * @since 3.1.2
454
+ *
455
+ * @todo Work on multi-form project, no current milestone.
456
+ */
457
+ function get_form( $form = 'default' ) {
458
+ /*
459
+ $current_form = ( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
460
+ $wpmem_forms = get_option( 'wpmembers_forms' );
461
+ $fields = $wpmem_forms[ $current_form ];
462
+ $this->current_form = $current_form;
463
+ $this->current_form_fields = $fields;
464
+ */
465
+ $this->current_form = sanitize_text_field( wpmem_get( 'form', $form, 'get' ) ); //( isset( $_GET['form'] ) ) ? $_GET['form'] : $form;
466
+ global $wpmem;
467
+ // Add numeric array form fields as associative
468
+ //foreach( $wpmem->fields as $field ) {
469
+ // $wpmem->fields[ $field[2] ] = $field;
470
+ //}
471
+ $this->current_form_fields = wpmem_fields();
472
+ }
473
+
474
+ /**
475
+ * Build admin panel form action url.
476
+ *
477
+ * @since 3.1.8
478
+ *
479
+ * @global string $pagenow
480
+ * @global string $plugin_page
481
+ * @global object $wpmem The WP_Members Object.
482
+ * @param mixed $args Array of additional arguments|boolean. Default: false.
483
+ * @return string $url
484
+ */
485
+ function form_post_url( $args = false ) {
486
+ global $pagenow, $plugin_page, $wpmem;
487
+ $tab = sanitize_text_field( wpmem_get( 'tab', false, 'get' ) );
488
+ $params = array( 'page' => $plugin_page );
489
+ if ( $tab ) {
490
+ $params['tab'] = $tab;
491
+ }
492
+ if ( $args ) {
493
+ foreach( $args as $key => $val ) {
494
+ $params[ $key ] = $val;
495
+ }
496
+ }
497
+ $url = add_query_arg( $params, admin_url( $pagenow ) );
498
+ return esc_url( $url );
499
+ }
500
+
501
+ /**
502
+ * Enqueues the admin javascript and css files.
503
+ *
504
+ * Replaces wpmem_admin_enqueue_scripts().
505
+ * Only loads the js and css on admin screens that use them.
506
+ *
507
+ * @since 3.1.7
508
+ * @since 3.2.0 Moved into admin object, renamed dashboard_enqueue_scripts().
509
+ * @since 3.2.1 Load js for post.php hook.
510
+ *
511
+ * @global object $current_screen
512
+ * @global object $wpmem
513
+ * @param string $hook The admin screen hook being loaded.
514
+ */
515
+ function dashboard_enqueue_scripts( $hook ) {
516
+ global $current_screen, $wpmem;
517
+ if ( 'edit.php' == $hook || 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook || 'user-edit.php' == $hook || 'profile.php' == $hook ) {
518
+ wp_enqueue_style( 'wpmem-admin', WPMEM_DIR . 'admin/css/admin.css', '', WPMEM_VERSION );
519
+ }
520
+ if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook ) {
521
+ wp_enqueue_script( 'wpmem-admin', WPMEM_DIR . 'admin/js/admin.js', '', WPMEM_VERSION );
522
+ }
523
+ if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products ) {
524
+ wp_register_style( 'select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css', false, '4.0.5', 'all' );
525
+ wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js', array( 'jquery' ), '4.0.5', true );
526
+ wp_enqueue_style( 'select2css' );
527
+ wp_enqueue_script( 'select2' );
528
+ }
529
+ if ( 'user-edit' == $current_screen->id ) {
530
+ wp_enqueue_script( 'jquery' );
531
+ wp_enqueue_script( 'jquery-ui-core' ); // enqueue jQuery UI Core
532
+ wp_enqueue_script( 'jquery-ui-tabs' ); // enqueue jQuery UI Tabs
533
+
534
+ wp_register_style( 'jquery-ui', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
535
+ wp_enqueue_style( 'jquery-ui' );
536
+ }
537
+ if ( 'settings_page_wpmem-settings' == $hook ) {
538
+ wp_enqueue_script( 'jquery' );
539
+ wp_enqueue_script( 'jquery-ui-core' );// enqueue jQuery UI Core
540
+ wp_enqueue_script( 'jquery-ui-dialog' );
541
+ wp_register_style( 'jquery-ui', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css' );
542
+ }
543
+ }
544
+
545
+ /**
546
+ * Filter to add link to settings from plugin panel.
547
+ *
548
+ * @since 2.4.0
549
+ * @since 3.2.0 Moved to admin API class, renamed from wpmem_admin_plugin_links().
550
+ *
551
+ * @param array $links
552
+ * @param string $file
553
+ * @return array $links
554
+ */
555
+ function plugin_links( $links, $file ) {
556
+ static $wpmem_plugin;
557
+ if ( ! $wpmem_plugin ) {
558
+ $wpmem_plugin = plugin_basename( WPMEM_PATH . '/wp-members.php' );
559
+ }
560
+ if ( $file == $wpmem_plugin ) {
561
+ $settings_link = '<a href="' . add_query_arg( 'page', 'wpmem-settings', 'options-general.php' ) . '">' . __( 'Settings', 'wp-members' ) . '</a>';
562
+ $links = array_merge( array( $settings_link ), $links );
563
+ }
564
+ return $links;
565
+ }
566
+
567
+ /**
568
+ * Returns an array of WordPress reserved terms.
569
+ *
570
+ * @since 3.0.2
571
+ * @since 3.2.3 Moved to WP_Members_Admin_API class.
572
+ *
573
+ * @return array An array of WordPress reserved terms.
574
+ */
575
+ function wp_reserved_terms() {
576
+ $reserved_terms = array( 'attachment', 'attachment_id', 'author', 'author_name', 'calendar', 'cat', 'category', 'category__and', 'category__in', 'category__not_in', 'category_name', 'comments_per_page', 'comments_popup', 'customize_messenger_channel', 'customized', 'cpage', 'day', 'debug', 'error', 'exact', 'feed', 'fields', 'hour', 'link_category', 'm', 'minute', 'monthnum', 'more', 'name', 'nav_menu', 'nonce', 'nopaging', 'offset', 'order', 'orderby', 'p', 'page', 'page_id', 'paged', 'pagename', 'pb', 'perm', 'post', 'post__in', 'post__not_in', 'post_format', 'post_mime_type', 'post_status', 'post_tag', 'post_type', 'posts', 'posts_per_archive_page', 'posts_per_page', 'preview', 'robots', 'role', 's', 'search', 'second', 'sentence', 'showposts', 'static', 'subpost', 'subpost_id', 'tag', 'tag__and', 'tag__in', 'tag__not_in', 'tag_id', 'tag_slug__and', 'tag_slug__in', 'taxonomy', 'tb', 'term', 'theme', 'type', 'w', 'withcomments', 'withoutcomments', 'year' );
577
+
578
+ /**
579
+ * Filter the array of reserved terms.
580
+ *
581
+ * @since 3.0.2
582
+ *
583
+ * @param array $reserved_terms
584
+ */
585
+ $reserved_terms = apply_filters( 'wpmem_wp_reserved_terms', $reserved_terms );
586
+
587
+ return $reserved_terms;
588
+ }
589
+ } // End of WP_Members_Admin_API class.
590
+
591
  // End of file.
admin/includes/class-wp-members-products-admin.php CHANGED
@@ -205,7 +205,7 @@ class WP_Members_Products_Admin {
205
 
206
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
207
  if ( ! isset( $_POST['wpmem_product_nonce'] ) || ! wp_verify_nonce( $_POST['wpmem_product_nonce'], '_wpmem_product_nonce' ) ) return;
208
- if ( ! current_user_can( 'edit_post', $post_id ) ) return;
209
 
210
  $post = get_post( $post_id );
211
 
205
 
206
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
207
  if ( ! isset( $_POST['wpmem_product_nonce'] ) || ! wp_verify_nonce( $_POST['wpmem_product_nonce'], '_wpmem_product_nonce' ) ) return;
208
+ if ( ! current_user_can( 'edit_posts', $post_id ) ) return;
209
 
210
  $post = get_post( $post_id );
211
 
admin/js/admin.js CHANGED
@@ -5,12 +5,12 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
- * Copyright (c) 2006-2018 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WP-Members
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  */
15
 
16
 
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
+ * Copyright (c) 2006-2019 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
  * @package WP-Members
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
 
admin/post.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_posts_action
@@ -218,14 +218,17 @@ function wpmem_block_meta() {
218
  <?php
219
  $original_value = ''; $original_label = '';
220
  foreach ( $post_meta_settings as $key => $value ) {
221
- $original_value = ( $post_meta_value == $key ) ? $key : $original_value;
222
  $original_label = ( $post_meta_value == $key ) ? $value['text'] : $original_label;
223
  echo '<input type="radio" id="wpmem_block_status_' . $key . '" name="wpmem_block" value="' . $key . '" ' . checked( $post_meta_value, $key, false ) . ' /><label>' . $value['text'] . '</label><br />';
224
  }
225
  echo '<input type="hidden" id="wpmem_block_original_value" name="wpmem_block_original_value" value="' . $original_value . '" />';
226
  echo '<input type="hidden" id="wpmem_block_original_label" name="wpmem_block_original_label" value="' . $original_label . '" />';
227
  ?>
228
- <p><a href="#" class="hide-if-no-js button" id="wpmem_ok_block_status"><?php echo _e( 'OK' ); ?></a> <!--<a href="#" class="hide-if-no-js" id="wpmem_cancel_block_status"><?php _e( 'Cancel' ); ?></a>--></p>
 
 
 
229
  </div>
230
  </p>
231
  <?php
@@ -366,7 +369,6 @@ function wpmem_post_columns_content( $column_name, $post_ID ) {
366
  * @global object $wpmem_shortcode The WP_Members_TinyMCE_Buttons object.
367
  */
368
  function wpmem_load_tinymce() {
369
- // @todo For now, only load if WP version is high enough.
370
  if ( version_compare( get_bloginfo( 'version' ), '3.9', '>=' ) ) {
371
  global $wpmem_shortcode;
372
  include( WPMEM_PATH . 'admin/includes/class-wp-members-tinymce-buttons.php' );
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_posts_action
218
  <?php
219
  $original_value = ''; $original_label = '';
220
  foreach ( $post_meta_settings as $key => $value ) {
221
+ $original_value = ( $post_meta_value == $key ) ? $key : $original_value;
222
  $original_label = ( $post_meta_value == $key ) ? $value['text'] : $original_label;
223
  echo '<input type="radio" id="wpmem_block_status_' . $key . '" name="wpmem_block" value="' . $key . '" ' . checked( $post_meta_value, $key, false ) . ' /><label>' . $value['text'] . '</label><br />';
224
  }
225
  echo '<input type="hidden" id="wpmem_block_original_value" name="wpmem_block_original_value" value="' . $original_value . '" />';
226
  echo '<input type="hidden" id="wpmem_block_original_label" name="wpmem_block_original_label" value="' . $original_label . '" />';
227
  ?>
228
+ <p>
229
+ <a href="#" class="hide-if-no-js button" id="wpmem_ok_block_status"><?php echo _e( 'Ok' ); ?></a>
230
+ <!--<a href="#" class="hide-if-no-js" id="wpmem_cancel_block_status"><?php _e( 'Cancel' ); ?></a>--><?php // @todo Cannot use this until js is updated to set the radio group back to the original value (otherwise it's confusing for the user). ?>
231
+ </p>
232
  </div>
233
  </p>
234
  <?php
369
  * @global object $wpmem_shortcode The WP_Members_TinyMCE_Buttons object.
370
  */
371
  function wpmem_load_tinymce() {
 
372
  if ( version_compare( get_bloginfo( 'version' ), '3.9', '>=' ) ) {
373
  global $wpmem_shortcode;
374
  include( WPMEM_PATH . 'admin/includes/class-wp-members-tinymce-buttons.php' );
admin/tab-captcha.php CHANGED
@@ -6,13 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
- * @package WordPress
13
- * @subpackage WP-Members
14
  * @author Chad Butler
15
- * @copyright 2006-2018
16
  *
17
  * Functions included:
18
  * - wpmem_a_build_captcha_options
@@ -64,7 +63,7 @@ function wpmem_a_build_captcha_options() {
64
 
65
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
66
  $url = home_url();
67
- $help_link = __( sprintf( 'See the %sUsers Guide on CAPTCHA%s.', '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/registration/using-captcha/" target="_blank">', '</a>' ), 'wp-members' );
68
  ?>
69
  <div class="metabox-holder has-right-sidebar">
70
 
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
+ * @package WP-Members
 
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_captcha_options
63
 
64
  $wpmem_captcha = get_option( 'wpmembers_captcha' );
65
  $url = home_url();
66
+ $help_link = sprintf( __( 'See the %sUsers Guide on CAPTCHA%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/registration/using-captcha/" target="_blank">', '</a>' );
67
  ?>
68
  <div class="metabox-holder has-right-sidebar">
69
 
admin/tab-dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_dialogs
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_dialogs
admin/tab-dropins.php CHANGED
@@ -3,14 +3,13 @@
3
  * WP-Members Dropins Admin Functions
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
- * You can find out more about this plugin at https://rocketgeek.com/plugins/wp-members/extensions/editor/
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
- * @subpackage WP-Members Editor
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  */
15
 
16
  // Exit if accessed directly.
3
  * WP-Members Dropins Admin Functions
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
+ * You can find out more about this plugin at https://rocketgeek.com/plugins/wp-members/
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
 
11
  * @author Chad Butler
12
+ * @copyright 2006-2019
13
  */
14
 
15
  // Exit if accessed directly.
admin/tab-emails.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_emails
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_emails
admin/tab-fields.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  // Exit if accessed directly.
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  */
16
 
17
  // Exit if accessed directly.
admin/tab-options.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_options
@@ -57,8 +57,8 @@ function wpmem_a_build_options() {
57
 
58
  /** This filter is documented in wp-members/inc/email.php */
59
  $admin_email = apply_filters( 'wpmem_notify_addr', get_option( 'admin_email' ) );
60
- $chg_email = __( sprintf( '%sChange%s or %sFilter%s this address', '<a href="' . site_url( 'wp-admin/options-general.php', 'admin' ) . '">', '</a>', '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/filter-hooks/wpmem_notify_addr/">', '</a>' ), 'wp-members' );
61
- $help_link = __( sprintf( 'See the %sUsers Guide on plugin options%s.', '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/plugin-settings/options/" target="_blank">', '</a>' ), 'wp-members' );
62
 
63
  // Build an array of post types
64
  $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
@@ -81,7 +81,8 @@ function wpmem_a_build_options() {
81
  <div class="postbox">
82
  <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
83
  <div class="inside">
84
- <strong><i><?php echo $help_link; ?></i></strong>
 
85
  </div>
86
  </div>
87
  <?php wpmem_a_rss_box(); ?>
@@ -182,7 +183,7 @@ function wpmem_a_build_options() {
182
  /** This filter is defined in class-wp-members.php */
183
  $dropin_folder = apply_filters( 'wpmem_dropin_folder', WPMEM_DROPIN_DIR );
184
  $arr = array(
185
- array(__('Enable Products', 'wp-members'),'wpmem_settings_products',__('Enables creation of different membership products'),'enable_products'),
186
  array(__('Clone menus','wp-members'),'wpmem_settings_menus',__('Enables logged in menus','wp-members'),'clone_menus'),
187
  array(__('Notify admin','wp-members'),'wpmem_settings_notify',sprintf(__('Notify %s for each new registration? %s','wp-members'),$admin_email,$chg_email),'notify'),
188
  array(__('Moderate registration','wp-members'),'wpmem_settings_moderate',__('Holds new registrations for admin approval','wp-members'),'mod_reg'),
@@ -301,6 +302,62 @@ function wpmem_a_build_options() {
301
  </div><!-- #post-body-content -->
302
  </div><!-- #post-body -->
303
  </div><!-- .metabox-holder -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  <?php
305
  }
306
 
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_a_build_options
57
 
58
  /** This filter is documented in wp-members/inc/email.php */
59
  $admin_email = apply_filters( 'wpmem_notify_addr', get_option( 'admin_email' ) );
60
+ $chg_email = sprintf( __( '%sChange%s or %sFilter%s this address', 'wp-members' ), '<a href="' . site_url( 'wp-admin/options-general.php', 'admin' ) . '">', '</a>', '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/filter-hooks/wpmem_notify_addr/">', '</a>' );
61
+ $help_link = sprintf( __( 'See the %sUsers Guide on plugin options%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/users-guide/plugin-settings/options/" target="_blank">', '</a>' );
62
 
63
  // Build an array of post types
64
  $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
81
  <div class="postbox">
82
  <h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
83
  <div class="inside">
84
+ <p><strong><i><?php echo $help_link; ?></i></strong></p>
85
+ <p><button id="opener">Get Settings Information</button></p>
86
  </div>
87
  </div>
88
  <?php wpmem_a_rss_box(); ?>
183
  /** This filter is defined in class-wp-members.php */
184
  $dropin_folder = apply_filters( 'wpmem_dropin_folder', WPMEM_DROPIN_DIR );
185
  $arr = array(
186
+ array(__('Enable Products', 'wp-members'),'wpmem_settings_products',__('Enables creation of different membership products','wp-members'),'enable_products'),
187
  array(__('Clone menus','wp-members'),'wpmem_settings_menus',__('Enables logged in menus','wp-members'),'clone_menus'),
188
  array(__('Notify admin','wp-members'),'wpmem_settings_notify',sprintf(__('Notify %s for each new registration? %s','wp-members'),$admin_email,$chg_email),'notify'),
189
  array(__('Moderate registration','wp-members'),'wpmem_settings_moderate',__('Holds new registrations for admin approval','wp-members'),'mod_reg'),
302
  </div><!-- #post-body-content -->
303
  </div><!-- #post-body -->
304
  </div><!-- .metabox-holder -->
305
+ <script>
306
+ jQuery(document).ready(function($){
307
+ $( function() {
308
+ $( "#dialog-message" ).dialog({
309
+ autoOpen: false,
310
+ modal: true,
311
+ buttons: {
312
+ <?php _e( 'Close', 'wp-members' ); ?>: function() {
313
+ $( this ).dialog( "close" );
314
+ }
315
+ }
316
+ });
317
+ $( "#opener" ).on( "click", function() {
318
+ $( "#dialog-message" ).dialog( "open" );
319
+ });
320
+ } );
321
+ $("#select_all").click(function(){
322
+ $("textarea").select();
323
+ document.execCommand('copy');
324
+ });
325
+ $(window).resize(function() {
326
+ $("#dialog-message").dialog("option", "position", {my: "center", at: "center", of: window});
327
+ });
328
+ });
329
+ </script>
330
+ <div id="dialog-message" title="<?php _e( 'WP-Members Settings', 'wp-members' ); ?>">
331
+ <h3><span><?php _e( 'WP-Members Settings', 'wp-members' ); ?></span></h3>
332
+ <p><?php _e( 'The following is your WP-Members settings information if needed for support.', 'wp-members' ); ?></p>
333
+ <pre>
334
+ <textarea cols=80 rows=10 align=left wrap=soft style="width:100%;" id="supportinfo" wrap="soft"><?php
335
+ global $wp_version, $wpdb, $wpmem;
336
+ echo "WP Version: " . $wp_version . "\r\n";
337
+ echo "PHP Version: " . phpversion() . "\r\n";
338
+ echo "MySQL Version: " . $wpdb->db_version() . "\r\n";
339
+ wpmem_fields();
340
+ print_r( $wpmem );
341
+
342
+ echo '***************** Plugin Info *******************' . "\r\n";
343
+ $all_plugins = get_plugins();
344
+ $active_plugins = get_option( 'active_plugins' );
345
+ $active_display = ''; $inactive_display = '';
346
+ foreach ( $all_plugins as $key => $value ) {
347
+ if ( in_array( $key, $active_plugins ) ) {
348
+ $active_display.= $key . " | " . $value['Name'] . " | Version: " . $value['Version'] . "\r\n";
349
+ } else {
350
+ $inactive_display.= $key . " | " . $value['Name'] . " | Version: " . $value['Version'] . "\r\n";
351
+ }
352
+ }
353
+ echo "*************** Active Plugins **************** \r\n";
354
+ echo $active_display;
355
+ echo "*************** Inactive Plugins **************** \r\n";
356
+ echo $inactive_display;
357
+ ?></textarea>
358
+ </pre>
359
+ <button id="select_all" class="ui-button-text"><?php _e( 'Click to Copy', 'wp-members' ); ?></button>
360
+ </div>
361
  <?php
362
  }
363
 
admin/user-export.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  // Exit if accessed directly.
@@ -52,6 +52,33 @@ function wpmem_export_users( $args, $users = null ) {
52
  * @param array $args An array of arguments to merge with defaults. Default null.
53
  */
54
  $args = wp_parse_args( apply_filters( 'wpmem_export_args', $args ), $defaults );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  // Output needs to be buffered, start the buffer.
57
  ob_start();
@@ -68,27 +95,15 @@ function wpmem_export_users( $args, $users = null ) {
68
  $handle = fopen( 'php://output', 'w' );
69
  fputs( $handle, "\xEF\xBB\xBF" ); // UTF-8 BOM
70
 
71
- $header = array( 'ID' => 'User ID', 'username' => 'Username' );
72
  // Remove excluded fields from $export_fields while setting up $header array.
73
- foreach ( $args['export_fields'] as $meta => $field ) {
 
74
  if ( in_array( $meta, $args['exclude_fields'] ) ) {
75
- unset( $args['export_fields'][ $meta ] );
76
  } else {
77
- $header[ $meta ] = $field['label'];
78
  }
79
  }
80
-
81
- if ( 1 == $wpmem->mod_reg ) {
82
- $header['active'] = __( 'Activated?', 'wp-members');
83
- }
84
-
85
- if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
86
- $header['exp_type'] = __( 'Subscription', 'wp-members' );
87
- $header['expires'] = __( 'Expires', 'wp-members' );
88
- }
89
-
90
- $header['user_registered'] = __( 'Registered', 'wp-members' );
91
- $header['wpmem_reg_ip'] = __( 'IP', 'wp-members' );
92
 
93
  /**
94
  * Filters user export header row before assembly.
@@ -102,34 +117,46 @@ function wpmem_export_users( $args, $users = null ) {
102
  fputcsv( $handle, $header );
103
 
104
  // Loop through the array of users, assemble csv.
105
- // $args['export_fields'] only includes fields to be exported at this point.
106
  foreach ( $users as $user ) {
107
 
108
  $user_info = get_userdata( $user );
109
 
110
  $wp_user_fields = [ 'username', 'user_email', 'user_nicename', 'user_url', 'display_name' ];
111
- $row = array( 'ID' => $user_info->ID, 'username' => $user_info->user_login );
112
- foreach ( $args['export_fields'] as $meta => $field ) {
113
- if ( in_array( $meta, $wp_user_fields ) ) {
114
- $row[ $meta ] = ( 'username' == $meta ) ? $user_info->user_login : $user_info->{$meta};
115
- } else {
116
- $raw_data = get_user_meta( $user, $meta, true );
117
- $row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  }
119
  }
120
 
121
- if ( 1 == $wpmem->mod_reg ) {
122
- $row['active'] = get_user_meta( $user, 'active', 1 ) ? __( 'Yes' ) : __( 'No' );
123
- }
124
-
125
- if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
126
- $row['exp_type'] = get_user_meta( $user, 'exp_type', true );
127
- $row['expires'] = get_user_meta( $user, 'expires', true );
128
- }
129
-
130
- $row['user_registered'] = $user_info->user_registered;
131
- $row['wpmem_reg_ip'] = get_user_meta( $user, 'wpmem_reg_ip', true );
132
-
133
  /**
134
  * Filter the user data before assembly.
135
  *
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  */
16
 
17
  // Exit if accessed directly.
52
  * @param array $args An array of arguments to merge with defaults. Default null.
53
  */
54
  $args = wp_parse_args( apply_filters( 'wpmem_export_args', $args ), $defaults );
55
+
56
+ // Prepare fields, add additional "special" fields.
57
+ $export_fields = array(
58
+ 'ID' => __( 'User ID', 'wp-members' ),
59
+ 'username' => __( 'Username', 'wp-members' ),
60
+ );
61
+ foreach( $args['export_fields'] as $meta_key => $value ) {
62
+ $export_fields[ $meta_key ] = $value['label'];
63
+ }
64
+ if ( 1 == $wpmem->mod_reg ) {
65
+ $export_fields['active'] = __( 'Activated?', 'wp-members');
66
+ }
67
+ if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
68
+ $export_fields['exp_type'] = __( 'Subscription', 'wp-members' );
69
+ $export_fields['expires'] = __( 'Expires', 'wp-members' );
70
+ }
71
+ $export_fields['user_registered'] = __( 'Registered', 'wp-members' );
72
+ $export_fields['wpmem_reg_ip'] = __( 'IP', 'wp-members' );
73
+
74
+ /**
75
+ * Filter the export fields.
76
+ *
77
+ * @since 3.2.5
78
+ *
79
+ * @param array $export_fields
80
+ */
81
+ $export_fields = apply_filters( 'wpmem_export_fields', $export_fields );
82
 
83
  // Output needs to be buffered, start the buffer.
84
  ob_start();
95
  $handle = fopen( 'php://output', 'w' );
96
  fputs( $handle, "\xEF\xBB\xBF" ); // UTF-8 BOM
97
 
 
98
  // Remove excluded fields from $export_fields while setting up $header array.
99
+ $header = array();
100
+ foreach ( $export_fields as $meta => $field ) {
101
  if ( in_array( $meta, $args['exclude_fields'] ) ) {
102
+ unset( $export_fields[ $meta ] );
103
  } else {
104
+ $header[ $meta ] = $field;
105
  }
106
  }
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  /**
109
  * Filters user export header row before assembly.
117
  fputcsv( $handle, $header );
118
 
119
  // Loop through the array of users, assemble csv.
120
+ // $export_fields only includes fields to be exported at this point.
121
  foreach ( $users as $user ) {
122
 
123
  $user_info = get_userdata( $user );
124
 
125
  $wp_user_fields = [ 'username', 'user_email', 'user_nicename', 'user_url', 'display_name' ];
126
+ foreach ( $export_fields as $meta => $field ) {
127
+ switch ( $meta ) {
128
+ case 'ID':
129
+ $row[ $meta ] = $user_info->ID;
130
+ break;
131
+ case 'username':
132
+ $row[ $meta ] = $user_info->user_login;
133
+ break;
134
+ case 'active':
135
+ $row[ $meta ] = get_user_meta( $user, 'active', 1 ) ? __( 'Yes' ) : __( 'No' );
136
+ break;
137
+ case 'exp_type':
138
+ $row['exp_type'] = get_user_meta( $user, 'exp_type', true );
139
+ break;
140
+ case 'expires':
141
+ $row['expires'] = get_user_meta( $user, 'expires', true );
142
+ break;
143
+ case 'user_registered':
144
+ $row['user_registered'] = $user_info->user_registered;
145
+ break;
146
+ case 'wpmem_reg_ip':
147
+ $row['wpmem_reg_ip'] = get_user_meta( $user, 'wpmem_reg_ip', true );
148
+ break;
149
+ default:
150
+ if ( in_array( $meta, $wp_user_fields ) ) {
151
+ $row[ $meta ] = ( 'username' == $meta ) ? $user_info->user_login : $user_info->{$meta};
152
+ } else {
153
+ $raw_data = get_user_meta( $user, $meta, true );
154
+ $row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
155
+ }
156
+ break;
157
  }
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  /**
161
  * Filter the user data before assembly.
162
  *
admin/users.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_user_action
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_bulk_user_action
css/generic-no-float.css CHANGED
@@ -5,13 +5,12 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
- * Copyright (c) 2006-2018 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
- * @package WordPress
12
- * @subpackage WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  /*
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
+ * Copyright (c) 2006-2019 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
+ * @package WP-Members
 
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
  /*
css/generic-rigid.css CHANGED
@@ -5,13 +5,12 @@
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
- * Copyright (c) 2006-2018 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
- * @package WordPress
12
- * @subpackage WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  /*
5
  *
6
  * This file is part of the WP-Members plugin by Chad Butler
7
  * You can find out more about this plugin at https://rocketgeek.com
8
+ * Copyright (c) 2006-2019 Chad Butler
9
  * WP-Members(tm) is a trademark of butlerblog.com
10
  *
11
+ * @package WP-Members
 
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
  /*
inc/api-email.php CHANGED
@@ -4,13 +4,13 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  */
15
 
16
  /**
@@ -46,13 +46,36 @@ function wpmem_mail_from_name() {
46
  *
47
  * @since 3.2.3
48
  *
49
- * @global object $wpmem The WP_Members object.
50
- * @param mixed $args Settings arguments or The User's ID.
51
- * @param string $password Password from the registration process.
52
- * @param string $toggle Toggle indicating the email being sent (newreg|newmod|appmod|repass|getuser).
53
- * @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
54
- * @param array $fields Array of the registration data (defaults to null).
55
- * @param array $custom Array of custom email information (defaults to null).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  */
57
  function wpmem_email_to_user( $args, $password = null, $tag = null, $wpmem_fields = null, $field_data = null, $custom = null ) {
58
  global $wpmem;
@@ -66,7 +89,7 @@ function wpmem_email_to_user( $args, $password = null, $tag = null, $wpmem_field
66
  } else {
67
  $user_id = $args;
68
  }
69
- $wpmem->email->to_user( $user_id, $password, $toggle, $wpmem_fields, $field_data, $custom );
70
  return;
71
  }
72
 
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
  /**
46
  *
47
  * @since 3.2.3
48
  *
49
+ * @global object $wpmem The WP_Members object.
50
+ * @param mixed $args {
51
+ * Settings arguments or The User's ID.
52
+ *
53
+ * @type int $user_id
54
+ * @type string $password
55
+ * @type string $tag
56
+ * @type array $wpmem_fields
57
+ * @type array $fields
58
+ * @type array $custom {
59
+ * Settings for custom email if used (optional).
60
+ *
61
+ * @type string $subj The email subject.
62
+ * @type string $body The email message body.
63
+ * @type string $tag The email tag.
64
+ * }
65
+ * }
66
+ * @param string $password Password from the registration process.
67
+ * @param string $tag Indicates the email being sent (newreg|newmod|appmod|repass|getuser).
68
+ * @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
69
+ * @param array $fields Array of the registration data (defaults to null).
70
+ * @param array $custom {
71
+ * Array of custom email information (defaults to null).
72
+ *
73
+ * @type string $subj The email subject.
74
+ * @type string $body The email message body.
75
+ * @type string $tag The email tag.
76
+ * }
77
+ *
78
+ * @todo Will probably change the WP_Members_Email::to_user() arguments to just accept the array.
79
  */
80
  function wpmem_email_to_user( $args, $password = null, $tag = null, $wpmem_fields = null, $field_data = null, $custom = null ) {
81
  global $wpmem;
89
  } else {
90
  $user_id = $args;
91
  }
92
+ $wpmem->email->to_user( $user_id, $password, $tag, $wpmem_fields, $field_data, $custom );
93
  return;
94
  }
95
 
inc/api-forms.php CHANGED
@@ -4,13 +4,13 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  *
15
  * Functions included:
16
  *
@@ -76,8 +76,8 @@ function wpmem_register_form( $args ) {
76
  * @param string|array $args {
77
  * @type string $name (required) The field meta key.
78
  * @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
79
- * @type string $value (required) The field's value (can be a null value).
80
- * @type string $compare (required) Compare value.
81
  * @type string $class (optional) Class identifier for the field.
82
  * @type boolean $required (optional) If a value is required default: true).
83
  * @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
@@ -153,7 +153,7 @@ function wpmem_fields( $tag = '', $form = 'default' ) {
153
  $wpmem->load_fields( $form );
154
  }
155
 
156
- // @todo Convert tag.
157
  $tag = $wpmem->convert_tag( $tag );
158
 
159
  /**
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  *
15
  * Functions included:
16
  *
76
  * @param string|array $args {
77
  * @type string $name (required) The field meta key.
78
  * @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
79
+ * @type string $value (optional) The field's value (can be a null value).
80
+ * @type string $compare (optional) Compare value.
81
  * @type string $class (optional) Class identifier for the field.
82
  * @type boolean $required (optional) If a value is required default: true).
83
  * @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
153
  $wpmem->load_fields( $form );
154
  }
155
 
156
+ // @todo Review for removal.
157
  $tag = $wpmem->convert_tag( $tag );
158
 
159
  /**
inc/api-users.php CHANGED
@@ -4,15 +4,28 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  */
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  /**
17
  * Checks if user has a particular role.
18
  *
@@ -283,4 +296,25 @@ function wpmem_retrieve_username() {
283
  global $wpmem;
284
  return $wpmem->user->retrieve_username();
285
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  // End of file.
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  */
15
 
16
+ /**
17
+ * Checks if a user exists.
18
+ *
19
+ * @since 3.2.5
20
+ *
21
+ * @param $user_id
22
+ * @return boolean
23
+ */
24
+ function wpmem_is_user( $user_id ) {
25
+ $user = get_userdata( $user_id );
26
+ return ( $user ) ? true : false;
27
+ }
28
+
29
  /**
30
  * Checks if user has a particular role.
31
  *
296
  global $wpmem;
297
  return $wpmem->user->retrieve_username();
298
  }
299
+
300
+ /**
301
+ * Creates a membership number.
302
+ *
303
+ * @since 3.1.1
304
+ * @since 3.2.0 Changed "lead" to "pad".
305
+ *
306
+ * @param array $args {
307
+ * @type string $option The wp_options name for the counter setting (required).
308
+ * @type string $meta_key The field's meta key (required).
309
+ * @type int $start Number to start with (optional, default 0).
310
+ * @type int $increment Number to increment by (optional, default 1).
311
+ * @type int $digits Number of digits for the number (optional).
312
+ * @type boolen $pad Pad leading zeros (optional, default true).
313
+ * }
314
+ * @return string $membersip_number
315
+ */
316
+ function wpmem_create_membership_number( $args ) {
317
+ global $wpmem;
318
+ return $wpmem->api->generate_membership_number( $args );
319
+ }
320
  // End of file.
inc/api-utilities.php CHANGED
@@ -7,13 +7,13 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
- * Copyright (c) 2006-2018 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP-Members Utility Functions
15
  * @author Chad Butler
16
- * @copyright 2006-2018
17
  */
18
 
19
  if ( ! function_exists( 'wpmem_securify' ) ):
@@ -146,14 +146,13 @@ if ( ! function_exists( 'wpmem_do_excerpt' ) ):
146
  * @since 2.6
147
  * @since 3.2.3 Now a wrapper for WP_Members::do_excerpt().
148
  *
149
- * @global object $post The post object.
150
  * @global object $wpmem The WP_Members object.
151
  *
152
  * @param string $content
153
  * @return string $content
154
  */
155
  function wpmem_do_excerpt( $content ) {
156
- global $post, $more, $wpmem;
157
  $content = $wpmem->do_excerpt( $content );
158
  return $content;
159
  }
@@ -221,15 +220,17 @@ function wpmem_load_dropins() {
221
  *
222
  * @since 3.2.4
223
  *
224
- * @param mixed $date
225
  * @return date $date
226
  */
227
- function wpmem_format_date( $date ) {
228
- $args = array(
229
- 'date_format' => get_option( 'date_format' ),
230
- 'localize' => true,
231
- 'date' => $date,
232
- );
 
 
233
  /**
234
  * Filter the date display and format settings.
235
  *
@@ -241,3 +242,35 @@ function wpmem_format_date( $date ) {
241
  $date = ( true === $args['localize'] ) ? date_i18n( $args['date_format'], strtotime( $args['date'] ) ) : date( $args['date_format'], strtotime( $args['date'] ) );
242
  return $date;
243
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
+ * Copyright (c) 2006-2019 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP-Members Utility Functions
15
  * @author Chad Butler
16
+ * @copyright 2006-2019
17
  */
18
 
19
  if ( ! function_exists( 'wpmem_securify' ) ):
146
  * @since 2.6
147
  * @since 3.2.3 Now a wrapper for WP_Members::do_excerpt().
148
  *
 
149
  * @global object $wpmem The WP_Members object.
150
  *
151
  * @param string $content
152
  * @return string $content
153
  */
154
  function wpmem_do_excerpt( $content ) {
155
+ global $wpmem;
156
  $content = $wpmem->do_excerpt( $content );
157
  return $content;
158
  }
220
  *
221
  * @since 3.2.4
222
  *
223
+ * @param mixed $args
224
  * @return date $date
225
  */
226
+ function wpmem_format_date( $args ) {
227
+ if ( ! is_array( $args ) ) {
228
+ $args = array(
229
+ 'date_format' => get_option( 'date_format' ),
230
+ 'localize' => true,
231
+ 'date' => $args,
232
+ );
233
+ }
234
  /**
235
  * Filter the date display and format settings.
236
  *
242
  $date = ( true === $args['localize'] ) ? date_i18n( $args['date_format'], strtotime( $args['date'] ) ) : date( $args['date_format'], strtotime( $args['date'] ) );
243
  return $date;
244
  }
245
+
246
+ /**
247
+ * Call a shortcode function by tag name.
248
+ *
249
+ * Use this function for directly calling a shortcode without using do_shortcode.
250
+ * do_shortcode() runs an extensive regex that goes through every shortcode in
251
+ * the WP global $shortcode_tags. That's a lot of processing wasted if all you
252
+ * want to do is run a specific shortcode/function. Yes, you could run the callback
253
+ * directly, but what if that callback is in a class instance method? This utlitiy
254
+ * allows you to run a shortcode function directly, regardless of whether it is
255
+ * a direct function or in a class. It comes from an article by J.D. Grimes on this
256
+ * subject and I've provided a link to that article.
257
+ *
258
+ * @author J.D. Grimes
259
+ * @link https://codesymphony.co/dont-do_shortcode/
260
+ *
261
+ * @param string $tag The shortcode whose function to call.
262
+ * @param array $atts The attributes to pass to the shortcode function. Optional.
263
+ * @param array $content The shortcode's content. Default is null (none).
264
+ *
265
+ * @return string|bool False on failure, the result of the shortcode on success.
266
+ */
267
+ function wpmem_do_shortcode( $tag, array $atts = array(), $content = null ) {
268
+
269
+ global $shortcode_tags;
270
+
271
+ if ( ! isset( $shortcode_tags[ $tag ] ) ) {
272
+ return false;
273
+ }
274
+
275
+ return call_user_func( $shortcode_tags[ $tag ], $atts, $content, $tag );
276
+ }
inc/api.php CHANGED
@@ -4,13 +4,13 @@
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
- * Copyright (c) 2006-2018 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
- * @copyright 2006-2018
14
  *
15
  * Functions included:
16
  * - wpmem_redirect_to_login
@@ -208,27 +208,6 @@ function wpmem_use_custom_dialog( $defaults, $tag, $dialogs ) {
208
  return $defaults;
209
  }
210
 
211
- /**
212
- * Creates a membership number.
213
- *
214
- * @since 3.1.1
215
- * @since 3.2.0 Changed "lead" to "pad".
216
- *
217
- * @param array $args {
218
- * @type string $option The wp_options name for the counter setting (required).
219
- * @type string $meta_key The field's meta key (required).
220
- * @type int $start Number to start with (optional, default 0).
221
- * @type int $increment Number to increment by (optional, default 1).
222
- * @type int $digits Number of digits for the number (optional).
223
- * @type boolen $pad Pad leading zeros (optional, default true).
224
- * }
225
- * @return string $membersip_number
226
- */
227
- function wpmem_create_membership_number( $args ) {
228
- global $wpmem;
229
- return $wpmem->api->generate_membership_number( $args );
230
- }
231
-
232
  /**
233
  * Returns or displays the user's login status.
234
  *
4
  *
5
  * This file is part of the WP-Members plugin by Chad Butler
6
  * You can find out more about this plugin at https://rocketgeek.com
7
+ * Copyright (c) 2006-2019 Chad Butler
8
  * WP-Members(tm) is a trademark of butlerblog.com
9
  *
10
  * @package WP-Members
11
  * @subpackage WP-Members API Functions
12
  * @author Chad Butler
13
+ * @copyright 2006-2019
14
  *
15
  * Functions included:
16
  * - wpmem_redirect_to_login
208
  return $defaults;
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  /**
212
  * Returns or displays the user's login status.
213
  *
inc/class-wp-members-email.php CHANGED
@@ -7,13 +7,13 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
- * Copyright (c) 2006-2018 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP_Members_Shortcodes
15
  * @author Chad Butler
16
- * @copyright 2006-2018
17
  */
18
 
19
  // Exit if accessed directly.
@@ -365,19 +365,24 @@ class WP_Members_Email {
365
  * @param array $this->settings P
366
  * An array containing email body, subject, user id, and additional settings.
367
  *
368
- * @type integer user_id
369
- * @type string user_login
370
- * @type string user_email
371
- * @type string blogname
372
- * @type string user_ip
373
- * @type string reg_link
374
- * @type string act_link
375
- * @type string exp_type
376
- * @type string exp_date
377
- * @type boolean do_shortcodes
378
- * @type boolean add_footer
379
- * @type boolean footer
380
- * @type boolean disable
 
 
 
 
 
381
  * }
382
  * @param array $wpmem_fields An array of the WP-Members fields.
383
  * @param array $field_data An array of the posted registration data.
@@ -512,11 +517,24 @@ class WP_Members_Email {
512
  * @since 3.2.0
513
  */
514
  function send( $to ) {
515
- $send_to = ( 'user' == $to ) ? $this->settings['user_email'] : $this->settings['admin_email'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  // Apply WP's "from" and "from name" email filters.
517
  add_filter( 'wp_mail_from', array( $this, 'from' ) );
518
  add_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
519
- // Send the message.
520
- wp_mail( $send_to, stripslashes( $this->settings['subj'] ), stripslashes( $this->settings['body'] ), $this->settings['headers'] );
521
  }
522
  }
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
+ * Copyright (c) 2006-2019 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP_Members_Shortcodes
15
  * @author Chad Butler
16
+ * @copyright 2006-2019
17
  */
18
 
19
  // Exit if accessed directly.
365
  * @param array $this->settings P
366
  * An array containing email body, subject, user id, and additional settings.
367
  *
368
+ * @type string $subj
369
+ * @type string $body
370
+ * @type integer $user_id
371
+ * @type string $user_login
372
+ * @type string $user_email
373
+ * @type string $blogname
374
+ * @type string $user_ip
375
+ * @type string $reg_link
376
+ * @type string $act_link
377
+ * @type string $exp_type
378
+ * @type string $exp_date
379
+ * @type boolean $do_shortcodes
380
+ * @type boolean $add_footer
381
+ * @type boolean $footer
382
+ * @type boolean $disable
383
+ * @type array $field_arr
384
+ * @type string $headers
385
+ * @type string $admin_email
386
  * }
387
  * @param array $wpmem_fields An array of the WP-Members fields.
388
  * @param array $field_data An array of the posted registration data.
517
  * @since 3.2.0
518
  */
519
  function send( $to ) {
520
+ $args['to'] = ( 'user' == $to ) ? $this->settings['user_email'] : $this->settings['admin_email'];
521
+ $args['subject'] = $this->settings['subj'];
522
+ $args['message'] = $this->settings['body'];
523
+ $args['headers'] = $this->settings['headers'];
524
+ // @todo Add attachments to arguments and email send (and probably in the original function).
525
+ /**
526
+ * Filter email send arguments.
527
+ *
528
+ * @since 3.2.5
529
+ *
530
+ * @param array $send_args
531
+ * @param string $to
532
+ * @param array $this->settings
533
+ */
534
+ $args = apply_filters( 'wpmem_email_send_args', $args, $to, $this->settings );
535
  // Apply WP's "from" and "from name" email filters.
536
  add_filter( 'wp_mail_from', array( $this, 'from' ) );
537
  add_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
538
+ wp_mail( $args['to'], stripslashes( $args['subject'] ), stripslashes( $args['message'] ), $args['headers'] );
 
539
  }
540
  }
inc/class-wp-members-forms.php CHANGED
@@ -60,7 +60,7 @@ class WP_Members_Forms {
60
  $id = ( isset( $args['id'] ) ) ? esc_attr( $args['id'] ) : esc_attr( $args['name'] );
61
  $name = esc_attr( $args['name'] );
62
  $type = esc_attr( $args['type'] );
63
- $value = maybe_unserialize( $args['value'] );
64
  $compare = ( isset( $args['compare'] ) ) ? $args['compare'] : '';
65
  $class = ( isset( $args['class'] ) ) ? $args['class'] : 'textbox';
66
  $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
@@ -594,10 +594,12 @@ class WP_Members_Forms {
594
  *
595
  * @since 2.8.0
596
  * @since 3.1.7 Combined all to a single process.
 
597
  *
598
  * @param string The raw link.
 
599
  */
600
- $link = apply_filters( "wpmem_{$tag}_link", $value['link'] );
601
  $str = $wpmem->get_text( "{$key}_link_before" ) . '<a href="' . esc_url( $link ) . '">' . $wpmem->get_text( "{$key}_link" ) . '</a>';
602
  $link_str = $args['link_before'];
603
  $link_str.= ( '' != $args['link_span_before'] ) ? sprintf( $args['link_span_before'], $key ) : '';
@@ -607,11 +609,13 @@ class WP_Members_Forms {
607
  * @since 2.9.0
608
  * @since 3.0.9 Added $link parameter.
609
  * @since 3.1.7 Combined all to a single process.
 
610
  *
611
  * @param string $str The link HTML.
612
  * @param string $link The link.
 
613
  */
614
- $link_str.= apply_filters( "wpmem_{$tag}_link_str", $str, $link );
615
  $link_str.= ( '' != $args['link_span_after'] ) ? $args['link_span_after'] : '';
616
  $link_str.= $args['link_after'] . $args['n'];
617
  /*
@@ -620,14 +624,18 @@ class WP_Members_Forms {
620
  * page, then do not add the register link, otherwise add the link.
621
  */
622
  if ( 'register' == $key ) {
623
- if ( isset( $wpmem->user_pages['login'] ) && $wpmem->user_pages['login'] != '' ) {
624
- $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && wpmem_current_url( true, false ) != wpmem_login_url() ) ? $form : $form . $link_str;
625
  } else {
626
- global $post;
627
- if ( has_shortcode( $post->post_content, 'wpmem_profile' ) ) {
628
- $form = $form;
629
  } else {
630
- $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && ! has_shortcode( $post->post_content, 'wpmem_form' ) ) ? $form : $form . $link_str;
 
 
 
 
 
631
  }
632
  }
633
  } else {
@@ -690,6 +698,7 @@ class WP_Members_Forms {
690
  *
691
  * @since 2.5.1
692
  * @since 3.1.7 Moved to forms object class as register_form().
 
693
  *
694
  * @global object $wpmem The WP_Members object.
695
  * @global string $wpmem_regchk Used to determine if the form is in an error state.
@@ -702,9 +711,10 @@ class WP_Members_Forms {
702
 
703
  // Handle legacy use.
704
  if ( is_array( $mixed ) ) {
705
- $tag = $mixed['tag'];
706
- $heading = $mixed['heading'];
707
- $redirect_to = $mixed['redirect_to'];
 
708
  } else {
709
  $tag = $mixed;
710
  }
@@ -749,7 +759,6 @@ class WP_Members_Forms {
749
  // Other.
750
  'post_to' => get_permalink(),
751
  'strip_breaks' => true,
752
- 'use_nonce' => false,
753
  'wrap_inputs' => true,
754
  'n' => "\n",
755
  't' => "\t",
@@ -763,11 +772,13 @@ class WP_Members_Forms {
763
  * includes default tags, labels, text, and small items including various booleans.
764
  *
765
  * @since 2.9.0
 
766
  *
767
  * @param array An array of arguments to merge with defaults. Default null.
768
  * @param string $tag Toggle new registration or profile update. new|edit.
 
769
  */
770
- $args = apply_filters( 'wpmem_register_form_args', '', $tag );
771
 
772
  // Merge $args with defaults.
773
  $args = wp_parse_args( $args, $defaults );
@@ -888,7 +899,8 @@ class WP_Members_Forms {
888
  'name' => $meta_key,
889
  'type' => $field['type'],
890
  'value' => $field['checked_value'],
891
- 'compare' => $val
 
892
  ) );
893
  $input = ( $field['required'] ) ? $input . $args['req_mark'] : $input;
894
 
@@ -1196,7 +1208,7 @@ class WP_Members_Forms {
1196
  $form = $form . wpmem_inc_attribution();
1197
 
1198
  // Apply nonce.
1199
- $form = ( defined( 'WPMEM_USE_NONCE' ) || $args['use_nonce'] ) ? wp_nonce_field( 'wpmem-validate-submit', 'wpmem-form-submit' ) . $args['n'] . $form : $form;
1200
 
1201
  // Apply form wrapper.
1202
  $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
60
  $id = ( isset( $args['id'] ) ) ? esc_attr( $args['id'] ) : esc_attr( $args['name'] );
61
  $name = esc_attr( $args['name'] );
62
  $type = esc_attr( $args['type'] );
63
+ $value = ( isset( $args['value'] ) ) ? maybe_unserialize( $args['value'] ) : '';
64
  $compare = ( isset( $args['compare'] ) ) ? $args['compare'] : '';
65
  $class = ( isset( $args['class'] ) ) ? $args['class'] : 'textbox';
66
  $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
594
  *
595
  * @since 2.8.0
596
  * @since 3.1.7 Combined all to a single process.
597
+ * @since 3.2.5 Added $tag parameter.
598
  *
599
  * @param string The raw link.
600
+ * @param string $tag forgot|reg|pwdreset.
601
  */
602
+ $link = apply_filters( "wpmem_{$tag}_link", $value['link'], $tag );
603
  $str = $wpmem->get_text( "{$key}_link_before" ) . '<a href="' . esc_url( $link ) . '">' . $wpmem->get_text( "{$key}_link" ) . '</a>';
604
  $link_str = $args['link_before'];
605
  $link_str.= ( '' != $args['link_span_before'] ) ? sprintf( $args['link_span_before'], $key ) : '';
609
  * @since 2.9.0
610
  * @since 3.0.9 Added $link parameter.
611
  * @since 3.1.7 Combined all to a single process.
612
+ * @since 3.2.5 Added $tag parameter.
613
  *
614
  * @param string $str The link HTML.
615
  * @param string $link The link.
616
+ * @param string $tag forgot|reg|pwdreset.
617
  */
618
+ $link_str.= apply_filters( "wpmem_{$tag}_link_str", $str, $link, $tag );
619
  $link_str.= ( '' != $args['link_span_after'] ) ? $args['link_span_after'] : '';
620
  $link_str.= $args['link_after'] . $args['n'];
621
  /*
624
  * page, then do not add the register link, otherwise add the link.
625
  */
626
  if ( 'register' == $key ) {
627
+ if ( ! isset( $wpmem->user_pages['register'] ) || '' == $wpmem->user_pages['register'] ) {
628
+ $form = $form;
629
  } else {
630
+ if ( isset( $wpmem->user_pages['login'] ) && '' != $wpmem->user_pages['login'] ) {
631
+ $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && wpmem_current_url( true, false ) != wpmem_login_url() ) ? $form : $form . $link_str;
 
632
  } else {
633
+ global $post;
634
+ if ( has_shortcode( $post->post_content, 'wpmem_profile' ) ) {
635
+ $form = $form;
636
+ } else {
637
+ $form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && ! has_shortcode( $post->post_content, 'wpmem_form' ) ) ? $form : $form . $link_str;
638
+ }
639
  }
640
  }
641
  } else {
698
  *
699
  * @since 2.5.1
700
  * @since 3.1.7 Moved to forms object class as register_form().
701
+ * @since 3.2.5 use_nonce now obsolete (nonce is added automatically).
702
  *
703
  * @global object $wpmem The WP_Members object.
704
  * @global string $wpmem_regchk Used to determine if the form is in an error state.
711
 
712
  // Handle legacy use.
713
  if ( is_array( $mixed ) ) {
714
+ $id = ( isset( $mixed['id'] ) ) ? $mixed['id'] : '';
715
+ $tag = ( isset( $mixed['tag'] ) ) ? $mixed['tag'] : 'new';
716
+ $heading = ( isset( $mixed['heading'] ) ) ? $mixed['heading'] : '';
717
+ $redirect_to = ( isset( $mixed['redirect_to'] ) ) ? $mixed['redirect_to'] : '';
718
  } else {
719
  $tag = $mixed;
720
  }
759
  // Other.
760
  'post_to' => get_permalink(),
761
  'strip_breaks' => true,
 
762
  'wrap_inputs' => true,
763
  'n' => "\n",
764
  't' => "\t",
772
  * includes default tags, labels, text, and small items including various booleans.
773
  *
774
  * @since 2.9.0
775
+ * @since 3.2.5 Added $id
776
  *
777
  * @param array An array of arguments to merge with defaults. Default null.
778
  * @param string $tag Toggle new registration or profile update. new|edit.
779
+ * @param string $id An id for the form (optional).
780
  */
781
+ $args = apply_filters( 'wpmem_register_form_args', '', $tag, $id );
782
 
783
  // Merge $args with defaults.
784
  $args = wp_parse_args( $args, $defaults );
899
  'name' => $meta_key,
900
  'type' => $field['type'],
901
  'value' => $field['checked_value'],
902
+ 'compare' => $val,
903
+ 'required' => $field['required'],
904
  ) );
905
  $input = ( $field['required'] ) ? $input . $args['req_mark'] : $input;
906
 
1208
  $form = $form . wpmem_inc_attribution();
1209
 
1210
  // Apply nonce.
1211
+ $form = wp_nonce_field( 'wpmem_reg_nonce' ) . $args['n'] . $form;
1212
 
1213
  // Apply form wrapper.
1214
  $enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
inc/class-wp-members-shortcodes.php CHANGED
@@ -7,13 +7,13 @@
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
- * Copyright (c) 2006-2018 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP_Members_Shortcodes
15
  * @author Chad Butler
16
- * @copyright 2006-2018
17
  */
18
 
19
  // Exit if accessed directly.
@@ -32,7 +32,7 @@ class WP_Members_Shortcodes {
32
  */
33
  do_action( 'wpmem_load_shortcodes' );
34
 
35
- add_shortcode( 'wp-members', 'wpmem_shortcode' );
36
  add_shortcode( 'wpmem_field', array( $this, 'fields' ) );
37
  add_shortcode( 'wpmem_logged_in', array( $this, 'logged_in' ) );
38
  add_shortcode( 'wpmem_logged_out', array( $this, 'logged_out' ) );
@@ -120,7 +120,7 @@ class WP_Members_Shortcodes {
120
  * If the user is not logged in, return an error message if a login
121
  * error state exists, or return the login form.
122
  */
123
- $content = ( $wpmem->regchk == 'loginfailed' ) ? wpmem_inc_loginfailed() : wpmem_inc_login( 'login', $redirect_to );
124
  }
125
  break;
126
 
@@ -131,7 +131,11 @@ class WP_Members_Shortcodes {
131
  * or the default bullet links if no nested content.
132
  */
133
  $content = ( $content ) ? $content : wpmem_inc_memberlinks( 'register' );
134
- } else {
 
 
 
 
135
  if ( $wpmem->regchk == 'loginfailed' ) {
136
  $content = wpmem_inc_loginfailed() . wpmem_inc_login( 'login', $redirect_to );
137
  break;
@@ -279,7 +283,8 @@ class WP_Members_Shortcodes {
279
 
280
  // If there is a product attribute.
281
  if ( isset( $atts['product'] ) ) {
282
- if ( wpmem_user_has_access( 'product' ) ) {
 
283
  $do_return = true;
284
  }
285
  }
@@ -515,6 +520,7 @@ class WP_Members_Shortcodes {
515
  * @since 3.1.5 Added display attribute, meta key as a direct attribute, and image/file display.
516
  * @since 3.2.0 Moved to WP_Members_Shortcodes::fields().
517
  * @since 3.2.0 Added clickable attribute.
 
518
  *
519
  * @global object $wpmem The WP_Members object.
520
  * @param array $atts {
@@ -526,7 +532,8 @@ class WP_Members_Shortcodes {
526
  * @type string $underscores
527
  * @type string $display
528
  * @type string $size
529
- * @type string $clickable default:false
 
530
  * }
531
  * @param string $content Any content passed with the shortcode (default:null).
532
  * @param string $tag The shortcode tag (wpmem_form).
@@ -546,25 +553,26 @@ class WP_Members_Shortcodes {
546
  $user_info = get_userdata( $the_ID );
547
 
548
  // If there is userdata.
549
- if ( $user_info ) {
550
 
551
  global $wpmem;
552
  $fields = wpmem_fields();
553
  $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native'; // @todo Is this needed? It seems to set the type to "native" if not set.
554
 
555
- $result = $user_info->{$field};
 
556
 
557
  // Handle select and radio groups (have single selections).
558
  if ( 'select' == $field_type || 'radio' == $field_type ) {
559
- $result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info->{$field} : $fields[ $field ]['options'][ $user_info->{$field} ];
560
  }
561
 
562
  // Handle multiple select and multiple checkbox (have multiple selections).
563
  if ( 'multiselect' == $field_type || 'multicheckbox' == $field_type ) {
564
  if ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) {
565
- $result = $user_info->{$field};
566
  } else {
567
- $saved_vals = explode( $fields[ $field ]['delimiter'], $user_info->{$field} );
568
  $result = ''; $x = 1;
569
  foreach ( $saved_vals as $value ) {
570
  $result.= ( $x > 1 ) ? ', ' : ''; $x++;
@@ -576,18 +584,18 @@ class WP_Members_Shortcodes {
576
  // Handle file/image fields.
577
  if ( isset( $field_type ) && ( 'file' == $field_type || 'image' == $field_type ) ) {
578
  if ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) {
579
- $result = $user_info->{$field};
580
  } else {
581
  if ( 'file' == $field_type ) {
582
- $attachment_url = wp_get_attachment_url( $user_info->{$field} );
583
- $result = ( $attachment_url ) ? '<a href="' . esc_url( $attachment_url ) . '">' . get_the_title( $user_info->{$field} ) . '</a>' : '';
584
  } else {
585
  $size = 'thumbnail';
586
  if ( isset( $atts['size'] ) ) {
587
  $sizes = array( 'thumbnail', 'medium', 'large', 'full' );
588
  $size = ( ! in_array( $atts['size'], $sizes ) ) ? explode( ",", $atts['size'] ) : $atts['size'];
589
  }
590
- $image = wp_get_attachment_image_src( $user_info->{$field}, $size );
591
  $result = ( $image ) ? '<img src="' . esc_url( $image[0] ) . '" width="' . esc_attr( $image[1] ) . '" height="' . esc_attr( $image[2] ) . '" />' : '';
592
  }
593
  }
@@ -596,19 +604,22 @@ class WP_Members_Shortcodes {
596
 
597
  // Handle line breaks for textarea fields
598
  if ( isset( $field_type ) && 'textarea' == $field_type ) {
599
- $result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info->{$field} : nl2br( $user_info->{$field} );
600
  }
601
 
602
  // Handle date fields.
603
  if ( isset( $field_type ) && 'date' == $field_type ) {
604
  if ( isset( $atts['format'] ) ) {
605
  // Formats date: https://secure.php.net/manual/en/function.date.php
606
- $result = ( '' != $user_info->{$field} ) ? date( $atts['format'], strtotime( $user_info->{$field} ) ) : '';
607
  } else {
608
  // Formats date to whatever the WP setting is.
609
- $result = ( '' != $user_info->{$field} ) ? date_i18n( get_option( 'date_format' ), strtotime( $user_info->{$field} ) ) : '';
610
  }
611
  }
 
 
 
612
 
613
  // Remove underscores from value if requested (default: on).
614
  if ( isset( $atts['underscores'] ) && 'off' == $atts['underscores'] && $user_info ) {
@@ -618,11 +629,22 @@ class WP_Members_Shortcodes {
618
  $content = ( $content ) ? $result . $content : $result;
619
 
620
  // Make it clickable?
621
- $content = ( isset( $atts['clickable'] ) && ( true === $atts['clickable'] || 'true' == $atts['clickable'] ) ) ? make_clickable( $content ) : $content;
622
-
623
- return do_shortcode( $content );
 
624
  }
625
- return;
 
 
 
 
 
 
 
 
 
 
626
  }
627
 
628
  /**
@@ -643,7 +665,7 @@ class WP_Members_Shortcodes {
643
  function logout( $atts, $content, $tag ) {
644
  // Logout link shortcode.
645
  if ( is_user_logged_in() && $tag == 'wpmem_logout' ) {
646
- $link = ( isset( $atts['url'] ) ) ? add_query_arg( 'a', 'logout', $atts['url'] ) : add_query_arg( 'a', 'logout' );
647
  $text = ( $content ) ? $content : __( 'Click here to log out.', 'wp-members' );
648
  return do_shortcode( '<a href="' . esc_url( $link ) . '">' . $text . '</a>' );
649
  }
7
  *
8
  * This file is part of the WP-Members plugin by Chad Butler
9
  * You can find out more about this plugin at https://rocketgeek.com
10
+ * Copyright (c) 2006-2019 Chad Butler
11
  * WP-Members(tm) is a trademark of butlerblog.com
12
  *
13
  * @package WP-Members
14
  * @subpackage WP_Members_Shortcodes
15
  * @author Chad Butler
16
+ * @copyright 2006-2019
17
  */
18
 
19
  // Exit if accessed directly.
32
  */
33
  do_action( 'wpmem_load_shortcodes' );
34
 
35
+ add_shortcode( 'wp-members', 'wpmem_shortcode' ); // This shortcode is obsolete, and the associated function is deprecated.
36
  add_shortcode( 'wpmem_field', array( $this, 'fields' ) );
37
  add_shortcode( 'wpmem_logged_in', array( $this, 'logged_in' ) );
38
  add_shortcode( 'wpmem_logged_out', array( $this, 'logged_out' ) );
120
  * If the user is not logged in, return an error message if a login
121
  * error state exists, or return the login form.
122
  */
123
+ $content = ( $wpmem->regchk == 'loginfailed' || ( is_customize_preview() && get_theme_mod( 'show_form_message_dialog', false ) ) ) ? wpmem_inc_loginfailed() : wpmem_inc_login( 'login', $redirect_to );
124
  }
125
  break;
126
 
131
  * or the default bullet links if no nested content.
132
  */
133
  $content = ( $content ) ? $content : wpmem_inc_memberlinks( 'register' );
134
+ } elseif ( is_customize_preview() && get_theme_mod( 'show_form_message_dialog', false ) ) {
135
+ $wpmem_themsg = __( "This is a generic message to display the form message dialog in the Customizer.", 'wp-members' );
136
+ $content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
137
+ $content .= wpmem_inc_registration( 'new', '', $redirect_to );
138
+ }else {
139
  if ( $wpmem->regchk == 'loginfailed' ) {
140
  $content = wpmem_inc_loginfailed() . wpmem_inc_login( 'login', $redirect_to );
141
  break;
283
 
284
  // If there is a product attribute.
285
  if ( isset( $atts['product'] ) ) {
286
+ // @todo What if attribute is comma separated/multiple?
287
+ if ( wpmem_user_has_access( $atts['product'] ) ) {
288
  $do_return = true;
289
  }
290
  }
520
  * @since 3.1.5 Added display attribute, meta key as a direct attribute, and image/file display.
521
  * @since 3.2.0 Moved to WP_Members_Shortcodes::fields().
522
  * @since 3.2.0 Added clickable attribute.
523
+ * @since 3.2.5 Added label attribute.
524
  *
525
  * @global object $wpmem The WP_Members object.
526
  * @param array $atts {
532
  * @type string $underscores
533
  * @type string $display
534
  * @type string $size
535
+ * @type string $clickable default:false
536
+ * @type string $label default:false
537
  * }
538
  * @param string $content Any content passed with the shortcode (default:null).
539
  * @param string $tag The shortcode tag (wpmem_form).
553
  $user_info = get_userdata( $the_ID );
554
 
555
  // If there is userdata.
556
+ if ( $user_info && isset( $user_info->{$field} ) ) {
557
 
558
  global $wpmem;
559
  $fields = wpmem_fields();
560
  $field_type = ( isset( $fields[ $field ]['type'] ) ) ? $fields[ $field ]['type'] : 'native'; // @todo Is this needed? It seems to set the type to "native" if not set.
561
 
562
+ $user_info_field = ( isset( $field ) && is_object( $user_info ) ) ? $user_info->{$field} : '';
563
+ $result = false;
564
 
565
  // Handle select and radio groups (have single selections).
566
  if ( 'select' == $field_type || 'radio' == $field_type ) {
567
+ $result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info_field : $fields[ $field ]['options'][ $user_info_field ];
568
  }
569
 
570
  // Handle multiple select and multiple checkbox (have multiple selections).
571
  if ( 'multiselect' == $field_type || 'multicheckbox' == $field_type ) {
572
  if ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) {
573
+ $result = $user_info_field;
574
  } else {
575
+ $saved_vals = explode( $fields[ $field ]['delimiter'], $user_info_field );
576
  $result = ''; $x = 1;
577
  foreach ( $saved_vals as $value ) {
578
  $result.= ( $x > 1 ) ? ', ' : ''; $x++;
584
  // Handle file/image fields.
585
  if ( isset( $field_type ) && ( 'file' == $field_type || 'image' == $field_type ) ) {
586
  if ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) {
587
+ $result = $user_info_field;
588
  } else {
589
  if ( 'file' == $field_type ) {
590
+ $attachment_url = wp_get_attachment_url( $user_info_field );
591
+ $result = ( $attachment_url ) ? '<a href="' . esc_url( $attachment_url ) . '">' . get_the_title( $user_info_field ) . '</a>' : '';
592
  } else {
593
  $size = 'thumbnail';
594
  if ( isset( $atts['size'] ) ) {
595
  $sizes = array( 'thumbnail', 'medium', 'large', 'full' );
596
  $size = ( ! in_array( $atts['size'], $sizes ) ) ? explode( ",", $atts['size'] ) : $atts['size'];
597
  }
598
+ $image = wp_get_attachment_image_src( $user_info_field, $size );
599
  $result = ( $image ) ? '<img src="' . esc_url( $image[0] ) . '" width="' . esc_attr( $image[1] ) . '" height="' . esc_attr( $image[2] ) . '" />' : '';
600
  }
601
  }
604
 
605
  // Handle line breaks for textarea fields
606
  if ( isset( $field_type ) && 'textarea' == $field_type ) {
607
+ $result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info_field : nl2br( $user_info_field );
608
  }
609
 
610
  // Handle date fields.
611
  if ( isset( $field_type ) && 'date' == $field_type ) {
612
  if ( isset( $atts['format'] ) ) {
613
  // Formats date: https://secure.php.net/manual/en/function.date.php
614
+ $result = ( '' != $user_info_field ) ? date( $atts['format'], strtotime( $user_info_field ) ) : '';
615
  } else {
616
  // Formats date to whatever the WP setting is.
617
+ $result = ( '' != $user_info_field ) ? date_i18n( get_option( 'date_format' ), strtotime( $user_info_field ) ) : '';
618
  }
619
  }
620
+
621
+ // Handle all other fields.
622
+ $result = ( ! $result ) ? $user_info_field : $result;
623
 
624
  // Remove underscores from value if requested (default: on).
625
  if ( isset( $atts['underscores'] ) && 'off' == $atts['underscores'] && $user_info ) {
629
  $content = ( $content ) ? $result . $content : $result;
630
 
631
  // Make it clickable?
632
+ $content = ( isset( $atts['clickable'] ) && ( true == $atts['clickable'] || 'true' == $atts['clickable'] ) ) ? make_clickable( $content ) : $content;
633
+
634
+ // Display field label?
635
+ $content = ( isset( $atts['label'] ) && ( true == $atts['label'] ) ) ? $fields[ $field ]['label'] . ": " . $content : $content;
636
  }
637
+ /**
638
+ * Filters the field shortcode before returning value.
639
+ *
640
+ * @since 3.2.5
641
+ *
642
+ * @param string $content
643
+ * @param array $atts
644
+ */
645
+ $content = apply_filters( 'wpmem_field_shortcode', $content, $atts );
646
+
647
+ return do_shortcode( $content );
648
  }
649
 
650
  /**
665
  function logout( $atts, $content, $tag ) {
666
  // Logout link shortcode.
667
  if ( is_user_logged_in() && $tag == 'wpmem_logout' ) {
668
+ $link = ( isset( $atts['url'] ) ) ? add_query_arg( array( 'a'=>'logout', 'redirect_to'=>$atts['url'] ) ) : add_query_arg( 'a', 'logout' );
669
  $text = ( $content ) ? $content : __( 'Click here to log out.', 'wp-members' );
670
  return do_shortcode( '<a href="' . esc_url( $link ) . '">' . $text . '</a>' );
671
  }
inc/class-wp-members-user-profile.php CHANGED
@@ -39,6 +39,9 @@ class WP_Members_User_Profile {
39
  /**
40
  * Filter the heading for additional profile fields.
41
  *
 
 
 
42
  * @since 2.8.2 Admin Profile
43
  * @since 2.9.1 Dashboard Profile
44
  * @since 3.1.9 Merged admin/dashboard profile
@@ -54,13 +57,18 @@ class WP_Members_User_Profile {
54
  $exclude = wpmem_get_excluded_meta( $display . '-profile' );
55
 
56
  // If tos is an active field, this is the dashboard profile, and user has current field value.
57
- if ( isset( $wpmem_fields['tos'] ) && get_user_meta( $user_ID, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) {
 
 
58
  unset( $wpmem_fields['tos'] );
59
  }
60
 
61
  /**
62
  * Fires at the beginning of generating the WP-Members fields in the user profile.
63
  *
 
 
 
64
  * @since 2.9.3 Created for admin profile.
65
  * @since 3.1.9 Added to dashboard profile.
66
  *
@@ -77,7 +85,7 @@ class WP_Members_User_Profile {
77
 
78
  // Determine which fields to show in the additional fields area.
79
  $show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false;
80
- $show = ( 'tos' == $meta && $field['register'] ) ? null : $show;
81
 
82
  if ( $show ) {
83
 
@@ -148,7 +156,10 @@ class WP_Members_User_Profile {
148
  }
149
 
150
  /**
151
- * Filter for rows
 
 
 
152
  *
153
  * @since 3.1.0
154
  * @since 3.1.6 Deprecated $order.
@@ -182,6 +193,9 @@ class WP_Members_User_Profile {
182
 
183
  /**
184
  * Filter the profile field.
 
 
 
185
  *
186
  * @since 2.8.2
187
  * @since 3.1.1 Added $user_id and $row
@@ -196,6 +210,9 @@ class WP_Members_User_Profile {
196
  /**
197
  * Fires after generating the WP-Members fields in the user profile.
198
  *
 
 
 
199
  * @since 2.9.3
200
  *
201
  * @param int $user_id The user's ID.
@@ -246,13 +263,18 @@ class WP_Members_User_Profile {
246
  }
247
 
248
  // If tos is an active field, this is the dashboard profile, and user has current field value.
249
- if ( isset( $wpmem_fields['tos'] ) && get_user_meta( $user_id, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) {
 
 
250
  unset( $wpmem_fields['tos'] );
251
  }
252
 
253
  /**
254
  * Fires before the user profile is updated.
255
  *
 
 
 
256
  * @since 2.9.2 Added for admin profile update.
257
  * @since 3.1.9 Added for user profile update.
258
  *
@@ -296,6 +318,9 @@ class WP_Members_User_Profile {
296
  /**
297
  * Filter the submitted field values for backend profile update.
298
  *
 
 
 
299
  * @since 2.8.2 Added for Admin profile update.
300
  * @since 3.1.9 Added for User profile update.
301
  *
@@ -358,6 +383,9 @@ class WP_Members_User_Profile {
358
  /**
359
  * Fires after the user profile is updated.
360
  *
 
 
 
361
  * @since 2.9.2
362
  *
363
  * @param int $user_id The user ID.
@@ -510,4 +538,48 @@ class WP_Members_User_Profile {
510
  </tr>
511
  <?php
512
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  }
39
  /**
40
  * Filter the heading for additional profile fields.
41
  *
42
+ * Filter is applied for the admin user edit ("wpmem_admin_profile_heading")
43
+ * and the user profile edit ("wpmem_user_profile_heading").
44
+ *
45
  * @since 2.8.2 Admin Profile
46
  * @since 2.9.1 Dashboard Profile
47
  * @since 3.1.9 Merged admin/dashboard profile
57
  $exclude = wpmem_get_excluded_meta( $display . '-profile' );
58
 
59
  // If tos is an active field, this is the dashboard profile, and user has current field value.
60
+ if ( isset( $wpmem_fields['tos'] )
61
+ && 'user' == $display
62
+ && ( get_user_meta( $user_ID, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) ) {
63
  unset( $wpmem_fields['tos'] );
64
  }
65
 
66
  /**
67
  * Fires at the beginning of generating the WP-Members fields in the user profile.
68
  *
69
+ * Action fires for the admin user edit ("wpmem_admin_before_profile")
70
+ * and the user profile edit ("wpmem_user_before_profile").
71
+ *
72
  * @since 2.9.3 Created for admin profile.
73
  * @since 3.1.9 Added to dashboard profile.
74
  *
85
 
86
  // Determine which fields to show in the additional fields area.
87
  $show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false;
88
+ //$show = ( 'tos' == $meta && $field['register'] ) ? null : $show;
89
 
90
  if ( $show ) {
91
 
156
  }
157
 
158
  /**
159
+ * Filter for rows.
160
+ *
161
+ * Filter is applied for the admin user edit ("wpmem_register_form_rows_admin")
162
+ * and the user profile edit ("wpmem_register_form_rows_user").
163
  *
164
  * @since 3.1.0
165
  * @since 3.1.6 Deprecated $order.
193
 
194
  /**
195
  * Filter the profile field.
196
+ *
197
+ * Filter is applied for the admin user edit ("wpmem_admin_profile_field")
198
+ * and the user profile edit ("wpmem_user_profile_field").
199
  *
200
  * @since 2.8.2
201
  * @since 3.1.1 Added $user_id and $row
210
  /**
211
  * Fires after generating the WP-Members fields in the user profile.
212
  *
213
+ * Action fires for the admin user edit ("wpmem_admin_after_profile")
214
+ * and the user profile edit ("wpmem_user_after_profile").
215
+ *
216
  * @since 2.9.3
217
  *
218
  * @param int $user_id The user's ID.
263
  }
264
 
265
  // If tos is an active field, this is the dashboard profile, and user has current field value.
266
+ if ( isset( $wpmem_fields['tos'] )
267
+ && 'user' == $display
268
+ && get_user_meta( $user_id, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) {
269
  unset( $wpmem_fields['tos'] );
270
  }
271
 
272
  /**
273
  * Fires before the user profile is updated.
274
  *
275
+ * Action fires for the admin user edit ("wpmem_admin_pre_user_update")
276
+ * and the user profile edit ("wpmem_user_pre_user_update").
277
+ *
278
  * @since 2.9.2 Added for admin profile update.
279
  * @since 3.1.9 Added for user profile update.
280
  *
318
  /**
319
  * Filter the submitted field values for backend profile update.
320
  *
321
+ * Filters is applied for the admin user edit ("wpmem_admin_profile_update")
322
+ * and the user profile edit ("wpmem_user_profile_update").
323
+ *
324
  * @since 2.8.2 Added for Admin profile update.
325
  * @since 3.1.9 Added for User profile update.
326
  *
383
  /**
384
  * Fires after the user profile is updated.
385
  *
386
+ * Action fires for the admin user edit ("wpmem_admin_after_user_update")
387
+ * and the user profile edit ("wpmem_user_after_user_update").
388
+ *
389
  * @since 2.9.2
390
  *
391
  * @param int $user_id The user ID.
538
  </tr>
539
  <?php
540
  }
541
+
542
+ /**
543
+ * Add jquery ui tabs to user profile.
544
+ *
545
+ * @since 3.2.5
546
+ *
547
+ * @param int $user_id
548
+ */
549
+ static function _profile_tabs( $user_id ) {
550
+
551
+ /**
552
+ * Add tabs to user profile tabs.
553
+ *
554
+ * @since 3.2.5
555
+ *
556
+ * @param array {
557
+ * @type string $tab (required)
558
+ * @type string $content (optional)
559
+ * }
560
+ */
561
+ $tabs = apply_filters( 'wpmem_user_profile_tabs', array() );
562
+
563
+ if ( ! empty( $tabs ) ) { ?>
564
+ <script>
565
+ jQuery(document).ready(function($){
566
+ $("#wpmem_user_profile_tabs").tabs();
567
+ });
568
+ </script>
569
+ <?php
570
+ echo '<div id="wpmem_user_profile_tabs">';
571
+ echo '<ul>';
572
+ foreach ( $tabs as $key => $value ) {
573
+ echo '<li><a href="#wpmem_user_profile_tabs-' . ( $key ) . '">' . $value['tab'] . '</a></li>';
574
+ }
575
+ echo '</ul>';
576
+ foreach ( $tabs as $key => $value ) {
577
+ echo '<div id="wpmem_user_profile_tabs-' . ( $key ) . '">';
578
+ echo ( isset( $value['content'] ) ) ? $value['content'] : '';
579
+ do_action( 'wpmem_user_profile_tabs_content', $key );
580
+ echo '</div>';
581
+ }
582
+ echo '</div>';
583
+ }
584
+ }
585
  }
inc/class-wp-members-user.php CHANGED
@@ -100,6 +100,7 @@ class WP_Members_User {
100
  * can be used to override a default in login_redirect.
101
  *
102
  * @since 2.7.7
 
103
  *
104
  * @param string $redirect_to The url to direct to.
105
  * @param int $user->ID The user's primary key ID.
@@ -411,7 +412,7 @@ class WP_Members_User {
411
  /**
412
  * Get user data for all fields in WP-Members.
413
  *
414
- * Retrieves user data for all WP-Members fields (and WP default fiels)
415
  * in an array keyed by WP-Members field meta keys.
416
  *
417
  * @since 3.2.0
@@ -490,6 +491,10 @@ class WP_Members_User {
490
  * Validates user access to content.
491
  *
492
  * @since 3.2.0
 
 
 
 
493
  *
494
  * @global object $wpmem
495
  * @param mixed $product
@@ -501,26 +506,38 @@ class WP_Members_User {
501
  if ( ! is_user_logged_in() ) {
502
  return false;
503
  }
504
- $user_id = ( ! $user_id ) ? get_current_user_id() : $user_id; //echo '<pre>'; global $wpmem; print_r( $wpmem );
 
 
 
 
 
 
 
505
  $access = false;
506
- foreach ( $product as $prod ) {
 
 
 
507
  if ( isset( $this->access[ $prod ] ) ) {
508
  // Is this an expiration product?
509
  if ( isset( $wpmem->membership->products[ $prod ]['expires'][0] ) && ! is_bool( $this->access[ $prod ] ) ) {
 
510
  if ( $this->is_current( $this->access[ $prod ] ) ) {
511
  $access = true;
512
  break;
513
  }
514
- } elseif ( '' != $wpmem->membership->products[ $prod ]['role'] ) {
 
 
515
  if ( $this->access[ $prod ] && wpmem_user_has_role( $wpmem->membership->products[ $prod ]['role'] ) ) {
516
  $access = true;
517
  break;
518
  }
519
- } else {
520
- if ( $this->access[ $prod ] ) {
521
- $access = true;
522
- break;
523
- }
524
  }
525
  }
526
  }
@@ -532,11 +549,11 @@ class WP_Members_User {
532
  * @since 3.2.3 Added $product argument.
533
  *
534
  * @param boolean $access
535
- * @param mixed $product
536
  * @param integer $user_id
537
  * @param array $args
538
  */
539
- return apply_filters( 'wpmem_user_has_access', $access, $product, $user_id );
540
 
541
  }
542
 
100
  * can be used to override a default in login_redirect.
101
  *
102
  * @since 2.7.7
103
+ * @since 2.9.2 Added $user_id
104
  *
105
  * @param string $redirect_to The url to direct to.
106
  * @param int $user->ID The user's primary key ID.
412
  /**
413
  * Get user data for all fields in WP-Members.
414
  *
415
+ * Retrieves user data for all WP-Members fields (and WP default fields)
416
  * in an array keyed by WP-Members field meta keys.
417
  *
418
  * @since 3.2.0
491
  * Validates user access to content.
492
  *
493
  * @since 3.2.0
494
+ * @todo Currently checks in this order: expiration, role, "other". If expiration product,
495
+ * and the user is current, then access is granted. This doesn't consider if the
496
+ * user is current but does not have a required role (if BOTH an expiration and role
497
+ * product). Maybe add role checking to the expiration block if both exist.
498
  *
499
  * @global object $wpmem
500
  * @param mixed $product
506
  if ( ! is_user_logged_in() ) {
507
  return false;
508
  }
509
+
510
+ // Product must be an array.
511
+ $product_array = ( ! is_array( $product ) ) ? array( $product ) : $product;
512
+
513
+ // Current user or requested user.
514
+ $user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
515
+
516
+ // Start by assuming no access.
517
  $access = false;
518
+
519
+ foreach ( $product_array as $prod ) {
520
+ $expiration_product = false;
521
+ $role_product = false;
522
  if ( isset( $this->access[ $prod ] ) ) {
523
  // Is this an expiration product?
524
  if ( isset( $wpmem->membership->products[ $prod ]['expires'][0] ) && ! is_bool( $this->access[ $prod ] ) ) {
525
+ $expiration_product = true;
526
  if ( $this->is_current( $this->access[ $prod ] ) ) {
527
  $access = true;
528
  break;
529
  }
530
+ }
531
+ if ( '' != $wpmem->membership->products[ $prod ]['role'] ) {
532
+ $role_product = true;
533
  if ( $this->access[ $prod ] && wpmem_user_has_role( $wpmem->membership->products[ $prod ]['role'] ) ) {
534
  $access = true;
535
  break;
536
  }
537
+ }
538
+ if ( ! $expiration_product && ! $role_product && $this->access[ $prod ] ) {
539
+ $access = true;
540
+ break;
 
541
  }
542
  }
543
  }
549
  * @since 3.2.3 Added $product argument.
550
  *
551
  * @param boolean $access
552
+ * @param array $product
553
  * @param integer $user_id
554
  * @param array $args
555
  */
556
+ return apply_filters( 'wpmem_user_has_access', $access, $product_array, $user_id );
557
 
558
  }
559
 
inc/class-wp-members-widget.php CHANGED
@@ -274,8 +274,10 @@ class widget_wpmemwidget extends WP_Widget {
274
 
275
  $form = '<form name="form" method="post" action="' . $post_to . '">' . $args['n'] . $form . $args['n'] . '</form>';
276
 
277
- // Add status message.
278
- $form = $args['status_msg'] . $args['n'] . $form;
 
 
279
 
280
  // Strip breaks.
281
  $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
@@ -290,9 +292,15 @@ class widget_wpmemwidget extends WP_Widget {
290
  $form = apply_filters( 'wpmem_sidebar_form', $form );
291
 
292
  $do_error_msg = '';
 
 
293
  if ( isset( $_POST['slog'] ) && $wpmem_regchk == 'loginfailed' ) {
294
  $do_error_msg = true;
295
- $error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
 
 
 
 
296
  /**
297
  * Filter the sidebar login failed message.
298
  *
@@ -301,8 +309,8 @@ class widget_wpmemwidget extends WP_Widget {
301
  * @param string $error_msg The error message.
302
  */
303
  $error_msg = apply_filters( 'wpmem_login_failed_sb', $error_msg );
 
304
  }
305
- $form = ( $do_error_msg ) ? $error_msg . $form : $form;
306
 
307
  echo $form;
308
 
274
 
275
  $form = '<form name="form" method="post" action="' . $post_to . '">' . $args['n'] . $form . $args['n'] . '</form>';
276
 
277
+ // Add status message, if one exists.
278
+ if ( '' == $args['status_msg'] ) {
279
+ $args['status_msg'] . $args['n'] . $form;
280
+ }
281
 
282
  // Strip breaks.
283
  $form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
292
  $form = apply_filters( 'wpmem_sidebar_form', $form );
293
 
294
  $do_error_msg = '';
295
+ $error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
296
+
297
  if ( isset( $_POST['slog'] ) && $wpmem_regchk == 'loginfailed' ) {
298
  $do_error_msg = true;
299
+ } elseif( is_customize_preview() && get_theme_mod( 'show_form_message_dialog', false ) ) {
300
+ $do_error_msg = true;
301
+ }
302
+
303
+ if ( $do_error_msg ) {
304
  /**
305
  * Filter the sidebar login failed message.
306
  *
309
  * @param string $error_msg The error message.
310
  */
311
  $error_msg = apply_filters( 'wpmem_login_failed_sb', $error_msg );
312
+ $form = $error_msg . $form;
313
  }
 
314
 
315
  echo $form;
316
 
inc/class-wp-members.php CHANGED
@@ -1,1626 +1,1715 @@
1
- <?php
2
- /**
3
- * The WP_Members Class.
4
- *
5
- * This is the main WP_Members object class. This class contains functions
6
- * for loading settings, shortcodes, hooks to WP, plugin dropins, constants,
7
- * and registration fields. It also manages whether content should be blocked.
8
- *
9
- * @package WP-Members
10
- * @subpackage WP_Members Object Class
11
- * @since 3.0.0
12
- */
13
-
14
- // Exit if accessed directly.
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit();
17
- }
18
-
19
- class WP_Members {
20
-
21
- /**
22
- * Plugin version.
23
- *
24
- * @since 3.0.0
25
- * @access public
26
- * @var string
27
- */
28
- public $version = WPMEM_VERSION;
29
-
30
- /**
31
- * Database version
32
- *
33
- * @since 3.2.2
34
- * @access public
35
- * @var string
36
- */
37
- public $db_version = WPMEM_DB_VERSION;
38
-
39
- /**
40
- * Content block settings.
41
- *
42
- * @since 3.0.0
43
- * @access public
44
- * @var array
45
- */
46
- public $block;
47
-
48
- /**
49
- * Excerpt settings.
50
- *
51
- * @since 3.0.0
52
- * @access public
53
- * @var array
54
- */
55
- public $show_excerpt;
56
-
57
- /**
58
- * Show login form settings.
59
- *
60
- * @since 3.0.0
61
- * @access public
62
- * @var array
63
- */
64
- public $show_login;
65
-
66
- /**
67
- * Show registration form settings.
68
- *
69
- * @since 3.0.0
70
- * @access public
71
- * @var array
72
- */
73
- public $show_reg;
74
-
75
- /**
76
- * Auto-excerpt settings.
77
- *
78
- * @since 3.0.0
79
- * @access public
80
- * @var array
81
- */
82
- public $autoex;
83
-
84
- /**
85
- * Notify admin settings.
86
- *
87
- * @since 3.0.0
88
- * @access public
89
- * @var string
90
- */
91
- public $notify;
92
-
93
- /**
94
- * Moderated registration settings.
95
- *
96
- * @since 3.0.0
97
- * @access public
98
- * @var string
99
- */
100
- public $mod_reg;
101
-
102
- /**
103
- * Captcha settings.
104
- *
105
- * @since 3.0.0
106
- * @access public
107
- * @var array
108
- */
109
- public $captcha;
110
-
111
- /**
112
- * Enable expiration extension settings.
113
- *
114
- * @since 3.0.0
115
- * @access public
116
- * @var string
117
- */
118
- public $use_exp;
119
-
120
- /**
121
- * Expiration extension enable trial period.
122
- *
123
- * @since 3.0.0
124
- * @access public
125
- * @var string
126
- */
127
- public $use_trial;
128
-
129
- /**
130
- *
131
- *
132
- * @since 3.0.0
133
- * @access public
134
- * @var array
135
- */
136
- public $warnings;
137
-
138
- /**
139
- * Enable drop-ins setting.
140
- *
141
- * @since 3.1.9
142
- * @access public
143
- * @var string
144
- */
145
- public $dropins = 0;
146
-
147
- /**
148
- * Container for enabled dropins.
149
- *
150
- * @since 3.1.9
151
- * @access public
152
- * @var array
153
- */
154
- public $dropins_enabled = array();
155
-
156
- /**
157
- * Current plugin action container.
158
- *
159
- * @since 3.0.0
160
- * @access public
161
- * @var string
162
- */
163
- public $action;
164
-
165
- /**
166
- * Regchk container.
167
- *
168
- * @since 3.0.0
169
- * @access public
170
- * @var string
171
- */
172
- public $regchk;
173
-
174
- /**
175
- * User page settings.
176
- *
177
- * @since 3.0.0
178
- * @access public
179
- * @var array
180
- */
181
- public $user_pages;
182
-
183
- /**
184
- * Custom Post Type settings.
185
- *
186
- * @since 3.0.0
187
- * @access public
188
- * @var array
189
- */
190
- public $post_types;
191
-
192
- /**
193
- * Setting for applying texturization.
194
- *
195
- * @since 3.1.7
196
- * @access public
197
- * @var boolean
198
- */
199
- public $texturize;
200
-
201
- /**
202
- * Enable product creation.
203
- *
204
- * @since 3.2.0
205
- * @access public
206
- * @var boolean
207
- */
208
- public $enable_products;
209
-
210
- /**
211
- * Enable logged-in menu clones.
212
- *
213
- * @since 3.2.0
214
- * @access public
215
- * @var string
216
- */
217
- public $clone_menus;
218
-
219
- /**
220
- * Container for error messages.
221
- *
222
- * @since 3.2.0
223
- * @access public
224
- * @var string
225
- */
226
- public $error;
227
-
228
- /**
229
- * Plugin initialization function.
230
- *
231
- * @since 3.0.0
232
- * @since 3.1.6 Dependencies now loaded by object.
233
- */
234
- function __construct() {
235
-
236
- // Load dependent files.
237
- $this->load_dependencies();
238
-
239
- /**
240
- * Filter the options before they are loaded into constants.
241
- *
242
- * @since 2.9.0
243
- * @since 3.0.0 Moved to the WP_Members class.
244
- *
245
- * @param array $this->settings An array of the WP-Members settings.
246
- */
247
- $settings = apply_filters( 'wpmem_settings', get_option( 'wpmembers_settings' ) );
248
-
249
- // Validate that v3 settings are loaded.
250
- if ( ! isset( $settings['version'] )
251
- || $settings['version'] != $this->version
252
- || ! isset( $settings['db_version'] )
253
- || $settings['db_version'] != $this->db_version ) {
254
- /**
255
- * Load installation routine.
256
- */
257
- require_once( WPMEM_PATH . 'inc/install.php' );
258
- // Update settings.
259
- /** This filter is documented in /inc/class-wp-members.php */
260
- $settings = apply_filters( 'wpmem_settings', wpmem_do_install() );
261
- }
262
-
263
- // Assemble settings.
264
- foreach ( $settings as $key => $val ) {
265
- $this->$key = $val;
266
- }
267
-
268
- $this->load_user_pages();
269
- $this->cssurl = ( isset( $this->style ) && $this->style == 'use_custom' ) ? $this->cssurl : $this->style; // Set the stylesheet.
270
- $this->forms = new WP_Members_Forms; // Load forms.
271
- $this->api = new WP_Members_API; // Load api.
272
- $this->user = new WP_Members_User( $this ); // Load user functions.
273
- $this->shortcodes = new WP_Members_Shortcodes(); // Load shortcodes.
274
- $this->membership = new WP_Members_Products(); // Load membership plans
275
- $this->email = new WP_Members_Email; // Load email functions
276
- $this->menus = ( $this->clone_menus ) ? new WP_Members_Menus() : null; // Load clone menus.
277
-
278
- /**
279
- * Fires after main settings are loaded.
280
- *
281
- * @since 3.0
282
- * @deprecated 3.2.0 Use wpmem_after_init instead.
283
- */
284
- do_action( 'wpmem_settings_loaded' );
285
-
286
- // Preload the expiration module, if available.
287
- $exp_active = ( function_exists( 'wpmem_exp_init' ) || function_exists( 'wpmem_set_exp' ) ) ? true : false;
288
- define( 'WPMEM_EXP_MODULE', $exp_active );
289
-
290
- // Load actions and filters.
291
- $this->load_hooks();
292
-
293
- // Load contants.
294
- $this->load_constants();
295
-
296
- // Load dropins.
297
- if ( $this->dropins ) {
298
- $this->load_dropins();
299
- }
300
- }
301
-
302
- /**
303
- * Plugin initialization function to load hooks.
304
- *
305
- * @since 3.0.0
306
- */
307
- function load_hooks() {
308
-
309
- /**
310
- * Fires before action and filter hooks load.
311
- *
312
- * @since 3.0.0
313
- * @since 3.1.6 Fires before hooks load.
314
- */
315
- do_action( 'wpmem_load_hooks' );
316
-
317
- // Add actions.
318
- add_action( 'template_redirect', array( $this, 'get_action' ) );
319
- add_action( 'widgets_init', array( $this, 'widget_init' ) ); // initializes the widget
320
- add_action( 'admin_init', array( $this, 'load_admin' ) ); // check user role to load correct dashboard
321
- add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
322
- add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
323
- add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
324
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); // Enqueues the stylesheet.
325
- add_action( 'wp_enqueue_scripts', array( $this, 'loginout_script' ) );
326
- add_action( 'init', array( $this->membership, 'add_cpt' ), 0 ); // Adds membership plans custom post type.
327
- add_action( 'wpmem_pwd_change', array( $this->user, 'set_password' ), 9, 2 );
328
- add_action( 'wpmem_pwd_change', array( $this->user, 'set_as_logged_in' ), 10 );
329
- add_action( 'pre_get_posts', array( $this, 'do_hide_posts' ) );
330
- add_action( 'customize_register', array( $this, 'customizer_settings' ) );
331
-
332
- // Add filters.
333
- add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
334
- add_filter( 'allow_password_reset', array( $this->user, 'no_reset' ) ); // no password reset for non-activated users
335
- add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
336
- add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
337
- add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
338
- add_filter( 'comments_open', array( $this, 'do_securify_comments' ), 99 ); // securifies the comments
339
- add_filter( 'wpmem_securify', array( $this, 'reg_securify' ) ); // adds success message on login form if redirected
340
- //add_filter( 'query_vars', array( $this, 'add_query_vars' ), 10, 2 ); // adds custom query vars
341
- add_filter( 'get_pages', array( $this, 'filter_get_pages' ) );
342
- add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_nav_menu_items' ), null, 3 );
343
- add_filter( 'get_previous_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
344
- add_filter( 'get_next_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
345
-
346
- // If registration is moderated, check for activation (blocks backend login by non-activated users).
347
- if ( $this->mod_reg == 1 ) {
348
- add_filter( 'authenticate', array( $this->user, 'check_activated' ), 99, 3 );
349
- }
350
-
351
- /**
352
- * Fires after action and filter hooks load.
353
- *
354
- * @since 3.0.0
355
- * @since 3.1.6 Was wpmem_load_hooks, now wpmem_hooks_loaded.
356
- */
357
- do_action( 'wpmem_hooks_loaded' );
358
- }
359
-
360
- /**
361
- * Load drop-ins.
362
- *
363
- * @since 3.0.0
364
- *
365
- * @todo This is experimental. The function and its operation is subject to change.
366
- */
367
- function load_dropins() {
368
-
369
- /**
370
- * Fires before dropins load (for adding additional drop-ins).
371
- *
372
- * @since 3.0.0
373
- * @since 3.1.6 Fires before dropins.
374
- */
375
- do_action( 'wpmem_load_dropins' );
376
-
377
- /**
378
- * Filters the drop-in file folder.
379
- *
380
- * @since 3.0.0
381
- *
382
- * @param string $folder The drop-in file folder.
383
- */
384
- $folder = apply_filters( 'wpmem_dropin_folder', WPMEM_DROPIN_DIR );
385
-
386
- // Load any drop-ins.
387
- $settings = get_option( 'wpmembers_dropins' );
388
- $this->dropins_enabled = ( $settings ) ? $settings : array();
389
- if ( ! empty( $this->dropins_enabled ) ) {
390
- foreach ( $this->dropins_enabled as $filename ) {
391
- $dropin = $folder . $filename;
392
- if ( file_exists( $dropin ) ) {
393
- include_once( $dropin );
394
- }
395
- }
396
- }
397
-
398
- /**
399
- * Fires before dropins load (for adding additional drop-ins).
400
- *
401
- * @since 3.0.0
402
- * @since 3.1.6 Was wpmem_load_dropins, now wpmem_dropins_loaded.
403
- */
404
- do_action( 'wpmem_dropins_loaded' );
405
- }
406
-
407
- /**
408
- * Loads pre-3.0 constants (included primarily for add-on compatibility).
409
- *
410
- * @since 3.0.0
411
- */
412
- function load_constants() {
413
- ( ! defined( 'WPMEM_BLOCK_POSTS' ) ) ? define( 'WPMEM_BLOCK_POSTS', $this->block['post'] ) : ''; // @todo Can deprecate? Probably 3.3
414
- ( ! defined( 'WPMEM_BLOCK_PAGES' ) ) ? define( 'WPMEM_BLOCK_PAGES', $this->block['page'] ) : ''; // @todo Can deprecate? Probably 3.3
415
- ( ! defined( 'WPMEM_SHOW_EXCERPT' ) ) ? define( 'WPMEM_SHOW_EXCERPT', $this->show_excerpt['post'] ) : ''; // @todo Can deprecate? Probably 3.3
416
- ( ! defined( 'WPMEM_NOTIFY_ADMIN' ) ) ? define( 'WPMEM_NOTIFY_ADMIN', $this->notify ) : ''; // @todo Can deprecate? Probably 3.3
417
- ( ! defined( 'WPMEM_MOD_REG' ) ) ? define( 'WPMEM_MOD_REG', $this->mod_reg ) : ''; // @todo Can deprecate? Probably 3.3
418
- ( ! defined( 'WPMEM_CAPTCHA' ) ) ? define( 'WPMEM_CAPTCHA', $this->captcha ) : ''; // @todo Can deprecate? Probably 3.3
419
- ( ! defined( 'WPMEM_NO_REG' ) ) ? define( 'WPMEM_NO_REG', ( -1 * $this->show_reg['post'] ) ) : ''; // @todo Can deprecate? Probably 3.3
420
- ( ! defined( 'WPMEM_USE_EXP' ) ) ? define( 'WPMEM_USE_EXP', $this->use_exp ) : '';
421
- ( ! defined( 'WPMEM_USE_TRL' ) ) ? define( 'WPMEM_USE_TRL', $this->use_trial ) : '';
422
- ( ! defined( 'WPMEM_IGNORE_WARN' ) ) ? define( 'WPMEM_IGNORE_WARN', $this->warnings ) : ''; // @todo Can deprecate? Probably 3.3
423
-
424
- ( ! defined( 'WPMEM_MSURL' ) ) ? define( 'WPMEM_MSURL', $this->user_pages['profile'] ) : ''; // @todo Can deprecate? Probably 3.3
425
- ( ! defined( 'WPMEM_REGURL' ) ) ? define( 'WPMEM_REGURL', $this->user_pages['register'] ) : ''; // @todo Can deprecate? Probably 3.3
426
- ( ! defined( 'WPMEM_LOGURL' ) ) ? define( 'WPMEM_LOGURL', $this->user_pages['login'] ) : ''; // @todo Can deprecate? Probably 3.3
427
-
428
- ( ! defined( 'WPMEM_DROPIN_DIR' ) ) ? define( 'WPMEM_DROPIN_DIR', WP_PLUGIN_DIR . '/wp-members-dropins/' ) : '';
429
-
430
- define( 'WPMEM_CSSURL', $this->cssurl );
431
- }
432
-
433
- /**
434
- * Load dependent files.
435
- *
436
- * @since 3.1.6
437
- */
438
- function load_dependencies() {
439
-
440
- /**
441
- * Filter the location and name of the pluggable file.
442
- *
443
- * @since 2.9.0
444
- * @since 3.1.6 Moved in load order to come before dependencies.
445
- *
446
- * @param string The path to WP-Members plugin functions file.
447
- */
448
- $wpmem_pluggable = apply_filters( 'wpmem_plugins_file', WP_PLUGIN_DIR . '/wp-members-pluggable.php' );
449
-
450
- // Preload any custom functions, if available.
451
- if ( file_exists( $wpmem_pluggable ) ) {
452
- include( $wpmem_pluggable );
453
- }
454
-
455
- require_once( WPMEM_PATH . 'inc/class-wp-members-api.php' );
456
- require_once( WPMEM_PATH . 'inc/class-wp-members-user.php' );
457
- require_once( WPMEM_PATH . 'inc/class-wp-members-email.php' );
458
- require_once( WPMEM_PATH . 'inc/class-wp-members-forms.php' );
459
- require_once( WPMEM_PATH . 'inc/class-wp-members-menus.php' );
460
- require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
461
- require_once( WPMEM_PATH . 'inc/class-wp-members-products.php' );
462
- require_once( WPMEM_PATH . 'inc/class-wp-members-shortcodes.php' );
463
- require_once( WPMEM_PATH . 'inc/api.php' );
464
- require_once( WPMEM_PATH . 'inc/api-email.php' );
465
- require_once( WPMEM_PATH . 'inc/api-forms.php' );
466
- require_once( WPMEM_PATH . 'inc/api-users.php' );
467
- require_once( WPMEM_PATH . 'inc/api-utilities.php' );
468
- require_once( WPMEM_PATH . 'inc/forms.php' );
469
- require_once( WPMEM_PATH . 'inc/dialogs.php' );
470
- require_once( WPMEM_PATH . 'inc/wp-registration.php' );
471
- require_once( WPMEM_PATH . 'inc/deprecated.php' );
472
- //require_once( WPMEM_PATH . 'inc/core.php' ); // @deprectated 3.2.4
473
- //require_once( WPMEM_PATH . 'inc/utilities.php' ); // @deprecated 3.2.3
474
- //require_once( WPMEM_PATH . 'inc/sidebar.php' ); // @deprecated 3.2.0
475
- //require_once( WPMEM_PATH . 'inc/shortcodes.php' ); // @deprecated 3.2.0
476
- //require_once( WPMEM_PATH . 'inc/email.php' ); // @deprecated 3.2.0
477
- //require_once( WPMEM_PATH . 'inc/users.php' ); // @deprecated 3.1.9
478
-
479
- }
480
-
481
- /**
482
- * Load admin API and dependencies.
483
- *
484
- * Determines which scripts to load and actions to use based on the
485
- * current users capabilities.
486
- *
487
- * @since 2.5.2
488
- * @since 3.1.0 Added admin api object.
489
- * @since 3.1.7 Moved from main plugin file as wpmem_chk_admin() to main object.
490
- */
491
- function load_admin() {
492
-
493
- /**
494
- * Fires before initialization of admin options.
495
- *
496
- * @since 2.9.0
497
- */
498
- do_action( 'wpmem_pre_admin_init' );
499
-
500
- // Initilize the admin api.
501
- $this->load_admin_api();
502
-
503
- /**
504
- * Fires after initialization of admin options.
505
- *
506
- * @since 2.9.0
507
- */
508
- do_action( 'wpmem_after_admin_init' );
509
- }
510
-
511
- /**
512
- * Gets the requested action.
513
- *
514
- * @since 3.0.0
515
- *
516
- * @global string $wpmem_a The WP-Members action variable.
517
- */
518
- function get_action() {
519
-
520
- // Get the action being done (if any).
521
- $this->action = sanitize_text_field( wpmem_get( 'a', '', 'request' ) );
522
-
523
- // For backward compatibility with processes that check $wpmem_a.
524
- global $wpmem_a;
525
- $wpmem_a = $this->action;
526
-
527
- /**
528
- * Fires when the wpmem action is retrieved.
529
- *
530
- * @since 3.1.7
531
- */
532
- do_action( 'wpmem_get_action' );
533
-
534
- // Get the regchk value (if any).
535
- $this->regchk = $this->get_regchk( $this->action );
536
- }
537
-
538
- /**
539
- * Gets the regchk value.
540
- *
541
- * regchk is a legacy variable that contains information about the current
542
- * action being performed. Login, logout, password, registration, profile
543
- * update functions all return a specific value that is stored in regchk.
544
- * This value and information about the current action can then be used to
545
- * determine what content is to be displayed by the securify function.
546
- *
547
- * @since 3.0.0
548
- *
549
- * @global string $wpmem_a The WP-Members action variable.
550
- *
551
- * @param string $action The current action.
552
- * @return string The regchk value.
553
- */
554
- function get_regchk( $action ) {
555
-
556
- switch ( $action ) {
557
-
558
- case 'login':
559
- $regchk = $this->user->login();
560
- break;
561
-
562
- case 'logout':
563
- $regchk = $this->user->logout();
564
- break;
565
-
566
- case 'pwdchange':
567
- $regchk = $this->user->password_update( 'change' );
568
- break;
569
-
570
- case 'pwdreset':
571
- $regchk = $this->user->password_update( 'reset' );
572
- break;
573
-
574
- case 'getusername':
575
- $regchk = $this->user->retrieve_username();
576
- break;
577
-
578
- case 'register':
579
- case 'update':
580
- require_once( WPMEM_PATH . 'inc/register.php' );
581
- $regchk = wpmem_registration( $action );
582
- break;
583
-
584
- default:
585
- $regchk = ( isset( $regchk ) ) ? $regchk : '';
586
- break;
587
- }
588
-
589
- /**
590
- * Filter wpmem_regchk.
591
- *
592
- * The value of regchk is determined by functions that may be run in the get_regchk function.
593
- * This value determines what happens in the wpmem_securify() function.
594
- *
595
- * @since 2.9.0
596
- * @since 3.0.0 Moved to get_regchk() in WP_Members object.
597
- *
598
- * @param string $this->regchk The value of wpmem_regchk.
599
- * @param string $this->action The $wpmem_a action.
600
- */
601
- $regchk = apply_filters( 'wpmem_regchk', $regchk, $action );
602
-
603
- // Legacy global variable for use with older extensions.
604
- global $wpmem_regchk;
605
- $wpmem_regchk = $regchk;
606
-
607
- return $regchk;
608
- }
609
-
610
- /**
611
- * Determines if content should be blocked.
612
- *
613
- * This function was originally stand alone in the core file and
614
- * was moved to the WP_Members class in 3.0.
615
- *
616
- * @since 3.0.0
617
- *
618
- * @global object $post The WordPress Post object.
619
- * @return bool $block true|false
620
- */
621
- function is_blocked() {
622
-
623
- global $post;
624
-
625
- if ( $post ) {
626
-
627
- // Backward compatibility for old block/unblock meta.
628
- $meta = get_post_meta( $post->ID, '_wpmem_block', true );
629
- if ( ! $meta ) {
630
- // Check for old meta.
631
- $old_block = get_post_meta( $post->ID, 'block', true );
632
- $old_unblock = get_post_meta( $post->ID, 'unblock', true );
633
- $meta = ( $old_block ) ? 1 : ( ( $old_unblock ) ? 0 : $meta );
634
- }
635
-
636
- // Setup defaults.
637
- $defaults = array(
638
- 'post_id' => $post->ID,
639
- 'post_type' => $post->post_type,
640
- 'block' => ( isset( $this->block[ $post->post_type ] ) && $this->block[ $post->post_type ] == 1 ) ? true : false,
641
- 'block_meta' => $meta, // @todo get_post_meta( $post->ID, '_wpmem_block', true ),
642
- 'block_type' => ( isset( $this->block[ $post->post_type ] ) ) ? $this->block[ $post->post_type ] : 0,
643
- );
644
-
645
- /**
646
- * Filter the block arguments.
647
- *
648
- * @since 2.9.8
649
- * @since 3.0.0 Moved to is_blocked() in WP_Members object.
650
- *
651
- * @param array $args Null.
652
- * @param array $defaults Although you are not filtering the defaults, knowing what they are can assist developing more powerful functions.
653
- */
654
- $args = apply_filters( 'wpmem_block_args', '', $defaults );
655
-
656
- // Merge $args with defaults.
657
- $args = ( wp_parse_args( $args, $defaults ) );
658
-
659
- if ( is_single() || is_page() ) {
660
- switch( $args['block_type'] ) {
661
- case 1: // If content is blocked by default.
662
- $args['block'] = ( $args['block_meta'] == '0' ) ? false : $args['block'];
663
- break;
664
- case 0 : // If content is unblocked by default.
665
- $args['block'] = ( $args['block_meta'] == '1' ) ? true : $args['block'];
666
- break;
667
- }
668
-
669
- } else {
670
- $args['block'] = false;
671
- }
672
-
673
- } else {
674
- $args = array( 'block' => false );
675
- }
676
-
677
- // Don't block user pages.
678
- $args['block'] = ( in_array( get_permalink(), $this->user_pages ) ) ? false : $args['block'];
679
-
680
- /**
681
- * Filter the block boolean.
682
- *
683
- * @since 2.7.5
684
- *
685
- * @param bool $args['block']
686
- * @param array $args
687
- */
688
- return apply_filters( 'wpmem_block', $args['block'], $args );
689
- }
690
-
691
- /**
692
- * The Securify Content Filter.
693
- *
694
- * This is the primary function that picks up where get_action() leaves off.
695
- * Determines whether content is shown or hidden for both post and pages. This
696
- * is a filter function for the_content.
697
- *
698
- * @link https://developer.wordpress.org/reference/functions/the_content/
699
- * @link https://developer.wordpress.org/reference/hooks/the_content/
700
- *
701
- * @since 3.0.0
702
- *
703
- * @global object $post The WordPress Post object.
704
- * @global object $wpmem The WP_Members object.
705
- * @global string $wpmem_themsg Contains messages to be output.
706
- * @param string $content
707
- * @return string $content
708
- */
709
- function do_securify( $content = null ) {
710
-
711
- global $post, $wpmem, $wpmem_themsg;
712
-
713
- $content = ( is_single() || is_page() ) ? $content : wpmem_do_excerpt( $content );
714
-
715
- if ( ( ! has_shortcode( $content, 'wp-members' ) ) ) {
716
-
717
- if ( $this->regchk == "captcha" ) {
718
- global $wpmem_captcha_err;
719
- $wpmem_themsg = $wpmem->get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
720
- }
721
-
722
- // Block/unblock Posts.
723
- if ( ! is_user_logged_in() && $this->is_blocked() == true ) {
724
-
725
- //Show the login and registration forms.
726
- if ( $this->regchk ) {
727
-
728
- // Empty content in any of these scenarios.
729
- $content = '';
730
-
731
- switch ( $this->regchk ) {
732
-
733
- case "loginfailed":
734
- $content = wpmem_inc_loginfailed();
735
- break;
736
-
737
- case "success":
738
- $content = wpmem_inc_regmessage( $this->regchk, $wpmem_themsg );
739
- $content = $content . wpmem_inc_login();
740
- break;
741
-
742
- default:
743
- $content = wpmem_inc_regmessage( $this->regchk, $wpmem_themsg );
744
- $content = $content . wpmem_inc_registration();
745
- break;
746
- }
747
-
748
- } else {
749
-
750
- // Toggle shows excerpt above login/reg on posts/pages.
751
- global $wp_query;
752
- if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
753
-
754
- // Shuts down excerpts on multipage posts if not on first page.
755
- $content = '';
756
-
757
- } elseif ( isset( $this->show_excerpt[ $post->post_type ] ) && $this->show_excerpt[ $post->post_type ] == 1 ) {
758
-
759
- if ( ! stristr( $content, '<span id="more' ) ) {
760
- $content = wpmem_do_excerpt( $content );
761
- } else {
762
- $len = strpos( $content, '<span id="more' );
763
- $content = substr( $content, 0, $len );
764
- }
765
-
766
- } else {
767
-
768
- // Empty all content.
769
- $content = '';
770
-
771
- }
772
-
773
- $content = ( isset( $this->show_login[ $post->post_type ] ) && $this->show_login[ $post->post_type ] == 1 ) ? $content . wpmem_inc_login() : $content . wpmem_inc_login( 'page', '', 'hide' );
774
-
775
- $content = ( isset( $this->show_reg[ $post->post_type ] ) && $this->show_reg[ $post->post_type ] == 1 ) ? $content . wpmem_inc_registration() : $content;
776
- }
777
-
778
- // Protects comments if expiration module is used and user is expired.
779
- } elseif ( is_user_logged_in() && $this->is_blocked() == true ){
780
-
781
- if ( $this->use_exp == 1 && function_exists( 'wpmem_do_expmessage' ) ) {
782
- /**
783
- * Filters the user expired message used by the PayPal extension.
784
- *
785
- * @since 3.2.0
786
- *
787
- * @param string $message
788
- * @param string $content
789
- */
790
- $content = apply_filters( 'wpmem_do_expmessage', wpmem_do_expmessage( $content ), $content );
791
- }
792
- }
793
- }
794
-
795
- /**
796
- * Filter the value of $content after wpmem_securify has run.
797
- *
798
- * @since 2.7.7
799
- * @since 3.0.0 Moved to new method in WP_Members Class.
800
- *
801
- * @param string $content The content after securify has run.
802
- */
803
- $content = apply_filters( 'wpmem_securify', $content );
804
-
805
- if ( 1 == $this->texturize && strstr( $content, '[wpmem_txt]' ) ) {
806
- // Fix the wptexturize.
807
- remove_filter( 'the_content', 'wpautop' );
808
- remove_filter( 'the_content', 'wptexturize' );
809
- add_filter( 'the_content', array( $this, 'texturize' ), 999 );
810
- }
811
-
812
- return $content;
813
-
814
- }
815
-
816
- /**
817
- * Securifies the comments.
818
- *
819
- * If the user is not logged in and the content is blocked
820
- * (i.e. wpmem->is_blocked() returns true), function loads a
821
- * dummy/empty comments template.
822
- *
823
- * @since 2.9.9
824
- * @since 3.2.0 Moved wpmem_securify_comments() to main class, renamed.
825
- *
826
- * @return bool $open true if current post is open for comments, otherwise false.
827
- */
828
- function do_securify_comments( $open ) {
829
-
830
- $open = ( ! is_user_logged_in() && wpmem_is_blocked() ) ? false : $open;
831
-
832
- /**
833
- * Filters whether comments are open or not.
834
- *
835
- * @since 3.0.0
836
- * @since 3.2.0 Moved to main class.
837
- *
838
- * @param bool $open true if current post is open for comments, otherwise false.
839
- */
840
- $open = apply_filters( 'wpmem_securify_comments', $open );
841
-
842
- if ( ! $open ) {
843
- /** This filter is documented in wp-includes/comment-template.php */
844
- add_filter( 'comments_array', array( $this, 'do_securify_comments_array' ), 10, 2 );
845
- }
846
-
847
- return $open;
848
- }
849
-
850
- /**
851
- * Empties the comments array if content is blocked.
852
- *
853
- * @since 3.0.1
854
- * @since 3.2.0 Moved wpmem_securify_comments_array() to main class, renamed.
855
- *
856
- * @global object $wpmem The WP-Members object class.
857
- *
858
- * @return array $comments The comments array.
859
- */
860
- function do_securify_comments_array( $comments , $post_id ) {
861
- $comments = ( ! is_user_logged_in() && wpmem_is_blocked() ) ? array() : $comments;
862
- return $comments;
863
- }
864
-
865
- /**
866
- * Adds the successful registration message on the login page if reg_nonce validates.
867
- *
868
- * @since 3.1.7
869
- * @since 3.2.0 Moved to wpmem object, renamed reg_securify()
870
- *
871
- * @param string $content
872
- * @return string $content
873
- */
874
- function reg_securify( $content ) {
875
- global $wpmem, $wpmem_themsg;
876
- $nonce = wpmem_get( 'reg_nonce', false, 'get' );
877
- if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
878
- $content = wpmem_inc_regmessage( 'success', $wpmem_themsg );
879
- $content = $content . wpmem_inc_login();
880
- }
881
- return $content;
882
- }
883
-
884
- /**
885
- * Gets an array of hidden post IDs.
886
- *
887
- * @since 3.2.0
888
- *
889
- * @global object $wpdb
890
- * @return array $hidden
891
- */
892
- function hidden_posts() {
893
- global $wpdb;
894
- $hidden = get_transient( '_wpmem_hidden_posts' );
895
- if ( false === $hidden ) {
896
- $hidden = $this->update_hidden_posts();
897
- }
898
- return $hidden;
899
- }
900
-
901
- /**
902
- * Updates the hidden post array transient.
903
- *
904
- * @since 3.2.0
905
- *
906
- * @global object $wpdb
907
- * @return array $hidden
908
- */
909
- function update_hidden_posts() {
910
- global $wpdb;
911
- $hidden = array();
912
- $results = $wpdb->get_results( "SELECT post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_wpmem_block' AND meta_value = 2" );
913
- foreach( $results as $result ) {
914
- $hidden[] = $result->post_id;
915
- }
916
- set_transient( '_wpmem_hidden_posts', $hidden, 60*5 );
917
- return $hidden;
918
- }
919
-
920
- /**
921
- * Gets an array of hidden post IDs.
922
- *
923
- * @since 3.2.0
924
- *
925
- * @global object $wpmem
926
- * @return array $hidden
927
- */
928
- function get_hidden_posts() {
929
- global $wpmem;
930
- $hidden = array();
931
- // @todo This should really be either a transient, or an array of
932
- // post IDs should be updated anytime a post is saved/updated.
933
- if ( ! is_admin() && ( ! is_user_logged_in() ) ) {
934
- $hidden = $this->hidden_posts();
935
- }
936
-
937
- // @todo Separate query here to check. If the user IS logged in, check what posts they DON'T have access to.
938
- if ( ! is_admin() && is_user_logged_in() && 1 == $wpmem->enable_products ) {
939
- // Get user product access.
940
- // @todo This should certainly be a transient stored in the user object.
941
- foreach ( $wpmem->membership->products as $key => $value ) {
942
- if ( ! isset( $wpmem->user->access[ $key ] ) || ! $wpmem->user->is_current( $wpmem->user->access[ $key ] ) ) {
943
- $hidden_posts = $this->hidden_posts();
944
- $hidden_posts = ( is_array( $hidden_posts ) ) ? $hidden_posts : array();
945
- foreach ( $hidden_posts as $post_id ) {
946
- if ( 1 == get_post_meta( $post_id, $wpmem->membership->post_stem . $key, true ) ) {
947
- $hidden[] = $post_id;
948
- }
949
- }
950
- }
951
- }
952
- }
953
- return $hidden;
954
- }
955
-
956
- /**
957
- * Hides posts based on settings and meta.
958
- *
959
- * @since 3.2.0
960
- *
961
- * @param array $query
962
- * @return array $query
963
- */
964
- function do_hide_posts( $query ) {
965
- $hidden_posts = $this->get_hidden_posts();
966
- if ( ! empty( $hidden_posts ) ) {
967
- $query->set( 'post__not_in', $hidden_posts );
968
- }
969
- return $query;
970
- }
971
-
972
- /**
973
- * Filter to hide pages for get_pages().
974
- *
975
- * @since 3.2.0
976
- *
977
- * @global object $wpdb
978
- * @param array $pages
979
- * @return array $pages
980
- */
981
- function filter_get_pages( $pages ) {
982
- $hidden_posts = $this->get_hidden_posts();
983
- if ( ! empty ( $hidden_posts ) ) {
984
- $new_pages = array();
985
- foreach ( $pages as $key => $page ) {
986
- if ( ! in_array( $page->ID, $hidden_posts ) ) {
987
- $new_pages[ $key ] = $page;
988
- }
989
- }
990
- $pages = $new_pages;
991
- }
992
- return $pages;
993
- }
994
-
995
- /**
996
- * Filter to hide menu items.
997
- *
998
- * @since 3.2.0
999
- *
1000
- * @param array $items
1001
- * @param $menu
1002
- * @param array $args
1003
- * @return array $items
1004
- */
1005
- function filter_nav_menu_items( $items, $menu, $args ) {
1006
- $hidden_posts = $this->get_hidden_posts();
1007
- if ( ! empty( $hidden_posts ) ) {
1008
- foreach ( $items as $key => $item ) {
1009
- if ( in_array( $item->object_id, $hidden_posts ) ) {
1010
- unset( $items[ $key ] );
1011
- }
1012
- }
1013
- }
1014
- return $items;
1015
- }
1016
-
1017
- /**
1018
- * Filter to remove hidden posts from prev/next links.
1019
- *
1020
- * @since 3.2.4
1021
- *
1022
- * @global object $wpmem
1023
- * @param string $where
1024
- * @return string $where
1025
- */
1026
- function filter_get_adjacent_post_where( $where ) {
1027
- global $wpmem;
1028
- $hidden_posts = $this->get_hidden_posts();
1029
- if ( ! empty( $hidden_posts ) ) {
1030
- $hidden = implode( ",", $hidden_posts );
1031
- $where = $where . " AND p.ID NOT IN ( $hidden )";
1032
- }
1033
- return $where;
1034
- }
1035
-
1036
- /**
1037
- * Sets the registration fields.
1038
- *
1039
- * @since 3.0.0
1040
- * @since 3.1.5 Added $form argument.
1041
- *
1042
- * @param string $form The form being generated.
1043
- */
1044
- function load_fields( $form = 'default' ) {
1045
-
1046
- // Get stored fields settings.
1047
- $fields = get_option( 'wpmembers_fields' );
1048
-
1049
- // Validate fields settings.
1050
- if ( ! isset( $fields ) || empty( $fields ) ) {
1051
- // Update settings.
1052
- $fields = array( array( 10, 'Email', 'user_email', 'email', 'y', 'y', 'y' ) );
1053
- }
1054
-
1055
- // Add new field array keys
1056
- foreach ( $fields as $key => $val ) {
1057
-
1058
- // Key fields with meta key.
1059
- $meta_key = $val[2];
1060
-
1061
- // Old format, new key.
1062
- foreach ( $val as $subkey => $subval ) {
1063
- $this->fields[ $meta_key ][ $subkey ] = $subval;
1064
- }
1065
-
1066
- // Setup field properties.
1067
- $this->fields[ $meta_key ]['label'] = $val[1];
1068
- $this->fields[ $meta_key ]['type'] = $val[3];
1069
- $this->fields[ $meta_key ]['register'] = ( 'y' == $val[4] ) ? true : false;
1070
- $this->fields[ $meta_key ]['required'] = ( 'y' == $val[5] ) ? true : false;
1071
- $this->fields[ $meta_key ]['profile'] = '';
1072
- $this->fields[ $meta_key ]['native'] = ( 'y' == $val[6] ) ? true : false;
1073
-
1074
- // Certain field types have additional properties.
1075
- switch ( $val[3] ) {
1076
-
1077
- case 'checkbox':
1078
- $this->fields[ $meta_key ]['checked_value'] = $val[7];
1079
- $this->fields[ $meta_key ]['checked_default'] = ( 'y' == $val[8] ) ? true : false;
1080
- break;
1081
-
1082
- case 'select':
1083
- case 'multiselect':
1084
- case 'multicheckbox':
1085
- case 'radio':
1086
- // Correct a malformed value (if last value is empty due to a trailing comma).
1087
- if ( '' == end( $val[7] ) ) {
1088
- array_pop( $val[7] );
1089
- $this->fields[ $meta_key ][7] = $val[7];
1090
- }
1091
- $this->fields[ $meta_key ]['values'] = $val[7];
1092
- $this->fields[ $meta_key ]['delimiter'] = ( isset( $val[8] ) ) ? $val[8] : '|';
1093
- $this->fields[ $meta_key ]['options'] = array();
1094
- foreach ( $val[7] as $value ) {
1095
- $pieces = explode( '|', trim( $value ) );
1096
- if ( isset( $pieces[1] ) && $pieces[1] != '' ) {
1097
- $this->fields[ $meta_key ]['options'][ $pieces[1] ] = $pieces[0];
1098
- }
1099
- }
1100
- break;
1101
-
1102
- case 'file':
1103
- case 'image':
1104
- $this->fields[ $meta_key ]['file_types'] = $val[7];
1105
- break;
1106
-
1107
- case 'hidden':
1108
- $this->fields[ $meta_key ]['value'] = $val[7];
1109
- break;
1110
-
1111
- }
1112
- }
1113
- }
1114
-
1115
- /**
1116
- * Get excluded meta fields.
1117
- *
1118
- * @since 3.0.0
1119
- *
1120
- * @param string $tag A tag so we know where the function is being used.
1121
- * @return array The excluded fields.
1122
- */
1123
- function excluded_fields( $tag ) {
1124
-
1125
- // Default excluded fields.
1126
- $excluded_fields = array( 'password', 'confirm_password', 'confirm_email', 'password_confirm', 'email_confirm' );
1127
-
1128
- if ( 'update' == $tag || 'admin-profile' == $tag || 'user-profile' == $tag || 'wp-register' == $tag ) {
1129
- $excluded_fields[] = 'username';
1130
- }
1131
-
1132
- if ( 'admin-profile' == $tag || 'user-profile' == $tag ) {
1133
- array_push( $excluded_fields, 'first_name', 'last_name', 'nickname', 'display_name', 'user_email', 'description', 'user_url' );
1134
- }
1135
-
1136
- /**
1137
- * Filter the fields to be excluded when user is created/updated.
1138
- *
1139
- * @since 2.9.3
1140
- * @since 3.0.0 Moved to new method in WP_Members Class.
1141
- *
1142
- * @param array An array of the field meta names to exclude.
1143
- * @param string $tag A tag so we know where the function is being used.
1144
- */
1145
- $excluded_fields = apply_filters( 'wpmem_exclude_fields', $excluded_fields, $tag );
1146
-
1147
- // Return excluded fields.
1148
- return $excluded_fields;
1149
- }
1150
-
1151
- /**
1152
- * Set page locations.
1153
- *
1154
- * Handles numeric page IDs while maintaining
1155
- * compatibility with old full url settings.
1156
- *
1157
- * @since 3.0.8
1158
- */
1159
- function load_user_pages() {
1160
- foreach ( $this->user_pages as $key => $val ) {
1161
- if ( is_numeric( $val ) ) {
1162
- $this->user_pages[ $key ] = get_page_link( $val );
1163
- }
1164
- }
1165
- }
1166
-
1167
- /**
1168
- * Returns a requested text string.
1169
- *
1170
- * This function manages all of the front-end facing text.
1171
- * All defaults can be filtered using wpmem_default_text_strings.
1172
- *
1173
- * @since 3.1.0
1174
- *
1175
- * @param string $str
1176
- * @return string $text
1177
- */
1178
- function get_text( $str ) {
1179
-
1180
- // Default Form Fields.
1181
- $default_form_fields = array(
1182
- 'first_name' => __( 'First Name', 'wp-members' ),
1183
- 'last_name' => __( 'Last Name', 'wp-members' ),
1184
- 'addr1' => __( 'Address 1', 'wp-members' ),
1185
- 'addr2' => __( 'Address 2', 'wp-members' ),
1186
- 'city' => __( 'City', 'wp-members' ),
1187
- 'thestate' => __( 'State', 'wp-members' ),
1188
- 'zip' => __( 'Zip', 'wp-members' ),
1189
- 'country' => __( 'Country', 'wp-members' ),
1190
- 'phone1' => __( 'Day Phone', 'wp-members' ),
1191
- 'user_email' => __( 'Email', 'wp-members' ),
1192
- 'confirm_email' => __( 'Confirm Email', 'wp-members' ),
1193
- 'user_url' => __( 'Website', 'wp-members' ),
1194
- 'description' => __( 'Biographical Info', 'wp-members' ),
1195
- 'password' => __( 'Password', 'wp-members' ),
1196
- 'confirm_password' => __( 'Confirm Password', 'wp-members' ),
1197
- 'tos' => __( 'TOS', 'wp-members' ),
1198
- );
1199
-
1200
- /*
1201
- * Strings to be added in a future version, included so they will
1202
- * be in the translation template ahead of time.
1203
- * @todo Remove this once these strings have been officially included.
1204
- */
1205
- $benign_strings = array(
1206
- __( 'No fields selected for deletion', 'wp-members' ),
1207
- __( 'Username or Email', 'wp-members' ),
1208
- );
1209
-
1210
- $defaults = array(
1211
-
1212
- // Login form.
1213
- 'login_heading' => __( 'Existing Users Log In', 'wp-members' ),
1214
- 'login_username' => __( 'Username', 'wp-members' ),
1215
- 'login_password' => __( 'Password', 'wp-members' ),
1216
- 'login_button' => __( 'Log In', 'wp-members' ),
1217
- 'remember_me' => __( 'Remember Me', 'wp-members' ),
1218
- 'forgot_link_before' => __( 'Forgot password?', 'wp-members' ) . '&nbsp;',
1219
- 'forgot_link' => __( 'Click here to reset', 'wp-members' ),
1220
- 'register_link_before' => __( 'New User?', 'wp-members' ) . '&nbsp;',
1221
- 'register_link' => __( 'Click here to register', 'wp-members' ),
1222
-
1223
- // Password change form.
1224
- 'pwdchg_heading' => __( 'Change Password', 'wp-members' ),
1225
- 'pwdchg_password1' => __( 'New password', 'wp-members' ),
1226
- 'pwdchg_password2' => __( 'Confirm new password', 'wp-members' ),
1227
- 'pwdchg_button' => __( 'Update Password', 'wp-members' ),
1228
-
1229
- // Password reset form.
1230
- 'pwdreset_heading' => __( 'Reset Forgotten Password', 'wp-members' ),
1231
- 'pwdreset_username' => __( 'Username', 'wp-members' ),
1232
- 'pwdreset_email' => __( 'Email', 'wp-members' ),
1233
- 'pwdreset_button' => __( 'Reset Password' ),
1234
- 'username_link_before' => __( 'Forgot username?', 'wp-members' ) . '&nbsp;',
1235
- 'username_link' => __( 'Click here', 'wp-members' ),
1236
-
1237
- // Retrieve username form.
1238
- 'username_heading' => __( 'Retrieve username', 'wp-members' ),
1239
- 'username_email' => __( 'Email Address', 'wp-members' ),
1240
- 'username_button' => __( 'Retrieve username', 'wp-members' ),
1241
-
1242
- // Register form.
1243
- 'register_heading' => __( 'New User Registration', 'wp-members' ),
1244
- 'register_username' => __( 'Choose a Username', 'wp-members' ),
1245
- 'register_rscaptcha' => __( 'Input the code:', 'wp-members' ),
1246
- 'register_tos' => __( 'Please indicate that you agree to the %s Terms of Service %s', 'wp-members' ), // @note: if default changes, default check after wpmem_tos_link_txt must change.
1247
- 'register_clear' => __( 'Reset Form', 'wp-members' ),
1248
- 'register_submit' => __( 'Register', 'wp-members' ),
1249
- 'register_req_mark' => '<span class="req">*</span>',
1250
- 'register_required' => '<span class="req">*</span>' . __( 'Required field', 'wp-members' ),
1251
-
1252
- // User profile update form.
1253
- 'profile_heading' => __( 'Edit Your Information', 'wp-members' ),
1254
- 'profile_username' => __( 'Username', 'wp-members' ),
1255
- 'profile_submit' => __( 'Update Profile', 'wp-members' ),
1256
- 'profile_upload' => __( 'Update this file', 'wp-members' ),
1257
-
1258
- // Error messages and dialogs.
1259
- 'login_failed_heading' => __( 'Login Failed!', 'wp-members' ),
1260
- 'login_failed' => __( 'You entered an invalid username or password.', 'wp-members' ),
1261
- 'login_failed_link' => __( 'Click here to continue.', 'wp-members' ),
1262
- 'pwdchangempty' => __( 'Password fields cannot be empty', 'wp-members' ),
1263
- 'usernamefailed' => __( 'Sorry, that email address was not found.', 'wp-members' ),
1264
- 'usernamesuccess' => __( 'An email was sent to %s with your username.', 'wp-members' ),
1265
- 'reg_empty_field' => __( 'Sorry, %s is a required field.', 'wp-members' ),
1266
- 'reg_valid_email' => __( 'You must enter a valid email address.', 'wp-members' ),
1267
- 'reg_non_alphanumeric' => __( 'The username cannot include non-alphanumeric characters.', 'wp-members' ),
1268
- 'reg_empty_username' => __( 'Sorry, username is a required field', 'wp-members' ),
1269
- 'reg_password_match' => __( 'Passwords did not match.', 'wp-members' ),
1270
- 'reg_email_match' => __( 'Emails did not match.', 'wp-members' ),
1271
- 'reg_empty_captcha' => __( 'You must complete the CAPTCHA form.', 'wp-members' ),
1272
- 'reg_invalid_captcha' => __( 'CAPTCHA was not valid.', 'wp-members' ),
1273
- 'reg_generic' => __( 'There was an error processing the form.', 'wp-members' ),
1274
- 'reg_captcha_err' => __( 'There was an error with the CAPTCHA form.', 'wp-members' ),
1275
-
1276
- // Links.
1277
- 'profile_edit' => __( 'Edit My Information', 'wp-members' ),
1278
- 'profile_password' => __( 'Change Password', 'wp-members' ),
1279
- 'register_status' => __( 'You are logged in as %s', 'wp-members' ),
1280
- 'register_logout' => __( 'Click to log out.', 'wp-members' ),
1281
- 'register_continue' => __( 'Begin using the site.', 'wp-members' ),
1282
- 'login_welcome' => __( 'You are logged in as %s', 'wp-members' ),
1283
- 'login_logout' => __( 'Click to log out', 'wp-members' ),
1284
- 'status_welcome' => __( 'You are logged in as %s', 'wp-members' ),
1285
- 'status_logout' => __( 'click to log out', 'wp-members' ),
1286
- 'menu_logout' => __( 'Log Out', 'wp-members' ),
1287
-
1288
- // Widget.
1289
- 'sb_status' => __( 'You are logged in as %s', 'wp-members' ),
1290
- 'sb_logout' => __( 'click here to log out', 'wp-members' ),
1291
- 'sb_login_failed' => __( 'Login Failed!<br />You entered an invalid username or password.', 'wp-members' ),
1292
- 'sb_not_logged_in' => __( 'You are not logged in.', 'wp-members' ),
1293
- 'sb_login_username' => __( 'Username', 'wp-members' ),
1294
- 'sb_login_password' => __( 'Password', 'wp-members' ),
1295
- 'sb_login_button' => __( 'log in', 'wp-members' ),
1296
- 'sb_login_forgot' => __( 'Forgot?', 'wp-members' ),
1297
- 'sb_login_register' => __( 'Register', 'wp-members' ),
1298
-
1299
- // Default Dialogs.
1300
- 'restricted_msg' => __( "This content is restricted to site members. If you are an existing user, please log in. New users may register below.", 'wp-members' ),
1301
- 'user' => __( "Sorry, that username is taken, please try another.", 'wp-members' ),
1302
- 'email' => __( "Sorry, that email address already has an account.<br />Please try another.", 'wp-members' ),
1303
- 'success' => __( "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", 'wp-members' ),
1304
- 'editsuccess' => __( "Your information was updated!", 'wp-members' ),
1305
- 'pwdchangerr' => __( "Passwords did not match.<br /><br />Please try again.", 'wp-members' ),
1306
- 'pwdchangesuccess' => __( "Password successfully changed!", 'wp-members' ),
1307
- 'pwdreseterr' => __( "Either the username or email address do not exist in our records.", 'wp-members' ),
1308
- 'pwdresetsuccess' => __( "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.", 'wp-members' ),
1309
- 'product_restricted' => __( "Sorry, you do not have access to this content.", 'wp-members' ),
1310
-
1311
- ); // End of $defaults array.
1312
-
1313
- /**
1314
- * Filter default terms.
1315
- *
1316
- * @since 3.1.0
1317
- */
1318
- $text = apply_filters( 'wpmem_default_text_strings', '' );
1319
-
1320
- // Merge filtered $terms with $defaults.
1321
- $text = wp_parse_args( $text, $defaults );
1322
-
1323
- // Return the requested text string.
1324
- return $text[ $str ];
1325
-
1326
- } // End of get_text().
1327
-
1328
- /**
1329
- * Load the admin api.
1330
- *
1331
- * @since 3.1.0
1332
- */
1333
- function load_admin_api() {
1334
- if ( is_admin() ) {
1335
- /**
1336
- * Load the admin api class.
1337
- *
1338
- * @since 3.1.0
1339
- */
1340
- include_once( WPMEM_PATH . 'admin/includes/class-wp-members-admin-api.php' );
1341
- $this->admin = new WP_Members_Admin_API;
1342
- }
1343
- }
1344
-
1345
- /**
1346
- * Initializes the WP-Members widget.
1347
- *
1348
- * @since 3.2.0 Replaces widget_wpmemwidget_init
1349
- */
1350
- public function widget_init() {
1351
- // Register the WP-Members widget.
1352
- register_widget( 'widget_wpmemwidget' );
1353
- }
1354
-
1355
- /**
1356
- * Adds WP-Members query vars to WP's public query vars.
1357
- *
1358
- * @since 3.2.0
1359
- *
1360
- * @see https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
1361
- *
1362
- * @param array $qvars
1363
- */
1364
- public function add_query_vars ( $qvars ) {
1365
- $qvars[] = 'a'; // The WP-Members action variable.
1366
- return $qvars;
1367
- }
1368
-
1369
- /**
1370
- * Enqueues login/out script for the footer.
1371
- *
1372
- * @since 3.2.0
1373
- */
1374
- public function loginout_script() {
1375
- if ( is_user_logged_in() ) {
1376
- wp_enqueue_script( 'jquery' );
1377
- add_action( 'wp_footer', array( $this, 'do_loginout_script' ), 50 );
1378
- }
1379
- }
1380
-
1381
- /**
1382
- * Outputs login/out script for the footer.
1383
- *
1384
- * @since 3.2.0
1385
- *
1386
- * @global object $wpmem
1387
- */
1388
- public function do_loginout_script() {
1389
- global $wpmem;
1390
- $logout = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
1391
- ?><script type="text/javascript">
1392
- jQuery('.wpmem_loginout').html('<a class="login_button" href="<?php echo $logout; ?>"><?php echo $this->get_text( 'menu_logout' ); ?></a>');
1393
- </script><?php
1394
- }
1395
-
1396
- /**
1397
- * Adds WP-Members controls to the Customizer
1398
- *
1399
- * @since 3.2.0
1400
- *
1401
- * @param object $wp_customize The Customizer object.
1402
- */
1403
- function customizer_settings( $wp_customize ) {
1404
- $wp_customize->add_section( 'wp_members' , array(
1405
- 'title' => 'WP-Members',
1406
- 'priority' => 190,
1407
- ) );
1408
-
1409
- // Add settings for output description
1410
- $wp_customize->add_setting( 'show_logged_out_state', array(
1411
- 'default' => '1',
1412
- 'type' => 'theme_mod', //'option'
1413
- 'capability' => 'edit_theme_options',
1414
- 'transport' => 'refresh',
1415
- ) );
1416
-
1417
- // Add control and output for select field
1418
- $wp_customize->add_control( 'show_form_logged_out', array(
1419
- 'label' => __( 'Show forms as logged out', 'wp-members' ),
1420
- 'section' => 'wp_members',
1421
- 'settings' => 'show_logged_out_state',
1422
- 'type' => 'checkbox',
1423
- 'std' => '1'
1424
- ) );
1425
- }
1426
-
1427
- /**
1428
- * Overrides the wptexturize filter.
1429
- *
1430
- * Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
1431
- *
1432
- * @since 2.6.4
1433
- * @since 3.2.3 Moved to WP_Members class.
1434
- *
1435
- * @todo Possibly deprecate or severely alter this process as its need may be obsolete.
1436
- *
1437
- * @param string $content
1438
- * @return string $new_content
1439
- */
1440
- function texturize( $content ) {
1441
-
1442
- $new_content = '';
1443
- $pattern_full = '{(\[wpmem_txt\].*?\[/wpmem_txt\])}is';
1444
- $pattern_contents = '{\[wpmem_txt\](.*?)\[/wpmem_txt\]}is';
1445
- $pieces = preg_split( $pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE );
1446
-
1447
- foreach ( $pieces as $piece ) {
1448
- if ( preg_match( $pattern_contents, $piece, $matches ) ) {
1449
- $new_content .= $matches[1];
1450
- } else {
1451
- $new_content .= wptexturize( wpautop( $piece ) );
1452
- }
1453
- }
1454
-
1455
- return $new_content;
1456
- }
1457
-
1458
- /**
1459
- * Loads the stylesheet for tableless forms.
1460
- *
1461
- * @since 2.6
1462
- * @since 3.2.3 Moved to WP_Members class.
1463
- *
1464
- * @global object $wpmem The WP_Members object.
1465
- */
1466
- function enqueue_style() {
1467
- global $wpmem;
1468
- wp_enqueue_style ( 'wp-members', wpmem_force_ssl( $wpmem->cssurl ), '', WPMEM_VERSION );
1469
- }
1470
-
1471
- /**
1472
- * Creates an excerpt on the fly if there is no 'more' tag.
1473
- *
1474
- * @since 2.6
1475
- * @since 3.2.3 Moved to WP_Members class.
1476
- *
1477
- * @global object $post The post object.
1478
- * @global object $wpmem The WP_Members object.
1479
- *
1480
- * @param string $content
1481
- * @return string $content
1482
- */
1483
- function do_excerpt( $content ) {
1484
-
1485
- global $post, $more, $wpmem;
1486
-
1487
- $autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
1488
-
1489
- // Is there already a 'more' link in the content?
1490
- $has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
1491
-
1492
- // If auto_ex is on.
1493
- if ( $autoex ) {
1494
-
1495
- // Build an excerpt if one does not exist.
1496
- if ( ! $has_more_link ) {
1497
-
1498
- $is_singular = ( is_singular( $post->post_type ) ) ? true : false;
1499
-
1500
- if ( $is_singular ) {
1501
- // If it's a single post, we don't need the 'more' link.
1502
- $more_link_text = '';
1503
- $more_link = '';
1504
- } else {
1505
- // The default $more_link_text.
1506
- if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
1507
- $more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
1508
- } else {
1509
- $more_link_text = __( '(more&hellip;)' );
1510
- }
1511
- // The default $more_link.
1512
- $more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
1513
- }
1514
-
1515
- // Apply the_content_more_link filter if one exists (will match up all 'more' link text).
1516
- /** This filter is documented in /wp-includes/post-template.php */
1517
- $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
1518
-
1519
- $defaults = array(
1520
- 'length' => $autoex['length'],
1521
- 'more_link' => $more_link,
1522
- 'blocked_only' => false,
1523
- );
1524
- /**
1525
- * Filter auto excerpt defaults.
1526
- *
1527
- * @since 3.0.9
1528
- * @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
1529
- *
1530
- * @param array {
1531
- * An array of settings to override the function defaults.
1532
- *
1533
- * @type int $length The default length of the excerpt.
1534
- * @type string $more_link The more link HTML.
1535
- * @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
1536
- * }
1537
- * @param string $post->ID The post ID.
1538
- * @param string $post->post_type The content's post type.
1539
- */
1540
- $args = apply_filters( 'wpmem_auto_excerpt_args', '', $post->ID, $post->post_type );
1541
-
1542
- // Merge settings.
1543
- $args = wp_parse_args( $args, $defaults );
1544
-
1545
- // Are we only excerpting blocked content?
1546
- if ( $args['blocked_only'] ) {
1547
- $post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
1548
- if ( 1 == $wpmem->block[ $post->post_type ] ) {
1549
- // Post type is blocked, if post meta unblocks it, don't do excerpt.
1550
- $do_excerpt = ( "0" == $post_meta ) ? false : true;
1551
- } else {
1552
- // Post type is unblocked, if post meta blocks it, do excerpt.
1553
- $do_excerpt = ( "1" == $post_meta ) ? true : false;
1554
- }
1555
- } else {
1556
- $do_excerpt = true;
1557
- }
1558
-
1559
- if ( $do_excerpt ) {
1560
- $content = wp_trim_words( $content, $args['length'], $args['more_link'] );
1561
- // Check if the more link was added (note: singular has no more_link):
1562
- if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
1563
- $content = $content . $args['more_link'];
1564
- }
1565
- }
1566
-
1567
- }
1568
- }
1569
-
1570
- /**
1571
- * Filter the auto excerpt.
1572
- *
1573
- * @since 2.8.1
1574
- * @since 3.0.9 Added post ID and post type parameters.
1575
- *
1576
- * @param string $content The content excerpt.
1577
- * @param string $post->ID The post ID.
1578
- * @param string $post->post_type The content's post type.
1579
- */
1580
- $content = apply_filters( 'wpmem_auto_excerpt', $content, $post->ID, $post->post_type );
1581
-
1582
- // Return the excerpt.
1583
- return $content;
1584
- }
1585
-
1586
- /**
1587
- * Convert form tag.
1588
- *
1589
- * @todo This is temporary to handle form tag conversion.
1590
- *
1591
- * @since 3.1.7
1592
- * @since 3.2.3 Moved to WP_Members class.
1593
- *
1594
- * @param string $tag
1595
- * @return string $tag
1596
- */
1597
- function convert_tag( $tag ) {
1598
- switch ( $tag ) {
1599
- case 'new':
1600
- return 'register';
1601
- break;
1602
- case 'edit':
1603
- case 'update':
1604
- return 'profile';
1605
- break;
1606
- case 'wp':
1607
- case 'wp_validate':
1608
- case 'wp_finalize':
1609
- return 'register_wp';
1610
- break;
1611
- case 'dashboard_profile':
1612
- case 'dashboard_profile_update':
1613
- return 'profile_dashboard';
1614
- break;
1615
- case 'admin_profile':
1616
- case 'admin_profile_update':
1617
- return 'profile_admin';
1618
- break;
1619
- default:
1620
- return $tag;
1621
- break;
1622
- }
1623
- return $tag;
1624
- }
1625
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1626
  } // End of WP_Members class.
1
+ <?php
2
+ /**
3
+ * The WP_Members Class.
4
+ *
5
+ * This is the main WP_Members object class. This class contains functions
6
+ * for loading settings, shortcodes, hooks to WP, plugin dropins, constants,
7
+ * and registration fields. It also manages whether content should be blocked.
8
+ *
9
+ * @package WP-Members
10
+ * @subpackage WP_Members Object Class
11
+ * @since 3.0.0
12
+ */
13
+
14
+ // Exit if accessed directly.
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit();
17
+ }
18
+
19
+ class WP_Members {
20
+
21
+ /**
22
+ * Plugin version.
23
+ *
24
+ * @since 3.0.0
25
+ * @access public
26
+ * @var string
27
+ */
28
+ public $version = WPMEM_VERSION;
29
+
30
+ /**
31
+ * Database version
32
+ *
33
+ * @since 3.2.2
34
+ * @access public
35
+ * @var string
36
+ */
37
+ public $db_version = WPMEM_DB_VERSION;
38
+
39
+ /**
40
+ * Content block settings.
41
+ *
42
+ * @since 3.0.0
43
+ * @access public
44
+ * @var array
45
+ */
46
+ public $block;
47
+
48
+ /**
49
+ * Excerpt settings.
50
+ *
51
+ * @since 3.0.0
52
+ * @access public
53
+ * @var array
54
+ */
55
+ public $show_excerpt;
56
+
57
+ /**
58
+ * Show login form settings.
59
+ *
60
+ * @since 3.0.0
61
+ * @access public
62
+ * @var array
63
+ */
64
+ public $show_login;
65
+
66
+ /**
67
+ * Show registration form settings.
68
+ *
69
+ * @since 3.0.0
70
+ * @access public
71
+ * @var array
72
+ */
73
+ public $show_reg;
74
+
75
+ /**
76
+ * Auto-excerpt settings.
77
+ *
78
+ * @since 3.0.0
79
+ * @access public
80
+ * @var array
81
+ */
82
+ public $autoex;
83
+
84
+ /**
85
+ * Notify admin settings.
86
+ *
87
+ * @since 3.0.0
88
+ * @access public
89
+ * @var string
90
+ */
91
+ public $notify;
92
+
93
+ /**
94
+ * Moderated registration settings.
95
+ *
96
+ * @since 3.0.0
97
+ * @access public
98
+ * @var string
99
+ */
100
+ public $mod_reg;
101
+
102
+ /**
103
+ * Captcha settings.
104
+ *
105
+ * @since 3.0.0
106
+ * @access public
107
+ * @var array
108
+ */
109
+ public $captcha;
110
+
111
+ /**
112
+ * Enable expiration extension settings.
113
+ *
114
+ * @since 3.0.0
115
+ * @access public
116
+ * @var string
117
+ */
118
+ public $use_exp;
119
+
120
+ /**
121
+ * Expiration extension enable trial period.
122
+ *
123
+ * @since 3.0.0
124
+ * @access public
125
+ * @var string
126
+ */
127
+ public $use_trial;
128
+
129
+ /**
130
+ *
131
+ *
132
+ * @since 3.0.0
133
+ * @access public
134
+ * @var array
135
+ */
136
+ public $warnings;
137
+
138
+ /**
139
+ * Enable drop-ins setting.
140
+ *
141
+ * @since 3.1.9
142
+ * @access public
143
+ * @var string
144
+ */
145
+ public $dropins = 0;
146
+
147
+ /**
148
+ * Container for enabled dropins.
149
+ *
150
+ * @since 3.1.9
151
+ * @access public
152
+ * @var array
153
+ */
154
+ public $dropins_enabled = array();
155
+
156
+ /**
157
+ * Current plugin action container.
158
+ *
159
+ * @since 3.0.0
160
+ * @access public
161
+ * @var string
162
+ */
163
+ public $action;
164
+
165
+ /**
166
+ * Regchk container.
167
+ *
168
+ * @since 3.0.0
169
+ * @access public
170
+ * @var string
171
+ */
172
+ public $regchk;
173
+
174
+ /**
175
+ * User page settings.
176
+ *
177
+ * @since 3.0.0
178
+ * @access public
179
+ * @var array
180
+ */
181
+ public $user_pages;
182
+
183
+ /**
184
+ * Custom Post Type settings.
185
+ *
186
+ * @since 3.0.0
187
+ * @access public
188
+ * @var array
189
+ */
190
+ public $post_types;
191
+
192
+ /**
193
+ * Setting for applying texturization.
194
+ *
195
+ * @since 3.1.7
196
+ * @access public
197
+ * @var boolean
198
+ */
199
+ public $texturize;
200
+
201
+ /**
202
+ * Enable product creation.
203
+ *
204
+ * @since 3.2.0
205
+ * @access public
206
+ * @var boolean
207
+ */
208
+ public $enable_products;
209
+
210
+ /**
211
+ * Enable logged-in menu clones.
212
+ *
213
+ * @since 3.2.0
214
+ * @access public
215
+ * @var string
216
+ */
217
+ public $clone_menus;
218
+
219
+ /**
220
+ * Container for error messages.
221
+ *
222
+ * @since 3.2.0
223
+ * @access public
224
+ * @var string
225
+ */
226
+ public $error;
227
+
228
+ /**
229
+ * Plugin initialization function.
230
+ *
231
+ * @since 3.0.0
232
+ * @since 3.1.6 Dependencies now loaded by object.
233
+ */
234
+ function __construct() {
235
+
236
+ // Load dependent files.
237
+ $this->load_dependencies();
238
+
239
+ /**
240
+ * Filter the options before they are loaded into constants.
241
+ *
242
+ * @since 2.9.0
243
+ * @since 3.0.0 Moved to the WP_Members class.
244
+ *
245
+ * @param array $this->settings An array of the WP-Members settings.
246
+ */
247
+ $settings = apply_filters( 'wpmem_settings', get_option( 'wpmembers_settings' ) );
248
+
249
+ // Validate that v3 settings are loaded.
250
+ if ( ! isset( $settings['version'] )
251
+ || $settings['version'] != $this->version
252
+ || ! isset( $settings['db_version'] )
253
+ || $settings['db_version'] != $this->db_version ) {
254
+ /**
255
+ * Load installation routine.
256
+ */
257
+ require_once( WPMEM_PATH . 'inc/install.php' );
258
+ // Update settings.
259
+ /** This filter is documented in /inc/class-wp-members.php */
260
+ $settings = apply_filters( 'wpmem_settings', wpmem_do_install() );
261
+ }
262
+
263
+ // Assemble settings.
264
+ foreach ( $settings as $key => $val ) {
265
+ $this->$key = $val;
266
+ }
267
+
268
+ $this->load_user_pages();
269
+ $this->cssurl = ( isset( $this->style ) && $this->style == 'use_custom' ) ? $this->cssurl : $this->style; // Set the stylesheet.
270
+ $this->forms = new WP_Members_Forms; // Load forms.
271
+ $this->api = new WP_Members_API; // Load api.
272
+ $this->user = new WP_Members_User( $this ); // Load user functions.
273
+ $this->shortcodes = new WP_Members_Shortcodes(); // Load shortcodes.
274
+ $this->membership = new WP_Members_Products(); // Load membership plans
275
+ $this->email = new WP_Members_Email; // Load email functions
276
+ $this->menus = ( $this->clone_menus ) ? new WP_Members_Menus() : null; // Load clone menus.
277
+
278
+ /**
279
+ * Fires after main settings are loaded.
280
+ *
281
+ * @since 3.0
282
+ * @deprecated 3.2.0 Use wpmem_after_init instead.
283
+ */
284
+ do_action( 'wpmem_settings_loaded' );
285
+
286
+ // Preload the expiration module, if available.
287
+ $exp_active = ( function_exists( 'wpmem_exp_init' ) || function_exists( 'wpmem_set_exp' ) ) ? true : false;
288
+ define( 'WPMEM_EXP_MODULE', $exp_active );
289
+
290
+ // Load actions and filters.
291
+ $this->load_hooks();
292
+
293
+ // Load contants.
294
+ $this->load_constants();
295
+
296
+ // Load dropins.
297
+ if ( $this->dropins ) {
298
+ $this->load_dropins();
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Plugin initialization function to load hooks.
304
+ *
305
+ * @since 3.0.0
306
+ */
307
+ function load_hooks() {
308
+
309
+ /**
310
+ * Fires before action and filter hooks load.
311
+ *
312
+ * @since 3.0.0
313
+ * @since 3.1.6 Fires before hooks load.
314
+ */
315
+ do_action( 'wpmem_load_hooks' );
316
+
317
+ // Add actions.
318
+ add_action( 'template_redirect', array( $this, 'get_action' ) );
319
+ add_action( 'widgets_init', array( $this, 'widget_init' ) ); // initializes the widget
320
+ add_action( 'admin_init', array( $this, 'load_admin' ) ); // check user role to load correct dashboard
321
+ add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
322
+ add_action( 'user_register', 'wpmem_wp_reg_finalize' ); // handles wp native registration
323
+ add_action( 'login_enqueue_scripts', 'wpmem_wplogin_stylesheet' ); // styles the native registration
324
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); // Enqueues the stylesheet.
325
+ add_action( 'wp_enqueue_scripts', array( $this, 'loginout_script' ) );
326
+ add_action( 'init', array( $this, 'load_textdomain' ) ); //add_action( 'plugins_loaded', 'wpmem_load_textdomain' );
327
+ add_action( 'init', array( $this->membership, 'add_cpt' ), 0 ); // Adds membership plans custom post type.
328
+ add_action( 'wpmem_pwd_change', array( $this->user, 'set_password' ), 9, 2 );
329
+ add_action( 'wpmem_pwd_change', array( $this->user, 'set_as_logged_in' ), 10 );
330
+ add_action( 'pre_get_posts', array( $this, 'do_hide_posts' ) );
331
+ add_action( 'customize_register', array( $this, 'customizer_settings' ) );
332
+
333
+ // Add filters.
334
+ add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
335
+ add_filter( 'allow_password_reset', array( $this->user, 'no_reset' ) ); // no password reset for non-activated users
336
+ add_filter( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
337
+ add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
338
+ add_filter( 'registration_errors', 'wpmem_wp_reg_validate', 10, 3 ); // native registration validation
339
+ add_filter( 'comments_open', array( $this, 'do_securify_comments' ), 99 ); // securifies the comments
340
+ add_filter( 'wpmem_securify', array( $this, 'reg_securify' ) ); // adds success message on login form if redirected
341
+ //add_filter( 'query_vars', array( $this, 'add_query_vars' ), 10, 2 ); // adds custom query vars
342
+ add_filter( 'get_pages', array( $this, 'filter_get_pages' ) );
343
+ add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_nav_menu_items' ), null, 3 );
344
+ add_filter( 'get_previous_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
345
+ add_filter( 'get_next_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
346
+
347
+ // If registration is moderated, check for activation (blocks backend login by non-activated users).
348
+ if ( $this->mod_reg == 1 ) {
349
+ add_filter( 'authenticate', array( $this->user, 'check_activated' ), 99, 3 );
350
+ }
351
+
352
+ /**
353
+ * Fires after action and filter hooks load.
354
+ *
355
+ * @since 3.0.0
356
+ * @since 3.1.6 Was wpmem_load_hooks, now wpmem_hooks_loaded.
357
+ */
358
+ do_action( 'wpmem_hooks_loaded' );
359
+ }
360
+
361
+ /**
362
+ * Load drop-ins.
363
+ *
364
+ * @since 3.0.0
365
+ *
366
+ * @todo This is experimental. The function and its operation is subject to change.
367
+ */
368
+ function load_dropins() {
369
+
370
+ /**
371
+ * Fires before dropins load (for adding additional drop-ins).
372
+ *
373
+ * @since 3.0.0
374
+ * @since 3.1.6 Fires before dropins.
375
+ */
376
+ do_action( 'wpmem_load_dropins' );
377
+
378
+ /**
379
+ * Filters the drop-in file folder.
380
+ *
381
+ * @since 3.0.0
382
+ *
383
+ * @param string $folder The drop-in file folder.
384
+ */
385
+ $folder = apply_filters( 'wpmem_dropin_folder', WPMEM_DROPIN_DIR );
386
+
387
+ // Load any drop-ins.
388
+ $settings = get_option( 'wpmembers_dropins' );
389
+ $this->dropins_enabled = ( $settings ) ? $settings : array();
390
+ if ( ! empty( $this->dropins_enabled ) ) {
391
+ foreach ( $this->dropins_enabled as $filename ) {
392
+ $dropin = $folder . $filename;
393
+ if ( file_exists( $dropin ) ) {
394
+ include_once( $dropin );
395
+ }
396
+ }
397
+ }
398
+
399
+ /**
400
+ * Fires before dropins load (for adding additional drop-ins).
401
+ *
402
+ * @since 3.0.0
403
+ * @since 3.1.6 Was wpmem_load_dropins, now wpmem_dropins_loaded.
404
+ */
405
+ do_action( 'wpmem_dropins_loaded' );
406
+ }
407
+
408
+ /**
409
+ * Loads pre-3.0 constants (included primarily for add-on compatibility).
410
+ *
411
+ * @since 3.0.0
412
+ */
413
+ function load_constants() {
414
+ ( ! defined( 'WPMEM_BLOCK_POSTS' ) ) ? define( 'WPMEM_BLOCK_POSTS', $this->block['post'] ) : ''; // @todo Can deprecate? Probably 3.3
415
+ ( ! defined( 'WPMEM_BLOCK_PAGES' ) ) ? define( 'WPMEM_BLOCK_PAGES', $this->block['page'] ) : ''; // @todo Can deprecate? Probably 3.3
416
+ ( ! defined( 'WPMEM_SHOW_EXCERPT' ) ) ? define( 'WPMEM_SHOW_EXCERPT', $this->show_excerpt['post'] ) : ''; // @todo Can deprecate? Probably 3.3
417
+ ( ! defined( 'WPMEM_NOTIFY_ADMIN' ) ) ? define( 'WPMEM_NOTIFY_ADMIN', $this->notify ) : ''; // @todo Can deprecate? Probably 3.3
418
+ ( ! defined( 'WPMEM_MOD_REG' ) ) ? define( 'WPMEM_MOD_REG', $this->mod_reg ) : ''; // @todo Can deprecate? Probably 3.3
419
+ ( ! defined( 'WPMEM_CAPTCHA' ) ) ? define( 'WPMEM_CAPTCHA', $this->captcha ) : ''; // @todo Can deprecate? Probably 3.3
420
+ ( ! defined( 'WPMEM_NO_REG' ) ) ? define( 'WPMEM_NO_REG', ( -1 * $this->show_reg['post'] ) ) : ''; // @todo Can deprecate? Probably 3.3
421
+ ( ! defined( 'WPMEM_USE_EXP' ) ) ? define( 'WPMEM_USE_EXP', $this->use_exp ) : '';
422
+ ( ! defined( 'WPMEM_USE_TRL' ) ) ? define( 'WPMEM_USE_TRL', $this->use_trial ) : '';
423
+ ( ! defined( 'WPMEM_IGNORE_WARN' ) ) ? define( 'WPMEM_IGNORE_WARN', $this->warnings ) : ''; // @todo Can deprecate? Probably 3.3
424
+
425
+ ( ! defined( 'WPMEM_MSURL' ) ) ? define( 'WPMEM_MSURL', $this->user_pages['profile'] ) : ''; // @todo Can deprecate? Probably 3.3
426
+ ( ! defined( 'WPMEM_REGURL' ) ) ? define( 'WPMEM_REGURL', $this->user_pages['register'] ) : ''; // @todo Can deprecate? Probably 3.3
427
+ ( ! defined( 'WPMEM_LOGURL' ) ) ? define( 'WPMEM_LOGURL', $this->user_pages['login'] ) : ''; // @todo Can deprecate? Probably 3.3
428
+
429
+ ( ! defined( 'WPMEM_DROPIN_DIR' ) ) ? define( 'WPMEM_DROPIN_DIR', WP_PLUGIN_DIR . '/wp-members-dropins/' ) : '';
430
+
431
+ define( 'WPMEM_CSSURL', $this->cssurl );
432
+ }
433
+
434
+ /**
435
+ * Load dependent files.
436
+ *
437
+ * @since 3.1.6
438
+ */
439
+ function load_dependencies() {
440
+
441
+ /**
442
+ * Filter the location and name of the pluggable file.
443
+ *
444
+ * @since 2.9.0
445
+ * @since 3.1.6 Moved in load order to come before dependencies.
446
+ *
447
+ * @param string The path to WP-Members plugin functions file.
448
+ */
449
+ $wpmem_pluggable = apply_filters( 'wpmem_plugins_file', WP_PLUGIN_DIR . '/wp-members-pluggable.php' );
450
+
451
+ // Preload any custom functions, if available.
452
+ if ( file_exists( $wpmem_pluggable ) ) {
453
+ include( $wpmem_pluggable );
454
+ }
455
+
456
+ require_once( WPMEM_PATH . 'inc/class-wp-members-api.php' );
457
+ require_once( WPMEM_PATH . 'inc/class-wp-members-email.php' );
458
+ require_once( WPMEM_PATH . 'inc/class-wp-members-forms.php' );
459
+ require_once( WPMEM_PATH . 'inc/class-wp-members-menus.php' );
460
+ require_once( WPMEM_PATH . 'inc/class-wp-members-products.php' );
461
+ require_once( WPMEM_PATH . 'inc/class-wp-members-shortcodes.php' );
462
+ require_once( WPMEM_PATH . 'inc/class-wp-members-user.php' );
463
+ require_once( WPMEM_PATH . 'inc/class-wp-members-user-profile.php' );
464
+ require_once( WPMEM_PATH . 'inc/class-wp-members-widget.php' );
465
+ require_once( WPMEM_PATH . 'inc/api.php' );
466
+ require_once( WPMEM_PATH . 'inc/api-email.php' );
467
+ require_once( WPMEM_PATH . 'inc/api-forms.php' );
468
+ require_once( WPMEM_PATH . 'inc/api-users.php' );
469
+ require_once( WPMEM_PATH . 'inc/api-utilities.php' );
470
+ require_once( WPMEM_PATH . 'inc/forms.php' );
471
+ require_once( WPMEM_PATH . 'inc/dialogs.php' );
472
+ require_once( WPMEM_PATH . 'inc/wp-registration.php' );
473
+ require_once( WPMEM_PATH . 'inc/deprecated.php' );
474
+ //require_once( WPMEM_PATH . 'inc/core.php' ); // @deprectated 3.2.4
475
+ //require_once( WPMEM_PATH . 'inc/utilities.php' ); // @deprecated 3.2.3
476
+ //require_once( WPMEM_PATH . 'inc/sidebar.php' ); // @deprecated 3.2.0
477
+ //require_once( WPMEM_PATH . 'inc/shortcodes.php' ); // @deprecated 3.2.0
478
+ //require_once( WPMEM_PATH . 'inc/email.php' ); // @deprecated 3.2.0
479
+ //require_once( WPMEM_PATH . 'inc/users.php' ); // @deprecated 3.1.9
480
+
481
+ }
482
+
483
+ /**
484
+ * Load admin API and dependencies.
485
+ *
486
+ * Determines which scripts to load and actions to use based on the
487
+ * current users capabilities.
488
+ *
489
+ * @since 2.5.2
490
+ * @since 3.1.0 Added admin api object.
491
+ * @since 3.1.7 Moved from main plugin file as wpmem_chk_admin() to main object.
492
+ */
493
+ function load_admin() {
494
+
495
+ /**
496
+ * Fires before initialization of admin options.
497
+ *
498
+ * @since 2.9.0
499
+ */
500
+ do_action( 'wpmem_pre_admin_init' );
501
+
502
+ // Initilize the admin api.
503
+ $this->load_admin_api();
504
+
505
+ /**
506
+ * Fires after initialization of admin options.
507
+ *
508
+ * @since 2.9.0
509
+ */
510
+ do_action( 'wpmem_after_admin_init' );
511
+ }
512
+
513
+ /**
514
+ * Gets the requested action.
515
+ *
516
+ * @since 3.0.0
517
+ *
518
+ * @global string $wpmem_a The WP-Members action variable.
519
+ */
520
+ function get_action() {
521
+
522
+ // Get the action being done (if any).
523
+ $this->action = sanitize_text_field( wpmem_get( 'a', '', 'request' ) );
524
+
525
+ // For backward compatibility with processes that check $wpmem_a.
526
+ global $wpmem_a;
527
+ $wpmem_a = $this->action;
528
+
529
+ /**
530
+ * Fires when the wpmem action is retrieved.
531
+ *
532
+ * @since 3.1.7
533
+ */
534
+ do_action( 'wpmem_get_action' );
535
+
536
+ // Get the regchk value (if any).
537
+ $this->regchk = $this->get_regchk( $this->action );
538
+ }
539
+
540
+ /**
541
+ * Gets the regchk value.
542
+ *
543
+ * regchk is a legacy variable that contains information about the current
544
+ * action being performed. Login, logout, password, registration, profile
545
+ * update functions all return a specific value that is stored in regchk.
546
+ * This value and information about the current action can then be used to
547
+ * determine what content is to be displayed by the securify function.
548
+ *
549
+ * @since 3.0.0
550
+ *
551
+ * @global string $wpmem_a The WP-Members action variable.
552
+ *
553
+ * @param string $action The current action.
554
+ * @return string The regchk value.
555
+ */
556
+ function get_regchk( $action ) {
557
+
558
+ switch ( $action ) {
559
+
560
+ case 'login':
561
+ $regchk = $this->user->login();
562
+ break;
563
+
564
+ case 'logout':
565
+ $regchk = $this->user->logout();
566
+ break;
567
+
568
+ case 'pwdchange':
569
+ $regchk = $this->user->password_update( 'change' );
570
+ break;
571
+
572
+ case 'pwdreset':
573
+ $regchk = $this->user->password_update( 'reset' );
574
+ break;
575
+
576
+ case 'getusername':
577
+ $regchk = $this->user->retrieve_username();
578
+ break;
579
+
580
+ case 'register':
581
+ case 'update':
582
+ require_once( WPMEM_PATH . 'inc/register.php' );
583
+ $regchk = wpmem_registration( $action );
584
+ break;
585
+
586
+ default:
587
+ $regchk = ( isset( $regchk ) ) ? $regchk : '';
588
+ break;
589
+ }
590
+
591
+ /**
592
+ * Filter wpmem_regchk.
593
+ *
594
+ * The value of regchk is determined by functions that may be run in the get_regchk function.
595
+ * This value determines what happens in the wpmem_securify() function.
596
+ *
597
+ * @since 2.9.0
598
+ * @since 3.0.0 Moved to get_regchk() in WP_Members object.
599
+ *
600
+ * @param string $this->regchk The value of wpmem_regchk.
601
+ * @param string $this->action The $wpmem_a action.
602
+ */
603
+ $regchk = apply_filters( 'wpmem_regchk', $regchk, $action );
604
+
605
+ // Legacy global variable for use with older extensions.
606
+ global $wpmem_regchk;
607
+ $wpmem_regchk = $regchk;
608
+
609
+ return $regchk;
610
+ }
611
+
612
+ /**
613
+ * Determines if content should be blocked.
614
+ *
615
+ * This function was originally stand alone in the core file and
616
+ * was moved to the WP_Members class in 3.0.
617
+ *
618
+ * @since 3.0.0
619
+ *
620
+ * @global object $post The WordPress Post object.
621
+ * @return bool $block true|false
622
+ */
623
+ function is_blocked() {
624
+
625
+ global $post;
626
+
627
+ if ( $post ) {
628
+
629
+ // Backward compatibility for old block/unblock meta.
630
+ $meta = get_post_meta( $post->ID, '_wpmem_block', true );
631
+ if ( ! $meta ) {
632
+ // Check for old meta.
633
+ $old_block = get_post_meta( $post->ID, 'block', true );
634
+ $old_unblock = get_post_meta( $post->ID, 'unblock', true );
635
+ $meta = ( $old_block ) ? 1 : ( ( $old_unblock ) ? 0 : $meta );
636
+ }
637
+
638
+ // Setup defaults.
639
+ $defaults = array(
640
+ 'post_id' => $post->ID,
641
+ 'post_type' => $post->post_type,
642
+ 'block' => ( isset( $this->block[ $post->post_type ] ) && $this->block[ $post->post_type ] == 1 ) ? true : false,
643
+ 'block_meta' => $meta, // @todo get_post_meta( $post->ID, '_wpmem_block', true ),
644
+ 'block_type' => ( isset( $this->block[ $post->post_type ] ) ) ? $this->block[ $post->post_type ] : 0,
645
+ );
646
+
647
+ /**
648
+ * Filter the block arguments.
649
+ *
650
+ * @since 2.9.8
651
+ * @since 3.0.0 Moved to is_blocked() in WP_Members object.
652
+ *
653
+ * @param array $args Null.
654
+ * @param array $defaults Although you are not filtering the defaults, knowing what they are can assist developing more powerful functions.
655
+ */
656
+ $args = apply_filters( 'wpmem_block_args', '', $defaults );
657
+
658
+ // Merge $args with defaults.
659
+ $args = ( wp_parse_args( $args, $defaults ) );
660
+
661
+ if ( is_single() || is_page() ) {
662
+ switch( $args['block_type'] ) {
663
+ case 1: // If content is blocked by default.
664
+ $args['block'] = ( $args['block_meta'] == '0' ) ? false : $args['block'];
665
+ break;
666
+ case 0 : // If content is unblocked by default.
667
+ $args['block'] = ( $args['block_meta'] == '1' ) ? true : $args['block'];
668
+ break;
669
+ }
670
+
671
+ } else {
672
+ $args['block'] = false;
673
+ }
674
+
675
+ } else {
676
+ $args = array( 'block' => false );
677
+ }
678
+
679
+ // Don't block user pages.
680
+ $args['block'] = ( in_array( get_permalink(), $this->user_pages ) ) ? false : $args['block'];
681
+
682
+ /**
683
+ * Filter the block boolean.
684
+ *
685
+ * @since 2.7.5
686
+ *
687
+ * @param bool $args['block']
688
+ * @param array $args
689
+ */
690
+ return apply_filters( 'wpmem_block', $args['block'], $args );
691
+ }
692
+
693
+ /**
694
+ * The Securify Content Filter.
695
+ *
696
+ * This is the primary function that picks up where get_action() leaves off.
697
+ * Determines whether content is shown or hidden for both post and pages. This
698
+ * is a filter function for the_content.
699
+ *
700
+ * @link https://developer.wordpress.org/reference/functions/the_content/
701
+ * @link https://developer.wordpress.org/reference/hooks/the_content/
702
+ *
703
+ * @since 3.0.0
704
+ *
705
+ * @global object $post The WordPress Post object.
706
+ * @global object $wpmem The WP_Members object.
707
+ * @global string $wpmem_themsg Contains messages to be output.
708
+ * @param string $content
709
+ * @return string $content
710
+ */
711
+ function do_securify( $content = null ) {
712
+
713
+ global $post, $wpmem, $wpmem_themsg;
714
+
715
+ $content = ( is_single() || is_page() ) ? $content : wpmem_do_excerpt( $content );
716
+
717
+ if ( ( ! has_shortcode( $content, 'wp-members' ) ) ) {
718
+
719
+ if ( $this->regchk == "captcha" ) {
720
+ global $wpmem_captcha_err;
721
+ $wpmem_themsg = $wpmem->get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
722
+ }
723
+
724
+ // Block/unblock Posts.
725
+ if ( ! is_user_logged_in() && $this->is_blocked() == true ) {
726
+
727
+ //Show the login and registration forms.
728
+ if ( $this->regchk ) {
729
+
730
+ // Empty content in any of these scenarios.
731
+ $content = '';
732
+
733
+ switch ( $this->regchk ) {
734
+
735
+ case "loginfailed":
736
+ $content = wpmem_inc_loginfailed();
737
+ break;
738
+
739
+ case "success":
740
+ $content = wpmem_inc_regmessage( $this->regchk, $wpmem_themsg );
741
+ $content = $content . wpmem_inc_login();
742
+ break;
743
+
744
+ default:
745
+ $content = wpmem_inc_regmessage( $this->regchk, $wpmem_themsg );
746
+ $content = $content . wpmem_inc_registration();
747
+ break;
748
+ }
749
+
750
+ } else {
751
+
752
+ // Toggle shows excerpt above login/reg on posts/pages.
753
+ global $wp_query;
754
+ if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
755
+
756
+ // Shuts down excerpts on multipage posts if not on first page.
757
+ $content = '';
758
+
759
+ } elseif ( isset( $this->show_excerpt[ $post->post_type ] ) && $this->show_excerpt[ $post->post_type ] == 1 ) {
760
+
761
+ if ( ! stristr( $content, '<span id="more' ) ) {
762
+ $content = wpmem_do_excerpt( $content );
763
+ } else {
764
+ $len = strpos( $content, '<span id="more' );
765
+ $content = substr( $content, 0, $len );
766
+ }
767
+
768
+ } else {
769
+
770
+ // Empty all content.
771
+ $content = '';
772
+
773
+ }
774
+
775
+ $content = ( isset( $this->show_login[ $post->post_type ] ) && $this->show_login[ $post->post_type ] == 1 ) ? $content . wpmem_inc_login() : $content . wpmem_inc_login( 'page', '', 'hide' );
776
+
777
+ $content = ( isset( $this->show_reg[ $post->post_type ] ) && $this->show_reg[ $post->post_type ] == 1 ) ? $content . wpmem_inc_registration() : $content;
778
+ }
779
+
780
+ // Protects comments if expiration module is used and user is expired.
781
+ } elseif ( is_user_logged_in() && $this->is_blocked() == true ){
782
+
783
+ if ( $this->use_exp == 1 && function_exists( 'wpmem_do_expmessage' ) ) {
784
+ /**
785
+ * Filters the user expired message used by the PayPal extension.
786
+ *
787
+ * @since 3.2.0
788
+ *
789
+ * @param string $message
790
+ * @param string $content
791
+ */
792
+ $content = apply_filters( 'wpmem_do_expmessage', wpmem_do_expmessage( $content ), $content );
793
+ }
794
+ }
795
+ }
796
+
797
+ /**
798
+ * Filter the value of $content after wpmem_securify has run.
799
+ *
800
+ * @since 2.7.7
801
+ * @since 3.0.0 Moved to new method in WP_Members Class.
802
+ *
803
+ * @param string $content The content after securify has run.
804
+ */
805
+ $content = apply_filters( 'wpmem_securify', $content );
806
+
807
+ if ( 1 == $this->texturize && strstr( $content, '[wpmem_txt]' ) ) {
808
+ // Fix the wptexturize.
809
+ remove_filter( 'the_content', 'wpautop' );
810
+ remove_filter( 'the_content', 'wptexturize' );
811
+ add_filter( 'the_content', array( $this, 'texturize' ), 999 );
812
+ }
813
+
814
+ return $content;
815
+
816
+ }
817
+
818
+ /**
819
+ * Securifies the comments.
820
+ *
821
+ * If the user is not logged in and the content is blocked
822
+ * (i.e. wpmem->is_blocked() returns true), function loads a
823
+ * dummy/empty comments template.
824
+ *
825
+ * @since 2.9.9
826
+ * @since 3.2.0 Moved wpmem_securify_comments() to main class, renamed.
827
+ *
828
+ * @return bool $open true if current post is open for comments, otherwise false.
829
+ */
830
+ function do_securify_comments( $open ) {
831
+
832
+ $open = ( ! is_user_logged_in() && wpmem_is_blocked() ) ? false : $open;
833
+
834
+ /**
835
+ * Filters whether comments are open or not.
836
+ *
837
+ * @since 3.0.0
838
+ * @since 3.2.0 Moved to main class.
839
+ *
840
+ * @param bool $open true if current post is open for comments, otherwise false.
841
+ */
842
+ $open = apply_filters( 'wpmem_securify_comments', $open );
843
+
844
+ if ( ! $open ) {
845
+ /** This filter is documented in wp-includes/comment-template.php */
846
+ add_filter( 'comments_array', array( $this, 'do_securify_comments_array' ), 10, 2 );
847
+ }
848
+
849
+ return $open;
850
+ }
851
+
852
+ /**
853
+ * Empties the comments array if content is blocked.
854
+ *
855
+ * @since 3.0.1
856
+ * @since 3.2.0 Moved wpmem_securify_comments_array() to main class, renamed.
857
+ *
858
+ * @global object $wpmem The WP-Members object class.
859
+ *
860
+ * @return array $comments The comments array.
861
+ */
862
+ function do_securify_comments_array( $comments , $post_id ) {
863
+ $comments = ( ! is_user_logged_in() && wpmem_is_blocked() ) ? array() : $comments;
864
+ return $comments;
865
+ }
866
+
867
+ /**
868
+ * Adds the successful registration message on the login page if reg_nonce validates.
869
+ *
870
+ * @since 3.1.7
871
+ * @since 3.2.0 Moved to wpmem object, renamed reg_securify()
872
+ *
873
+ * @param string $content
874
+ * @return string $content
875
+ */
876
+ function reg_securify( $content ) {
877
+ global $wpmem, $wpmem_themsg;
878
+ $nonce = wpmem_get( 'reg_nonce', false, 'get' );
879
+ if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
880
+ $content = wpmem_inc_regmessage( 'success', $wpmem_themsg );
881
+ $content = $content . wpmem_inc_login();
882
+ }
883
+ return $content;
884
+ }
885
+
886
+ /**
887
+ * Gets an array of hidden post IDs.
888
+ *
889
+ * @since 3.2.0
890
+ *
891
+ * @global object $wpdb
892
+ * @return array $hidden
893
+ */
894
+ function hidden_posts() {
895
+ global $wpdb;
896
+ $hidden = get_transient( '_wpmem_hidden_posts' );
897
+ if ( false === $hidden ) {
898
+ $hidden = $this->update_hidden_posts();
899
+ }
900
+ return $hidden;
901
+ }
902
+
903
+ /**
904
+ * Updates the hidden post array transient.
905
+ *
906
+ * @since 3.2.0
907
+ *
908
+ * @global object $wpdb
909
+ * @return array $hidden
910
+ */
911
+ function update_hidden_posts() {
912
+ global $wpdb;
913
+ $hidden = array();
914
+ $results = $wpdb->get_results( "SELECT post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_wpmem_block' AND meta_value = 2" );
915
+ foreach( $results as $result ) {
916
+ $hidden[] = $result->post_id;
917
+ }
918
+ set_transient( '_wpmem_hidden_posts', $hidden, 60*5 );
919
+ return $hidden;
920
+ }
921
+
922
+ /**
923
+ * Gets an array of hidden post IDs.
924
+ *
925
+ * @since 3.2.0
926
+ *
927
+ * @return array $hidden
928
+ */
929
+ function get_hidden_posts() {
930
+ $hidden = array();
931
+ if ( ! is_admin() && ( ! is_user_logged_in() ) ) {
932
+ $hidden = $this->hidden_posts();
933
+ }
934
+ // @todo Possibly separate query here to check. If the user IS logged in, check what posts they DON'T have access to.
935
+ if ( ! is_admin() && is_user_logged_in() && 1 == $this->enable_products ) {
936
+ // Get user product access.
937
+ // @todo This maybe should be a transient stored in the user object.
938
+ $hidden = $this->hidden_posts();
939
+ $hidden = ( is_array( $hidden ) ) ? $hidden : array();
940
+ foreach ( $this->membership->products as $key => $value ) {
941
+ if ( isset( $this->user->access[ $key ] ) && ( true === $this->user->access[ $key ] || $this->user->is_current( $this->user->access[ $key ] ) ) ) {
942
+ foreach ( $hidden as $post_id ) {
943
+ if ( 1 == get_post_meta( $post_id, $this->membership->post_stem . $key, true ) ) {
944
+ $hidden_key = array_search( $post_id, $hidden );
945
+ unset( $hidden[ $hidden_key ] );
946
+ }
947
+ }
948
+ }
949
+ }
950
+ }
951
+ return $hidden;
952
+ }
953
+
954
+ /**
955
+ * Hides posts based on settings and meta.
956
+ *
957
+ * @since 3.2.0
958
+ *
959
+ * @param array $query
960
+ * @return array $query
961
+ */
962
+ function do_hide_posts( $query ) {
963
+ $hidden_posts = $this->get_hidden_posts();
964
+ if ( ! empty( $hidden_posts ) ) {
965
+ $query->set( 'post__not_in', $hidden_posts );
966
+ }
967
+ return $query;
968
+ }
969
+
970
+ /**
971
+ * Filter to hide pages for get_pages().
972
+ *
973
+ * @since 3.2.0
974
+ *
975
+ * @global object $wpdb
976
+ * @param array $pages
977
+ * @return array $pages
978
+ */
979
+ function filter_get_pages( $pages ) {
980
+ $hidden_posts = $this->get_hidden_posts();
981
+ if ( ! empty ( $hidden_posts ) ) {
982
+ $new_pages = array();
983
+ foreach ( $pages as $key => $page ) {
984
+ if ( ! in_array( $page->ID, $hidden_posts ) ) {
985
+ $new_pages[ $key ] = $page;
986
+ }
987
+ }
988
+ $pages = $new_pages;
989
+ }
990
+ return $pages;
991
+ }
992
+
993
+ /**
994
+ * Filter to hide menu items.
995
+ *
996
+ * @since 3.2.0
997
+ *
998
+ * @param array $items
999
+ * @param $menu
1000
+ * @param array $args
1001
+ * @return array $items
1002
+ */
1003
+ function filter_nav_menu_items( $items, $menu, $args ) {
1004
+ $hidden_posts = $this->get_hidden_posts();
1005
+ if ( ! empty( $hidden_posts ) ) {
1006
+ foreach ( $items as $key => $item ) {
1007
+ if ( in_array( $item->object_id, $hidden_posts ) ) {
1008
+ unset( $items[ $key ] );
1009
+ }
1010
+ }
1011
+ }
1012
+ return $items;
1013
+ }
1014
+
1015
+ /**
1016
+ * Filter to remove hidden posts from prev/next links.
1017
+ *
1018
+ * @since 3.2.4
1019
+ *
1020
+ * @global object $wpmem
1021
+ * @param string $where
1022
+ * @return string $where
1023
+ */
1024
+ function filter_get_adjacent_post_where( $where ) {
1025
+ global $wpmem;
1026
+ $hidden_posts = $this->get_hidden_posts();
1027
+ if ( ! empty( $hidden_posts ) ) {
1028
+ $hidden = implode( ",", $hidden_posts );
1029
+ $where = $where . " AND p.ID NOT IN ( $hidden )";
1030
+ }
1031
+ return $where;
1032
+ }
1033
+
1034
+ /**
1035
+ * Sets the registration fields.
1036
+ *
1037
+ * @since 3.0.0
1038
+ * @since 3.1.5 Added $form argument.
1039
+ *
1040
+ * @param string $form The form being generated.
1041
+ */
1042
+ function load_fields( $form = 'default' ) {
1043
+
1044
+ // Get stored fields settings.
1045
+ $fields = get_option( 'wpmembers_fields' );
1046
+
1047
+ // Validate fields settings.
1048
+ if ( ! isset( $fields ) || empty( $fields ) ) {
1049
+ // Update settings.
1050
+ $fields = array( array( 10, 'Email', 'user_email', 'email', 'y', 'y', 'y' ) );
1051
+ }
1052
+
1053
+ // Add new field array keys
1054
+ foreach ( $fields as $key => $val ) {
1055
+
1056
+ // Key fields with meta key.
1057
+ $meta_key = $val[2];
1058
+
1059
+ // Old format, new key.
1060
+ foreach ( $val as $subkey => $subval ) {
1061
+ $this->fields[ $meta_key ][ $subkey ] = $subval;
1062
+ }
1063
+
1064
+ // Setup field properties.
1065
+ $this->fields[ $meta_key ]['label'] = $val[1];
1066
+ $this->fields[ $meta_key ]['type'] = $val[3];
1067
+ $this->fields[ $meta_key ]['register'] = ( 'y' == $val[4] ) ? true : false;
1068
+ $this->fields[ $meta_key ]['required'] = ( 'y' == $val[5] ) ? true : false;
1069
+ $this->fields[ $meta_key ]['profile'] = '';
1070
+ $this->fields[ $meta_key ]['native'] = ( 'y' == $val[6] ) ? true : false;
1071
+
1072
+ // Certain field types have additional properties.
1073
+ switch ( $val[3] ) {
1074
+
1075
+ case 'checkbox':
1076
+ $this->fields[ $meta_key ]['checked_value'] = $val[7];
1077
+ $this->fields[ $meta_key ]['checked_default'] = ( 'y' == $val[8] ) ? true : false;
1078
+ break;
1079
+
1080
+ case 'select':
1081
+ case 'multiselect':
1082
+ case 'multicheckbox':
1083
+ case 'radio':
1084
+ // Correct a malformed value (if last value is empty due to a trailing comma).
1085
+ if ( '' == end( $val[7] ) ) {
1086
+ array_pop( $val[7] );
1087
+ $this->fields[ $meta_key ][7] = $val[7];
1088
+ }
1089
+ $this->fields[ $meta_key ]['values'] = $val[7];
1090
+ $this->fields[ $meta_key ]['delimiter'] = ( isset( $val[8] ) ) ? $val[8] : '|';
1091
+ $this->fields[ $meta_key ]['options'] = array();
1092
+ foreach ( $val[7] as $value ) {
1093
+ $pieces = explode( '|', trim( $value ) );
1094
+ if ( isset( $pieces[1] ) && $pieces[1] != '' ) {
1095
+ $this->fields[ $meta_key ]['options'][ $pieces[1] ] = $pieces[0];
1096
+ }
1097
+ }
1098
+ break;
1099
+
1100
+ case 'file':
1101
+ case 'image':
1102
+ $this->fields[ $meta_key ]['file_types'] = $val[7];
1103
+ break;
1104
+
1105
+ case 'hidden':
1106
+ $this->fields[ $meta_key ]['value'] = $val[7];
1107
+ break;
1108
+
1109
+ }
1110
+ }
1111
+ }
1112
+
1113
+ /**
1114
+ * Get excluded meta fields.
1115
+ *
1116
+ * @since 3.0.0
1117
+ *
1118
+ * @param string $tag A tag so we know where the function is being used.
1119
+ * @return array The excluded fields.
1120
+ */
1121
+ function excluded_fields( $tag ) {
1122
+
1123
+ // Default excluded fields.
1124
+ $excluded_fields = array( 'password', 'confirm_password', 'confirm_email', 'password_confirm', 'email_confirm' );
1125
+
1126
+ if ( 'update' == $tag || 'admin-profile' == $tag || 'user-profile' == $tag || 'wp-register' == $tag ) {
1127
+ $excluded_fields[] = 'username';
1128
+ }
1129
+
1130
+ if ( 'admin-profile' == $tag || 'user-profile' == $tag ) {
1131
+ array_push( $excluded_fields, 'first_name', 'last_name', 'nickname', 'display_name', 'user_email', 'description', 'user_url' );
1132
+ }
1133
+
1134
+ /**
1135
+ * Filter the fields to be excluded when user is created/updated.
1136
+ *
1137
+ * @since 2.9.3
1138
+ * @since 3.0.0 Moved to new method in WP_Members Class.
1139
+ *
1140
+ * @param array An array of the field meta names to exclude.
1141
+ * @param string $tag A tag so we know where the function is being used.
1142
+ */
1143
+ $excluded_fields = apply_filters( 'wpmem_exclude_fields', $excluded_fields, $tag );
1144
+
1145
+ // Return excluded fields.
1146
+ return $excluded_fields;
1147
+ }
1148
+
1149
+ /**
1150
+ * Set page locations.
1151
+ *
1152
+ * Handles numeric page IDs while maintaining
1153
+ * compatibility with old full url settings.
1154
+ *
1155
+ * @since 3.0.8
1156
+ */
1157
+ function load_user_pages() {
1158
+ foreach ( $this->user_pages as $key => $val ) {
1159
+ if ( is_numeric( $val ) ) {
1160
+ $this->user_pages[ $key ] = get_page_link( $val );
1161
+ }
1162
+ }
1163
+ }
1164
+
1165
+ /**
1166
+ * Returns a requested text string.
1167
+ *
1168
+ * This function manages all of the front-end facing text.
1169
+ * All defaults can be filtered using wpmem_default_text_strings.
1170
+ *
1171
+ * @since 3.1.0
1172
+ *
1173
+ * @param string $str
1174
+ * @return string $text
1175
+ */
1176
+ function get_text( $str ) {
1177
+
1178
+ // Default Form Fields.
1179
+ $default_form_fields = array(
1180
+ 'first_name' => __( 'First Name', 'wp-members' ),
1181
+ 'last_name' => __( 'Last Name', 'wp-members' ),
1182
+ 'addr1' => __( 'Address 1', 'wp-members' ),
1183
+ 'addr2' => __( 'Address 2', 'wp-members' ),
1184
+ 'city' => __( 'City', 'wp-members' ),
1185
+ 'thestate' => __( 'State', 'wp-members' ),
1186
+ 'zip' => __( 'Zip', 'wp-members' ),
1187
+ 'country' => __( 'Country', 'wp-members' ),
1188
+ 'phone1' => __( 'Day Phone', 'wp-members' ),
1189
+ 'user_email' => __( 'Email', 'wp-members' ),
1190
+ 'confirm_email' => __( 'Confirm Email', 'wp-members' ),
1191
+ 'user_url' => __( 'Website', 'wp-members' ),
1192
+ 'description' => __( 'Biographical Info', 'wp-members' ),
1193
+ 'password' => __( 'Password', 'wp-members' ),
1194
+ 'confirm_password' => __( 'Confirm Password', 'wp-members' ),
1195
+ 'tos' => __( 'TOS', 'wp-members' ),
1196
+ );
1197
+
1198
+ /*
1199
+ * Strings to be added or removed in future versions, included so they will
1200
+ * be in the translation template.
1201
+ * @todo Check whether any of these should be removed.
1202
+ */
1203
+ $benign_strings = array(
1204
+ __( 'No fields selected for deletion', 'wp-members' ),
1205
+ __( 'Username or Email', 'wp-members' ),
1206
+ __( 'You are not logged in.', 'wp-members' ), // Technically removed 3.5
1207
+ );
1208
+
1209
+ $defaults = array(
1210
+
1211
+ // Login form.
1212
+ 'login_heading' => __( 'Existing Users Log In', 'wp-members' ),
1213
+ 'login_username' => __( 'Username', 'wp-members' ),
1214
+ 'login_password' => __( 'Password', 'wp-members' ),
1215
+ 'login_button' => __( 'Log In', 'wp-members' ),
1216
+ 'remember_me' => __( 'Remember Me', 'wp-members' ),
1217
+ 'forgot_link_before' => __( 'Forgot password?', 'wp-members' ) . '&nbsp;',
1218
+ 'forgot_link' => __( 'Click here to reset', 'wp-members' ),
1219
+ 'register_link_before' => __( 'New User?', 'wp-members' ) . '&nbsp;',
1220
+ 'register_link' => __( 'Click here to register', 'wp-members' ),
1221
+
1222
+ // Password change form.
1223
+ 'pwdchg_heading' => __( 'Change Password', 'wp-members' ),
1224
+ 'pwdchg_password1' => __( 'New password', 'wp-members' ),
1225
+ 'pwdchg_password2' => __( 'Confirm new password', 'wp-members' ),
1226
+ 'pwdchg_button' => __( 'Update Password', 'wp-members' ),
1227
+
1228
+ // Password reset form.
1229
+ 'pwdreset_heading' => __( 'Reset Forgotten Password', 'wp-members' ),
1230
+ 'pwdreset_username' => __( 'Username', 'wp-members' ),
1231
+ 'pwdreset_email' => __( 'Email', 'wp-members' ),
1232
+ 'pwdreset_button' => __( 'Reset Password' ),
1233
+ 'username_link_before' => __( 'Forgot username?', 'wp-members' ) . '&nbsp;',
1234
+ 'username_link' => __( 'Click here', 'wp-members' ),
1235
+
1236
+ // Retrieve username form.
1237
+ 'username_heading' => __( 'Retrieve username', 'wp-members' ),
1238
+ 'username_email' => __( 'Email Address', 'wp-members' ),
1239
+ 'username_button' => __( 'Retrieve username', 'wp-members' ),
1240
+
1241
+ // Register form.
1242
+ 'register_heading' => __( 'New User Registration', 'wp-members' ),
1243
+ 'register_username' => __( 'Choose a Username', 'wp-members' ),
1244
+ 'register_rscaptcha' => __( 'Input the code:', 'wp-members' ),
1245
+ 'register_tos' => __( 'Please indicate that you agree to the %s Terms of Service %s', 'wp-members' ), // @note: if default changes, default check after wpmem_tos_link_txt must change.
1246
+ 'register_clear' => __( 'Reset Form', 'wp-members' ),
1247
+ 'register_submit' => __( 'Register', 'wp-members' ),
1248
+ 'register_req_mark' => '<span class="req">*</span>',
1249
+ 'register_required' => '<span class="req">*</span>' . __( 'Required field', 'wp-members' ),
1250
+
1251
+ // User profile update form.
1252
+ 'profile_heading' => __( 'Edit Your Information', 'wp-members' ),
1253
+ 'profile_username' => __( 'Username', 'wp-members' ),
1254
+ 'profile_submit' => __( 'Update Profile', 'wp-members' ),
1255
+ 'profile_upload' => __( 'Update this file', 'wp-members' ),
1256
+
1257
+ // Error messages and dialogs.
1258
+ 'login_failed_heading' => __( 'Login Failed!', 'wp-members' ),
1259
+ 'login_failed' => __( 'You entered an invalid username or password.', 'wp-members' ),
1260
+ 'login_failed_link' => __( 'Click here to continue.', 'wp-members' ),
1261
+ 'pwdchangempty' => __( 'Password fields cannot be empty', 'wp-members' ),
1262
+ 'usernamefailed' => __( 'Sorry, that email address was not found.', 'wp-members' ),
1263
+ 'usernamesuccess' => __( 'An email was sent to %s with your username.', 'wp-members' ),
1264
+ 'reg_empty_field' => __( 'Sorry, %s is a required field.', 'wp-members' ),
1265
+ 'reg_valid_email' => __( 'You must enter a valid email address.', 'wp-members' ),
1266
+ 'reg_non_alphanumeric' => __( 'The username cannot include non-alphanumeric characters.', 'wp-members' ),
1267
+ 'reg_empty_username' => __( 'Sorry, username is a required field', 'wp-members' ),
1268
+ 'reg_password_match' => __( 'Passwords did not match.', 'wp-members' ),
1269
+ 'reg_email_match' => __( 'Emails did not match.', 'wp-members' ),
1270
+ 'reg_empty_captcha' => __( 'You must complete the CAPTCHA form.', 'wp-members' ),
1271
+ 'reg_invalid_captcha' => __( 'CAPTCHA was not valid.', 'wp-members' ),
1272
+ 'reg_generic' => __( 'There was an error processing the form.', 'wp-members' ),
1273
+ 'reg_captcha_err' => __( 'There was an error with the CAPTCHA form.', 'wp-members' ),
1274
+
1275
+ // Links.
1276
+ 'profile_edit' => __( 'Edit My Information', 'wp-members' ),
1277
+ 'profile_password' => __( 'Change Password', 'wp-members' ),
1278
+ 'register_status' => __( 'You are logged in as %s', 'wp-members' ),
1279
+ 'register_logout' => __( 'Click to log out.', 'wp-members' ),
1280
+ 'register_continue' => __( 'Begin using the site.', 'wp-members' ),
1281
+ 'login_welcome' => __( 'You are logged in as %s', 'wp-members' ),
1282
+ 'login_logout' => __( 'Click to log out', 'wp-members' ),
1283
+ 'status_welcome' => __( 'You are logged in as %s', 'wp-members' ),
1284
+ 'status_logout' => __( 'click to log out', 'wp-members' ),
1285
+ 'menu_logout' => __( 'Log Out', 'wp-members' ),
1286
+
1287
+ // Widget.
1288
+ 'sb_status' => __( 'You are logged in as %s', 'wp-members' ),
1289
+ 'sb_logout' => __( 'click here to log out', 'wp-members' ),
1290
+ 'sb_login_failed' => __( 'Login Failed!<br />You entered an invalid username or password.', 'wp-members' ),
1291
+ 'sb_not_logged_in' => '',
1292
+ 'sb_login_username' => __( 'Username or Email', 'wp-members' ),
1293
+ 'sb_login_password' => __( 'Password', 'wp-members' ),
1294
+ 'sb_login_button' => __( 'log in', 'wp-members' ),
1295
+ 'sb_login_forgot' => __( 'Forgot?', 'wp-members' ),
1296
+ 'sb_login_register' => __( 'Register', 'wp-members' ),
1297
+
1298
+ // Default Dialogs.
1299
+ 'restricted_msg' => __( "This content is restricted to site members. If you are an existing user, please log in. New users may register below.", 'wp-members' ),
1300
+ 'user' => __( "Sorry, that username is taken, please try another.", 'wp-members' ),
1301
+ 'email' => __( "Sorry, that email address already has an account.<br />Please try another.", 'wp-members' ),
1302
+ 'success' => __( "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", 'wp-members' ),
1303
+ 'editsuccess' => __( "Your information was updated!", 'wp-members' ),
1304
+ 'pwdchangerr' => __( "Passwords did not match.<br /><br />Please try again.", 'wp-members' ),
1305
+ 'pwdchangesuccess' => __( "Password successfully changed!", 'wp-members' ),
1306
+ 'pwdreseterr' => __( "Either the username or email address do not exist in our records.", 'wp-members' ),
1307
+ 'pwdresetsuccess' => __( "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.", 'wp-members' ),
1308
+ 'product_restricted' => __( "Sorry, you do not have access to this content.", 'wp-members' ),
1309
+
1310
+ ); // End of $defaults array.
1311
+
1312
+ /**
1313
+ * Filter default terms.
1314
+ *
1315
+ * @since 3.1.0
1316
+ */
1317
+ $text = apply_filters( 'wpmem_default_text_strings', '' );
1318
+
1319
+ // Merge filtered $terms with $defaults.
1320
+ $text = wp_parse_args( $text, $defaults );
1321
+
1322
+ // Return the requested text string.
1323
+ return $text[ $str ];
1324
+
1325
+ } // End of get_text().
1326
+
1327
+ /**
1328
+ * Load the admin api.
1329
+ *
1330
+ * @since 3.1.0
1331
+ */
1332
+ function load_admin_api() {
1333
+ if ( is_admin() ) {
1334
+ /**
1335
+ * Load the admin api class.
1336
+ *
1337
+ * @since 3.1.0
1338
+ */
1339
+ include_once( WPMEM_PATH . 'admin/includes/class-wp-members-admin-api.php' );
1340
+ $this->admin = new WP_Members_Admin_API;
1341
+ }
1342
+ }
1343
+
1344
+ /**
1345
+ * Initializes the WP-Members widget.
1346
+ *
1347
+ * @since 3.2.0 Replaces widget_wpmemwidget_init
1348
+ */
1349
+ public function widget_init() {
1350
+ // Register the WP-Members widget.
1351
+ register_widget( 'widget_wpmemwidget' );
1352
+ }
1353
+
1354
+ /**
1355
+ * Adds WP-Members query vars to WP's public query vars.
1356
+ *
1357
+ * @since 3.2.0
1358
+ *
1359
+ * @see https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
1360
+ *
1361
+ * @param array $qvars
1362
+ */
1363
+ public function add_query_vars ( $qvars ) {
1364
+ $qvars[] = 'a'; // The WP-Members action variable.
1365
+ return $qvars;
1366
+ }
1367
+
1368
+ /**
1369
+ * Enqueues login/out script for the footer.
1370
+ *
1371
+ * @since 3.2.0
1372
+ */
1373
+ public function loginout_script() {
1374
+ if ( is_user_logged_in() ) {
1375
+ wp_enqueue_script( 'jquery' );
1376
+ add_action( 'wp_footer', array( $this, 'do_loginout_script' ), 50 );
1377
+ }
1378
+ }
1379
+
1380
+ /**
1381
+ * Outputs login/out script for the footer.
1382
+ *
1383
+ * @since 3.2.0
1384
+ *
1385
+ * @global object $wpmem
1386
+ */
1387
+ public function do_loginout_script() {
1388
+ global $wpmem;
1389
+ $logout = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
1390
+ ?><script type="text/javascript">
1391
+ jQuery('.wpmem_loginout').html('<a class="login_button" href="<?php echo $logout; ?>"><?php echo $this->get_text( 'menu_logout' ); ?></a>');
1392
+ </script><?php
1393
+ }
1394
+
1395
+ /**
1396
+ * Adds WP-Members controls to the Customizer
1397
+ *
1398
+ * @since 3.2.0
1399
+ *
1400
+ * @param object $wp_customize The Customizer object.
1401
+ */
1402
+ function customizer_settings( $wp_customize ) {
1403
+ $wp_customize->add_section( 'wp_members' , array(
1404
+ 'title' => 'WP-Members',
1405
+ 'priority' => 190,
1406
+ ) );
1407
+
1408
+ // Add settings for output description
1409
+ $wp_customize->add_setting( 'show_logged_out_state', array(
1410
+ 'default' => '1',
1411
+ 'type' => 'theme_mod', //'option'
1412
+ 'capability' => 'edit_theme_options',
1413
+ 'transport' => 'refresh',
1414
+ ) );
1415
+
1416
+ // Add settings for output description
1417
+ $wp_customize->add_setting( 'show_form_message_dialog', array(
1418
+ 'default' => '1',
1419
+ 'type' => 'theme_mod', //'option'
1420
+ 'capability' => 'edit_theme_options',
1421
+ 'transport' => 'refresh',
1422
+ ) );
1423
+
1424
+ // Add control and output for select field
1425
+ $wp_customize->add_control( 'show_form_logged_out', array(
1426
+ 'label' => __( 'Show forms as logged out', 'wp-members' ),
1427
+ 'section' => 'wp_members',
1428
+ 'settings' => 'show_logged_out_state',
1429
+ 'type' => 'checkbox',
1430
+ 'std' => '1'
1431
+ ) );
1432
+
1433
+ // Add control for showing dialog
1434
+ $wp_customize->add_control( 'show_form_dialog', array(
1435
+ 'label' => __( 'Show form message dialog', 'wp-members' ),
1436
+ 'section' => 'wp_members',
1437
+ 'settings' => 'show_form_message_dialog',
1438
+ 'type' => 'checkbox',
1439
+ 'std' => '0'
1440
+ ) );
1441
+ }
1442
+
1443
+ /**
1444
+ * Overrides the wptexturize filter.
1445
+ *
1446
+ * Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
1447
+ *
1448
+ * @since 2.6.4
1449
+ * @since 3.2.3 Moved to WP_Members class.
1450
+ *
1451
+ * @todo Possibly deprecate or severely alter this process as its need may be obsolete.
1452
+ *
1453
+ * @param string $content
1454
+ * @return string $new_content
1455
+ */
1456
+ function texturize( $content ) {
1457
+
1458
+ $new_content = '';
1459
+ $pattern_full = '{(\[wpmem_txt\].*?\[/wpmem_txt\])}is';
1460
+ $pattern_contents = '{\[wpmem_txt\](.*?)\[/wpmem_txt\]}is';
1461
+ $pieces = preg_split( $pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE );
1462
+
1463
+ foreach ( $pieces as $piece ) {
1464
+ if ( preg_match( $pattern_contents, $piece, $matches ) ) {
1465
+ $new_content .= $matches[1];
1466
+ } else {
1467
+ $new_content .= wptexturize( wpautop( $piece ) );
1468
+ }
1469
+ }
1470
+
1471
+ return $new_content;
1472
+ }
1473
+
1474
+ /**
1475
+ * Loads the stylesheet for tableless forms.
1476
+ *
1477
+ * @since 2.6
1478
+ * @since 3.2.3 Moved to WP_Members class.
1479
+ *
1480
+ * @global object $wpmem The WP_Members object.
1481
+ */
1482
+ function enqueue_style() {
1483
+ global $wpmem;
1484
+ wp_enqueue_style ( 'wp-members', wpmem_force_ssl( $wpmem->cssurl ), '', WPMEM_VERSION );
1485
+ }
1486
+
1487
+ /**
1488
+ * Creates an excerpt on the fly if there is no 'more' tag.
1489
+ *
1490
+ * @since 2.6
1491
+ * @since 3.2.3 Moved to WP_Members class.
1492
+ * @since 3.2.5 Check if post object exists.
1493
+ *
1494
+ * @global object $post The post object.
1495
+ * @global object $wpmem The WP_Members object.
1496
+ *
1497
+ * @param string $content
1498
+ * @return string $content
1499
+ */
1500
+ function do_excerpt( $content ) {
1501
+
1502
+ global $post, $more, $wpmem;
1503
+
1504
+ if ( is_object( $post ) ) {
1505
+
1506
+ $post_id = $post->ID;
1507
+ $post_type = $post->post_type;
1508
+
1509
+ $autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
1510
+
1511
+ // Is there already a 'more' link in the content?
1512
+ $has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
1513
+
1514
+ // If auto_ex is on.
1515
+ if ( $autoex ) {
1516
+
1517
+ // Build an excerpt if one does not exist.
1518
+ if ( ! $has_more_link ) {
1519
+
1520
+ $is_singular = ( is_singular( $post->post_type ) ) ? true : false;
1521
+
1522
+ if ( $is_singular ) {
1523
+ // If it's a single post, we don't need the 'more' link.
1524
+ $more_link_text = '';
1525
+ $more_link = '';
1526
+ } else {
1527
+ // The default $more_link_text.
1528
+ if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
1529
+ $more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
1530
+ } else {
1531
+ $more_link_text = __( '(more&hellip;)' );
1532
+ }
1533
+ // The default $more_link.
1534
+ $more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
1535
+ }
1536
+
1537
+ // Apply the_content_more_link filter if one exists (will match up all 'more' link text).
1538
+ /** This filter is documented in /wp-includes/post-template.php */
1539
+ $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
1540
+
1541
+ $defaults = array(
1542
+ 'length' => $autoex['length'],
1543
+ 'more_link' => $more_link,
1544
+ 'blocked_only' => false,
1545
+ );
1546
+ /**
1547
+ * Filter auto excerpt defaults.
1548
+ *
1549
+ * @since 3.0.9
1550
+ * @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
1551
+ *
1552
+ * @param array {
1553
+ * An array of settings to override the function defaults.
1554
+ *
1555
+ * @type int $length The default length of the excerpt.
1556
+ * @type string $more_link The more link HTML.
1557
+ * @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
1558
+ * }
1559
+ * @param string $post->ID The post ID.
1560
+ * @param string $post->post_type The content's post type.
1561
+ */
1562
+ $args = apply_filters( 'wpmem_auto_excerpt_args', '', $post->ID, $post->post_type );
1563
+
1564
+ // Merge settings.
1565
+ $args = wp_parse_args( $args, $defaults );
1566
+
1567
+ // Are we only excerpting blocked content?
1568
+ if ( $args['blocked_only'] ) {
1569
+ $post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
1570
+ if ( 1 == $wpmem->block[ $post->post_type ] ) {
1571
+ // Post type is blocked, if post meta unblocks it, don't do excerpt.
1572
+ $do_excerpt = ( "0" == $post_meta ) ? false : true;
1573
+ } else {
1574
+ // Post type is unblocked, if post meta blocks it, do excerpt.
1575
+ $do_excerpt = ( "1" == $post_meta ) ? true : false;
1576
+ }
1577
+ } else {
1578
+ $do_excerpt = true;
1579
+ }
1580
+
1581
+ if ( $do_excerpt ) {
1582
+ $content = wp_trim_words( $content, $args['length'], $args['more_link'] );
1583
+ // Check if the more link was added (note: singular has no more_link):
1584
+ if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
1585
+ $content = $content . $args['more_link'];
1586
+ }
1587
+ }
1588
+ }
1589
+ }
1590
+ } else {
1591
+ $post_id = false;
1592
+ $post_type = false;
1593
+ }
1594
+
1595
+ /**
1596
+ * Filter the auto excerpt.
1597
+ *
1598
+ * @since 2.8.1
1599
+ * @since 3.0.9 Added post ID and post type parameters.
1600
+ * @since 3.2.5 Post ID and post type may be false if there is no post object.
1601
+ *
1602
+ * @param string $content The content excerpt.
1603
+ * @param string $post_id The post ID.
1604
+ * @param string $post_type The content's post type.
1605
+ */
1606
+ $content = apply_filters( 'wpmem_auto_excerpt', $content, $post_id, $post_type );
1607
+
1608
+ // Return the excerpt.
1609
+ return $content;
1610
+ }
1611
+
1612
+ /**
1613
+ * Convert form tag.
1614
+ *
1615
+ * @todo This is temporary to handle form tag conversion.
1616
+ *
1617
+ * @since 3.1.7
1618
+ * @since 3.2.3 Moved to WP_Members class.
1619
+ *
1620
+ * @param string $tag
1621
+ * @return string $tag
1622
+ */
1623
+ function convert_tag( $tag ) {
1624
+ switch ( $tag ) {
1625
+ case 'new':
1626
+ return 'register';
1627
+ break;
1628
+ case 'edit':
1629
+ case 'update':
1630
+ return 'profile';
1631
+ break;
1632
+ case 'wp':
1633
+ case 'wp_validate':
1634
+ case 'wp_finalize':
1635
+ return 'register_wp';
1636
+ break;
1637
+ case 'dashboard_profile':
1638
+ case 'dashboard_profile_update':
1639
+ return 'profile_dashboard';
1640
+ break;
1641
+ case 'admin_profile':
1642
+ case 'admin_profile_update':
1643
+ return 'profile_admin';
1644
+ break;
1645
+ default:
1646
+ return $tag;
1647
+ break;
1648
+ }
1649
+ return $tag;
1650
+ }
1651
+
1652
+ /**
1653
+ * Loads translation files.
1654
+ *
1655
+ * @since 3.0.0
1656
+ * @since 3.2.5 Moved to main object, dropped wpmem_ stem.
1657
+ */
1658
+ function load_textdomain() {
1659
+
1660
+ // @see: https://ulrich.pogson.ch/load-theme-plugin-translations for notes on changes.
1661
+
1662
+ // Plugin textdomain.
1663
+ $domain = 'wp-members';
1664
+
1665
+ // Wordpress locale.
1666
+ /** This filter is documented in wp-includes/l10n.php */
1667
+ $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
1668
+
1669
+ /**
1670
+ * Filter translation file.
1671
+ *
1672
+ * If the translate.wordpress.org language pack is available, it will
1673
+ * be /wp-content/languages/plugins/wp-members-{locale}.mo by default.
1674
+ * You can filter this if you want to load a language pack from a
1675
+ * different location (or different file name).
1676
+ *
1677
+ * @since 3.0.0
1678
+ * @since 3.2.0 Added locale as a parameter.
1679
+ *
1680
+ * @param string $file The translation file to load.
1681
+ * @param string $locale The current locale.
1682
+ */
1683
+ $file = apply_filters( 'wpmem_localization_file', trailingslashit( WP_LANG_DIR ) . 'plugins/' . $domain . '-' . $locale . '.mo', $locale );
1684
+
1685
+ $loaded = load_textdomain( $domain, $file );
1686
+ if ( $loaded ) {
1687
+ return $loaded;
1688
+ } else {
1689
+
1690
+ /*
1691
+ * If there is no wordpress.org language pack or the filtered
1692
+ * language file does not load, $loaded will be false and will
1693
+ * end up here to attempt to load one of the legacy language
1694
+ * packs. Note that the legacy language files are no longer
1695
+ * actively maintained and may not contain all strings.
1696
+ * The directory that the file will load from can be changed
1697
+ * using the wpmem_localization_dir filter.
1698
+ */
1699
+
1700
+ /**
1701
+ * Filter translation directory.
1702
+ *
1703
+ * @since 3.0.3
1704
+ * @since 3.2.0 Added locale as a parameter.
1705
+ *
1706
+ * @param string $dir The translation directory.
1707
+ * @param string $locale The current locale.
1708
+ */
1709
+ $dir = apply_filters( 'wpmem_localization_dir', dirname( plugin_basename( __FILE__ ) ) . '/lang/', $locale );
1710
+ load_plugin_textdomain( $domain, FALSE, $dir );
1711
+ }
1712
+ return;
1713
+ }
1714
+
1715
  } // End of WP_Members class.
inc/deprecated.php CHANGED
@@ -8,12 +8,12 @@
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at https://rocketgeek.com
11
- * Copyright (c) 2006-2018 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
- * @copyright 2006-2018
17
  */
18
 
19
  // Exit if accessed directly.
@@ -1170,6 +1170,7 @@ if ( ! function_exists( 'wpmem_inc_regemail' ) ):
1170
  */
1171
  function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null, $field_data = null, $custom = null ) {
1172
  global $wpmem;
 
1173
  $wpmem->email->to_user( $user_id, $password, $toggle, $wpmem_fields, $field_data, $custom );
1174
  return;
1175
  }
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at https://rocketgeek.com
11
+ * Copyright (c) 2006-2019 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
+ * @copyright 2006-2019
17
  */
18
 
19
  // Exit if accessed directly.
1170
  */
1171
  function wpmem_inc_regemail( $user_id, $password, $toggle, $wpmem_fields = null, $field_data = null, $custom = null ) {
1172
  global $wpmem;
1173
+ wpmem_write_log( "wpmem_inc_regemail() is deprecated since WP-Members 3.2.0. Use $ wpmem->email->to_user() instead" );
1174
  $wpmem->email->to_user( $user_id, $password, $toggle, $wpmem_fields, $field_data, $custom );
1175
  return;
1176
  }
inc/dialogs.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_loginfailed
@@ -61,8 +61,6 @@ function wpmem_inc_loginfailed() {
61
  *
62
  * @since 2.9.0
63
  *
64
- * @todo Needs probably to pass user ID or some identifier so we can get user info without going to the post object and then get_user_by().
65
- *
66
  * @param array An array of arguments to merge with defaults.
67
  */
68
  $args = apply_filters( 'wpmem_login_failed_args', '' );
@@ -81,8 +79,6 @@ function wpmem_inc_loginfailed() {
81
  *
82
  * @since 2.7.3
83
  *
84
- * @todo Needs probably to pass user ID or some identifier so we can get user info without going to the post object and then get_user_by().
85
- *
86
  * @param string $str The login failed dialog.
87
  */
88
  $str = apply_filters( 'wpmem_login_failed', $str );
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions Included:
17
  * - wpmem_inc_loginfailed
61
  *
62
  * @since 2.9.0
63
  *
 
 
64
  * @param array An array of arguments to merge with defaults.
65
  */
66
  $args = apply_filters( 'wpmem_login_failed_args', '' );
79
  *
80
  * @since 2.7.3
81
  *
 
 
82
  * @param string $str The login failed dialog.
83
  */
84
  $str = apply_filters( 'wpmem_login_failed', $str );
inc/forms.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Form Building Functions
14
  * @author Chad Butler
15
- * @copyright 2006-2018
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_login
@@ -195,19 +195,7 @@ function wpmem_inc_recaptcha( $arr ) {
195
  $http = wpmem_use_ssl();
196
 
197
  global $wpmem;
198
- if ( $wpmem->captcha == 1 ) {
199
-
200
- $str = '<script type="text/javascript">
201
- var RecaptchaOptions = { theme : \''. $arr['theme'] . '\'' . $lang . ' };
202
- </script>
203
- <script type="text/javascript" src="' . $http . 'www.google.com/recaptcha/api/challenge?k=' . $arr['public'] . '"></script>
204
- <noscript>
205
- <iframe src="' . $http . 'www.google.com/recaptcha/api/noscript?k=' . $arr['public'] . '" height="300" width="500" frameborder="0"></iframe><br/>
206
- <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
207
- <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
208
- </noscript>';
209
-
210
- } elseif ( $wpmem->captcha == 3 ) {
211
 
212
  $str = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>
213
  <div class="g-recaptcha" data-sitekey="' . $arr['public'] . '"></div>';
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Form Building Functions
14
  * @author Chad Butler
15
+ * @copyright 2006-2019
16
  *
17
  * Functions Included:
18
  * - wpmem_inc_login
195
  $http = wpmem_use_ssl();
196
 
197
  global $wpmem;
198
+ if ( $wpmem->captcha == 3 ) {
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
  $str = '<script src="https://www.google.com/recaptcha/api.js" async defer></script>
201
  <div class="g-recaptcha" data-sitekey="' . $arr['public'] . '"></div>';
inc/install.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  *
16
  * Functions included:
17
  * - wpmem_do_install
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  *
16
  * Functions included:
17
  * - wpmem_do_install
inc/register.php CHANGED
@@ -6,13 +6,13 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Registration Functions
14
  * @author Chad Butler
15
- * @copyright 2006-2018
16
  *
17
  * Functions Included:
18
  * - wpmem_registration
@@ -48,11 +48,9 @@ function wpmem_registration( $tag ) {
48
  global $user_ID, $wpmem, $wpmem_themsg, $userdata;
49
 
50
  // Check the nonce.
51
- if ( defined( 'WPMEM_USE_NONCE' ) ) {
52
- if ( empty( $_POST ) || ! wp_verify_nonce( $_POST['wpmem-form-submit'], 'wpmem-validate-submit' ) ) {
53
- $wpmem_themsg = __( 'There was an error processing the form.', 'wp-members' );
54
- return;
55
- }
56
  }
57
 
58
  // Is this a registration or a user profile update?
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @subpackage WP-Members Registration Functions
14
  * @author Chad Butler
15
+ * @copyright 2006-2019
16
  *
17
  * Functions Included:
18
  * - wpmem_registration
48
  global $user_ID, $wpmem, $wpmem_themsg, $userdata;
49
 
50
  // Check the nonce.
51
+ if ( empty( $_POST ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wpmem_reg_nonce' ) ) {
52
+ $wpmem_themsg = __( 'There was an error processing the form.', 'wp-members' );
53
+ return;
 
 
54
  }
55
 
56
  // Is this a registration or a user profile update?
inc/wp-registration.php CHANGED
@@ -8,12 +8,12 @@
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at https://rocketgeek.com
11
- * Copyright (c) 2006-2018 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
- * @copyright 2006-2018
17
  *
18
  * Functions Included:
19
  * - wpmem_do_wp_register_form
@@ -310,10 +310,6 @@ function wpmem_do_wp_newuser_form() {
310
  * @since 3.1.8 Added $process argument.
311
  */
312
  function wpmem_wp_register_form( $process = 'wp' ) {
313
- /**
314
- * Load native WP registration functions.
315
- */
316
- require_once( WPMEM_PATH . 'inc/wp-registration.php' );
317
  wpmem_do_wp_register_form( $process );
318
  }
319
 
8
  *
9
  * This file is part of the WP-Members plugin by Chad Butler
10
  * You can find out more about this plugin at https://rocketgeek.com
11
+ * Copyright (c) 2006-2019 Chad Butler
12
  * WP-Members(tm) is a trademark of butlerblog.com
13
  *
14
  * @package WP-Members
15
  * @author Chad Butler
16
+ * @copyright 2006-2019
17
  *
18
  * Functions Included:
19
  * - wpmem_do_wp_register_form
310
  * @since 3.1.8 Added $process argument.
311
  */
312
  function wpmem_wp_register_form( $process = 'wp' ) {
 
 
 
 
313
  wpmem_do_wp_register_form( $process );
314
  }
315
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: cbutlerjr
3
  Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
4
  Requires at least: 4.0
5
  Tested up to: 5.0
6
- Stable tag: 3.2.4.2
7
  License: GPLv2
8
 
9
  == Description ==
@@ -101,7 +101,7 @@ The FAQs are maintained at https://rocketgeek.com/plugins/wp-members/docs/faqs/
101
  == Upgrade Notice ==
102
 
103
  WP-Members 3.2.0 is a major update. See changelog for important details. Minimum WP version is 4.0.
104
- WP-Members 3.2.4 is primarily a feature update, with some fixes. See changelog.
105
 
106
  == Screenshots ==
107
 
@@ -124,13 +124,36 @@ WP-Members 3.2.4 is primarily a feature update, with some fixes. See changelog.
124
 
125
  == Changelog ==
126
 
127
- = 3.2.4.2 =
128
-
129
- * Fixes a URL issue with the default stylesheet for new installs.
130
-
131
- = 3.2.4.1 =
132
-
133
- * Fixes a jQuery incompatibility from 3.2.4, rolls back to the 3.2.3 script.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  = 3.2.4 =
136
 
@@ -140,13 +163,13 @@ WP-Members 3.2.4 is primarily a feature update, with some fixes. See changelog.
140
  * Added label tags to multipe checkbox and radio group items.
141
  * Added assigned product(s) column to users and posts screens.
142
  * Updated membership product object structure.
143
- * Updated users bulk action jquery to use noconflict().
144
  * Updated load priority to run later for jquery loginout script.
145
  * Removed query_vars filter.
146
- * Depreacted wpmem_a_activate_user(), use wpmem_activate_user() instead.
147
  * Deprecated wpmem_a_deactivate_user(), use wpmem_deactivate_user() instead.
148
  * Relocated install file to /inc/ directory.
149
  * Moved methods out of core.php, deprecated file.
 
150
 
151
  = 3.2.3 =
152
 
3
  Tags: access, authentication, content, login, member, membership, password, protect, register, registration, restriction, subscriber
4
  Requires at least: 4.0
5
  Tested up to: 5.0
6
+ Stable tag: 3.2.5.1
7
  License: GPLv2
8
 
9
  == Description ==
101
  == Upgrade Notice ==
102
 
103
  WP-Members 3.2.0 is a major update. See changelog for important details. Minimum WP version is 4.0.
104
+ WP-Members 3.2.5 is primarily a feature update, with some fixes. See changelog for details.
105
 
106
  == Screenshots ==
107
 
124
 
125
  == Changelog ==
126
 
127
+ = 3.2.5.1 =
128
+
129
+ * Fixes bug in 3.2.5 with the [wpmem_field] shortcode not displaying correctly.
130
+ * Reintroduces WPMEM_DEBUG constant (which is used in outside extensions).
131
+
132
+ = 3.2.5 =
133
+
134
+ * Fix user profile (admin/user) issue with tos field not displaying.
135
+ * Fix [wpmem_logged_in] shortcode to pass product attribute.
136
+ * Fix [wpmem_field] shortcode, checks if field is set to avoid undefined index error.
137
+ * Fix do_excerpt() if post object is not set as an object.
138
+ * Fix logic for displaying hidden posts based on product access.
139
+ * Added message dialog to display in Customizer.
140
+ * Added HTML5 "required" attribute to TOS checkbox.
141
+ * Added redirect_to attribute to logout link.
142
+ * Added $tag parameter to wpmem_{$tag}_link and wpmem_{$tag}_link_str filters.
143
+ * Added id parameter to wpmem_register_form_args filter.
144
+ * Added wpmem_email_send_args filter.
145
+ * Added wpmem_is_user() function to API.
146
+ * Added wpmem_do_shortcode() utility function in API.
147
+ * Added wpmem_export_fields filter to user export function.
148
+ * Added label attribute to field shortcode.
149
+ * Added user profile tabs (jquery ui tabs).
150
+ * Updated wpmem_form_date() API function.
151
+ * Updated check product access to handle product as an array.
152
+ * Updated to make a nonce a default for the registration form (reduces possibility of spam registrations).
153
+ * Updated form field creation, $value is now optional.
154
+ * Moved textdomain to load in main class file.
155
+ * Removed possibility of using reCAPTCHA v1 which is totally obsolete.
156
+ * Removed widget status message ("you are not logged in") for logged out state.
157
 
158
  = 3.2.4 =
159
 
163
  * Added label tags to multipe checkbox and radio group items.
164
  * Added assigned product(s) column to users and posts screens.
165
  * Updated membership product object structure.
 
166
  * Updated load priority to run later for jquery loginout script.
167
  * Removed query_vars filter.
168
+ * Deprecated wpmem_a_activate_user(), use wpmem_activate_user() instead.
169
  * Deprecated wpmem_a_deactivate_user(), use wpmem_deactivate_user() instead.
170
  * Relocated install file to /inc/ directory.
171
  * Moved methods out of core.php, deprecated file.
172
+ * Fixed issue with default stylesheet setting caused by moving install file.
173
 
174
  = 3.2.3 =
175
 
uninstall.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  // Exit if accessed directly.
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  */
16
 
17
  // Exit if accessed directly.
wp-members-tos.php CHANGED
@@ -6,12 +6,12 @@
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
- * Copyright (c) 2006-2018 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
- * @copyright 2006-2018
15
  */
16
 
17
  define ( 'WP_USE_THEMES', false );
6
  *
7
  * This file is part of the WP-Members plugin by Chad Butler
8
  * You can find out more about this plugin at https://rocketgeek.com
9
+ * Copyright (c) 2006-2019 Chad Butler
10
  * WP-Members(tm) is a trademark of butlerblog.com
11
  *
12
  * @package WP-Members
13
  * @author Chad Butler
14
+ * @copyright 2006-2019
15
  */
16
 
17
  define ( 'WP_USE_THEMES', false );
wp-members.php CHANGED
@@ -1,289 +1,223 @@
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/users-guide/">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.2.4.2
7
- Author: Chad Butler
8
- Author URI: http://butlerblog.com/
9
- Text Domain: wp-members
10
- Domain Path: /lang
11
- License: GPLv2
12
- */
13
-
14
-
15
- /*
16
- Copyright (c) 2006-2018 Chad Butler
17
-
18
- The name WP-Members(tm) is a trademark of butlerblog.com
19
-
20
- This program is free software; you can redistribute it and/or modify
21
- it under the terms of the GNU General Public License, version 2, as
22
- published by the Free Software Foundation.
23
-
24
- This program is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with this program; if not, write to the Free Software
31
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32
-
33
- You may also view the license here:
34
- http://www.gnu.org/licenses/gpl.html
35
- */
36
-
37
-
38
- /*
39
- A NOTE ABOUT LICENSE:
40
-
41
- While this plugin is freely available and open-source under the GPL2
42
- license, that does not mean it is "public domain." You are free to modify
43
- and redistribute as long as you comply with the license. Any derivative
44
- work MUST be GPL licensed and available as open source. You also MUST give
45
- proper attribution to the original author, copyright holder, and trademark
46
- owner. This means you cannot change two lines of code and claim copyright
47
- of the entire work as your own. The GPL2 license requires that if you
48
- modify this code, you must clearly indicate what section(s) you have
49
- modified and you may only claim copyright of your modifications and not
50
- the body of work. If you are unsure or have questions about how a
51
- derivative work you are developing complies with the license, copyright,
52
- trademark, or if you do not understand the difference between
53
- open source and public domain, contact the original author at:
54
- https://rocketgeek.com/contact/.
55
-
56
-
57
- INSTALLATION PROCEDURE:
58
-
59
- For complete installation and usage instructions,
60
- visit https://rocketgeek.com
61
- */
62
-
63
- // Exit if accessed directly.
64
- if ( ! defined( 'ABSPATH' ) ) {
65
- exit();
66
- }
67
-
68
- // Initialize constants.
69
- define( 'WPMEM_VERSION', '3.2.4.2' );
70
- define( 'WPMEM_DB_VERSION', '2.1.4' );
71
- define( 'WPMEM_DEBUG', false );
72
- define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
73
- define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );
74
-
75
- // Localization.
76
- add_action( 'init', 'wpmem_load_textdomain' ); //add_action( 'plugins_loaded', 'wpmem_load_textdomain' );
77
-
78
- // Initialize the plugin.
79
- add_action( 'after_setup_theme', 'wpmem_init', 10 );
80
-
81
- // Install the plugin.
82
- register_activation_hook( __FILE__, 'wpmem_install' );
83
-
84
- // Downgrade settings on deactivation.
85
- //register_deactivation_hook( __FILE__, 'wpmem_downgrade' );
86
-
87
-
88
- /**
89
- * Initialize WP-Members.
90
- *
91
- * The initialization function contains much of what was previously just
92
- * loaded in the main plugin file. It has been moved into this function
93
- * in order to allow action hooks for loading the plugin and initializing
94
- * its features and options.
95
- *
96
- * @since 2.9.0
97
- * @since 3.1.6 Dependencies now loaded by object.
98
- *
99
- * @global object $wpmem The WP-Members object class.
100
- */
101
- function wpmem_init() {
102
-
103
- // Set the object as global.
104
- global $wpmem;
105
-
106
- /**
107
- * Fires before initialization of plugin options.
108
- *
109
- * @since 2.9.0
110
- */
111
- do_action( 'wpmem_pre_init' );
112
-
113
- /**
114
- * Load the WP_Members class.
115
- */
116
- require_once( WPMEM_PATH . 'inc/class-wp-members.php' );
117
-
118
- // Invoke the WP_Members class.
119
- $wpmem = new WP_Members();
120
-
121
- /**
122
- * Fires after initialization of plugin options.
123
- *
124
- * @since 2.9.0
125
- */
126
- do_action( 'wpmem_after_init' );
127
- }
128
-
129
-
130
- /**
131
- * Adds the plugin options page and JavaScript.
132
- *
133
- * @since 2.5.2
134
- */
135
- function wpmem_admin_options() {
136
- if ( ! is_multisite() || ( is_multisite() && current_user_can( 'edit_theme_options' ) ) ) {
137
- $plugin_page = add_options_page ( 'WP-Members', 'WP-Members', 'manage_options', 'wpmem-settings', 'wpmem_admin' );
138
- }
139
- }
140
-
141
-
142
- /**
143
- * Install the plugin options.
144
- *
145
- * @since 2.5.2
146
- * @since 3.1.1 Added rollback.
147
- * @since 3.1.6 Removed rollback.
148
- *
149
- * @param
150
- */
151
- function wpmem_install() {
152
-
153
- /**
154
- * Load the install file.
155
- */
156
- require_once( WPMEM_PATH . 'inc/install.php' );
157
-
158
- // Multisite requires different install process.
159
- if ( is_multisite() ) {
160
-
161
- // If it is multisite, install options for each blog.
162
- global $wpdb;
163
- $blogs = $wpdb->get_results(
164
- "SELECT blog_id
165
- FROM {$wpdb->blogs}
166
- WHERE site_id = '{$wpdb->siteid}'
167
- AND spam = '0'
168
- AND deleted = '0'
169
- AND archived = '0'"
170
- );
171
- $original_blog_id = get_current_blog_id();
172
- foreach ( $blogs as $blog_id ) {
173
- switch_to_blog( $blog_id->blog_id );
174
- wpmem_do_install();
175
- }
176
- switch_to_blog( $original_blog_id );
177
-
178
- } else {
179
-
180
- // Single site install.
181
- wpmem_do_install();
182
- }
183
- }
184
-
185
-
186
- /**
187
- * Runs downgrade steps in install function.
188
- *
189
- * @since 3.1.1
190
- */
191
- function wpmem_downgrade() {
192
- //wpmem_install( 'downgrade' );
193
- }
194
-
195
-
196
- add_action( 'wpmu_new_blog', 'wpmem_mu_new_site', 10, 6 );
197
- /**
198
- * Install default plugin options for a newly added blog in multisite.
199
- *
200
- * @since 2.9.3
201
- *
202
- * @param $blog_id
203
- * @param $user_id
204
- * @param $domain
205
- * @param $path
206
- * @param $site_id
207
- * @param $meta
208
- */
209
- function wpmem_mu_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
210
-
211
- /**
212
- * Load the install file.
213
- */
214
- require_once( WPMEM_PATH . 'inc/install.php' );
215
-
216
- // Switch to the new blog.
217
- switch_to_blog( $blog_id );
218
-
219
- // Run the WP-Members install.
220
- wpmem_do_install();
221
-
222
- // Switch back to the current blog.
223
- restore_current_blog();
224
- }
225
-
226
-
227
- /**
228
- * Loads translation files.
229
- *
230
- * @since 3.0.0
231
- */
232
- function wpmem_load_textdomain() {
233
-
234
- // @see: https://ulrich.pogson.ch/load-theme-plugin-translations for notes on changes.
235
-
236
- // Plugin textdomain.
237
- $domain = 'wp-members';
238
-
239
- // Wordpress locale.
240
- /** This filter is documented in wp-includes/l10n.php */
241
- $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
242
-
243
- /**
244
- * Filter translation file.
245
- *
246
- * If the translate.wordpress.org language pack is available, it will
247
- * be /wp-content/languages/plugins/wp-members-{locale}.mo by default.
248
- * You can filter this if you want to load a language pack from a
249
- * different location (or different file name).
250
- *
251
- * @since 3.0.0
252
- * @since 3.2.0 Added locale as a parameter.
253
- *
254
- * @param string $file The translation file to load.
255
- * @param string $locale The current locale.
256
- */
257
- $file = apply_filters( 'wpmem_localization_file', trailingslashit( WP_LANG_DIR ) . 'plugins/' . $domain . '-' . $locale . '.mo', $locale );
258
-
259
- $loaded = load_textdomain( $domain, $file );
260
- if ( $loaded ) {
261
- return $loaded;
262
- } else {
263
-
264
- /*
265
- * If there is no wordpress.org language pack or the filtered
266
- * language file does not load, $loaded will be false and will
267
- * end up here to attempt to load one of the legacy language
268
- * packs. Note that the legacy language files are no longer
269
- * actively maintained and may not contain all strings.
270
- * The directory that the file will load from can be changed
271
- * using the wpmem_localization_dir filter.
272
- */
273
-
274
- /**
275
- * Filter translation directory.
276
- *
277
- * @since 3.0.3
278
- * @since 3.2.0 Added locale as a parameter.
279
- *
280
- * @param string $dir The translation directory.
281
- * @param string $locale The current locale.
282
- */
283
- $dir = apply_filters( 'wpmem_localization_dir', dirname( plugin_basename( __FILE__ ) ) . '/lang/', $locale );
284
- load_plugin_textdomain( $domain, FALSE, $dir );
285
- }
286
- return;
287
- }
288
-
289
  // End of file.
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/users-guide/">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.2.5.1
7
+ Author: Chad Butler
8
+ Author URI: http://butlerblog.com/
9
+ Text Domain: wp-members
10
+ Domain Path: /lang
11
+ License: GPLv2
12
+ */
13
+
14
+
15
+ /*
16
+ Copyright (c) 2006-2019 Chad Butler
17
+
18
+ The name WP-Members(tm) is a trademark of butlerblog.com
19
+
20
+ This program is free software; you can redistribute it and/or modify
21
+ it under the terms of the GNU General Public License, version 2, as
22
+ published by the Free Software Foundation.
23
+
24
+ This program is distributed in the hope that it will be useful,
25
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ GNU General Public License for more details.
28
+
29
+ You should have received a copy of the GNU General Public License
30
+ along with this program; if not, write to the Free Software
31
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32
+
33
+ You may also view the license here:
34
+ http://www.gnu.org/licenses/gpl.html
35
+ */
36
+
37
+
38
+ /*
39
+ A NOTE ABOUT LICENSE:
40
+
41
+ While this plugin is freely available and open-source under the GPL2
42
+ license, that does not mean it is "public domain." You are free to modify
43
+ and redistribute as long as you comply with the license. Any derivative
44
+ work MUST be GPL licensed and available as open source. You also MUST give
45
+ proper attribution to the original author, copyright holder, and trademark
46
+ owner. This means you cannot change two lines of code and claim copyright
47
+ of the entire work as your own. The GPL2 license requires that if you
48
+ modify this code, you must clearly indicate what section(s) you have
49
+ modified and you may only claim copyright of your modifications and not
50
+ the body of work. If you are unsure or have questions about how a
51
+ derivative work you are developing complies with the license, copyright,
52
+ trademark, or if you do not understand the difference between
53
+ open source and public domain, contact the original author at:
54
+ https://rocketgeek.com/contact/.
55
+
56
+
57
+ INSTALLATION PROCEDURE:
58
+
59
+ For complete installation and usage instructions,
60
+ visit https://rocketgeek.com
61
+ */
62
+
63
+ // Exit if accessed directly.
64
+ if ( ! defined( 'ABSPATH' ) ) {
65
+ exit();
66
+ }
67
+
68
+ // Initialize constants.
69
+ define( 'WPMEM_VERSION', '3.2.5.1' );
70
+ define( 'WPMEM_DB_VERSION', '2.1.4' );
71
+ define( 'WPMEM_DIR', plugin_dir_url ( __FILE__ ) );
72
+ define( 'WPMEM_PATH', plugin_dir_path( __FILE__ ) );
73
+ define( 'WPMEM_DEBUG', false );
74
+
75
+ // Initialize the plugin.
76
+ add_action( 'after_setup_theme', 'wpmem_init', 10 );
77
+
78
+ // Install the plugin.
79
+ register_activation_hook( __FILE__, 'wpmem_install' );
80
+
81
+ // Downgrade settings on deactivation.
82
+ //register_deactivation_hook( __FILE__, 'wpmem_downgrade' );
83
+
84
+
85
+ /**
86
+ * Initialize WP-Members.
87
+ *
88
+ * The initialization function contains much of what was previously just
89
+ * loaded in the main plugin file. It has been moved into this function
90
+ * in order to allow action hooks for loading the plugin and initializing
91
+ * its features and options.
92
+ *
93
+ * @since 2.9.0
94
+ * @since 3.1.6 Dependencies now loaded by object.
95
+ *
96
+ * @global object $wpmem The WP-Members object class.
97
+ */
98
+ function wpmem_init() {
99
+
100
+ // Set the object as global.
101
+ global $wpmem;
102
+
103
+ /**
104
+ * Fires before initialization of plugin options.
105
+ *
106
+ * @since 2.9.0
107
+ */
108
+ do_action( 'wpmem_pre_init' );
109
+
110
+ /**
111
+ * Load the WP_Members class.
112
+ */
113
+ require_once( WPMEM_PATH . 'inc/class-wp-members.php' );
114
+
115
+ // Invoke the WP_Members class.
116
+ $wpmem = new WP_Members();
117
+
118
+ /**
119
+ * Fires after initialization of plugin options.
120
+ *
121
+ * @since 2.9.0
122
+ */
123
+ do_action( 'wpmem_after_init' );
124
+ }
125
+
126
+
127
+ /**
128
+ * Adds the plugin options page and JavaScript.
129
+ *
130
+ * @since 2.5.2
131
+ */
132
+ function wpmem_admin_options() {
133
+ if ( ! is_multisite() || ( is_multisite() && current_user_can( 'edit_theme_options' ) ) ) {
134
+ $plugin_page = add_options_page ( 'WP-Members', 'WP-Members', 'manage_options', 'wpmem-settings', 'wpmem_admin' );
135
+ }
136
+ }
137
+
138
+
139
+ /**
140
+ * Install the plugin options.
141
+ *
142
+ * @since 2.5.2
143
+ * @since 3.1.1 Added rollback.
144
+ * @since 3.1.6 Removed rollback.
145
+ *
146
+ * @param
147
+ */
148
+ function wpmem_install() {
149
+
150
+ /**
151
+ * Load the install file.
152
+ */
153
+ require_once( WPMEM_PATH . 'inc/install.php' );
154
+
155
+ // Multisite requires different install process.
156
+ if ( is_multisite() ) {
157
+
158
+ // If it is multisite, install options for each blog.
159
+ global $wpdb;
160
+ $blogs = $wpdb->get_results(
161
+ "SELECT blog_id
162
+ FROM {$wpdb->blogs}
163
+ WHERE site_id = '{$wpdb->siteid}'
164
+ AND spam = '0'
165
+ AND deleted = '0'
166
+ AND archived = '0'"
167
+ );
168
+ $original_blog_id = get_current_blog_id();
169
+ foreach ( $blogs as $blog_id ) {
170
+ switch_to_blog( $blog_id->blog_id );
171
+ wpmem_do_install();
172
+ }
173
+ switch_to_blog( $original_blog_id );
174
+
175
+ } else {
176
+
177
+ // Single site install.
178
+ wpmem_do_install();
179
+ }
180
+ }
181
+
182
+
183
+ /**
184
+ * Runs downgrade steps in install function.
185
+ *
186
+ * @since 3.1.1
187
+ */
188
+ function wpmem_downgrade() {
189
+ //wpmem_install( 'downgrade' );
190
+ }
191
+
192
+
193
+ add_action( 'wpmu_new_blog', 'wpmem_mu_new_site', 10, 6 );
194
+ /**
195
+ * Install default plugin options for a newly added blog in multisite.
196
+ *
197
+ * @since 2.9.3
198
+ *
199
+ * @param $blog_id
200
+ * @param $user_id
201
+ * @param $domain
202
+ * @param $path
203
+ * @param $site_id
204
+ * @param $meta
205
+ */
206
+ function wpmem_mu_new_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
207
+
208
+ /**
209
+ * Load the install file.
210
+ */
211
+ require_once( WPMEM_PATH . 'inc/install.php' );
212
+
213
+ // Switch to the new blog.
214
+ switch_to_blog( $blog_id );
215
+
216
+ // Run the WP-Members install.
217
+ wpmem_do_install();
218
+
219
+ // Switch back to the current blog.
220
+ restore_current_blog();
221
+ }
222
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  // End of file.