WP-Members Membership Plugin - Version 3.2.4

Version Description

  • Added deactivate users both bulk and single in Users > All Users.
  • Added id attribute for form labels.
  • Added wpmem_format_date() API function.
  • Added label tags to multipe checkbox and radio group items.
  • Added assigned product(s) column to users and posts screens.
  • Updated membership product object structure.
  • Updated users bulk action jquery to use noconflict().
  • Updated load priority to run later for jquery loginout script.
  • Removed query_vars filter.
  • Depreacted wpmem_a_activate_user(), use wpmem_activate_user() instead.
  • Deprecated wpmem_a_deactivate_user(), use wpmem_deactivate_user() instead.
  • Relocated install file to /inc/ directory.
  • Moved methods out of core.php, deprecated file.
Download this release

Release Info

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

Code changes from version 3.2.3 to 3.2.4

admin/includes/class-wp-members-admin-api.php CHANGED
@@ -125,7 +125,7 @@ class WP_Members_Admin_API {
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( 'edit_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' );
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' );
admin/includes/class-wp-members-products-admin.php CHANGED
@@ -31,6 +31,16 @@ class WP_Members_Products_Admin {
31
  add_action( 'wpmem_admin_after_block_meta', array( $this, 'add_product_to_post' ), 10, 2 );
32
  add_action( 'wpmem_admin_block_meta_save', array( $this, 'save_product_to_post' ), 10, 3 );
33
  add_action( 'admin_footer', array( $this, 'enqueue_select2' ) );
 
 
 
 
 
 
 
 
 
 
34
  }
35
  }
36
 
@@ -230,11 +240,11 @@ class WP_Members_Products_Admin {
230
  */
231
  function add_product_to_post( $post, $block ) {
232
  global $wpmem;
233
- $product = get_post_meta( $post->ID, $wpmem->membership->post_meta, true );
234
  $product = ( $product ) ? $product : array();
235
  $values[] = __( 'None', 'wp-members' ) . '|';
236
  foreach ( $wpmem->membership->products as $key => $value ) {
237
- $values[] = $value . '|' . $key;
238
  }
239
  echo wpmem_form_label( array(
240
  'meta_key'=>$wpmem->membership->post_meta,
@@ -268,7 +278,7 @@ class WP_Members_Products_Admin {
268
  } else {
269
  update_post_meta( $post->ID, $wpmem->membership->post_meta, $products );
270
  }
271
- foreach ( $wpmem->membership->products as $key => $name ) {
272
  if ( in_array( $key, $products ) ) {
273
  update_post_meta( $post->ID, $wpmem->membership->post_stem . $key, 1 );
274
  } else {
@@ -295,4 +305,86 @@ class WP_Members_Products_Admin {
295
  }
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  }
31
  add_action( 'wpmem_admin_after_block_meta', array( $this, 'add_product_to_post' ), 10, 2 );
32
  add_action( 'wpmem_admin_block_meta_save', array( $this, 'save_product_to_post' ), 10, 3 );
33
  add_action( 'admin_footer', array( $this, 'enqueue_select2' ) );
34
+ add_filter( 'manage_users_columns', array( $this, 'user_columns' ) );
35
+ add_filter( 'manage_users_custom_column', array( $this, 'user_columns_content' ), 10, 3 );
36
+ add_filter( 'manage_posts_columns', array( $this, 'post_columns' ) );
37
+ add_action( 'manage_posts_custom_column', array( $this, 'post_columns_content' ), 10, 2 );
38
+ add_filter( 'manage_pages_columns', array( $this, 'post_columns' ) );
39
+ add_action( 'manage_pages_custom_column', array( $this, 'post_columns_content' ), 10, 2 );
40
+ foreach( $wpmem->post_types as $key => $val ) {
41
+ add_filter( 'manage_' . $key . '_posts_columns', array( $this, 'post_columns' ) );
42
+ add_action( 'manage_' . $key . '_posts_custom_column', array( $this, 'post_columns_content' ), 10, 2 );
43
+ }
44
  }
45
  }
46
 
240
  */
241
  function add_product_to_post( $post, $block ) {
242
  global $wpmem;
243
+ $product = $wpmem->membership->get_post_products( $post->ID ); //get_post_meta( $post->ID, $wpmem->membership->post_meta, true );
244
  $product = ( $product ) ? $product : array();
245
  $values[] = __( 'None', 'wp-members' ) . '|';
246
  foreach ( $wpmem->membership->products as $key => $value ) {
247
+ $values[] = $value['title'] . '|' . $key;
248
  }
249
  echo wpmem_form_label( array(
250
  'meta_key'=>$wpmem->membership->post_meta,
278
  } else {
279
  update_post_meta( $post->ID, $wpmem->membership->post_meta, $products );
280
  }
281
+ foreach ( $wpmem->membership->products as $key => $value ) {
282
  if ( in_array( $key, $products ) ) {
283
  update_post_meta( $post->ID, $wpmem->membership->post_stem . $key, 1 );
284
  } else {
305
  }
306
  }
307
 
308
+ /**
309
+ * Add membership product column to post table.
310
+ *
311
+ * @since 3.2.4
312
+ *
313
+ * @global object $wpmem
314
+ * @param array $columns
315
+ * @return array $columns
316
+ */
317
+ function post_columns( $columns ){
318
+ global $wpmem;
319
+ $post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_text_field( $_REQUEST['post_type'] ) : 'post';
320
+ if ( $post_type == 'page' || $post_type == 'post' || array_key_exists( $post_type, $wpmem->post_types ) ) {
321
+ $product = array( 'wpmem_product' => __( 'Required Membership', 'wp-members' ) );
322
+ $columns = wpmem_array_insert( $columns, $product, 'wpmem_block', 'before' );
323
+ }
324
+ return $columns;
325
+ }
326
+
327
+ /**
328
+ * Membership product column data.
329
+ *
330
+ * @since 3.2.4
331
+ *
332
+ * @global object $wpmem
333
+ * @param string $column_name
334
+ * @param int $post_id
335
+ */
336
+ function post_columns_content( $column_name, $post_id ) {
337
+ if ( 'wpmem_product' == $column_name ) {
338
+ global $wpmem;
339
+ $post_products = $wpmem->membership->get_post_products( $post_id );
340
+ if ( $post_products ) {
341
+ foreach ( $post_products as $meta ) {
342
+ if ( isset( $wpmem->membership->products[ $meta ]['title'] ) ) {
343
+ $display[] = $wpmem->membership->products[ $meta ]['title'];
344
+ }
345
+ }
346
+ echo implode( ", ", $display );
347
+ }
348
+ }
349
+ }
350
+
351
+ /**
352
+ * Add membership product column to post table.
353
+ *
354
+ * @since 3.2.4
355
+ *
356
+ * @param array $columns
357
+ * @return array $columns
358
+ */
359
+ function user_columns( $columns ){
360
+ $columns['wpmem_product'] = __( 'Membership', 'wp-members' );
361
+ return $columns;
362
+ }
363
+
364
+ /**
365
+ * Membership product column data.
366
+ *
367
+ * @since 3.2.4
368
+ *
369
+ * @global object $wpmem
370
+ * @param string $column_name
371
+ * @param int $post_id
372
+ * @return array $display
373
+ */
374
+ function user_columns_content( $val, $column_name, $user_id ) {
375
+ if ( 'wpmem_product' == $column_name ) {
376
+ global $wpmem;
377
+ $display = array();
378
+ $user_products = $wpmem->user->get_user_products( $user_id );
379
+ if ( $user_products ) {
380
+ foreach ( $user_products as $meta => $value ) {
381
+ if ( isset( $wpmem->membership->products[ $meta ]['title'] ) ) {
382
+ $display[] = $wpmem->membership->products[ $meta ]['title'];
383
+ }
384
+ }
385
+ }
386
+ return implode( ", ", $display );
387
+ }
388
+ return $val;
389
+ }
390
  }
admin/post.php CHANGED
@@ -176,7 +176,9 @@ function wpmem_block_meta_add() {
176
  */
177
  $post_title = apply_filters( 'wpmem_admin_' . $key . '_meta_title', sprintf( __( '%s Restriction', 'wp-members' ), $post_type->labels->singular_name ) );
178
 
179
- add_meta_box( 'wpmem-block-meta-id', $post_title, 'wpmem_block_meta', $key, 'side', 'high' );
 
 
180
  }
181
  }
182
  }
176
  */
177
  $post_title = apply_filters( 'wpmem_admin_' . $key . '_meta_title', sprintf( __( '%s Restriction', 'wp-members' ), $post_type->labels->singular_name ) );
178
 
179
+ add_meta_box( 'wpmem-block-meta-id', $post_title, 'wpmem_block_meta', $key, 'side', 'high'
180
+ // ,array( '__back_compat_meta_box' => true, ) // @todo Convert to Block and declare this for backwards compat ONLY!
181
+ );
182
  }
183
  }
184
  }
admin/tab-about.php CHANGED
@@ -63,7 +63,7 @@ function wpmem_a_build_about_tab() { ?>
63
  <p>If you want to make the most out of WP-Members, subscribing to Priority Support is a great way to do that. You'll not only get priority email support, but also a member-only forum
64
  and access to the member's only site with a code library of tutorials and customizations. You can also subscribe to the WP-Members Pro Bundle to get everything Priority Support has to offer
65
  PLUS all of the premium extensions as well.<br /><br />
66
- <a href="https://rkt.bz/join"><strong>Check out the Premium Support options here</strong></a>.</p>
67
  <h2>Premium Extensions</h2>
68
  <table>
69
  <tr>
63
  <p>If you want to make the most out of WP-Members, subscribing to Priority Support is a great way to do that. You'll not only get priority email support, but also a member-only forum
64
  and access to the member's only site with a code library of tutorials and customizations. You can also subscribe to the WP-Members Pro Bundle to get everything Priority Support has to offer
65
  PLUS all of the premium extensions as well.<br /><br />
66
+ <a href="https://rkt.bz/join"><strong>Check out the Premium Support options here</strong></a>.<br /><strong>NEW!! <a href="https://rkt.bz/121">One-on-one Consulting Now Available</a>!</strong></p>
67
  <h2>Premium Extensions</h2>
68
  <table>
69
  <tr>
admin/tab-options.php CHANGED
@@ -63,8 +63,8 @@ function wpmem_a_build_options() {
63
  // Build an array of post types
64
  $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
65
  $post_arr = array(
66
- 'post' => 'Posts',
67
- 'page' => 'Pages',
68
  );
69
  if ( $post_types ) {
70
  foreach ( $post_types as $post_type ) {
@@ -205,7 +205,7 @@ function wpmem_a_build_options() {
205
  <label><?php _e( 'Enable CAPTCHA', 'wp-members' ); ?></label>
206
  <?php $captcha = array( __( 'None', 'wp-members' ) . '|0' );
207
  if ( 1 == $wpmem->captcha ) {
208
- $wpmem->captcha = 3; // @todo reCAPTCHA v1 is fully obsolete. Change it to v2.
209
  }
210
  $captcha[] = __( 'reCAPTCHA', 'wp-members' ) . '|3';
211
  $captcha[] = __( 'Really Simple CAPTCHA', 'wp-members' ) . '|2';
63
  // Build an array of post types
64
  $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
65
  $post_arr = array(
66
+ 'post' => __( 'Posts' ),
67
+ 'page' => __( 'Pages' ),
68
  );
69
  if ( $post_types ) {
70
  foreach ( $post_types as $post_type ) {
205
  <label><?php _e( 'Enable CAPTCHA', 'wp-members' ); ?></label>
206
  <?php $captcha = array( __( 'None', 'wp-members' ) . '|0' );
207
  if ( 1 == $wpmem->captcha ) {
208
+ $wpmem->captcha = 3; // reCAPTCHA v1 is fully obsolete. Change it to v2.
209
  }
210
  $captcha[] = __( 'reCAPTCHA', 'wp-members' ) . '|3';
211
  $captcha[] = __( 'Really Simple CAPTCHA', 'wp-members' ) . '|2';
admin/users.php CHANGED
@@ -21,8 +21,8 @@
21
  * - wpmem_users_views
22
  * - wpmem_add_user_column
23
  * - wpmem_add_user_column_content
24
- * - wpmem_a_activate_user
25
- * - wpmem_a_deactivate_user
26
  * - wpmem_a_pre_user_query
27
  * - wpmem_set_new_user_non_active
28
  * - wpmem_set_activated_user
@@ -40,26 +40,26 @@ if ( ! defined( 'ABSPATH' ) ) {
40
  *
41
  * @since 2.8.2
42
  */
43
- function wpmem_bulk_user_action() {
44
  global $wpmem; ?>
45
  <script type="text/javascript">
46
- jQuery(document).ready(function() {
 
47
  <?php if( $wpmem->mod_reg == 1 ) { ?>
48
- jQuery('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action']");
49
- jQuery('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action']");
50
  <?php } ?>
51
- jQuery('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action']");
52
  <?php if( $wpmem->mod_reg == 1 ) { ?>
53
- jQuery('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action2']");
54
- jQuery('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action2']");
55
  <?php } ?>
56
- jQuery('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action2']");
57
- jQuery('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
58
  });
59
  </script><?php
60
  }
61
 
62
-
63
  /**
64
  * Function to add activate link to the user row action.
65
  *
@@ -76,15 +76,19 @@ function wpmem_insert_activate_link( $actions, $user_object ) {
76
  $var = get_user_meta( $user_object->ID, 'active', true );
77
 
78
  if ( $var != 1 ) {
79
- $url = add_query_arg( array( 'action' => 'activate-single', 'user' => $user_object->ID ), "users.php" );
80
- $url = wp_nonce_url( $url, 'activate-user' );
81
- $actions['activate'] = '<a href="' . $url . '">' . __( 'Activate', 'wp-members' ) . '</a>';
 
 
82
  }
 
 
 
83
  }
84
  return $actions;
85
  }
86
 
87
-
88
  /**
89
  * Function to handle bulk actions at page load.
90
  *
@@ -128,6 +132,7 @@ function wpmem_users_page_load() {
128
  switch ( $action ) {
129
 
130
  case 'activate':
 
131
 
132
  // Validate nonce.
133
  check_admin_referer( 'bulk-users' );
@@ -142,12 +147,15 @@ function wpmem_users_page_load() {
142
  foreach ( $users as $user ) {
143
  $user = filter_var( $user, FILTER_VALIDATE_INT );
144
  // Check to see if the user is already activated, if not, activate.
145
- if ( ! get_user_meta( $user, 'active', true ) ) {
146
- wpmem_a_activate_user( $user, $chk_pass );
147
- $x++;
 
148
  }
 
 
149
  }
150
- $msg = urlencode( sprintf( __( '%s users activated', 'wp-members' ), $x ) );
151
 
152
  } else {
153
  $msg = urlencode( __( 'No users selected', 'wp-members' ) );
@@ -158,6 +166,7 @@ function wpmem_users_page_load() {
158
  break;
159
 
160
  case 'activate-single':
 
161
 
162
  // Validate nonce.
163
  check_admin_referer( 'activate-user' );
@@ -166,21 +175,19 @@ function wpmem_users_page_load() {
166
  $users = $_REQUEST['user'];
167
 
168
  // Check to see if the user is already activated, if not, activate.
169
- if ( ! get_user_meta( $users, 'active', true ) ) {
170
-
171
- wpmem_a_activate_user( $users, $chk_pass );
172
-
173
- // Get the user data.
174
  $user_info = get_userdata( $users );
175
-
176
- // Set the return message.
177
  $msg = urlencode( sprintf( __( "%s activated", 'wp-members' ), $user_info->user_login ) );
178
-
 
 
 
 
 
179
  } else {
180
-
181
  // Set the return message.
182
  $msg = urlencode( __( "That user is already active", 'wp-members' ) );
183
-
184
  }
185
  $sendback = add_query_arg( array( 'activated' => $msg ), $sendback );
186
  break;
@@ -215,7 +222,6 @@ function wpmem_users_page_load() {
215
 
216
  }
217
 
218
-
219
  /**
220
  * Function to echo admin update message.
221
  *
@@ -234,7 +240,6 @@ function wpmem_users_admin_notices() {
234
  }
235
  }
236
 
237
-
238
  /**
239
  * Function to add user views to the top list.
240
  *
@@ -334,7 +339,6 @@ function wpmem_users_views( $views ) {
334
  return $views;
335
  }
336
 
337
-
338
  /**
339
  * Function to add custom user columns to the user table.
340
  *
@@ -366,7 +370,6 @@ function wpmem_add_user_column( $columns ) {
366
  return $columns;
367
  }
368
 
369
-
370
  /**
371
  * Function to add the user content to the custom column.
372
  *
@@ -419,7 +422,6 @@ function wpmem_add_user_column_content( $value, $column_name, $user_id ) {
419
  return $value;
420
  }
421
 
422
-
423
  /**
424
  * Activates a user.
425
  *
@@ -430,12 +432,13 @@ function wpmem_add_user_column_content( $value, $column_name, $user_id ) {
430
  *
431
  * @since 2.4
432
  * @since 3.1.6 Dependencies now loaded by object.
 
433
  *
434
  * @param int $user_id
435
  * @param bool $chk_pass
436
  * @uses $wpdb WordPress Database object.
437
  */
438
- function wpmem_a_activate_user( $user_id, $chk_pass = false ) {
439
 
440
  global $wpmem;
441
 
@@ -478,7 +481,6 @@ function wpmem_a_activate_user( $user_id, $chk_pass = false ) {
478
  return;
479
  }
480
 
481
-
482
  /**
483
  * Deactivates a user.
484
  *
@@ -486,10 +488,11 @@ function wpmem_a_activate_user( $user_id, $chk_pass = false ) {
486
  * preventing login when registration is moderated.
487
  *
488
  * @since 2.7.1
 
489
  *
490
  * @param int $user_id
491
  */
492
- function wpmem_a_deactivate_user( $user_id ) {
493
  update_user_meta( $user_id, 'active', 0 );
494
 
495
  /**
@@ -502,7 +505,6 @@ function wpmem_a_deactivate_user( $user_id ) {
502
  do_action( 'wpmem_user_deactivated', $user_id );
503
  }
504
 
505
-
506
  /**
507
  * Adjusts user query based on custom views.
508
  *
@@ -553,7 +555,6 @@ function wpmem_a_pre_user_query( $user_search ) {
553
  $user_search->query_where = str_replace( 'WHERE 1=1', $replace_query, $user_search->query_where );
554
  }
555
 
556
-
557
  /**
558
  * Use wpmem_post_register_data to set the user_status field to 2 using wp_update_user.
559
  * http://codex.wordpress.org/Function_Reference/wp_update_user
@@ -566,7 +567,6 @@ function wpmem_set_new_user_non_active( $fields ) {
566
  return;
567
  }
568
 
569
-
570
  /**
571
  * Use wpmem_user_activated to set the user_status field to 0 using wp_update_user.
572
  *
@@ -578,7 +578,6 @@ function wpmem_set_activated_user( $user_id ) {
578
  return;
579
  }
580
 
581
-
582
  /**
583
  * Use wpmem_user_deactivated to set the user_status field to 2 using wp_update_user.
584
  *
@@ -590,7 +589,6 @@ function wpmem_set_deactivated_user( $user_id ) {
590
  return;
591
  }
592
 
593
-
594
  /**
595
  * Updates the user_status value in the wp_users table.
596
  *
21
  * - wpmem_users_views
22
  * - wpmem_add_user_column
23
  * - wpmem_add_user_column_content
24
+ * - wpmem_activate_user
25
+ * - wpmem_deactivate_user
26
  * - wpmem_a_pre_user_query
27
  * - wpmem_set_new_user_non_active
28
  * - wpmem_set_activated_user
40
  *
41
  * @since 2.8.2
42
  */
43
+ function wpmem_bulk_user_action() {
44
  global $wpmem; ?>
45
  <script type="text/javascript">
46
+ var $j = jQuery.noConflict();
47
+ $j(document).ready(function() {
48
  <?php if( $wpmem->mod_reg == 1 ) { ?>
49
+ $j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action']");
50
+ $j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action']");
51
  <?php } ?>
52
+ $j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action']");
53
  <?php if( $wpmem->mod_reg == 1 ) { ?>
54
+ $j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action2']");
55
+ $j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action2']");
56
  <?php } ?>
57
+ $j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action2']");
58
+ $j('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
59
  });
60
  </script><?php
61
  }
62
 
 
63
  /**
64
  * Function to add activate link to the user row action.
65
  *
76
  $var = get_user_meta( $user_object->ID, 'active', true );
77
 
78
  if ( $var != 1 ) {
79
+ $action = 'activate';
80
+ $term = __( 'Activate', 'wp-members' );
81
+ } elseif ( 1 == $var ) {
82
+ $action = 'deactivate';
83
+ $term = __( 'Deactivate', 'wp-members' );
84
  }
85
+ $url = add_query_arg( array( 'action' => $action . '-single', 'user' => $user_object->ID ), "users.php" );
86
+ $url = wp_nonce_url( $url, 'activate-user' );
87
+ $actions[ $action ] = '<a href="' . $url . '">' . $term . '</a>';
88
  }
89
  return $actions;
90
  }
91
 
 
92
  /**
93
  * Function to handle bulk actions at page load.
94
  *
132
  switch ( $action ) {
133
 
134
  case 'activate':
135
+ case 'deactivate':
136
 
137
  // Validate nonce.
138
  check_admin_referer( 'bulk-users' );
147
  foreach ( $users as $user ) {
148
  $user = filter_var( $user, FILTER_VALIDATE_INT );
149
  // Check to see if the user is already activated, if not, activate.
150
+ if ( 'activate' == $action && 1 != get_user_meta( $user, 'active', true ) ) {
151
+ wpmem_activate_user( $user, $chk_pass );
152
+ } elseif( 'deactivate' == $action ) {
153
+ wpmem_deactivate_user( $user );
154
  }
155
+
156
+ $x++;
157
  }
158
+ $msg = ( 'activate' == $action ) ? urlencode( sprintf( __( '%s users activated', 'wp-members' ), $x ) ) : urlencode( sprintf( __( '%s users deactivated', 'wp-members' ), $x ) );
159
 
160
  } else {
161
  $msg = urlencode( __( 'No users selected', 'wp-members' ) );
166
  break;
167
 
168
  case 'activate-single':
169
+ case 'deactivate-single':
170
 
171
  // Validate nonce.
172
  check_admin_referer( 'activate-user' );
175
  $users = $_REQUEST['user'];
176
 
177
  // Check to see if the user is already activated, if not, activate.
178
+ if ( 'activate-single' == $action && 1 != get_user_meta( $users, 'active', true ) ) {
179
+ wpmem_activate_user( $users, $chk_pass );
 
 
 
180
  $user_info = get_userdata( $users );
 
 
181
  $msg = urlencode( sprintf( __( "%s activated", 'wp-members' ), $user_info->user_login ) );
182
+
183
+ } elseif ( 'deactivate-single' == $action ) {
184
+ wpmem_deactivate_user( $users );
185
+ $user_info = get_userdata( $users );
186
+ $msg = urlencode( sprintf( __( "%s deactivated", 'wp-members' ), $user_info->user_login ) );
187
+
188
  } else {
 
189
  // Set the return message.
190
  $msg = urlencode( __( "That user is already active", 'wp-members' ) );
 
191
  }
192
  $sendback = add_query_arg( array( 'activated' => $msg ), $sendback );
193
  break;
222
 
223
  }
224
 
 
225
  /**
226
  * Function to echo admin update message.
227
  *
240
  }
241
  }
242
 
 
243
  /**
244
  * Function to add user views to the top list.
245
  *
339
  return $views;
340
  }
341
 
 
342
  /**
343
  * Function to add custom user columns to the user table.
344
  *
370
  return $columns;
371
  }
372
 
 
373
  /**
374
  * Function to add the user content to the custom column.
375
  *
422
  return $value;
423
  }
424
 
 
425
  /**
426
  * Activates a user.
427
  *
432
  *
433
  * @since 2.4
434
  * @since 3.1.6 Dependencies now loaded by object.
435
+ * @since 3.2.4 Renamed from wpmem_a_activate_user().
436
  *
437
  * @param int $user_id
438
  * @param bool $chk_pass
439
  * @uses $wpdb WordPress Database object.
440
  */
441
+ function wpmem_activate_user( $user_id, $chk_pass = false ) {
442
 
443
  global $wpmem;
444
 
481
  return;
482
  }
483
 
 
484
  /**
485
  * Deactivates a user.
486
  *
488
  * preventing login when registration is moderated.
489
  *
490
  * @since 2.7.1
491
+ * @since 3.2.4 Renamed from wpmem_a_deactivate_user().
492
  *
493
  * @param int $user_id
494
  */
495
+ function wpmem_deactivate_user( $user_id ) {
496
  update_user_meta( $user_id, 'active', 0 );
497
 
498
  /**
505
  do_action( 'wpmem_user_deactivated', $user_id );
506
  }
507
 
 
508
  /**
509
  * Adjusts user query based on custom views.
510
  *
555
  $user_search->query_where = str_replace( 'WHERE 1=1', $replace_query, $user_search->query_where );
556
  }
557
 
 
558
  /**
559
  * Use wpmem_post_register_data to set the user_status field to 2 using wp_update_user.
560
  * http://codex.wordpress.org/Function_Reference/wp_update_user
567
  return;
568
  }
569
 
 
570
  /**
571
  * Use wpmem_user_activated to set the user_status field to 0 using wp_update_user.
572
  *
578
  return;
579
  }
580
 
 
581
  /**
582
  * Use wpmem_user_deactivated to set the user_status field to 2 using wp_update_user.
583
  *
589
  return;
590
  }
591
 
 
592
  /**
593
  * Updates the user_status value in the wp_users table.
594
  *
inc/api-email.php CHANGED
@@ -16,12 +16,13 @@
16
  /**
17
  * Returns the wp_mail from address (if set).
18
  *
19
- * @since 3.2.3
 
20
  *
21
  * @global object $wpmem
22
  * @return string $wpmem_mail_from|$email
23
  */
24
- function wpmem_email_from() {
25
  global $wpmem;
26
  return $wpmem->email->from;
27
  }
@@ -29,12 +30,13 @@ function wpmem_email_from() {
29
  /**
30
  * Returns the wp_mail from name (if set).
31
  *
32
- * @since 3.2.3
 
33
  *
34
  * @global object $wpmem
35
  * @return string $wpmem_mail_from_name|$name
36
  */
37
- function wpmem_email_from_name() {
38
  global $wpmem;
39
  return $wpmem->email->from_name;
40
  }
16
  /**
17
  * Returns the wp_mail from address (if set).
18
  *
19
+ * @since 2.7
20
+ * @since 3.1 Converted to use email var in object.
21
  *
22
  * @global object $wpmem
23
  * @return string $wpmem_mail_from|$email
24
  */
25
+ function wpmem_mail_from() {
26
  global $wpmem;
27
  return $wpmem->email->from;
28
  }
30
  /**
31
  * Returns the wp_mail from name (if set).
32
  *
33
+ * @since 2.7
34
+ * @since 3.1 Converted to use email var in object.
35
  *
36
  * @global object $wpmem
37
  * @return string $wpmem_mail_from_name|$name
38
  */
39
+ function wpmem_mail_from_name() {
40
  global $wpmem;
41
  return $wpmem->email->from_name;
42
  }
inc/api-forms.php CHANGED
@@ -122,6 +122,7 @@ function wpmem_form_field( $name, $type=null, $value=null, $valtochk=null, $clas
122
  * @type string $meta_key
123
  * @type string $label
124
  * @type string $type
 
125
  * @type string $class (optional)
126
  * @type string $required (optional)
127
  * @type string $req_mark (optional)
122
  * @type string $meta_key
123
  * @type string $label
124
  * @type string $type
125
+ * @type string $id (optional)
126
  * @type string $class (optional)
127
  * @type string $required (optional)
128
  * @type string $req_mark (optional)
inc/api-users.php CHANGED
@@ -41,8 +41,7 @@ function wpmem_user_has_role( $role, $user_id = false ) {
41
  $has_role = false;
42
  if ( $user_id ) {
43
  $user = get_userdata( $user_id );
44
- }
45
- if ( is_user_logged_in() && ! $user_id ) {
46
  $user = ( isset( $current_user ) ) ? $current_user : wp_get_current_user();
47
  }
48
  if ( is_array( $role ) ) {
@@ -153,7 +152,7 @@ function wpmem_user_has_access( $product, $user_id = false ) {
153
  * @since 3.2.3
154
  *
155
  * @global object $wpmem
156
- * @param string $product
157
  * @param int $user_id
158
  * @return bool $result
159
  */
@@ -189,4 +188,99 @@ function wpmem_set_as_logged_in( $user_id ) {
189
  global $wpmem;
190
  $wpmem->user->set_as_logged_in( $user_id );
191
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  // End of file.
41
  $has_role = false;
42
  if ( $user_id ) {
43
  $user = get_userdata( $user_id );
44
+ } else {
 
45
  $user = ( isset( $current_user ) ) ? $current_user : wp_get_current_user();
46
  }
47
  if ( is_array( $role ) ) {
152
  * @since 3.2.3
153
  *
154
  * @global object $wpmem
155
+ * @param string $product The meta key of the product.
156
  * @param int $user_id
157
  * @return bool $result
158
  */
188
  global $wpmem;
189
  $wpmem->user->set_as_logged_in( $user_id );
190
  }
191
+
192
+ if ( ! function_exists( 'wpmem_login' ) ):
193
+ /**
194
+ * Logs in the user.
195
+ *
196
+ * Logs in the the user using wp_signon (since 2.5.2). If login is
197
+ * successful, it will set a cookie using wp_set_auth_cookie (since 2.7.7),
198
+ * then it redirects and exits; otherwise "loginfailed" is returned.
199
+ *
200
+ * @since 0.1.0
201
+ * @since 2.5.2 Now uses wp_signon().
202
+ * @since 2.7.7 Sets cookie using wp_set_auth_cookie().
203
+ * @since 3.0.0 Removed wp_set_auth_cookie(), this already happens in wp_signon().
204
+ * @since 3.1.7 Now a wrapper for login() in WP_Members_Users Class.
205
+ * @since 3.2.4 Moved to user API (could be deprecated).
206
+ *
207
+ * @global object $wpmem
208
+ * @return string Returns "loginfailed" if the login fails.
209
+ */
210
+ function wpmem_login() {
211
+ global $wpmem;
212
+ return $wpmem->user->login();
213
+ } // End of login function.
214
+ endif;
215
+
216
+ if ( ! function_exists( 'wpmem_logout' ) ):
217
+ /**
218
+ * Logs the user out then redirects.
219
+ *
220
+ * @since 2.0.0
221
+ * @since 3.1.6 Added wp_destroy_current_session(), removed nocache_headers().
222
+ * @since 3.1.7 Now a wrapper for logout() in WP_Members_Users Class.
223
+ * @since 3.2.4 Moved to user API (could be deprecated).
224
+ *
225
+ * @global object $wpmem
226
+ * @param string $redirect_to The URL to redirect to at logout.
227
+ */
228
+ function wpmem_logout( $redirect_to = false ) {
229
+ global $wpmem;
230
+ $wpmem->user->logout( $redirect_to );
231
+ }
232
+ endif;
233
+
234
+ if ( ! function_exists( 'wpmem_change_password' ) ):
235
+ /**
236
+ * Handles user password change (not reset).
237
+ *
238
+ * @since 2.1.0
239
+ * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
240
+ * @since 3.2.4 Moved to user API (could be deprecated).
241
+ *
242
+ * @global int $user_ID The WordPress user ID.
243
+ *
244
+ * @return string The value for $wpmem->regchk
245
+ */
246
+ function wpmem_change_password() {
247
+ global $wpmem;
248
+ return $wpmem->user->password_update( 'change' );
249
+ }
250
+ endif;
251
+
252
+ if ( ! function_exists( 'wpmem_reset_password' ) ):
253
+ /**
254
+ * Resets a forgotten password.
255
+ *
256
+ * @since 2.1.0
257
+ * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
258
+ * @since 3.2.4 Moved to user API (could be deprecated).
259
+ *
260
+ * @global object $wpmem The WP-Members object class.
261
+ *
262
+ * @return string The value for $wpmem->regchk
263
+ */
264
+ function wpmem_reset_password() {
265
+ global $wpmem;
266
+ return $wpmem->user->password_update( 'reset' );
267
+ }
268
+ endif;
269
+
270
+ /**
271
+ * Handles retrieving a forgotten username.
272
+ *
273
+ * @since 3.0.8
274
+ * @since 3.1.6 Dependencies now loaded by object.
275
+ * @since 3.1.8 Now a wrapper for $wpmem->retrieve_username() in WP_Members_Users Class.
276
+ * @since 3.2.4 Moved to user API (could be deprecated).
277
+ *
278
+ * @global object $wpmem The WP-Members object class.
279
+ *
280
+ * @return string $regchk The regchk value.
281
+ */
282
+ function wpmem_retrieve_username() {
283
+ global $wpmem;
284
+ return $wpmem->user->retrieve_username();
285
+ }
286
  // End of file.
inc/api-utilities.php CHANGED
@@ -16,6 +16,29 @@
16
  * @copyright 2006-2018
17
  */
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * Sets an array of user meta fields to be excluded from update/insert.
21
  *
@@ -191,4 +214,30 @@ function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
191
  function wpmem_load_dropins() {
192
  global $wpmem;
193
  $wpmem->load_dropins();
194
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  * @copyright 2006-2018
17
  */
18
 
19
+ if ( ! function_exists( 'wpmem_securify' ) ):
20
+ /**
21
+ * The Securify Content Filter.
22
+ *
23
+ * This is the primary function that picks up where wpmem() leaves off.
24
+ * Determines whether content is shown or hidden for both post and pages.
25
+ * Since 3.0, this function is a wrapper for $wpmem->do_securify().
26
+ *
27
+ * @since 2.0.0
28
+ * @since 3.0.0 Now a wrapper for $wpmem->do_securify().
29
+ * @since 3.2.4 Moved to utility API (could be deprecated).
30
+ *
31
+ * @global object $wpmem The WP-Members object class.
32
+ *
33
+ * @param string $content Content of the current post.
34
+ * @return string $content Content of the current post or replaced content if post is blocked and user is not logged in.
35
+ */
36
+ function wpmem_securify( $content = null ) {
37
+ global $wpmem;
38
+ return $wpmem->do_securify( $content );
39
+ }
40
+ endif;
41
+
42
  /**
43
  * Sets an array of user meta fields to be excluded from update/insert.
44
  *
214
  function wpmem_load_dropins() {
215
  global $wpmem;
216
  $wpmem->load_dropins();
217
+ }
218
+
219
+ /**
220
+ * Display a localized date based on the WP date format setting.
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
+ *
236
+ * @since 3.2.4
237
+ *
238
+ * @param arrag $args
239
+ */
240
+ $args = apply_filters( 'wpmem_format_date_args', $args );
241
+ $date = ( true === $args['localize'] ) ? date_i18n( $args['date_format'], strtotime( $args['date'] ) ) : date( $args['date_format'], strtotime( $args['date'] ) );
242
+ return $date;
243
+ }
inc/class-wp-members-forms.php CHANGED
@@ -34,6 +34,7 @@ class WP_Members_Forms {
34
  * @since 3.1.6 Added $placeholder.
35
  * @since 3.1.7 Added number type & $min, $max, $title and $pattern attributes.
36
  * @since 3.2.0 Added $id argument.
 
37
  *
38
  * @param array $args {
39
  * @type string $id
@@ -162,18 +163,21 @@ class WP_Members_Forms {
162
  case "multicheckbox":
163
  $class = ( 'textbox' == $class ) ? "checkbox" : $class;
164
  $str = '';
 
165
  foreach ( $value as $option ) {
166
  $pieces = explode( '|', $option );
167
  $values = ( empty( $compare ) ) ? array() : ( is_array( $compare ) ? $compare : explode( $delimiter, $compare ) );
168
  $chk = ( isset( $pieces[2] ) && '' == $compare ) ? $pieces[1] : '';
169
  if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
 
 
170
  $str = $str . $this->create_form_field( array(
171
- 'id' => $id . '[' . $pieces[1] . ']',
172
  'name' => $name . '[]',
173
  'type' => 'checkbox',
174
  'value' => $pieces[1],
175
  'compare' => ( in_array( $pieces[1], $values ) ) ? $pieces[1] : $chk,
176
- ) ) . "&nbsp;" . esc_html( $pieces[0] ) . "<br />\n";
177
  } else {
178
  $str = $str . '<span class="div_multicheckbox_separator">' . esc_html( $pieces[0] ) . "</span><br />\n";
179
  }
@@ -186,13 +190,14 @@ class WP_Members_Forms {
186
  $num = 1;
187
  foreach ( $value as $option ) {
188
  $pieces = explode( '|', $option );
189
- $id = $this->sanitize_class( $id . '_' . $num );
190
  if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
191
- $str = $str . "<input type=\"radio\" name=\"$name\" id=\"$id\" value=\"" . esc_attr( $pieces[1] ) . '"' . checked( $pieces[1], $compare, false ) . ( ( $required ) ? " required " : " " ) . "> " . esc_html( __( $pieces[0], 'wp-members' ) ) . "<br />\n";
 
 
192
  } else {
193
  $str = $str . '<span class="div_radio_separator">' . esc_html( __( $pieces[0], 'wp-members' ) ) . "</span><br />\n";
194
  }
195
- $num++;
196
  }
197
  break;
198
 
@@ -205,11 +210,13 @@ class WP_Members_Forms {
205
  * Create form label.
206
  *
207
  * @since 3.1.7
 
208
  *
209
  * @param array $args {
210
  * @type string $meta_key
211
- * @type string $label_text
212
  * @type string $type
 
213
  * @type string $class (optional)
214
  * @type string $required (optional)
215
  * @type string $req_mark (optional)
@@ -223,6 +230,7 @@ class WP_Members_Forms {
223
  $label = $args['label'];
224
  $type = $args['type'];
225
  $class = ( isset( $args['class'] ) ) ? $args['class'] : false;
 
226
  $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
227
  $req_mark = ( isset( $args['req_mark'] ) ) ? $args['req_mark'] : false;
228
 
@@ -231,8 +239,10 @@ class WP_Members_Forms {
231
  if ( ! $class ) {
232
  $class = ( $type == 'password' || $type == 'email' || $type == 'url' ) ? 'text' : $type;
233
  }
 
 
234
 
235
- $label = '<label for="' . esc_attr( $meta_key ) . '" class="' . $this->sanitize_class( $class ) . '">' . __( $label, 'wp-members' );
236
  $label = ( $required ) ? $label . $req_mark : $label;
237
  $label = $label . '</label>';
238
 
34
  * @since 3.1.6 Added $placeholder.
35
  * @since 3.1.7 Added number type & $min, $max, $title and $pattern attributes.
36
  * @since 3.2.0 Added $id argument.
37
+ * @since 3.2.4 Added radio group and multiple checkbox individual item labels.
38
  *
39
  * @param array $args {
40
  * @type string $id
163
  case "multicheckbox":
164
  $class = ( 'textbox' == $class ) ? "checkbox" : $class;
165
  $str = '';
166
+ $num = 1;
167
  foreach ( $value as $option ) {
168
  $pieces = explode( '|', $option );
169
  $values = ( empty( $compare ) ) ? array() : ( is_array( $compare ) ? $compare : explode( $delimiter, $compare ) );
170
  $chk = ( isset( $pieces[2] ) && '' == $compare ) ? $pieces[1] : '';
171
  if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
172
+ $id_value = esc_attr( $id . '[' . $pieces[1] . ']' );
173
+ $label = wpmem_form_label( array( 'meta_key'=>$id_value, 'label'=>esc_html( __( $pieces[0], 'wp-members' ) ), 'type'=>'radio', 'id'=>$id_value ) );
174
  $str = $str . $this->create_form_field( array(
175
+ 'id' => $id_value,
176
  'name' => $name . '[]',
177
  'type' => 'checkbox',
178
  'value' => $pieces[1],
179
  'compare' => ( in_array( $pieces[1], $values ) ) ? $pieces[1] : $chk,
180
+ ) ) . "&nbsp;" . $label . "<br />\n";
181
  } else {
182
  $str = $str . '<span class="div_multicheckbox_separator">' . esc_html( $pieces[0] ) . "</span><br />\n";
183
  }
190
  $num = 1;
191
  foreach ( $value as $option ) {
192
  $pieces = explode( '|', $option );
193
+ $id_num = $id . '_' . $num;
194
  if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
195
+ $label = wpmem_form_label( array( 'meta_key'=>esc_attr( $id_num ), 'label'=>esc_html( __( $pieces[0], 'wp-members' ) ), 'type'=>'radio', 'id'=>esc_attr( "label_" . $id_num ) ) );
196
+ $str = $str . "<input type=\"radio\" name=\"$name\" id=\"" . esc_attr( $id_num ) . "\" value=\"" . esc_attr( $pieces[1] ) . '"' . checked( $pieces[1], $compare, false ) . ( ( $required ) ? " required " : " " ) . "> $label<br />\n";
197
+ $num++;
198
  } else {
199
  $str = $str . '<span class="div_radio_separator">' . esc_html( __( $pieces[0], 'wp-members' ) ) . "</span><br />\n";
200
  }
 
201
  }
202
  break;
203
 
210
  * Create form label.
211
  *
212
  * @since 3.1.7
213
+ * @since 3.2.4 Added $id
214
  *
215
  * @param array $args {
216
  * @type string $meta_key
217
+ * @type string $label
218
  * @type string $type
219
+ * @type string $id (optional)
220
  * @type string $class (optional)
221
  * @type string $required (optional)
222
  * @type string $req_mark (optional)
230
  $label = $args['label'];
231
  $type = $args['type'];
232
  $class = ( isset( $args['class'] ) ) ? $args['class'] : false;
233
+ $id = ( isset( $args['id'] ) ) ? $args['id'] : false;
234
  $required = ( isset( $args['required'] ) ) ? $args['required'] : false;
235
  $req_mark = ( isset( $args['req_mark'] ) ) ? $args['req_mark'] : false;
236
 
239
  if ( ! $class ) {
240
  $class = ( $type == 'password' || $type == 'email' || $type == 'url' ) ? 'text' : $type;
241
  }
242
+
243
+ $id = ( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
244
 
245
+ $label = '<label for="' . esc_attr( $meta_key ) . '"' . $id . ' class="' . $this->sanitize_class( $class ) . '">' . __( $label, 'wp-members' );
246
  $label = ( $required ) ? $label . $req_mark : $label;
247
  $label = $label . '</label>';
248
 
inc/class-wp-members-products.php CHANGED
@@ -18,11 +18,58 @@ if ( ! defined( 'ABSPATH' ) ) {
18
 
19
  class WP_Members_Products {
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  public $post_meta = '_wpmem_products';
 
 
 
 
 
 
 
 
22
  public $post_stem = '_wpmem_products_';
 
 
 
 
 
 
 
 
23
  public $products = array();
24
- public $product_detail = array();
 
 
 
 
 
 
 
 
25
 
 
 
 
 
 
 
 
26
  function __construct() {
27
 
28
  $this->load_products();
@@ -30,25 +77,42 @@ class WP_Members_Products {
30
  add_filter( 'wpmem_securify', array( $this, 'product_access' ) );
31
  }
32
 
 
 
 
 
 
33
  function load_products() {
34
  global $wpdb;
35
  $sql = "SELECT ID, post_title, post_name FROM " . $wpdb->prefix . "posts WHERE post_type = 'wpmem_product' AND post_status = 'publish';";
36
  $result = $wpdb->get_results( $sql );
37
  foreach ( $result as $plan ) {
38
- $this->products[ $plan->post_name ] = $plan->post_title;
39
-
40
- $this->product_detail[ $plan->post_name ]['title'] = $plan->post_title;
41
  $post_meta = get_post_meta( $plan->ID );
42
  foreach ( $post_meta as $key => $meta ) {
43
  if ( false !== strpos( $key, 'wpmem_product' ) ) {
44
  if ( $key == 'wpmem_product_expires' ) {
45
  $meta[0] = unserialize( $meta[0] );
46
  }
47
- $this->product_detail[ $plan->post_name ][ str_replace( 'wpmem_product_', '', $key ) ] = $meta[0];
48
  }
49
  }
50
  }
51
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  /**
54
  * Sets up custom access restriction by product.
@@ -68,7 +132,7 @@ class WP_Members_Products {
68
  if ( is_user_logged_in() && wpmem_is_blocked() ) {
69
 
70
  // Get the post access products.
71
- $post_products = get_post_meta( $post->ID, $wpmem->membership->post_meta, true );
72
  // If the post is restricted to a product.
73
  if ( $post_products ) {
74
  if ( wpmem_user_has_access( $post_products ) ) {
@@ -155,7 +219,7 @@ class WP_Members_Products {
155
  'show_in_rest' => false,
156
  //'register_meta_box_cb' => '', // callback for meta box
157
  );
158
- register_post_type( 'wpmem_product', $args );
159
  }
160
 
161
  }
18
 
19
  class WP_Members_Products {
20
 
21
+ /**
22
+ * Product post type.
23
+ *
24
+ * @since 3.4.0
25
+ * @access public
26
+ * @var string
27
+ */
28
+ public $post_type = 'wpmem_product';
29
+
30
+ /**
31
+ * Product meta key.
32
+ *
33
+ * @since 3.2.0
34
+ * @access public
35
+ * @var string
36
+ */
37
  public $post_meta = '_wpmem_products';
38
+
39
+ /**
40
+ * Product meta key stem.
41
+ *
42
+ * @since 3.2.0
43
+ * @access public
44
+ * @var string
45
+ */
46
  public $post_stem = '_wpmem_products_';
47
+
48
+ /**
49
+ * Product details.
50
+ *
51
+ * @since 3.2.0
52
+ * @access public
53
+ * @var array
54
+ */
55
  public $products = array();
56
+
57
+ /**
58
+ * Product meta keyed by ID.
59
+ *
60
+ * @since 3.2.4
61
+ * @access public
62
+ * @var array
63
+ */
64
+ public $product_by_id = array();
65
 
66
+ /**
67
+ * Class constructor.
68
+ *
69
+ * @since 3.2.0
70
+ *
71
+ * @global object $wpmem
72
+ */
73
  function __construct() {
74
 
75
  $this->load_products();
77
  add_filter( 'wpmem_securify', array( $this, 'product_access' ) );
78
  }
79
 
80
+ /**
81
+ * Loads product settings.
82
+ *
83
+ * @since 3.2.0
84
+ */
85
  function load_products() {
86
  global $wpdb;
87
  $sql = "SELECT ID, post_title, post_name FROM " . $wpdb->prefix . "posts WHERE post_type = 'wpmem_product' AND post_status = 'publish';";
88
  $result = $wpdb->get_results( $sql );
89
  foreach ( $result as $plan ) {
90
+ $this->product_by_id[ $plan->ID ] = $plan->post_name;
91
+ $this->products[ $plan->post_name ]['title'] = $plan->post_title;
 
92
  $post_meta = get_post_meta( $plan->ID );
93
  foreach ( $post_meta as $key => $meta ) {
94
  if ( false !== strpos( $key, 'wpmem_product' ) ) {
95
  if ( $key == 'wpmem_product_expires' ) {
96
  $meta[0] = unserialize( $meta[0] );
97
  }
98
+ $this->products[ $plan->post_name ][ str_replace( 'wpmem_product_', '', $key ) ] = $meta[0];
99
  }
100
  }
101
  }
102
  }
103
+
104
+ /**
105
+ * Gets products assigned to a post.
106
+ *
107
+ * @since 3.2.4
108
+ *
109
+ * @param integer $post_id
110
+ * @return array $products
111
+ */
112
+ function get_post_products( $post_id ) {
113
+ $products = get_post_meta( $post_id, $this->post_meta, true );
114
+ return $products;
115
+ }
116
 
117
  /**
118
  * Sets up custom access restriction by product.
132
  if ( is_user_logged_in() && wpmem_is_blocked() ) {
133
 
134
  // Get the post access products.
135
+ $post_products = $this->get_post_products( $post->ID );
136
  // If the post is restricted to a product.
137
  if ( $post_products ) {
138
  if ( wpmem_user_has_access( $post_products ) ) {
219
  'show_in_rest' => false,
220
  //'register_meta_box_cb' => '', // callback for meta box
221
  );
222
+ register_post_type( $this->post_type, $args );
223
  }
224
 
225
  }
inc/class-wp-members-user-profile.php CHANGED
@@ -323,9 +323,9 @@ class WP_Members_User_Profile {
323
  $wpmem_activate_user = ( isset( $_POST['activate_user'] ) == '' ) ? -1 : filter_var( $_POST['activate_user'], FILTER_SANITIZE_NUMBER_INT );
324
 
325
  if ( $wpmem_activate_user == 1 ) {
326
- wpmem_a_activate_user( $user_id, $chk_pass );
327
  } elseif ( $wpmem_activate_user == 0 ) {
328
- wpmem_a_deactivate_user( $user_id );
329
  }
330
  }
331
 
@@ -342,8 +342,8 @@ class WP_Members_User_Profile {
342
  // Enable or Disable?
343
  if ( 'enable' == $product_value ) {
344
  // Does product require a role?
345
- if ( false !== $wpmem->membership->product_detail[ $product_key ]['role'] ) {
346
- wpmem_update_user_role( $user_id, $wpmem->membership->product_detail[ $product_key ]['role'], 'add' );
347
  }
348
  $wpmem->user->set_user_product( $product_key, $user_id );
349
  }
@@ -484,7 +484,7 @@ class WP_Members_User_Profile {
484
  <tr>
485
  <th><label><?php _e( 'Product Access', 'wp-members' ); ?></label></th>
486
  <td><table><?php
487
- foreach ( $wpmem->membership->products as $key => $label ) {
488
  $checked = ( $user_products && array_key_exists( $key, $user_products ) ) ? "checked" : "";
489
  echo "<tr>";
490
  echo '<td style="padding:5px 5px;">
@@ -492,7 +492,7 @@ class WP_Members_User_Profile {
492
  <option value="">----</option>
493
  <option value="enable">' . __( 'Enable', 'wp-members' ) . '</option>
494
  <option value="disable">' . __( 'Disable', 'wp-members' ) . '</option>
495
- </select></td><td style="padding:0px 0px;">' . $label . '</td>
496
  <td style="padding:0px 0px;">';
497
  if ( isset( $user_products[ $key ] ) ) {
498
  echo '<span id="wpmem_product_enabled" class="dashicons dashicons-yes"></span>';
323
  $wpmem_activate_user = ( isset( $_POST['activate_user'] ) == '' ) ? -1 : filter_var( $_POST['activate_user'], FILTER_SANITIZE_NUMBER_INT );
324
 
325
  if ( $wpmem_activate_user == 1 ) {
326
+ wpmem_activate_user( $user_id, $chk_pass );
327
  } elseif ( $wpmem_activate_user == 0 ) {
328
+ wpmem_deactivate_user( $user_id );
329
  }
330
  }
331
 
342
  // Enable or Disable?
343
  if ( 'enable' == $product_value ) {
344
  // Does product require a role?
345
+ if ( false !== $wpmem->membership->products[ $product_key ]['role'] ) {
346
+ wpmem_update_user_role( $user_id, $wpmem->membership->products[ $product_key ]['role'], 'add' );
347
  }
348
  $wpmem->user->set_user_product( $product_key, $user_id );
349
  }
484
  <tr>
485
  <th><label><?php _e( 'Product Access', 'wp-members' ); ?></label></th>
486
  <td><table><?php
487
+ foreach ( $wpmem->membership->products as $key => $value ) {
488
  $checked = ( $user_products && array_key_exists( $key, $user_products ) ) ? "checked" : "";
489
  echo "<tr>";
490
  echo '<td style="padding:5px 5px;">
492
  <option value="">----</option>
493
  <option value="enable">' . __( 'Enable', 'wp-members' ) . '</option>
494
  <option value="disable">' . __( 'Disable', 'wp-members' ) . '</option>
495
+ </select></td><td style="padding:0px 0px;">' . $value['title'] . '</td>
496
  <td style="padding:0px 0px;">';
497
  if ( isset( $user_products[ $key ] ) ) {
498
  echo '<span id="wpmem_product_enabled" class="dashicons dashicons-yes"></span>';
inc/class-wp-members-user.php CHANGED
@@ -68,6 +68,8 @@ class WP_Members_User {
68
  */
69
  function login() {
70
 
 
 
71
  if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
72
  $user_name = sanitize_user( $_POST['log'] );
73
  $user = get_user_by( 'login', $user_name );
@@ -80,6 +82,7 @@ class WP_Members_User {
80
  $user = wp_signon( array(), is_ssl() );
81
 
82
  if ( is_wp_error( $user ) ) {
 
83
  return "loginfailed";
84
  } else {
85
  $redirect_to = wpmem_get( 'redirect_to', false );
@@ -503,13 +506,13 @@ class WP_Members_User {
503
  foreach ( $product as $prod ) {
504
  if ( isset( $this->access[ $prod ] ) ) {
505
  // Is this an expiration product?
506
- if ( isset( $wpmem->membership->product_detail[ $prod ]['expires'][0] ) && ! is_bool( $this->access[ $prod ] ) ) {
507
  if ( $this->is_current( $this->access[ $prod ] ) ) {
508
  $access = true;
509
  break;
510
  }
511
- } elseif ( '' != $wpmem->membership->product_detail[ $prod ]['role'] ) {
512
- if ( $this->access[ $prod ] && wpmem_user_has_role( $wpmem->membership->product_detail[ $prod ]['role'] ) ) {
513
  $access = true;
514
  break;
515
  }
@@ -573,10 +576,10 @@ class WP_Members_User {
573
  }
574
 
575
  // Convert date to add.
576
- $expires = ( isset( $wpmem->membership->product_detail[ $product ]['expires'] ) ) ? $wpmem->membership->product_detail[ $product ]['expires'] : false;
577
 
578
  if ( is_array( $expires ) ) {
579
- $add_date = explode( "|", $wpmem->membership->product_detail[ $product ]['expires'][0] );
580
  $add = ( 1 < $add_date[0] ) ? $add_date[0] . " " . $add_date[1] . "s" : $add_date[0] . " " . $add_date[1];
581
  $user_products[ $product ] = ( isset( $user_products[ $product ] ) ) ? date( 'Y-m-d H:i:s', strtotime( $add, strtotime( $user_products[ $product ] ) ) ) : date( 'Y-m-d H:i:s', strtotime( $add ) );
582
  } else {
68
  */
69
  function login() {
70
 
71
+ global $wpmem;
72
+
73
  if ( ! empty( $_POST['log'] ) && ! force_ssl_admin() ) {
74
  $user_name = sanitize_user( $_POST['log'] );
75
  $user = get_user_by( 'login', $user_name );
82
  $user = wp_signon( array(), is_ssl() );
83
 
84
  if ( is_wp_error( $user ) ) {
85
+ $wpmem->error = $user->get_error_message();
86
  return "loginfailed";
87
  } else {
88
  $redirect_to = wpmem_get( 'redirect_to', 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
  }
576
  }
577
 
578
  // Convert date to add.
579
+ $expires = ( isset( $wpmem->membership->products[ $product ]['expires'] ) ) ? $wpmem->membership->products[ $product ]['expires'] : false;
580
 
581
  if ( is_array( $expires ) ) {
582
+ $add_date = explode( "|", $wpmem->membership->products[ $product ]['expires'][0] );
583
  $add = ( 1 < $add_date[0] ) ? $add_date[0] . " " . $add_date[1] . "s" : $add_date[0] . " " . $add_date[1];
584
  $user_products[ $product ] = ( isset( $user_products[ $product ] ) ) ? date( 'Y-m-d H:i:s', strtotime( $add, strtotime( $user_products[ $product ] ) ) ) : date( 'Y-m-d H:i:s', strtotime( $add ) );
585
  } else {
inc/class-wp-members.php CHANGED
@@ -1,1626 +1,1626 @@
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 . 'wp-members-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' ); // @todo Should be deprecated, functions are obsolete. Schedule for 3.3
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' ) );
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->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.
inc/core.php DELETED
@@ -1,156 +0,0 @@
1
- <?php
2
- /**
3
- * WP-Members Core Functions
4
- *
5
- * Handles primary functions that are carried out in most
6
- * situations. Includes commonly used utility functions.
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
- * @author Chad Butler
15
- * @copyright 2006-2018
16
- */
17
-
18
- // Exit if accessed directly.
19
- if ( ! defined( 'ABSPATH' ) ) {
20
- exit();
21
- }
22
-
23
- /**
24
- * The Main Action Function.
25
- *
26
- * Does actions required at initialization prior to headers being sent.
27
- * Since 3.0, this function is a wrapper for $wpmem->get_action().
28
- *
29
- * @since 0.1.0
30
- * @since 3.0.0 Now a wrapper for $wpmem->get_action().
31
- *
32
- * @global object $wpmem The WP-Members object class.
33
- */
34
- function wpmem() {
35
- global $wpmem;
36
- $wpmem->get_action();
37
- }
38
-
39
-
40
- if ( ! function_exists( 'wpmem_securify' ) ):
41
- /**
42
- * The Securify Content Filter.
43
- *
44
- * This is the primary function that picks up where wpmem() leaves off.
45
- * Determines whether content is shown or hidden for both post and pages.
46
- * Since 3.0, this function is a wrapper for $wpmem->do_securify().
47
- *
48
- * @since 2.0.0
49
- * @since 3.0.0 Now a wrapper for $wpmem->do_securify().
50
- *
51
- * @global object $wpmem The WP-Members object class.
52
- *
53
- * @param string $content Content of the current post.
54
- * @return string $content Content of the current post or replaced content if post is blocked and user is not logged in.
55
- */
56
- function wpmem_securify( $content = null ) {
57
- global $wpmem;
58
- return $wpmem->do_securify( $content );
59
- }
60
- endif;
61
-
62
-
63
- if ( ! function_exists( 'wpmem_login' ) ):
64
- /**
65
- * Logs in the user.
66
- *
67
- * Logs in the the user using wp_signon (since 2.5.2). If login is
68
- * successful, it will set a cookie using wp_set_auth_cookie (since 2.7.7),
69
- * then it redirects and exits; otherwise "loginfailed" is returned.
70
- *
71
- * @since 0.1.0
72
- * @since 2.5.2 Now uses wp_signon().
73
- * @since 2.7.7 Sets cookie using wp_set_auth_cookie().
74
- * @since 3.0.0 Removed wp_set_auth_cookie(), this already happens in wp_signon().
75
- * @since 3.1.7 Now a wrapper for login() in WP_Members_Users Class.
76
- *
77
- * @global object $wpmem
78
- * @return string Returns "loginfailed" if the login fails.
79
- */
80
- function wpmem_login() {
81
- global $wpmem;
82
- return $wpmem->user->login();
83
- } // End of login function.
84
- endif;
85
-
86
-
87
- if ( ! function_exists( 'wpmem_logout' ) ):
88
- /**
89
- * Logs the user out then redirects.
90
- *
91
- * @since 2.0.0
92
- * @since 3.1.6 Added wp_destroy_current_session(), removed nocache_headers().
93
- * @since 3.1.7 Now a wrapper for logout() in WP_Members_Users Class.
94
- *
95
- * @global object $wpmem
96
- * @param string $redirect_to The URL to redirect to at logout.
97
- */
98
- function wpmem_logout( $redirect_to = false ) {
99
- global $wpmem;
100
- $wpmem->user->logout( $redirect_to );
101
- }
102
- endif;
103
-
104
-
105
- if ( ! function_exists( 'wpmem_change_password' ) ):
106
- /**
107
- * Handles user password change (not reset).
108
- *
109
- * @since 2.1.0
110
- * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
111
- *
112
- * @global int $user_ID The WordPress user ID.
113
- *
114
- * @return string The value for $wpmem->regchk
115
- */
116
- function wpmem_change_password() {
117
- global $wpmem;
118
- return $wpmem->user->password_update( 'change' );
119
- }
120
- endif;
121
-
122
-
123
- if ( ! function_exists( 'wpmem_reset_password' ) ):
124
- /**
125
- * Resets a forgotten password.
126
- *
127
- * @since 2.1.0
128
- * @since 3.1.7 Now a wrapper for password_update() in WP_Members_Users Class.
129
- *
130
- * @global object $wpmem The WP-Members object class.
131
- *
132
- * @return string The value for $wpmem->regchk
133
- */
134
- function wpmem_reset_password() {
135
- global $wpmem;
136
- return $wpmem->user->password_update( 'reset' );
137
- }
138
- endif;
139
-
140
- /**
141
- * Handles retrieving a forgotten username.
142
- *
143
- * @since 3.0.8
144
- * @since 3.1.6 Dependencies now loaded by object.
145
- * @since 3.1.8 Now a wrapper for $wpmem->retrieve_username() in WP_Members_Users Class.
146
- *
147
- * @global object $wpmem The WP-Members object class.
148
- *
149
- * @return string $regchk The regchk value.
150
- */
151
- function wpmem_retrieve_username() {
152
- global $wpmem;
153
- return $wpmem->user->retrieve_username();
154
- }
155
-
156
- // End of file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/deprecated.php CHANGED
@@ -1194,3 +1194,40 @@ function wpmem_check_activated( $user, $username, $password ) {
1194
  return $user;
1195
  }
1196
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1194
  return $user;
1195
  }
1196
  endif;
1197
+
1198
+ /**
1199
+ * Activates a user.
1200
+ *
1201
+ * If registration is moderated, sets the activated flag
1202
+ * in the usermeta. Flag prevents login when $wpmem->mod_reg
1203
+ * is true (1). Function is fired from bulk user edit or
1204
+ * user profile update.
1205
+ *
1206
+ * @since 2.4
1207
+ * @since 3.1.6 Dependencies now loaded by object.
1208
+ * @deprecated 3.2.4 Use wpmem_activate_user().
1209
+ *
1210
+ * @param int $user_id
1211
+ * @param bool $chk_pass
1212
+ * @uses $wpdb WordPress Database object.
1213
+ */
1214
+ function wpmem_a_activate_user( $user_id, $chk_pass = false ) {
1215
+ wpmem_write_log( "wpmem_a_activate_user() is deprecated as of WP-Members 3.2.4. Use wpmem_activate_user instead" );
1216
+ wpmem_activate_user( $user_id, $chk_pass );
1217
+ }
1218
+
1219
+ /**
1220
+ * Deactivates a user.
1221
+ *
1222
+ * Reverses the active flag from the activation process
1223
+ * preventing login when registration is moderated.
1224
+ *
1225
+ * @since 2.7.1
1226
+ * @depreacted 3.2.4 Use wpmem_deactivate_user().
1227
+ *
1228
+ * @param int $user_id
1229
+ */
1230
+ function wpmem_a_deactivate_user( $user_id ) {
1231
+ wpmem_write_log( "wpmem_a_deactivate_user() is deprecated as of WP-Members 3.2.4. Use wpmem_deactivate_user instead" );
1232
+ wpmem_deactivate_user( $user_id );
1233
+ }
inc/dialogs.php CHANGED
@@ -51,7 +51,7 @@ function wpmem_inc_loginfailed() {
51
  'heading' => $wpmem->get_text( 'login_failed_heading' ),
52
  'heading_after' => '</h2>',
53
  'p_before' => '<p>',
54
- 'message' => $wpmem->get_text( 'login_failed' ),
55
  'p_after' => '</p>',
56
  'link' => '<a href="' . esc_url( $_SERVER['REQUEST_URI'] ) . '">' . $wpmem->get_text( 'login_failed_link' ) . '</a>',
57
  );
51
  'heading' => $wpmem->get_text( 'login_failed_heading' ),
52
  'heading_after' => '</h2>',
53
  'p_before' => '<p>',
54
+ 'message' => $wpmem->get_text( 'login_failed' ), // @todo $wpmem->error
55
  'p_after' => '</p>',
56
  'link' => '<a href="' . esc_url( $_SERVER['REQUEST_URI'] ) . '">' . $wpmem->get_text( 'login_failed_link' ) . '</a>',
57
  );
wp-members-install.php → inc/install.php RENAMED
@@ -1,606 +1,606 @@
1
- <?php
2
- /**
3
- * WP-Members Installation Functions
4
- *
5
- * Functions to install and upgrade WP-Members.
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
18
- * - wpmem_upgrade_settings
19
- * - wpmem_upgrade_email
20
- * - wpmem_upgrade_dialogs
21
- * - wpmem_downgrade_dialogs
22
- * - wpmem_upgrade_captcha
23
- */
24
-
25
- // Exit if accessed directly.
26
- if ( ! defined( 'ABSPATH' ) ) {
27
- exit();
28
- }
29
-
30
- /**
31
- * Installs or upgrades the plugin.
32
- *
33
- * @since 2.2.2
34
- * @since 3.1.6 Returns $wpmem_settings.
35
- *
36
- * @return array $wpmem_settings
37
- */
38
- function wpmem_do_install() {
39
-
40
- /*
41
- * If you need to force an install, set $chk_force = true.
42
- *
43
- * Important notes:
44
- *
45
- * 1. This will override any settings you already have for any of the plugin settings.
46
- * 2. This will not effect any WP settings or registered users.
47
- */
48
-
49
- $chk_force = false;
50
-
51
- if ( ! get_option( 'wpmembers_settings' ) || $chk_force == true ) {
52
-
53
- // New install.
54
- $wpmem_settings = wpmem_install_settings();
55
- wpmem_install_fields();
56
- wpmem_install_dialogs();
57
- wpmem_append_email();
58
- update_option( 'wpmembers_style', plugin_dir_url ( __FILE__ ) . 'css/generic-no-float.css', '', 'yes' );
59
-
60
- } else {
61
-
62
- // Upgrade.
63
- $wpmem_settings = wpmem_upgrade_settings();
64
- wpmem_upgrade_captcha();
65
- wpmem_append_email();
66
- wpmem_upgrade_fields();
67
-
68
- }
69
-
70
- return $wpmem_settings;
71
- }
72
-
73
-
74
- /**
75
- * Updates the existing settings if doing an update.
76
- *
77
- * @since 3.0.0
78
- * @since 3.1.0 Changed from wpmem_update_settings() to wpmem_upgrade_settings().
79
- *
80
- * @return array $wpmem_newsettings
81
- */
82
- function wpmem_upgrade_settings() {
83
-
84
- // Update dialogs for 3.1.1
85
- wpmem_upgrade_dialogs();
86
-
87
- $wpmem_settings = get_option( 'wpmembers_settings' );
88
-
89
- // Is this an update from pre-3.0 or 3.0+?
90
- $is_three = ( array_key_exists( 'version', $wpmem_settings ) ) ? true : false;
91
-
92
- // If install is 3.0 or higher.
93
- if ( $is_three ) {
94
-
95
- if ( ! isset( $wpmem_settings['enable_products'] ) ) {
96
- $wpmem_settings['enable_products'] = 0;
97
- }
98
-
99
- if ( ! isset( $wpmem_settings['clone_menus'] ) ) {
100
- $wpmem_settings['clone_menus'] = 0;
101
- }
102
-
103
- // reCAPTCHA v1 is obsolete.
104
- if ( isset( $wpmem_settings['captcha'] ) && 1 == $wpmem_settings['captcha'] ) {
105
- $wpmem_settings['captcha'] = 3;
106
- }
107
-
108
- // If old auto excerpt settings exists, update it.
109
- if ( isset( $wpmem_settings['autoex']['auto_ex'] ) ) {
110
- // Update Autoex setting.
111
- if ( $wpmem_settings['autoex']['auto_ex'] == 1 || $wpmem_settings['autoex']['auto_ex'] == "1" ) {
112
- // If Autoex is set, move it to posts/pages.
113
- $wpmem_settings['autoex']['post'] = array( 'enabled' => 1, 'length' => $wpmem_settings['autoex']['auto_ex_len'] );
114
- $wpmem_settings['autoex']['page'] = array( 'enabled' => 1, 'length' => $wpmem_settings['autoex']['auto_ex_len'] );
115
- } else {
116
- // If it is not turned on (!=1), set it to off in new setting (-1).
117
- $wpmem_settings['autoex']['post'] = array( 'enabled' => 0, 'length' => '' );
118
- $wpmem_settings['autoex']['page'] = array( 'enabled' => 0, 'length' => '' );
119
- }
120
- unset( $wpmem_settings['autoex']['auto_ex'] );
121
- unset( $wpmem_settings['autoex']['auto_ex_len'] );
122
- }
123
-
124
- // If post types settings does not exist, set as empty array.
125
- if ( ! isset( $wpmem_settings['post_types'] ) ) {
126
- $wpmem_settings['post_types'] = array();
127
- }
128
-
129
- // If form tags is not set, add default.
130
- if ( ! isset( $wpmem_settings['form_tags'] ) ) {
131
- $wpmem_settings['form_tags'] = array( 'default' => 'Registration Default' );
132
- }
133
-
134
- // If email is set in the settings array, change it back to the pre-3.1 option.
135
- if ( isset( $wpmem_settings['email'] ) ) {
136
- $from = ( is_array( $wpmem_settings['email'] ) ) ? $wpmem_settings['email']['from'] : '';
137
- $name = ( is_array( $wpmem_settings['email'] ) ) ? $wpmem_settings['email']['from_name'] : '';
138
- update_option( 'wpmembers_email_wpfrom', $from );
139
- update_option( 'wpmembers_email_wpname', $name );
140
- unset( $wpmem_settings['email'] );
141
- }
142
-
143
- // Version number should be updated no matter what.
144
- $wpmem_settings['version'] = WPMEM_VERSION;
145
- $wpmem_settings['db_version'] = WPMEM_DB_VERSION;
146
-
147
- update_option( 'wpmembers_settings', $wpmem_settings );
148
- return $wpmem_settings;
149
- } else {
150
- // Update pre 3.0 installs (must be 2.5.1 or higher).
151
- // Handle show registration setting change.
152
- $show_reg = ( $wpmem_settings[7] == 0 ) ? 1 : 0;
153
- // Create new settings array.
154
- $wpmem_newsettings = array(
155
- 'version' => WPMEM_VERSION,
156
- 'db_version' => WPMEM_DB_VERSION,
157
- 'block' => array(
158
- 'post' => $wpmem_settings[1],
159
- 'page' => $wpmem_settings[2],
160
- ),
161
- 'show_excerpt' => array(
162
- 'post' => $wpmem_settings[3],
163
- 'page' => $wpmem_settings[3],
164
- ),
165
- 'show_reg' => array(
166
- 'post' => $show_reg,
167
- 'page' => $show_reg,
168
- ),
169
- 'show_login' => array(
170
- 'post' => 1,
171
- 'page' => 1,
172
- ),
173
- 'notify' => $wpmem_settings[4],
174
- 'mod_reg' => $wpmem_settings[5],
175
- 'captcha' => ( 1 == $wpmem_settings[6] ) ? 3 : $wpmem_settings[6], // reCAPTCHA v1 is obsolete, move to v2.
176
- 'use_exp' => $wpmem_settings[9],
177
- 'use_trial' => $wpmem_settings[10],
178
- 'warnings' => $wpmem_settings[11],
179
- 'user_pages' => array(
180
- 'profile' => get_option( 'wpmembers_msurl' ),
181
- 'register' => get_option( 'wpmembers_regurl' ),
182
- 'login' => get_option( 'wpmembers_logurl' ),
183
- ),
184
- 'cssurl' => get_option( 'wpmembers_cssurl' ),
185
- 'style' => get_option( 'wpmembers_style' ),
186
- 'attrib' => get_option( 'wpmembers_attrib' ),
187
- 'clone_menus' => 0,
188
- 'enable_products' => 0,
189
- );
190
- // Handle auto excerpt setting change and add to setting array.
191
- $autoex = get_option( 'wpmembers_autoex' );
192
- if ( $autoex['auto_ex'] == 1 || $autoex['auto_ex'] == "1" ) {
193
- // If Autoex is set, move it to posts/pages.
194
- $wpmem_newsettings['autoex']['post'] = array( 'enabled' => 1, 'length' => $autoex['auto_ex_len'] );
195
- $wpmem_newsettings['autoex']['page'] = array( 'enabled' => 1, 'length' => $autoex['auto_ex_len'] );
196
- } else {
197
- // If it is not turned on, set it to off in new setting.
198
- $wpmem_newsettings['autoex']['post'] = array( 'enabled' => 0, 'length' => '' );
199
- $wpmem_newsettings['autoex']['page'] = array( 'enabled' => 0, 'length' => '' );
200
- }
201
-
202
- // Add new settings.
203
- $wpmem_newsettings['post_types'] = array();
204
- $wpmem_settings['form_tags'] = array( 'default' => 'Registration Default' );
205
-
206
- // Merge settings.
207
- $wpmem_newsettings = array_merge( $wpmem_settings, $wpmem_newsettings );
208
-
209
- update_option( 'wpmembers_settings', $wpmem_newsettings );
210
-
211
- return $wpmem_newsettings;
212
- }
213
- }
214
-
215
-
216
- /**
217
- * Adds the fields for email messages.
218
- *
219
- * Was append_email() since 2.7, changed to wpmem_append_email() in 3.0.
220
- *
221
- * @since 2.7
222
- */
223
- function wpmem_append_email() {
224
-
225
- // Email for a new registration.
226
- $subj = 'Your registration info for [blogname]';
227
- $body = 'Thank you for registering for [blogname]
228
-
229
- Your registration information is below.
230
- You may wish to retain a copy for your records.
231
-
232
- username: [username]
233
- password: [password]
234
-
235
- You may log in here:
236
- [reglink]
237
-
238
- You may change your password here:
239
- [user-profile]
240
- ';
241
-
242
- $arr = array(
243
- "subj" => $subj,
244
- "body" => $body,
245
- );
246
-
247
- if ( ! get_option( 'wpmembers_email_newreg' ) ) {
248
- update_option( 'wpmembers_email_newreg', $arr, false );
249
- }
250
-
251
- $arr = $subj = $body = '';
252
-
253
- // Email for new registration, registration is moderated.
254
- $subj = 'Thank you for registering for [blogname]';
255
- $body = 'Thank you for registering for [blogname].
256
- Your registration has been received and is pending approval.
257
- You will receive login instructions upon approval of your account
258
- ';
259
-
260
- $arr = array(
261
- "subj" => $subj,
262
- "body" => $body,
263
- );
264
-
265
- if ( ! get_option( 'wpmembers_email_newmod' ) ) {
266
- update_option( 'wpmembers_email_newmod', $arr, false );
267
- }
268
-
269
- $arr = $subj = $body = '';
270
-
271
- // Email for registration is moderated, user is approved.
272
- $subj = 'Your registration for [blogname] has been approved';
273
- $body = 'Your registration for [blogname] has been approved.
274
-
275
- Your registration information is below.
276
- You may wish to retain a copy for your records.
277
-
278
- username: [username]
279
- password: [password]
280
-
281
- You may log in and change your password here:
282
- [user-profile]
283
-
284
- You originally registered at:
285
- [reglink]
286
- ';
287
-
288
- $arr = array(
289
- "subj" => $subj,
290
- "body" => $body,
291
- );
292
-
293
- if ( ! get_option( 'wpmembers_email_appmod' ) ) {
294
- update_option( 'wpmembers_email_appmod', $arr, false );
295
- }
296
-
297
- $arr = $subj = $body = '';
298
-
299
- // Email for password reset.
300
- $subj = 'Your password reset for [blogname]';
301
- $body = 'Your password for [blogname] has been reset
302
-
303
- Your new password is included below. You may wish to retain a copy for your records.
304
-
305
- password: [password]
306
- ';
307
-
308
- $arr = array(
309
- "subj" => $subj,
310
- "body" => $body,
311
- );
312
-
313
- if ( ! get_option( 'wpmembers_email_repass' ) ) {
314
- update_option( 'wpmembers_email_repass', $arr, false );
315
- }
316
-
317
- $arr = $subj = $body = '';
318
-
319
- // Email for admin notification.
320
- $subj = 'New user registration for [blogname]';
321
- $body = 'The following user registered for [blogname]:
322
-
323
- username: [username]
324
- email: [email]
325
-
326
- [fields]
327
- This user registered here:
328
- [reglink]
329
-
330
- user IP: [user-ip]
331
-
332
- activate user: [activate-user]
333
- ';
334
-
335
- $arr = array(
336
- "subj" => $subj,
337
- "body" => $body,
338
- );
339
-
340
- if ( ! get_option( 'wpmembers_email_notify' ) ) {
341
- update_option( 'wpmembers_email_notify', $arr, false );
342
- }
343
-
344
- $arr = $subj = $body = '';
345
-
346
- // Email footer (no subject).
347
- $body = '----------------------------------
348
- This is an automated message from [blogname]
349
- Please do not reply to this address';
350
-
351
- if ( ! get_option( 'wpmembers_email_footer' ) ) {
352
- update_option( 'wpmembers_email_footer', $body, false );
353
- }
354
-
355
- $arr = $subj = $body = '';
356
-
357
- // Email for retrieve username.
358
- $subj = 'Username for [blogname]';
359
- $body = 'Your username for [blogname] is below.
360
-
361
- username: [username]
362
- ';
363
-
364
- $arr = array(
365
- "subj" => $subj,
366
- "body" => $body,
367
- );
368
-
369
- if ( ! get_option( 'wpmembers_email_getuser' ) ) {
370
- update_option( 'wpmembers_email_getuser', $arr, false );
371
- }
372
-
373
- return true;
374
- }
375
-
376
-
377
- /**
378
- * Checks the dialogs array for necessary changes.
379
- *
380
- * @since 2.9.3
381
- * @since 3.0.0 Changed from update_dialogs() to wpmem_update_dialogs().
382
- * @since 3.1.0 Changed from wpmem_update_dialogs() to wpmem_upgrade_dialogs().
383
- * @since 3.1.1 Converts numeric dialog array to associative.
384
- */
385
- function wpmem_upgrade_dialogs() {
386
-
387
- $wpmem_dialogs = get_option( 'wpmembers_dialogs' );
388
-
389
- if ( ! array_key_exists( 'restricted_msg', $wpmem_dialogs ) ) {
390
- // Update is needed.
391
- $new_arr = array();
392
- $new_keys = array( 'restricted_msg', 'user', 'email', 'success', 'editsuccess', 'pwdchangerr', 'pwdchangesuccess', 'pwdreseterr', 'pwdresetsuccess' );
393
- foreach ( $wpmem_dialogs as $key => $val ) {
394
- $new_arr[ $new_keys[ $key ] ] = $val;
395
- }
396
- update_option( 'wpmembers_dialogs', $new_arr, '', 'yes' );
397
- }
398
-
399
- return;
400
- }
401
-
402
-
403
- /**
404
- * Downgrades dialogs array for pre-3.1.1 version rollback.
405
- *
406
- * @since 3.1.1
407
- */
408
- function wpmem_downgrade_dialogs() {
409
-
410
- $wpmem_dialogs = get_option( 'wpmembers_dialogs' );
411
-
412
- if ( array_key_exists( 'restricted_msg', $wpmem_dialogs ) ) {
413
- // Update is needed.
414
- $new_arr = array();
415
- $i = 0;
416
- foreach ( $wpmem_dialogs as $key => $val ) {
417
- $new_arr[ $i ] = $val;
418
- $i++;
419
- }
420
- update_option( 'wpmembers_dialogs', $new_arr, '', 'yes' );
421
- }
422
-
423
- return;
424
- }
425
-
426
-
427
- /**
428
- * Checks the captcha settings and updates accordingly.
429
- *
430
- * Was update_captcha() since 2.9.5, changed to wpmem_update_captcha() in 3.0.
431
- *
432
- * @since 2.9.5
433
- * @since 3.0.0 Changed from update_captcha() to wpmem_update_captcha().
434
- * @since 3.1.0 Changed from wpmem_update_captcha() to wpmem_upgrade_captcha().
435
- */
436
- function wpmem_upgrade_captcha() {
437
-
438
- $captcha_settings = get_option( 'wpmembers_captcha' );
439
-
440
- // If there captcha settings, update them.
441
- if ( $captcha_settings && ! array_key_exists( 'recaptcha', $captcha_settings ) ) {
442
-
443
- // Check to see if the array keys are numeric.
444
- $is_numeric = false;
445
- foreach ( $captcha_settings as $key => $setting ) {
446
- $is_numeric = ( is_int( $key ) ) ? true : $is_numeric;
447
- }
448
-
449
- if ( $is_numeric ) {
450
- $new_captcha = array();
451
- // These are old recaptcha settings.
452
- $new_captcha['recaptcha']['public'] = $captcha_settings[0];
453
- $new_captcha['recaptcha']['private'] = $captcha_settings[1];
454
- $new_captcha['recaptcha']['theme'] = $captcha_settings[2];
455
- update_option( 'wpmembers_captcha', $new_captcha );
456
- }
457
- }
458
- return;
459
- }
460
-
461
- /**
462
- * Does install of default settings.
463
- *
464
- * @since 3.1.5
465
- * @since 3.1.6 Returns $wpmem_settings
466
- *
467
- * @return array $wpmem_settings
468
- */
469
- function wpmem_install_settings() {
470
-
471
- $wpmem_settings = array(
472
- 'version' => WPMEM_VERSION,
473
- 'db_version' => WPMEM_DB_VERSION,
474
- 'block' => array(
475
- 'post' => ( is_multisite() ) ? 0 : 1,
476
- 'page' => 0,
477
- ),
478
- 'show_excerpt' => array(
479
- 'post' => 0,
480
- 'page' => 0,
481
- ),
482
- 'show_reg' => array(
483
- 'post' => 1,
484
- 'page' => 1,
485
- ),
486
- 'show_login' => array(
487
- 'post' => 1,
488
- 'page' => 1,
489
- ),
490
- 'autoex' => array(
491
- 'post' => array( 'enabled' => 0, 'length' => '' ),
492
- 'page' => array( 'enabled' => 0, 'length' => '' ),
493
- ),
494
- 'enable_products' => 0,
495
- 'clone_menus' => 0,
496
- 'notify' => 0,
497
- 'mod_reg' => 0,
498
- 'captcha' => 0,
499
- 'use_exp' => 0,
500
- 'use_trial' => 0,
501
- 'warnings' => 0,
502
- 'user_pages' => array(
503
- 'profile' => '',
504
- 'register' => '',
505
- 'login' => '',
506
- ),
507
- 'cssurl' => '',
508
- 'style' => plugin_dir_url ( __FILE__ ) . 'css/generic-no-float.css',
509
- 'attrib' => 0,
510
- 'post_types' => array(),
511
- 'form_tags' => array( 'default' => 'Registration Default' ),
512
- );
513
-
514
- // Using update_option to allow for forced update.
515
- update_option( 'wpmembers_settings', $wpmem_settings, '', 'yes' );
516
-
517
- return $wpmem_settings;
518
- }
519
-
520
- /**
521
- * Installs default fields.
522
- *
523
- * @since 3.1.5
524
- *
525
- * @return array $fields {
526
- * @type array {
527
- * order,
528
- * label,
529
- * meta key,
530
- * type,
531
- * display,
532
- * required,
533
- * native,
534
- * checked value,
535
- * checked by default,
536
- * }
537
- * }
538
- */
539
- function wpmem_install_fields() {
540
- $fields = array(
541
- array( 0, 'Choose a Username', 'username', 'text', 'y', 'y', 'y' ),
542
- array( 1, 'First Name', 'first_name', 'text', 'y', 'y', 'y' ),
543
- array( 2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y' ),
544
- array( 3, 'Address 1', 'billing_address_1', 'text', 'y', 'y', 'n' ),
545
- array( 4, 'Address 2', 'billing_address_2', 'text', 'y', 'n', 'n' ),
546
- array( 5, 'City', 'billing_city', 'text', 'y', 'y', 'n' ),
547
- array( 6, 'State', 'billing_state', 'text', 'y', 'y', 'n' ),
548
- array( 7, 'Zip', 'billing_postcode', 'text', 'y', 'y', 'n' ),
549
- array( 8, 'Country', 'billing_country', 'text', 'y', 'y', 'n' ),
550
- array( 9, 'Phone', 'billing_phone', 'text', 'y', 'y', 'n' ),
551
- array( 10, 'Email', 'user_email', 'email', 'y', 'y', 'y' ),
552
- array( 11, 'Confirm Email', 'confirm_email', 'email', 'n', 'n', 'n' ),
553
- array( 12, 'Website', 'user_url', 'url', 'n', 'n', 'y' ),
554
- array( 13, 'Biographical Info', 'description', 'textarea', 'n', 'n', 'y' ),
555
- array( 14, 'Password', 'password', 'password', 'n', 'n', 'n' ),
556
- array( 15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n' ),
557
- array( 16, 'Terms of Service', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n' ),
558
- );
559
- update_option( 'wpmembers_fields', $fields, '', 'yes' ); // using update_option to allow for forced update
560
- return $fields;
561
- }
562
-
563
- /**
564
- * Installs default dialogs.
565
- *
566
- * @since 3.1.5
567
- */
568
- function wpmem_install_dialogs() {
569
- $wpmem_dialogs_arr = array(
570
- 'restricted_msg' => "This content is restricted to site members. If you are an existing user, please log in. New users may register below.",
571
- 'user' => "Sorry, that username is taken, please try another.",
572
- 'email' => "Sorry, that email address already has an account.<br />Please try another.",
573
- 'success' => "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.",
574
- 'editsuccess' => "Your information was updated!",
575
- 'pwdchangerr' => "Passwords did not match.<br /><br />Please try again.",
576
- 'pwdchangesuccess' => "Password successfully changed!",
577
- 'pwdreseterr' => "Either the username or email address do not exist in our records.",
578
- 'pwdresetsuccess' => "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.",
579
- );
580
- // Insert TOS dialog placeholder.
581
- $dummy_tos = "Put your TOS (Terms of Service) text here. You can use HTML markup.";
582
- update_option( 'wpmembers_tos', $dummy_tos );
583
- update_option( 'wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes' ); // using update_option to allow for forced update
584
- }
585
-
586
- /**
587
- * Upgrades fields settings.
588
- *
589
- * @since 3.2.0
590
- */
591
- function wpmem_upgrade_fields() {
592
- $fields = get_option( 'wpmembers_fields' );
593
- $old_style = false;
594
- foreach ( $fields as $key => $val ) {
595
- if ( is_numeric( $key ) ) {
596
- $old_style = true;
597
- $check_array[] = $val[2];
598
- }
599
- }
600
- if ( $old_style && ! in_array( 'username', $check_array ) ) {
601
- $username_array = array( 0, 'Choose a Username', 'username', 'text', 'y', 'y', 'y' );
602
- array_unshift( $fields, $username_array );
603
- update_option( 'wpmembers_fields', $fields, '', 'yes' );
604
- }
605
- }
606
  // End of file.
1
+ <?php
2
+ /**
3
+ * WP-Members Installation Functions
4
+ *
5
+ * Functions to install and upgrade WP-Members.
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
18
+ * - wpmem_upgrade_settings
19
+ * - wpmem_upgrade_email
20
+ * - wpmem_upgrade_dialogs
21
+ * - wpmem_downgrade_dialogs
22
+ * - wpmem_upgrade_captcha
23
+ */
24
+
25
+ // Exit if accessed directly.
26
+ if ( ! defined( 'ABSPATH' ) ) {
27
+ exit();
28
+ }
29
+
30
+ /**
31
+ * Installs or upgrades the plugin.
32
+ *
33
+ * @since 2.2.2
34
+ * @since 3.1.6 Returns $wpmem_settings.
35
+ *
36
+ * @return array $wpmem_settings
37
+ */
38
+ function wpmem_do_install() {
39
+
40
+ /*
41
+ * If you need to force an install, set $chk_force = true.
42
+ *
43
+ * Important notes:
44
+ *
45
+ * 1. This will override any settings you already have for any of the plugin settings.
46
+ * 2. This will not effect any WP settings or registered users.
47
+ */
48
+
49
+ $chk_force = false;
50
+
51
+ if ( ! get_option( 'wpmembers_settings' ) || $chk_force == true ) {
52
+
53
+ // New install.
54
+ $wpmem_settings = wpmem_install_settings();
55
+ wpmem_install_fields();
56
+ wpmem_install_dialogs();
57
+ wpmem_append_email();
58
+ update_option( 'wpmembers_style', WPMEM_DIR . 'css/generic-no-float.css', '', 'yes' );
59
+
60
+ } else {
61
+
62
+ // Upgrade.
63
+ $wpmem_settings = wpmem_upgrade_settings();
64
+ wpmem_upgrade_captcha();
65
+ wpmem_append_email();
66
+ wpmem_upgrade_fields();
67
+
68
+ }
69
+
70
+ return $wpmem_settings;
71
+ }
72
+
73
+
74
+ /**
75
+ * Updates the existing settings if doing an update.
76
+ *
77
+ * @since 3.0.0
78
+ * @since 3.1.0 Changed from wpmem_update_settings() to wpmem_upgrade_settings().
79
+ *
80
+ * @return array $wpmem_newsettings
81
+ */
82
+ function wpmem_upgrade_settings() {
83
+
84
+ // Update dialogs for 3.1.1
85
+ wpmem_upgrade_dialogs();
86
+
87
+ $wpmem_settings = get_option( 'wpmembers_settings' );
88
+
89
+ // Is this an update from pre-3.0 or 3.0+?
90
+ $is_three = ( array_key_exists( 'version', $wpmem_settings ) ) ? true : false;
91
+
92
+ // If install is 3.0 or higher.
93
+ if ( $is_three ) {
94
+
95
+ if ( ! isset( $wpmem_settings['enable_products'] ) ) {
96
+ $wpmem_settings['enable_products'] = 0;
97
+ }
98
+
99
+ if ( ! isset( $wpmem_settings['clone_menus'] ) ) {
100
+ $wpmem_settings['clone_menus'] = 0;
101
+ }
102
+
103
+ // reCAPTCHA v1 is obsolete.
104
+ if ( isset( $wpmem_settings['captcha'] ) && 1 == $wpmem_settings['captcha'] ) {
105
+ $wpmem_settings['captcha'] = 3;
106
+ }
107
+
108
+ // If old auto excerpt settings exists, update it.
109
+ if ( isset( $wpmem_settings['autoex']['auto_ex'] ) ) {
110
+ // Update Autoex setting.
111
+ if ( $wpmem_settings['autoex']['auto_ex'] == 1 || $wpmem_settings['autoex']['auto_ex'] == "1" ) {
112
+ // If Autoex is set, move it to posts/pages.
113
+ $wpmem_settings['autoex']['post'] = array( 'enabled' => 1, 'length' => $wpmem_settings['autoex']['auto_ex_len'] );
114
+ $wpmem_settings['autoex']['page'] = array( 'enabled' => 1, 'length' => $wpmem_settings['autoex']['auto_ex_len'] );
115
+ } else {
116
+ // If it is not turned on (!=1), set it to off in new setting (-1).
117
+ $wpmem_settings['autoex']['post'] = array( 'enabled' => 0, 'length' => '' );
118
+ $wpmem_settings['autoex']['page'] = array( 'enabled' => 0, 'length' => '' );
119
+ }
120
+ unset( $wpmem_settings['autoex']['auto_ex'] );
121
+ unset( $wpmem_settings['autoex']['auto_ex_len'] );
122
+ }
123
+
124
+ // If post types settings does not exist, set as empty array.
125
+ if ( ! isset( $wpmem_settings['post_types'] ) ) {
126
+ $wpmem_settings['post_types'] = array();
127
+ }
128
+
129
+ // If form tags is not set, add default.
130
+ if ( ! isset( $wpmem_settings['form_tags'] ) ) {
131
+ $wpmem_settings['form_tags'] = array( 'default' => 'Registration Default' );
132
+ }
133
+
134
+ // If email is set in the settings array, change it back to the pre-3.1 option.
135
+ if ( isset( $wpmem_settings['email'] ) ) {
136
+ $from = ( is_array( $wpmem_settings['email'] ) ) ? $wpmem_settings['email']['from'] : '';
137
+ $name = ( is_array( $wpmem_settings['email'] ) ) ? $wpmem_settings['email']['from_name'] : '';
138
+ update_option( 'wpmembers_email_wpfrom', $from );
139
+ update_option( 'wpmembers_email_wpname', $name );
140
+ unset( $wpmem_settings['email'] );
141
+ }
142
+
143
+ // Version number should be updated no matter what.
144
+ $wpmem_settings['version'] = WPMEM_VERSION;
145
+ $wpmem_settings['db_version'] = WPMEM_DB_VERSION;
146
+
147
+ update_option( 'wpmembers_settings', $wpmem_settings );
148
+ return $wpmem_settings;
149
+ } else {
150
+ // Update pre 3.0 installs (must be 2.5.1 or higher).
151
+ // Handle show registration setting change.
152
+ $show_reg = ( $wpmem_settings[7] == 0 ) ? 1 : 0;
153
+ // Create new settings array.
154
+ $wpmem_newsettings = array(
155
+ 'version' => WPMEM_VERSION,
156
+ 'db_version' => WPMEM_DB_VERSION,
157
+ 'block' => array(
158
+ 'post' => $wpmem_settings[1],
159
+ 'page' => $wpmem_settings[2],
160
+ ),
161
+ 'show_excerpt' => array(
162
+ 'post' => $wpmem_settings[3],
163
+ 'page' => $wpmem_settings[3],
164
+ ),
165
+ 'show_reg' => array(
166
+ 'post' => $show_reg,
167
+ 'page' => $show_reg,
168
+ ),
169
+ 'show_login' => array(
170
+ 'post' => 1,
171
+ 'page' => 1,
172
+ ),
173
+ 'notify' => $wpmem_settings[4],
174
+ 'mod_reg' => $wpmem_settings[5],
175
+ 'captcha' => ( 1 == $wpmem_settings[6] ) ? 3 : $wpmem_settings[6], // reCAPTCHA v1 is obsolete, move to v2.
176
+ 'use_exp' => $wpmem_settings[9],
177
+ 'use_trial' => $wpmem_settings[10],
178
+ 'warnings' => $wpmem_settings[11],
179
+ 'user_pages' => array(
180
+ 'profile' => get_option( 'wpmembers_msurl' ),
181
+ 'register' => get_option( 'wpmembers_regurl' ),
182
+ 'login' => get_option( 'wpmembers_logurl' ),
183
+ ),
184
+ 'cssurl' => get_option( 'wpmembers_cssurl' ),
185
+ 'style' => get_option( 'wpmembers_style' ),
186
+ 'attrib' => get_option( 'wpmembers_attrib' ),
187
+ 'clone_menus' => 0,
188
+ 'enable_products' => 0,
189
+ );
190
+ // Handle auto excerpt setting change and add to setting array.
191
+ $autoex = get_option( 'wpmembers_autoex' );
192
+ if ( $autoex['auto_ex'] == 1 || $autoex['auto_ex'] == "1" ) {
193
+ // If Autoex is set, move it to posts/pages.
194
+ $wpmem_newsettings['autoex']['post'] = array( 'enabled' => 1, 'length' => $autoex['auto_ex_len'] );
195
+ $wpmem_newsettings['autoex']['page'] = array( 'enabled' => 1, 'length' => $autoex['auto_ex_len'] );
196
+ } else {
197
+ // If it is not turned on, set it to off in new setting.
198
+ $wpmem_newsettings['autoex']['post'] = array( 'enabled' => 0, 'length' => '' );
199
+ $wpmem_newsettings['autoex']['page'] = array( 'enabled' => 0, 'length' => '' );
200
+ }
201
+
202
+ // Add new settings.
203
+ $wpmem_newsettings['post_types'] = array();
204
+ $wpmem_settings['form_tags'] = array( 'default' => 'Registration Default' );
205
+
206
+ // Merge settings.
207
+ $wpmem_newsettings = array_merge( $wpmem_settings, $wpmem_newsettings );
208
+
209
+ update_option( 'wpmembers_settings', $wpmem_newsettings );
210
+
211
+ return $wpmem_newsettings;
212
+ }
213
+ }
214
+
215
+
216
+ /**
217
+ * Adds the fields for email messages.
218
+ *
219
+ * Was append_email() since 2.7, changed to wpmem_append_email() in 3.0.
220
+ *
221
+ * @since 2.7
222
+ */
223
+ function wpmem_append_email() {
224
+
225
+ // Email for a new registration.
226
+ $subj = 'Your registration info for [blogname]';
227
+ $body = 'Thank you for registering for [blogname]
228
+
229
+ Your registration information is below.
230
+ You may wish to retain a copy for your records.
231
+
232
+ username: [username]
233
+ password: [password]
234
+
235
+ You may log in here:
236
+ [reglink]
237
+
238
+ You may change your password here:
239
+ [user-profile]
240
+ ';
241
+
242
+ $arr = array(
243
+ "subj" => $subj,
244
+ "body" => $body,
245
+ );
246
+
247
+ if ( ! get_option( 'wpmembers_email_newreg' ) ) {
248
+ update_option( 'wpmembers_email_newreg', $arr, false );
249
+ }
250
+
251
+ $arr = $subj = $body = '';
252
+
253
+ // Email for new registration, registration is moderated.
254
+ $subj = 'Thank you for registering for [blogname]';
255
+ $body = 'Thank you for registering for [blogname].
256
+ Your registration has been received and is pending approval.
257
+ You will receive login instructions upon approval of your account
258
+ ';
259
+
260
+ $arr = array(
261
+ "subj" => $subj,
262
+ "body" => $body,
263
+ );
264
+
265
+ if ( ! get_option( 'wpmembers_email_newmod' ) ) {
266
+ update_option( 'wpmembers_email_newmod', $arr, false );
267
+ }
268
+
269
+ $arr = $subj = $body = '';
270
+
271
+ // Email for registration is moderated, user is approved.
272
+ $subj = 'Your registration for [blogname] has been approved';
273
+ $body = 'Your registration for [blogname] has been approved.
274
+
275
+ Your registration information is below.
276
+ You may wish to retain a copy for your records.
277
+
278
+ username: [username]
279
+ password: [password]
280
+
281
+ You may log in and change your password here:
282
+ [user-profile]
283
+
284
+ You originally registered at:
285
+ [reglink]
286
+ ';
287
+
288
+ $arr = array(
289
+ "subj" => $subj,
290
+ "body" => $body,
291
+ );
292
+
293
+ if ( ! get_option( 'wpmembers_email_appmod' ) ) {
294
+ update_option( 'wpmembers_email_appmod', $arr, false );
295
+ }
296
+
297
+ $arr = $subj = $body = '';
298
+
299
+ // Email for password reset.
300
+ $subj = 'Your password reset for [blogname]';
301
+ $body = 'Your password for [blogname] has been reset
302
+
303
+ Your new password is included below. You may wish to retain a copy for your records.
304
+
305
+ password: [password]
306
+ ';
307
+
308
+ $arr = array(
309
+ "subj" => $subj,
310
+ "body" => $body,
311
+ );
312
+
313
+ if ( ! get_option( 'wpmembers_email_repass' ) ) {
314
+ update_option( 'wpmembers_email_repass', $arr, false );
315
+ }
316
+
317
+ $arr = $subj = $body = '';
318
+
319
+ // Email for admin notification.
320
+ $subj = 'New user registration for [blogname]';
321
+ $body = 'The following user registered for [blogname]:
322
+
323
+ username: [username]
324
+ email: [email]
325
+
326
+ [fields]
327
+ This user registered here:
328
+ [reglink]
329
+
330
+ user IP: [user-ip]
331
+
332
+ activate user: [activate-user]
333
+ ';
334
+
335
+ $arr = array(
336
+ "subj" => $subj,
337
+ "body" => $body,
338
+ );
339
+
340
+ if ( ! get_option( 'wpmembers_email_notify' ) ) {
341
+ update_option( 'wpmembers_email_notify', $arr, false );
342
+ }
343
+
344
+ $arr = $subj = $body = '';
345
+
346
+ // Email footer (no subject).
347
+ $body = '----------------------------------
348
+ This is an automated message from [blogname]
349
+ Please do not reply to this address';
350
+
351
+ if ( ! get_option( 'wpmembers_email_footer' ) ) {
352
+ update_option( 'wpmembers_email_footer', $body, false );
353
+ }
354
+
355
+ $arr = $subj = $body = '';
356
+
357
+ // Email for retrieve username.
358
+ $subj = 'Username for [blogname]';
359
+ $body = 'Your username for [blogname] is below.
360
+
361
+ username: [username]
362
+ ';
363
+
364
+ $arr = array(
365
+ "subj" => $subj,
366
+ "body" => $body,
367
+ );
368
+
369
+ if ( ! get_option( 'wpmembers_email_getuser' ) ) {
370
+ update_option( 'wpmembers_email_getuser', $arr, false );
371
+ }
372
+
373
+ return true;
374
+ }
375
+
376
+
377
+ /**
378
+ * Checks the dialogs array for necessary changes.
379
+ *
380
+ * @since 2.9.3
381
+ * @since 3.0.0 Changed from update_dialogs() to wpmem_update_dialogs().
382
+ * @since 3.1.0 Changed from wpmem_update_dialogs() to wpmem_upgrade_dialogs().
383
+ * @since 3.1.1 Converts numeric dialog array to associative.
384
+ */
385
+ function wpmem_upgrade_dialogs() {
386
+
387
+ $wpmem_dialogs = get_option( 'wpmembers_dialogs' );
388
+
389
+ if ( ! array_key_exists( 'restricted_msg', $wpmem_dialogs ) ) {
390
+ // Update is needed.
391
+ $new_arr = array();
392
+ $new_keys = array( 'restricted_msg', 'user', 'email', 'success', 'editsuccess', 'pwdchangerr', 'pwdchangesuccess', 'pwdreseterr', 'pwdresetsuccess' );
393
+ foreach ( $wpmem_dialogs as $key => $val ) {
394
+ $new_arr[ $new_keys[ $key ] ] = $val;
395
+ }
396
+ update_option( 'wpmembers_dialogs', $new_arr, '', 'yes' );
397
+ }
398
+
399
+ return;
400
+ }
401
+
402
+
403
+ /**
404
+ * Downgrades dialogs array for pre-3.1.1 version rollback.
405
+ *
406
+ * @since 3.1.1
407
+ */
408
+ function wpmem_downgrade_dialogs() {
409
+
410
+ $wpmem_dialogs = get_option( 'wpmembers_dialogs' );
411
+
412
+ if ( array_key_exists( 'restricted_msg', $wpmem_dialogs ) ) {
413
+ // Update is needed.
414
+ $new_arr = array();
415
+ $i = 0;
416
+ foreach ( $wpmem_dialogs as $key => $val ) {
417
+ $new_arr[ $i ] = $val;
418
+ $i++;
419
+ }
420
+ update_option( 'wpmembers_dialogs', $new_arr, '', 'yes' );
421
+ }
422
+
423
+ return;
424
+ }
425
+
426
+
427
+ /**
428
+ * Checks the captcha settings and updates accordingly.
429
+ *
430
+ * Was update_captcha() since 2.9.5, changed to wpmem_update_captcha() in 3.0.
431
+ *
432
+ * @since 2.9.5
433
+ * @since 3.0.0 Changed from update_captcha() to wpmem_update_captcha().
434
+ * @since 3.1.0 Changed from wpmem_update_captcha() to wpmem_upgrade_captcha().
435
+ */
436
+ function wpmem_upgrade_captcha() {
437
+
438
+ $captcha_settings = get_option( 'wpmembers_captcha' );
439
+
440
+ // If there captcha settings, update them.
441
+ if ( $captcha_settings && ! array_key_exists( 'recaptcha', $captcha_settings ) ) {
442
+
443
+ // Check to see if the array keys are numeric.
444
+ $is_numeric = false;
445
+ foreach ( $captcha_settings as $key => $setting ) {
446
+ $is_numeric = ( is_int( $key ) ) ? true : $is_numeric;
447
+ }
448
+
449
+ if ( $is_numeric ) {
450
+ $new_captcha = array();
451
+ // These are old recaptcha settings.
452
+ $new_captcha['recaptcha']['public'] = $captcha_settings[0];
453
+ $new_captcha['recaptcha']['private'] = $captcha_settings[1];
454
+ $new_captcha['recaptcha']['theme'] = $captcha_settings[2];
455
+ update_option( 'wpmembers_captcha', $new_captcha );
456
+ }
457
+ }
458
+ return;
459
+ }
460
+
461
+ /**
462
+ * Does install of default settings.
463
+ *
464
+ * @since 3.1.5
465
+ * @since 3.1.6 Returns $wpmem_settings
466
+ *
467
+ * @return array $wpmem_settings
468
+ */
469
+ function wpmem_install_settings() {
470
+
471
+ $wpmem_settings = array(
472
+ 'version' => WPMEM_VERSION,
473
+ 'db_version' => WPMEM_DB_VERSION,
474
+ 'block' => array(
475
+ 'post' => ( is_multisite() ) ? 0 : 1,
476
+ 'page' => 0,
477
+ ),
478
+ 'show_excerpt' => array(
479
+ 'post' => 0,
480
+ 'page' => 0,
481
+ ),
482
+ 'show_reg' => array(
483
+ 'post' => 1,
484
+ 'page' => 1,
485
+ ),
486
+ 'show_login' => array(
487
+ 'post' => 1,
488
+ 'page' => 1,
489
+ ),
490
+ 'autoex' => array(
491
+ 'post' => array( 'enabled' => 0, 'length' => '' ),
492
+ 'page' => array( 'enabled' => 0, 'length' => '' ),
493
+ ),
494
+ 'enable_products' => 0,
495
+ 'clone_menus' => 0,
496
+ 'notify' => 0,
497
+ 'mod_reg' => 0,
498
+ 'captcha' => 0,
499
+ 'use_exp' => 0,
500
+ 'use_trial' => 0,
501
+ 'warnings' => 0,
502
+ 'user_pages' => array(
503
+ 'profile' => '',
504
+ 'register' => '',
505
+ 'login' => '',
506
+ ),
507
+ 'cssurl' => '',
508
+ 'style' => WPMEM_DIR . 'css/generic-no-float.css',
509
+ 'attrib' => 0,
510
+ 'post_types' => array(),
511
+ 'form_tags' => array( 'default' => 'Registration Default' ),
512
+ );
513
+
514
+ // Using update_option to allow for forced update.
515
+ update_option( 'wpmembers_settings', $wpmem_settings, '', 'yes' );
516
+
517
+ return $wpmem_settings;
518
+ }
519
+
520
+ /**
521
+ * Installs default fields.
522
+ *
523
+ * @since 3.1.5
524
+ *
525
+ * @return array $fields {
526
+ * @type array {
527
+ * order,
528
+ * label,
529
+ * meta key,
530
+ * type,
531
+ * display,
532
+ * required,
533
+ * native,
534
+ * checked value,
535
+ * checked by default,
536
+ * }
537
+ * }
538
+ */
539
+ function wpmem_install_fields() {
540
+ $fields = array(
541
+ array( 0, 'Choose a Username', 'username', 'text', 'y', 'y', 'y' ),
542
+ array( 1, 'First Name', 'first_name', 'text', 'y', 'y', 'y' ),
543
+ array( 2, 'Last Name', 'last_name', 'text', 'y', 'y', 'y' ),
544
+ array( 3, 'Address 1', 'billing_address_1', 'text', 'y', 'y', 'n' ),
545
+ array( 4, 'Address 2', 'billing_address_2', 'text', 'y', 'n', 'n' ),
546
+ array( 5, 'City', 'billing_city', 'text', 'y', 'y', 'n' ),
547
+ array( 6, 'State', 'billing_state', 'text', 'y', 'y', 'n' ),
548
+ array( 7, 'Zip', 'billing_postcode', 'text', 'y', 'y', 'n' ),
549
+ array( 8, 'Country', 'billing_country', 'text', 'y', 'y', 'n' ),
550
+ array( 9, 'Phone', 'billing_phone', 'text', 'y', 'y', 'n' ),
551
+ array( 10, 'Email', 'user_email', 'email', 'y', 'y', 'y' ),
552
+ array( 11, 'Confirm Email', 'confirm_email', 'email', 'n', 'n', 'n' ),
553
+ array( 12, 'Website', 'user_url', 'url', 'n', 'n', 'y' ),
554
+ array( 13, 'Biographical Info', 'description', 'textarea', 'n', 'n', 'y' ),
555
+ array( 14, 'Password', 'password', 'password', 'n', 'n', 'n' ),
556
+ array( 15, 'Confirm Password', 'confirm_password', 'password', 'n', 'n', 'n' ),
557
+ array( 16, 'Terms of Service', 'tos', 'checkbox', 'n', 'n', 'n', 'agree', 'n' ),
558
+ );
559
+ update_option( 'wpmembers_fields', $fields, '', 'yes' ); // using update_option to allow for forced update
560
+ return $fields;
561
+ }
562
+
563
+ /**
564
+ * Installs default dialogs.
565
+ *
566
+ * @since 3.1.5
567
+ */
568
+ function wpmem_install_dialogs() {
569
+ $wpmem_dialogs_arr = array(
570
+ 'restricted_msg' => "This content is restricted to site members. If you are an existing user, please log in. New users may register below.",
571
+ 'user' => "Sorry, that username is taken, please try another.",
572
+ 'email' => "Sorry, that email address already has an account.<br />Please try another.",
573
+ 'success' => "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.",
574
+ 'editsuccess' => "Your information was updated!",
575
+ 'pwdchangerr' => "Passwords did not match.<br /><br />Please try again.",
576
+ 'pwdchangesuccess' => "Password successfully changed!",
577
+ 'pwdreseterr' => "Either the username or email address do not exist in our records.",
578
+ 'pwdresetsuccess' => "Password successfully reset!<br /><br />An email containing a new password has been sent to the email address on file for your account.",
579
+ );
580
+ // Insert TOS dialog placeholder.
581
+ $dummy_tos = "Put your TOS (Terms of Service) text here. You can use HTML markup.";
582
+ update_option( 'wpmembers_tos', $dummy_tos );
583
+ update_option( 'wpmembers_dialogs', $wpmem_dialogs_arr, '', 'yes' ); // using update_option to allow for forced update
584
+ }
585
+
586
+ /**
587
+ * Upgrades fields settings.
588
+ *
589
+ * @since 3.2.0
590
+ */
591
+ function wpmem_upgrade_fields() {
592
+ $fields = get_option( 'wpmembers_fields' );
593
+ $old_style = false;
594
+ foreach ( $fields as $key => $val ) {
595
+ if ( is_numeric( $key ) ) {
596
+ $old_style = true;
597
+ $check_array[] = $val[2];
598
+ }
599
+ }
600
+ if ( $old_style && ! in_array( 'username', $check_array ) ) {
601
+ $username_array = array( 0, 'Choose a Username', 'username', 'text', 'y', 'y', 'y' );
602
+ array_unshift( $fields, $username_array );
603
+ update_option( 'wpmembers_fields', $fields, '', 'yes' );
604
+ }
605
+ }
606
  // End of file.
readme.txt CHANGED
@@ -1,295 +1,308 @@
1
- === WP-Members Membership Plugin ===
2
- 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: 4.9
6
- Stable tag: 3.2.3.2
7
- License: GPLv2
8
-
9
- The WP-Members membership plugin turns your WordPress site into a membership site. Restrict premium content, create custom registration fields, and more.
10
-
11
- == Description ==
12
-
13
- === Membership Sites. Simplified. ===
14
-
15
- You need a membership site, but you want to focus on your business, not mastering a plugin. WP-Members is simple to use, easy to set up, yet flexible in every way imaginable.
16
-
17
- The plugin restricts selected WordPress content to registered site members. WP-Members puts the registration process on the site front end so it is part of your content instead of the native WP login page. WP-Members requires no modifications to your theme while remaining scalable for users who want to customize the look and feel, or want to restrict only some content. It is a great tool for sites offering premium content to subscribers and is adaptable to a variety of applications.
18
-
19
- Simple to install and configure - yet customizable and scalable!
20
-
21
- = Features: =
22
-
23
- * Block posts, pages, and custom post types
24
- * User login, registration, and profile integrated into your theme
25
- * Sidebar login widget
26
- * Create custom registration and profile fields
27
- * Notify admin of new user registrations
28
- * Hold new registrations for admin approval
29
- * Create post excerpt teaser content automatically
30
- * More than 120 action and filter hooks for customization
31
- * A library of API functions for extensibility
32
-
33
- WP-Members allows you to set content as blocked or hidden to restrict For those that simply want to utilize the member management features and possibly restrict some content, the default setting can easily be toggled to block or unblock pages and/or posts by default. No matter what the default setting, individual posts or pages can be set to be blocked or unblocked at the article level, overriding the default setting.
34
-
35
- The plugin installs with additional registration fields including name, address, phone, and email. Using the WP-Members admin panel, you can also create your own custom registration fields and delete existing ones. Changing the field order is simple with a drag-and-drop interface. The registration form will be part of your content rather than using the WordPress login page. This offers you a premium content site with a professional and branded look and feel. It also provides an opportunity for the user to register without leaving the page to do so - less clicks = more conversions.
36
-
37
- There are also some special pages that can be created with simple shortcodes:
38
-
39
- * A User Profile page where registered members can edit their information and change/reset their password: [wpmem_profile]
40
- * A Registration page available for those that need a specific URL for registrations (such as email marketing or banner ad landing pages). Note: this is strictly optional as a registration form can also be included by default on blocked content pages: [wpmem_form register]
41
- * A Login page. This is also an optional page as the login form is included by default on blocked content. But if you need a specific login page, this can be created with a simple shortcode: [wpmem_form login]
42
- * [And more shortcodes are available](https://rocketgeek.com/plugins/wp-members/users-guide/shortcodes/)!
43
-
44
- Powerful cusotmizations can be constructed with over 100 action and filter hooks, as well as user accessible functions.
45
-
46
- In addition to all of the features above, the plugin can be extended with premium add-on modules available from the support site rocketgeek.com. Members of rocketgeek.com have access to support, examples, tutorials, and code snippets that will help you extend and customize the base plugin using the plugin's framework. Some of the add-ons have their own hooks and shortcodes to further expand the plugin's extensibility. [Visit the site for more info](https://rocketgeek.com/about/site-membership-subscription/).
47
-
48
-
49
- == Installation ==
50
-
51
- WP-Members is designed to run "out-of-the-box" with no modifications to your WP installation necessary. Please follow the installation instructions below. __Most of the support issues that arise are a result of improper installation or simply not reading/following directions__.
52
-
53
- = Basic Install: =
54
-
55
- The best way to begin is to review the [Initial Setup Video](https://rocketgeek.com/plugins/wp-members/docs/videos/). There is also a complete [Users Guide available](https://rocketgeek.com/plugins/wp-members/docs/) that covers all of the plugin's features in depth.
56
-
57
- 1. Upload the `/wp-members/` directory and its contents to the `/wp-content/plugins/` directory
58
- 2. Activate the plugin through the 'Plugins' menu in WordPress&reg;
59
-
60
- You are ready to begin using WP-Members. Now follow the instructions titled "Locking down your site" below.
61
-
62
- = Locking down your site: =
63
-
64
- * To restrict posts, you will need to use the `<!--more-->` link in your posts. Content above to the "more" split will display on summary pages (home, archive, category) but the user will be required to login to view the entire post. You may also use the plugin's auto excerpt setting to create post excerpts automatically. If you do not use the "more" tag or the auto excerpt setting, full post content is going to show on archive templates, unless the post is marked as hidden.
65
- * To begin restricting pages, change the plugin default setting for pages to be blocked. Unlike posts, the `<!--more-->` link is not necessary in the blocking of pages, but __must__ be used if you have the "show excerpts" setting turned on for pages.
66
- * To protect comments, we recommend setting "Users must be registered and logged in to comment" under Settings > Discussion.
67
- * On the Settings > General page, it is recommended that you uncheck "Anyone can register". While not required, this will prevent WP's native registration from colliding with WP-Members, especially if you are using any of the WP-Members additional registration fields.
68
- * Under Settings > Reading, "For each article in a feed, show" is recommended to be set to "Summary." WordPress installs with full feed settings by default. If you don't change this, your feeds will show full content.
69
-
70
-
71
- = Additional Settings and Information =
72
-
73
- A full Users Guide is [available here](https://rocketgeek.com/plugins/wp-members/docs/). The guide outlines the installation process, and also documents how to use all of the settings.
74
-
75
- = Plugin Extensibility =
76
-
77
- WP-Members is designed to be an out-of-the-box usable plugin, but also have an extensible framework for maximum flexibility and customization. For this purpose, there are a number of functions, shortcodes, filters, and actions that can be used.
78
-
79
- See [this page](https://rocketgeek.com/plugins/wp-members/users-guide/shortcodes/) for a list of shortcodes and their description.
80
-
81
- The plugin has over 120 filter and action hooks. For a list of hooks and a description of their use, see [this page](https://rocketgeek.com/plugins/wp-members/users-guide/filter-hooks/)
82
-
83
- The plugin's premium support site has many tips, tricks, and sample code for you to make maximum use out of the plugin. [Get more information here](https://rocketgeek.com/plugins/wp-members/support-options/). Members of the premium support site also have access to premium add-on modules.
84
-
85
-
86
- == Frequently Asked Questions ==
87
-
88
- The FAQs are maintained at https://rocketgeek.com/plugins/wp-members/docs/faqs/
89
-
90
-
91
- == Other Notes ==
92
-
93
- = WP-Members&trade; is a trademark of butlerblog.com =
94
-
95
- There are a number of commercial vendors offering products called WP-Members. Most of these products are neither free and some are not open source. The original plugin hosted here has been publicly available since 2006 and is in no way associated with any of these vendors. If you are seeking support for one of these commercial products, you should seek support from the vendor. If you got it from a site other than [rocketgeek.com](https://rocketgeek.com/plugins/wp-members/) or [wordpress.org](https://wordpress.org/extend/plugins/wp-members) then it isn't WP-Members&trade;.
96
-
97
- An [official statement is available here](http://butlerblog.com/regarding-wp-members).
98
-
99
- = RocketGeek.com =
100
-
101
- Premium priority support is available at the plugin's site [RocketGeek.com](https://rocketgeek.com). A site membership includes priority support, members-only forum access, plugin extensions, and a custom code snippet library. [RocketGeek.com](https://rocketgeek.com) is the only site officially managed for this plugin's support.
102
-
103
-
104
- == Upgrade Notice ==
105
-
106
- WP-Members 3.2.0 is a major update. See changelog for important details. Minimum WP version is 4.0.
107
- WP-Members 3.2.3.2 is a minor update for 3.2.3. See changelog.
108
-
109
- == Screenshots ==
110
-
111
- 1. The default when viewing a blocked post - the plugin will deliver a login screen and registration form in place of blocked content (this default can be changed to other options).
112
-
113
- 2. Admin Panel - Options Tab - the various option settings for the plugin.
114
-
115
- 3. Admin Panel - Fields Tab - the plugin field manager allows you to manage (or delete) the installed extra fields and field order, and also add your own custom fields.
116
-
117
- 4. Admin Panel - Dialogs Tab - the major dialogs that the plugin uses for error and other messages can be edited in the plugin's admin panel.
118
-
119
- 5. Admin Panel - Emails Tab - all of the emails that are sent by the plugin can be edited in the admin panel.
120
-
121
- 6. Posts > All Posts - The plugin adds a column to the list of posts and pages to display if a post or page is unblocked or blocked (the opposite of whatver you have set for the plugin's default in the options tab).
122
-
123
- 7. Posts > Edit Post - The plugin adds a meta box to the post/page editor allowing you to set an individual post to be blocked or unblocked (the opposite of whatver your default setting is).
124
-
125
- 8. Responsive forms.
126
-
127
-
128
- == Changelog ==
129
-
130
- = 3.2.3.2 =
131
-
132
- * Bug fix where export functions are not loaded correctly when exporting individual users.
133
-
134
- = 3.2.3.1 =
135
-
136
- * Login with username or email address was added in 3.2.3. HOWEVER, this was intended to be a "soft launch" and the login form label "Username" was not intended to be changed. This update changes the label back to "Username" until translations can catch up and other testing has been completed. The functionality remains for login with username or email, so feel free to filter the label.
137
- * Implemented change in the native WP registration form processing to allow values of "0" to be interpreted as string literals. Previously could be interpreted as boolean when being saved.
138
-
139
- = 3.2.3 =
140
-
141
- * Bug fix in user export that caused usernames to be dropped.
142
- * Bug fix to allow admins to edit their own profile.
143
- * Bug fix for jquery with regards to select2, only load if products are enabled.
144
- * Added email API.
145
- * Added product attribute to [wpmem_logged_in] shortcode.
146
- * Added wpmem_force_ssl() API function.
147
- * Added wpmem_set_as_logged_in() API function.
148
- * Added filters to remove posts marked hidden from previous/next links.
149
- * Updated user login function to use WP script, facilitates login with username OR email, removes wpmem_login_fields filter, changes to wp_safe_redirect().
150
- * Updated password change for maintaining login state.
151
- * Moved wpmem_fields(), wpmem_form_label(), and wpmem_form_field() to api-forms.php.
152
- * Moved wpmem_user_has_role(), wpmem_user_has_meta(), wpmem_is_user_activated(), wpmem_user_data(), wpmem_update_user_role(), and wpmem_user_has_access() to api-users.php.
153
- * Moved wpmem_do_excerpt(), wpmem_texturize(), wpmem_get_excluded_meta(), wpmem_use_ssl(), wpmem_write_log(), wpmem_load_dropins(), wpmem_array_insert(), and wpmem_get_sub_str() to api-utilities.php.
154
- * Moved wpmem_wp_reserved_terms() to admin API.
155
- * Deprecated wpmem_check_activated() and wpmem_use_ssl().
156
- * Removed obsolete functions wpmem_enqueue_style(), wpmem_convert_tag(), wpmem_no_reset(), and wpmem_user_profile_multipart().
157
- * Applied wpmem_force_ssl() to stylesheet in case it needs to load securely (even if the setting is saved as http://).
158
-
159
- = 3.2.2 =
160
-
161
- * Fixed bug in 3.2.1/3.2.2 for user activation when user creates password at registration and is activated from the user profile.
162
- * Fixed a 3.2 upgrade issue, verifies username field is properly added to field settings array.
163
- * Fixed issue with user product verification where only expiration products were validated.
164
- * Fixed logic in form field builder so multiselect will accept a custom class.
165
- * Added select2 support for setting product access in the post editor.
166
- * Removed duplicate API function wpmem_current_postid() (use wpmem_current_post_id()).
167
- * Replaced sanitize_html_class() with WP_Members_Forms::sanitize_class() so variables may contain multiple classes.
168
-
169
- = 3.2.1 =
170
-
171
- * Fixed duplicate ID in login form.
172
- * Fixed user profile update for excluded fields.
173
- * Fixed native WP registration, excluded WP-Members username field in form validation.
174
- * Fixed update post when block status is not changed.
175
- * Rebuilt user interface for post restriction metabox to make it more intuitive.
176
- * Changed status column in All Posts to show all block statuses, not just those opposite the default.
177
- * Changed "clickable" attribute for field shortcode default to false.
178
- * Added wpmem_user_export_header and wpmem_user_export_row filter for export.
179
-
180
- = 3.2.0 =
181
-
182
- * Tested and compatible with Gutenberg.
183
- * Changed default address meta fields to WooCommerce billing meta keys.
184
- * Removed language packs that install from wordpress.org (de_DE, hu_HU, ja, nl_NL, pt_BR, ru_RU, and sv_SE).
185
- * All remaining user facing strings in get_text() added wp-members textdomain.
186
- * Added locale as a parameter for localization filters.
187
- * Added wpmem_register_hidden_rows filter.
188
- * Added "post_to" key for wpmem_register_form_args.
189
- * Rebuild of user export function. User export now uses fputcsv.
190
- * Updates/code improvement for enqueueing styles.
191
- * Updated widget, added widget_title filter before wpmem_widget_title, documented wpmem_widget_id filter, added instance and id_base parameters.
192
- * Updated empty $fields check to not rewrite fields.
193
- * Deprecated wpmem_inc_status().
194
- * Deprecated wpmem_do_sidebar().
195
- * Deprecated wpmem_create_formfield(), use wpmem_form_field() instead.
196
- * Deprecated a number of non-user callable functions.
197
- * Eliminated capability-based load for admin files.
198
- * Maintain user login state when password is changed.
199
- * Added wpmem_get_sub_str() string manipulation utility.
200
- * Updated login form redirect_to to account for query vars.
201
- * Fixes issue with login status if logout url is encoded (sprintf() has too few arguments).
202
- * Added Membership Products Custom Post Type.
203
- * Added "Hide Post" option for blocking content (currently only by post meta _wpmem_block).
204
- * Removed several outdated stylesheets from selection (still packaged with download for users who may use them).
205
- * Added wpmem_update_user_role() API function.
206
- * Added wpmem_display_message() API function.
207
- * Added wpmem_user_has_access() API function.
208
- * HTML5 update - form anchor tags changed from "name" to "id".
209
- * HTML5 update - form id tags set default value (can still be filtered).
210
- * HTML5 update - removed "align" attribute (captcha, link-text).
211
- * HTML5 update - added placeholder, pattern, and title attribute support for password fields.
212
- * Improved the add a field dialog to adjust required inputs depending on field type.
213
- * Added placeholder, rows, and cols attribute support for textarea field settings.
214
- * Moved remaining core functions to appropriate object classes, left wrappers for most.
215
- * Added new email class and shortcode class to replace previous functions/files.
216
- * Added link_span_before/link_span_after wrapper for login link text.
217
- * Updated "TOS" text to accept a custom label (priority to filtered label with wpmem_tos_link_txt).
218
- * Updated all processing involving "TOS" to better exclude the field on profile update (if saved value equals the field's checked value).
219
- * Fixed a bug that caused WP native fields to be set as non-native when labels were updated in the fields tab.
220
- * Added Customizer control to display login, register, and widget forms when using the Customizer (easier to work on custom CSS).
221
- * Added login/out menu item.
222
-
223
- = 3.1.9 =
224
-
225
- * Security enhancements.
226
- * Improved user search in Users > All Users.
227
- * Fully deprecated obsolete reCAPTCHA v1. If v1 is selected as a setting, it will be automatically changed to v2. (v1 users check your API keys for compatibility.)
228
- * Removed obsolete comments_template.php.
229
- * Set image field to display "medium" image in dashboard/admin user profile. Admin profile image display links to media editor.
230
- * Added default format to date field shortcode to date format set in WP settings.
231
- * Added format attribute to date field shortcode for custom date formatting.
232
- * Added User ID as an optional column for the Users > All Users screen.
233
- * Deprecated wpmem_user_profile(), wpmem_profile_update(), wpmem_user_profile_multipart(), wpmem_admin_fields(), wpmem_admin_update().
234
- * Rebuild of dashboard profile functions incorporated into new user profile object class.
235
- * Fields tab bulk action now checks for both page and tab (rather than just tab) to prevent namespace collisions.
236
- * Removed $requested_redirect_to argument from login_redirect filter hook.
237
- * Removed height property of button_div for generic stylesheets.
238
- * Fixed user edit shortcode to display updated user data without page refresh.
239
- * Fixed password change so that login state is maintained after password update.
240
- * Fix for multiple checkbox and multiple select field types if "comma" was selected as the delimiter (previously, this would break the field settings array option assembly).
241
- * Improvements on field manager add/edit field screen.
242
- * Improvements to multiple checkbox and radio groups: better handling of non-value selections and span wrapper for group separators.
243
-
244
- = 3.1.8 =
245
-
246
- * Added new native registration handling to accommodate WooCommerce 3.0.
247
- * Added support for user file upload on admin/dashboard profile.
248
- * Added meta_key/meta_value attribute to [wpmem_logged_in] shortcode.
249
- * Added wpmem_user_has_meta() API function.
250
- * Updated post editor shortcode button javascript to include new(er) shortcodes.
251
- * Fixed WP-Members user profile shortcode to only display logged in content (by shortcode) if the wpmem_a 'action' is not set (i.e. logged in content only displays if page is in "member links" state).
252
- * Fixed register link in login form to prevent link from displaying if login form is displayed along with the registration form (standard configuration).
253
- * Improved multisite support, including revisions to load all admin dependencies for administrator role, not just super admin. Dependency load role requirement is filterable.
254
- * Improved line break stripping process in form builder to allow for line breaks in textarea fields.
255
- * Improved field shortcode for textarea fields to display line breaks.
256
- * Deprecated old wpmem_do_sc_pages() function, updated wpmem_sc_user_profile().
257
- * Removed $_SERVER['REQUEST_URI'] from all admin tab form action attributes. Replaced with new wpmem_admin_form_post_url() API function.
258
- * Fields Tab: ground-up rebuild to utilize WP_List_Table and jquery sorting UI.
259
- * Fields Tab: improved field add/edit screen: return link at bottom of page, display current field upon successful form submission, success message include return link.
260
- * Fields Tab: added support for HTML5 field types: number, date.
261
- * Fields Tab: added support for HTML5 field attributes: placeholder, pattern (regex), title, min, max.
262
- * Corrects an issue with user profile display/update of textarea fields that are not the WP default bio field.
263
- * Added display=raw attribute handling to textarea fields to allow display without converting line breaks to HTML br tags.
264
- * Fixes issue with User Profile form heading not using the get_text() value.
265
- * Improves logic for displaying register link in login form if login page is not set.
266
-
267
- = 3.1.7 =
268
-
269
- * API updates: added wpmem_is_user_activated().
270
- * API updates: wpmem_is_reg_page() added default of current page ID.
271
- * API updates: wpmem_current_url() added check for query string.
272
- * API updates: Added wpmem_fields filter to wpmem_fields().
273
- * API updates: Added wpmem_current_post_id() and wpmem_form_label() functions.
274
- * API updates: Added new [wpmem_avatar], [wpmem_login_link], and [wpmem_register_link] shortcodes.
275
- * API updates: Added filter option in user export to decode html entities in user fields.
276
- * API updates: Added wpmem_get_action action hook when wpmem_a is loaded.
277
- * All admin dependencies and actions/filters loaded in admin api object.
278
- * Corrected issue in forms function were RS Captcha had empty div wrapper variable.
279
- * Removed deprecated functions wpmem_load_admin_js(), wpmem_test_shortcode(), and wpmem_generatePassword().
280
- * Moved remaining deprecated functions to new inc/deprecated.php.
281
- * Added successful registration message on page if nonce validates (for reg redirects).
282
- * Added User object class, handling login, logout, register.
283
- * Added buffering to login form and widget to allow do_login action results to be displayed (such as 3rd party login captcha).
284
- * Added support for WP's login_redirect filter (loads before wpmem_login_redirect).
285
- * Added a div wrapper for post restricted message.
286
- * Added initial form support for HTML5 number input, & min, max, title, and pattern attributes (placeholder support was added in 3.1.6).
287
- * Updated wpmem_admin_update() to exit if there is no user ID.
288
- * Updated admin notification email to translate field labels.
289
- * Updated login form links and filters to a single process (was one for each).
290
- * Updated WP Registration finalize process.
291
- * Moved form building functions to forms object class.
292
- * Deprecated wpmem_register_fields_arr filter (Use wpmem_fields instead).
293
- * Removing the wpautop() function is now optional rather than default.
294
- * Fixed load fields error checking, install function now correctly returns defaults.
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  * Changed password reset and password change to use wp_set_password() for improved performance with caching.
1
+ === WP-Members Membership Plugin ===
2
+ 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 ==
10
+
11
+ The WP-Members membership plugin turns your WordPress site into a membership site. Restrict premium content, create custom registration fields, and more.
12
+
13
+ === Membership Sites. Simplified. ===
14
+
15
+ You need a membership site, but you want to focus on your business, not mastering a plugin. WP-Members is simple to use, easy to set up, yet flexible in every way imaginable.
16
+
17
+ The plugin restricts selected WordPress content to registered site members. WP-Members puts the registration process on the site front end so it is part of your content instead of the native WP login page. WP-Members requires no modifications to your theme while remaining scalable for users who want to customize the look and feel, or want to restrict only some content. It is a great tool for sites offering premium content to subscribers and is adaptable to a variety of applications.
18
+
19
+ __Simple to install and configure - yet customizable and scalable!__
20
+
21
+ = Features: =
22
+
23
+ * Restrict or hide posts, pages, and custom post types
24
+ * User login, registration, and profile integrated into your theme
25
+ * Login widget
26
+ * Create custom registration and profile fields
27
+ * Notify admin of new user registrations
28
+ * Hold new registrations for admin approval
29
+ * Create post excerpt teaser content automatically
30
+ * [Shortcodes for login, registration, content restriction, and more](https://rkt.bz/docssc)
31
+ * Create powerful customizations with [more than 120 action and filter hooks](https://rkt.bz/hooks)
32
+ * [A library of API functions for extensibility](https://rkt.bz/api)
33
+
34
+ WP-Members allows you to restrict content as restricted or hidden, limiting access to registered users.
35
+
36
+ A full Users Guide is [available here](https://rkt.bz/docs). The guide outlines the installation process, and also documents how to use all of the settings.
37
+
38
+ Get support along with all of the plugin's premium extensions in one [cost saving Pro Bundle!](https://rkt.bz/pro)
39
+
40
+ = Premium Support =
41
+
42
+ Premium support subscribers have access to priority email support, examples, tutorials, and code snippets that will help you extend and customize the base plugin using the plugin's framework. [Visit the site for more info](https://rkt.bz/getsupport).
43
+
44
+ = Premium Extensions =
45
+
46
+ The plugin has several premium extensions for additional functionality. You can purchase any of them individually, or get them all for a significant discount in the Pro Bundle.
47
+
48
+ * [Advanced Options](https://rkt.bz/advanced) - adds additional settings to WP-Members for redirecting core WP created URLs, redirecting restricted content, hiding the WP toolbar, and more! Also includes integrations with popular plugins like WooCommerce, BuddyPress, bbPress, ADF, Easy Digital Downloads, and The Events Calendar.
49
+ * [Download Protect](https://rkt.bz/downloadprotect) - Allows you to restrict access to specific files, requiring the user to be logged in to access.
50
+ * [Invite Codes](https://rkt.bz/invitecodes) - set up invitation codes to restrict registration to only those with a valide invite code.
51
+ * [MailChimp Integration](https://rkt.bz/mailchimp) - add MailChimp list subscription to your registation form.
52
+ * [Memberships for WooCommerce](https://rkt.bz/fR) - Sell memberships through WooCommerce.
53
+ * [PayPal Subscriptions](https://rkt.bz/paypal) - Sell restricted content access through PayPal.
54
+ * [Security](https://rkt.bz/security) - adds a number of security features to the plugin such as preventing concurrent logins, registration form honey pot (spam blocker), require passwords be changed on first use, require passwords to be changed after defined period of time, require strong passwords, block registration by IP and email, restrict specified usernames from being registered.
55
+ * [Text Editor](https://rkt.bz/te) - Adds an editor to the WP-Members admin panel to easily customize all user facing strings in the plugin.
56
+ * [User List](https://rkt.bz/userlist) - Display lists of users on your site. Great for creating user directories with detailed and customizable profiles.
57
+ * [User Tracking](https://rkt.bz/usertrack) - Track what pages logged in users are visting and when.
58
+ * [WordPass Pro](https://rkt.bz/3O) - Change your random password generator from gibberish to word-based passwords (can be used with or without WP-Members).
59
+
60
+ Get support along with all of the plugin's premium extensions in one [cost saving Pro Bundle!](https://rkt.bz/pro)
61
+
62
+
63
+ == Installation ==
64
+
65
+ WP-Members is designed to run "out-of-the-box" with no modifications to your WP installation necessary. Please follow the installation instructions below. __Most of the support issues that arise are a result of improper installation or simply not reading/following directions__.
66
+
67
+ = Basic Install: =
68
+
69
+ The best way to begin is to review the [Initial Setup Video](https://rkt.bz/videos). There is also a complete [Users Guide available](https://rkt.bz/docs) that covers all of the plugin's features in depth.
70
+
71
+ 1. Upload the `/wp-members/` directory and its contents to the `/wp-content/plugins/` directory
72
+ 2. Activate the plugin through the 'Plugins' menu in WordPress&reg;
73
+
74
+ You are ready to begin using WP-Members. Now follow the instructions titled "Locking down your site" below.
75
+
76
+ = Locking down your site: =
77
+
78
+ * To restrict posts, you will need to use the `<!--more-->` link in your posts. Content above to the "more" split will display on summary pages (home, archive, category) but the user will be required to login to view the entire post. You may also use the plugin's auto excerpt setting to create post excerpts automatically. If you do not use the "more" tag or the auto excerpt setting, full post content is going to show on archive templates, unless the post is marked as hidden.
79
+ * To begin restricting pages, change the plugin default setting for pages to be blocked. Unlike posts, the `<!--more-->` link is not necessary in the blocking of pages, but __must__ be used if you have the "show excerpts" setting turned on for pages.
80
+ * To protect comments, we recommend setting "Users must be registered and logged in to comment" under Settings > Discussion.
81
+ * On the Settings > General page, it is recommended that you uncheck "Anyone can register". While not required, this will prevent WP's native registration from colliding with WP-Members, especially if you are using any of the WP-Members additional registration fields.
82
+ * Under Settings > Reading, "For each article in a feed, show" is recommended to be set to "Summary." WordPress installs with full feed settings by default. If you don't change this, your feeds will show full content.
83
+
84
+ = Additional Setup Information =
85
+
86
+ There are also some special pages that can be created with simple shortcodes:
87
+
88
+ * A User Profile page where registered members can edit their information and change/reset their password: [wpmem_profile]
89
+ * A Registration page available for those that need a specific URL for registrations (such as email marketing or banner ad landing pages). Note: this is strictly optional as a registration form can also be included by default on blocked content pages: [wpmem_form register]
90
+ * A Login page. This is also an optional page as the login form is included by default on blocked content. But if you need a specific login page, this can be created with a simple shortcode: [wpmem_form login]
91
+ * [And more shortcodes are available](https://rkt.bz/docssc)!
92
+
93
+ Powerful cusotmizations can be constructed with [over 120 action and filter hooks](https://rkt.bz/hooks), as well as user accessible functions.
94
+
95
+
96
+ == Frequently Asked Questions ==
97
+
98
+ The FAQs are maintained at https://rocketgeek.com/plugins/wp-members/docs/faqs/
99
+
100
+
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
+
108
+ 1. The default when viewing a blocked post - the plugin will deliver a login screen and registration form in place of blocked content (this default can be changed to other options).
109
+
110
+ 2. Admin Panel - Options Tab - the various option settings for the plugin.
111
+
112
+ 3. Admin Panel - Fields Tab - the plugin field manager allows you to manage (or delete) the installed extra fields and field order, and also add your own custom fields.
113
+
114
+ 4. Admin Panel - Dialogs Tab - the major dialogs that the plugin uses for error and other messages can be edited in the plugin's admin panel.
115
+
116
+ 5. Admin Panel - Emails Tab - all of the emails that are sent by the plugin can be edited in the admin panel.
117
+
118
+ 6. Posts > All Posts - The plugin adds a column to the list of posts and pages to display if a post or page is unblocked or blocked (the opposite of whatver you have set for the plugin's default in the options tab).
119
+
120
+ 7. Posts > Edit Post - The plugin adds a meta box to the post/page editor allowing you to set an individual post to be blocked or unblocked (the opposite of whatver your default setting is).
121
+
122
+ 8. Responsive forms.
123
+
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
+
137
+ * Added deactivate users both bulk and single in Users > All Users.
138
+ * Added id attribute for form labels.
139
+ * Added wpmem_format_date() API function.
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
+
153
+ * Bug fix in user export that caused usernames to be dropped.
154
+ * Bug fix to allow admins to edit their own profile.
155
+ * Bug fix for jquery with regards to select2, only load if products are enabled.
156
+ * Added email API.
157
+ * Added product attribute to [wpmem_logged_in] shortcode.
158
+ * Added wpmem_force_ssl() API function.
159
+ * Added wpmem_set_as_logged_in() API function.
160
+ * Added filters to remove posts marked hidden from previous/next links.
161
+ * Updated user login function to use WP script, facilitates login with username OR email, removes wpmem_login_fields filter, changes to wp_safe_redirect().
162
+ * Updated password change for maintaining login state.
163
+ * Moved wpmem_fields(), wpmem_form_label(), and wpmem_form_field() to api-forms.php.
164
+ * Moved wpmem_user_has_role(), wpmem_user_has_meta(), wpmem_is_user_activated(), wpmem_user_data(), wpmem_update_user_role(), and wpmem_user_has_access() to api-users.php.
165
+ * Moved wpmem_do_excerpt(), wpmem_texturize(), wpmem_get_excluded_meta(), wpmem_use_ssl(), wpmem_write_log(), wpmem_load_dropins(), wpmem_array_insert(), and wpmem_get_sub_str() to api-utilities.php.
166
+ * Moved wpmem_wp_reserved_terms() to admin API.
167
+ * Deprecated wpmem_check_activated() and wpmem_use_ssl().
168
+ * Removed obsolete functions wpmem_enqueue_style(), wpmem_convert_tag(), wpmem_no_reset(), and wpmem_user_profile_multipart().
169
+ * Applied wpmem_force_ssl() to stylesheet in case it needs to load securely (even if the setting is saved as http://).
170
+ * Implemented change in the native WP registration form processing to allow values of "0" to be interpreted as string literals. Previously could be interpreted as boolean when being saved.
171
+
172
+ = 3.2.2 =
173
+
174
+ * Fixed bug in 3.2.1/3.2.2 for user activation when user creates password at registration and is activated from the user profile.
175
+ * Fixed a 3.2 upgrade issue, verifies username field is properly added to field settings array.
176
+ * Fixed issue with user product verification where only expiration products were validated.
177
+ * Fixed logic in form field builder so multiselect will accept a custom class.
178
+ * Added select2 support for setting product access in the post editor.
179
+ * Removed duplicate API function wpmem_current_postid() (use wpmem_current_post_id()).
180
+ * Replaced sanitize_html_class() with WP_Members_Forms::sanitize_class() so variables may contain multiple classes.
181
+
182
+ = 3.2.1 =
183
+
184
+ * Fixed duplicate ID in login form.
185
+ * Fixed user profile update for excluded fields.
186
+ * Fixed native WP registration, excluded WP-Members username field in form validation.
187
+ * Fixed update post when block status is not changed.
188
+ * Rebuilt user interface for post restriction metabox to make it more intuitive.
189
+ * Changed status column in All Posts to show all block statuses, not just those opposite the default.
190
+ * Changed "clickable" attribute for field shortcode default to false.
191
+ * Added wpmem_user_export_header and wpmem_user_export_row filter for export.
192
+
193
+ = 3.2.0 =
194
+
195
+ * Tested and compatible with Gutenberg.
196
+ * Changed default address meta fields to WooCommerce billing meta keys.
197
+ * Removed language packs that install from wordpress.org (de_DE, hu_HU, ja, nl_NL, pt_BR, ru_RU, and sv_SE).
198
+ * All remaining user facing strings in get_text() added wp-members textdomain.
199
+ * Added locale as a parameter for localization filters.
200
+ * Added wpmem_register_hidden_rows filter.
201
+ * Added "post_to" key for wpmem_register_form_args.
202
+ * Rebuild of user export function. User export now uses fputcsv.
203
+ * Updates/code improvement for enqueueing styles.
204
+ * Updated widget, added widget_title filter before wpmem_widget_title, documented wpmem_widget_id filter, added instance and id_base parameters.
205
+ * Updated empty $fields check to not rewrite fields.
206
+ * Deprecated wpmem_inc_status().
207
+ * Deprecated wpmem_do_sidebar().
208
+ * Deprecated wpmem_create_formfield(), use wpmem_form_field() instead.
209
+ * Deprecated a number of non-user callable functions.
210
+ * Eliminated capability-based load for admin files.
211
+ * Maintain user login state when password is changed.
212
+ * Added wpmem_get_sub_str() string manipulation utility.
213
+ * Updated login form redirect_to to account for query vars.
214
+ * Fixes issue with login status if logout url is encoded (sprintf() has too few arguments).
215
+ * Added Membership Products Custom Post Type.
216
+ * Added "Hide Post" option for blocking content (currently only by post meta _wpmem_block).
217
+ * Removed several outdated stylesheets from selection (still packaged with download for users who may use them).
218
+ * Added wpmem_update_user_role() API function.
219
+ * Added wpmem_display_message() API function.
220
+ * Added wpmem_user_has_access() API function.
221
+ * HTML5 update - form anchor tags changed from "name" to "id".
222
+ * HTML5 update - form id tags set default value (can still be filtered).
223
+ * HTML5 update - removed "align" attribute (captcha, link-text).
224
+ * HTML5 update - added placeholder, pattern, and title attribute support for password fields.
225
+ * Improved the add a field dialog to adjust required inputs depending on field type.
226
+ * Added placeholder, rows, and cols attribute support for textarea field settings.
227
+ * Moved remaining core functions to appropriate object classes, left wrappers for most.
228
+ * Added new email class and shortcode class to replace previous functions/files.
229
+ * Added link_span_before/link_span_after wrapper for login link text.
230
+ * Updated "TOS" text to accept a custom label (priority to filtered label with wpmem_tos_link_txt).
231
+ * Updated all processing involving "TOS" to better exclude the field on profile update (if saved value equals the field's checked value).
232
+ * Fixed a bug that caused WP native fields to be set as non-native when labels were updated in the fields tab.
233
+ * Added Customizer control to display login, register, and widget forms when using the Customizer (easier to work on custom CSS).
234
+ * Added login/out menu item.
235
+
236
+ = 3.1.9 =
237
+
238
+ * Security enhancements.
239
+ * Improved user search in Users > All Users.
240
+ * Fully deprecated obsolete reCAPTCHA v1. If v1 is selected as a setting, it will be automatically changed to v2. (v1 users check your API keys for compatibility.)
241
+ * Removed obsolete comments_template.php.
242
+ * Set image field to display "medium" image in dashboard/admin user profile. Admin profile image display links to media editor.
243
+ * Added default format to date field shortcode to date format set in WP settings.
244
+ * Added format attribute to date field shortcode for custom date formatting.
245
+ * Added User ID as an optional column for the Users > All Users screen.
246
+ * Deprecated wpmem_user_profile(), wpmem_profile_update(), wpmem_user_profile_multipart(), wpmem_admin_fields(), wpmem_admin_update().
247
+ * Rebuild of dashboard profile functions incorporated into new user profile object class.
248
+ * Fields tab bulk action now checks for both page and tab (rather than just tab) to prevent namespace collisions.
249
+ * Removed $requested_redirect_to argument from login_redirect filter hook.
250
+ * Removed height property of button_div for generic stylesheets.
251
+ * Fixed user edit shortcode to display updated user data without page refresh.
252
+ * Fixed password change so that login state is maintained after password update.
253
+ * Fix for multiple checkbox and multiple select field types if "comma" was selected as the delimiter (previously, this would break the field settings array option assembly).
254
+ * Improvements on field manager add/edit field screen.
255
+ * Improvements to multiple checkbox and radio groups: better handling of non-value selections and span wrapper for group separators.
256
+
257
+ = 3.1.8 =
258
+
259
+ * Added new native registration handling to accommodate WooCommerce 3.0.
260
+ * Added support for user file upload on admin/dashboard profile.
261
+ * Added meta_key/meta_value attribute to [wpmem_logged_in] shortcode.
262
+ * Added wpmem_user_has_meta() API function.
263
+ * Updated post editor shortcode button javascript to include new(er) shortcodes.
264
+ * Fixed WP-Members user profile shortcode to only display logged in content (by shortcode) if the wpmem_a 'action' is not set (i.e. logged in content only displays if page is in "member links" state).
265
+ * Fixed register link in login form to prevent link from displaying if login form is displayed along with the registration form (standard configuration).
266
+ * Improved multisite support, including revisions to load all admin dependencies for administrator role, not just super admin. Dependency load role requirement is filterable.
267
+ * Improved line break stripping process in form builder to allow for line breaks in textarea fields.
268
+ * Improved field shortcode for textarea fields to display line breaks.
269
+ * Deprecated old wpmem_do_sc_pages() function, updated wpmem_sc_user_profile().
270
+ * Removed $_SERVER['REQUEST_URI'] from all admin tab form action attributes. Replaced with new wpmem_admin_form_post_url() API function.
271
+ * Fields Tab: ground-up rebuild to utilize WP_List_Table and jquery sorting UI.
272
+ * Fields Tab: improved field add/edit screen: return link at bottom of page, display current field upon successful form submission, success message include return link.
273
+ * Fields Tab: added support for HTML5 field types: number, date.
274
+ * Fields Tab: added support for HTML5 field attributes: placeholder, pattern (regex), title, min, max.
275
+ * Corrects an issue with user profile display/update of textarea fields that are not the WP default bio field.
276
+ * Added display=raw attribute handling to textarea fields to allow display without converting line breaks to HTML br tags.
277
+ * Fixes issue with User Profile form heading not using the get_text() value.
278
+ * Improves logic for displaying register link in login form if login page is not set.
279
+
280
+ = 3.1.7 =
281
+
282
+ * API updates: added wpmem_is_user_activated().
283
+ * API updates: wpmem_is_reg_page() added default of current page ID.
284
+ * API updates: wpmem_current_url() added check for query string.
285
+ * API updates: Added wpmem_fields filter to wpmem_fields().
286
+ * API updates: Added wpmem_current_post_id() and wpmem_form_label() functions.
287
+ * API updates: Added new [wpmem_avatar], [wpmem_login_link], and [wpmem_register_link] shortcodes.
288
+ * API updates: Added filter option in user export to decode html entities in user fields.
289
+ * API updates: Added wpmem_get_action action hook when wpmem_a is loaded.
290
+ * All admin dependencies and actions/filters loaded in admin api object.
291
+ * Corrected issue in forms function were RS Captcha had empty div wrapper variable.
292
+ * Removed deprecated functions wpmem_load_admin_js(), wpmem_test_shortcode(), and wpmem_generatePassword().
293
+ * Moved remaining deprecated functions to new inc/deprecated.php.
294
+ * Added successful registration message on page if nonce validates (for reg redirects).
295
+ * Added User object class, handling login, logout, register.
296
+ * Added buffering to login form and widget to allow do_login action results to be displayed (such as 3rd party login captcha).
297
+ * Added support for WP's login_redirect filter (loads before wpmem_login_redirect).
298
+ * Added a div wrapper for post restricted message.
299
+ * Added initial form support for HTML5 number input, & min, max, title, and pattern attributes (placeholder support was added in 3.1.6).
300
+ * Updated wpmem_admin_update() to exit if there is no user ID.
301
+ * Updated admin notification email to translate field labels.
302
+ * Updated login form links and filters to a single process (was one for each).
303
+ * Updated WP Registration finalize process.
304
+ * Moved form building functions to forms object class.
305
+ * Deprecated wpmem_register_fields_arr filter (Use wpmem_fields instead).
306
+ * Removing the wpautop() function is now optional rather than default.
307
+ * Fixed load fields error checking, install function now correctly returns defaults.
308
  * Changed password reset and password change to use wp_set_password() for improved performance with caching.
wp-members.php CHANGED
@@ -1,289 +1,289 @@
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.3.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.3.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 . 'wp-members-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 . 'wp-members-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.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.