Version Description
Here is a list of changes in 3.4.0, but for a more detailed look at the impact of some of these items, be sure to review https://rocketgeek.com/release-announcements/wp-members-3-4-0-wow/
- Rebuilds the login widget functions so there are filter hooks that more closely mimic the main body login filters. Every attempt was made to provide an HTML result that is the same as previous versions, as well as providing support for legacy dialog tags.
- Rebuilt and revised user export functionality. Now includes an api function that can be used to customize user exports for a variety of uses.
New Feature Settings: * The default password reset process is now the reset link. New installs will automatically have this setting. Existing installs can change to this by toggling the setting to use the legacy option in Settings > WP-Members > Options > New Features. * The default new registration process now uses the email confirmation link. A user must confirm their email address prior to their account being able to log in. New installs will automatically have this setting, but you may opt to use the legacy option by changing the setting in Settings > WP-Members > Options > New Features. * The default emails at install reflect the above changes. Existing installs as always will not have their email content altered by the upgrade script.
- Post restricted message now completely separate from login form.
Post restricted message now has new wrapper id - #wpmem_restricted_msg
Improved redirect_to handling in login and register forms. Can now specify a page by slug alone in the shortcode param for portability.
Improved Google reCAPTCHA v3 ("invisible captcha") to optionally display on all pages (recommended by Google to improve user "score").
Improved forms display in Customizer, now can view forms on blocked content (not just shortcode pages).
Improved functionality of hidden posts. Now saved in WP settings (options) instead of as a transient.
Improved user count transient. Now expires in 5 minutes instead of 30 seconds (will result in fewer loads of the query).
Membership products now support hierarchy. This can be used for "levels" or for multiple expiration periods yet still only have to assign one membership to content for all child memberships.
HTML email for WP-Members emails can be enabled as an option in the Emails tab.
Login failed dialog now displays login form below the error. Removed "continue" (return) link from default message.
Login failed dialog (#wpmem_msg) text centered in stylesheet instead of applying in the div tag. Best way to customize is using the WP Customizer.
-
Updates to export function.
- deprecated 'export_fields', use 'fields' instead.
Clone menus is deprecated. The setting remains in place for users who have it enabled. But if it is not enabled, the setting is no longer available.
Expands Customizer functionality so logged out forms show on blocked content (not just shortcodes).
Adds integration for WP's "registration_errors" filter hook, allowing for standarized custom validation and integration with other plugins.
New API functions: * wpmem_is_reg_form_showing()
Deprecated functions: * wpmem_inc_loginfailed() * wpmem_inc_regmessage() * wpmem_inc_login() * wpmem_page_pwd_reset() * wpmem_page_user_edit() * wpmem_page_forgot_username() * wpmem_inc_memberlinks() * wpmem_gettext() - use wpmem_get_text() instead. * $wpmem->texturize()
Bug fixes: * Fixes a bug in the signon process that causes the "rememberme" option to be ignored. * Fixes a bug in wpmem_is_blocked() that returns false when checking a specific post ID. * Fixes a bug in the autoexcerpt function that caused a double "read more" link when excerpt length was set to zero.
Release Info
Developer | cbutlerjr |
Plugin | WP-Members Membership Plugin |
Version | 3.4.0 |
Comparing to | |
See all releases |
Code changes from version 3.3.8 to 3.4.0
- README.md +24 -0
- assets/css/admin.css +140 -132
- assets/css/admin.min.css +1 -1
- assets/css/forms/generic-no-float.css +16 -16
- assets/css/forms/generic-no-float.min.css +1 -1
- assets/css/forms/generic-rigid.css +2 -2
- assets/css/forms/wp-members-styles.css +2 -2
- assets/js/admin.js +257 -227
- assets/js/admin.min.js +1 -1
- changelog.txt +181 -3
- includes/admin/admin.php +2 -17
- includes/admin/api.php +118 -118
- includes/admin/class-wp-members-admin-api.php +29 -73
- includes/admin/class-wp-members-admin-users.php +620 -600
- includes/admin/class-wp-members-export.php +0 -219
- includes/admin/class-wp-members-products-admin.php +176 -56
- includes/admin/class-wp-members-user-export.php +297 -0
- includes/admin/dialogs.php +5 -5
- includes/admin/tabs/class-wp-members-admin-tab-captcha.php +320 -319
- includes/admin/tabs/class-wp-members-admin-tab-dialogs.php +3 -3
- includes/admin/tabs/class-wp-members-admin-tab-dropins.php +2 -2
- includes/admin/tabs/class-wp-members-admin-tab-emails.php +74 -10
- includes/admin/tabs/class-wp-members-admin-tab-fields.php +773 -762
- includes/admin/tabs/class-wp-members-admin-tab-options.php +685 -690
- includes/admin/tabs/class-wp-members-dropins-table.php +2 -2
- includes/admin/tabs/class-wp-members-fields-table.php +167 -167
- includes/api/api-email.php +25 -6
- includes/api/api-forms.php +633 -581
- includes/api/api-products.php +64 -41
- includes/api/api-users.php +970 -942
- includes/api/api-utilities.php +56 -92
- includes/api/api.php +124 -51
- includes/class-wp-members-captcha.php +19 -10
- includes/class-wp-members-clone-menus.php +3 -23
- includes/class-wp-members-dialogs.php +398 -0
- includes/class-wp-members-email.php +66 -32
- includes/class-wp-members-forms.php +2180 -2128
- includes/class-wp-members-products.php +540 -526
- includes/class-wp-members-pwd-reset.php +301 -288
- includes/class-wp-members-shortcodes.php +486 -173
- includes/class-wp-members-user-profile.php +611 -609
- includes/class-wp-members-user.php +1228 -1176
- includes/class-wp-members-validation-link.php +385 -349
- includes/class-wp-members-widget.php +145 -31
- includes/class-wp-members.php +1790 -2128
- includes/cli/class-wp-members-cli-settings.php +309 -309
- includes/cli/class-wp-members-cli-user.php +16 -3
- includes/deprecated.php +110 -13
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WP-Members #
|
2 |
+
|
3 |
+
WP-Members™ is a free membership management framework for WordPress® that restricts content to registered users.
|
4 |
+
|
5 |
+
## Description ##
|
6 |
+
|
7 |
+
This is the development repository for the WP-Members plugin for WordPress.
|
8 |
+
|
9 |
+
## Usage Information ##
|
10 |
+
|
11 |
+
Keep in mind that the branch here is a development branch, so it should be tested prior to loading to a production site. Although every effort is made to only load stable updates to this repo, this may not necessarily be production ready and some features may be subject to change prior to release.
|
12 |
+
|
13 |
+
If you need a production ready version of the plugin, use the version hosted here:
|
14 |
+
https://wordpress.org/plugins/wp-members/
|
15 |
+
|
16 |
+
## Bug Reporting and Pull Requests ##
|
17 |
+
|
18 |
+
I do accept pull requests. However, I have a pretty strict standard on what goes into the production version of the plugin. So please make sure that your pull request actually makes sense and is a proper pull request. Also make sure that your code follows WP's code standards for both PHP and inline documentation.
|
19 |
+
|
20 |
+
Make sure any bug reports are actually bugs. A bug is *not* a feature that you wish to operate differently than it currently does in the plugin. A bug is something broken. Unfortunately, I get a lot of bug reports that are essentially feature requests or a user's inability to follow setup instructions. I wish I didn't have to say that, but I do.
|
21 |
+
|
22 |
+
## Feature Requests ##
|
23 |
+
|
24 |
+
I am open to feature requests. However, I have a roadmap in place for the plugin so it ultimately needs to make sense for that. Consider Matt Mullenweg's vision for options in WordPress, which essentially boils down to the fact that too many options make the interface more confusing. Something that is better handled as a customization (through actions and filters) will likely be addressed that way (as it should be) rather than being incorporated into the plugin; but if your idea is a good one, don't hold it back just because you're not sure. All I'm saying is don't have hurt feelings if I see it differently.
|
@@ -1,133 +1,141 @@
|
|
1 |
-
/**
|
2 |
-
* WP-Members Admin Styles CSS
|
3 |
-
*
|
4 |
-
* CSS for the WP-Members admin panels
|
5 |
-
*
|
6 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
-
* Copyright (c) 2006-
|
9 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
-
*
|
11 |
-
* @package WP-Members
|
12 |
-
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*/
|
15 |
-
|
16 |
-
|
17 |
-
.wpmem_tbl_drag {
|
18 |
-
background:#fffbcc;
|
19 |
-
font-weight: bold;
|
20 |
-
border: 1px solid #990000;
|
21 |
-
}
|
22 |
-
|
23 |
-
.column-wpmem_block {
|
24 |
-
width: 80px;
|
25 |
-
}
|
26 |
-
|
27 |
-
#addfieldform li,
|
28 |
-
#editfieldform li,
|
29 |
-
#updatesettings li {
|
30 |
-
padding: 5px 0;
|
31 |
-
}
|
32 |
-
|
33 |
-
#addfieldform label,
|
34 |
-
#editfieldform label,
|
35 |
-
#updatesettings label {
|
36 |
-
float:left;
|
37 |
-
width: 166px;
|
38 |
-
clear: both;
|
39 |
-
display: block;
|
40 |
-
}
|
41 |
-
|
42 |
-
#addfieldform .add-field-indent,
|
43 |
-
#editfieldform .add-field-indent {
|
44 |
-
margin-left: 165px;
|
45 |
-
}
|
46 |
-
|
47 |
-
#fields_postbox,
|
48 |
-
#add_field_postbox {
|
49 |
-
min-width:950px;
|
50 |
-
}
|
51 |
-
|
52 |
-
.req {
|
53 |
-
color: #f00;
|
54 |
-
}
|
55 |
-
|
56 |
-
#the-list {
|
57 |
-
cursor: move;
|
58 |
-
}
|
59 |
-
#sort, #edit {
|
60 |
-
width: 30px;
|
61 |
-
}
|
62 |
-
|
63 |
-
#wpmem_block input {
|
64 |
-
vertical-align: -webkit-baseline-middle;
|
65 |
-
margin: 0 0 8px 0;
|
66 |
-
}
|
67 |
-
#wpmem_block label {
|
68 |
-
margin: 0 0 0 8px;
|
69 |
-
}
|
70 |
-
#wpmem_ok_block_status {
|
71 |
-
margin: 5px 0 0 0;
|
72 |
-
}
|
73 |
-
#wpmem_post_block_status {
|
74 |
-
font-weight: 600;
|
75 |
-
}
|
76 |
-
#wpmem_post_icon_0 {
|
77 |
-
color: red;
|
78 |
-
}
|
79 |
-
#wpmem_post_icon_1 {
|
80 |
-
color: green;
|
81 |
-
}
|
82 |
-
#wpmem_post_icon_2 {
|
83 |
-
color: black;
|
84 |
-
}
|
85 |
-
#wpmem_product_enabled {
|
86 |
-
color: green;
|
87 |
-
}
|
88 |
-
#s2id__wpmem_products,
|
89 |
-
.select2-search-field,
|
90 |
-
#_wpmem_products {
|
91 |
-
width: 100%;
|
92 |
-
}
|
93 |
-
|
94 |
-
/** User Profile Tabs **/
|
95 |
-
#wpmem_user_profile_tabs {
|
96 |
-
padding: 0px;
|
97 |
-
background: none;
|
98 |
-
border-width: 0px;
|
99 |
-
}
|
100 |
-
#wpmem_user_profile_tabs .ui-tabs-nav {
|
101 |
-
padding-left: 0px;
|
102 |
-
background: transparent;
|
103 |
-
border-width: 0px 0px 1px 0px;
|
104 |
-
-moz-border-radius: 0px;
|
105 |
-
-webkit-border-radius: 0px;
|
106 |
-
border-radius: 0px;
|
107 |
-
}
|
108 |
-
#wpmem_user_profile_tabs .ui-tabs-panel {
|
109 |
-
background: #fff;
|
110 |
-
border-width: 0px 1px 1px 1px;
|
111 |
-
}
|
112 |
-
#wpmem_user_profile_tabs .ui-state-active {
|
113 |
-
border: 1px solid #006799;
|
114 |
-
background: #008ec2;
|
115 |
-
}
|
116 |
-
#wpmem_user_profile_tabs .ui-state-active a {
|
117 |
-
color: #fff;
|
118 |
-
}
|
119 |
-
|
120 |
-
#wpmem_product_fixed_period_select label,
|
121 |
-
#wpmem_product_fixed_period_select input,
|
122 |
-
#wpmem_product_no_gap,
|
123 |
-
#wpmem_product_fixed_period {
|
124 |
-
margin-top: 10px;
|
125 |
-
margin-left: 24px;
|
126 |
-
}
|
127 |
-
|
128 |
-
#updatesettings a {
|
129 |
-
text-decoration:none;
|
130 |
-
}
|
131 |
-
updatesettings a:hover {
|
132 |
-
color: black;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
1 |
+
/**
|
2 |
+
* WP-Members Admin Styles CSS
|
3 |
+
*
|
4 |
+
* CSS for the WP-Members admin panels
|
5 |
+
*
|
6 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
+
* Copyright (c) 2006-2021 Chad Butler
|
9 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
+
*
|
11 |
+
* @package WP-Members
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
.wpmem_tbl_drag {
|
18 |
+
background:#fffbcc;
|
19 |
+
font-weight: bold;
|
20 |
+
border: 1px solid #990000;
|
21 |
+
}
|
22 |
+
|
23 |
+
.column-wpmem_block {
|
24 |
+
width: 80px;
|
25 |
+
}
|
26 |
+
|
27 |
+
#addfieldform li,
|
28 |
+
#editfieldform li,
|
29 |
+
#updatesettings li {
|
30 |
+
padding: 5px 0;
|
31 |
+
}
|
32 |
+
|
33 |
+
#addfieldform label,
|
34 |
+
#editfieldform label,
|
35 |
+
#updatesettings label {
|
36 |
+
float:left;
|
37 |
+
width: 166px;
|
38 |
+
clear: both;
|
39 |
+
display: block;
|
40 |
+
}
|
41 |
+
|
42 |
+
#addfieldform .add-field-indent,
|
43 |
+
#editfieldform .add-field-indent {
|
44 |
+
margin-left: 165px;
|
45 |
+
}
|
46 |
+
|
47 |
+
#fields_postbox,
|
48 |
+
#add_field_postbox {
|
49 |
+
min-width:950px;
|
50 |
+
}
|
51 |
+
|
52 |
+
.req {
|
53 |
+
color: #f00;
|
54 |
+
}
|
55 |
+
|
56 |
+
#the-list {
|
57 |
+
cursor: move;
|
58 |
+
}
|
59 |
+
#sort, #edit {
|
60 |
+
width: 30px;
|
61 |
+
}
|
62 |
+
|
63 |
+
#wpmem_block input {
|
64 |
+
vertical-align: -webkit-baseline-middle;
|
65 |
+
margin: 0 0 8px 0;
|
66 |
+
}
|
67 |
+
#wpmem_block label {
|
68 |
+
margin: 0 0 0 8px;
|
69 |
+
}
|
70 |
+
#wpmem_ok_block_status {
|
71 |
+
margin: 5px 0 0 0;
|
72 |
+
}
|
73 |
+
#wpmem_post_block_status {
|
74 |
+
font-weight: 600;
|
75 |
+
}
|
76 |
+
#wpmem_post_icon_0 {
|
77 |
+
color: red;
|
78 |
+
}
|
79 |
+
#wpmem_post_icon_1 {
|
80 |
+
color: green;
|
81 |
+
}
|
82 |
+
#wpmem_post_icon_2 {
|
83 |
+
color: black;
|
84 |
+
}
|
85 |
+
#wpmem_product_enabled {
|
86 |
+
color: green;
|
87 |
+
}
|
88 |
+
#s2id__wpmem_products,
|
89 |
+
.select2-search-field,
|
90 |
+
#_wpmem_products {
|
91 |
+
width: 100%;
|
92 |
+
}
|
93 |
+
|
94 |
+
/** User Profile Tabs **/
|
95 |
+
#wpmem_user_profile_tabs {
|
96 |
+
padding: 0px;
|
97 |
+
background: none;
|
98 |
+
border-width: 0px;
|
99 |
+
}
|
100 |
+
#wpmem_user_profile_tabs .ui-tabs-nav {
|
101 |
+
padding-left: 0px;
|
102 |
+
background: transparent;
|
103 |
+
border-width: 0px 0px 1px 0px;
|
104 |
+
-moz-border-radius: 0px;
|
105 |
+
-webkit-border-radius: 0px;
|
106 |
+
border-radius: 0px;
|
107 |
+
}
|
108 |
+
#wpmem_user_profile_tabs .ui-tabs-panel {
|
109 |
+
background: #fff;
|
110 |
+
border-width: 0px 1px 1px 1px;
|
111 |
+
}
|
112 |
+
#wpmem_user_profile_tabs .ui-state-active {
|
113 |
+
border: 1px solid #006799;
|
114 |
+
background: #008ec2;
|
115 |
+
}
|
116 |
+
#wpmem_user_profile_tabs .ui-state-active a {
|
117 |
+
color: #fff;
|
118 |
+
}
|
119 |
+
|
120 |
+
#wpmem_product_fixed_period_select label,
|
121 |
+
#wpmem_product_fixed_period_select input,
|
122 |
+
#wpmem_product_no_gap,
|
123 |
+
#wpmem_product_fixed_period {
|
124 |
+
margin-top: 10px;
|
125 |
+
margin-left: 24px;
|
126 |
+
}
|
127 |
+
|
128 |
+
#updatesettings a {
|
129 |
+
text-decoration:none;
|
130 |
+
}
|
131 |
+
updatesettings a:hover {
|
132 |
+
color: black;
|
133 |
+
}
|
134 |
+
|
135 |
+
#createuser .form-field input[type="checkbox"] {
|
136 |
+
width: initial;
|
137 |
+
}
|
138 |
+
|
139 |
+
.wpmem-user-table-membership {
|
140 |
+
border-bottom:1px solid #999;
|
141 |
}
|
@@ -1 +1 @@
|
|
1 |
-
.wpmem_tbl_drag{background:#fffbcc;font-weight:700;border:1px solid #900}.column-wpmem_block{width:80px}#addfieldform li,#editfieldform li,#updatesettings li{padding:5px 0}#addfieldform label,#editfieldform label,#updatesettings label{float:left;width:166px;clear:both;display:block}#addfieldform .add-field-indent,#editfieldform .add-field-indent{margin-left:165px}#add_field_postbox,#fields_postbox{min-width:950px}.req{color:red}#the-list{cursor:move}#edit,#sort{width:30px}#wpmem_block input{vertical-align:-webkit-baseline-middle;margin:0 0 8px 0}#wpmem_block label{margin:0 0 0 8px}#wpmem_ok_block_status{margin:5px 0 0 0}#wpmem_post_block_status{font-weight:600}#wpmem_post_icon_0{color:red}#wpmem_post_icon_1{color:green}#wpmem_post_icon_2{color:#000}#wpmem_product_enabled{color:green}#_wpmem_products,#s2id__wpmem_products,.select2-search-field{width:100%}#wpmem_user_profile_tabs{padding:0;background:0 0;border-width:0}#wpmem_user_profile_tabs .ui-tabs-nav{padding-left:0;background:0 0;border-width:0 0 1px 0;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}#wpmem_user_profile_tabs .ui-tabs-panel{background:#fff;border-width:0 1px 1px 1px}#wpmem_user_profile_tabs .ui-state-active{border:1px solid #006799;background:#008ec2}#wpmem_user_profile_tabs .ui-state-active a{color:#fff}#wpmem_product_fixed_period,#wpmem_product_fixed_period_select input,#wpmem_product_fixed_period_select label,#wpmem_product_no_gap{margin-top:10px;margin-left:24px}#updatesettings a{text-decoration:none}updatesettings a:hover{color:#000}
|
1 |
+
.wpmem_tbl_drag{background:#fffbcc;font-weight:700;border:1px solid #900}.column-wpmem_block{width:80px}#addfieldform li,#editfieldform li,#updatesettings li{padding:5px 0}#addfieldform label,#editfieldform label,#updatesettings label{float:left;width:166px;clear:both;display:block}#addfieldform .add-field-indent,#editfieldform .add-field-indent{margin-left:165px}#add_field_postbox,#fields_postbox{min-width:950px}.req{color:red}#the-list{cursor:move}#edit,#sort{width:30px}#wpmem_block input{vertical-align:-webkit-baseline-middle;margin:0 0 8px 0}#wpmem_block label{margin:0 0 0 8px}#wpmem_ok_block_status{margin:5px 0 0 0}#wpmem_post_block_status{font-weight:600}#wpmem_post_icon_0{color:red}#wpmem_post_icon_1{color:green}#wpmem_post_icon_2{color:#000}#wpmem_product_enabled{color:green}#_wpmem_products,#s2id__wpmem_products,.select2-search-field{width:100%}#wpmem_user_profile_tabs{padding:0;background:0 0;border-width:0}#wpmem_user_profile_tabs .ui-tabs-nav{padding-left:0;background:0 0;border-width:0 0 1px 0;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}#wpmem_user_profile_tabs .ui-tabs-panel{background:#fff;border-width:0 1px 1px 1px}#wpmem_user_profile_tabs .ui-state-active{border:1px solid #006799;background:#008ec2}#wpmem_user_profile_tabs .ui-state-active a{color:#fff}#wpmem_product_fixed_period,#wpmem_product_fixed_period_select input,#wpmem_product_fixed_period_select label,#wpmem_product_no_gap{margin-top:10px;margin-left:24px}#updatesettings a{text-decoration:none}updatesettings a:hover{color:#000}#createuser .form-field input[type="checkbox"]{width: initial;}.wpmem-user-table-membership {border-bottom:1px solid #999;}
|
@@ -5,12 +5,12 @@
|
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
-
* Copyright (c) 2006-
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
*/
|
15 |
|
16 |
/*
|
@@ -27,23 +27,25 @@ For information how to load custom stylesheets with wp_enqueue_style,
|
|
27 |
see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
28 |
*/
|
29 |
|
30 |
-
|
31 |
/* Error and Dialog Messages */
|
32 |
|
33 |
#wpmem_msg,
|
34 |
.wpmem_msg {
|
|
|
35 |
background: #F9F9F9;
|
36 |
border:1px solid lightGrey;
|
37 |
border-radius: 3px;
|
38 |
-
padding: 20px 0
|
39 |
-
|
40 |
-
#wpmem_msg {
|
41 |
-
width: 100%;
|
42 |
-
}
|
43 |
-
.wpmem_msg {
|
44 |
-
width: 74%;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
/* Sidebar Login Widget */
|
49 |
|
@@ -76,8 +78,8 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
76 |
border-radius: 3px;
|
77 |
}
|
78 |
|
79 |
-
|
80 |
/* Login Form and Registration Form */
|
|
|
81 |
#wpmem_reg,
|
82 |
#wpmem_login {
|
83 |
color: rgb(43, 43, 43);
|
@@ -135,6 +137,7 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
135 |
border-radius: 2px;
|
136 |
color: rgb(43, 43, 43);
|
137 |
margin: 5px 0;
|
|
|
138 |
}
|
139 |
|
140 |
#wpmem_reg fieldset,
|
@@ -177,8 +180,8 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
177 |
#wpmem_reg .div_file,
|
178 |
#wpmem_reg .div_url,
|
179 |
#wpmem_reg .div_number,
|
180 |
-
#wpmem_reg .div_date
|
181 |
-
|
182 |
margin:0 0 14px 0;
|
183 |
}
|
184 |
#wpmem_login input[type="checkbox"] {
|
@@ -220,7 +223,6 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
220 |
}
|
221 |
|
222 |
#wpmem_reg .captcha {
|
223 |
-
width: 74%;
|
224 |
margin: 5px 0px;
|
225 |
}
|
226 |
#wpmem_reg .captcha table{
|
@@ -228,7 +230,6 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
228 |
}
|
229 |
#wpmem_login .link-text {
|
230 |
padding: 4px 0;
|
231 |
-
width: 74%;
|
232 |
text-align:right;
|
233 |
}
|
234 |
|
@@ -240,7 +241,6 @@ see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
|
240 |
/* Buttons */
|
241 |
|
242 |
#wpmem_reg .button_div, #wpmem_login .button_div {
|
243 |
-
width:74%;
|
244 |
/* height:55px; */
|
245 |
padding: 6px 0;
|
246 |
text-align: right;
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
+
* Copyright (c) 2006-2021 Chad Butler
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
*/
|
15 |
|
16 |
/*
|
27 |
see https://rocketgeek.com/tips-and-tricks/load-a-custom-stylesheet/
|
28 |
*/
|
29 |
|
|
|
30 |
/* Error and Dialog Messages */
|
31 |
|
32 |
#wpmem_msg,
|
33 |
.wpmem_msg {
|
34 |
+
text-align: center;
|
35 |
background: #F9F9F9;
|
36 |
border:1px solid lightGrey;
|
37 |
border-radius: 3px;
|
38 |
+
padding: 20px 0;
|
39 |
+
margin: 15px 0;
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
+
/* Messages and forms should (ideally) be the same width */
|
43 |
+
#wpmem_msg,
|
44 |
+
.wpmem_msg,
|
45 |
+
#wpmem_reg,
|
46 |
+
#wpmem_login {
|
47 |
+
width: 75%;
|
48 |
+
}
|
49 |
|
50 |
/* Sidebar Login Widget */
|
51 |
|
78 |
border-radius: 3px;
|
79 |
}
|
80 |
|
|
|
81 |
/* Login Form and Registration Form */
|
82 |
+
|
83 |
#wpmem_reg,
|
84 |
#wpmem_login {
|
85 |
color: rgb(43, 43, 43);
|
137 |
border-radius: 2px;
|
138 |
color: rgb(43, 43, 43);
|
139 |
margin: 5px 0;
|
140 |
+
background: none repeat scroll 0% 0% #fff;
|
141 |
}
|
142 |
|
143 |
#wpmem_reg fieldset,
|
180 |
#wpmem_reg .div_file,
|
181 |
#wpmem_reg .div_url,
|
182 |
#wpmem_reg .div_number,
|
183 |
+
#wpmem_reg .div_date,
|
184 |
+
#wpmem_reg .div_membership {
|
185 |
margin:0 0 14px 0;
|
186 |
}
|
187 |
#wpmem_login input[type="checkbox"] {
|
223 |
}
|
224 |
|
225 |
#wpmem_reg .captcha {
|
|
|
226 |
margin: 5px 0px;
|
227 |
}
|
228 |
#wpmem_reg .captcha table{
|
230 |
}
|
231 |
#wpmem_login .link-text {
|
232 |
padding: 4px 0;
|
|
|
233 |
text-align:right;
|
234 |
}
|
235 |
|
241 |
/* Buttons */
|
242 |
|
243 |
#wpmem_reg .button_div, #wpmem_login .button_div {
|
|
|
244 |
/* height:55px; */
|
245 |
padding: 6px 0;
|
246 |
text-align: right;
|
@@ -1 +1 @@
|
|
1 |
-
#wpmem_msg,.wpmem_msg{background:#f9f9f9;border:1px solid #d3d3d3;border-radius:3px;padding:20px 0 0
|
1 |
+
#wpmem_msg,.wpmem_msg{text-align:center;background:#f9f9f9;border:1px solid #d3d3d3;border-radius:3px;padding:20px 0;margin:15px 0;}#wpmem_login,#wpmem_msg,#wpmem_reg,.wpmem_msg{width:75%}#wp-members{width:100%}#wp-members fieldset{border:none;padding:0}#wp-members input{font-family:inherit}#wp-members input[type=password],#wp-members input[type=text]{margin:0 0 4px 0}#wp-members input[type=submit]{padding:5px 6px 4px;margin:0 4px 0 0}#wp-members .button_div{margin-top:4px}#wp-members .err{width:100%;padding:5px;font-family:inherit;border:1px solid #ccc;border-radius:3px}#wpmem_login,#wpmem_reg{color:#2b2b2b;font-family:Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.5}#wpmem_login label,#wpmem_reg label{display:initial}#wpmem_login input[type=password],#wpmem_login input[type=text],#wpmem_reg input[type=date],#wpmem_reg input[type=email],#wpmem_reg input[type=number],#wpmem_reg input[type=password],#wpmem_reg input[type=text],#wpmem_reg input[type=url],#wpmem_reg textarea{border:1px solid rgba(0,0,0,.1);border-radius:2px;color:#2b2b2b;padding:8px 10px 8px;background:none repeat scroll 0 0 #fff}#wpmem_login button,#wpmem_login input,#wpmem_reg button,#wpmem_reg input,#wpmem_reg select,#wpmem_reg textarea{-moz-box-sizing:border-box;font-size:100%;margin:0;max-width:100%;vertical-align:baseline}#wpmem_login input:focus,#wpmem_reg input:focus,#wpmem_reg textarea:focus{border:1px solid rgba(0,0,0,.3);outline:0 none}#wpmem_reg select{width:100%;padding:8px 10px 7px;border:1px solid rgba(0,0,0,.1);border-radius:2px;color:#2b2b2b;margin:5px 0;background:none repeat scroll 0 0 #fff}#wpmem_login fieldset,#wpmem_reg fieldset{border:none;padding:0;margin:40px 0}#wpmem_login legend,#wpmem_reg legend{font-size:24px;line-height:1;font-weight:700;margin-bottom:10px;width:100%}#wpmem_login .form,#wpmem_reg .form{margin:0;padding:0}#wpmem_login .clear,#wpmem_reg .clear{clear:both}#wpmem_login .holder,#wpmem_reg .holder{background-color:#fff}#wpmem_login .div_text,#wpmem_reg .div_checkbox,#wpmem_reg .div_date,#wpmem_reg .div_file,#wpmem_reg .div_image,#wpmem_reg .div_membership,#wpmem_reg .div_multicheckbox,#wpmem_reg .div_multiselect,#wpmem_reg .div_number,#wpmem_reg .div_radio,#wpmem_reg .div_select,#wpmem_reg .div_text,#wpmem_reg .div_textarea,#wpmem_reg .div_url{margin:0 0 14px 0}#wpmem_login input[type=checkbox]{margin:12px 2px}#wpmem_login .password,#wpmem_login .textbox,#wpmem_login .username,#wpmem_reg .div_textarea textarea,#wpmem_reg .file,#wpmem_reg .image,#wpmem_reg .password,#wpmem_reg .textbox,#wpmem_reg .username{width:100%}#wpmem_reg textarea{height:185px}#wpmem_reg .req{color:#bd3500;font-size:22px;line-height:50%}#wpmem_reg .req-text{margin:20px 0 0 5px}#wpmem_reg .noinput{width:93%;padding:8px 10px 7px;border:1px solid rgba(0,0,0,.1);border-radius:2px;color:#2b2b2b;margin:5px 0}#wpmem_reg .captcha{margin:5px 0}#wpmem_reg .captcha table{line-height:0}#wpmem_login .link-text{padding:4px 0;text-align:right}#tos{margin-right:5px}#wpmem_login .button_div,#wpmem_reg .button_div{padding:6px 0;text-align:right}@media screen and (max-width:720px){#wpmem_login .button_div,#wpmem_login .div_text,#wpmem_login label,#wpmem_reg .button_div,#wpmem_reg .div_checkbox,#wpmem_reg .div_select,#wpmem_reg .div_text,#wpmem_reg .div_textarea,#wpmem_reg label.checkbox,#wpmem_reg label.select,#wpmem_reg label.text,#wpmem_reg label.textarea{float:none}#wpmem_reg label.checkbox,#wpmem_reg label.select,#wpmem_reg label.text,#wpmem_reg label.textarea{width:90%;padding:5px 0 0 0}#wpmem_reg label.textarea{height:26px}#wpmem_login .div_text,#wpmem_reg .div_checkbox,#wpmem_reg .div_select,#wpmem_reg .div_text,#wpmem_reg .div_textarea{width:98%}#wpmem_msg,.wpmem_msg{width:100%}#wpmem_login .button_div,#wpmem_login .link-text,#wpmem_reg .button_div{width:98%}}
|
@@ -5,12 +5,12 @@
|
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
-
* Copyright (c) 2006-
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
*/
|
15 |
|
16 |
/*
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
+
* Copyright (c) 2006-2021 Chad Butler
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
*/
|
15 |
|
16 |
/*
|
@@ -5,12 +5,12 @@
|
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
-
* Copyright (c) 2006-
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
*/
|
15 |
|
16 |
/*
|
5 |
*
|
6 |
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
+
* Copyright (c) 2006-2021 Chad Butler
|
9 |
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
*
|
11 |
* @package WP-Members
|
12 |
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
*/
|
15 |
|
16 |
/*
|
@@ -1,227 +1,257 @@
|
|
1 |
-
/**
|
2 |
-
* WP-Members Admin JavaScript Functions
|
3 |
-
*
|
4 |
-
* Contains the JavaScript functions for WP-Members admin.
|
5 |
-
*
|
6 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
-
* Copyright (c) 2006-
|
9 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
-
*
|
11 |
-
* @package WP-Members
|
12 |
-
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*/
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* JS for forms field table drag-and-drop.
|
19 |
-
*
|
20 |
-
* @since 3.1.2
|
21 |
-
*/
|
22 |
-
(function($) {
|
23 |
-
$(document).ready(function($) {
|
24 |
-
$("#the-list").sortable({
|
25 |
-
items: '.list_item',
|
26 |
-
opacity: 0.6,
|
27 |
-
cursor: 'move',
|
28 |
-
axis: 'y',
|
29 |
-
update: function() {
|
30 |
-
var order = $(this).sortable('serialize') + '&action=wpmem_do_field_reorder';
|
31 |
-
$.post(ajaxurl, order, function(response) {
|
32 |
-
alert(response);
|
33 |
-
});
|
34 |
-
$('.list_item').each(function(i) {
|
35 |
-
$(this).data('id', i + 1); // updates the data object
|
36 |
-
$(this).attr('list_item', i + 1); // updates the attribute
|
37 |
-
});
|
38 |
-
}
|
39 |
-
});
|
40 |
-
});
|
41 |
-
})(jQuery);
|
42 |
-
|
43 |
-
|
44 |
-
/**
|
45 |
-
* JS for displaying custom url for:
|
46 |
-
* - Profile page
|
47 |
-
* - Register page
|
48 |
-
* - Custom stylesheet
|
49 |
-
*
|
50 |
-
* @since 2.9.6
|
51 |
-
*/
|
52 |
-
(function($) {
|
53 |
-
$(document).ready(function() {
|
54 |
-
if ($("#wpmem_logpage_select").val() == 'use_custom')
|
55 |
-
$("#wpmem_logpage_custom").show();
|
56 |
-
else
|
57 |
-
$("#wpmem_logpage_custom").hide();
|
58 |
-
if ($("#wpmem_regpage_select").val() == 'use_custom')
|
59 |
-
$("#wpmem_regpage_custom").show();
|
60 |
-
else
|
61 |
-
$("#wpmem_regpage_custom").hide();
|
62 |
-
if ($("#wpmem_mspage_select").val() == 'use_custom')
|
63 |
-
$("#wpmem_mspage_custom").show();
|
64 |
-
else
|
65 |
-
$("#wpmem_mspage_custom").hide();
|
66 |
-
if ($("#wpmem_stylesheet_select").val() == 'use_custom')
|
67 |
-
$("#wpmem_stylesheet_custom").show();
|
68 |
-
else
|
69 |
-
$("#wpmem_stylesheet_custom").hide();
|
70 |
-
$("#wpmem_logpage_select").change(function() {
|
71 |
-
if ($("#wpmem_logpage_select").val() == 'use_custom')
|
72 |
-
$("#wpmem_logpage_custom").show();
|
73 |
-
else
|
74 |
-
$("#wpmem_logpage_custom").hide();
|
75 |
-
});
|
76 |
-
$("#wpmem_regpage_select").change(function() {
|
77 |
-
if ($("#wpmem_regpage_select").val() == 'use_custom')
|
78 |
-
$("#wpmem_regpage_custom").show();
|
79 |
-
else
|
80 |
-
$("#wpmem_regpage_custom").hide();
|
81 |
-
});
|
82 |
-
$("#wpmem_mspage_select").change(function() {
|
83 |
-
if ($("#wpmem_mspage_select").val() == 'use_custom')
|
84 |
-
$("#wpmem_mspage_custom").show();
|
85 |
-
else
|
86 |
-
$("#wpmem_mspage_custom").hide();
|
87 |
-
});
|
88 |
-
$("#wpmem_stylesheet_select").change(function() {
|
89 |
-
if ($("#wpmem_stylesheet_select").val() == 'use_custom')
|
90 |
-
$("#wpmem_stylesheet_custom").show();
|
91 |
-
else
|
92 |
-
$("#wpmem_stylesheet_custom").hide();
|
93 |
-
});
|
94 |
-
});
|
95 |
-
})(jQuery);
|
96 |
-
|
97 |
-
|
98 |
-
/**
|
99 |
-
* JS for displaying additional info for checkbox/dropdowns
|
100 |
-
*
|
101 |
-
* @since 2.9.6
|
102 |
-
*/
|
103 |
-
(function($) {
|
104 |
-
$(document).ready(function() {
|
105 |
-
$("#wpmem_allowhtml").hide();
|
106 |
-
$("#wpmem_rows_cols").hide();
|
107 |
-
$("#wpmem_min_max").hide();
|
108 |
-
$("#wpmem_checkbox_info").hide();
|
109 |
-
$("#wpmem_dropdown_info").hide();
|
110 |
-
$("#wpmem_file_info").hide();
|
111 |
-
$("#wpmem_delimiter_info").hide();
|
112 |
-
$("#wpmem_hidden_info").hide();
|
113 |
-
});
|
114 |
-
$(document).ready(function() {
|
115 |
-
$("#wpmem_field_type_select").change(function() {
|
116 |
-
if ($("#wpmem_field_type_select").val() == 'text'
|
117 |
-
|| $("#wpmem_field_type_select").val() == 'password'
|
118 |
-
|| $("#wpmem_field_type_select").val() == 'email'
|
119 |
-
|| $("#wpmem_field_type_select").val() == 'url'
|
120 |
-
|| $("#wpmem_field_type_select").val() == 'number'
|
121 |
-
|| $("#wpmem_field_type_select").val() == 'date'
|
122 |
-
|| $("#wpmem_field_type_select").val() == 'textarea' )
|
123 |
-
$("#wpmem_placeholder").show();
|
124 |
-
else
|
125 |
-
$("#wpmem_placeholder").hide();
|
126 |
-
if ($("#wpmem_field_type_select").val() == 'text'
|
127 |
-
|| $("#wpmem_field_type_select").val() == 'password'
|
128 |
-
|| $("#wpmem_field_type_select").val() == 'email'
|
129 |
-
|| $("#wpmem_field_type_select").val() == 'url'
|
130 |
-
|| $("#wpmem_field_type_select").val() == 'date' ) {
|
131 |
-
$("#wpmem_pattern").show();
|
132 |
-
$("#wpmem_title").show();
|
133 |
-
} else {
|
134 |
-
$("#wpmem_pattern").hide();
|
135 |
-
$("#wpmem_title").hide();
|
136 |
-
}
|
137 |
-
if ($("#wpmem_field_type_select").val() == 'textarea' ) {
|
138 |
-
$("#wpmem_allowhtml").show();
|
139 |
-
$("#wpmem_rows_cols").show();
|
140 |
-
} else {
|
141 |
-
$("#wpmem_allowhtml").hide();
|
142 |
-
$("#wpmem_rows_cols").hide();
|
143 |
-
}
|
144 |
-
if ($("#wpmem_field_type_select").val() == 'number' || $("#wpmem_field_type_select").val() == 'date' )
|
145 |
-
$("#wpmem_min_max").show();
|
146 |
-
else
|
147 |
-
$("#wpmem_min_max").hide();
|
148 |
-
if ($("#wpmem_field_type_select").val() == 'checkbox') {
|
149 |
-
$("#wpmem_checkbox_info").show();
|
150 |
-
$("#add_checked_value").prop('required',true);
|
151 |
-
} else {
|
152 |
-
$("#wpmem_checkbox_info").hide();
|
153 |
-
$("#add_checked_value").prop('required',false);
|
154 |
-
}
|
155 |
-
if ( $("#wpmem_field_type_select").val() == 'select'
|
156 |
-
|| $("#wpmem_field_type_select").val() == 'multiselect'
|
157 |
-
|| $("#wpmem_field_type_select").val() == 'radio'
|
158 |
-
|| $("#wpmem_field_type_select").val() == 'multicheckbox'
|
159 |
-
) {
|
160 |
-
$("#wpmem_dropdown_info").show();
|
161 |
-
$("#add_dropdown_value").prop('required',true);
|
162 |
-
} else {
|
163 |
-
$("#wpmem_dropdown_info").hide();
|
164 |
-
$("#add_dropdown_value").prop('required',false);
|
165 |
-
}
|
166 |
-
if ( $("#wpmem_field_type_select").val() == 'multiselect' || $("#wpmem_field_type_select").val() == 'multicheckbox'
|
167 |
-
)
|
168 |
-
$("#wpmem_delimiter_info").show();
|
169 |
-
else
|
170 |
-
$("#wpmem_delimiter_info").hide();
|
171 |
-
if ($("#wpmem_field_type_select").val() == 'file' || $("#wpmem_field_type_select").val() == 'image' )
|
172 |
-
$("#wpmem_file_info").show();
|
173 |
-
else
|
174 |
-
$("#wpmem_file_info").hide();
|
175 |
-
if ($("#wpmem_field_type_select").val() == 'hidden') {
|
176 |
-
$("#wpmem_hidden_info").show();
|
177 |
-
$("#add_hidden_value").prop('required',true);
|
178 |
-
} else {
|
179 |
-
$("#wpmem_hidden_info").hide();
|
180 |
-
$("#add_hidden_value").prop('required',false);
|
181 |
-
}
|
182 |
-
});
|
183 |
-
});
|
184 |
-
})(jQuery);
|
185 |
-
|
186 |
-
/**
|
187 |
-
* JS for post block status meta box
|
188 |
-
*
|
189 |
-
* @since 3.2.1
|
190 |
-
*/
|
191 |
-
(function($) {
|
192 |
-
$(document).ready(function() {
|
193 |
-
$("#wpmem_block").hide();
|
194 |
-
});
|
195 |
-
$(document).ready(function() {
|
196 |
-
$("#wpmem_edit_block_status").click(function() {
|
197 |
-
$("#wpmem_block").show('normal');
|
198 |
-
$("#wpmem_edit_block_status").hide();
|
199 |
-
});
|
200 |
-
$("#wpmem_cancel_block_status").click(function() {
|
201 |
-
$("#wpmem_block").hide('normal');
|
202 |
-
$("#wpmem_edit_block_status").show();
|
203 |
-
$("#wpmem_post_block_status").text($("input[name=wpmem_block_original_label]").val());
|
204 |
-
$('#wpmem_post_block_status_' + $('input[name=wpmem_block_original_value]')).val().prop("checked", true);
|
205 |
-
});
|
206 |
-
$("#wpmem_ok_block_status").click(function() {
|
207 |
-
$("#wpmem_block").hide('normal');
|
208 |
-
$("#wpmem_edit_block_status").show();
|
209 |
-
$("#wpmem_post_block_status").text($("input[name=wpmem_block]:checked + label").text());
|
210 |
-
if($('#wpmem_block_status_0').is(':checked')) {
|
211 |
-
$("#wpmem_post_icon_0").show();
|
212 |
-
$("#wpmem_post_icon_1").hide();
|
213 |
-
$("#wpmem_post_icon_2").hide();
|
214 |
-
}
|
215 |
-
if($('#wpmem_block_status_1').is(':checked')) {
|
216 |
-
$("#wpmem_post_icon_0").hide();
|
217 |
-
$("#wpmem_post_icon_1").show();
|
218 |
-
$("#wpmem_post_icon_2").hide();
|
219 |
-
}
|
220 |
-
if($('#wpmem_block_status_2').is(':checked')) {
|
221 |
-
$("#wpmem_post_icon_0").hide();
|
222 |
-
$("#wpmem_post_icon_1").hide();
|
223 |
-
$("#wpmem_post_icon_2").show();
|
224 |
-
}
|
225 |
-
});
|
226 |
-
});
|
227 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* WP-Members Admin JavaScript Functions
|
3 |
+
*
|
4 |
+
* Contains the JavaScript functions for WP-Members admin.
|
5 |
+
*
|
6 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
7 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
8 |
+
* Copyright (c) 2006-2021 Chad Butler
|
9 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
10 |
+
*
|
11 |
+
* @package WP-Members
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
+
*/
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* JS for forms field table drag-and-drop.
|
19 |
+
*
|
20 |
+
* @since 3.1.2
|
21 |
+
*/
|
22 |
+
(function($) {
|
23 |
+
$(document).ready(function($) {
|
24 |
+
$("#the-list").sortable({
|
25 |
+
items: '.list_item',
|
26 |
+
opacity: 0.6,
|
27 |
+
cursor: 'move',
|
28 |
+
axis: 'y',
|
29 |
+
update: function() {
|
30 |
+
var order = $(this).sortable('serialize') + '&action=wpmem_do_field_reorder';
|
31 |
+
$.post(ajaxurl, order, function(response) {
|
32 |
+
alert(response);
|
33 |
+
});
|
34 |
+
$('.list_item').each(function(i) {
|
35 |
+
$(this).data('id', i + 1); // updates the data object
|
36 |
+
$(this).attr('list_item', i + 1); // updates the attribute
|
37 |
+
});
|
38 |
+
}
|
39 |
+
});
|
40 |
+
});
|
41 |
+
})(jQuery);
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* JS for displaying custom url for:
|
46 |
+
* - Profile page
|
47 |
+
* - Register page
|
48 |
+
* - Custom stylesheet
|
49 |
+
*
|
50 |
+
* @since 2.9.6
|
51 |
+
*/
|
52 |
+
(function($) {
|
53 |
+
$(document).ready(function() {
|
54 |
+
if ($("#wpmem_logpage_select").val() == 'use_custom')
|
55 |
+
$("#wpmem_logpage_custom").show();
|
56 |
+
else
|
57 |
+
$("#wpmem_logpage_custom").hide();
|
58 |
+
if ($("#wpmem_regpage_select").val() == 'use_custom')
|
59 |
+
$("#wpmem_regpage_custom").show();
|
60 |
+
else
|
61 |
+
$("#wpmem_regpage_custom").hide();
|
62 |
+
if ($("#wpmem_mspage_select").val() == 'use_custom')
|
63 |
+
$("#wpmem_mspage_custom").show();
|
64 |
+
else
|
65 |
+
$("#wpmem_mspage_custom").hide();
|
66 |
+
if ($("#wpmem_stylesheet_select").val() == 'use_custom')
|
67 |
+
$("#wpmem_stylesheet_custom").show();
|
68 |
+
else
|
69 |
+
$("#wpmem_stylesheet_custom").hide();
|
70 |
+
$("#wpmem_logpage_select").change(function() {
|
71 |
+
if ($("#wpmem_logpage_select").val() == 'use_custom')
|
72 |
+
$("#wpmem_logpage_custom").show();
|
73 |
+
else
|
74 |
+
$("#wpmem_logpage_custom").hide();
|
75 |
+
});
|
76 |
+
$("#wpmem_regpage_select").change(function() {
|
77 |
+
if ($("#wpmem_regpage_select").val() == 'use_custom')
|
78 |
+
$("#wpmem_regpage_custom").show();
|
79 |
+
else
|
80 |
+
$("#wpmem_regpage_custom").hide();
|
81 |
+
});
|
82 |
+
$("#wpmem_mspage_select").change(function() {
|
83 |
+
if ($("#wpmem_mspage_select").val() == 'use_custom')
|
84 |
+
$("#wpmem_mspage_custom").show();
|
85 |
+
else
|
86 |
+
$("#wpmem_mspage_custom").hide();
|
87 |
+
});
|
88 |
+
$("#wpmem_stylesheet_select").change(function() {
|
89 |
+
if ($("#wpmem_stylesheet_select").val() == 'use_custom')
|
90 |
+
$("#wpmem_stylesheet_custom").show();
|
91 |
+
else
|
92 |
+
$("#wpmem_stylesheet_custom").hide();
|
93 |
+
});
|
94 |
+
});
|
95 |
+
})(jQuery);
|
96 |
+
|
97 |
+
|
98 |
+
/**
|
99 |
+
* JS for displaying additional info for checkbox/dropdowns
|
100 |
+
*
|
101 |
+
* @since 2.9.6
|
102 |
+
*/
|
103 |
+
(function($) {
|
104 |
+
$(document).ready(function() {
|
105 |
+
$("#wpmem_allowhtml").hide();
|
106 |
+
$("#wpmem_rows_cols").hide();
|
107 |
+
$("#wpmem_min_max").hide();
|
108 |
+
$("#wpmem_checkbox_info").hide();
|
109 |
+
$("#wpmem_dropdown_info").hide();
|
110 |
+
$("#wpmem_file_info").hide();
|
111 |
+
$("#wpmem_delimiter_info").hide();
|
112 |
+
$("#wpmem_hidden_info").hide();
|
113 |
+
});
|
114 |
+
$(document).ready(function() {
|
115 |
+
$("#wpmem_field_type_select").change(function() {
|
116 |
+
if ($("#wpmem_field_type_select").val() == 'text'
|
117 |
+
|| $("#wpmem_field_type_select").val() == 'password'
|
118 |
+
|| $("#wpmem_field_type_select").val() == 'email'
|
119 |
+
|| $("#wpmem_field_type_select").val() == 'url'
|
120 |
+
|| $("#wpmem_field_type_select").val() == 'number'
|
121 |
+
|| $("#wpmem_field_type_select").val() == 'date'
|
122 |
+
|| $("#wpmem_field_type_select").val() == 'textarea' )
|
123 |
+
$("#wpmem_placeholder").show();
|
124 |
+
else
|
125 |
+
$("#wpmem_placeholder").hide();
|
126 |
+
if ($("#wpmem_field_type_select").val() == 'text'
|
127 |
+
|| $("#wpmem_field_type_select").val() == 'password'
|
128 |
+
|| $("#wpmem_field_type_select").val() == 'email'
|
129 |
+
|| $("#wpmem_field_type_select").val() == 'url'
|
130 |
+
|| $("#wpmem_field_type_select").val() == 'date' ) {
|
131 |
+
$("#wpmem_pattern").show();
|
132 |
+
$("#wpmem_title").show();
|
133 |
+
} else {
|
134 |
+
$("#wpmem_pattern").hide();
|
135 |
+
$("#wpmem_title").hide();
|
136 |
+
}
|
137 |
+
if ($("#wpmem_field_type_select").val() == 'textarea' ) {
|
138 |
+
$("#wpmem_allowhtml").show();
|
139 |
+
$("#wpmem_rows_cols").show();
|
140 |
+
} else {
|
141 |
+
$("#wpmem_allowhtml").hide();
|
142 |
+
$("#wpmem_rows_cols").hide();
|
143 |
+
}
|
144 |
+
if ($("#wpmem_field_type_select").val() == 'number' || $("#wpmem_field_type_select").val() == 'date' )
|
145 |
+
$("#wpmem_min_max").show();
|
146 |
+
else
|
147 |
+
$("#wpmem_min_max").hide();
|
148 |
+
if ($("#wpmem_field_type_select").val() == 'checkbox') {
|
149 |
+
$("#wpmem_checkbox_info").show();
|
150 |
+
$("#add_checked_value").prop('required',true);
|
151 |
+
} else {
|
152 |
+
$("#wpmem_checkbox_info").hide();
|
153 |
+
$("#add_checked_value").prop('required',false);
|
154 |
+
}
|
155 |
+
if ( $("#wpmem_field_type_select").val() == 'select'
|
156 |
+
|| $("#wpmem_field_type_select").val() == 'multiselect'
|
157 |
+
|| $("#wpmem_field_type_select").val() == 'radio'
|
158 |
+
|| $("#wpmem_field_type_select").val() == 'multicheckbox'
|
159 |
+
) {
|
160 |
+
$("#wpmem_dropdown_info").show();
|
161 |
+
$("#add_dropdown_value").prop('required',true);
|
162 |
+
} else {
|
163 |
+
$("#wpmem_dropdown_info").hide();
|
164 |
+
$("#add_dropdown_value").prop('required',false);
|
165 |
+
}
|
166 |
+
if ( $("#wpmem_field_type_select").val() == 'multiselect' || $("#wpmem_field_type_select").val() == 'multicheckbox'
|
167 |
+
)
|
168 |
+
$("#wpmem_delimiter_info").show();
|
169 |
+
else
|
170 |
+
$("#wpmem_delimiter_info").hide();
|
171 |
+
if ($("#wpmem_field_type_select").val() == 'file' || $("#wpmem_field_type_select").val() == 'image' )
|
172 |
+
$("#wpmem_file_info").show();
|
173 |
+
else
|
174 |
+
$("#wpmem_file_info").hide();
|
175 |
+
if ($("#wpmem_field_type_select").val() == 'hidden') {
|
176 |
+
$("#wpmem_hidden_info").show();
|
177 |
+
$("#add_hidden_value").prop('required',true);
|
178 |
+
} else {
|
179 |
+
$("#wpmem_hidden_info").hide();
|
180 |
+
$("#add_hidden_value").prop('required',false);
|
181 |
+
}
|
182 |
+
});
|
183 |
+
});
|
184 |
+
})(jQuery);
|
185 |
+
|
186 |
+
/**
|
187 |
+
* JS for post block status meta box
|
188 |
+
*
|
189 |
+
* @since 3.2.1
|
190 |
+
*/
|
191 |
+
(function($) {
|
192 |
+
$(document).ready(function() {
|
193 |
+
$("#wpmem_block").hide();
|
194 |
+
});
|
195 |
+
$(document).ready(function() {
|
196 |
+
$("#wpmem_edit_block_status").click(function() {
|
197 |
+
$("#wpmem_block").show('normal');
|
198 |
+
$("#wpmem_edit_block_status").hide();
|
199 |
+
});
|
200 |
+
$("#wpmem_cancel_block_status").click(function() {
|
201 |
+
$("#wpmem_block").hide('normal');
|
202 |
+
$("#wpmem_edit_block_status").show();
|
203 |
+
$("#wpmem_post_block_status").text($("input[name=wpmem_block_original_label]").val());
|
204 |
+
$('#wpmem_post_block_status_' + $('input[name=wpmem_block_original_value]')).val().prop("checked", true);
|
205 |
+
});
|
206 |
+
$("#wpmem_ok_block_status").click(function() {
|
207 |
+
$("#wpmem_block").hide('normal');
|
208 |
+
$("#wpmem_edit_block_status").show();
|
209 |
+
$("#wpmem_post_block_status").text($("input[name=wpmem_block]:checked + label").text());
|
210 |
+
if($('#wpmem_block_status_0').is(':checked')) {
|
211 |
+
$("#wpmem_post_icon_0").show();
|
212 |
+
$("#wpmem_post_icon_1").hide();
|
213 |
+
$("#wpmem_post_icon_2").hide();
|
214 |
+
}
|
215 |
+
if($('#wpmem_block_status_1').is(':checked')) {
|
216 |
+
$("#wpmem_post_icon_0").hide();
|
217 |
+
$("#wpmem_post_icon_1").show();
|
218 |
+
$("#wpmem_post_icon_2").hide();
|
219 |
+
}
|
220 |
+
if($('#wpmem_block_status_2').is(':checked')) {
|
221 |
+
$("#wpmem_post_icon_0").hide();
|
222 |
+
$("#wpmem_post_icon_1").hide();
|
223 |
+
$("#wpmem_post_icon_2").show();
|
224 |
+
}
|
225 |
+
});
|
226 |
+
});
|
227 |
+
})(jQuery);
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Shows the WP-Members settings.
|
231 |
+
*/
|
232 |
+
(function($) {
|
233 |
+
$(document).ready(function($){
|
234 |
+
var close_button = wpmem_get_settings_vars.close_btn;
|
235 |
+
$("#dialog-message" ).dialog({
|
236 |
+
autoOpen: false,
|
237 |
+
modal: true,
|
238 |
+
height: "auto",
|
239 |
+
width: 600,
|
240 |
+
buttons: {
|
241 |
+
Close : function() {
|
242 |
+
$( this ).dialog( "close" );
|
243 |
+
}
|
244 |
+
}
|
245 |
+
});
|
246 |
+
$( "#opener" ).on( "click", function() {
|
247 |
+
$( "#dialog-message" ).dialog( "open" );
|
248 |
+
});
|
249 |
+
$("#select_all").click(function(){
|
250 |
+
$("textarea").select();
|
251 |
+
document.execCommand('copy');
|
252 |
+
});
|
253 |
+
$(window).resize(function() {
|
254 |
+
$("#dialog-message").dialog("option", "position", {my: "center", at: "center", of: window});
|
255 |
+
});
|
256 |
+
});
|
257 |
+
})(jQuery);
|
@@ -1 +1 @@
|
|
1 |
-
jQuery(document).ready(function(e){e("#the-list").sortable({items:".list_item",opacity:.6,cursor:"move",axis:"y",update:function(){var m=e(this).sortable("serialize")+"&action=wpmem_do_field_reorder";e.post(ajaxurl,m,function(e){alert(e)}),e(".list_item").each(function(m){e(this).data("id",m+1),e(this).attr("list_item",m+1)})}})}),function(e){e(document).ready(function(){"use_custom"==e("#wpmem_logpage_select").val()?e("#wpmem_logpage_custom").show():e("#wpmem_logpage_custom").hide(),"use_custom"==e("#wpmem_regpage_select").val()?e("#wpmem_regpage_custom").show():e("#wpmem_regpage_custom").hide(),"use_custom"==e("#wpmem_mspage_select").val()?e("#wpmem_mspage_custom").show():e("#wpmem_mspage_custom").hide(),"use_custom"==e("#wpmem_stylesheet_select").val()?e("#wpmem_stylesheet_custom").show():e("#wpmem_stylesheet_custom").hide(),e("#wpmem_logpage_select").change(function(){"use_custom"==e("#wpmem_logpage_select").val()?e("#wpmem_logpage_custom").show():e("#wpmem_logpage_custom").hide()}),e("#wpmem_regpage_select").change(function(){"use_custom"==e("#wpmem_regpage_select").val()?e("#wpmem_regpage_custom").show():e("#wpmem_regpage_custom").hide()}),e("#wpmem_mspage_select").change(function(){"use_custom"==e("#wpmem_mspage_select").val()?e("#wpmem_mspage_custom").show():e("#wpmem_mspage_custom").hide()}),e("#wpmem_stylesheet_select").change(function(){"use_custom"==e("#wpmem_stylesheet_select").val()?e("#wpmem_stylesheet_custom").show():e("#wpmem_stylesheet_custom").hide()})})}(jQuery),function(e){e(document).ready(function(){e("#wpmem_allowhtml").hide(),e("#wpmem_rows_cols").hide(),e("#wpmem_min_max").hide(),e("#wpmem_checkbox_info").hide(),e("#wpmem_dropdown_info").hide(),e("#wpmem_file_info").hide(),e("#wpmem_delimiter_info").hide(),e("#wpmem_hidden_info").hide()}),e(document).ready(function(){e("#wpmem_field_type_select").change(function(){"text"==e("#wpmem_field_type_select").val()||"password"==e("#wpmem_field_type_select").val()||"email"==e("#wpmem_field_type_select").val()||"url"==e("#wpmem_field_type_select").val()||"number"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()||"textarea"==e("#wpmem_field_type_select").val()?e("#wpmem_placeholder").show():e("#wpmem_placeholder").hide(),"text"==e("#wpmem_field_type_select").val()||"password"==e("#wpmem_field_type_select").val()||"email"==e("#wpmem_field_type_select").val()||"url"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()?(e("#wpmem_pattern").show(),e("#wpmem_title").show()):(e("#wpmem_pattern").hide(),e("#wpmem_title").hide()),"textarea"==e("#wpmem_field_type_select").val()?(e("#wpmem_allowhtml").show(),e("#wpmem_rows_cols").show()):(e("#wpmem_allowhtml").hide(),e("#wpmem_rows_cols").hide()),"number"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()?e("#wpmem_min_max").show():e("#wpmem_min_max").hide(),"checkbox"==e("#wpmem_field_type_select").val()?(e("#wpmem_checkbox_info").show(),e("#add_checked_value").prop("required",!0)):(e("#wpmem_checkbox_info").hide(),e("#add_checked_value").prop("required",!1)),"select"==e("#wpmem_field_type_select").val()||"multiselect"==e("#wpmem_field_type_select").val()||"radio"==e("#wpmem_field_type_select").val()||"multicheckbox"==e("#wpmem_field_type_select").val()?(e("#wpmem_dropdown_info").show(),e("#add_dropdown_value").prop("required",!0)):(e("#wpmem_dropdown_info").hide(),e("#add_dropdown_value").prop("required",!1)),"multiselect"==e("#wpmem_field_type_select").val()||"multicheckbox"==e("#wpmem_field_type_select").val()?e("#wpmem_delimiter_info").show():e("#wpmem_delimiter_info").hide(),"file"==e("#wpmem_field_type_select").val()||"image"==e("#wpmem_field_type_select").val()?e("#wpmem_file_info").show():e("#wpmem_file_info").hide(),"hidden"==e("#wpmem_field_type_select").val()?(e("#wpmem_hidden_info").show(),e("#add_hidden_value").prop("required",!0)):(e("#wpmem_hidden_info").hide(),e("#add_hidden_value").prop("required",!1))})})}(jQuery),function(e){e(document).ready(function(){e("#wpmem_block").hide()}),e(document).ready(function(){e("#wpmem_edit_block_status").click(function(){e("#wpmem_block").show("normal"),e("#wpmem_edit_block_status").hide()}),e("#wpmem_cancel_block_status").click(function(){e("#wpmem_block").hide("normal"),e("#wpmem_edit_block_status").show(),e("#wpmem_post_block_status").text(e("input[name=wpmem_block_original_label]").val()),e("#wpmem_post_block_status_"+e("input[name=wpmem_block_original_value]")).val().prop("checked",!0)}),e("#wpmem_ok_block_status").click(function(){e("#wpmem_block").hide("normal"),e("#wpmem_edit_block_status").show(),e("#wpmem_post_block_status").text(e("input[name=wpmem_block]:checked + label").text()),e("#wpmem_block_status_0").is(":checked")&&(e("#wpmem_post_icon_0").show(),e("#wpmem_post_icon_1").hide(),e("#wpmem_post_icon_2").hide()),e("#wpmem_block_status_1").is(":checked")&&(e("#wpmem_post_icon_0").hide(),e("#wpmem_post_icon_1").show(),e("#wpmem_post_icon_2").hide()),e("#wpmem_block_status_2").is(":checked")&&(e("#wpmem_post_icon_0").hide(),e("#wpmem_post_icon_1").hide(),e("#wpmem_post_icon_2").show())})})}(jQuery);
|
1 |
+
jQuery(document).ready(function(e){e("#the-list").sortable({items:".list_item",opacity:.6,cursor:"move",axis:"y",update:function(){var m=e(this).sortable("serialize")+"&action=wpmem_do_field_reorder";e.post(ajaxurl,m,function(e){alert(e)}),e(".list_item").each(function(m){e(this).data("id",m+1),e(this).attr("list_item",m+1)})}})}),function(e){e(document).ready(function(){"use_custom"==e("#wpmem_logpage_select").val()?e("#wpmem_logpage_custom").show():e("#wpmem_logpage_custom").hide(),"use_custom"==e("#wpmem_regpage_select").val()?e("#wpmem_regpage_custom").show():e("#wpmem_regpage_custom").hide(),"use_custom"==e("#wpmem_mspage_select").val()?e("#wpmem_mspage_custom").show():e("#wpmem_mspage_custom").hide(),"use_custom"==e("#wpmem_stylesheet_select").val()?e("#wpmem_stylesheet_custom").show():e("#wpmem_stylesheet_custom").hide(),e("#wpmem_logpage_select").change(function(){"use_custom"==e("#wpmem_logpage_select").val()?e("#wpmem_logpage_custom").show():e("#wpmem_logpage_custom").hide()}),e("#wpmem_regpage_select").change(function(){"use_custom"==e("#wpmem_regpage_select").val()?e("#wpmem_regpage_custom").show():e("#wpmem_regpage_custom").hide()}),e("#wpmem_mspage_select").change(function(){"use_custom"==e("#wpmem_mspage_select").val()?e("#wpmem_mspage_custom").show():e("#wpmem_mspage_custom").hide()}),e("#wpmem_stylesheet_select").change(function(){"use_custom"==e("#wpmem_stylesheet_select").val()?e("#wpmem_stylesheet_custom").show():e("#wpmem_stylesheet_custom").hide()})})}(jQuery),function(e){e(document).ready(function(){e("#wpmem_allowhtml").hide(),e("#wpmem_rows_cols").hide(),e("#wpmem_min_max").hide(),e("#wpmem_checkbox_info").hide(),e("#wpmem_dropdown_info").hide(),e("#wpmem_file_info").hide(),e("#wpmem_delimiter_info").hide(),e("#wpmem_hidden_info").hide()}),e(document).ready(function(){e("#wpmem_field_type_select").change(function(){"text"==e("#wpmem_field_type_select").val()||"password"==e("#wpmem_field_type_select").val()||"email"==e("#wpmem_field_type_select").val()||"url"==e("#wpmem_field_type_select").val()||"number"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()||"textarea"==e("#wpmem_field_type_select").val()?e("#wpmem_placeholder").show():e("#wpmem_placeholder").hide(),"text"==e("#wpmem_field_type_select").val()||"password"==e("#wpmem_field_type_select").val()||"email"==e("#wpmem_field_type_select").val()||"url"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()?(e("#wpmem_pattern").show(),e("#wpmem_title").show()):(e("#wpmem_pattern").hide(),e("#wpmem_title").hide()),"textarea"==e("#wpmem_field_type_select").val()?(e("#wpmem_allowhtml").show(),e("#wpmem_rows_cols").show()):(e("#wpmem_allowhtml").hide(),e("#wpmem_rows_cols").hide()),"number"==e("#wpmem_field_type_select").val()||"date"==e("#wpmem_field_type_select").val()?e("#wpmem_min_max").show():e("#wpmem_min_max").hide(),"checkbox"==e("#wpmem_field_type_select").val()?(e("#wpmem_checkbox_info").show(),e("#add_checked_value").prop("required",!0)):(e("#wpmem_checkbox_info").hide(),e("#add_checked_value").prop("required",!1)),"select"==e("#wpmem_field_type_select").val()||"multiselect"==e("#wpmem_field_type_select").val()||"radio"==e("#wpmem_field_type_select").val()||"multicheckbox"==e("#wpmem_field_type_select").val()?(e("#wpmem_dropdown_info").show(),e("#add_dropdown_value").prop("required",!0)):(e("#wpmem_dropdown_info").hide(),e("#add_dropdown_value").prop("required",!1)),"multiselect"==e("#wpmem_field_type_select").val()||"multicheckbox"==e("#wpmem_field_type_select").val()?e("#wpmem_delimiter_info").show():e("#wpmem_delimiter_info").hide(),"file"==e("#wpmem_field_type_select").val()||"image"==e("#wpmem_field_type_select").val()?e("#wpmem_file_info").show():e("#wpmem_file_info").hide(),"hidden"==e("#wpmem_field_type_select").val()?(e("#wpmem_hidden_info").show(),e("#add_hidden_value").prop("required",!0)):(e("#wpmem_hidden_info").hide(),e("#add_hidden_value").prop("required",!1))})})}(jQuery),function(e){e(document).ready(function(){e("#wpmem_block").hide()}),e(document).ready(function(){e("#wpmem_edit_block_status").click(function(){e("#wpmem_block").show("normal"),e("#wpmem_edit_block_status").hide()}),e("#wpmem_cancel_block_status").click(function(){e("#wpmem_block").hide("normal"),e("#wpmem_edit_block_status").show(),e("#wpmem_post_block_status").text(e("input[name=wpmem_block_original_label]").val()),e("#wpmem_post_block_status_"+e("input[name=wpmem_block_original_value]")).val().prop("checked",!0)}),e("#wpmem_ok_block_status").click(function(){e("#wpmem_block").hide("normal"),e("#wpmem_edit_block_status").show(),e("#wpmem_post_block_status").text(e("input[name=wpmem_block]:checked + label").text()),e("#wpmem_block_status_0").is(":checked")&&(e("#wpmem_post_icon_0").show(),e("#wpmem_post_icon_1").hide(),e("#wpmem_post_icon_2").hide()),e("#wpmem_block_status_1").is(":checked")&&(e("#wpmem_post_icon_0").hide(),e("#wpmem_post_icon_1").show(),e("#wpmem_post_icon_2").hide()),e("#wpmem_block_status_2").is(":checked")&&(e("#wpmem_post_icon_0").hide(),e("#wpmem_post_icon_1").hide(),e("#wpmem_post_icon_2").show())})})}(jQuery),jQuery(document).ready(function(e){wpmem_get_settings_vars.close_btn,e("#dialog-message").dialog({autoOpen:!1,modal:!0,height:"auto",width:600,buttons:{Close:function(){e(this).dialog("close")}}}),e("#opener").on("click",function(){e("#dialog-message").dialog("open")}),e("#select_all").click(function(){e("textarea").select(),document.execCommand("copy")}),e(window).resize(function(){e("#dialog-message").dialog("option","position",{my:"center",at:"center",of:window})})});
|
@@ -1,4 +1,182 @@
|
|
1 |
-
= 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
* Security enhancements.
|
4 |
* Improved user search in Users > All Users.
|
@@ -633,11 +811,11 @@ New Features:
|
|
633 |
|
634 |
Bug Fix:
|
635 |
|
636 |
-
* Fixed a bug where the reCAPTCHA error messages do not display on the [shortcode pages "register" and "members-area"](https://rocketgeek.com/plugins/wp-members/
|
637 |
|
638 |
Code Improvement:
|
639 |
|
640 |
-
* Completed a rebuild of the login function wpmem_login. Updated the cookie process to switch from [wp_setcookie](http://codex.wordpress.org/Function_Reference/wp_setcookie) (which is deprecated) to [wp_set_auth_cookie](http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). Also, the [wpmem_login_redirect hook](https://rocketgeek.com/plugins/wp-members/
|
641 |
|
642 |
= 2.7.6 =
|
643 |
|
1 |
+
= 3.2.9 =
|
2 |
+
|
3 |
+
* Load jQuery UI and Select2 libraries locally (if they have not already been enqueued).
|
4 |
+
* Use (local) template file for default tos field link (can be customized and saved in theme folder).
|
5 |
+
* Added new sanitization functions to API: wpmem_sanitize_class() and wpmem_sanitize_array().
|
6 |
+
* Review and cleanup of form data sanitization.
|
7 |
+
* Improved file/image field upload file type validation.
|
8 |
+
* Fixed issue with loading legacy translation files.
|
9 |
+
* Added "membership" attribute to [wpmem_logged_in] shortcode (same as "product" attribute, they are interchangeable).
|
10 |
+
* Added datepicker for setting user expiration (when membership products are used).
|
11 |
+
|
12 |
+
= 3.2.8 =
|
13 |
+
|
14 |
+
* Include jQuery UI CSS and Select2 library locally.
|
15 |
+
* Updated default TOS to a template file.
|
16 |
+
* Added additional data sanitization.
|
17 |
+
* Fixed potential security issues to prevent CSRF (Cross Site Request Forgery).
|
18 |
+
|
19 |
+
= 3.2.7 =
|
20 |
+
|
21 |
+
* Fix console error from nonce by implementing different nonce names.
|
22 |
+
* Updated packaged POT file for legacy lanaguage files. Updated legacy language files to use new POT.
|
23 |
+
* Full removal of legacy language files that are available as language packs from https://translate.wordpress.org/projects/wp-plugins/wp-members/
|
24 |
+
* Added jQuery UI stylesheet (fixes issue with main options tab settings modal).
|
25 |
+
* Added wpmem_default_text filter.
|
26 |
+
* Deprecated wpmem_default_text_strings filter, use wpmem_default_text instead.
|
27 |
+
* Added translation capability to field placeholders and title attributes.
|
28 |
+
* Updated Customizer setting slug to avoid namespace collisions (added "wpmem_" stem).
|
29 |
+
* Updated instances of wp_redirect() to use wp_safe_redirect().
|
30 |
+
* Updated install for multisite to use wp_insert_site (wpmu_new_blog deprecated in WP 5.1).
|
31 |
+
* Added user screen filter to show activated users.
|
32 |
+
|
33 |
+
= 3.2.6 =
|
34 |
+
|
35 |
+
* Update to evaluate required fields as not null (instead of false).
|
36 |
+
* Added wpmem_tos_link_tag filter.
|
37 |
+
* Added $button_html parameter to wpmem_register_form_buttons filter.
|
38 |
+
* Added wpmem_serve_menu filter.
|
39 |
+
* Added nonce to short form (long form was added in 3.2.5).
|
40 |
+
* Password change function only can be fired if user is logged in.
|
41 |
+
* Added "all" argument to wpmem_user_data() to retrieve either all user meta or WP-Members fields only.
|
42 |
+
* Added $date argument to wpmem_set_user_product(). Allows specific date to be set using API.
|
43 |
+
* Added wpmem_admin_after_profile_table and wpmem_user_after_profile_table actions.
|
44 |
+
* get_user_products() returns empty array if no products (previously boolean).
|
45 |
+
* Rebuild of [wpmem_field] logic for field type. Combined multiple conditions into a single switch.
|
46 |
+
* Update password reset form - password field should be "text" class.
|
47 |
+
* Added membership field type for allowing selection of a membership at registration.
|
48 |
+
* Login form updated from "Username" to "Username or Email".
|
49 |
+
* Added $arr parameter to wpmem_login_form_rows filter.
|
50 |
+
* Added file's post ID to post_data array.
|
51 |
+
|
52 |
+
= 3.2.5 =
|
53 |
+
|
54 |
+
* Fix user profile (admin/user) issue with tos field not displaying.
|
55 |
+
* Fix [wpmem_logged_in] shortcode to pass product attribute.
|
56 |
+
* Fix [wpmem_field] shortcode, checks if field is set to avoid undefined index error.
|
57 |
+
* Fix do_excerpt() if post object is not set as an object.
|
58 |
+
* Fix logic for displaying hidden posts based on product access.
|
59 |
+
* Added message dialog to display in Customizer.
|
60 |
+
* Added HTML5 "required" attribute to TOS checkbox.
|
61 |
+
* Added redirect_to attribute to logout link.
|
62 |
+
* Added $tag parameter to wpmem_{$tag}_link and wpmem_{$tag}_link_str filters.
|
63 |
+
* Added id parameter to wpmem_register_form_args filter.
|
64 |
+
* Added wpmem_email_send_args filter.
|
65 |
+
* Added wpmem_is_user() function to API.
|
66 |
+
* Added wpmem_do_shortcode() utility function in API.
|
67 |
+
* Added wpmem_export_fields filter to user export function.
|
68 |
+
* Added label attribute to field shortcode.
|
69 |
+
* Added user profile tabs (jquery ui tabs).
|
70 |
+
* Updated wpmem_form_date() API function.
|
71 |
+
* Updated check product access to handle product as an array.
|
72 |
+
* Updated to make a nonce a default for the registration form (reduces possibility of spam registrations).
|
73 |
+
* Updated form field creation, $value is now optional.
|
74 |
+
* Moved textdomain to load in main class file.
|
75 |
+
* Removed possibility of using reCAPTCHA v1 which is totally obsolete.
|
76 |
+
* Removed widget status message ("you are not logged in") for logged out state.
|
77 |
+
|
78 |
+
= 3.2.4 =
|
79 |
+
|
80 |
+
* Added deactivate users both bulk and single in Users > All Users.
|
81 |
+
* Added id attribute for form labels.
|
82 |
+
* Added wpmem_format_date() API function.
|
83 |
+
* Added label tags to multipe checkbox and radio group items.
|
84 |
+
* Added assigned product(s) column to users and posts screens.
|
85 |
+
* Updated membership product object structure.
|
86 |
+
* Updated load priority to run later for jquery loginout script.
|
87 |
+
* Removed query_vars filter.
|
88 |
+
* Deprecated wpmem_a_activate_user(), use wpmem_activate_user() instead.
|
89 |
+
* Deprecated wpmem_a_deactivate_user(), use wpmem_deactivate_user() instead.
|
90 |
+
* Relocated install file to /inc/ directory.
|
91 |
+
* Moved methods out of core.php, deprecated file.
|
92 |
+
* Fixed issue with default stylesheet setting caused by moving install file.
|
93 |
+
|
94 |
+
= 3.2.3 =
|
95 |
+
|
96 |
+
* Bug fix in user export that caused usernames to be dropped.
|
97 |
+
* Bug fix to allow admins to edit their own profile.
|
98 |
+
* Bug fix for jquery with regards to select2, only load if products are enabled.
|
99 |
+
* Added email API.
|
100 |
+
* Added product attribute to [wpmem_logged_in] shortcode.
|
101 |
+
* Added wpmem_force_ssl() API function.
|
102 |
+
* Added wpmem_set_as_logged_in() API function.
|
103 |
+
* Added filters to remove posts marked hidden from previous/next links.
|
104 |
+
* Updated user login function to use WP script, facilitates login with username OR email, removes wpmem_login_fields filter, changes to wp_safe_redirect().
|
105 |
+
* Updated password change for maintaining login state.
|
106 |
+
* Moved wpmem_fields(), wpmem_form_label(), and wpmem_form_field() to api-forms.php.
|
107 |
+
* 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.
|
108 |
+
* 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.
|
109 |
+
* Moved wpmem_wp_reserved_terms() to admin API.
|
110 |
+
* Deprecated wpmem_check_activated() and wpmem_use_ssl().
|
111 |
+
* Removed obsolete functions wpmem_enqueue_style(), wpmem_convert_tag(), wpmem_no_reset(), and wpmem_user_profile_multipart().
|
112 |
+
* Applied wpmem_force_ssl() to stylesheet in case it needs to load securely (even if the setting is saved as http://).
|
113 |
+
* 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.
|
114 |
+
|
115 |
+
= 3.2.2 =
|
116 |
+
|
117 |
+
* 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.
|
118 |
+
* Fixed a 3.2 upgrade issue, verifies username field is properly added to field settings array.
|
119 |
+
* Fixed issue with user product verification where only expiration products were validated.
|
120 |
+
* Fixed logic in form field builder so multiselect will accept a custom class.
|
121 |
+
* Added select2 support for setting product access in the post editor.
|
122 |
+
* Removed duplicate API function wpmem_current_postid() (use wpmem_current_post_id()).
|
123 |
+
* Replaced sanitize_html_class() with WP_Members_Forms::sanitize_class() so variables may contain multiple classes.
|
124 |
+
|
125 |
+
= 3.2.1 =
|
126 |
+
|
127 |
+
* Fixed duplicate ID in login form.
|
128 |
+
* Fixed user profile update for excluded fields.
|
129 |
+
* Fixed native WP registration, excluded WP-Members username field in form validation.
|
130 |
+
* Fixed update post when block status is not changed.
|
131 |
+
* Rebuilt user interface for post restriction metabox to make it more intuitive.
|
132 |
+
* Changed status column in All Posts to show all block statuses, not just those opposite the default.
|
133 |
+
* Changed "clickable" attribute for field shortcode default to false.
|
134 |
+
* Added wpmem_user_export_header and wpmem_user_export_row filter for export.
|
135 |
+
|
136 |
+
= 3.2.0 =
|
137 |
+
|
138 |
+
* Tested and compatible with Gutenberg.
|
139 |
+
* Changed default address meta fields to WooCommerce billing meta keys.
|
140 |
+
* Removed language packs that install from wordpress.org (de_DE, hu_HU, ja, nl_NL, pt_BR, ru_RU, and sv_SE).
|
141 |
+
* All remaining user facing strings in get_text() added wp-members textdomain.
|
142 |
+
* Added locale as a parameter for localization filters.
|
143 |
+
* Added wpmem_register_hidden_rows filter.
|
144 |
+
* Added "post_to" key for wpmem_register_form_args.
|
145 |
+
* Rebuild of user export function. User export now uses fputcsv.
|
146 |
+
* Updates/code improvement for enqueueing styles.
|
147 |
+
* Updated widget, added widget_title filter before wpmem_widget_title, documented wpmem_widget_id filter, added instance and id_base parameters.
|
148 |
+
* Updated empty $fields check to not rewrite fields.
|
149 |
+
* Deprecated wpmem_inc_status().
|
150 |
+
* Deprecated wpmem_do_sidebar().
|
151 |
+
* Deprecated wpmem_create_formfield(), use wpmem_form_field() instead.
|
152 |
+
* Deprecated a number of non-user callable functions.
|
153 |
+
* Eliminated capability-based load for admin files.
|
154 |
+
* Maintain user login state when password is changed.
|
155 |
+
* Added wpmem_get_sub_str() string manipulation utility.
|
156 |
+
* Updated login form redirect_to to account for query vars.
|
157 |
+
* Fixes issue with login status if logout url is encoded (sprintf() has too few arguments).
|
158 |
+
* Added Membership Products Custom Post Type.
|
159 |
+
* Added "Hide Post" option for blocking content (currently only by post meta _wpmem_block).
|
160 |
+
* Removed several outdated stylesheets from selection (still packaged with download for users who may use them).
|
161 |
+
* Added wpmem_update_user_role() API function.
|
162 |
+
* Added wpmem_display_message() API function.
|
163 |
+
* Added wpmem_user_has_access() API function.
|
164 |
+
* HTML5 update - form anchor tags changed from "name" to "id".
|
165 |
+
* HTML5 update - form id tags set default value (can still be filtered).
|
166 |
+
* HTML5 update - removed "align" attribute (captcha, link-text).
|
167 |
+
* HTML5 update - added placeholder, pattern, and title attribute support for password fields.
|
168 |
+
* Improved the add a field dialog to adjust required inputs depending on field type.
|
169 |
+
* Added placeholder, rows, and cols attribute support for textarea field settings.
|
170 |
+
* Moved remaining core functions to appropriate object classes, left wrappers for most.
|
171 |
+
* Added new email class and shortcode class to replace previous functions/files.
|
172 |
+
* Added link_span_before/link_span_after wrapper for login link text.
|
173 |
+
* Updated "TOS" text to accept a custom label (priority to filtered label with wpmem_tos_link_txt).
|
174 |
+
* Updated all processing involving "TOS" to better exclude the field on profile update (if saved value equals the field's checked value).
|
175 |
+
* Fixed a bug that caused WP native fields to be set as non-native when labels were updated in the fields tab.
|
176 |
+
* Added Customizer control to display login, register, and widget forms when using the Customizer (easier to work on custom CSS).
|
177 |
+
* Added login/out menu item.
|
178 |
+
|
179 |
+
= 3.1.9 =
|
180 |
|
181 |
* Security enhancements.
|
182 |
* Improved user search in Users > All Users.
|
811 |
|
812 |
Bug Fix:
|
813 |
|
814 |
+
* Fixed a bug where the reCAPTCHA error messages do not display on the [shortcode pages "register" and "members-area"](https://rocketgeek.com/plugins/wp-members/docs/shortcodes/page-shortcodes/).
|
815 |
|
816 |
Code Improvement:
|
817 |
|
818 |
+
* Completed a rebuild of the login function wpmem_login. Updated the cookie process to switch from [wp_setcookie](http://codex.wordpress.org/Function_Reference/wp_setcookie) (which is deprecated) to [wp_set_auth_cookie](http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). Also, the [wpmem_login_redirect hook](https://rocketgeek.com/plugins/wp-members/docs/filter-hooks/wpmem_login_redirect/) was moved to after the login credentials have been validated and the user is logged in. This allows the hook to access user data without the need to validate the user within the filter.
|
819 |
|
820 |
= 2.7.6 =
|
821 |
|
@@ -6,12 +6,12 @@
|
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
-
* Copyright (c) 2006-
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
*
|
16 |
* Functions included:
|
17 |
* - wpmem_admin
|
@@ -112,21 +112,6 @@ function wpmem_admin_action( $action ) {
|
|
112 |
return $did_update;
|
113 |
}
|
114 |
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Adds WP-Members custom fields to the WP Add New User form.
|
118 |
-
*
|
119 |
-
* @since 2.9.1
|
120 |
-
*
|
121 |
-
* @global stdClass $wpmem
|
122 |
-
*/
|
123 |
-
function wpmem_admin_add_new_user() {
|
124 |
-
global $wpmem;
|
125 |
-
// Output the custom registration fields.
|
126 |
-
echo $wpmem->forms->wp_newuser_form();
|
127 |
-
return;
|
128 |
-
}
|
129 |
-
|
130 |
/**
|
131 |
* Wrapper for WP_Members_Admin_Tab_Options::page_list()
|
132 |
*
|
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-2021 Chad Butler
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
*
|
16 |
* Functions included:
|
17 |
* - wpmem_admin
|
112 |
return $did_update;
|
113 |
}
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
/**
|
116 |
* Wrapper for WP_Members_Admin_Tab_Options::page_list()
|
117 |
*
|
@@ -1,119 +1,119 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members Admin API Functions
|
4 |
-
*
|
5 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
-
*
|
10 |
-
* @package WP-Members
|
11 |
-
* @author Chad Butler
|
12 |
-
* @copyright 2006-
|
13 |
-
*
|
14 |
-
* Functions included:
|
15 |
-
* - wpmem_add_custom_email
|
16 |
-
* - wpmem_add_custom_dialog
|
17 |
-
* - wpmem_is_tab
|
18 |
-
*/
|
19 |
-
|
20 |
-
// Exit if accessed directly.
|
21 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
22 |
-
exit();
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Wrapper function for adding custom emails.
|
27 |
-
*
|
28 |
-
* @since 3.1.1
|
29 |
-
*
|
30 |
-
* @global object $wpmem The WP_Members object class.
|
31 |
-
* @param string $tag Slug for the custom email.
|
32 |
-
* @param string $heading Heading to display in admin panel.
|
33 |
-
* @param string $subject_input Slug for the subject.
|
34 |
-
* @param string $message_input Slug for the message body.
|
35 |
-
*/
|
36 |
-
function wpmem_add_custom_email( $tag, $heading, $subject_input, $message_input ) {
|
37 |
-
global $wpmem;
|
38 |
-
$args = array(
|
39 |
-
'name' => $tag,
|
40 |
-
'heading' => $heading,
|
41 |
-
'subject_input' => $subject_input,
|
42 |
-
'body_input' => $message_input,
|
43 |
-
);
|
44 |
-
$wpmem->admin->add_email( $args );
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Checks the current tab being displayed in the admin panel.
|
49 |
-
*
|
50 |
-
* @since 3.1.4
|
51 |
-
*
|
52 |
-
* @param string $tab The tab slug.
|
53 |
-
* @return bool
|
54 |
-
*/
|
55 |
-
function wpmem_is_tab( $tab ) {
|
56 |
-
return ( $tab == wpmem_get( 'tab', false, 'get' ) ) ? true : false;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Utility function generates link to user profile.
|
61 |
-
*
|
62 |
-
* @since 3.1.7
|
63 |
-
*
|
64 |
-
* @param int $user_id
|
65 |
-
* @return string user profile URL.
|
66 |
-
*/
|
67 |
-
function wpmem_admin_user_profile( $user_id ) {
|
68 |
-
return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Wrapper for form_post_url().
|
73 |
-
*
|
74 |
-
* @since 3.1.8
|
75 |
-
*
|
76 |
-
* @global object $wpmem The WP_Members Object.
|
77 |
-
* @param string $tab The plugin tab being displayed.
|
78 |
-
* @param mixed $args Array of additional arguments|boolean. Default: false.
|
79 |
-
* @return string $url
|
80 |
-
*/
|
81 |
-
function wpmem_admin_form_post_url( $args = false ) {
|
82 |
-
global $wpmem;
|
83 |
-
return $wpmem->admin->form_post_url( $args );
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Returns an array of WordPress reserved terms.
|
88 |
-
*
|
89 |
-
* @since 3.0.2
|
90 |
-
* @since 3.2.3 Moved to Admin API as wrapper for WP_Members_Admin_API::wp_reserved_terms().
|
91 |
-
*
|
92 |
-
* @global object $wpmem
|
93 |
-
* @return array An array of WordPress reserved terms.
|
94 |
-
*/
|
95 |
-
function wpmem_wp_reserved_terms() {
|
96 |
-
global $wpmem;
|
97 |
-
return $wpmem->admin->wp_reserved_terms();
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Updates a single plugin option.
|
102 |
-
*
|
103 |
-
* @since 3.3.6
|
104 |
-
*
|
105 |
-
* @param string $option Name of the option to update.
|
106 |
-
* @param string $key Which key to update. Update a subkey as primary_key/subkey.
|
107 |
-
* @param string $value New value.
|
108 |
-
* @return
|
109 |
-
*/
|
110 |
-
function wpmem_update_option( $option, $key, $value ) {
|
111 |
-
$settings = get_option( $option );
|
112 |
-
if ( strpos( $key, '/' ) ) {
|
113 |
-
$keys = explode( '/', $key );
|
114 |
-
$settings[ $keys[0] ][ $keys[1] ] = $value;
|
115 |
-
} else {
|
116 |
-
$settings[ $key ] = $value;
|
117 |
-
}
|
118 |
-
update_option( $option, $settings );
|
119 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Admin API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @author Chad Butler
|
12 |
+
* @copyright 2006-2021
|
13 |
+
*
|
14 |
+
* Functions included:
|
15 |
+
* - wpmem_add_custom_email
|
16 |
+
* - wpmem_add_custom_dialog
|
17 |
+
* - wpmem_is_tab
|
18 |
+
*/
|
19 |
+
|
20 |
+
// Exit if accessed directly.
|
21 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
22 |
+
exit();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Wrapper function for adding custom emails.
|
27 |
+
*
|
28 |
+
* @since 3.1.1
|
29 |
+
*
|
30 |
+
* @global object $wpmem The WP_Members object class.
|
31 |
+
* @param string $tag Slug for the custom email.
|
32 |
+
* @param string $heading Heading to display in admin panel.
|
33 |
+
* @param string $subject_input Slug for the subject.
|
34 |
+
* @param string $message_input Slug for the message body.
|
35 |
+
*/
|
36 |
+
function wpmem_add_custom_email( $tag, $heading, $subject_input, $message_input ) {
|
37 |
+
global $wpmem;
|
38 |
+
$args = array(
|
39 |
+
'name' => $tag,
|
40 |
+
'heading' => $heading,
|
41 |
+
'subject_input' => $subject_input,
|
42 |
+
'body_input' => $message_input,
|
43 |
+
);
|
44 |
+
$wpmem->admin->add_email( $args );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Checks the current tab being displayed in the admin panel.
|
49 |
+
*
|
50 |
+
* @since 3.1.4
|
51 |
+
*
|
52 |
+
* @param string $tab The tab slug.
|
53 |
+
* @return bool
|
54 |
+
*/
|
55 |
+
function wpmem_is_tab( $tab ) {
|
56 |
+
return ( $tab == wpmem_get( 'tab', false, 'get' ) ) ? true : false;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Utility function generates link to user profile.
|
61 |
+
*
|
62 |
+
* @since 3.1.7
|
63 |
+
*
|
64 |
+
* @param int $user_id
|
65 |
+
* @return string user profile URL.
|
66 |
+
*/
|
67 |
+
function wpmem_admin_user_profile( $user_id ) {
|
68 |
+
return add_query_arg( 'user_id', $user_id, admin_url( 'user-edit.php' ) );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Wrapper for form_post_url().
|
73 |
+
*
|
74 |
+
* @since 3.1.8
|
75 |
+
*
|
76 |
+
* @global object $wpmem The WP_Members Object.
|
77 |
+
* @param string $tab The plugin tab being displayed.
|
78 |
+
* @param mixed $args Array of additional arguments|boolean. Default: false.
|
79 |
+
* @return string $url
|
80 |
+
*/
|
81 |
+
function wpmem_admin_form_post_url( $args = false ) {
|
82 |
+
global $wpmem;
|
83 |
+
return $wpmem->admin->form_post_url( $args );
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Returns an array of WordPress reserved terms.
|
88 |
+
*
|
89 |
+
* @since 3.0.2
|
90 |
+
* @since 3.2.3 Moved to Admin API as wrapper for WP_Members_Admin_API::wp_reserved_terms().
|
91 |
+
*
|
92 |
+
* @global object $wpmem
|
93 |
+
* @return array An array of WordPress reserved terms.
|
94 |
+
*/
|
95 |
+
function wpmem_wp_reserved_terms() {
|
96 |
+
global $wpmem;
|
97 |
+
return $wpmem->admin->wp_reserved_terms();
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Updates a single plugin option.
|
102 |
+
*
|
103 |
+
* @since 3.3.6
|
104 |
+
*
|
105 |
+
* @param string $option Name of the option to update.
|
106 |
+
* @param string $key Which key to update. Update a subkey as primary_key/subkey.
|
107 |
+
* @param string $value New value.
|
108 |
+
* @return bool True if the value was updated, otherwise false.
|
109 |
+
*/
|
110 |
+
function wpmem_update_option( $option, $key, $value ) {
|
111 |
+
$settings = get_option( $option );
|
112 |
+
if ( strpos( $key, '/' ) ) {
|
113 |
+
$keys = explode( '/', $key );
|
114 |
+
$settings[ $keys[0] ][ $keys[1] ] = $value;
|
115 |
+
} else {
|
116 |
+
$settings[ $key ] = $value;
|
117 |
+
}
|
118 |
+
return update_option( $option, $settings );
|
119 |
}
|
@@ -116,8 +116,9 @@ class WP_Members_Admin_API {
|
|
116 |
global $wpmem;
|
117 |
|
118 |
add_action( 'admin_enqueue_scripts', array( $this, 'dashboard_enqueue_scripts' ) );
|
119 |
-
add_action( 'user_new_form', 'wpmem_admin_add_new_user' );
|
120 |
add_filter( 'plugin_action_links', array( $this, 'plugin_links' ), 10, 2 );
|
|
|
|
|
121 |
// add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
|
122 |
|
123 |
add_action( 'wp_ajax_wpmem_do_field_reorder', array( 'WP_Members_Admin_Tab_Fields', 'do_field_reorder' ) );
|
@@ -235,44 +236,6 @@ class WP_Members_Admin_API {
|
|
235 |
echo '</h2>';
|
236 |
}
|
237 |
|
238 |
-
/**
|
239 |
-
* Adds custom email dialog to the Emails tab.
|
240 |
-
*
|
241 |
-
* @since 3.1.0
|
242 |
-
*
|
243 |
-
* @param array $args Settings array for the email.
|
244 |
-
*/
|
245 |
-
function do_email_input( $args ) { ?>
|
246 |
-
<tr valign="top"><td colspan="2"><strong><?php echo esc_html( $args['heading'] ); ?></strong></td></tr>
|
247 |
-
<tr valign="top">
|
248 |
-
<th scope="row"><?php echo esc_html( $args['subject_label'] ); ?></th>
|
249 |
-
<td><input type="text" name="<?php echo esc_attr( $args['subject_input'] ); ?>" size="80" value="<?php echo esc_attr( wp_unslash( $args['subject_value'] ) ); ?>"></td>
|
250 |
-
</tr>
|
251 |
-
<tr valign="top">
|
252 |
-
<th scope="row"><?php echo esc_html( $args['body_label'] ); ?></th>
|
253 |
-
<td><textarea name="<?php echo esc_attr( $args['body_input'] ); ?>" rows="12" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['body_value'] ) ); ?></textarea></td>
|
254 |
-
</tr>
|
255 |
-
<tr><td colspan="2"><hr /></td></tr><?php
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Saves custom email settings.
|
260 |
-
*
|
261 |
-
* @since 3.1.0
|
262 |
-
*
|
263 |
-
* @param array $args Settings array for the email.
|
264 |
-
*/
|
265 |
-
function email_update( $args ) {
|
266 |
-
$settings = array(
|
267 |
-
'subj' => sanitize_text_field( wpmem_get( $args['subject_input'] ) ),
|
268 |
-
'body' => wp_kses( wpmem_get( $args['body_input'] ), 'post' ),
|
269 |
-
);
|
270 |
-
update_option( $args['name'], $settings, true );
|
271 |
-
$this->emails[ $args['name'] ]['subject_value'] = $settings['subj'];
|
272 |
-
$this->emails[ $args['name'] ]['body_value'] = $settings['body'];
|
273 |
-
return;
|
274 |
-
}
|
275 |
-
|
276 |
/**
|
277 |
* Handles custom email settings.
|
278 |
*
|
@@ -353,7 +316,7 @@ class WP_Members_Admin_API {
|
|
353 |
'label' => $args['label'],
|
354 |
//'input' => $args['name'] . '_dialog',
|
355 |
'value' => $args['value'],
|
356 |
-
//'value' => ( $args['value'] ) ? $args['value'] :
|
357 |
);
|
358 |
|
359 |
// Merge args with settings.
|
@@ -569,11 +532,35 @@ class WP_Members_Admin_API {
|
|
569 |
*/
|
570 |
function dashboard_enqueue_scripts( $hook ) {
|
571 |
global $current_screen, $wpmem;
|
572 |
-
if ( 'edit.php' == $hook
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
wp_enqueue_style( 'wpmem-admin', $wpmem->url . 'assets/css/admin' . wpmem_get_suffix() . '.css', '', $wpmem->version );
|
574 |
}
|
575 |
if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook ) {
|
576 |
-
wp_enqueue_script( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products ) {
|
579 |
if ( ! wp_script_is( 'select2', 'enqueued' ) ) {
|
@@ -582,40 +569,9 @@ class WP_Members_Admin_API {
|
|
582 |
wp_enqueue_style( 'select2-style' );
|
583 |
wp_enqueue_script( 'select2' );
|
584 |
}
|
585 |
-
|
586 |
-
//if ( ( 'post-new.php' == $hook && isset( $_GET['post_type'] ) && 'wpmem_product' == $_GET['post_type'] ) || )
|
587 |
-
if ( 'wpmem_product' == get_post_type() ) {
|
588 |
-
wp_enqueue_script( 'jquery' );
|
589 |
-
wp_enqueue_script( 'jquery-ui-core' );// enqueue jQuery UI Core
|
590 |
-
wp_enqueue_script( 'jquery-ui-datepicker' ); // enqueue jQuery UI Datepicker
|
591 |
-
if ( ! wp_style_is( 'jquery-ui-style', 'enqueued' ) ) {
|
592 |
-
wp_register_style( 'jquery-ui-style', $wpmem->url . 'assets/css/jquery-ui' . wpmem_get_suffix() . '.css' );
|
593 |
-
}
|
594 |
-
wp_enqueue_style( 'jquery-ui-style' );
|
595 |
-
}
|
596 |
}
|
597 |
if ( 'user-edit' == $current_screen->id || 'profile' == $current_screen->id ) {
|
598 |
-
wp_enqueue_script( 'jquery' );
|
599 |
-
wp_enqueue_script( 'jquery-ui-core' ); // enqueue jQuery UI Core
|
600 |
wp_enqueue_script( 'jquery-ui-tabs' ); // enqueue jQuery UI Tabs
|
601 |
-
wp_enqueue_script( 'jquery-ui-datepicker' ); // enqueue jQuery UI Datepicker
|
602 |
-
|
603 |
-
if ( ! wp_style_is( 'jquery-ui-style', 'enqueued' ) ) {
|
604 |
-
wp_register_style( 'jquery-ui-style', $wpmem->url . 'assets/css/jquery-ui' . wpmem_get_suffix() . '.css' );
|
605 |
-
}
|
606 |
-
wp_enqueue_style( 'jquery-ui-style' );
|
607 |
-
}
|
608 |
-
if ( 'settings_page_wpmem-settings' == $hook ) {
|
609 |
-
wp_enqueue_script( 'jquery' );
|
610 |
-
wp_enqueue_script( 'jquery-ui-core' );// enqueue jQuery UI Core
|
611 |
-
wp_enqueue_script( 'jquery-ui-dialog' );
|
612 |
-
wp_enqueue_script( 'jquery-ui-datepicker' ); // enqueue jQuery UI Datepicker
|
613 |
-
|
614 |
-
if ( ! wp_style_is( 'jquery-ui-style', 'enqueued' ) ) {
|
615 |
-
wp_register_style( 'jquery-ui-style', $wpmem->url . 'assets/css/jquery-ui' . wpmem_get_suffix() . '.css' );
|
616 |
-
}
|
617 |
-
wp_enqueue_style( 'jquery-ui-style' );
|
618 |
-
|
619 |
}
|
620 |
}
|
621 |
|
116 |
global $wpmem;
|
117 |
|
118 |
add_action( 'admin_enqueue_scripts', array( $this, 'dashboard_enqueue_scripts' ) );
|
|
|
119 |
add_filter( 'plugin_action_links', array( $this, 'plugin_links' ), 10, 2 );
|
120 |
+
|
121 |
+
add_action( 'user_new_form', array( $wpmem->forms, 'wp_newuser_form' ) );
|
122 |
// add_filter( 'wpmem_admin_tabs', 'wpmem_add_about_tab' );
|
123 |
|
124 |
add_action( 'wp_ajax_wpmem_do_field_reorder', array( 'WP_Members_Admin_Tab_Fields', 'do_field_reorder' ) );
|
236 |
echo '</h2>';
|
237 |
}
|
238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
/**
|
240 |
* Handles custom email settings.
|
241 |
*
|
316 |
'label' => $args['label'],
|
317 |
//'input' => $args['name'] . '_dialog',
|
318 |
'value' => $args['value'],
|
319 |
+
//'value' => ( $args['value'] ) ? $args['value'] : wpmem_get_text( $key ),
|
320 |
);
|
321 |
|
322 |
// Merge args with settings.
|
532 |
*/
|
533 |
function dashboard_enqueue_scripts( $hook ) {
|
534 |
global $current_screen, $wpmem;
|
535 |
+
if ( 'edit.php' == $hook
|
536 |
+
|| 'settings_page_wpmem-settings' == $hook
|
537 |
+
|| 'post.php' == $hook
|
538 |
+
|| 'post-new.php' == $hook
|
539 |
+
|| 'user-edit.php' == $hook
|
540 |
+
|| 'profile.php' == $hook
|
541 |
+
|| 'users.php' ) {
|
542 |
wp_enqueue_style( 'wpmem-admin', $wpmem->url . 'assets/css/admin' . wpmem_get_suffix() . '.css', '', $wpmem->version );
|
543 |
}
|
544 |
if ( 'settings_page_wpmem-settings' == $hook || 'post.php' == $hook || 'post-new.php' == $hook ) {
|
545 |
+
wp_enqueue_script( 'jquery-ui-dialog' ); // enqueue jQuery UI Dialog dependency
|
546 |
+
wp_register_script( 'wpmem-admin', $wpmem->url . 'assets/js/admin' . wpmem_get_suffix() . '.js', 'jquery', $wpmem->version, true );
|
547 |
+
$translation_array = array(
|
548 |
+
'close_btn' => __( 'Close', 'wp-members' ),
|
549 |
+
);
|
550 |
+
wp_localize_script( 'wpmem-admin', 'wpmem_get_settings_vars', $translation_array );
|
551 |
+
wp_enqueue_script( 'wpmem-admin' );
|
552 |
+
}
|
553 |
+
if ( ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products )
|
554 |
+
|| ( 'wpmem_product' == get_post_type() )
|
555 |
+
|| ( 'user-edit' == $current_screen->id || 'profile' == $current_screen->id )
|
556 |
+
|| ( 'settings_page_wpmem-settings' == $hook ) ) {
|
557 |
+
wp_enqueue_script( 'jquery' );
|
558 |
+
wp_enqueue_script( 'jquery-ui-core' ); // enqueue jQuery UI Core
|
559 |
+
wp_enqueue_script( 'jquery-ui-datepicker' ); // enqueue jQuery UI Datepicker
|
560 |
+
if ( ! wp_style_is( 'jquery-ui-style', 'enqueued' ) ) {
|
561 |
+
wp_register_style( 'jquery-ui-style', $wpmem->url . 'assets/css/jquery-ui' . wpmem_get_suffix() . '.css' );
|
562 |
+
}
|
563 |
+
wp_enqueue_style( 'jquery-ui-style' );
|
564 |
}
|
565 |
if ( ( 'post.php' == $hook || 'post-new.php' == $hook ) && 1 == $wpmem->enable_products ) {
|
566 |
if ( ! wp_script_is( 'select2', 'enqueued' ) ) {
|
569 |
wp_enqueue_style( 'select2-style' );
|
570 |
wp_enqueue_script( 'select2' );
|
571 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
}
|
573 |
if ( 'user-edit' == $current_screen->id || 'profile' == $current_screen->id ) {
|
|
|
|
|
574 |
wp_enqueue_script( 'jquery-ui-tabs' ); // enqueue jQuery UI Tabs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
}
|
576 |
}
|
577 |
|
@@ -1,601 +1,621 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members Admin Users Class.
|
4 |
-
*
|
5 |
-
* @package WP-Members
|
6 |
-
* @subpackage WP_Members Admin Users Object Class
|
7 |
-
* @since 3.3.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly.
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit();
|
13 |
-
}
|
14 |
-
|
15 |
-
class WP_Members_Admin_Users {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Function to add activate/export to the bulk dropdown list.
|
19 |
-
*
|
20 |
-
* @since 2.8.2
|
21 |
-
*/
|
22 |
-
static function bulk_user_action() {
|
23 |
-
global $wpmem; ?>
|
24 |
-
<script type="text/javascript">
|
25 |
-
var $j = jQuery.noConflict();
|
26 |
-
$j(document).ready(function() {
|
27 |
-
<?php if( $wpmem->mod_reg == 1 ) { ?>
|
28 |
-
$j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action']");
|
29 |
-
$j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action']");
|
30 |
-
<?php } ?>
|
31 |
-
$j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action']");
|
32 |
-
$j('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".top .bulkactions");
|
33 |
-
<?php if( $wpmem->mod_reg == 1 ) { ?>
|
34 |
-
$j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action2']");
|
35 |
-
$j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action2']");
|
36 |
-
<?php } ?>
|
37 |
-
$j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action2']");
|
38 |
-
$j('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
|
39 |
-
});
|
40 |
-
</script><?php
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Function to add activate link to the user row action.
|
45 |
-
*
|
46 |
-
* @since 2.8.2
|
47 |
-
* @since 3.3.5 Updated to use wpmem_is_user_activated().
|
48 |
-
* @since 3.3.8 Added confirmation link, changed from insert_activate_link().
|
49 |
-
*
|
50 |
-
* @param array $actions
|
51 |
-
* @param $user_object
|
52 |
-
* @return array $actions
|
53 |
-
*/
|
54 |
-
static function insert_hover_links( $actions, $user_object ) {
|
55 |
-
global $wpmem;
|
56 |
-
if ( $user_object->ID != get_current_user_id() ) {
|
57 |
-
|
58 |
-
if ( 1 == $wpmem->act_link ) {
|
59 |
-
|
60 |
-
|
61 |
-
$
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
$url =
|
68 |
-
$
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
$
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
*
|
94 |
-
*
|
95 |
-
* @
|
96 |
-
*
|
97 |
-
* @
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
}
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
*
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
*
|
269 |
-
*
|
270 |
-
*
|
271 |
-
* @
|
272 |
-
*
|
273 |
-
* @
|
274 |
-
* @
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
'
|
301 |
-
'
|
302 |
-
'
|
303 |
-
'
|
304 |
-
'
|
305 |
-
'
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$count = $
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
$views['
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
$
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
$
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
$
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
*
|
592 |
-
*
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members Admin Users Class.
|
4 |
+
*
|
5 |
+
* @package WP-Members
|
6 |
+
* @subpackage WP_Members Admin Users Object Class
|
7 |
+
* @since 3.3.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly.
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit();
|
13 |
+
}
|
14 |
+
|
15 |
+
class WP_Members_Admin_Users {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Function to add activate/export to the bulk dropdown list.
|
19 |
+
*
|
20 |
+
* @since 2.8.2
|
21 |
+
*/
|
22 |
+
static function bulk_user_action() {
|
23 |
+
global $wpmem; ?>
|
24 |
+
<script type="text/javascript">
|
25 |
+
var $j = jQuery.noConflict();
|
26 |
+
$j(document).ready(function() {
|
27 |
+
<?php if( $wpmem->mod_reg == 1 ) { ?>
|
28 |
+
$j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action']");
|
29 |
+
$j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action']");
|
30 |
+
<?php } ?>
|
31 |
+
$j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action']");
|
32 |
+
$j('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".top .bulkactions");
|
33 |
+
<?php if( $wpmem->mod_reg == 1 ) { ?>
|
34 |
+
$j('<option>').val('activate').text('<?php _e( 'Activate', 'wp-members' )?>').appendTo("select[name='action2']");
|
35 |
+
$j('<option>').val('deactivate').text('<?php _e( 'Deactivate', 'wp-members' )?>').appendTo("select[name='action2']");
|
36 |
+
<?php } ?>
|
37 |
+
$j('<option>').val('export').text('<?php _e( 'Export', 'wp-members' )?>').appendTo("select[name='action2']");
|
38 |
+
$j('<input id="export_all" name="export_all" class="button action" type="submit" value="<?php _e( 'Export All Users', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
|
39 |
+
});
|
40 |
+
</script><?php
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Function to add activate link to the user row action.
|
45 |
+
*
|
46 |
+
* @since 2.8.2
|
47 |
+
* @since 3.3.5 Updated to use wpmem_is_user_activated().
|
48 |
+
* @since 3.3.8 Added confirmation link, changed from insert_activate_link().
|
49 |
+
*
|
50 |
+
* @param array $actions
|
51 |
+
* @param $user_object
|
52 |
+
* @return array $actions
|
53 |
+
*/
|
54 |
+
static function insert_hover_links( $actions, $user_object ) {
|
55 |
+
global $wpmem;
|
56 |
+
if ( $user_object->ID != get_current_user_id() ) {
|
57 |
+
|
58 |
+
if ( 1 == $wpmem->act_link ) {
|
59 |
+
if ( false === wpmem_is_user_confirmed( $user_object->ID ) ) {
|
60 |
+
$action = 'confirm';
|
61 |
+
$term = __( 'Confirm', 'wp-members' );
|
62 |
+
} else {
|
63 |
+
$action = 'unconfirm';
|
64 |
+
$term = __( 'Unconfirm', 'wp-members' );
|
65 |
+
}
|
66 |
+
$url = add_query_arg( array( 'action' => $action . '-single', 'user' => $user_object->ID ), "users.php" );
|
67 |
+
$url = wp_nonce_url( $url, 'confirm-user' );
|
68 |
+
$actions[ $action ] = '<a href="' . $url . '">' . $term . '</a>';
|
69 |
+
|
70 |
+
// Resend welcome email (will contain confirmation link if enabled).
|
71 |
+
//$actions['resend_welcome'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'resend_welcome', 'user' => $user_object->ID ), "users.php" ), 'resend-welcome' ) . '">' . __( 'Resend welcome email', 'wp-members' ) . '</a>';
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( 1 == $wpmem->mod_reg ) {
|
75 |
+
$is_active = wpmem_is_user_activated( $user_object->ID );
|
76 |
+
|
77 |
+
if ( false === $is_active ) {
|
78 |
+
$action = 'activate';
|
79 |
+
$term = __( 'Activate', 'wp-members' );
|
80 |
+
} else {
|
81 |
+
$action = 'deactivate';
|
82 |
+
$term = __( 'Deactivate', 'wp-members' );
|
83 |
+
}
|
84 |
+
$url = add_query_arg( array( 'action' => $action . '-single', 'user' => $user_object->ID ), "users.php" );
|
85 |
+
$url = wp_nonce_url( $url, 'activate-user' );
|
86 |
+
$actions[ $action ] = '<a href="' . $url . '">' . $term . '</a>';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
return $actions;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Function to handle bulk actions at page load.
|
94 |
+
*
|
95 |
+
* @since 2.8.2
|
96 |
+
*
|
97 |
+
* @uses WP_Users_List_Table
|
98 |
+
*
|
99 |
+
* @global object $wpmem
|
100 |
+
*/
|
101 |
+
static function page_load() {
|
102 |
+
|
103 |
+
global $wpmem;
|
104 |
+
if ( current_user_can( 'list_users' ) ) {
|
105 |
+
$wpmem->admin->user_search = new WP_Members_Admin_User_Search();
|
106 |
+
}
|
107 |
+
|
108 |
+
// If exporting all users, do it, then exit.
|
109 |
+
if ( current_user_can( 'list_users' ) && wpmem_get( 'export_all', false, 'request' ) ) {
|
110 |
+
$today = date( "Y-m-d" );
|
111 |
+
wpmem_export_users();
|
112 |
+
exit();
|
113 |
+
}
|
114 |
+
|
115 |
+
$wp_list_table = _get_list_table( 'WP_Users_List_Table' );
|
116 |
+
$action = $wp_list_table->current_action();
|
117 |
+
$sendback = '';
|
118 |
+
|
119 |
+
switch ( $action ) {
|
120 |
+
|
121 |
+
case 'activate':
|
122 |
+
case 'deactivate':
|
123 |
+
|
124 |
+
// Validate nonce.
|
125 |
+
check_admin_referer( 'bulk-users' );
|
126 |
+
|
127 |
+
// Get the users.
|
128 |
+
if ( isset( $_REQUEST['users'] ) ) {
|
129 |
+
|
130 |
+
$users = $_REQUEST['users'];
|
131 |
+
|
132 |
+
// Update the users.
|
133 |
+
$x = 0;
|
134 |
+
foreach ( $users as $user ) {
|
135 |
+
$user = filter_var( $user, FILTER_VALIDATE_INT );
|
136 |
+
// Current user cannot activate or deactivate themselves.
|
137 |
+
if ( $user != get_current_user_id() ) {
|
138 |
+
// Check to see if the user is already activated, if not, activate.
|
139 |
+
if ( 'activate' == $action && 1 != get_user_meta( $user, 'active', true ) ) {
|
140 |
+
wpmem_activate_user( $user );
|
141 |
+
} elseif( 'deactivate' == $action ) {
|
142 |
+
wpmem_deactivate_user( $user );
|
143 |
+
}
|
144 |
+
$x++;
|
145 |
+
}
|
146 |
+
}
|
147 |
+
$msg = ( 'activate' == $action ) ? urlencode( sprintf( __( '%s users activated', 'wp-members' ), $x ) ) : urlencode( sprintf( __( '%s users deactivated', 'wp-members' ), $x ) );
|
148 |
+
|
149 |
+
} else {
|
150 |
+
$msg = urlencode( __( 'No users selected', 'wp-members' ) );
|
151 |
+
}
|
152 |
+
|
153 |
+
// Set the return message.
|
154 |
+
$sendback = add_query_arg( array( 'activated' => $msg ), $sendback );
|
155 |
+
break;
|
156 |
+
|
157 |
+
case 'activate-single':
|
158 |
+
case 'deactivate-single':
|
159 |
+
|
160 |
+
// Validate nonce.
|
161 |
+
check_admin_referer( 'activate-user' );
|
162 |
+
|
163 |
+
// Get the users.
|
164 |
+
$user_id = filter_var( $_REQUEST['user'], FILTER_VALIDATE_INT );
|
165 |
+
|
166 |
+
// Check to see if the user is already activated, if not, activate.
|
167 |
+
if ( $user_id == get_current_user_id() ) {
|
168 |
+
$msg = urlencode( sprintf( esc_html__( 'You cannot activate or deactivate yourself', 'wp-members' ) ) );
|
169 |
+
|
170 |
+
} elseif ( 'activate-single' == $action && false === wpmem_is_user_activated( $user_id ) ) {
|
171 |
+
wpmem_activate_user( $user_id );
|
172 |
+
$user_info = get_userdata( $user_id );
|
173 |
+
$msg = urlencode( sprintf( esc_html__( "%s activated", 'wp-members' ), $user_info->user_login ) );
|
174 |
+
|
175 |
+
} elseif ( 'deactivate-single' == $action ) {
|
176 |
+
wpmem_deactivate_user( $user_id );
|
177 |
+
$user_info = get_userdata( $user_id );
|
178 |
+
$msg = urlencode( sprintf( esc_html__( "%s deactivated", 'wp-members' ), $user_info->user_login ) );
|
179 |
+
|
180 |
+
} else {
|
181 |
+
// Set the return message.
|
182 |
+
$msg = urlencode( __( "That user is already active", 'wp-members' ) );
|
183 |
+
}
|
184 |
+
$sendback = add_query_arg( array( 'activated' => $msg ), $sendback );
|
185 |
+
break;
|
186 |
+
|
187 |
+
case 'confirm-single':
|
188 |
+
case 'unconfirm-single':
|
189 |
+
|
190 |
+
// Validate nonce.
|
191 |
+
check_admin_referer( 'confirm-user' );
|
192 |
+
|
193 |
+
// Get the users.
|
194 |
+
$user_id = filter_var( $_REQUEST['user'], FILTER_VALIDATE_INT );
|
195 |
+
|
196 |
+
// Check to see if the user is already activated, if not, activate.
|
197 |
+
if ( $users == get_current_user_id() ) {
|
198 |
+
$msg = urlencode( sprintf( esc_html__( 'You cannot confirm or unconfirm yourself', 'wp-members' ) ) );
|
199 |
+
|
200 |
+
} elseif ( 'confirm-single' == $action && false === wpmem_is_user_confirmed( $user_id ) ) {
|
201 |
+
wpmem_set_user_as_confirmed( $user_id );
|
202 |
+
$user_info = get_userdata( $user_id );
|
203 |
+
$msg = urlencode( sprintf( esc_html__( "%s confirmed", 'wp-members' ), $user_info->user_login ) );
|
204 |
+
|
205 |
+
} elseif ( 'unconfirm-single' == $action ) {
|
206 |
+
wpmem_set_user_as_unconfirmed( $user_id );
|
207 |
+
$user_info = get_userdata( $user_id );
|
208 |
+
$msg = urlencode( sprintf( esc_html__( "%s unconfirmed", 'wp-members' ), $user_info->user_login ) );
|
209 |
+
|
210 |
+
} else {
|
211 |
+
// Set the return message.
|
212 |
+
$msg = urlencode( __( "That user is already confirmed", 'wp-members' ) );
|
213 |
+
}
|
214 |
+
$sendback = add_query_arg( array( 'activated' => $msg ), $sendback );
|
215 |
+
break;
|
216 |
+
|
217 |
+
case 'show':
|
218 |
+
|
219 |
+
add_action( 'pre_user_query', array( 'WP_Members_Admin_Users', 'pre_user_query' ) );
|
220 |
+
return;
|
221 |
+
break;
|
222 |
+
|
223 |
+
case 'export':
|
224 |
+
|
225 |
+
$users = wpmem_get( 'users', array(), 'request' );
|
226 |
+
wpmem_export_users( array( 'export'=>'selected' ), wpmem_sanitize_array( $users, 'integer' ) );
|
227 |
+
return;
|
228 |
+
break;
|
229 |
+
|
230 |
+
default:
|
231 |
+
return;
|
232 |
+
break;
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Doing user action.
|
238 |
+
*
|
239 |
+
* @since 3.3.0
|
240 |
+
*/
|
241 |
+
do_action( 'wpmem_user_action' );
|
242 |
+
|
243 |
+
// If we did not return already, we need to wp_safe_redirect.
|
244 |
+
wp_safe_redirect( $sendback );
|
245 |
+
exit();
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Function to echo admin update message.
|
251 |
+
*
|
252 |
+
* @since 2.8.2
|
253 |
+
*/
|
254 |
+
static function admin_notices() {
|
255 |
+
|
256 |
+
global $pagenow, $user_action_msg;
|
257 |
+
if( $pagenow == 'users.php' && isset( $_REQUEST['activated'] ) ) {
|
258 |
+
$message = esc_html( $_REQUEST['activated'] );
|
259 |
+
echo "<div class=\"updated\"><p>{$message}</p></div>";
|
260 |
+
}
|
261 |
+
|
262 |
+
if ( $user_action_msg ) {
|
263 |
+
echo "<div class=\"updated\"><p>{$user_action_msg}</p></div>";
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Function to add user views to the top list.
|
269 |
+
*
|
270 |
+
* @since 2.8.2
|
271 |
+
* @since 3.1.2 Added user view counts as transient.
|
272 |
+
*
|
273 |
+
* @global object $wpdb
|
274 |
+
* @global object $wpmem
|
275 |
+
* @param array $views
|
276 |
+
* @return array $views
|
277 |
+
*/
|
278 |
+
static function views( $views ) {
|
279 |
+
|
280 |
+
global $wpmem;
|
281 |
+
|
282 |
+
// Get the cached user counts.
|
283 |
+
$user_counts = get_transient( 'wpmem_user_counts' );
|
284 |
+
|
285 |
+
// check to see if data was successfully retrieved from the cache
|
286 |
+
if ( false === $user_counts ) {
|
287 |
+
|
288 |
+
// @todo For now, 5 minutes. We'll see how things go.
|
289 |
+
$transient_expires = 300; // Value in seconds, 1 day: ( 60 * 60 * 24 );
|
290 |
+
|
291 |
+
global $wpdb;
|
292 |
+
|
293 |
+
// We need a count of total users.
|
294 |
+
// @todo - need a more elegant way of this entire process.
|
295 |
+
$sql = "SELECT COUNT(*) FROM " . $wpdb->users;
|
296 |
+
$users = $wpdb->get_var( $sql );
|
297 |
+
|
298 |
+
// What needs to be counted?
|
299 |
+
$count_metas = array(
|
300 |
+
'pending' => 'pending', // Used for PayPal Extension
|
301 |
+
'trial' => 'trial', // Used for PayPal Extension
|
302 |
+
'subscription' => 'subscription', // Used for PayPal Extension
|
303 |
+
'expired' => 'expired', // Used for PayPal Extension
|
304 |
+
'active' => 'active',
|
305 |
+
'notactive' => 'active',
|
306 |
+
'deactivated' => 'deactivated',
|
307 |
+
'notexported' => 'exported',
|
308 |
+
'confirmed' => '_wpmem_user_confirmed',
|
309 |
+
'notconfirmed' => '_wpmem_user_confirmed',
|
310 |
+
);
|
311 |
+
|
312 |
+
// Handle various counts.
|
313 |
+
$user_counts = array();
|
314 |
+
foreach ( $count_metas as $key => $meta_key ) {
|
315 |
+
if ( 'confirmed' == $key || 'notconfirmed' == $key ) {
|
316 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key=%s AND meta_value>0", $meta_key ) );
|
317 |
+
$count = ( 'notconfirmed' == $key ) ? $users - $count : $count;
|
318 |
+
}
|
319 |
+
if ( 'active' == $key ) {
|
320 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key=%s AND meta_value=1", $meta_key ) );
|
321 |
+
}
|
322 |
+
if ( 'notactive' == $key || 'notexported' == $key ) {
|
323 |
+
$users_with_meta = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key=%s AND meta_value=1", $meta_key ) );
|
324 |
+
$count = $users - $users_with_meta;
|
325 |
+
}
|
326 |
+
if ( 'deactivated' == $key ) {
|
327 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key = 'active' AND meta_value = 0" );
|
328 |
+
}
|
329 |
+
if ( 'trial' == $key || 'subscription' == $key || 'pending' == $key ) {
|
330 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key = 'exp_type' AND meta_value = \"%s\"", $key ) );
|
331 |
+
}
|
332 |
+
if ( 'expired' == $key ) {
|
333 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key = 'expires' AND STR_TO_DATE( meta_value, '%m/%d/%Y' ) < CURDATE() AND meta_value != '01/01/1970'" );
|
334 |
+
}
|
335 |
+
$user_counts[ $key ] = $count;
|
336 |
+
}
|
337 |
+
set_transient( 'wpmem_user_counts', $user_counts, $transient_expires );
|
338 |
+
}
|
339 |
+
|
340 |
+
if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
|
341 |
+
$views['pending'] = __( 'Pending', 'wp-members' );
|
342 |
+
$views['trial'] = __( 'Trial', 'wp-members' );
|
343 |
+
$views['subscription'] = __( 'Subscription', 'wp-members' );
|
344 |
+
$views['expired'] = __( 'Expired', 'wp-members' );
|
345 |
+
}
|
346 |
+
if ( 1 == $wpmem->mod_reg ) {
|
347 |
+
$views['active'] = __( 'Activated', 'wp-members' );
|
348 |
+
$views['notactive'] = __( 'Pending Activation', 'wp-members' );
|
349 |
+
$views['deactivated'] = __( 'Deactivated', 'wp-members' );
|
350 |
+
}
|
351 |
+
if ( 1 == $wpmem->act_link ) {
|
352 |
+
$views['confirmed'] = __( 'Confirmed', 'wp-members' );
|
353 |
+
$views['notconfirmed'] = __( 'Not Confirmed', 'wp-members' );
|
354 |
+
}
|
355 |
+
$views['notexported'] = __( 'Not Exported', 'wp-members' );
|
356 |
+
$show = sanitize_text_field( wpmem_get( 'show', false, 'get' ) );
|
357 |
+
|
358 |
+
foreach ( $views as $key => $view ) {
|
359 |
+
if ( isset( $user_counts[ $key ] ) ) {
|
360 |
+
$link = "users.php?action=show&show=" . $key;
|
361 |
+
$current = ( $show == $key ) ? ' class="current"' : '';
|
362 |
+
$views[ $key ] = sprintf(
|
363 |
+
'<a href="%s" %s>%s <span class="count">(%d)</span></a>',
|
364 |
+
esc_url( $link ),
|
365 |
+
$current,
|
366 |
+
$view,
|
367 |
+
isset( $user_counts[ $key ] ) ? $user_counts[ $key ] : ''
|
368 |
+
);
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Filters all views before returning to the WP 'views_users' filter.
|
374 |
+
*
|
375 |
+
* @since 3.3.0
|
376 |
+
*
|
377 |
+
* @param array $views {
|
378 |
+
*
|
379 |
+
* @type string The HTML for the view.
|
380 |
+
* }
|
381 |
+
*/
|
382 |
+
$views = apply_filters( 'wpmem_views_users', $views, $show );
|
383 |
+
|
384 |
+
return $views;
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Function to add custom user columns to the user table.
|
389 |
+
*
|
390 |
+
* @since 2.8.2
|
391 |
+
*
|
392 |
+
* @param array $columns
|
393 |
+
* @return array $columns
|
394 |
+
*/
|
395 |
+
static function add_user_column( $columns ) {
|
396 |
+
|
397 |
+
global $wpmem_user_columns, $wpmem;
|
398 |
+
|
399 |
+
// Get any columns to be added to the Users > All Users screen.
|
400 |
+
$wpmem_user_columns = get_option( 'wpmembers_utfields' );
|
401 |
+
|
402 |
+
if ( $wpmem_user_columns ) {
|
403 |
+
$column_labels = array();
|
404 |
+
if ( 1 != $wpmem->mod_reg ) {
|
405 |
+
unset( $wpmem_user_columns['active'] );
|
406 |
+
}
|
407 |
+
|
408 |
+
// @todo This is a workaround so that wpmembers_utfields doesn't have to be updated.
|
409 |
+
if ( isset( $wpmem_user_columns['active'] ) ) {
|
410 |
+
$wpmem_user_columns['active'] = __( 'Activated', 'wp-members' );
|
411 |
+
}
|
412 |
+
|
413 |
+
if ( 1 != $wpmem->act_link ) {
|
414 |
+
unset( $wpmem_user_columns['_wpmem_user_confirmed'] );
|
415 |
+
}
|
416 |
+
|
417 |
+
// @todo Need to eventually change the wpmembers_utfields setting so we don't have to do it this way.
|
418 |
+
$fields = wpmem_fields();
|
419 |
+
foreach ( $wpmem_user_columns as $key => $value ) {
|
420 |
+
$column_labels[ $key ] = ( isset( $fields[ $key ] ) ) ? $fields[ $key ]['label'] : $value;
|
421 |
+
}
|
422 |
+
|
423 |
+
/**
|
424 |
+
* Filter the User > All Users custom columns before they are merged.
|
425 |
+
*
|
426 |
+
* @since 3.3.8
|
427 |
+
*
|
428 |
+
* @param array
|
429 |
+
*/
|
430 |
+
$column_labels = apply_filters( 'wpmem_user_columns', $column_labels );
|
431 |
+
|
432 |
+
$columns = array_merge( $columns, $column_labels );
|
433 |
+
}
|
434 |
+
|
435 |
+
// Makes WP-Members columns sortable.
|
436 |
+
// @todo - finish debugging class or add sortable functions to users.php.
|
437 |
+
// require_once( $wpmem->path . 'admin/includes/class-wp-members-sortable-user-columns.php' );
|
438 |
+
// new WP_Members_Sortable_User_Columns( $wpmem_user_columns );
|
439 |
+
|
440 |
+
return $columns;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* Function to add the user content to the custom column.
|
445 |
+
*
|
446 |
+
* @since 2.8.2
|
447 |
+
*
|
448 |
+
* @param $value
|
449 |
+
* @param $column_name
|
450 |
+
* @param $user_id
|
451 |
+
* @return The user value for the custom column.
|
452 |
+
*/
|
453 |
+
static function add_user_column_content( $value, $column_name, $user_id ) {
|
454 |
+
|
455 |
+
// Is the column a WP-Members column?
|
456 |
+
global $wpmem_user_columns, $wpmem;
|
457 |
+
$is_wpmem = ( is_array( $wpmem_user_columns ) && array_key_exists( $column_name, $wpmem_user_columns ) ) ? true : false;
|
458 |
+
|
459 |
+
if ( $is_wpmem ) {
|
460 |
+
|
461 |
+
switch ( $column_name ) {
|
462 |
+
|
463 |
+
case 'active':
|
464 |
+
if ( 1 == $wpmem->mod_reg ) {
|
465 |
+
// If the column is "active", then return the value or empty. Returning in here keeps us from displaying another value.
|
466 |
+
return ( get_user_meta( $user_id , 'active', 'true' ) != 1 ) ? '<span class="dashicons dashicons-dismiss" style="color:red;"></span>' : '<span class="dashicons dashicons-yes-alt" style="color:green;"></span>';
|
467 |
+
} else {
|
468 |
+
return;
|
469 |
+
}
|
470 |
+
break;
|
471 |
+
|
472 |
+
case '_wpmem_user_confirmed':
|
473 |
+
if ( 1 == $wpmem->act_link ) {
|
474 |
+
$user_confirmed = get_user_meta( $user_id , '_wpmem_user_confirmed', 'true' );
|
475 |
+
return ( $user_confirmed ) ? date_i18n( get_option( 'date_format' ), $user_confirmed ) : __( 'Not confirmed', 'wp-members' );
|
476 |
+
} else {
|
477 |
+
return;
|
478 |
+
}
|
479 |
+
break;
|
480 |
+
|
481 |
+
case 'user_url':
|
482 |
+
case 'user_registered':
|
483 |
+
// Unlike other fields, website/url is not a meta field.
|
484 |
+
$user_info = get_userdata( $user_id );
|
485 |
+
return $user_info->$column_name;
|
486 |
+
break;
|
487 |
+
|
488 |
+
case 'user_id':
|
489 |
+
return $user_id;
|
490 |
+
|
491 |
+
default:
|
492 |
+
return get_user_meta( $user_id, $column_name, true );
|
493 |
+
break;
|
494 |
+
}
|
495 |
+
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Filter user column content.
|
500 |
+
*
|
501 |
+
* @since 3.3.8
|
502 |
+
*
|
503 |
+
* @param string $value
|
504 |
+
* @param string $column_name
|
505 |
+
* @param int $user_id
|
506 |
+
*/
|
507 |
+
$value = apply_filters( 'wpmem_user_column_content', $value, $column_name, $user_id );
|
508 |
+
return $value;
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Adjusts user query based on custom views.
|
513 |
+
*
|
514 |
+
* @since 2.8.3
|
515 |
+
*
|
516 |
+
* @todo Currently, not activated query returns users who are deactivated. This
|
517 |
+
* may be confusing for admins, so work on a query that displays only
|
518 |
+
* users who have never been activated.
|
519 |
+
*
|
520 |
+
* @param $user_search
|
521 |
+
*/
|
522 |
+
static function pre_user_query( $user_search ) {
|
523 |
+
|
524 |
+
global $wpdb;
|
525 |
+
$show = sanitize_text_field( wpmem_get( 'show', '', 'get' ) );
|
526 |
+
switch ( $show ) {
|
527 |
+
|
528 |
+
case 'trial':
|
529 |
+
case 'subscription':
|
530 |
+
case 'pending':
|
531 |
+
$replace_query = "WHERE 1=1 AND {$wpdb->users}.ID IN (
|
532 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
533 |
+
WHERE {$wpdb->usermeta}.meta_key = 'exp_type'
|
534 |
+
AND {$wpdb->usermeta}.meta_value = \"" . esc_sql( $show ) . "\" )";
|
535 |
+
break;
|
536 |
+
|
537 |
+
case 'expired':
|
538 |
+
$replace_query = "WHERE 1=1 AND {$wpdb->users}.ID IN (
|
539 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
540 |
+
WHERE {$wpdb->usermeta}.meta_key = 'expires'
|
541 |
+
AND STR_TO_DATE( {$wpdb->usermeta}.meta_value, '%m/%d/%Y' ) < CURDATE()
|
542 |
+
AND {$wpdb->usermeta}.meta_value != '01/01/1970' )";
|
543 |
+
break;
|
544 |
+
|
545 |
+
case 'confirmed':
|
546 |
+
case 'notconfirmed':
|
547 |
+
$in = ( 'confirmed' == $show ) ? 'IN' : 'NOT IN';
|
548 |
+
$replace_query = "WHERE 1=1 AND {$wpdb->users}.ID " . esc_sql( $in ) . " (
|
549 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
550 |
+
WHERE {$wpdb->usermeta}.meta_key = \"" . esc_sql( '_wpmem_user_confirmed' ) . "\" )";
|
551 |
+
break;
|
552 |
+
|
553 |
+
case 'active':
|
554 |
+
case 'notactive':
|
555 |
+
case 'notexported':
|
556 |
+
case 'deactivated':
|
557 |
+
default:
|
558 |
+
$key = ( 'notactive' == $show || 'deactivated' == $show ) ? 'active' : 'exported';
|
559 |
+
$in = ( 'deactivated' == $show ) ? 'IN' : 'NOT IN';
|
560 |
+
$val = ( 'deactivated' == $show ) ? '0' : '1';
|
561 |
+
if ( 'active' == $show ) {
|
562 |
+
$key = 'active'; $in = 'IN';
|
563 |
+
}
|
564 |
+
$replace_query = "WHERE 1=1 AND {$wpdb->users}.ID " . esc_sql( $in ) . " (
|
565 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
566 |
+
WHERE {$wpdb->usermeta}.meta_key = \"" . esc_sql( $key ) . "\"
|
567 |
+
AND {$wpdb->usermeta}.meta_value = \"" . esc_sql( $val ) . "\" )";
|
568 |
+
break;
|
569 |
+
}
|
570 |
+
|
571 |
+
$query_where = str_replace( 'WHERE 1=1', $replace_query, $user_search->query_where );
|
572 |
+
|
573 |
+
/**
|
574 |
+
* Filters the pre_user_query being applied.
|
575 |
+
*
|
576 |
+
* @since 3.3.0
|
577 |
+
*
|
578 |
+
* @param string $query_where
|
579 |
+
*/
|
580 |
+
$query_where = apply_filters( 'wpmem_query_where', $query_where, $show );
|
581 |
+
|
582 |
+
$user_search->query_where = $query_where;
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Use wpmem_post_register_data to set the user_status field to 2 using wp_update_user.
|
587 |
+
* http://codex.wordpress.org/Function_Reference/wp_update_user
|
588 |
+
*
|
589 |
+
* @deprecated 3.3.6 No longer used.
|
590 |
+
*
|
591 |
+
* @uses wpmem_set_user_status
|
592 |
+
* @param $fields
|
593 |
+
*/
|
594 |
+
static function set_new_user_non_active( $fields ) {
|
595 |
+
wpmem_set_user_status( $fields['ID'], 2 );
|
596 |
+
return;
|
597 |
+
}
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Use wpmem_user_activated to set the user_status field to 0 using wp_update_user.
|
601 |
+
*
|
602 |
+
* @uses wpmem_set_user_status
|
603 |
+
* @param $user_id
|
604 |
+
*/
|
605 |
+
static function set_activated_user( $user_id ) {
|
606 |
+
wpmem_set_user_status( $user_id, 0 );
|
607 |
+
return;
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Use wpmem_user_deactivated to set the user_status field to 2 using wp_update_user.
|
612 |
+
*
|
613 |
+
* @uses wpmem_set_user_status
|
614 |
+
* @param $user_id
|
615 |
+
*/
|
616 |
+
static function set_deactivated_user( $user_id ) {
|
617 |
+
wpmem_set_user_status( $user_id, 2 );
|
618 |
+
return;
|
619 |
+
}
|
620 |
+
|
621 |
}
|
@@ -1,219 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members Export Class.
|
4 |
-
*
|
5 |
-
* @package WP-Members
|
6 |
-
* @subpackage WP_Members Export Object Class
|
7 |
-
* @since 3.3.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly.
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit();
|
13 |
-
}
|
14 |
-
|
15 |
-
class WP_Members_Export {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* New export function to export all or selected users
|
19 |
-
*
|
20 |
-
* @since 2.9.7
|
21 |
-
* @since 3.2.0 Updated to use fputcsv.
|
22 |
-
* @since 3.2.1 Added user data filters.
|
23 |
-
* @since 3.3.0 Moved to new object class as static method.
|
24 |
-
*
|
25 |
-
* @param array $args
|
26 |
-
* @param array $users
|
27 |
-
*/
|
28 |
-
static function export_users( $args, $users = array() ) {
|
29 |
-
|
30 |
-
global $wpmem;
|
31 |
-
|
32 |
-
$wpmem_fields = wpmem_fields();
|
33 |
-
|
34 |
-
// Prepare fields, add additional "special" fields.
|
35 |
-
$export_fields = array(
|
36 |
-
'ID' => __( 'User ID', 'wp-members' ),
|
37 |
-
'username' => __( 'Username', 'wp-members' ),
|
38 |
-
);
|
39 |
-
foreach( $wpmem_fields as $meta_key => $value ) {
|
40 |
-
$export_fields[ $meta_key ] = $value['label'];
|
41 |
-
}
|
42 |
-
if ( 1 == $wpmem->mod_reg ) {
|
43 |
-
$export_fields['active'] = __( 'Activated?', 'wp-members' );
|
44 |
-
}
|
45 |
-
if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
|
46 |
-
$export_fields['exp_type'] = __( 'Subscription', 'wp-members' );
|
47 |
-
$export_fields['expires'] = __( 'Expires', 'wp-members' );
|
48 |
-
}
|
49 |
-
$export_fields['user_registered'] = __( 'Registered', 'wp-members' );
|
50 |
-
$export_fields['wpmem_reg_ip'] = __( 'IP', 'wp-members' );
|
51 |
-
if ( 1 == $wpmem->enable_products ) {
|
52 |
-
foreach( $wpmem->membership->products as $product_key => $product ) {
|
53 |
-
$export_fields[ $wpmem->membership->post_stem . $product_key ] = $wpmem->membership->products[ $product_key ]['title'];
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Filter the export fields.
|
59 |
-
*
|
60 |
-
* @since 3.2.5
|
61 |
-
*
|
62 |
-
* @param array $export_fields {
|
63 |
-
* The array of export fields is keyed as 'heading value' => 'meta_key'.
|
64 |
-
* The array will include all fields in the Fields tab, plus the following:
|
65 |
-
*
|
66 |
-
* @type int $ID ID from wp_users
|
67 |
-
* @type string $username user_login from wp_users
|
68 |
-
* @type string $user_nicename user_nicename
|
69 |
-
* @type string $user_url user_url
|
70 |
-
* @type string $display_name display_name
|
71 |
-
* @type int $active Whether the user is active/deactivated.
|
72 |
-
* @type string $exp_type If the PayPal extension is installed pending|subscrption (optional)
|
73 |
-
* @type string $expires If the PayPal extension is installed MM/DD/YYYY (optional)
|
74 |
-
* @type string $user_registered user_registered
|
75 |
-
* @type string $user_ip The IP of the user when they registered.
|
76 |
-
}
|
77 |
-
*/
|
78 |
-
$export_fields = apply_filters( 'wpmem_export_fields', $export_fields );
|
79 |
-
|
80 |
-
$today = date( "Y-m-d" );
|
81 |
-
|
82 |
-
// Setup defaults.
|
83 |
-
$defaults = array(
|
84 |
-
'export' => 'all',
|
85 |
-
'filename' => 'wp-members-user-export-' . $today . '.csv',
|
86 |
-
'export_fields' => $export_fields,
|
87 |
-
'exclude_fields' => array( 'password', 'confirm_password', 'confirm_email' ),
|
88 |
-
'entity_decode' => false,
|
89 |
-
'date_format' => 'Y-m-d',
|
90 |
-
);
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Filter the default export arguments.
|
94 |
-
*
|
95 |
-
* @since 2.9.7
|
96 |
-
*
|
97 |
-
* @param array $args {
|
98 |
-
* Array of defaults for export.
|
99 |
-
*
|
100 |
-
* @type string $export
|
101 |
-
* @type string $filename
|
102 |
-
* @type array $export_fields
|
103 |
-
* @type array $exclude_fields
|
104 |
-
* @type boolean $entity_decode
|
105 |
-
* @type string $date_format
|
106 |
-
* }
|
107 |
-
*/
|
108 |
-
$args = wp_parse_args( apply_filters( 'wpmem_export_args', $args ), $defaults );
|
109 |
-
|
110 |
-
// Output needs to be buffered, start the buffer.
|
111 |
-
ob_start();
|
112 |
-
|
113 |
-
// If exporting all, get all of the users.
|
114 |
-
$export_users = ( 'all' == $args['export'] ) ? get_users( array( 'fields' => 'ID' ) ) : $users;
|
115 |
-
|
116 |
-
// Generate headers and a filename based on date of export.
|
117 |
-
header( "Content-Description: File Transfer" );
|
118 |
-
header( "Content-type: application/octet-stream" );
|
119 |
-
header( "Content-Disposition: attachment; filename=" . $args['filename'] );
|
120 |
-
header( "Content-Type: text/csv; charset=" . get_option( 'blog_charset' ), true );
|
121 |
-
|
122 |
-
$handle = fopen( 'php://output', 'w' );
|
123 |
-
fputs( $handle, "\xEF\xBB\xBF" ); // UTF-8 BOM
|
124 |
-
|
125 |
-
// Remove excluded fields from $export_fields while setting up $header array.
|
126 |
-
$header = array();
|
127 |
-
foreach ( $export_fields as $meta => $field ) {
|
128 |
-
if ( in_array( $meta, $args['exclude_fields'] ) ) {
|
129 |
-
unset( $export_fields[ $meta ] );
|
130 |
-
} else {
|
131 |
-
$header[ $meta ] = $field;
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Filters user export header row before assembly.
|
137 |
-
*
|
138 |
-
* @since 3.2.1
|
139 |
-
*
|
140 |
-
* @param array $header The header column values
|
141 |
-
*/
|
142 |
-
$header = apply_filters( 'wpmem_user_export_header', $header );
|
143 |
-
|
144 |
-
fputcsv( $handle, $header );
|
145 |
-
|
146 |
-
// Loop through the array of users, assemble csv.
|
147 |
-
// $export_fields only includes fields to be exported at this point.
|
148 |
-
foreach ( $export_users as $user ) {
|
149 |
-
|
150 |
-
$user_info = get_userdata( $user );
|
151 |
-
|
152 |
-
$wp_user_fields = [ 'username', 'user_email', 'user_nicename', 'user_url', 'display_name' ];
|
153 |
-
foreach ( $export_fields as $meta => $field ) {
|
154 |
-
switch ( $meta ) {
|
155 |
-
case 'ID':
|
156 |
-
$row[ $meta ] = $user_info->ID;
|
157 |
-
break;
|
158 |
-
case 'username':
|
159 |
-
$row[ $meta ] = $user_info->user_login;
|
160 |
-
break;
|
161 |
-
case 'active':
|
162 |
-
$row[ $meta ] = get_user_meta( $user, 'active', 1 ) ? __( 'Yes' ) : __( 'No' );
|
163 |
-
break;
|
164 |
-
case 'exp_type':
|
165 |
-
$row['exp_type'] = get_user_meta( $user, 'exp_type', true );
|
166 |
-
break;
|
167 |
-
case 'expires':
|
168 |
-
$row['expires'] = get_user_meta( $user, 'expires', true );
|
169 |
-
break;
|
170 |
-
case 'user_registered':
|
171 |
-
$row['user_registered'] = $user_info->user_registered;
|
172 |
-
break;
|
173 |
-
case 'wpmem_reg_ip':
|
174 |
-
$row['wpmem_reg_ip'] = get_user_meta( $user, 'wpmem_reg_ip', true );
|
175 |
-
break;
|
176 |
-
case ( $wpmem->membership->post_stem === substr( $meta, 0, strlen( $wpmem->membership->post_stem ) ) ):
|
177 |
-
$product = str_replace( $wpmem->membership->post_stem, '', $meta );
|
178 |
-
$row[ $meta ] = get_user_meta( $user, $meta, true );
|
179 |
-
// If value is a date and false is not the format_date option...
|
180 |
-
if ( false !== $args['date_format'] && '' != $row[ $meta ] && $row[ $meta ] > 2 ) {
|
181 |
-
$date_format = ( 'wp' == $args['date_format'] ) ? get_option('date_format') : $args['date_format'];
|
182 |
-
$row[ $meta ] = date( $date_format, $row[ $meta ] );
|
183 |
-
}
|
184 |
-
break;
|
185 |
-
default:
|
186 |
-
if ( in_array( $meta, $wp_user_fields ) ) {
|
187 |
-
$row[ $meta ] = ( 'username' == $meta ) ? $user_info->user_login : $user_info->{$meta};
|
188 |
-
} else {
|
189 |
-
$raw_data = get_user_meta( $user, $meta, true );
|
190 |
-
$row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
|
191 |
-
}
|
192 |
-
break;
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Filter the user data before assembly.
|
198 |
-
*
|
199 |
-
* @since 3.2.1
|
200 |
-
*
|
201 |
-
* @param array $row The user data row
|
202 |
-
*/
|
203 |
-
$row = apply_filters( 'wpmem_user_export_row', $row );
|
204 |
-
|
205 |
-
fputcsv( $handle, $row );
|
206 |
-
|
207 |
-
// Update the user record as being exported.
|
208 |
-
if ( 'all' != $args['export'] ) {
|
209 |
-
update_user_meta( $user, 'exported', 1 );
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
fclose( $handle );
|
214 |
-
print( ob_get_clean() );
|
215 |
-
|
216 |
-
exit();
|
217 |
-
}
|
218 |
-
|
219 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -33,6 +33,7 @@ class WP_Members_Products_Admin {
|
|
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' ) );
|
@@ -44,6 +45,9 @@ class WP_Members_Products_Admin {
|
|
44 |
|
45 |
add_filter( 'wpmem_user_profile_tabs', array( $this, 'user_profile_tabs' ), 1 );
|
46 |
add_action( 'wpmem_user_profile_tabs_content', array( $this, 'user_profile_tab_content' ), 10 );
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
$this->default_products = $wpmem->membership->get_default_products();
|
@@ -352,8 +356,16 @@ class WP_Members_Products_Admin {
|
|
352 |
* @since 3.3.5
|
353 |
*/
|
354 |
do_action( 'wpmem_membership_product_message_meta_before' );
|
355 |
-
|
356 |
-
echo '<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
/**
|
358 |
* Fires after membership product messate meta box.
|
359 |
*
|
@@ -488,7 +500,7 @@ class WP_Members_Products_Admin {
|
|
488 |
'type' => 'multiselect',
|
489 |
'value' => $values,
|
490 |
'compare' => $product,
|
491 |
-
'class' => 'wpmem-product-select2',
|
492 |
) );
|
493 |
}
|
494 |
|
@@ -529,13 +541,24 @@ class WP_Members_Products_Admin {
|
|
529 |
<script language="javascript">
|
530 |
(function($) {
|
531 |
$(document).ready(function() {
|
532 |
-
$('.wpmem-product-select2').select2();
|
533 |
});
|
534 |
})(jQuery);
|
535 |
</script><?php
|
536 |
}
|
537 |
}
|
538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
/**
|
540 |
* Add membership product column to post table.
|
541 |
*
|
@@ -610,6 +633,20 @@ class WP_Members_Products_Admin {
|
|
610 |
* @return array $display
|
611 |
*/
|
612 |
function user_columns_content( $val, $column_name, $user_id ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
613 |
if ( 'wpmem_product' == $column_name ) {
|
614 |
global $wpmem;
|
615 |
$display = array();
|
@@ -617,8 +654,8 @@ class WP_Members_Products_Admin {
|
|
617 |
if ( $user_products ) {
|
618 |
foreach ( $user_products as $meta => $value ) {
|
619 |
if ( isset( $wpmem->membership->products[ $meta ]['title'] ) ) {
|
620 |
-
$expires = ( $user_products[ $meta ] > 1 ) ? ' expires: ' . date_i18n( get_option( 'date_format' ), $user_products[ $meta ] ) : '';
|
621 |
-
$display[] = $wpmem->membership->products[ $meta ]['title'] . $expires;
|
622 |
}
|
623 |
}
|
624 |
}
|
@@ -632,7 +669,7 @@ class WP_Members_Products_Admin {
|
|
632 |
* @param int $user_id
|
633 |
* @param array $user_products
|
634 |
*/
|
635 |
-
return apply_filters( 'wpmem_user_columns_membership_value', implode( "
|
636 |
}
|
637 |
return $val;
|
638 |
}
|
@@ -672,58 +709,141 @@ class WP_Members_Products_Admin {
|
|
672 |
* logged in when checking profiles.
|
673 |
*/
|
674 |
$user_id = ( 'profile' == $pagenow && current_user_can( 'edit_users' ) ) ? get_current_user_id() : sanitize_text_field( wpmem_get( 'user_id', false, 'get' ) );
|
675 |
-
$user_products =
|
676 |
-
echo '<h3>' . __( '
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
|
|
|
|
|
|
711 |
} else {
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
|
|
|
|
|
|
|
|
717 |
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
|
|
723 |
});
|
724 |
-
|
725 |
-
|
726 |
-
|
|
|
|
|
727 |
}
|
728 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
729 |
}
|
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_action( 'admin_head', array( $this, 'post_columns_width' ) );
|
37 |
add_filter( 'manage_posts_columns', array( $this, 'post_columns' ) );
|
38 |
add_action( 'manage_posts_custom_column', array( $this, 'post_columns_content' ), 10, 2 );
|
39 |
add_filter( 'manage_pages_columns', array( $this, 'post_columns' ) );
|
45 |
|
46 |
add_filter( 'wpmem_user_profile_tabs', array( $this, 'user_profile_tabs' ), 1 );
|
47 |
add_action( 'wpmem_user_profile_tabs_content', array( $this, 'user_profile_tab_content' ), 10 );
|
48 |
+
|
49 |
+
add_filter( 'wpmem_views_users', array( $this, 'user_views' ), 10, 2 );
|
50 |
+
add_filter( 'wpmem_query_where', array( $this, 'query_where' ), 10, 2 );
|
51 |
}
|
52 |
|
53 |
$this->default_products = $wpmem->membership->get_default_products();
|
356 |
* @since 3.3.5
|
357 |
*/
|
358 |
do_action( 'wpmem_membership_product_message_meta_before' );
|
359 |
+
|
360 |
+
echo '<p>' . __( 'Restricted Message (displays when a user does not have access to a membership)', 'wp-members' ) . '</p>';
|
361 |
+
|
362 |
+
$args = array(
|
363 |
+
'media_buttons' => false,
|
364 |
+
'textarea_rows' => 10,
|
365 |
+
);
|
366 |
+
|
367 |
+
wp_editor( $message, 'product_message', $args );
|
368 |
+
|
369 |
/**
|
370 |
* Fires after membership product messate meta box.
|
371 |
*
|
500 |
'type' => 'multiselect',
|
501 |
'value' => $values,
|
502 |
'compare' => $product,
|
503 |
+
'class' => 'wpmem-product-select2 populate placeholder',
|
504 |
) );
|
505 |
}
|
506 |
|
541 |
<script language="javascript">
|
542 |
(function($) {
|
543 |
$(document).ready(function() {
|
544 |
+
$('.wpmem-product-select2').select2({width:"100%"});
|
545 |
});
|
546 |
})(jQuery);
|
547 |
</script><?php
|
548 |
}
|
549 |
}
|
550 |
|
551 |
+
/**
|
552 |
+
* Styles the width for membership post column.
|
553 |
+
*
|
554 |
+
* @since 3.4.0
|
555 |
+
*/
|
556 |
+
function post_columns_width() {
|
557 |
+
if ( isset( $_REQUEST['post_type'] ) ) {
|
558 |
+
echo '<style>.column-wpmem_product{ min-width:140px; width: 12%;}</style>';
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
/**
|
563 |
* Add membership product column to post table.
|
564 |
*
|
633 |
* @return array $display
|
634 |
*/
|
635 |
function user_columns_content( $val, $column_name, $user_id ) {
|
636 |
+
/**
|
637 |
+
* Filter the users > all users screen membership column default html.
|
638 |
+
*
|
639 |
+
* @since 3.4.0
|
640 |
+
*
|
641 |
+
* @param array $defaults
|
642 |
+
* @param array $val
|
643 |
+
* @param array $column_name
|
644 |
+
* @param array $user_id
|
645 |
+
*/
|
646 |
+
$defaults = apply_filters( 'wpmem_user_columns_membership_defaults', array(
|
647 |
+
'item_wrap_before' => '<div class="wpmem-user-table-membership">',
|
648 |
+
'item_wrap_after' => '</div>',
|
649 |
+
), $val, $column_name, $user_id );
|
650 |
if ( 'wpmem_product' == $column_name ) {
|
651 |
global $wpmem;
|
652 |
$display = array();
|
654 |
if ( $user_products ) {
|
655 |
foreach ( $user_products as $meta => $value ) {
|
656 |
if ( isset( $wpmem->membership->products[ $meta ]['title'] ) ) {
|
657 |
+
$expires = ( $user_products[ $meta ] > 1 ) ? '<br />' . __( 'expires:', 'wp-members' ) . ' ' . date_i18n( get_option( 'date_format' ), $user_products[ $meta ] ) : '';
|
658 |
+
$display[] = $defaults['item_wrap_before'] . $wpmem->membership->products[ $meta ]['title'] . $expires . $defaults['item_wrap_after'];
|
659 |
}
|
660 |
}
|
661 |
}
|
669 |
* @param int $user_id
|
670 |
* @param array $user_products
|
671 |
*/
|
672 |
+
return apply_filters( 'wpmem_user_columns_membership_value', implode( " ", $display ), $display, $user_id, $user_products );
|
673 |
}
|
674 |
return $val;
|
675 |
}
|
709 |
* logged in when checking profiles.
|
710 |
*/
|
711 |
$user_id = ( 'profile' == $pagenow && current_user_can( 'edit_users' ) ) ? get_current_user_id() : sanitize_text_field( wpmem_get( 'user_id', false, 'get' ) );
|
712 |
+
$user_products = wpmem_get_user_products( $user_id );
|
713 |
+
echo '<h3>' . __( 'Membership Access', 'wp-members' ) . '</h3>';
|
714 |
+
if ( ! empty( $wpmem->membership->products ) ) {
|
715 |
+
$expires_heading = " ";
|
716 |
+
foreach( $wpmem->membership->products as $key => $value ) {
|
717 |
+
$expires_heading = ( ! empty( $value['expires'] ) ) ? __( 'Expires', 'wp-members' ) : $expires_heading;
|
718 |
+
}
|
719 |
+
echo '<table>
|
720 |
+
<tr>
|
721 |
+
<th>' . __( 'Action', 'wp-members' ) . '</th>
|
722 |
+
<th>' . __( 'Membership', 'wp-members' ) . '</th>
|
723 |
+
<th>' . __( 'Enabled?', 'wp-members' ) . '</th>
|
724 |
+
<th>' . $expires_heading . '</th>
|
725 |
+
</tr>'; ?>
|
726 |
+
<?php
|
727 |
+
|
728 |
+
foreach ( $wpmem->membership->products as $key => $value ) {
|
729 |
+
$checked = ( $user_products && array_key_exists( $key, $user_products ) ) ? "checked" : "";
|
730 |
+
echo "<tr>";
|
731 |
+
echo '<td style="padding:5px 5px;">
|
732 |
+
<select name="_wpmem_membership_product[' . $key . ']">
|
733 |
+
<option value="">----</option>
|
734 |
+
<option value="enable">' . __( 'Enable', 'wp-members' ) . '</option>
|
735 |
+
<option value="disable">' . __( 'Disable', 'wp-members' ) . '</option>
|
736 |
+
<option value="enable">' . __( 'Update', 'wp-members' ) . '</option>
|
737 |
+
</select></td><td style="padding:0px 0px;">' . $value['title'] . '</td>';
|
738 |
+
|
739 |
+
// If user has date, display that; otherwise placeholder
|
740 |
+
$date_value = ( isset( $user_products[ $key ] ) && 1 != $user_products[ $key ] && 0 != $user_products[ $key ] && '' != $user_products[ $key ] ) ? date( 'Y-m-d', $user_products[ $key ] ) : "";
|
741 |
+
$placeholder = ( ! isset( $user_products[ $key ] ) ) ? 'placeholder="' . __( 'Expiration date (optional)', 'wp-members' ) . '" ' : '';
|
742 |
+
$product_date_field = ' <input type="text" name="_wpmem_membership_expiration_' . $key . '" value="' . $date_value . '" class="wpmem_datepicker" ' . $placeholder . ' />';
|
743 |
+
|
744 |
+
if ( isset( $user_products[ $key ] ) ) {
|
745 |
+
echo '<td align="center"><span id="wpmem_product_enabled" class="dashicons dashicons-yes"></span></td>';
|
746 |
+
if ( $user_products[ $key ] != 1 ) {
|
747 |
+
echo '<td>' . $product_date_field . '</td>';
|
748 |
+
} else {
|
749 |
+
echo '<td> </td>';
|
750 |
+
}
|
751 |
} else {
|
752 |
+
if ( isset( $value['expires'] ) && ! empty( $value['expires'] ) ) {
|
753 |
+
echo '<td><span id="wpmem_product_enabled" class="dashicons"></span></td>';
|
754 |
+
echo '<td>' . $product_date_field . '</td>';
|
755 |
+
} else {
|
756 |
+
echo '<td> </td>';
|
757 |
+
}
|
758 |
+
}
|
759 |
+
echo '</tr>';
|
760 |
+
}
|
761 |
|
762 |
+
?></table>
|
763 |
+
<script>
|
764 |
+
jQuery(function() {
|
765 |
+
jQuery( ".wpmem_datepicker" ).datepicker({
|
766 |
+
dateFormat : "yy-mm-dd"
|
767 |
+
});
|
768 |
});
|
769 |
+
</script>
|
770 |
+
<?php
|
771 |
+
} else {
|
772 |
+
echo '<p>' . sprintf( __( 'No memberships have been created. %sCreate new memberships here%s', 'wp-members' ), '<a href="' . admin_url() . 'edit.php?post_type=wpmem_product">', '</a>' );
|
773 |
+
}
|
774 |
}
|
775 |
}
|
776 |
+
|
777 |
+
/**
|
778 |
+
* Adds user view links to Users > All Users for each membership.
|
779 |
+
*
|
780 |
+
* @since 3.3.9
|
781 |
+
*
|
782 |
+
* @param array $views
|
783 |
+
* @param string $show The slug of the current view.
|
784 |
+
* @return array $views
|
785 |
+
*/
|
786 |
+
function user_views( $views, $show ) {
|
787 |
+
|
788 |
+
global $wpdb, $wpmem;
|
789 |
+
|
790 |
+
// Add a view for each membership
|
791 |
+
foreach ( $wpmem->membership->product_by_id as $product_slug ) {
|
792 |
+
|
793 |
+
// Count is stored in a transient (see "if" condition below).
|
794 |
+
$count = get_transient( 'wpmem_user_counts_' . $product_slug );
|
795 |
+
// If the transient is not already set.
|
796 |
+
if ( false === $count ) {
|
797 |
+
|
798 |
+
// Get the count
|
799 |
+
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . $wpdb->usermeta . " WHERE meta_key=%s AND meta_value>0", "_wpmem_products_" . $product_slug ) );
|
800 |
+
|
801 |
+
// Save it in a transient
|
802 |
+
$transient_expires = 60; // Value in seconds, 1 day: ( 60 * 60 * 24 );
|
803 |
+
set_transient( 'wpmem_user_counts_' . $product_slug, $count, $transient_expires );
|
804 |
+
}
|
805 |
+
|
806 |
+
// Build the link for the filter view
|
807 |
+
$link = "users.php?action=show&show=" . $product_slug;
|
808 |
+
$current = ( $show == $product_slug ) ? ' class="current"' : '';
|
809 |
+
$views[ $product_slug ] = sprintf(
|
810 |
+
'<a href="%s" %s>%s <span class="count">(%d)</span></a>',
|
811 |
+
esc_url( $link ),
|
812 |
+
$current,
|
813 |
+
$wpmem->membership->products[ $product_slug ]['title'],
|
814 |
+
$count
|
815 |
+
);
|
816 |
+
}
|
817 |
+
|
818 |
+
// Return the $views array with the added membership views.
|
819 |
+
return $views;
|
820 |
+
}
|
821 |
+
|
822 |
+
/**
|
823 |
+
* Filters the "where" query for user view links in Users > All Users for each membership.
|
824 |
+
*
|
825 |
+
* @since 3.3.9
|
826 |
+
*
|
827 |
+
* @param string $query_where
|
828 |
+
* @param string $show The slug of the current view.
|
829 |
+
* @return string $query_where
|
830 |
+
*/
|
831 |
+
function query_where( $query_where, $show ) {
|
832 |
+
|
833 |
+
global $wpdb, $wpmem;
|
834 |
+
|
835 |
+
// Check for membership views.
|
836 |
+
foreach ( $wpmem->membership->product_by_id as $product_slug ) {
|
837 |
+
// Check if we are viewing ($show) a membership ($prduct_slug).
|
838 |
+
if ( $product_slug == $show ) {
|
839 |
+
// Set appropriate $query_where to filter the view.
|
840 |
+
$query_where = "WHERE 1=1 AND {$wpdb->users}.ID IN (
|
841 |
+
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
842 |
+
WHERE {$wpdb->usermeta}.meta_key = \"" . esc_sql( "_wpmem_products_" . $product_slug ) . "\"
|
843 |
+
AND {$wpdb->usermeta}.meta_value > 0 )";
|
844 |
+
}
|
845 |
+
}
|
846 |
+
|
847 |
+
return $query_where;
|
848 |
+
}
|
849 |
}
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members Export Class.
|
4 |
+
*
|
5 |
+
* @package WP-Members
|
6 |
+
* @subpackage WP_Members Export Object Class
|
7 |
+
* @since 3.3.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly.
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit();
|
13 |
+
}
|
14 |
+
|
15 |
+
class WP_Members_User_Export {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* New export function to export all or selected users
|
19 |
+
*
|
20 |
+
* @since 2.9.7
|
21 |
+
* @since 3.2.0 Updated to use fputcsv.
|
22 |
+
* @since 3.2.1 Added user data filters.
|
23 |
+
* @since 3.3.0 Moved to new object class as static method.
|
24 |
+
* @since 3.4.0 Added $tag to identify what export process is being run.
|
25 |
+
*
|
26 |
+
* @param array $args array {
|
27 |
+
* Array of defaults for export.
|
28 |
+
*
|
29 |
+
* @type string $export The type of export (all|selected)
|
30 |
+
* @type string $filename
|
31 |
+
* @type array $fields {
|
32 |
+
* The array of export fields is keyed as 'meta_key' => 'heading value'.
|
33 |
+
* The array can include fields in the Fields tab, plus the following:
|
34 |
+
*
|
35 |
+
* @type int $ID ID from wp_users
|
36 |
+
* @type string $username user_login from wp_users
|
37 |
+
* @type string $user_nicename user_nicename
|
38 |
+
* @type string $user_url user_url
|
39 |
+
* @type string $display_name display_name
|
40 |
+
* @type int $active Whether the user is active/deactivated.
|
41 |
+
* @type string $exp_type If the PayPal extension is installed pending|subscrption (optional)
|
42 |
+
* @type string $expires If the PayPal extension is installed MM/DD/YYYY (optional)
|
43 |
+
* @type string $user_registered user_registered
|
44 |
+
* @type string $user_ip The IP of the user when they registered.
|
45 |
+
* @type string $role The user's role (or roles, if multiple).
|
46 |
+
* }
|
47 |
+
* @type array $exclude_fields @deprecated 3.4.0
|
48 |
+
* @type boolean $entity_decode
|
49 |
+
* @type string $date_format
|
50 |
+
* }
|
51 |
+
* @param array $users Array of user IDs to export.
|
52 |
+
* @param string $tag
|
53 |
+
*/
|
54 |
+
static function export_users( $args = array(), $users = array(), $tag = 'default' ) {
|
55 |
+
|
56 |
+
global $wpmem;
|
57 |
+
|
58 |
+
$export_fields = ( ! isset( $args['fields'] ) ) ? self::get_export_fields() : $args['fields'];
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Filter the export fields.
|
62 |
+
*
|
63 |
+
* @since 3.2.5
|
64 |
+
* @since 3.4.0 Added $tag.
|
65 |
+
*
|
66 |
+
* @param array $export_fields {
|
67 |
+
* The array of export fields is keyed as 'meta_key' => 'heading value'.
|
68 |
+
* The array will include all fields in the Fields tab, plus the following:
|
69 |
+
*
|
70 |
+
* @type int $ID ID from wp_users
|
71 |
+
* @type string $username user_login from wp_users
|
72 |
+
* @type string $user_nicename user_nicename
|
73 |
+
* @type string $user_url user_url
|
74 |
+
* @type string $display_name display_name
|
75 |
+
* @type int $active Whether the user is active/deactivated.
|
76 |
+
* @type string $exp_type If the PayPal extension is installed pending|subscrption (optional)
|
77 |
+
* @type string $expires If the PayPal extension is installed MM/DD/YYYY (optional)
|
78 |
+
* @type string $user_registered user_registered
|
79 |
+
* @type string $user_ip The IP of the user when they registered.
|
80 |
+
* @type string $role The user's role (or roles, if multiple).
|
81 |
+
* }
|
82 |
+
* @param string $tag
|
83 |
+
*/
|
84 |
+
$export_fields = apply_filters( 'wpmem_export_fields', $export_fields, $tag );
|
85 |
+
|
86 |
+
$today = date( "Y-m-d" );
|
87 |
+
|
88 |
+
// Setup defaults.
|
89 |
+
$defaults = array(
|
90 |
+
'export' => 'all',
|
91 |
+
'filename' => 'wp-members-user-export-' . $today . '.csv',
|
92 |
+
'fields' => $export_fields,
|
93 |
+
'entity_decode' => false,
|
94 |
+
'date_format' => 'Y-m-d',
|
95 |
+
'required_caps' => 'list_users',
|
96 |
+
);
|
97 |
+
// Merge args with default (in case any were missing).
|
98 |
+
$args = wp_parse_args( $args, $defaults );
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Filter the default export arguments.
|
102 |
+
*
|
103 |
+
* @since 2.9.7
|
104 |
+
* @since 3.4.0 Filter all defaults (like other _args changes), then wp_parse_args() in case any are missing.
|
105 |
+
* @since 3.4.0 Added $tag.
|
106 |
+
* @since 3.4.0 Deprecated 'exclude_fields' (unset using wpmem_export_fields instead).
|
107 |
+
* @since 3.4.0 Deprecated 'export_fields' use "fields" instead.
|
108 |
+
*
|
109 |
+
* @param array $args {
|
110 |
+
* Array of defaults for export.
|
111 |
+
*
|
112 |
+
* @type string $export
|
113 |
+
* @type string $filename
|
114 |
+
* @type array $fields
|
115 |
+
* @type array $exclude_fields @deprecated 3.4.0
|
116 |
+
* @type boolean $entity_decode
|
117 |
+
* @type string $date_format
|
118 |
+
* }
|
119 |
+
* @param string $tag
|
120 |
+
*/
|
121 |
+
$args = apply_filters( 'wpmem_export_args', $args, $tag );
|
122 |
+
|
123 |
+
// Merge args with default (in case any were missing).
|
124 |
+
$args = wp_parse_args( $args, $defaults );
|
125 |
+
|
126 |
+
if ( current_user_can( $args['required_caps'] ) ) {
|
127 |
+
// Output needs to be buffered, start the buffer.
|
128 |
+
ob_start();
|
129 |
+
|
130 |
+
// If exporting all, get all of the users.
|
131 |
+
$export_users = ( 'all' == $args['export'] ) ? get_users( array( 'fields' => 'ID' ) ) : $users;
|
132 |
+
|
133 |
+
// Generate headers and a filename based on date of export.
|
134 |
+
header( "Content-Description: File Transfer" );
|
135 |
+
header( "Content-type: application/octet-stream" );
|
136 |
+
header( "Content-Disposition: attachment; filename=" . $args['filename'] );
|
137 |
+
header( "Content-Type: text/csv; charset=" . get_option( 'blog_charset' ), true );
|
138 |
+
|
139 |
+
$handle = fopen( 'php://output', 'w' );
|
140 |
+
fputs( $handle, "\xEF\xBB\xBF" ); // UTF-8 BOM
|
141 |
+
|
142 |
+
// Remove excluded fields from $export_fields while setting up $header array.
|
143 |
+
$header = array();
|
144 |
+
foreach ( $args['fields'] as $meta => $field ) {
|
145 |
+
$header[ $meta ] = $field;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Filters user export header row before assembly.
|
150 |
+
*
|
151 |
+
* As of 3.4.0, this really isn't a necessary filter. You can specify the header
|
152 |
+
* value in wpmem_export_fields instead and just use one filter.
|
153 |
+
*
|
154 |
+
* @since 3.2.1
|
155 |
+
* @since 3.4.0 Added $tag.
|
156 |
+
*
|
157 |
+
* @param array $header The header column values
|
158 |
+
* @param string $tag
|
159 |
+
*/
|
160 |
+
$header = apply_filters( 'wpmem_user_export_header', $header, $tag );
|
161 |
+
|
162 |
+
fputcsv( $handle, $header );
|
163 |
+
|
164 |
+
// Loop through the array of users, assemble csv.
|
165 |
+
// $fields only includes fields to be exported at this point.
|
166 |
+
foreach ( $export_users as $user ) {
|
167 |
+
|
168 |
+
$user_info = get_userdata( $user );
|
169 |
+
|
170 |
+
$wp_user_fields = array( 'ID', 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_activation_key', 'user_status', 'display_name' );
|
171 |
+
foreach ( $args['fields'] as $meta => $field ) {
|
172 |
+
|
173 |
+
switch ( $meta ) {
|
174 |
+
case 'ID':
|
175 |
+
case 'user_login':
|
176 |
+
case 'user_pass':
|
177 |
+
case 'user_nicename':
|
178 |
+
case 'user_email':
|
179 |
+
case 'user_url':
|
180 |
+
case 'user_registered':
|
181 |
+
case 'user_activation_key':
|
182 |
+
case 'user_status':
|
183 |
+
case 'display_name':
|
184 |
+
$row[ $meta ] = $user_info->{$meta};
|
185 |
+
break;
|
186 |
+
case 'username':
|
187 |
+
$row['username'] = $user_info->user_login;
|
188 |
+
break;
|
189 |
+
case 'password':
|
190 |
+
$row['password'] = $user_info->user_pass;
|
191 |
+
break;
|
192 |
+
case 'active':
|
193 |
+
$row['active'] = wpmem_get_user_meta( $user, 'active' ) ? __( 'Yes' ) : __( 'No' );
|
194 |
+
break;
|
195 |
+
case 'exp_type':
|
196 |
+
$exp_type = wpmem_get_user_meta( $user, 'exp_type' );
|
197 |
+
$row['exp_type'] = ( false !== $exp_type ) ? $exp_type : '';
|
198 |
+
break;
|
199 |
+
case 'expires':
|
200 |
+
$expires = wpmem_get_user_meta( $user, 'expires' );
|
201 |
+
$row['expires'] = ( false !== $expires ) ? $expires : '';
|
202 |
+
break;
|
203 |
+
case 'wpmem_reg_ip':
|
204 |
+
$reg_ip = wpmem_get_user_meta( $user, 'wpmem_reg_ip' );
|
205 |
+
$row['wpmem_reg_ip'] = ( false !== $reg_ip ) ? $reg_ip : '';
|
206 |
+
break;
|
207 |
+
case 'role':
|
208 |
+
$role = wpmem_get_user_role( $user, true ); // As of 3.4, wpmem_get_user_role() can get all roles.
|
209 |
+
$row['role'] = ( is_array( $role ) ) ? implode( ",", $role ) : $role;
|
210 |
+
break;
|
211 |
+
case ( $wpmem->membership->post_stem === substr( $meta, 0, strlen( $wpmem->membership->post_stem ) ) ):
|
212 |
+
$product = str_replace( $wpmem->membership->post_stem, '', $meta );
|
213 |
+
$row[ $meta ] = wpmem_get_user_meta( $user, $meta );
|
214 |
+
// If value is a date and false is not the format_date option...
|
215 |
+
if ( false !== $args['date_format'] && '' != $row[ $meta ] && $row[ $meta ] > 2 ) {
|
216 |
+
$date_format = ( 'wp' == $args['date_format'] ) ? get_option('date_format') : $args['date_format'];
|
217 |
+
$row[ $meta ] = date( $date_format, $row[ $meta ] );
|
218 |
+
}
|
219 |
+
break;
|
220 |
+
default:
|
221 |
+
if ( in_array( $meta, $wp_user_fields ) ) {
|
222 |
+
$row[ $meta ] = ( 'username' == $meta ) ? $user_info->user_login : $user_info->{$meta};
|
223 |
+
} else {
|
224 |
+
$raw_data = wpmem_get_user_meta( $user, $meta );
|
225 |
+
$raw_data = ( $raw_data ) ? $raw_data : '';
|
226 |
+
$row[ $meta ] = ( $args['entity_decode'] ) ? html_entity_decode( $raw_data ) : $raw_data;
|
227 |
+
}
|
228 |
+
break;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Filter the user data before assembly.
|
234 |
+
*
|
235 |
+
* @since 3.2.1
|
236 |
+
* @since 3.4.0 Added user ID (it may not be included in the $row array if the field were filtered out).
|
237 |
+
* @since 3.4.0 Added $tag.
|
238 |
+
*
|
239 |
+
* @param array $row The user data row.
|
240 |
+
* @param int $user_id The user ID.
|
241 |
+
* @param string $tag
|
242 |
+
*/
|
243 |
+
$row = apply_filters( 'wpmem_user_export_row', $row, $user_info->ID, $tag );
|
244 |
+
|
245 |
+
fputcsv( $handle, $row );
|
246 |
+
|
247 |
+
// Update the user record as being exported.
|
248 |
+
if ( 'all' != $args['export'] ) {
|
249 |
+
update_user_meta( $user, 'exported', 1 );
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
fclose( $handle );
|
254 |
+
print( ob_get_clean() );
|
255 |
+
|
256 |
+
exit();
|
257 |
+
} else {
|
258 |
+
wp_die( __( 'You do not have the required user capabilities to export users.', 'wp-members' ) );
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
private static function get_export_fields() {
|
263 |
+
|
264 |
+
$wpmem_fields = wpmem_fields();
|
265 |
+
|
266 |
+
// Fields to exclude.
|
267 |
+
$exclude_fields = array( 'user_pass', 'password', 'confirm_password', 'confirm_email' );
|
268 |
+
|
269 |
+
// Prepare fields, add additional "special" fields.
|
270 |
+
$export_fields = array(
|
271 |
+
'ID' => __( 'User ID', 'wp-members' ),
|
272 |
+
);
|
273 |
+
foreach( $wpmem_fields as $meta_key => $value ) {
|
274 |
+
if ( ! in_array( $meta_key, $exclude_fields ) ) {
|
275 |
+
$export_fields[ $meta_key ] = $value['label'];
|
276 |
+
}
|
277 |
+
}
|
278 |
+
$export_fields['username'] = __( 'Username', 'wp-members' );
|
279 |
+
if ( 1 == $wpmem->mod_reg ) {
|
280 |
+
$export_fields['active'] = __( 'Activated?', 'wp-members' );
|
281 |
+
}
|
282 |
+
if ( defined( 'WPMEM_EXP_MODULE' ) && 1 == $wpmem->use_exp ) {
|
283 |
+
$export_fields['exp_type'] = __( 'Subscription', 'wp-members' );
|
284 |
+
$export_fields['expires'] = __( 'Expires', 'wp-members' );
|
285 |
+
}
|
286 |
+
$export_fields['user_registered'] = __( 'Registered', 'wp-members' );
|
287 |
+
$export_fields['wpmem_reg_ip'] = __( 'IP', 'wp-members' );
|
288 |
+
$export_fields['role'] = __( 'Role', 'wp-members' );
|
289 |
+
if ( 1 == $wpmem->enable_products ) {
|
290 |
+
foreach( $wpmem->membership->products as $product_key => $product ) {
|
291 |
+
$export_fields[ $wpmem->membership->post_stem . $product_key ] = $wpmem->membership->products[ $product_key ]['title'];
|
292 |
+
}
|
293 |
+
}
|
294 |
+
|
295 |
+
return $export_fields;
|
296 |
+
}
|
297 |
+
}
|
@@ -6,12 +6,12 @@
|
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
-
* Copyright (c) 2006-
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
*
|
16 |
* Functions included:
|
17 |
* - wpmem_a_do_warnings
|
@@ -75,7 +75,7 @@ function wpmem_a_do_warnings( $did_update ) {
|
|
75 |
}
|
76 |
|
77 |
// Holding registrations but haven't changed default successful registration message.
|
78 |
-
if ( $warnings_on && $wpmem->mod_reg == 1 && $dialogs['success'] ==
|
79 |
wpmem_a_warning_msg( 'success' );
|
80 |
$warning_active = true;
|
81 |
}
|
@@ -173,8 +173,8 @@ function wpmem_a_meta_box() {
|
|
173 |
|
174 |
<p><strong><?php _e( 'Version:', 'wp-members' ); echo " " . $wpmem->version; ?></strong><br />
|
175 |
<a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/"><?php _e( 'Quick Start Guide', 'wp-members' ); ?></a><br />
|
176 |
-
<a href="https://rocketgeek.com/plugins/wp-members/
|
177 |
-
<a href="https://rocketgeek.com/plugins/wp-members/
|
178 |
<?php if( ! defined( 'WPMEM_REMOVE_ATTR' ) ) { ?>
|
179 |
<br /><br /><a href="https://rocketgeek.com/about/site-membership-subscription/">Find out how to get access</a> to WP-Members private members forum, premium code snippets, tutorials, and add-on modules!
|
180 |
<?php } ?>
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
+
* Copyright (c) 2006-2021 Chad Butler
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
*
|
16 |
* Functions included:
|
17 |
* - wpmem_a_do_warnings
|
75 |
}
|
76 |
|
77 |
// Holding registrations but haven't changed default successful registration message.
|
78 |
+
if ( $warnings_on && $wpmem->mod_reg == 1 && $dialogs['success'] == wpmem_get_text( 'success' ) ) {
|
79 |
wpmem_a_warning_msg( 'success' );
|
80 |
$warning_active = true;
|
81 |
}
|
173 |
|
174 |
<p><strong><?php _e( 'Version:', 'wp-members' ); echo " " . $wpmem->version; ?></strong><br />
|
175 |
<a href="https://rocketgeek.com/plugins/wp-members/quick-start-guide/"><?php _e( 'Quick Start Guide', 'wp-members' ); ?></a><br />
|
176 |
+
<a href="https://rocketgeek.com/plugins/wp-members/docs/"><?php _e( 'Online User Guide', 'wp-members' ); ?></a><br />
|
177 |
+
<a href="https://rocketgeek.com/plugins/wp-members/docs/faqs/"><?php _e( 'FAQs', 'wp-members' ); ?></a>
|
178 |
<?php if( ! defined( 'WPMEM_REMOVE_ATTR' ) ) { ?>
|
179 |
<br /><br /><a href="https://rocketgeek.com/about/site-membership-subscription/">Find out how to get access</a> to WP-Members private members forum, premium code snippets, tutorials, and add-on modules!
|
180 |
<?php } ?>
|
@@ -1,320 +1,321 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members Admin Functions
|
4 |
-
*
|
5 |
-
* Functions to manage the captcha tab.
|
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-
|
10 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
-
*
|
12 |
-
* @package WP-Members
|
13 |
-
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
-
*/
|
16 |
-
|
17 |
-
// Exit if accessed directly.
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit();
|
20 |
-
}
|
21 |
-
|
22 |
-
class WP_Members_Admin_Tab_Captcha {
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Creates the captcha tab.
|
26 |
-
*
|
27 |
-
* @since 2.8.0
|
28 |
-
* @since 3.3.0 Ported to do_tab().
|
29 |
-
*
|
30 |
-
* @param string $tab The admin tab being displayed.
|
31 |
-
* @return string|bool The captcha options tab, otherwise false.
|
32 |
-
*/
|
33 |
-
public static function do_tab( $tab ) {
|
34 |
-
if ( $tab == 'captcha' ) {
|
35 |
-
return self::build_settings();
|
36 |
-
} else {
|
37 |
-
return false;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Adds the captcha tab.
|
43 |
-
*
|
44 |
-
* @since 2.8.0
|
45 |
-
* @since 3.3.0 Ported wpmem_add_captcha_tab() to add_tab().
|
46 |
-
*
|
47 |
-
* @param array $tabs The array of tabs for the admin panel.
|
48 |
-
* @return array The updated array of tabs for the admin panel.
|
49 |
-
*/
|
50 |
-
public static function add_tab( $tabs ) {
|
51 |
-
return array_merge( $tabs, array( 'captcha' => 'Captcha' ) );
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Builds the captcha options.
|
56 |
-
*
|
57 |
-
* @since 2.4.0
|
58 |
-
* @since 3.3.0 Ported wpmem_a_build_captcha_options() to build_settings().
|
59 |
-
*/
|
60 |
-
public static function build_settings() {
|
61 |
-
|
62 |
-
// Global settings.
|
63 |
-
global $wpmem, $updated_captcha_type;
|
64 |
-
|
65 |
-
$wpmem_captcha = get_option( 'wpmembers_captcha' );
|
66 |
-
$url = home_url();
|
67 |
-
$help_link = sprintf( __( 'See the %sUsers Guide on CAPTCHA%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/
|
68 |
-
?>
|
69 |
-
<div class="metabox-holder has-right-sidebar">
|
70 |
-
|
71 |
-
<div class="inner-sidebar">
|
72 |
-
<?php wpmem_a_meta_box(); ?>
|
73 |
-
<div class="postbox">
|
74 |
-
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
75 |
-
<div class="inside">
|
76 |
-
<strong><i><?php echo $help_link; ?></i></strong>
|
77 |
-
</div>
|
78 |
-
</div>
|
79 |
-
</div> <!-- .inner-sidebar -->
|
80 |
-
|
81 |
-
<div id="post-body">
|
82 |
-
<div id="post-body-content">
|
83 |
-
<div class="postbox">
|
84 |
-
|
85 |
-
<h3><?php _e( 'Manage CAPTCHA Options', 'wp-members' ); ?></h3>
|
86 |
-
<div class="inside">
|
87 |
-
<form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
|
88 |
-
<?php wp_nonce_field( 'wpmem-update-captcha' ); ?>
|
89 |
-
<table class="form-table">
|
90 |
-
<tr valign="top">
|
91 |
-
<th><?php _e( 'CAPTCHA Type', 'wp-members' ); ?></th>
|
92 |
-
<td><?php
|
93 |
-
if ( 1 == $wpmem->captcha ) {
|
94 |
-
$wpmem->captcha = 3; // reCAPTCHA v1 is fully obsolete. Change it to v2.
|
95 |
-
}
|
96 |
-
$captcha[] = __( 'reCAPTCHA v2', 'wp-members' ) . '|3';
|
97 |
-
$captcha[] = __( 'reCAPTCHA v3', 'wp-members' ) . '|4';
|
98 |
-
$captcha[] = __( 'Really Simple CAPTCHA', 'wp-members' ) . '|2';
|
99 |
-
$captcha[] = __( 'hCaptcha', 'wp-members' ) . '|5';
|
100 |
-
echo
|
101 |
-
</td>
|
102 |
-
</tr>
|
103 |
-
<?php if ( isset( $updated_captcha_type ) ) { ?>
|
104 |
-
<tr>
|
105 |
-
<td colspan="2">
|
106 |
-
<p><?php _e( 'CAPTCHA type was changed. Please verify and update the settings below for the new CAPTCHA type.', 'wp-members' ); ?></p>
|
107 |
-
</td>
|
108 |
-
</tr>
|
109 |
-
<?php } ?>
|
110 |
-
<?php // if reCAPTCHA is enabled...
|
111 |
-
if ( 3 == $wpmem->captcha || 4 == $wpmem->captcha ) {
|
112 |
-
$show_update_button = true;
|
113 |
-
$private_key = ( isset( $wpmem_captcha['recaptcha'] ) ) ? $wpmem_captcha['recaptcha']['private'] : '';
|
114 |
-
$public_key = ( isset( $wpmem_captcha['recaptcha'] ) ) ? $wpmem_captcha['recaptcha']['public'] : '';
|
115 |
-
?>
|
116 |
-
<tr valign="top">
|
117 |
-
<th scope="row"><?php _e( 'reCAPTCHA Keys', 'wp-members' ); ?></th>
|
118 |
-
<td>
|
119 |
-
<p><?php if ( '' == $wpmem_captcha['recaptcha']['private'] || '' == $wpmem_captcha['recaptcha']['public'] ) {
|
120 |
-
printf( __( 'reCAPTCHA requires an API key, consisting of a "site" and a "secret" key. You can sign up for a %s free reCAPTCHA key%s', 'wp-members' ), "<a href=\"https://www.google.com/recaptcha/admin#whyrecaptcha\" target=\"_blank\">", '</a>' );
|
121 |
-
} ?></p>
|
122 |
-
<p><label><?php _e( 'Site Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_publickey" size="60" value="<?php echo $public_key; ?>" /></p>
|
123 |
-
<p><label><?php _e( 'Secret Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_privatekey" size="60" value="<?php echo $private_key; ?>" /></p>
|
124 |
-
</td>
|
125 |
-
</tr>
|
126 |
-
<?php
|
127 |
-
} elseif ( 5 == $wpmem->captcha ) {
|
128 |
-
$show_update_button = true;
|
129 |
-
$private_key = ( isset( $wpmem_captcha['hcaptcha'] ) ) ? $wpmem_captcha['hcaptcha']['secret'] : '';
|
130 |
-
$public_key = ( isset( $wpmem_captcha['hcaptcha'] ) ) ? $wpmem_captcha['hcaptcha']['api_key'] : '';
|
131 |
-
?>
|
132 |
-
<tr valign="top">
|
133 |
-
<th scope="row"><?php _e( 'hCaptcha Keys', 'wp-members' ); ?></th>
|
134 |
-
<td>
|
135 |
-
<p><?php if ( '' == $private_key || '' == $public_key ) {
|
136 |
-
printf( __( 'hCaptcha requires an API key. You can sign up for %s an hCaptcha API key here %s', 'wp-members' ), "<a href=\"https://hcaptcha.com/\" target=\"_blank\">", '</a>' );
|
137 |
-
} ?></p>
|
138 |
-
<p><label><?php _e( 'API Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_publickey" size="60" value="<?php echo $public_key; ?>" /></p>
|
139 |
-
<p><label><?php _e( 'Secret Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_privatekey" size="60" value="<?php echo $private_key; ?>" /></p>
|
140 |
-
</td>
|
141 |
-
</tr>
|
142 |
-
<?php
|
143 |
-
// If Really Simple CAPTCHA is enabled.
|
144 |
-
} elseif ( $wpmem->captcha == 2 ) {
|
145 |
-
|
146 |
-
// Setup defaults.
|
147 |
-
$defaults = array(
|
148 |
-
'characters' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789',
|
149 |
-
'num_char' => '4',
|
150 |
-
'dim_w' => '72',
|
151 |
-
'dim_h' => '30',
|
152 |
-
'font_color' => '0,0,0',
|
153 |
-
'bg_color' => '255,255,255',
|
154 |
-
'font_size' => '12',
|
155 |
-
'kerning' => '14',
|
156 |
-
'img_type' => 'png',
|
157 |
-
);
|
158 |
-
|
159 |
-
$args = ( isset( $wpmem_captcha['really_simple'] ) && is_array( $wpmem_captcha['really_simple'] ) ) ? $wpmem_captcha['really_simple'] : array();
|
160 |
-
|
161 |
-
$args = wp_parse_args( $args, $defaults );
|
162 |
-
|
163 |
-
// Explode colors.
|
164 |
-
$font_color = explode( ',', $args['font_color'] );
|
165 |
-
$bg_color = explode( ',', $args['bg_color'] );
|
166 |
-
|
167 |
-
$show_update_button = true;
|
168 |
-
if ( is_plugin_active( 'really-simple-captcha/really-simple-captcha.php' ) ) { ?>
|
169 |
-
<tr>
|
170 |
-
<th scope="row"><?php _e( 'Characters for image', 'wp-members' ); ?></th>
|
171 |
-
<td><input name="characters" type="text" size="34" value="<?php echo $args['characters']; ?>" /></td>
|
172 |
-
</tr>
|
173 |
-
<tr>
|
174 |
-
<th scope="row"><?php _e( 'Number of characters', 'wp-members' ); ?></th>
|
175 |
-
<td><input name="num_char" type="text" size="2" value="<?php echo $args['num_char']; ?>" /></td>
|
176 |
-
</tr>
|
177 |
-
<tr>
|
178 |
-
<th scope="row"><?php _e( 'Image dimensions', 'wp-members' ); ?></th>
|
179 |
-
<td><?php _e( 'Width' ); ?> <input name="dim_w" type="text" size="2" value="<?php echo $args['dim_w']; ?>" /> <?php _e( 'Height' ); ?> <input name="dim_h" type="text" size="2" value="<?php echo $args['dim_h']; ?>" /></td>
|
180 |
-
</tr>
|
181 |
-
<tr>
|
182 |
-
<th scope="row"><?php _e( 'Font color of characters', 'wp-members' ); ?></th>
|
183 |
-
<td>R:<input name="font_color_r" type="text" size="2" value="<?php echo $font_color[0]; ?>" /> G:<input name="font_color_g" type="text" size="2" value="<?php echo $font_color[1]; ?>" /> B:<input name="font_color_b" type="text" size="2" value="<?php echo $font_color[2]; ?>" /></td>
|
184 |
-
</tr>
|
185 |
-
<tr>
|
186 |
-
<th scope="row"><?php _e( 'Background color of image', 'wp-members' ); ?></th>
|
187 |
-
<td>R:<input name="bg_color_r" type="text" size="2" value="<?php echo $bg_color[0]; ?>" /> G:<input name="bg_color_g" type="text" size="2" value="<?php echo $bg_color[1]; ?>" /> B:<input name="bg_color_b" type="text" size="2" value="<?php echo $bg_color[2]; ?>" /></td>
|
188 |
-
</tr>
|
189 |
-
<tr>
|
190 |
-
<th scope="row"><?php _e( 'Font size', 'wp-members' ); ?></th>
|
191 |
-
<td><input name="font_size" type="text" value="<?php echo $args['font_size']; ?>" /></td>
|
192 |
-
</tr>
|
193 |
-
<tr>
|
194 |
-
<th scope="row"><?php _e( 'Width between characters', 'wp-members' ); ?></th>
|
195 |
-
<td><input name="kerning" type="text" value="<?php echo $args['kerning']; ?>" /></td>
|
196 |
-
</tr>
|
197 |
-
<tr>
|
198 |
-
<th scope="row"><?php _e( 'Image type', 'wp-members' ); ?></th>
|
199 |
-
<td><select name="img_type">
|
200 |
-
<option<?php echo ( $args['img_type'] == 'png' ) ? ' selected' : ''; ?>>png</option>
|
201 |
-
<option<?php echo ( $args['img_type'] == 'gif' ) ? ' selected' : ''; ?>>gif</option>
|
202 |
-
<option<?php echo ( $args['img_type'] == 'jpg' ) ? ' selected' : ''; ?>>jpg</option>
|
203 |
-
</select>
|
204 |
-
</td>
|
205 |
-
</tr><?php
|
206 |
-
|
207 |
-
} else {
|
208 |
-
|
209 |
-
$show_update_button =
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
<p><?php _e(
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
case
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<
|
238 |
-
|
239 |
-
<input type="hidden" name="
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
*
|
257 |
-
*
|
258 |
-
* @since
|
259 |
-
*
|
260 |
-
*
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
$
|
271 |
-
$
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
$updated_captcha_type
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
'
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
$settings['hcaptcha']['
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
$
|
304 |
-
$
|
305 |
-
|
306 |
-
'
|
307 |
-
'
|
308 |
-
'
|
309 |
-
'
|
310 |
-
'
|
311 |
-
'
|
312 |
-
'
|
313 |
-
'
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
320 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Admin Functions
|
4 |
+
*
|
5 |
+
* Functions to manage the captcha tab.
|
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-2021 Chad Butler
|
10 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
+
*
|
12 |
+
* @package WP-Members
|
13 |
+
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
+
*/
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit();
|
20 |
+
}
|
21 |
+
|
22 |
+
class WP_Members_Admin_Tab_Captcha {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Creates the captcha tab.
|
26 |
+
*
|
27 |
+
* @since 2.8.0
|
28 |
+
* @since 3.3.0 Ported to do_tab().
|
29 |
+
*
|
30 |
+
* @param string $tab The admin tab being displayed.
|
31 |
+
* @return string|bool The captcha options tab, otherwise false.
|
32 |
+
*/
|
33 |
+
public static function do_tab( $tab ) {
|
34 |
+
if ( $tab == 'captcha' ) {
|
35 |
+
return self::build_settings();
|
36 |
+
} else {
|
37 |
+
return false;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Adds the captcha tab.
|
43 |
+
*
|
44 |
+
* @since 2.8.0
|
45 |
+
* @since 3.3.0 Ported wpmem_add_captcha_tab() to add_tab().
|
46 |
+
*
|
47 |
+
* @param array $tabs The array of tabs for the admin panel.
|
48 |
+
* @return array The updated array of tabs for the admin panel.
|
49 |
+
*/
|
50 |
+
public static function add_tab( $tabs ) {
|
51 |
+
return array_merge( $tabs, array( 'captcha' => 'Captcha' ) );
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Builds the captcha options.
|
56 |
+
*
|
57 |
+
* @since 2.4.0
|
58 |
+
* @since 3.3.0 Ported wpmem_a_build_captcha_options() to build_settings().
|
59 |
+
*/
|
60 |
+
public static function build_settings() {
|
61 |
+
|
62 |
+
// Global settings.
|
63 |
+
global $wpmem, $updated_captcha_type;
|
64 |
+
|
65 |
+
$wpmem_captcha = get_option( 'wpmembers_captcha' );
|
66 |
+
$url = home_url();
|
67 |
+
$help_link = sprintf( __( 'See the %sUsers Guide on CAPTCHA%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/docs/registration/using-captcha/" target="_blank">', '</a>' );
|
68 |
+
?>
|
69 |
+
<div class="metabox-holder has-right-sidebar">
|
70 |
+
|
71 |
+
<div class="inner-sidebar">
|
72 |
+
<?php wpmem_a_meta_box(); ?>
|
73 |
+
<div class="postbox">
|
74 |
+
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
75 |
+
<div class="inside">
|
76 |
+
<strong><i><?php echo $help_link; ?></i></strong>
|
77 |
+
</div>
|
78 |
+
</div>
|
79 |
+
</div> <!-- .inner-sidebar -->
|
80 |
+
|
81 |
+
<div id="post-body">
|
82 |
+
<div id="post-body-content">
|
83 |
+
<div class="postbox">
|
84 |
+
|
85 |
+
<h3><?php _e( 'Manage CAPTCHA Options', 'wp-members' ); ?></h3>
|
86 |
+
<div class="inside">
|
87 |
+
<form name="updatecaptchaform" id="updatecaptchaform" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
|
88 |
+
<?php wp_nonce_field( 'wpmem-update-captcha' ); ?>
|
89 |
+
<table class="form-table">
|
90 |
+
<tr valign="top">
|
91 |
+
<th><?php _e( 'CAPTCHA Type', 'wp-members' ); ?></th>
|
92 |
+
<td><?php
|
93 |
+
if ( 1 == $wpmem->captcha ) {
|
94 |
+
$wpmem->captcha = 3; // reCAPTCHA v1 is fully obsolete. Change it to v2.
|
95 |
+
}
|
96 |
+
$captcha[] = __( 'reCAPTCHA v2', 'wp-members' ) . '|3';
|
97 |
+
$captcha[] = __( 'reCAPTCHA v3', 'wp-members' ) . '|4';
|
98 |
+
$captcha[] = __( 'Really Simple CAPTCHA', 'wp-members' ) . '|2';
|
99 |
+
$captcha[] = __( 'hCaptcha', 'wp-members' ) . '|5';
|
100 |
+
echo wpmem_form_field( 'wpmem_settings_captcha', 'select', $captcha, $wpmem->captcha ); ?>
|
101 |
+
</td>
|
102 |
+
</tr>
|
103 |
+
<?php if ( isset( $updated_captcha_type ) ) { ?>
|
104 |
+
<tr>
|
105 |
+
<td colspan="2">
|
106 |
+
<p><?php _e( 'CAPTCHA type was changed. Please verify and update the settings below for the new CAPTCHA type.', 'wp-members' ); ?></p>
|
107 |
+
</td>
|
108 |
+
</tr>
|
109 |
+
<?php } ?>
|
110 |
+
<?php // if reCAPTCHA is enabled...
|
111 |
+
if ( 3 == $wpmem->captcha || 4 == $wpmem->captcha ) {
|
112 |
+
$show_update_button = true;
|
113 |
+
$private_key = ( isset( $wpmem_captcha['recaptcha'] ) ) ? $wpmem_captcha['recaptcha']['private'] : '';
|
114 |
+
$public_key = ( isset( $wpmem_captcha['recaptcha'] ) ) ? $wpmem_captcha['recaptcha']['public'] : '';
|
115 |
+
?>
|
116 |
+
<tr valign="top">
|
117 |
+
<th scope="row"><?php _e( 'reCAPTCHA Keys', 'wp-members' ); ?></th>
|
118 |
+
<td>
|
119 |
+
<p><?php if ( '' == $wpmem_captcha['recaptcha']['private'] || '' == $wpmem_captcha['recaptcha']['public'] ) {
|
120 |
+
printf( __( 'reCAPTCHA requires an API key, consisting of a "site" and a "secret" key. You can sign up for a %s free reCAPTCHA key%s', 'wp-members' ), "<a href=\"https://www.google.com/recaptcha/admin#whyrecaptcha\" target=\"_blank\">", '</a>' );
|
121 |
+
} ?></p>
|
122 |
+
<p><label><?php _e( 'Site Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_publickey" size="60" value="<?php echo $public_key; ?>" /></p>
|
123 |
+
<p><label><?php _e( 'Secret Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_privatekey" size="60" value="<?php echo $private_key; ?>" /></p>
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
<?php
|
127 |
+
} elseif ( 5 == $wpmem->captcha ) {
|
128 |
+
$show_update_button = true;
|
129 |
+
$private_key = ( isset( $wpmem_captcha['hcaptcha'] ) ) ? $wpmem_captcha['hcaptcha']['secret'] : '';
|
130 |
+
$public_key = ( isset( $wpmem_captcha['hcaptcha'] ) ) ? $wpmem_captcha['hcaptcha']['api_key'] : '';
|
131 |
+
?>
|
132 |
+
<tr valign="top">
|
133 |
+
<th scope="row"><?php _e( 'hCaptcha Keys', 'wp-members' ); ?></th>
|
134 |
+
<td>
|
135 |
+
<p><?php if ( '' == $private_key || '' == $public_key ) {
|
136 |
+
printf( __( 'hCaptcha requires an API key. You can sign up for %s an hCaptcha API key here %s', 'wp-members' ), "<a href=\"https://hcaptcha.com/\" target=\"_blank\">", '</a>' );
|
137 |
+
} ?></p>
|
138 |
+
<p><label><?php _e( 'API Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_publickey" size="60" value="<?php echo $public_key; ?>" /></p>
|
139 |
+
<p><label><?php _e( 'Secret Key', 'wp-members' ); ?>:</label><br /><input type="text" name="wpmem_captcha_privatekey" size="60" value="<?php echo $private_key; ?>" /></p>
|
140 |
+
</td>
|
141 |
+
</tr>
|
142 |
+
<?php
|
143 |
+
// If Really Simple CAPTCHA is enabled.
|
144 |
+
} elseif ( $wpmem->captcha == 2 ) {
|
145 |
+
|
146 |
+
// Setup defaults.
|
147 |
+
$defaults = array(
|
148 |
+
'characters' => 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789',
|
149 |
+
'num_char' => '4',
|
150 |
+
'dim_w' => '72',
|
151 |
+
'dim_h' => '30',
|
152 |
+
'font_color' => '0,0,0',
|
153 |
+
'bg_color' => '255,255,255',
|
154 |
+
'font_size' => '12',
|
155 |
+
'kerning' => '14',
|
156 |
+
'img_type' => 'png',
|
157 |
+
);
|
158 |
+
|
159 |
+
$args = ( isset( $wpmem_captcha['really_simple'] ) && is_array( $wpmem_captcha['really_simple'] ) ) ? $wpmem_captcha['really_simple'] : array();
|
160 |
+
|
161 |
+
$args = wp_parse_args( $args, $defaults );
|
162 |
+
|
163 |
+
// Explode colors.
|
164 |
+
$font_color = explode( ',', $args['font_color'] );
|
165 |
+
$bg_color = explode( ',', $args['bg_color'] );
|
166 |
+
|
167 |
+
$show_update_button = true;
|
168 |
+
if ( is_plugin_active( 'really-simple-captcha/really-simple-captcha.php' ) ) { ?>
|
169 |
+
<tr>
|
170 |
+
<th scope="row"><?php _e( 'Characters for image', 'wp-members' ); ?></th>
|
171 |
+
<td><input name="characters" type="text" size="34" value="<?php echo $args['characters']; ?>" /></td>
|
172 |
+
</tr>
|
173 |
+
<tr>
|
174 |
+
<th scope="row"><?php _e( 'Number of characters', 'wp-members' ); ?></th>
|
175 |
+
<td><input name="num_char" type="text" size="2" value="<?php echo $args['num_char']; ?>" /></td>
|
176 |
+
</tr>
|
177 |
+
<tr>
|
178 |
+
<th scope="row"><?php _e( 'Image dimensions', 'wp-members' ); ?></th>
|
179 |
+
<td><?php _e( 'Width' ); ?> <input name="dim_w" type="text" size="2" value="<?php echo $args['dim_w']; ?>" /> <?php _e( 'Height' ); ?> <input name="dim_h" type="text" size="2" value="<?php echo $args['dim_h']; ?>" /></td>
|
180 |
+
</tr>
|
181 |
+
<tr>
|
182 |
+
<th scope="row"><?php _e( 'Font color of characters', 'wp-members' ); ?></th>
|
183 |
+
<td>R:<input name="font_color_r" type="text" size="2" value="<?php echo $font_color[0]; ?>" /> G:<input name="font_color_g" type="text" size="2" value="<?php echo $font_color[1]; ?>" /> B:<input name="font_color_b" type="text" size="2" value="<?php echo $font_color[2]; ?>" /></td>
|
184 |
+
</tr>
|
185 |
+
<tr>
|
186 |
+
<th scope="row"><?php _e( 'Background color of image', 'wp-members' ); ?></th>
|
187 |
+
<td>R:<input name="bg_color_r" type="text" size="2" value="<?php echo $bg_color[0]; ?>" /> G:<input name="bg_color_g" type="text" size="2" value="<?php echo $bg_color[1]; ?>" /> B:<input name="bg_color_b" type="text" size="2" value="<?php echo $bg_color[2]; ?>" /></td>
|
188 |
+
</tr>
|
189 |
+
<tr>
|
190 |
+
<th scope="row"><?php _e( 'Font size', 'wp-members' ); ?></th>
|
191 |
+
<td><input name="font_size" type="text" value="<?php echo $args['font_size']; ?>" /></td>
|
192 |
+
</tr>
|
193 |
+
<tr>
|
194 |
+
<th scope="row"><?php _e( 'Width between characters', 'wp-members' ); ?></th>
|
195 |
+
<td><input name="kerning" type="text" value="<?php echo $args['kerning']; ?>" /></td>
|
196 |
+
</tr>
|
197 |
+
<tr>
|
198 |
+
<th scope="row"><?php _e( 'Image type', 'wp-members' ); ?></th>
|
199 |
+
<td><select name="img_type">
|
200 |
+
<option<?php echo ( $args['img_type'] == 'png' ) ? ' selected' : ''; ?>>png</option>
|
201 |
+
<option<?php echo ( $args['img_type'] == 'gif' ) ? ' selected' : ''; ?>>gif</option>
|
202 |
+
<option<?php echo ( $args['img_type'] == 'jpg' ) ? ' selected' : ''; ?>>jpg</option>
|
203 |
+
</select>
|
204 |
+
</td>
|
205 |
+
</tr><?php
|
206 |
+
|
207 |
+
} else {
|
208 |
+
|
209 |
+
$show_update_button = true; // @todo Fixes whether the update button shows or not.
|
210 |
+
// Could remove that logic altogether? ?>
|
211 |
+
<tr>
|
212 |
+
<td colspan="2">
|
213 |
+
<p><?php _e( 'To use Really Simple CAPTCHA, you must have the Really Simple CAPTCHA plugin installed and activated.', 'wp-members' ); ?></p>
|
214 |
+
<p><?php _e( sprintf( 'You can download Really Simple CAPTCHA from the %swordpress.org plugin repository%s.', '<a href="http://wordpress.org/plugins/really-simple-captcha/">', '</a>' ), 'wp-members' ); ?></p>
|
215 |
+
</td>
|
216 |
+
</tr><?php
|
217 |
+
}
|
218 |
+
} // End if RSC is selected.
|
219 |
+
if ( $show_update_button ) {
|
220 |
+
|
221 |
+
switch ( $wpmem->captcha ) {
|
222 |
+
case 1:
|
223 |
+
$captcha_type = 'recaptcha';
|
224 |
+
break;
|
225 |
+
case 2:
|
226 |
+
$captcha_type = 'really_simple';
|
227 |
+
break;
|
228 |
+
case 3:
|
229 |
+
case 4:
|
230 |
+
$captcha_type = 'recaptcha2';
|
231 |
+
break;
|
232 |
+
case 5:
|
233 |
+
$captcha_type = 'hcaptcha';
|
234 |
+
break;
|
235 |
+
} ?>
|
236 |
+
<tr valign="top">
|
237 |
+
<th scope="row"> </th>
|
238 |
+
<td>
|
239 |
+
<input type="hidden" name="wpmem_recaptcha_type" value="<?php echo $captcha_type ?>" />
|
240 |
+
<input type="hidden" name="wpmem_admin_a" value="update_captcha" />
|
241 |
+
<?php submit_button( __( 'Update CAPTCHA Settings', 'wp-members' ) ); ?>
|
242 |
+
</td>
|
243 |
+
</tr>
|
244 |
+
<?php } ?>
|
245 |
+
</table>
|
246 |
+
</form>
|
247 |
+
</div><!-- .inside -->
|
248 |
+
</div>
|
249 |
+
</div><!-- #post-body-content -->
|
250 |
+
</div><!-- #post-body -->
|
251 |
+
</div><!-- .metabox-holder -->
|
252 |
+
<?php
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Updates the captcha options.
|
257 |
+
*
|
258 |
+
* @since 2.8
|
259 |
+
* @since 3.3.0 Ported wpmem_update_captcha() to update().
|
260 |
+
*
|
261 |
+
* @return string The captcha option update message.
|
262 |
+
*/
|
263 |
+
public static function update() {
|
264 |
+
|
265 |
+
global $wpmem;
|
266 |
+
|
267 |
+
// Check nonce.
|
268 |
+
check_admin_referer( 'wpmem-update-captcha' );
|
269 |
+
|
270 |
+
$settings = get_option( 'wpmembers_captcha' );
|
271 |
+
$update_type = sanitize_text_field( wpmem_get( 'wpmem_recaptcha_type', '' ) );
|
272 |
+
$which = intval( wpmem_get( 'wpmem_settings_captcha', 0 ) );
|
273 |
+
|
274 |
+
// If there are no current settings.
|
275 |
+
if ( ! $settings ) {
|
276 |
+
$settings = array();
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( 0 != $which && $wpmem->captcha != $which ) {
|
280 |
+
// Changing captcha type.
|
281 |
+
global $updated_captcha_type;
|
282 |
+
$updated_captcha_type = true;
|
283 |
+
$wpmem->captcha = $which;
|
284 |
+
wpmem_update_option( 'wpmembers_settings', 'captcha', $which );
|
285 |
+
}
|
286 |
+
|
287 |
+
if ( $update_type == 'recaptcha' || $update_type == 'recaptcha2' ) {
|
288 |
+
$settings['recaptcha'] = array(
|
289 |
+
'public' => sanitize_text_field( wpmem_get( 'wpmem_captcha_publickey', '' ) ),
|
290 |
+
'private' => sanitize_text_field( wpmem_get( 'wpmem_captcha_privatekey', '' ) ),
|
291 |
+
);
|
292 |
+
if ( 'recaptcha' == wpmem_get( 'wpmem_captcha_theme', false ) ) {
|
293 |
+
$settings['recaptcha']['theme'] = sanitize_text_field( wpmem_get( 'wpmem_captcha_theme', '' ) );
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
if ( 'hcaptcha' == $update_type ) {
|
298 |
+
$settings['hcaptcha']['api_key'] = sanitize_text_field( wpmem_get( 'wpmem_captcha_publickey', '' ) );
|
299 |
+
$settings['hcaptcha']['secret'] = sanitize_text_field( wpmem_get( 'wpmem_captcha_privatekey', '' ) );
|
300 |
+
}
|
301 |
+
|
302 |
+
if ( $update_type == 'really_simple' ) {
|
303 |
+
$font_color = sanitize_text_field( wpmem_get( 'font_color_r', '' ) ) . ',' . sanitize_text_field( wpmem_get( 'font_color_g', '' ) ) . ',' . sanitize_text_field( wpmem_get( 'font_color_b', '' ) );
|
304 |
+
$bg_color = sanitize_text_field( wpmem_get( 'bg_color_r', '' ) ) . ',' . sanitize_text_field( wpmem_get( 'bg_color_g', '' ) ) . ',' . sanitize_text_field( wpmem_get( 'bg_color_b', '' ) );
|
305 |
+
$settings['really_simple'] = array(
|
306 |
+
'characters' => sanitize_text_field( wpmem_get( 'characters', '' ) ),
|
307 |
+
'num_char' => sanitize_text_field( wpmem_get( 'num_char', '' ) ),
|
308 |
+
'dim_w' => sanitize_text_field( wpmem_get( 'dim_w', '' ) ),
|
309 |
+
'dim_h' => sanitize_text_field( wpmem_get( 'dim_h', '' ) ),
|
310 |
+
'font_color' => $font_color,
|
311 |
+
'bg_color' => $bg_color,
|
312 |
+
'font_size' => sanitize_text_field( wpmem_get( 'font_size', '' ) ),
|
313 |
+
'kerning' => sanitize_text_field( wpmem_get( 'kerning', '' ) ),
|
314 |
+
'img_type' => sanitize_text_field( wpmem_get( 'img_type', '' ) ),
|
315 |
+
);
|
316 |
+
}
|
317 |
+
|
318 |
+
update_option( 'wpmembers_captcha', $settings );
|
319 |
+
return __( 'CAPTCHA was updated for WP-Members', 'wp-members' );
|
320 |
+
}
|
321 |
}
|
@@ -6,12 +6,12 @@
|
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
-
* Copyright (c) 2006-
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
@@ -56,7 +56,7 @@ class WP_Members_Admin_Tab_Dialogs {
|
|
56 |
<div class="postbox">
|
57 |
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
58 |
<div class="inside">
|
59 |
-
<strong><i>See the <a href="https://rocketgeek.com/plugins/wp-members/
|
60 |
</div>
|
61 |
</div>
|
62 |
</div> <!-- .inner-sidebar -->
|
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-2021 Chad Butler
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
56 |
<div class="postbox">
|
57 |
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
58 |
<div class="inside">
|
59 |
+
<strong><i>See the <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/dialogs/" target="_blank">Users Guide on dialogs</a>.</i></strong>
|
60 |
</div>
|
61 |
</div>
|
62 |
</div> <!-- .inner-sidebar -->
|
@@ -6,12 +6,12 @@
|
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
-
* Copyright (c) 2006-
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
+
* Copyright (c) 2006-2021 Chad Butler
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
@@ -6,12 +6,12 @@
|
|
6 |
*
|
7 |
* This file is part of the WP-Members plugin by Chad Butler
|
8 |
* You can find out more about this plugin at https://rocketgeek.com
|
9 |
-
* Copyright (c) 2006-
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
@@ -58,7 +58,7 @@ class WP_Members_Admin_Tab_Emails {
|
|
58 |
<div class="inside">
|
59 |
<p>
|
60 |
<?php _e( 'You can customize the content of the emails sent by the plugin.', 'wp-members' ); ?><br />
|
61 |
-
<a href="https://rocketgeek.com/plugins/wp-members/
|
62 |
<?php _e( 'A list of shortcodes is available here.', 'wp-members' ); ?></a>
|
63 |
</p>
|
64 |
<hr />
|
@@ -73,16 +73,25 @@ class WP_Members_Admin_Tab_Emails {
|
|
73 |
<th scope="row"><?php _e( 'Set a custom email name', 'wp-members' ); ?></th>
|
74 |
<td><input type="text" name="wp_mail_from_name" size="40" value="<?php echo esc_attr( stripslashes( $wpmem->email->from_name ) ); ?>" /> <span class="description"><?php _e( '(optional)', 'wp-members' ); ?> John Smith</span></td>
|
75 |
</tr>
|
|
|
|
|
|
|
|
|
76 |
<tr><td colspan="2"><hr /></td></tr>
|
77 |
-
<?php
|
|
|
78 |
foreach( $wpmem->admin->emails as $email ) {
|
79 |
-
|
80 |
}
|
81 |
}
|
82 |
-
$arr = get_option( 'wpmembers_email_footer' );
|
|
|
|
|
|
|
|
|
83 |
<tr valign="top">
|
84 |
<th scope="row"><strong><?php echo __( "Email Signature", 'wp-members' ); ?></strong> <span class="description"><?php _e( '(optional)', 'wp-members' ); ?></span></th>
|
85 |
-
<td
|
86 |
</tr>
|
87 |
<tr><td colspan="2"><hr /></td></tr>
|
88 |
<tr valign="top">
|
@@ -99,7 +108,7 @@ class WP_Members_Admin_Tab_Emails {
|
|
99 |
<div class="postbox">
|
100 |
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
101 |
<div class="inside">
|
102 |
-
<strong><i>See the <a href="https://rocketgeek.com/plugins/wp-members/
|
103 |
</div>
|
104 |
</div>
|
105 |
</div> <!-- #post-body-content -->
|
@@ -126,11 +135,13 @@ class WP_Members_Admin_Tab_Emails {
|
|
126 |
check_admin_referer( 'wpmem-update-emails' );
|
127 |
|
128 |
// Update the email address (if applicable).
|
129 |
-
if ( $wpmem->email->from != $_POST['wp_mail_from'] || $wpmem->email->from_name != $_POST['wp_mail_from_name'] ) {
|
130 |
$wpmem->email->from = sanitize_email( $_POST['wp_mail_from'] );
|
131 |
$wpmem->email->from_name = sanitize_text_field( $_POST['wp_mail_from_name'] );
|
|
|
132 |
update_option( 'wpmembers_email_wpfrom', $wpmem->email->from );
|
133 |
update_option( 'wpmembers_email_wpname', $wpmem->email->from_name );
|
|
|
134 |
}
|
135 |
|
136 |
// Update the various emails being used.
|
@@ -154,7 +165,7 @@ class WP_Members_Admin_Tab_Emails {
|
|
154 |
|
155 |
if ( ! empty ( $wpmem->admin->emails ) ) {
|
156 |
foreach( $wpmem->admin->emails as $email ) {
|
157 |
-
|
158 |
}
|
159 |
}
|
160 |
|
@@ -162,4 +173,57 @@ class WP_Members_Admin_Tab_Emails {
|
|
162 |
|
163 |
}
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
} // End of file.
|
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-2021 Chad Butler
|
10 |
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
*
|
12 |
* @package WP-Members
|
13 |
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
*/
|
16 |
|
17 |
// Exit if accessed directly.
|
58 |
<div class="inside">
|
59 |
<p>
|
60 |
<?php _e( 'You can customize the content of the emails sent by the plugin.', 'wp-members' ); ?><br />
|
61 |
+
<a href="https://rocketgeek.com/plugins/wp-members/docs/customizing-emails/" target="_blank">
|
62 |
<?php _e( 'A list of shortcodes is available here.', 'wp-members' ); ?></a>
|
63 |
</p>
|
64 |
<hr />
|
73 |
<th scope="row"><?php _e( 'Set a custom email name', 'wp-members' ); ?></th>
|
74 |
<td><input type="text" name="wp_mail_from_name" size="40" value="<?php echo esc_attr( stripslashes( $wpmem->email->from_name ) ); ?>" /> <span class="description"><?php _e( '(optional)', 'wp-members' ); ?> John Smith</span></td>
|
75 |
</tr>
|
76 |
+
<tr valign="top">
|
77 |
+
<th scope="row"><?php _e( 'Send HTML email', 'wp-members' ); ?></th>
|
78 |
+
<td><input type="checkbox" name="wpmem_email_html" value="1" <?php checked( $wpmem->email->html, 1, true ); ?> /></td>
|
79 |
+
</tr>
|
80 |
<tr><td colspan="2"><hr /></td></tr>
|
81 |
+
<?php // Here is where we handle all emails, both standard and custom.
|
82 |
+
if ( ! empty ( $wpmem->admin->emails ) ) {
|
83 |
foreach( $wpmem->admin->emails as $email ) {
|
84 |
+
self::do_email_input( $email );
|
85 |
}
|
86 |
}
|
87 |
+
$arr = get_option( 'wpmembers_email_footer' );
|
88 |
+
$footer_args = array(
|
89 |
+
'body_input' => 'wpmembers_email_footer_body',
|
90 |
+
'body_value' => $arr,
|
91 |
+
); ?>
|
92 |
<tr valign="top">
|
93 |
<th scope="row"><strong><?php echo __( "Email Signature", 'wp-members' ); ?></strong> <span class="description"><?php _e( '(optional)', 'wp-members' ); ?></span></th>
|
94 |
+
<td><?php self::do_email_editor( $footer_args ); ?></td>
|
95 |
</tr>
|
96 |
<tr><td colspan="2"><hr /></td></tr>
|
97 |
<tr valign="top">
|
108 |
<div class="postbox">
|
109 |
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
110 |
<div class="inside">
|
111 |
+
<strong><i>See the <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/emails/" target="_blank">Users Guide on email options</a>.</i></strong>
|
112 |
</div>
|
113 |
</div>
|
114 |
</div> <!-- #post-body-content -->
|
135 |
check_admin_referer( 'wpmem-update-emails' );
|
136 |
|
137 |
// Update the email address (if applicable).
|
138 |
+
if ( $wpmem->email->from != $_POST['wp_mail_from'] || $wpmem->email->from_name != $_POST['wp_mail_from_name'] || $wpmem->email->html != wpmem_get( 'wpmem_email_html', 0 ) ) {
|
139 |
$wpmem->email->from = sanitize_email( $_POST['wp_mail_from'] );
|
140 |
$wpmem->email->from_name = sanitize_text_field( $_POST['wp_mail_from_name'] );
|
141 |
+
$wpmem->email->html = intval( wpmem_get( 'wpmem_email_html', 0 ) );
|
142 |
update_option( 'wpmembers_email_wpfrom', $wpmem->email->from );
|
143 |
update_option( 'wpmembers_email_wpname', $wpmem->email->from_name );
|
144 |
+
update_option( 'wpmembers_email_html', $wpmem->email->html );
|
145 |
}
|
146 |
|
147 |
// Update the various emails being used.
|
165 |
|
166 |
if ( ! empty ( $wpmem->admin->emails ) ) {
|
167 |
foreach( $wpmem->admin->emails as $email ) {
|
168 |
+
self::email_update( $email );
|
169 |
}
|
170 |
}
|
171 |
|
173 |
|
174 |
}
|
175 |
|
176 |
+
/**
|
177 |
+
* Adds custom email dialog to the Emails tab.
|
178 |
+
*
|
179 |
+
* @since 3.1.0
|
180 |
+
* @since 3.4.0 Moved to emails tab class.
|
181 |
+
*
|
182 |
+
* @param array $args Settings array for the email.
|
183 |
+
*/
|
184 |
+
static private function do_email_input( $args ) { ?>
|
185 |
+
<tr valign="top"><td colspan="2"><strong><?php echo esc_html( $args['heading'] ); ?></strong></td></tr>
|
186 |
+
<tr valign="top">
|
187 |
+
<th scope="row"><?php echo esc_html( $args['subject_label'] ); ?></th>
|
188 |
+
<td><input type="text" name="<?php echo esc_attr( $args['subject_input'] ); ?>" size="80" value="<?php echo esc_attr( wp_unslash( $args['subject_value'] ) ); ?>"></td>
|
189 |
+
</tr>
|
190 |
+
<tr valign="top">
|
191 |
+
<th scope="row"><?php echo esc_html( $args['body_label'] ); ?></th>
|
192 |
+
<td><?php self::do_email_editor( $args ); ?></td>
|
193 |
+
</tr>
|
194 |
+
<tr><td colspan="2"><hr /></td></tr><?php
|
195 |
+
}
|
196 |
+
|
197 |
+
static private function do_email_editor( $args ) {
|
198 |
+
global $wpmem;
|
199 |
+
if ( 1 == $wpmem->email->html ) {
|
200 |
+
$editor_args = array(
|
201 |
+
'media_buttons' => false,
|
202 |
+
'textarea_rows' => 10,
|
203 |
+
);
|
204 |
+
wp_editor( $args['body_value'], esc_attr( $args['body_input'] ), $editor_args );
|
205 |
+
} else { ?>
|
206 |
+
<textarea name="<?php echo esc_attr( $args['body_input'] ); ?>" rows="12" cols="50" id="" class="large-text code"><?php echo esc_textarea( wp_unslash( $args['body_value'] ) ); ?></textarea>
|
207 |
+
<?php }
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Saves custom email settings.
|
212 |
+
*
|
213 |
+
* @since 3.1.0
|
214 |
+
* @since 3.4.0 Moved to emails tab class.
|
215 |
+
*
|
216 |
+
* @param array $args Settings array for the email.
|
217 |
+
*/
|
218 |
+
static private function email_update( $args ) {
|
219 |
+
global $wpmem;
|
220 |
+
$settings = array(
|
221 |
+
'subj' => sanitize_text_field( wpmem_get( $args['subject_input'] ) ),
|
222 |
+
'body' => wp_kses( wpmem_get( $args['body_input'] ), 'post' ),
|
223 |
+
);
|
224 |
+
update_option( $args['name'], $settings, true );
|
225 |
+
$wpmem->admin->emails[ $args['name'] ]['subject_value'] = $settings['subj'];
|
226 |
+
$wpmem->admin->emails[ $args['name'] ]['body_value'] = $settings['body'];
|
227 |
+
return;
|
228 |
+
}
|
229 |
} // End of file.
|
@@ -1,763 +1,774 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members Admin Functions
|
4 |
-
*
|
5 |
-
* Functions to manage the fields tab.
|
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-
|
10 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
-
*
|
12 |
-
* @package WP-Members
|
13 |
-
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
-
*/
|
16 |
-
|
17 |
-
// Exit if accessed directly.
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit();
|
20 |
-
}
|
21 |
-
|
22 |
-
class WP_Members_Admin_Tab_Fields {
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Creates the fields tab.
|
26 |
-
*
|
27 |
-
* @since 3.0.1
|
28 |
-
* @since 3.3.0 Renamed wpmem_a_fields_tab() to do_tab().
|
29 |
-
*
|
30 |
-
* @param string $tab The admin tab being displayed.
|
31 |
-
* @return string|bool The fields tab, otherwise false.
|
32 |
-
*/
|
33 |
-
public static function do_tab( $tab ) {
|
34 |
-
if ( $tab == 'fields' ) {
|
35 |
-
// Render the fields tab.
|
36 |
-
WP_Members_Admin_Tab_Fields::build_settings();
|
37 |
-
return;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Scripts needed for the fields tab.
|
43 |
-
*
|
44 |
-
* @since 3.1.8
|
45 |
-
* @sinec 3.3.0 Renamed wpmem_a_fields_tab_scripts() to enqueue_scripts
|
46 |
-
*/
|
47 |
-
public static function enqueue_scripts() {
|
48 |
-
wp_enqueue_script( 'jquery-ui-sortable' );
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Function to write the field edit link.
|
53 |
-
*
|
54 |
-
* @since 2.8
|
55 |
-
* @since 3.3.0 Renamed wpmem_fields_edit_link() to do_edit_link();
|
56 |
-
*
|
57 |
-
* @param string $field_id The option name of the field to be edited
|
58 |
-
*/
|
59 |
-
public static function do_edit_link( $field_id ) {
|
60 |
-
$link_args = array(
|
61 |
-
'page' => 'wpmem-settings',
|
62 |
-
'tab' => 'fields',
|
63 |
-
'mode' => 'edit',
|
64 |
-
'edit' => 'field',
|
65 |
-
'field' => $field_id,
|
66 |
-
);
|
67 |
-
$link = add_query_arg( $link_args, admin_url( 'options-general.php' ) );
|
68 |
-
return '<a href="' . $link . '">' . __( 'Edit' ) . '</a>';
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Renders the content of the fields tab.
|
73 |
-
*
|
74 |
-
* @since 3.1.8
|
75 |
-
* @since 3.3.0 Renamed from wpmem_a_render_fields_tab() to build_settings().
|
76 |
-
*
|
77 |
-
* @global object $wpmem The WP_Members Object.
|
78 |
-
* @global string $did_update
|
79 |
-
* @global string $delete_action
|
80 |
-
*/
|
81 |
-
public static function build_settings() {
|
82 |
-
|
83 |
-
global $wpmem, $did_update, $delete_action;
|
84 |
-
$wpmem_fields = wpmem_fields();
|
85 |
-
$edit_meta = sanitize_text_field( wpmem_get( 'field', false, 'get' ) );
|
86 |
-
$add_meta = sanitize_text_field( wpmem_get( 'add_field', false ) );
|
87 |
-
|
88 |
-
if ( 'delete' == $delete_action ) {
|
89 |
-
|
90 |
-
$delete_fields = wpmem_get( 'delete' )
|
91 |
-
|
92 |
-
<?php if ( empty( $delete_fields ) ) { ?>
|
93 |
-
<p><?php _e( 'No fields selected for deletion', 'wp-members' ); ?></p>
|
94 |
-
<?php } else { ?>
|
95 |
-
<p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p>
|
96 |
-
<?php foreach ( $delete_fields as $meta ) {
|
97 |
-
$meta = esc_html( $meta );
|
98 |
-
echo esc_html( $wpmem->fields[ $meta ]['label'] ) . ' (meta key: ' . $meta . ')<br />';
|
99 |
-
} ?>
|
100 |
-
<form name="<?php echo esc_attr( $delete_action ); ?>" id="<?php echo esc_attr( $delete_action ); ?>" method="post" action="<?php echo esc_url( wpmem_admin_form_post_url() ); ?>">
|
101 |
-
<?php wp_nonce_field( 'wpmem-confirm-delete' ); ?>
|
102 |
-
<input type="hidden" name="delete_fields" value="<?php echo esc_attr( implode( ",", $delete_fields ) ); ?>" />
|
103 |
-
<input type="hidden" name="dodelete" value="delete_confirmed" />
|
104 |
-
<?php submit_button( 'Delete Fields' ); ?>
|
105 |
-
</form><?php
|
106 |
-
}
|
107 |
-
} else {
|
108 |
-
|
109 |
-
if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) {
|
110 |
-
|
111 |
-
check_admin_referer( 'wpmem-confirm-delete' );
|
112 |
-
|
113 |
-
$delete_fields = sanitize_text_field( wpmem_get( 'delete_fields', array() ) );
|
114 |
-
$delete_fields = explode( ",", $delete_fields );
|
115 |
-
$wpmem_new_fields = array();
|
116 |
-
foreach ( $wpmem_fields as $field ) {
|
117 |
-
if ( ! in_array( $field[2], $delete_fields ) ) {
|
118 |
-
$wpmem_new_fields[] = $field;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
update_option( 'wpmembers_fields', $wpmem_new_fields );
|
122 |
-
$did_update = __( 'Fields deleted', 'wp-members' );
|
123 |
-
}
|
124 |
-
|
125 |
-
if ( $did_update ) { ?>
|
126 |
-
<div id="message" class="updated fade"><p><strong><?php echo $did_update; ?></strong></p></div>
|
127 |
-
<?php }
|
128 |
-
if ( $edit_meta || $add_meta ) {
|
129 |
-
$mode = ( $edit_meta ) ? sanitize_text_field( wpmem_get( 'mode', false, 'get' ) ) : 'add';
|
130 |
-
self::build_field_edit( $mode, $wpmem_fields, $edit_meta );
|
131 |
-
} else {
|
132 |
-
self::build_field_table();
|
133 |
-
} ?>
|
134 |
-
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
135 |
-
<div class="inside">
|
136 |
-
<strong><i><a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/fields/" target="_blank"><?php _e( 'Field Manager Documentation', 'wp-members' ); ?></a></i></strong>
|
137 |
-
</div>
|
138 |
-
<?php
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Function to dispay the add/edit field form.
|
144 |
-
*
|
145 |
-
* @since 2.8
|
146 |
-
* @since 3.1.8 Changed name from wpmem_a_field_edit().
|
147 |
-
* @since 3.3.0 Changed name from wpmem_a_render_fields_tab_field_edit() to build_field_edit().
|
148 |
-
*
|
149 |
-
* @global object $wpmem The WP_Members Object.
|
150 |
-
* @param string $mode The mode for the function (edit|add)
|
151 |
-
* @param array|null $wpmem_fields The array of fields
|
152 |
-
* @param string|null $field The field being edited
|
153 |
-
*/
|
154 |
-
public static function build_field_edit( $mode, $wpmem_fields, $meta_key ) {
|
155 |
-
global $wpmem;
|
156 |
-
$fields = wpmem_fields();
|
157 |
-
if ( $mode == 'edit' ) {
|
158 |
-
$field = $fields[ $meta_key ];
|
159 |
-
}
|
160 |
-
|
161 |
-
|
162 |
-
$
|
163 |
-
$
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
<input type="
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
<
|
193 |
-
|
194 |
-
|
195 |
-
<option value="
|
196 |
-
<option value="
|
197 |
-
<option value="
|
198 |
-
<option value="
|
199 |
-
<option value="
|
200 |
-
<option value="
|
201 |
-
<option value="
|
202 |
-
<option value="
|
203 |
-
<option value="
|
204 |
-
<option value="
|
205 |
-
<option value="
|
206 |
-
<option value="
|
207 |
-
<option value="
|
208 |
-
|
209 |
-
<option value="
|
210 |
-
<?php
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
<
|
218 |
-
<?php
|
219 |
-
<
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
<
|
227 |
-
<?php
|
228 |
-
<
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
<?php
|
247 |
-
<?php
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
<?php
|
255 |
-
<?php
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
<?php
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
<?php
|
276 |
-
<?php
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
<?php
|
288 |
-
<?php
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
<?php
|
300 |
-
<?php
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
<li>
|
336 |
-
<label
|
337 |
-
<
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
"
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
<
|
374 |
-
|
375 |
-
|
376 |
-
<?php
|
377 |
-
|
378 |
-
<?php if ( $mode == '
|
379 |
-
<?php
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
$
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
'
|
440 |
-
'
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
'
|
472 |
-
'
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
'
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
$
|
496 |
-
|
497 |
-
$
|
498 |
-
|
499 |
-
echo '
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
*
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
$
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
$
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
$
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
$add_field_err_msg = (
|
618 |
-
|
619 |
-
|
620 |
-
$
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
$
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
$
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
$
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
$arr['
|
655 |
-
}
|
656 |
-
|
657 |
-
if ( '
|
658 |
-
$arr['
|
659 |
-
$arr['
|
660 |
-
}
|
661 |
-
|
662 |
-
if ( $type
|
663 |
-
$
|
664 |
-
$arr[
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
) {
|
673 |
-
|
674 |
-
$
|
675 |
-
|
676 |
-
$
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
}
|
714 |
-
|
715 |
-
|
716 |
-
}
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
// End of file.
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Admin Functions
|
4 |
+
*
|
5 |
+
* Functions to manage the fields tab.
|
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-2021 Chad Butler
|
10 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
+
*
|
12 |
+
* @package WP-Members
|
13 |
+
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
+
*/
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit();
|
20 |
+
}
|
21 |
+
|
22 |
+
class WP_Members_Admin_Tab_Fields {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Creates the fields tab.
|
26 |
+
*
|
27 |
+
* @since 3.0.1
|
28 |
+
* @since 3.3.0 Renamed wpmem_a_fields_tab() to do_tab().
|
29 |
+
*
|
30 |
+
* @param string $tab The admin tab being displayed.
|
31 |
+
* @return string|bool The fields tab, otherwise false.
|
32 |
+
*/
|
33 |
+
public static function do_tab( $tab ) {
|
34 |
+
if ( $tab == 'fields' ) {
|
35 |
+
// Render the fields tab.
|
36 |
+
WP_Members_Admin_Tab_Fields::build_settings();
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Scripts needed for the fields tab.
|
43 |
+
*
|
44 |
+
* @since 3.1.8
|
45 |
+
* @sinec 3.3.0 Renamed wpmem_a_fields_tab_scripts() to enqueue_scripts
|
46 |
+
*/
|
47 |
+
public static function enqueue_scripts() {
|
48 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Function to write the field edit link.
|
53 |
+
*
|
54 |
+
* @since 2.8
|
55 |
+
* @since 3.3.0 Renamed wpmem_fields_edit_link() to do_edit_link();
|
56 |
+
*
|
57 |
+
* @param string $field_id The option name of the field to be edited
|
58 |
+
*/
|
59 |
+
public static function do_edit_link( $field_id ) {
|
60 |
+
$link_args = array(
|
61 |
+
'page' => 'wpmem-settings',
|
62 |
+
'tab' => 'fields',
|
63 |
+
'mode' => 'edit',
|
64 |
+
'edit' => 'field',
|
65 |
+
'field' => $field_id,
|
66 |
+
);
|
67 |
+
$link = add_query_arg( $link_args, admin_url( 'options-general.php' ) );
|
68 |
+
return '<a href="' . $link . '">' . __( 'Edit' ) . '</a>';
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Renders the content of the fields tab.
|
73 |
+
*
|
74 |
+
* @since 3.1.8
|
75 |
+
* @since 3.3.0 Renamed from wpmem_a_render_fields_tab() to build_settings().
|
76 |
+
*
|
77 |
+
* @global object $wpmem The WP_Members Object.
|
78 |
+
* @global string $did_update
|
79 |
+
* @global string $delete_action
|
80 |
+
*/
|
81 |
+
public static function build_settings() {
|
82 |
+
|
83 |
+
global $wpmem, $did_update, $delete_action;
|
84 |
+
$wpmem_fields = wpmem_fields();
|
85 |
+
$edit_meta = sanitize_text_field( wpmem_get( 'field', false, 'get' ) );
|
86 |
+
$add_meta = sanitize_text_field( wpmem_get( 'add_field', false ) );
|
87 |
+
|
88 |
+
if ( 'delete' == $delete_action ) {
|
89 |
+
|
90 |
+
$delete_fields = wpmem_sanitize_array( wpmem_get( 'delete' ) );?>
|
91 |
+
|
92 |
+
<?php if ( empty( $delete_fields ) ) { ?>
|
93 |
+
<p><?php _e( 'No fields selected for deletion', 'wp-members' ); ?></p>
|
94 |
+
<?php } else { ?>
|
95 |
+
<p><?php _e( 'Are you sure you want to delete the following fields?', 'wp-members' ); ?></p>
|
96 |
+
<?php foreach ( $delete_fields as $meta ) {
|
97 |
+
$meta = esc_html( $meta );
|
98 |
+
echo esc_html( $wpmem->fields[ $meta ]['label'] ) . ' (meta key: ' . $meta . ')<br />';
|
99 |
+
} ?>
|
100 |
+
<form name="<?php echo esc_attr( $delete_action ); ?>" id="<?php echo esc_attr( $delete_action ); ?>" method="post" action="<?php echo esc_url( wpmem_admin_form_post_url() ); ?>">
|
101 |
+
<?php wp_nonce_field( 'wpmem-confirm-delete' ); ?>
|
102 |
+
<input type="hidden" name="delete_fields" value="<?php echo esc_attr( implode( ",", $delete_fields ) ); ?>" />
|
103 |
+
<input type="hidden" name="dodelete" value="delete_confirmed" />
|
104 |
+
<?php submit_button( 'Delete Fields' ); ?>
|
105 |
+
</form><?php
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
|
109 |
+
if ( 'delete_confirmed' == wpmem_get( 'dodelete' ) ) {
|
110 |
+
|
111 |
+
check_admin_referer( 'wpmem-confirm-delete' );
|
112 |
+
|
113 |
+
$delete_fields = sanitize_text_field( wpmem_get( 'delete_fields', array() ) );
|
114 |
+
$delete_fields = explode( ",", $delete_fields );
|
115 |
+
$wpmem_new_fields = array();
|
116 |
+
foreach ( $wpmem_fields as $field ) {
|
117 |
+
if ( ! in_array( $field[2], $delete_fields ) ) {
|
118 |
+
$wpmem_new_fields[] = $field;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
update_option( 'wpmembers_fields', $wpmem_new_fields );
|
122 |
+
$did_update = __( 'Fields deleted', 'wp-members' );
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( $did_update ) { ?>
|
126 |
+
<div id="message" class="updated fade"><p><strong><?php echo $did_update; ?></strong></p></div>
|
127 |
+
<?php }
|
128 |
+
if ( $edit_meta || $add_meta ) {
|
129 |
+
$mode = ( $edit_meta ) ? sanitize_text_field( wpmem_get( 'mode', false, 'get' ) ) : 'add';
|
130 |
+
self::build_field_edit( $mode, $wpmem_fields, $edit_meta );
|
131 |
+
} else {
|
132 |
+
self::build_field_table();
|
133 |
+
} ?>
|
134 |
+
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
135 |
+
<div class="inside">
|
136 |
+
<strong><i><a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/fields/" target="_blank"><?php _e( 'Field Manager Documentation', 'wp-members' ); ?></a></i></strong>
|
137 |
+
</div>
|
138 |
+
<?php
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Function to dispay the add/edit field form.
|
144 |
+
*
|
145 |
+
* @since 2.8
|
146 |
+
* @since 3.1.8 Changed name from wpmem_a_field_edit().
|
147 |
+
* @since 3.3.0 Changed name from wpmem_a_render_fields_tab_field_edit() to build_field_edit().
|
148 |
+
*
|
149 |
+
* @global object $wpmem The WP_Members Object.
|
150 |
+
* @param string $mode The mode for the function (edit|add)
|
151 |
+
* @param array|null $wpmem_fields The array of fields
|
152 |
+
* @param string|null $field The field being edited
|
153 |
+
*/
|
154 |
+
public static function build_field_edit( $mode, $wpmem_fields, $meta_key ) {
|
155 |
+
global $wpmem;
|
156 |
+
$fields = wpmem_fields();
|
157 |
+
if ( $mode == 'edit' ) {
|
158 |
+
$field = $fields[ $meta_key ];
|
159 |
+
} else {
|
160 |
+
$field['checkbox_label'] = ''; // fixes unset variable at 308/309 since $field would not be set.
|
161 |
+
}
|
162 |
+
$form_action = ( $mode == 'edit' ) ? 'editfieldform' : 'addfieldform';
|
163 |
+
$span_optional = '<span class="description">' . __( '(optional)', 'wp-members' ) . '</span>';
|
164 |
+
$span_required = '<span class="req">' . __( '(required)', 'wp-members' ) . '</span>';
|
165 |
+
$form_submit = array( 'mode' => $mode );
|
166 |
+
if ( isset( $_GET['field'] ) ) {
|
167 |
+
$form_submit['field'] = $meta_key;
|
168 |
+
} ?>
|
169 |
+
<h3 class="title"><?php ( $mode == 'edit' ) ? _e( 'Edit Field', 'wp-members' ) : _e( 'Add a Field', 'wp-members' ); ?></h3>
|
170 |
+
<form name="<?php echo $form_action; ?>" id="<?php echo $form_action; ?>" method="post" action="<?php echo wpmem_admin_form_post_url( $form_submit ); ?>">
|
171 |
+
<?php wp_nonce_field( 'wpmem_add_field' ); ?>
|
172 |
+
<ul>
|
173 |
+
<li>
|
174 |
+
<label><?php _e( 'Field Label', 'wp-members' ); ?> <?php echo $span_required; ?></label>
|
175 |
+
<input type="text" name="add_name" value="<?php echo ( $mode == 'edit' ) ? $field['label'] : false; ?>" required />
|
176 |
+
<?php _e( 'The name of the field as it will be displayed to the user.', 'wp-members' ); ?>
|
177 |
+
</li>
|
178 |
+
<li>
|
179 |
+
<label><?php _e( 'Meta Key', 'wp-members' ); ?> <?php echo $span_required; ?></label>
|
180 |
+
<?php if ( $mode == 'edit' ) {
|
181 |
+
echo "<span>$meta_key</span>"; ?>
|
182 |
+
<input type="hidden" name="add_option" value="<?php echo $meta_key; ?>" required />
|
183 |
+
<?php } else { ?>
|
184 |
+
<input type="text" name="add_option" value="" />
|
185 |
+
<?php _e( 'The database meta value for the field. It must be unique and contain no spaces (underscores are ok).', 'wp-members' ); ?>
|
186 |
+
<?php } ?>
|
187 |
+
</li>
|
188 |
+
<li>
|
189 |
+
<label><?php _e( 'Field Type', 'wp-members' ); ?></label>
|
190 |
+
<?php if ( $mode == 'edit' ) {
|
191 |
+
echo '<span>' . $field['type'] . '</span>'; ?>
|
192 |
+
<input type="hidden" name="add_type" value="<?php echo $field['type']; ?>" />
|
193 |
+
<?php } else { ?>
|
194 |
+
<select name="add_type" id="wpmem_field_type_select">
|
195 |
+
<option value="text"><?php _e( 'text', 'wp-members' ); ?></option>
|
196 |
+
<option value="email"><?php _e( 'email', 'wp-members' ); ?></option>
|
197 |
+
<option value="textarea"><?php _e( 'textarea', 'wp-members' ); ?></option>
|
198 |
+
<option value="checkbox"><?php _e( 'checkbox', 'wp-members' ); ?></option>
|
199 |
+
<option value="multicheckbox"><?php _e( 'multiple checkbox', 'wp-members' ); ?></option>
|
200 |
+
<option value="select"><?php _e( 'select (dropdown)', 'wp-members' ); ?></option>
|
201 |
+
<option value="multiselect"><?php _e( 'multiple select', 'wp-members' ); ?></option>
|
202 |
+
<option value="radio"><?php _e( 'radio group', 'wp-members' ); ?></option>
|
203 |
+
<option value="password"><?php _e( 'password', 'wp-members' ); ?></option>
|
204 |
+
<option value="image"><?php _e( 'image', 'wp-members' ); ?></option>
|
205 |
+
<option value="file"><?php _e( 'file', 'wp-members' ); ?></option>
|
206 |
+
<option value="url"><?php _e( 'url', 'wp-members' ); ?></option>
|
207 |
+
<option value="number"><?php _e( 'number', 'wp-members' ); ?></option>
|
208 |
+
<option value="date"><?php _e( 'date', 'wp-members' ); ?></option>
|
209 |
+
<option value="hidden"><?php _e( 'hidden', 'wp-members' ); ?></option>
|
210 |
+
<?php if ( $wpmem->enable_products ) { ?>
|
211 |
+
<option value="membership"><?php _e( 'membership', 'wp-members' ); ?></option>
|
212 |
+
<?php } ?>
|
213 |
+
</select>
|
214 |
+
<?php } ?>
|
215 |
+
</li>
|
216 |
+
<li>
|
217 |
+
<label><?php _e( 'Display?', 'wp-members' ); ?></label>
|
218 |
+
<?php if ( 'username' != $meta_key && 'user_email' != $meta_key ) { ?>
|
219 |
+
<input type="checkbox" name="add_display" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['register'] ) : false; ?> />
|
220 |
+
<?php } else { ?>
|
221 |
+
<span><?php _e( 'This field is always displayed', 'wp-members' ); ?></span>
|
222 |
+
<input type="hidden" name="add_display" value="y" />
|
223 |
+
<?php } ?>
|
224 |
+
</li>
|
225 |
+
<li>
|
226 |
+
<label><?php _e( 'Required?', 'wp-members' ); ?></label>
|
227 |
+
<?php if ( 'username' != $meta_key && 'user_email' != $meta_key ) { ?>
|
228 |
+
<input type="checkbox" name="add_required" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['required'] ) : false; ?> />
|
229 |
+
<?php } else { ?>
|
230 |
+
<span><?php _e( 'This field is always required', 'wp-members' ); ?></span>
|
231 |
+
<input type="hidden" name="add_required" value="y" />
|
232 |
+
<?php } ?>
|
233 |
+
</li>
|
234 |
+
<!--<div id="wpmem_allowhtml">
|
235 |
+
<li>
|
236 |
+
<label><?php _e( 'Allow HTML?', 'wp-members' ); ?></label>
|
237 |
+
<input type="checkbox" name="add_html" value="y" <?php echo ( $mode == 'edit' ) ? checked( true, $field['html'] ) : false; ?> />
|
238 |
+
</li>
|
239 |
+
</div>-->
|
240 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date', 'textarea' ) ) ) ) ) { ?>
|
241 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_placeholder">' : ''; ?>
|
242 |
+
<li>
|
243 |
+
<label><?php _e( 'Placeholder', 'wp-members' ); ?></label>
|
244 |
+
<input type="text" name="add_placeholder" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['placeholder'] ) ? $field['placeholder'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
245 |
+
</li>
|
246 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
247 |
+
<?php } ?>
|
248 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'date' ) ) ) ) ) { ?>
|
249 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_pattern">' : ''; ?>
|
250 |
+
<li>
|
251 |
+
<label><?php _e( 'Pattern', 'wp-members' ); ?></label>
|
252 |
+
<input type="text" name="add_pattern" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['pattern'] ) ? $field['pattern'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
253 |
+
</li>
|
254 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
255 |
+
<?php } ?>
|
256 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'text', 'password', 'email', 'url', 'number', 'date' ) ) ) ) ) { ?>
|
257 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_title">' : ''; ?>
|
258 |
+
<li>
|
259 |
+
<label><?php _e( 'Title', 'wp-members' ); ?></label>
|
260 |
+
<input type="text" name="add_title" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['title'] ) ? $field['title'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
261 |
+
</li>
|
262 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
263 |
+
<?php } ?>
|
264 |
+
|
265 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'number', 'date' ) ) ) ) ) { ?>
|
266 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_min_max">' : ''; ?>
|
267 |
+
<li>
|
268 |
+
<label><?php _e( 'Minimum Value', 'wp-members' ); ?></label>
|
269 |
+
<input type="text" name="add_min" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['min'] ) ? $field['min'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
270 |
+
</li>
|
271 |
+
<li>
|
272 |
+
<label><?php _e( 'Maximum Value', 'wp-members' ); ?></label>
|
273 |
+
<input type="text" name="add_max" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['max'] ) ? $field['max'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
274 |
+
</li>
|
275 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
276 |
+
<?php } ?>
|
277 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( in_array( $field['type'], array( 'textarea' ) ) ) ) ) { ?>
|
278 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_rows_cols">' : ''; ?>
|
279 |
+
<li>
|
280 |
+
<label><?php _e( 'Rows', 'wp-members' ); ?></label>
|
281 |
+
<input type="number" name="add_rows" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['rows'] ) ? $field['rows'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
282 |
+
</li>
|
283 |
+
<li>
|
284 |
+
<label><?php _e( 'Columns', 'wp-members' ); ?></label>
|
285 |
+
<input type="number" name="add_cols" value="<?php echo ( $mode == 'edit' ) ? ( isset( $field['cols'] ) ? $field['cols'] : false ) : false; ?>" /> <?php echo $span_optional; ?>
|
286 |
+
</li>
|
287 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
288 |
+
<?php } ?>
|
289 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ) { ?>
|
290 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_file_info">' : ''; ?>
|
291 |
+
<li>
|
292 |
+
<label><?php _e( 'Accepted file types:', 'wp-members' ); ?></label>
|
293 |
+
<input type="text" name="add_file_value" value="<?php echo ( $mode == 'edit' && ( $field['type'] == 'file' || $field['type'] == 'image' ) ) ? $field['file_types'] : false; ?>" />
|
294 |
+
</li>
|
295 |
+
<li>
|
296 |
+
<label> </label>
|
297 |
+
<span class="description"><?php _e( 'Accepted file types should be set like this: jpg|jpeg|png|gif', 'wp-members' ); ?></span>
|
298 |
+
</li>
|
299 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
300 |
+
<?php } ?>
|
301 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'checkbox' ) ) { ?>
|
302 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_checkbox_info">' : ''; ?>
|
303 |
+
<li>
|
304 |
+
<label><?php _e( 'Checked by default?', 'wp-members' ); ?></label>
|
305 |
+
<input type="checkbox" name="add_checked_default" value="y" <?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? checked( true, $field['checked_default'] ) : false; ?> />
|
306 |
+
</li>
|
307 |
+
<li>
|
308 |
+
<label><?php _e( 'HTML label position', 'wp-members' ); ?></label>
|
309 |
+
<select name="add_checkbox_label">
|
310 |
+
<option value="0" <?php selected( $field['checkbox_label'], 0 ); ?>><?php _e( 'Before the input tag', 'wp-members' ); ?></option>
|
311 |
+
<option value="1" <?php selected( $field['checkbox_label'], 1 ); ?>><?php _e( 'After the input tag', 'wp-members' ); ?></option>
|
312 |
+
</select> <span class="description"><?php _e( 'Selecting "after" will generally display the label to the right of the checkbox', 'wp-members' ); ?></span>
|
313 |
+
</li>
|
314 |
+
<li>
|
315 |
+
<label><?php _e( 'Stored value if checked:', 'wp-members' ); ?> <span class="req"><?php _e( '(required)', 'wp-members' ); ?></span></label>
|
316 |
+
<input type="text" name="add_checked_value" id="add_checked_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'checkbox' ) ? $field['checked_value'] : false; ?>" />
|
317 |
+
</li>
|
318 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
319 |
+
<?php }
|
320 |
+
|
321 |
+
if ( isset( $field['type'] ) ) {
|
322 |
+
$additional_settings = ( $field['type'] == 'select' || $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' || $field['type'] == 'radio' ) ? true : false;
|
323 |
+
$delimiter_settings = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? true : false;
|
324 |
+
}
|
325 |
+
if ( $mode == 'add' || ( $mode == 'edit' && $additional_settings ) ) { ?>
|
326 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_dropdown_info">' : ''; ?>
|
327 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && $delimiter_settings ) ) {
|
328 |
+
echo ( $mode == 'add' ) ? '<div id="wpmem_delimiter_info">' : '';
|
329 |
+
if ( isset( $field['delimiter'] ) && ( "|" == $field['delimiter'] || "," == $field['delimiter'] ) ) {
|
330 |
+
$delimiter = $field['delimiter'];
|
331 |
+
} else {
|
332 |
+
$delimiter = "|";
|
333 |
+
}
|
334 |
+
?>
|
335 |
+
<li>
|
336 |
+
<label><?php _e( 'Stored values delimiter:', 'wp-members' ); ?></label>
|
337 |
+
<select name = "add_delimiter_value">
|
338 |
+
<option value="|" <?php selected( '|', $delimiter ); ?>>pipe "|"</option>
|
339 |
+
<option value="," <?php selected( ',', $delimiter ); ?>>comma ","</option>
|
340 |
+
</select>
|
341 |
+
</li>
|
342 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : '';
|
343 |
+
} ?>
|
344 |
+
<li>
|
345 |
+
<label style="vertical-align:top"><?php _e( 'Values (Displayed|Stored):', 'wp-members' ); ?> <?php echo $span_required; ?></label>
|
346 |
+
<textarea name="add_dropdown_value" id="add_dropdown_value" rows="5" cols="40"><?php
|
347 |
+
// Accomodate editing the current dropdown values or create dropdown value example.
|
348 |
+
if ( $mode == 'edit' ) {
|
349 |
+
for ( $row = 0; $row < count( $field['values'] ); $row++ ) {
|
350 |
+
// If the row contains commas (i.e. 1,000-10,000), wrap in double quotes.
|
351 |
+
if ( strstr( $field['values'][ $row ], ',' ) ) {
|
352 |
+
echo '"' . $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? '"' : "\",\n";
|
353 |
+
} else {
|
354 |
+
echo $field['values'][ $row ]; echo ( $row == count( $field['values'] )- 1 ) ? "" : ",\n";
|
355 |
+
} }
|
356 |
+
} else {
|
357 |
+
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { ?>
|
358 |
+
---- Select One ----|,
|
359 |
+
Choice One|choice_one,
|
360 |
+
"1,000|one_thousand",
|
361 |
+
"1,000-10,000|1,000-10,000",
|
362 |
+
Last Row|last_row<?php } else { ?>
|
363 |
+
---- Select One ----|,
|
364 |
+
Choice One|choice_one,
|
365 |
+
Choice 2|choice_two,
|
366 |
+
Last Row|last_row<?php } } ?></textarea>
|
367 |
+
</li>
|
368 |
+
<li>
|
369 |
+
<label> </label>
|
370 |
+
<span class="description"><?php _e( 'Options should be Option Name|option_value,', 'wp-members' ); ?></span>
|
371 |
+
</li>
|
372 |
+
<li>
|
373 |
+
<label> </label>
|
374 |
+
<span class="description"><a href="https://rocketgeek.com/plugins/wp-members/docs/registration/choosing-fields/" target="_blank"><?php _e( 'Visit plugin site for more information', 'wp-members' ); ?></a></span>
|
375 |
+
</li>
|
376 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
377 |
+
<?php } ?>
|
378 |
+
<?php if ( $mode == 'add' || ( $mode == 'edit' && $field['type'] == 'hidden' ) ) { ?>
|
379 |
+
<?php echo ( $mode == 'add' ) ? '<div id="wpmem_hidden_info">' : ''; ?>
|
380 |
+
<li>
|
381 |
+
<label><?php _e( 'Value', 'wp-members' ); ?> <?php echo $span_required; ?></label>
|
382 |
+
<input type="text" name="add_hidden_value" id="add_hidden_value" value="<?php echo ( $mode == 'edit' && $field['type'] == 'hidden' ) ? $field['value'] : ''; ?>" />
|
383 |
+
</li>
|
384 |
+
<?php echo ( $mode == 'add' ) ? '</div>' : ''; ?>
|
385 |
+
<?php } ?>
|
386 |
+
</ul><br />
|
387 |
+
<?php if ( $mode == 'edit' ) { ?><input type="hidden" name="field_arr" value="<?php echo $meta_key; ?>" /><?php } ?>
|
388 |
+
<?php if ( 'add' == $mode ) {
|
389 |
+
$ids = array();
|
390 |
+
foreach ( $fields as $f ) {
|
391 |
+
$ids[] = $f[0];
|
392 |
+
}
|
393 |
+
sort( $ids );
|
394 |
+
$field_order_id = end( $ids ) + 1;
|
395 |
+
} else {
|
396 |
+
$field_order_id = $field[0];
|
397 |
+
} ?>
|
398 |
+
<input type="hidden" name="add_order_id" value="<?php echo $field_order_id; ?>" />
|
399 |
+
<input type="hidden" name="wpmem_admin_a" value="<?php echo ( $mode == 'edit' ) ? 'edit_field' : 'add_field'; ?>" />
|
400 |
+
<?php $text = ( $mode == 'edit' ) ? __( 'Save Changes', 'wp-members' ) : __( 'Add Field', 'wp-members' ); ?>
|
401 |
+
<?php submit_button( $text ); ?>
|
402 |
+
<p><a href="<?php echo add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ); ?>">« <?php _e( 'Return to Fields Table', 'wp-members' ); ?></a></p>
|
403 |
+
</form><?php
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Function to display the table of fields in the field manager tab.
|
408 |
+
*
|
409 |
+
* @since 2.8.0
|
410 |
+
* @since 3.1.8 Changed name from wpmem_a_field_table().
|
411 |
+
* @since 3.3.0 Changed namme from wpmem_a_render_fields_tab_field_table() to build_field_table().
|
412 |
+
*
|
413 |
+
* @global object $wpmem
|
414 |
+
*/
|
415 |
+
public static function build_field_table() {
|
416 |
+
global $wpmem;
|
417 |
+
|
418 |
+
$wpmem_ut_fields_skip = array( 'username', 'user_email', 'confirm_email', 'password', 'confirm_password' );
|
419 |
+
$wpmem_ut_fields = get_option( 'wpmembers_utfields' );
|
420 |
+
$wpmem_us_fields_skip = array( 'username', 'user_email', 'confirm_email', 'password', 'confirm_password' );
|
421 |
+
$wpmem_us_fields = get_option( 'wpmembers_usfields' );
|
422 |
+
|
423 |
+
$wpmem_fields = get_option( 'wpmembers_fields', array() );
|
424 |
+
foreach ( $wpmem_fields as $key => $field ) {
|
425 |
+
|
426 |
+
// @todo - transitional until new array keys
|
427 |
+
if ( is_numeric( $key ) ) {
|
428 |
+
// Adjust for profile @todo - temporary until new array keys.
|
429 |
+
if ( isset( $field['profile'] ) ) {
|
430 |
+
$profile = ( true === $field['profile'] ) ? 'y' : 'n';
|
431 |
+
} else {
|
432 |
+
$profile = $field[4];
|
433 |
+
}
|
434 |
+
|
435 |
+
$meta = $field[2];
|
436 |
+
$ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $field[1], $wpmem_ut_fields ) ) ) ? $field[1] : '';
|
437 |
+
$us_checked = ( ( $wpmem_us_fields ) && ( in_array( $field[1], $wpmem_us_fields ) ) ) ? $field[1] : '';
|
438 |
+
$field_items[] = array(
|
439 |
+
'order' => $field[0],
|
440 |
+
'label' => $field[1],
|
441 |
+
'meta' => $meta,
|
442 |
+
'type' => $field[3],
|
443 |
+
'display' => ( 'user_email' != $meta && 'username' != $meta ) ? wpmem_form_field( $meta . "_display", 'checkbox', 'y', $field[4] ) : '',
|
444 |
+
'req' => ( 'user_email' != $meta && 'username' != $meta ) ? wpmem_form_field( $meta . "_required", 'checkbox', 'y', $field[5] ) : '',
|
445 |
+
'profile' => ( 'user_email' != $meta && 'username' != $meta ) ? wpmem_form_field( $meta . "_profile", 'checkbox', 'y', $profile ) : '',
|
446 |
+
'userscrn' => ( ! in_array( $meta, $wpmem_ut_fields_skip ) ) ? wpmem_form_field( 'ut_fields[' . $meta . ']', 'checkbox', $field[1], $ut_checked ) : '',
|
447 |
+
'usearch' => ( ! in_array( $meta, $wpmem_us_fields_skip ) ) ? wpmem_form_field( 'us_fields[' . $meta . ']', 'checkbox', $field[1], $us_checked ) : '',
|
448 |
+
'edit' => self::do_edit_link( $meta ),
|
449 |
+
'sort' => '<span class="dashicons dashicons-sort" title="' . __( 'Drag and drop to reorder fields', 'wp-members' ) . '"></span>',
|
450 |
+
);
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
$extra_user_screen_items = array(
|
455 |
+
'user_registered' => __( 'Registration Date', 'wp-members' ),
|
456 |
+
'_wpmem_user_confirmed' => __( 'Confirmed', 'wp-members' ),
|
457 |
+
'active' => __( 'Activated', 'wp-members' ),
|
458 |
+
'wpmem_reg_ip' => __( 'Registration IP', 'wp-members' ),
|
459 |
+
'exp_type' => __( 'Subscription Type', 'wp-members' ),
|
460 |
+
'expires' => __( 'Expires', 'wp-members' ),
|
461 |
+
'user_id' => __( 'User ID', 'wp-members' ),
|
462 |
+
);
|
463 |
+
|
464 |
+
foreach ( $extra_user_screen_items as $key => $item ) {
|
465 |
+
$ut_checked = ( ( $wpmem_ut_fields ) && ( in_array( $item, $wpmem_ut_fields ) ) ) ? $item : '';
|
466 |
+
if ( 'user_id' == $key
|
467 |
+
|| 'user_registered' == $key
|
468 |
+
|| 'wpmem_reg_ip' == $key
|
469 |
+
|| ( '_wpmem_user_confirmed' == $key && 1 == $wpmem->act_link )
|
470 |
+
|| ( 'active' == $key && 1 == $wpmem->mod_reg )
|
471 |
+
|| defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 && ( 'exp_type' == $key || 'expires' == $key ) ) {
|
472 |
+
$user_screen_items[ $key ] = array( 'label' => __( $item, 'wp-members' ), 'meta' => $key,
|
473 |
+
'userscrn' => wpmem_form_field( "ut_fields[{$key}]", 'checkbox', $item, $ut_checked ),
|
474 |
+
);
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
foreach ( $user_screen_items as $screen_item ) {
|
479 |
+
$field_items[] = array(
|
480 |
+
'label' => $screen_item['label'],
|
481 |
+
'meta' => $screen_item['meta'],
|
482 |
+
'type' => '',
|
483 |
+
'display' => '',
|
484 |
+
'req' => '',
|
485 |
+
'profile' => '',
|
486 |
+
'userscrn' => $screen_item['userscrn'],
|
487 |
+
'usearch' => '',
|
488 |
+
'edit' => '',
|
489 |
+
'sort' => '',
|
490 |
+
);
|
491 |
+
}
|
492 |
+
|
493 |
+
$table = new WP_Members_Fields_Table();
|
494 |
+
|
495 |
+
$heading = __( 'Manage Fields', 'wp-members' );
|
496 |
+
//$description = __( 'Displaying fields for:', 'wp-members' );
|
497 |
+
//$which_form = $wpmem->form_tags[ $wpmem->admin->current_form ];
|
498 |
+
|
499 |
+
echo '<div class="wrap">';
|
500 |
+
printf( '<h3 class="title">%s</h3>', $heading );
|
501 |
+
//printf( '<p>%s <strong>%s</strong></p>', $description, $which_form );
|
502 |
+
printf( '<form name="updatefieldform" id="updatefieldform" method="post" action="%s">', wpmem_admin_form_post_url() );
|
503 |
+
|
504 |
+
$table->items = $field_items;
|
505 |
+
$table->prepare_items();
|
506 |
+
$table->display();
|
507 |
+
echo '</form>';
|
508 |
+
echo '</div>';
|
509 |
+
}
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Javascript to ID the fields table and add curser style to rows.
|
513 |
+
*
|
514 |
+
* @since 3.1.8
|
515 |
+
* @since 3.3.0 Changed from wpmem_bulk_fields_actions() to bulk_actions().
|
516 |
+
*/
|
517 |
+
|
518 |
+
public static function bulk_actions() {
|
519 |
+
if ( 'wpmem-settings' == wpmem_get( 'page', false, 'get' ) && 'fields' == wpmem_get( 'tab', false, 'get' ) ) {
|
520 |
+
?><script type="text/javascript">
|
521 |
+
(function($) {
|
522 |
+
$(document).ready(function() {
|
523 |
+
$("table").attr("id", "wpmem-fields");
|
524 |
+
/**$("tr").attr('style', 'cursor:move;');**/
|
525 |
+
});
|
526 |
+
})(jQuery);
|
527 |
+
jQuery('<input id="add_field" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".top .bulkactions");
|
528 |
+
jQuery('<input id="add_field2" name="add_field" class="button action" type="submit" value="<?php _e( 'Add Field', 'wp-members' ); ?>" />').appendTo(".bottom .bulkactions");
|
529 |
+
</script><?php
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Updates fields.
|
535 |
+
*
|
536 |
+
* Derived from wpmem_update_fields()
|
537 |
+
*
|
538 |
+
* @since 3.1.8
|
539 |
+
* @since 3.3.0 Changed from wpmem_admin_fields_update() to update().
|
540 |
+
* @since 3.3.9 load_fields() moved to forms object class.
|
541 |
+
*
|
542 |
+
* @global object $wpmem
|
543 |
+
* @global string $did_update
|
544 |
+
* @global string $add_field_err_msg The add field error message
|
545 |
+
*/
|
546 |
+
public static function update() {
|
547 |
+
|
548 |
+
global $wpmem, $did_update, $delete_action;
|
549 |
+
|
550 |
+
if ( 'wpmem-settings' == wpmem_get( 'page', false, 'get' ) && 'fields' == wpmem_get( 'tab', false, 'get' ) ) {
|
551 |
+
// Get the current fields.
|
552 |
+
$wpmem_fields = get_option( 'wpmembers_fields' );
|
553 |
+
|
554 |
+
$action = sanitize_text_field( wpmem_get( 'action', false ) );
|
555 |
+
$action = ( -1 == $action ) ? sanitize_text_field( wpmem_get( 'action2' ) ) : $action;
|
556 |
+
|
557 |
+
$delete_action = false;
|
558 |
+
|
559 |
+
if ( 'save' == $action ) {
|
560 |
+
|
561 |
+
// Check nonce.
|
562 |
+
check_admin_referer( 'bulk-settings_page_wpmem-settings' );
|
563 |
+
|
564 |
+
// Update user table fields.
|
565 |
+
$arr = ( isset( $_POST['ut_fields'] ) ) ? $_POST['ut_fields'] : array();
|
566 |
+
$ut_fields_arr = array();
|
567 |
+
foreach ( $arr as $key => $item ) {
|
568 |
+
$ut_fields_arr[ sanitize_text_field( $key ) ] = sanitize_text_field( $item );
|
569 |
+
}
|
570 |
+
update_option( 'wpmembers_utfields', $ut_fields_arr );
|
571 |
+
|
572 |
+
// Update user search fields.
|
573 |
+
$arr = ( isset( $_POST['us_fields'] ) ) ? $_POST['us_fields'] : array();
|
574 |
+
$us_fields_arr = array();
|
575 |
+
foreach ( $arr as $key => $item ) {
|
576 |
+
$us_fields_arr[ sanitize_text_field( $key ) ] = sanitize_text_field( $item );
|
577 |
+
}
|
578 |
+
update_option( 'wpmembers_usfields', $us_fields_arr );
|
579 |
+
|
580 |
+
// Update display/required settings
|
581 |
+
foreach ( $wpmem_fields as $key => $field ) {
|
582 |
+
$meta_key = $field[2];
|
583 |
+
if ( 'username' == $meta_key || 'user_email' == $meta_key ) {
|
584 |
+
$wpmem_fields[ $key ][4] = 'y';
|
585 |
+
$wpmem_fields[ $key ][5] = 'y';
|
586 |
+
$wpmem_fields[ $key ]['profile'] = ( 'username' == $meta_key ) ? false : true;
|
587 |
+
} else {
|
588 |
+
$wpmem_fields[ $key ][4] = ( wpmem_get( $meta_key . "_display" ) ) ? 'y' : '';
|
589 |
+
$wpmem_fields[ $key ][5] = ( wpmem_get( $meta_key . "_required" ) ) ? 'y' : '';
|
590 |
+
$wpmem_fields[ $key ]['profile'] = ( wpmem_get( $meta_key . '_profile' ) ) ? true : false;
|
591 |
+
}
|
592 |
+
}
|
593 |
+
update_option( 'wpmembers_fields', $wpmem_fields );
|
594 |
+
$wpmem->forms->load_fields();
|
595 |
+
$did_update = __( 'WP-Members fields were updated', 'wp-members' );
|
596 |
+
return $did_update;
|
597 |
+
|
598 |
+
} elseif ( 'delete' == $action ) {
|
599 |
+
|
600 |
+
// Check nonce.
|
601 |
+
check_admin_referer( 'bulk-settings_page_wpmem-settings' );
|
602 |
+
|
603 |
+
$delete_action = 'delete';
|
604 |
+
|
605 |
+
} elseif ( ( 'add_field' == wpmem_get( 'wpmem_admin_a' ) || 'edit_field' == wpmem_get( 'wpmem_admin_a' ) ) && check_admin_referer( 'wpmem_add_field' ) ) {
|
606 |
+
|
607 |
+
// Set action.
|
608 |
+
$action = sanitize_text_field( wpmem_get( 'wpmem_admin_a' ) );
|
609 |
+
|
610 |
+
global $add_field_err_msg;
|
611 |
+
|
612 |
+
$add_field_err_msg = false;
|
613 |
+
$add_name = sanitize_text_field( wpmem_get( 'add_name' ) );
|
614 |
+
$add_option = sanitize_text_field( wpmem_get( 'add_option' ) );
|
615 |
+
|
616 |
+
// Error check that field label and option name are included and unique.
|
617 |
+
$add_field_err_msg = ( ! $add_name ) ? __( 'Field Label is required. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
|
618 |
+
$add_field_err_msg = ( ! $add_option ) ? __( 'Meta Key is required. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
|
619 |
+
|
620 |
+
$add_field_err_msg = ( ! preg_match("/^[A-Za-z0-9_]*$/", $add_option ) ) ? __( 'Meta Key must contain only letters, numbers, and underscores', 'wp-members' ) : $add_field_err_msg;
|
621 |
+
|
622 |
+
// Check for duplicate field names.
|
623 |
+
$chk_fields = array();
|
624 |
+
foreach ( $wpmem_fields as $field ) {
|
625 |
+
$chk_fields[] = $field[2];
|
626 |
+
}
|
627 |
+
$add_field_err_msg = ( in_array( $add_option, $chk_fields ) ) ? __( 'A field with that meta key already exists', 'wp-members' ) : $add_field_err_msg;
|
628 |
+
|
629 |
+
// Error check for reserved terms.
|
630 |
+
$reserved_terms = wpmem_wp_reserved_terms();
|
631 |
+
if ( in_array( strtolower( $add_option ), $reserved_terms ) ) {
|
632 |
+
$add_field_err_msg = sprintf( __( 'Sorry, "%s" is a <a href="https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms" target="_blank">reserved term</a>. Field was not added.', 'wp-members' ), $add_option );
|
633 |
+
}
|
634 |
+
|
635 |
+
// Error check option name for spaces and replace with underscores.
|
636 |
+
$us_option = preg_replace( "/ /", '_', $add_option );
|
637 |
+
|
638 |
+
$arr = array();
|
639 |
+
|
640 |
+
$type = sanitize_text_field( wpmem_get( 'add_type' ) );
|
641 |
+
|
642 |
+
$arr[0] = filter_var( wpmem_get( 'add_order_id' ), FILTER_SANITIZE_NUMBER_INT );
|
643 |
+
$arr[1] = sanitize_text_field( stripslashes( wpmem_get( 'add_name' ) ) );
|
644 |
+
$arr[2] = $us_option;
|
645 |
+
$arr[3] = $type;
|
646 |
+
$arr[4] = ( 'y' == wpmem_get( 'add_display', 'n' ) ) ? 'y' : 'n';
|
647 |
+
$arr[5] = ( 'y' == wpmem_get( 'add_required', 'n' ) ) ? 'y' : 'n';
|
648 |
+
|
649 |
+
// Mark native fields:
|
650 |
+
$native_fields = array( 'user_login', 'user_pass', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'display_name', 'first_name', 'last_name', 'nickname', 'description' );
|
651 |
+
$arr[6] = ( in_array( $us_option, $native_fields ) ) ? 'y' : 'n';
|
652 |
+
|
653 |
+
if ( 'text' == $type || 'email' == $type || 'textarea' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) {
|
654 |
+
$arr['placeholder'] = sanitize_text_field( stripslashes( wpmem_get( 'add_placeholder' ) ) );
|
655 |
+
}
|
656 |
+
|
657 |
+
if ( 'text' == $type || 'email' == $type || 'password' == $type || 'url' == $type || 'number' == $type || 'date' == $type ) {
|
658 |
+
$arr['pattern'] = sanitize_text_field( stripslashes( wpmem_get( 'add_pattern' ) ) );
|
659 |
+
$arr['title'] = sanitize_text_field( stripslashes( wpmem_get( 'add_title' ) ) );
|
660 |
+
}
|
661 |
+
|
662 |
+
if ( 'number' == $type || 'date' == $type ) {
|
663 |
+
$arr['min'] = filter_var( wpmem_get( 'add_min' ), FILTER_SANITIZE_NUMBER_INT );
|
664 |
+
$arr['max'] = filter_var( wpmem_get( 'add_max' ), FILTER_SANITIZE_NUMBER_INT );
|
665 |
+
}
|
666 |
+
|
667 |
+
if ( 'textarea' == $type ) {
|
668 |
+
$arr['rows'] = filter_var( wpmem_get( 'add_rows' ), FILTER_SANITIZE_NUMBER_INT );
|
669 |
+
$arr['cols'] = filter_var( wpmem_get( 'add_cols' ), FILTER_SANITIZE_NUMBER_INT );
|
670 |
+
}
|
671 |
+
|
672 |
+
if ( $type == 'checkbox' ) {
|
673 |
+
$add_field_err_msg = ( ! $_POST['add_checked_value'] ) ? __( 'Checked value is required for checkboxes. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
|
674 |
+
$arr[7] = sanitize_text_field( wpmem_get( 'add_checked_value', false ) );
|
675 |
+
$arr[8] = ( 'y' == wpmem_get( 'add_checked_default', 'n' ) ) ? 'y' : 'n';
|
676 |
+
$arr['checkbox_label'] = intval( wpmem_get( 'add_checkbox_label', 0 ) );
|
677 |
+
}
|
678 |
+
|
679 |
+
if ( $type == 'select'
|
680 |
+
|| $type == 'multiselect'
|
681 |
+
|| $type == 'radio'
|
682 |
+
|| $type == 'multicheckbox'
|
683 |
+
) {
|
684 |
+
// Get the values.
|
685 |
+
$str = stripslashes( sanitize_textarea_field( $_POST['add_dropdown_value'] ) );
|
686 |
+
// Remove linebreaks.
|
687 |
+
$str = trim( str_replace( array("\r", "\r\n", "\n"), '', $str ) );
|
688 |
+
// Create array.
|
689 |
+
if ( ! function_exists( 'str_getcsv' ) ) {
|
690 |
+
$arr[7] = explode( ',', $str );
|
691 |
+
} else {
|
692 |
+
$arr[7] = str_getcsv( $str, ',', '"' );
|
693 |
+
}
|
694 |
+
// If multiselect or multicheckbox, set delimiter.
|
695 |
+
if ( 'multiselect' == $type || 'multicheckbox' == $type ) {
|
696 |
+
$arr[8] = ( ',' === wpmem_get( 'add_delimiter_value', '|' ) ) ? ',' : '|';
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
if ( $type == 'file' || $type == 'image' ) {
|
701 |
+
$arr[7] = sanitize_text_field( stripslashes( $_POST['add_file_value'] ) );
|
702 |
+
}
|
703 |
+
|
704 |
+
if ( wpmem_get( 'add_type' ) == 'hidden' ) {
|
705 |
+
$add_field_err_msg = ( ! $_POST['add_hidden_value'] ) ? __( 'A value is required for hidden fields. Nothing was updated.', 'wp-members' ) : $add_field_err_msg;
|
706 |
+
$arr[7] = ( isset( $_POST['add_hidden_value'] ) ) ? sanitize_text_field( stripslashes( $_POST['add_hidden_value'] ) ) : '';
|
707 |
+
}
|
708 |
+
|
709 |
+
if ( $action == 'add_field' ) {
|
710 |
+
if ( ! $add_field_err_msg ) {
|
711 |
+
array_push( $wpmem_fields, $arr );
|
712 |
+
$did_update = sprintf( __( '%s was added', 'wp-members' ), esc_html( $_POST['add_name'] ) );
|
713 |
+
} else {
|
714 |
+
$did_update = $add_field_err_msg;
|
715 |
+
}
|
716 |
+
} else {
|
717 |
+
for ( $row = 0; $row < count( $wpmem_fields ); $row++ ) {
|
718 |
+
if ( $wpmem_fields[ $row ][2] == wpmem_get( 'field', false, 'get' ) ) {
|
719 |
+
$arr[0] = $wpmem_fields[ $row ][0];
|
720 |
+
foreach ( $arr as $key => $value ) {
|
721 |
+
$wpmem_fields[ $row ][ $key ] = $arr[ $key ];
|
722 |
+
}
|
723 |
+
}
|
724 |
+
}
|
725 |
+
$did_update = sprintf( __( '%s was updated', 'wp-members' ), esc_html( stripslashes( $add_name ) ) );
|
726 |
+
$did_update.= '<p><a href="' . esc_url( add_query_arg( array( 'page' => 'wpmem-settings', 'tab' => 'fields' ), get_admin_url() . 'options-general.php' ) ) . '">« ' . __( 'Return to Fields Table', 'wp-members' ) . '</a></p>';
|
727 |
+
}
|
728 |
+
|
729 |
+
$wpmem_newfields = $wpmem_fields;
|
730 |
+
|
731 |
+
update_option( 'wpmembers_fields', $wpmem_newfields );
|
732 |
+
$wpmem->forms->load_fields();
|
733 |
+
return $did_update;
|
734 |
+
}
|
735 |
+
}
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Reorders form fields.
|
740 |
+
*
|
741 |
+
* @since 2.5.1
|
742 |
+
* @since 3.1.8 Rebuilt for new List Table.
|
743 |
+
* @since 3.3.0 Merged do_field_reorder() and field_reorder().
|
744 |
+
*/
|
745 |
+
public static function do_field_reorder() {
|
746 |
+
|
747 |
+
// Start fresh.
|
748 |
+
$new_order = $wpmem_fields = $field = $key = $wpmem_new_fields = $id = $k = '';
|
749 |
+
$wpmem_fields = get_option( 'wpmembers_fields' );
|
750 |
+
|
751 |
+
// Get the list items
|
752 |
+
$new_order = $_POST;
|
753 |
+
|
754 |
+
// Put fields in the proper order for the current form.
|
755 |
+
$wpmem_new_fields = array();
|
756 |
+
foreach ( $new_order['list_items'] as $id ) {
|
757 |
+
foreach( $wpmem_fields as $val ) {
|
758 |
+
if ( $val[0] == $id ) {
|
759 |
+
$wpmem_new_fields[] = $val;
|
760 |
+
}
|
761 |
+
}
|
762 |
+
}
|
763 |
+
|
764 |
+
// Save fields array with new current form field order.
|
765 |
+
update_option( 'wpmembers_fields', $wpmem_new_fields );
|
766 |
+
|
767 |
+
// Indicate successful transaction.
|
768 |
+
_e( 'Form field order updated.', 'wp-members' );
|
769 |
+
|
770 |
+
die(); // This is required to return a proper result.
|
771 |
+
|
772 |
+
}
|
773 |
+
}
|
774 |
// End of file.
|
@@ -1,691 +1,686 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members Admin functions
|
4 |
-
*
|
5 |
-
* Static functions to manage the plugin options tab.
|
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-
|
10 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
-
*
|
12 |
-
* @package WP-Members
|
13 |
-
* @author Chad Butler
|
14 |
-
* @copyright 2006-
|
15 |
-
*/
|
16 |
-
|
17 |
-
// Exit if accessed directly.
|
18 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
-
exit();
|
20 |
-
}
|
21 |
-
|
22 |
-
class WP_Members_Admin_Tab_Options {
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Creates the tab.
|
26 |
-
*
|
27 |
-
* @since 3.2.0
|
28 |
-
* @since 3.3.0 Ported from wpmem_a_options_tab().
|
29 |
-
*
|
30 |
-
* @param string $tab The admin tab being displayed.
|
31 |
-
* @return string|bool The about tab, otherwise false.
|
32 |
-
*/
|
33 |
-
static function do_tab( $tab ) {
|
34 |
-
if ( $tab == 'options' || ! $tab ) {
|
35 |
-
// Render the about tab.
|
36 |
-
return self::build_settings();
|
37 |
-
} else {
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Builds the settings panel.
|
44 |
-
*
|
45 |
-
* @since 2.2.2
|
46 |
-
* @since 3.3.0 Ported from wpmem_a_build_options().
|
47 |
-
*
|
48 |
-
* @global object $wpmem The WP_Members Object.
|
49 |
-
*/
|
50 |
-
static function build_settings() {
|
51 |
-
|
52 |
-
global $wpmem;
|
53 |
-
|
54 |
-
/** This filter is documented in wp-members/includes/class-wp-members-email.php */
|
55 |
-
$admin_email = apply_filters( 'wpmem_notify_addr', get_option( 'admin_email' ) );
|
56 |
-
$chg_email = sprintf( __( '%sChange%s or %sFilter%s this address', 'wp-members' ), '<a href="' . site_url( 'wp-admin/options-general.php', 'admin' ) . '">', '</a>', '<a href="https://rocketgeek.com/plugins/wp-members/
|
57 |
-
$help_link = sprintf( __( 'See the %sUsers Guide on plugin options%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/
|
58 |
-
|
59 |
-
// Build an array of post types
|
60 |
-
$post_types = $wpmem->admin->post_types();
|
61 |
-
$post_arr = array(
|
62 |
-
'post' => __( 'Posts' ),
|
63 |
-
'page' => __( 'Pages' ),
|
64 |
-
);
|
65 |
-
if ( $post_types ) {
|
66 |
-
foreach ( $post_types as $post_type ) {
|
67 |
-
$cpt_obj = get_post_type_object( $post_type );
|
68 |
-
$post_arr[ $cpt_obj->name ] = $cpt_obj->labels->name;
|
69 |
-
}
|
70 |
-
} ?>
|
71 |
-
|
72 |
-
<div class="metabox-holder has-right-sidebar">
|
73 |
-
|
74 |
-
<div class="inner-sidebar">
|
75 |
-
<?php wpmem_a_meta_box(); ?>
|
76 |
-
<?php wpmem_a_rating_box(); ?>
|
77 |
-
<div class="postbox">
|
78 |
-
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
79 |
-
<div class="inside">
|
80 |
-
<p><strong><i><?php echo $help_link; ?></i></strong></p>
|
81 |
-
<p><button id="opener">Get Settings Information</button></p>
|
82 |
-
</div>
|
83 |
-
</div>
|
84 |
-
<?php wpmem_a_rss_box(); ?>
|
85 |
-
</div> <!-- .inner-sidebar -->
|
86 |
-
|
87 |
-
<div id="post-body">
|
88 |
-
<div id="post-body-content">
|
89 |
-
<div class="postbox">
|
90 |
-
<h3><span><?php _e( 'Manage Options', 'wp-members' ); ?></span></h3>
|
91 |
-
<div class="inside">
|
92 |
-
<form name="updatesettings" id="updatesettings" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
|
93 |
-
<?php wp_nonce_field( 'wpmem-update-settings' ); ?>
|
94 |
-
<h3><?php _e( 'Content', 'wp-members' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#content" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
95 |
-
<ul>
|
96 |
-
<?php
|
97 |
-
|
98 |
-
// Content Blocking option group.
|
99 |
-
$i = 0;
|
100 |
-
$len = count( $post_arr );
|
101 |
-
foreach ( $post_arr as $key => $val ) {
|
102 |
-
if ( $key == 'post' || $key == 'page' || ( isset( $wpmem->post_types ) && array_key_exists( $key, $wpmem->post_types ) ) ) {
|
103 |
-
?>
|
104 |
-
<li<?php echo ( $i == $len - 1 ) ? ' style="border-bottom:1px solid #eee;"' : ''; ?>>
|
105 |
-
<label><?php echo ( $i == 0 ) ? __( 'Content Blocking', 'wp-members' ) : ' '; ?></label>
|
106 |
-
<?php
|
107 |
-
$block = ( isset( $wpmem->block[ $key ] ) ) ? $wpmem->block[ $key ] : '';
|
108 |
-
$values = array(
|
109 |
-
__( 'Do not block', 'wp-members' ) . '|0',
|
110 |
-
__( 'Block', 'wp-members' ) . '|1',
|
111 |
-
// @todo Future development. __( 'Hide', 'wp-members' ) . '|2',
|
112 |
-
);
|
113 |
-
echo
|
114 |
-
<span><?php echo $val; ?></span><?php // @todo - this needs to be translatable. ?>
|
115 |
-
</li>
|
116 |
-
<?php $i++;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
// Show Excerpts, Login Form, and Registration Form option groups.
|
121 |
-
|
122 |
-
$option_group_array = array(
|
123 |
-
'show_excerpt' => __( 'Show Excerpts', 'wp-members' ),
|
124 |
-
'show_login' => __( 'Show Login Form', 'wp-members' ),
|
125 |
-
'show_reg' => __( 'Show Registration Form', 'wp-members' ),
|
126 |
-
'autoex' => __( 'Auto Excerpt:', 'wp-members' ),
|
127 |
-
);
|
128 |
-
|
129 |
-
foreach ( $option_group_array as $item_key => $item_val ) {
|
130 |
-
$i = 0;
|
131 |
-
$len = count( $post_arr );
|
132 |
-
foreach ( $post_arr as $key => $val ) {
|
133 |
-
if ( $key == 'post' || $key == 'page' || ( isset( $wpmem->post_types ) && array_key_exists( $key, $wpmem->post_types ) ) ) {
|
134 |
-
?>
|
135 |
-
<li<?php echo ( $i == $len - 1 ) ? ' style="border-bottom:1px solid #eee;"' : ''; ?>>
|
136 |
-
<label><?php echo ( $i == 0 ) ? $item_val : ' '; ?></label>
|
137 |
-
<?php if ( 'autoex' == $item_key ) {
|
138 |
-
if ( isset( $wpmem->{$item_key}[ $key ] ) && $wpmem->{$item_key}[ $key ]['enabled'] == 1 ) {
|
139 |
-
$setting = 1;
|
140 |
-
$ex_len = $wpmem->{$item_key}[ $key ]['length'];
|
141 |
-
$ex_text = ( isset( $wpmem->{$item_key}[ $key ]['text'] ) ) ? $wpmem->{$item_key}[ $key ]['text'] : '';
|
142 |
-
} else {
|
143 |
-
$setting = 0;
|
144 |
-
$ex_len = '';
|
145 |
-
$ex_text = '';
|
146 |
-
}
|
147 |
-
echo
|
148 |
-
<span><?php _e( 'Number of words in excerpt:', 'wp-members' ); ?> </span><input name="wpmem_autoex_<?php echo $key; ?>_len" type="text" size="5" value="<?php echo $ex_len; ?>" />
|
149 |
-
<span><?php _e( 'Custom read more link (optional):', 'wp-members' ); ?> </span><input name="wpmem_autoex_<?php echo $key; ?>_text" type="text" size="5" value="<?php echo $ex_text; ?>" />
|
150 |
-
<?php } else {
|
151 |
-
$setting = ( isset( $wpmem->{$item_key}[ $key ] ) ) ? $wpmem->{$item_key}[ $key ] : 0;
|
152 |
-
echo
|
153 |
-
<?php } ?>
|
154 |
-
</li>
|
155 |
-
<?php $i++;
|
156 |
-
}
|
157 |
-
}
|
158 |
-
} ?>
|
159 |
-
</ul>
|
160 |
-
<?php
|
161 |
-
if ( WPMEM_EXP_MODULE == true ) {
|
162 |
-
$rows = array(
|
163 |
-
array(__('Time-based expiration','wp-members'),'wpmem_settings_time_exp',__('Allows for access to expire','wp-members'),'use_exp'),
|
164 |
-
array(__('Trial period','wp-members'),'wpmem_settings_trial',__('Allows for a trial period','wp-members'),'use_trial'),
|
165 |
-
); ?>
|
166 |
-
<h3><?php _e( 'Subscription Settings', 'wp-members' ); ?></h3>
|
167 |
-
<ul><?php
|
168 |
-
foreach ( $rows as $row ) { ?>
|
169 |
-
<li>
|
170 |
-
<label><?php echo $row[0]; ?></label>
|
171 |
-
<?php echo
|
172 |
-
<?php if ( $row[2] ) { ?><span class="description"><?php echo $row[2]; ?></span><?php } ?>
|
173 |
-
</li>
|
174 |
-
<?php }
|
175 |
-
}?></ul>
|
176 |
-
<h3><?php _e( 'Feature Settings', 'wp-members' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/new-feature-settings/" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
177 |
-
<?php
|
178 |
-
$
|
179 |
-
|
180 |
-
|
181 |
-
array(__('
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
$
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<li>
|
238 |
-
<label><?php _e( '
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
<
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
<
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
<label
|
283 |
-
<input class="regular-text code" type="text" name="
|
284 |
-
|
285 |
-
</
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
<td
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
}
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
echo
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
*
|
390 |
-
*
|
391 |
-
* @
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
$
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
$
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
'
|
503 |
-
'
|
504 |
-
'
|
505 |
-
'
|
506 |
-
'
|
507 |
-
'
|
508 |
-
'
|
509 |
-
'
|
510 |
-
'
|
511 |
-
'
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
'
|
517 |
-
'
|
518 |
-
'
|
519 |
-
|
520 |
-
),
|
521 |
-
'
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
}
|
538 |
-
|
539 |
-
//
|
540 |
-
if (
|
541 |
-
|
542 |
-
}
|
543 |
-
|
544 |
-
//
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
//
|
557 |
-
$arr[ $post_type ]
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
*
|
590 |
-
*
|
591 |
-
* @
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
*
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
'
|
627 |
-
'
|
628 |
-
'Twenty
|
629 |
-
'Twenty
|
630 |
-
'Twenty
|
631 |
-
'Twenty
|
632 |
-
'
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
*
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
$selected =
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
*
|
663 |
-
*
|
664 |
-
* @
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
$
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
$selected = ( ! $selected ) ? ' selected' : '';
|
687 |
-
echo '<option value="use_custom"' . $selected . '>' . __( 'USE CUSTOM URL BELOW', 'wp-members' ) . '</option>';
|
688 |
-
}
|
689 |
-
}
|
690 |
-
|
691 |
} // End of file.
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members Admin functions
|
4 |
+
*
|
5 |
+
* Static functions to manage the plugin options tab.
|
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-2021 Chad Butler
|
10 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
11 |
+
*
|
12 |
+
* @package WP-Members
|
13 |
+
* @author Chad Butler
|
14 |
+
* @copyright 2006-2021
|
15 |
+
*/
|
16 |
+
|
17 |
+
// Exit if accessed directly.
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
+
exit();
|
20 |
+
}
|
21 |
+
|
22 |
+
class WP_Members_Admin_Tab_Options {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Creates the tab.
|
26 |
+
*
|
27 |
+
* @since 3.2.0
|
28 |
+
* @since 3.3.0 Ported from wpmem_a_options_tab().
|
29 |
+
*
|
30 |
+
* @param string $tab The admin tab being displayed.
|
31 |
+
* @return string|bool The about tab, otherwise false.
|
32 |
+
*/
|
33 |
+
static function do_tab( $tab ) {
|
34 |
+
if ( $tab == 'options' || ! $tab ) {
|
35 |
+
// Render the about tab.
|
36 |
+
return self::build_settings();
|
37 |
+
} else {
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Builds the settings panel.
|
44 |
+
*
|
45 |
+
* @since 2.2.2
|
46 |
+
* @since 3.3.0 Ported from wpmem_a_build_options().
|
47 |
+
*
|
48 |
+
* @global object $wpmem The WP_Members Object.
|
49 |
+
*/
|
50 |
+
static function build_settings() {
|
51 |
+
|
52 |
+
global $wpmem;
|
53 |
+
|
54 |
+
/** This filter is documented in wp-members/includes/class-wp-members-email.php */
|
55 |
+
$admin_email = apply_filters( 'wpmem_notify_addr', get_option( 'admin_email' ) );
|
56 |
+
$chg_email = sprintf( __( '%sChange%s or %sFilter%s this address', 'wp-members' ), '<a href="' . site_url( 'wp-admin/options-general.php', 'admin' ) . '">', '</a>', '<a href="https://rocketgeek.com/plugins/wp-members/docs/filter-hooks/wpmem_notify_addr/">', '</a>' );
|
57 |
+
$help_link = sprintf( __( 'See the %sUsers Guide on plugin options%s.', 'wp-members' ), '<a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/" target="_blank">', '</a>' );
|
58 |
+
|
59 |
+
// Build an array of post types
|
60 |
+
$post_types = $wpmem->admin->post_types();
|
61 |
+
$post_arr = array(
|
62 |
+
'post' => __( 'Posts' ),
|
63 |
+
'page' => __( 'Pages' ),
|
64 |
+
);
|
65 |
+
if ( $post_types ) {
|
66 |
+
foreach ( $post_types as $post_type ) {
|
67 |
+
$cpt_obj = get_post_type_object( $post_type );
|
68 |
+
$post_arr[ $cpt_obj->name ] = $cpt_obj->labels->name;
|
69 |
+
}
|
70 |
+
} ?>
|
71 |
+
|
72 |
+
<div class="metabox-holder has-right-sidebar">
|
73 |
+
|
74 |
+
<div class="inner-sidebar">
|
75 |
+
<?php wpmem_a_meta_box(); ?>
|
76 |
+
<?php wpmem_a_rating_box(); ?>
|
77 |
+
<div class="postbox">
|
78 |
+
<h3><span><?php _e( 'Need help?', 'wp-members' ); ?></span></h3>
|
79 |
+
<div class="inside">
|
80 |
+
<p><strong><i><?php echo $help_link; ?></i></strong></p>
|
81 |
+
<p><button id="opener">Get Settings Information</button></p>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
<?php wpmem_a_rss_box(); ?>
|
85 |
+
</div> <!-- .inner-sidebar -->
|
86 |
+
|
87 |
+
<div id="post-body">
|
88 |
+
<div id="post-body-content">
|
89 |
+
<div class="postbox">
|
90 |
+
<h3><span><?php _e( 'Manage Options', 'wp-members' ); ?></span></h3>
|
91 |
+
<div class="inside">
|
92 |
+
<form name="updatesettings" id="updatesettings" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
|
93 |
+
<?php wp_nonce_field( 'wpmem-update-settings' ); ?>
|
94 |
+
<h3><?php _e( 'Content', 'wp-members' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#content" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
95 |
+
<ul>
|
96 |
+
<?php
|
97 |
+
|
98 |
+
// Content Blocking option group.
|
99 |
+
$i = 0;
|
100 |
+
$len = count( $post_arr );
|
101 |
+
foreach ( $post_arr as $key => $val ) {
|
102 |
+
if ( $key == 'post' || $key == 'page' || ( isset( $wpmem->post_types ) && array_key_exists( $key, $wpmem->post_types ) ) ) {
|
103 |
+
?>
|
104 |
+
<li<?php echo ( $i == $len - 1 ) ? ' style="border-bottom:1px solid #eee;"' : ''; ?>>
|
105 |
+
<label><?php echo ( $i == 0 ) ? __( 'Content Blocking', 'wp-members' ) : ' '; ?></label>
|
106 |
+
<?php
|
107 |
+
$block = ( isset( $wpmem->block[ $key ] ) ) ? $wpmem->block[ $key ] : '';
|
108 |
+
$values = array(
|
109 |
+
__( 'Do not block', 'wp-members' ) . '|0',
|
110 |
+
__( 'Block', 'wp-members' ) . '|1',
|
111 |
+
// @todo Future development. __( 'Hide', 'wp-members' ) . '|2',
|
112 |
+
);
|
113 |
+
echo wpmem_form_field( 'wpmem_block_' . $key, 'select', $values, $block ); ?>
|
114 |
+
<span><?php echo $val; ?></span><?php // @todo - this needs to be translatable. ?>
|
115 |
+
</li>
|
116 |
+
<?php $i++;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
// Show Excerpts, Login Form, and Registration Form option groups.
|
121 |
+
|
122 |
+
$option_group_array = array(
|
123 |
+
'show_excerpt' => __( 'Show Excerpts', 'wp-members' ),
|
124 |
+
'show_login' => __( 'Show Login Form', 'wp-members' ),
|
125 |
+
'show_reg' => __( 'Show Registration Form', 'wp-members' ),
|
126 |
+
'autoex' => __( 'Auto Excerpt:', 'wp-members' ),
|
127 |
+
);
|
128 |
+
|
129 |
+
foreach ( $option_group_array as $item_key => $item_val ) {
|
130 |
+
$i = 0;
|
131 |
+
$len = count( $post_arr );
|
132 |
+
foreach ( $post_arr as $key => $val ) {
|
133 |
+
if ( $key == 'post' || $key == 'page' || ( isset( $wpmem->post_types ) && array_key_exists( $key, $wpmem->post_types ) ) ) {
|
134 |
+
?>
|
135 |
+
<li<?php echo ( $i == $len - 1 ) ? ' style="border-bottom:1px solid #eee;"' : ''; ?>>
|
136 |
+
<label><?php echo ( $i == 0 ) ? $item_val : ' '; ?></label>
|
137 |
+
<?php if ( 'autoex' == $item_key ) {
|
138 |
+
if ( isset( $wpmem->{$item_key}[ $key ] ) && $wpmem->{$item_key}[ $key ]['enabled'] == 1 ) {
|
139 |
+
$setting = 1;
|
140 |
+
$ex_len = $wpmem->{$item_key}[ $key ]['length'];
|
141 |
+
$ex_text = ( isset( $wpmem->{$item_key}[ $key ]['text'] ) ) ? $wpmem->{$item_key}[ $key ]['text'] : '';
|
142 |
+
} else {
|
143 |
+
$setting = 0;
|
144 |
+
$ex_len = '';
|
145 |
+
$ex_text = '';
|
146 |
+
}
|
147 |
+
echo wpmem_form_field( 'wpmem_' . $item_key . '_' . $key, 'checkbox', '1', $setting ); ?> <span><?php echo $val; ?></span>
|
148 |
+
<span><?php _e( 'Number of words in excerpt:', 'wp-members' ); ?> </span><input name="wpmem_autoex_<?php echo $key; ?>_len" type="text" size="5" value="<?php echo $ex_len; ?>" />
|
149 |
+
<span><?php _e( 'Custom read more link (optional):', 'wp-members' ); ?> </span><input name="wpmem_autoex_<?php echo $key; ?>_text" type="text" size="5" value="<?php echo $ex_text; ?>" />
|
150 |
+
<?php } else {
|
151 |
+
$setting = ( isset( $wpmem->{$item_key}[ $key ] ) ) ? $wpmem->{$item_key}[ $key ] : 0;
|
152 |
+
echo wpmem_form_field( 'wpmem_' . $item_key . '_' . $key, 'checkbox', '1', $setting ); ?> <span><?php echo $val; ?></span>
|
153 |
+
<?php } ?>
|
154 |
+
</li>
|
155 |
+
<?php $i++;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
} ?>
|
159 |
+
</ul>
|
160 |
+
<?php
|
161 |
+
if ( WPMEM_EXP_MODULE == true ) {
|
162 |
+
$rows = array(
|
163 |
+
array(__('Time-based expiration','wp-members'),'wpmem_settings_time_exp',__('Allows for access to expire','wp-members'),'use_exp'),
|
164 |
+
array(__('Trial period','wp-members'),'wpmem_settings_trial',__('Allows for a trial period','wp-members'),'use_trial'),
|
165 |
+
); ?>
|
166 |
+
<h3><?php _e( 'Subscription Settings', 'wp-members' ); ?></h3>
|
167 |
+
<ul><?php
|
168 |
+
foreach ( $rows as $row ) { ?>
|
169 |
+
<li>
|
170 |
+
<label><?php echo $row[0]; ?></label>
|
171 |
+
<?php echo wpmem_form_field( $row[1], 'checkbox', '1', $wpmem->{$row[3]} ); ?>
|
172 |
+
<?php if ( $row[2] ) { ?><span class="description"><?php echo $row[2]; ?></span><?php } ?>
|
173 |
+
</li>
|
174 |
+
<?php }
|
175 |
+
}?></ul>
|
176 |
+
<h3><?php _e( 'New Feature Settings', 'wp-members' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/new-feature-settings/" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
177 |
+
<?php
|
178 |
+
$reset_link_start = '<a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/new-feature-settings/" target="_blank">';
|
179 |
+
$reset_link_end = '</a>';
|
180 |
+
$rows = array(
|
181 |
+
//array(__('Password Reset Link', 'wp-members'),'wpmem_settings_pwd_link',__('Send password reset link instead of new password. (Requires additional configuration)','wp-members'),'pwd_link'),
|
182 |
+
array(__('Legacy Password Reset', 'wp-members'),'wpmem_settings_pwd_link',sprintf(__('Use legacy password reset. %s(Requires additional configuration)%s','wp-members'),$reset_link_start,$reset_link_end),'pwd_link'),
|
183 |
+
//array(__('Enable WP Login Error', 'wp-members' ),'wpmem_settings_login_error',__('Use WP login error object instead of WP-Members default login error','wp-members'),'login_error'),
|
184 |
+
array(__('Legacy Login Error', 'wp-members' ),'wpmem_settings_login_error',__('Use legacy WP-Members login error instead of WP error object.','wp-members'),'login_error'),
|
185 |
+
);
|
186 |
+
if ( wpmem_is_woo_active() ) {
|
187 |
+
$rows[] = array(__('WooCommerce My Account', 'wp-members' ),'wpmem_settings_add_my_account_fields',__('Add WP-Members fields to WooCommerce My Account registration','wp-members'),'add_my_account_fields');
|
188 |
+
$rows[] = array(__('WooCommerce Checkout', 'wp-members' ),'wpmem_settings_add_checkout_fields',__('Add WP-Members fields to WooCommerce registration during checkout','wp-members'),'add_checkout_fields');
|
189 |
+
}
|
190 |
+
?><ul><?php
|
191 |
+
foreach ( $rows as $key => $row ) { ?>
|
192 |
+
<li>
|
193 |
+
<label><?php echo $row[0]; ?></label>
|
194 |
+
<?php $checkbox_value = ( 2 == $key || 3 == $key ) ? $wpmem->woo[ $row[3] ] : $wpmem->{$row[3]}; ?>
|
195 |
+
<?php if ( 1 == $key || 0 == $key ) {
|
196 |
+
echo wpmem_form_field( $row[1], 'checkbox', '0', $checkbox_value ); ?>
|
197 |
+
<?php } else {
|
198 |
+
echo wpmem_form_field( $row[1], 'checkbox', '1', $checkbox_value ); ?>
|
199 |
+
<?php } ?>
|
200 |
+
<?php if ( $row[2] ) { ?><span class="description"><?php echo $row[2]; ?></span><?php } ?>
|
201 |
+
</li>
|
202 |
+
<?php } ?>
|
203 |
+
</ul>
|
204 |
+
<h3><?php _e( 'Other Settings', 'wp-members' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#other" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
205 |
+
<ul>
|
206 |
+
<?php
|
207 |
+
/** This filter is defined in includes/class-wp-members.php */
|
208 |
+
$dropin_dir = apply_filters( 'wpmem_dropin_dir', $wpmem->dropin_dir );
|
209 |
+
$mem_link_start = '<a href="https://rocketgeek.com/plugins/wp-members/docs/membership-products/" target="_blank">';
|
210 |
+
$mem_link_end = '</a>';
|
211 |
+
$conf_link_start = '<a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#confirm" target="_blank">';
|
212 |
+
$conf_link_end = '</a>';
|
213 |
+
$rows = array(
|
214 |
+
array(__('Enable Products', 'wp-members'),'wpmem_settings_products',sprintf(__('Enables creation of different %s membership products %s','wp-members'),$mem_link_start,$mem_link_end),'enable_products'),
|
215 |
+
array(__('Clone menus','wp-members'),'wpmem_settings_menus',__('Enables logged in menus','wp-members'),'clone_menus'),
|
216 |
+
array(__('Notify admin','wp-members'),'wpmem_settings_notify',sprintf(__('Notify %s for each new registration? %s','wp-members'),$admin_email,$chg_email),'notify'),
|
217 |
+
array(__('Moderate registration','wp-members'),'wpmem_settings_moderate',__('Holds new registrations for admin approval','wp-members'),'mod_reg'),
|
218 |
+
array(__('Confirmation Link', 'wp-members'),'wpmem_settings_act_link',sprintf(__('Send email confirmation link on new registration. %s(Requires additional configuration)%s','wp-members'),$conf_link_start,$conf_link_end),'act_link'),
|
219 |
+
array(__('Ignore warning messages','wp-members'),'wpmem_settings_ignore_warnings',__('Ignores WP-Members warning messages in the admin panel','wp-members'),'warnings'),
|
220 |
+
//array(__('Enable dropins', 'wp-members'),'wpmem_settings_enable_dropins',sprintf(__('Enables dropins in %s', 'wp-members'), $dropin_dir),'dropins'),
|
221 |
+
);
|
222 |
+
foreach ( $rows as $row ) {
|
223 |
+
if ( $row[0] == __('Clone menus','wp-members') && 1 != $wpmem->clone_menus ) {
|
224 |
+
continue;
|
225 |
+
}?>
|
226 |
+
<li>
|
227 |
+
<label><?php echo $row[0]; ?></label>
|
228 |
+
<?php echo wpmem_form_field( $row[1], 'checkbox', '1', $wpmem->{$row[3]} ); ?>
|
229 |
+
<?php if ( $row[2] ) { ?><span class="description"><?php echo $row[2]; ?></span><?php } ?>
|
230 |
+
</li>
|
231 |
+
<?php } ?>
|
232 |
+
<li>
|
233 |
+
<label><?php _e( 'Attribution', 'wp-members' ); ?></label>
|
234 |
+
<?php echo wpmem_form_field( 'attribution', 'checkbox', '1', $wpmem->attrib ); ?>
|
235 |
+
<span class="description"><?php _e( 'Attribution is appreciated! Display "powered by" link on register form?', 'wp-members' ); ?></span>
|
236 |
+
</li>
|
237 |
+
<li>
|
238 |
+
<label><?php _e( 'Enable CAPTCHA for Registration', 'wp-members' ); ?></label>
|
239 |
+
<?php $captcha = array( __( 'None', 'wp-members' ) . '|0' );
|
240 |
+
if ( 1 == $wpmem->captcha ) {
|
241 |
+
$wpmem->captcha = 3; // reCAPTCHA v1 is fully obsolete. Change it to v2.
|
242 |
+
}
|
243 |
+
$captcha[] = __( 'reCAPTCHA v2', 'wp-members' ) . '|3';
|
244 |
+
$captcha[] = __( 'reCAPTCHA v3', 'wp-members' ) . '|4';
|
245 |
+
$captcha[] = __( 'Really Simple CAPTCHA', 'wp-members' ) . '|2';
|
246 |
+
$captcha[] = __( 'hCaptcha', 'wp-members' ) . '|5';
|
247 |
+
echo wpmem_form_field( 'wpmem_settings_captcha', 'select', $captcha, $wpmem->captcha ); ?>
|
248 |
+
</li>
|
249 |
+
<h3><?php _e( 'Pages' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#pages" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
250 |
+
<?php $wpmem_logurl = $wpmem->user_pages['login'];
|
251 |
+
if ( ! $wpmem_logurl ) { $wpmem_logurl = wpmem_use_ssl(); } ?>
|
252 |
+
<li>
|
253 |
+
<label><?php _e( 'Login Page:', 'wp-members' ); ?></label>
|
254 |
+
<select name="wpmem_settings_logpage" id="wpmem_logpage_select">
|
255 |
+
<?php WP_Members_Admin_Tab_Options::page_list( $wpmem_logurl ); ?>
|
256 |
+
</select> <span class="description"><?php _e( 'Specify a login page (optional)', 'wp-members' ); ?></span><br />
|
257 |
+
<div id="wpmem_logpage_custom">
|
258 |
+
<label> </label>
|
259 |
+
<input class="regular-text code" type="text" name="wpmem_settings_logurl" value="<?php echo $wpmem_logurl; ?>" size="50" />
|
260 |
+
</div>
|
261 |
+
</li>
|
262 |
+
<?php $wpmem_regurl = $wpmem->user_pages['register'];
|
263 |
+
if ( ! $wpmem_regurl ) { $wpmem_regurl = wpmem_use_ssl(); } ?>
|
264 |
+
<li>
|
265 |
+
<label><?php _e( 'Register Page:', 'wp-members' ); ?></label>
|
266 |
+
<select name="wpmem_settings_regpage" id="wpmem_regpage_select">
|
267 |
+
<?php WP_Members_Admin_Tab_Options::page_list( $wpmem_regurl ); ?>
|
268 |
+
</select> <span class="description"><?php _e( 'For creating a register link in the login form', 'wp-members' ); ?></span><br />
|
269 |
+
<div id="wpmem_regpage_custom">
|
270 |
+
<label> </label>
|
271 |
+
<input class="regular-text code" type="text" name="wpmem_settings_regurl" value="<?php echo $wpmem_regurl; ?>" size="50" />
|
272 |
+
</div>
|
273 |
+
</li>
|
274 |
+
<?php $wpmem_msurl = $wpmem->user_pages['profile'];
|
275 |
+
if ( ! $wpmem_msurl ) { $wpmem_msurl = wpmem_use_ssl(); } ?>
|
276 |
+
<li>
|
277 |
+
<label><?php _e( 'User Profile Page:', 'wp-members' ); ?></label>
|
278 |
+
<select name="wpmem_settings_mspage" id="wpmem_mspage_select">
|
279 |
+
<?php WP_Members_Admin_Tab_Options::page_list( $wpmem_msurl ); ?>
|
280 |
+
</select> <span class="description"><?php _e( 'For creating a forgot password link in the login form', 'wp-members' ); ?></span><br />
|
281 |
+
<div id="wpmem_mspage_custom">
|
282 |
+
<label> </label>
|
283 |
+
<input class="regular-text code" type="text" name="wpmem_settings_msurl" value="<?php echo $wpmem_msurl; ?>" size="50" />
|
284 |
+
</div>
|
285 |
+
</li>
|
286 |
+
<h3><?php _e( 'Stylesheet' ); ?> <a href="https://rocketgeek.com/plugins/wp-members/docs/plugin-settings/options/#styles" target="_blank" title="info"><span class="dashicons dashicons-info"></span></a></h3>
|
287 |
+
<li>
|
288 |
+
<label><?php _e( 'Stylesheet' ); ?>:</label>
|
289 |
+
<select name="wpmem_settings_style" id="wpmem_stylesheet_select">
|
290 |
+
<?php WP_Members_Admin_Tab_Options::style_list( $wpmem->select_style ); ?>
|
291 |
+
</select>
|
292 |
+
</li>
|
293 |
+
<?php $wpmem_cssurl = $wpmem->cssurl;
|
294 |
+
if ( ! $wpmem_cssurl ) { $wpmem_cssurl = wpmem_use_ssl(); } ?>
|
295 |
+
<div id="wpmem_stylesheet_custom">
|
296 |
+
<li>
|
297 |
+
<label><?php _e( 'Custom Stylesheet:', 'wp-members' ); ?></label>
|
298 |
+
<input class="regular-text code" type="text" name="wpmem_settings_cssurl" value="<?php echo $wpmem_cssurl; ?>" size="50" />
|
299 |
+
</li>
|
300 |
+
</div>
|
301 |
+
<input type="hidden" name="wpmem_admin_a" value="update_settings">
|
302 |
+
<?php submit_button( __( 'Update Settings', 'wp-members' ) ); ?>
|
303 |
+
</ul>
|
304 |
+
</form>
|
305 |
+
<p>If you like <strong>WP-Members</strong> please give it a <a href="https://wordpress.org/support/plugin/wp-members/reviews?rate=5#new-post">★★★★★</a> rating. Thanks!!</p>
|
306 |
+
</div><!-- .inside -->
|
307 |
+
</div>
|
308 |
+
<?php if ( $post_types ) { ?>
|
309 |
+
<div class="postbox">
|
310 |
+
<h3><span><?php _e( 'Custom Post Types', 'wp-members' ); ?></span></h3>
|
311 |
+
<div class="inside">
|
312 |
+
<form name="updatecpts" id="updatecpts" method="post" action="<?php echo wpmem_admin_form_post_url(); ?>">
|
313 |
+
<?php wp_nonce_field( 'wpmem-update-cpts' ); ?>
|
314 |
+
<table class="form-table">
|
315 |
+
<tr>
|
316 |
+
<th scope="row"><?php _e( 'Add to WP-Members Settings', 'wp-members' ); ?></th>
|
317 |
+
<td><fieldset><?php
|
318 |
+
foreach ( $post_arr as $key => $val ) {
|
319 |
+
if ( 'post' != $key && 'page' != $key && 'wpmem_product' != $key ) {
|
320 |
+
$checked = ( isset( $wpmem->post_types ) && array_key_exists( $key, $wpmem->post_types ) ) ? ' checked' : '';
|
321 |
+
echo '<label for="' . $key . '"><input type="checkbox" name="wpmembers_handle_cpts[]" value="' . $key . '"' . $checked . ' />' . $val . '</label><br />';
|
322 |
+
}
|
323 |
+
}
|
324 |
+
?></fieldset>
|
325 |
+
</td>
|
326 |
+
</tr>
|
327 |
+
<tr>
|
328 |
+
<input type="hidden" name="wpmem_admin_a" value="update_cpts" />
|
329 |
+
<td colspan="2"><?php submit_button( __( 'Update Settings', 'wp-members' ) ); ?></td>
|
330 |
+
</tr>
|
331 |
+
<tr>
|
332 |
+
<td colspan="2"><?php _e( 'Please keep in mind that Custom Post Types are "custom" and therefore, not all of them will function exactly the same way. WP-Members will certainly work with any post type that operate like a post or a page; but you will need to review any custom post type added to determine that it functions the way you expect.', 'wp-members' ); ?></td>
|
333 |
+
</tr>
|
334 |
+
</table>
|
335 |
+
</form>
|
336 |
+
</div>
|
337 |
+
</div>
|
338 |
+
<?php } ?>
|
339 |
+
</div><!-- #post-body-content -->
|
340 |
+
</div><!-- #post-body -->
|
341 |
+
</div><!-- .metabox-holder -->
|
342 |
+
<div id="dialog-message" title="<?php _e( 'WP-Members Settings', 'wp-members' ); ?>">
|
343 |
+
<h3><span><?php _e( 'WP-Members Settings', 'wp-members' ); ?></span></h3>
|
344 |
+
<p><?php _e( 'The following is your WP-Members settings information if needed for support.', 'wp-members' ); ?></p>
|
345 |
+
<pre>
|
346 |
+
<textarea cols=80 rows=10 align=left wrap=soft style="width:80%;" id="supportinfo" wrap="soft"><?php
|
347 |
+
global $wp_version, $wpdb, $wpmem;
|
348 |
+
echo "WP Version: " . $wp_version . "\r\n";
|
349 |
+
echo "PHP Version: " . phpversion() . "\r\n";
|
350 |
+
echo "MySQL Version: " . $wpdb->db_version() . "\r\n";
|
351 |
+
wpmem_fields();
|
352 |
+
print_r( $wpmem );
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Action to add before other plugin info.
|
356 |
+
*
|
357 |
+
* @since 3.4.0
|
358 |
+
*/
|
359 |
+
do_action( 'wpmem_settings_for_support' );
|
360 |
+
|
361 |
+
echo '***************** Plugin Info *******************' . "\r\n";
|
362 |
+
$all_plugins = get_plugins();
|
363 |
+
$active_plugins = get_option( 'active_plugins' );
|
364 |
+
$active_display = ''; $inactive_display = '';
|
365 |
+
foreach ( $all_plugins as $key => $value ) {
|
366 |
+
if ( in_array( $key, $active_plugins ) ) {
|
367 |
+
$active_display.= $key . " | " . $value['Name'] . " | Version: " . $value['Version'] . "\r\n";
|
368 |
+
} else {
|
369 |
+
$inactive_display.= $key . " | " . $value['Name'] . " | Version: " . $value['Version'] . "\r\n";
|
370 |
+
}
|
371 |
+
}
|
372 |
+
echo "*************** Active Plugins **************** \r\n";
|
373 |
+
echo $active_display;
|
374 |
+
echo "*************** Inactive Plugins **************** \r\n";
|
375 |
+
echo $inactive_display;
|
376 |
+
?></textarea>
|
377 |
+
</pre>
|
378 |
+
<button id="select_all" class="ui-button-text"><?php _e( 'Click to Copy', 'wp-members' ); ?></button>
|
379 |
+
</div>
|
380 |
+
<?php
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Updates the plugin options.
|
385 |
+
*
|
386 |
+
* @since 2.8.0
|
387 |
+
* @since 3.3.0 Ported from wpmem_update_options() and wpmem_update_cpts().
|
388 |
+
*
|
389 |
+
* @global object $wpmem The WP_Members object.
|
390 |
+
* @param string $action
|
391 |
+
* @return string The options updated message.
|
392 |
+
*/
|
393 |
+
static function update( $action ) {
|
394 |
+
|
395 |
+
if ( 'update_cpts' == $action ) {
|
396 |
+
|
397 |
+
// Check nonce.
|
398 |
+
check_admin_referer( 'wpmem-update-cpts' );
|
399 |
+
|
400 |
+
// Get the main settings array as it stands.
|
401 |
+
$wpmem_newsettings = get_option( 'wpmembers_settings' );
|
402 |
+
|
403 |
+
// Assemble CPT settings.
|
404 |
+
$cpts = array();
|
405 |
+
|
406 |
+
$post_arr = array();
|
407 |
+
$post_types = get_post_types( array( 'public' => true, '_builtin' => false ), 'names', 'and' );
|
408 |
+
if ( $post_types ) {
|
409 |
+
foreach ( $post_types as $post_type ) {
|
410 |
+
$cpt_obj = get_post_type_object( $post_type );
|
411 |
+
if ( $cpt_obj->labels->name != 'wpmem_product' ) {
|
412 |
+
$post_arr[ $cpt_obj->name ] = $cpt_obj->labels->name;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
$post_vals = ( isset( $_POST['wpmembers_handle_cpts'] ) ) ? $_POST['wpmembers_handle_cpts'] : false;
|
418 |
+
if ( $post_vals ) {
|
419 |
+
foreach ( $post_vals as $val ) {
|
420 |
+
$cpts[ $val ] = sanitize_text_field( $post_arr[ $val ] );
|
421 |
+
}
|
422 |
+
} else {
|
423 |
+
$cpts = array();
|
424 |
+
}
|
425 |
+
$wpmem_newsettings['post_types'] = $cpts;
|
426 |
+
|
427 |
+
// Update settings, remove or add CPTs.
|
428 |
+
$chk_settings = array( 'block', 'show_excerpt', 'show_login', 'show_reg', 'autoex' );
|
429 |
+
foreach ( $chk_settings as $chk ) {
|
430 |
+
// Handle removing unmanaged CPTs.
|
431 |
+
foreach ( $wpmem_newsettings[ $chk ] as $key => $val ) {
|
432 |
+
if ( 'post' != $key && 'page' != $key ) {
|
433 |
+
// If the $key is not in managed CPTs, remove it.
|
434 |
+
if ( ! array_key_exists( $key, $cpts ) ) {
|
435 |
+
unset( $wpmem_newsettings[ $chk ][ $key ] );
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
// Handle adding managed CPTs.
|
440 |
+
foreach ( $cpts as $key => $val ) {
|
441 |
+
if ( ! array_key_exists( $key, $wpmem_newsettings[ $chk ] ) ) {
|
442 |
+
if ( 'autoex' == $chk ) {
|
443 |
+
// Auto excerpt is an array.
|
444 |
+
$wpmem_newsettings[ $chk ][ $key ] = array(
|
445 |
+
'enabled' => 0,
|
446 |
+
'length' => '',
|
447 |
+
);
|
448 |
+
} else {
|
449 |
+
// All other settings are 0|1.
|
450 |
+
$wpmem_newsettings[ $chk ][ $key ] = 0;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
WP_Members_Admin_Tab_Options::save_settings( $wpmem_newsettings );
|
457 |
+
|
458 |
+
return __( 'Custom Post Type settings were updated', 'wp-members' );
|
459 |
+
|
460 |
+
} else {
|
461 |
+
|
462 |
+
global $wpmem;
|
463 |
+
|
464 |
+
// Check nonce.
|
465 |
+
check_admin_referer( 'wpmem-update-settings' );
|
466 |
+
|
467 |
+
$wpmem_settings_msurl = ( $_POST['wpmem_settings_mspage'] == 'use_custom' ) ? esc_url( $_POST['wpmem_settings_msurl'] ) : '';
|
468 |
+
$wpmem_settings_mspage = ( $_POST['wpmem_settings_mspage'] == 'use_custom' ) ? '' : wpmem_sanitize_field( $_POST['wpmem_settings_mspage'], 'int' );
|
469 |
+
if ( $wpmem_settings_msurl != wpmem_use_ssl() && $wpmem_settings_msurl != 'use_custom' && ! $wpmem_settings_mspage ) {
|
470 |
+
$msurl = trim( $wpmem_settings_msurl );
|
471 |
+
} else {
|
472 |
+
$msurl = $wpmem_settings_mspage;
|
473 |
+
}
|
474 |
+
|
475 |
+
$wpmem_settings_regurl = ( $_POST['wpmem_settings_regpage'] == 'use_custom' ) ? esc_url( $_POST['wpmem_settings_regurl'] ) : '';
|
476 |
+
$wpmem_settings_regpage = ( $_POST['wpmem_settings_regpage'] == 'use_custom' ) ? '' : wpmem_sanitize_field( $_POST['wpmem_settings_regpage'], 'int' );
|
477 |
+
if ( $wpmem_settings_regurl != wpmem_use_ssl() && $wpmem_settings_regurl != 'use_custom' && ! $wpmem_settings_regpage ) {
|
478 |
+
$regurl = trim( $wpmem_settings_regurl );
|
479 |
+
} else {
|
480 |
+
$regurl = $wpmem_settings_regpage;
|
481 |
+
}
|
482 |
+
|
483 |
+
$wpmem_settings_logurl = ( $_POST['wpmem_settings_logpage'] == 'use_custom' ) ? esc_url( $_POST['wpmem_settings_logurl'] ) : '';
|
484 |
+
$wpmem_settings_logpage = ( $_POST['wpmem_settings_logpage'] == 'use_custom' ) ? '' : wpmem_sanitize_field( $_POST['wpmem_settings_logpage'], 'int' );
|
485 |
+
if ( $wpmem_settings_logurl != wpmem_use_ssl() && $wpmem_settings_logurl != 'use_custom' && ! $wpmem_settings_logpage ) {
|
486 |
+
$logurl = trim( $wpmem_settings_logurl );
|
487 |
+
} else {
|
488 |
+
$logurl = $wpmem_settings_logpage;
|
489 |
+
}
|
490 |
+
|
491 |
+
$wpmem_settings_cssurl = esc_url( $_POST['wpmem_settings_cssurl'] );
|
492 |
+
$cssurl = ( $wpmem_settings_cssurl != wpmem_use_ssl() ) ? trim( $wpmem_settings_cssurl ) : '';
|
493 |
+
|
494 |
+
$wpmem_settings_style = ( isset( $_POST['wpmem_settings_style'] ) ) ? sanitize_text_field( $_POST['wpmem_settings_style'] ) : false;
|
495 |
+
|
496 |
+
$wpmem_newsettings = array(
|
497 |
+
'version' => $wpmem->version,
|
498 |
+
'db_version' => $wpmem->db_version,
|
499 |
+
'act_link' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_act_link', 0 ), 'int' ),
|
500 |
+
'pwd_link' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_pwd_link', 1 ), 'int' ),
|
501 |
+
'login_error' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_login_error', 1 ), 'int' ),
|
502 |
+
'enable_products' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_products', 0 ), 'int' ),
|
503 |
+
'clone_menus' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_menus', 0 ), 'int' ),
|
504 |
+
'notify' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_notify', 0 ), 'int' ),
|
505 |
+
'mod_reg' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_moderate', 0 ), 'int' ),
|
506 |
+
'captcha' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_captcha', 0 ), 'int' ),
|
507 |
+
'use_exp' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_time_exp', 0 ), 'int' ),
|
508 |
+
'use_trial' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_trial', 0 ), 'int' ),
|
509 |
+
'warnings' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_ignore_warnings', 0 ), 'int' ),
|
510 |
+
'dropins' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_enable_dropins', 0 ), 'int' ),
|
511 |
+
'user_pages' => array(
|
512 |
+
'profile' => ( $msurl ) ? $msurl : '',
|
513 |
+
'register' => ( $regurl ) ? $regurl : '',
|
514 |
+
'login' => ( $logurl ) ? $logurl : '',
|
515 |
+
),
|
516 |
+
'woo' => array(
|
517 |
+
'add_my_account_fields' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_add_my_account_fields', 0 ), 'int' ),
|
518 |
+
'add_checkout_fields' => wpmem_sanitize_field( wpmem_get( 'wpmem_settings_add_checkout_fields', 0 ), 'int' ),
|
519 |
+
),
|
520 |
+
'cssurl' => ( $cssurl ) ? $cssurl : '',
|
521 |
+
'select_style' => $wpmem_settings_style,
|
522 |
+
'attrib' => wpmem_sanitize_field( wpmem_get( 'attribution', 0 ), 'int' ),
|
523 |
+
);
|
524 |
+
|
525 |
+
// Build an array of post types
|
526 |
+
$post_arr = array( 'post', 'page' );
|
527 |
+
if ( isset( $wpmem->post_types ) ) {
|
528 |
+
$wpmem_newsettings['post_types'] = $wpmem->post_types;
|
529 |
+
foreach ( $wpmem_newsettings['post_types'] as $key => $val ) {
|
530 |
+
$post_arr[] = $key;
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
// If activation link is being enabled, make sure current admin is marked as activated.
|
535 |
+
if ( 1 == $wpmem_newsettings['act_link'] && 0 == $wpmem->act_link ) {
|
536 |
+
update_user_meta( get_current_user_id(), '_wpmem_user_confirmed', time() );
|
537 |
+
}
|
538 |
+
|
539 |
+
// Leave form tag settings alone.
|
540 |
+
if ( isset( $wpmem->form_tags ) ) {
|
541 |
+
$wpmem_newsettings['form_tags'] = $wpmem->form_tags;
|
542 |
+
}
|
543 |
+
|
544 |
+
// Get settings for blocking, excerpts, show login, and show registration for posts, pages, and custom post types.
|
545 |
+
$option_group_array = array( 'block', 'show_excerpt', 'show_login', 'show_reg', 'autoex' );
|
546 |
+
foreach ( $option_group_array as $option_group_item ) {
|
547 |
+
$arr = array();
|
548 |
+
foreach ( $post_arr as $post_type ) {
|
549 |
+
$post_var = 'wpmem_' . $option_group_item . '_' . $post_type;
|
550 |
+
if ( $option_group_item == 'autoex' ) {
|
551 |
+
// Auto excerpt is an array.
|
552 |
+
$arr[ $post_type ]['enabled'] = ( isset( $_POST[ $post_var ] ) ) ? wpmem_sanitize_field( $_POST[ $post_var ], 'int' ) : 0;
|
553 |
+
$arr[ $post_type ]['length'] = ( isset( $_POST[ $post_var . '_len' ] ) ) ? ( ( $_POST[ $post_var . '_len' ] == '' ) ? 0 : wpmem_sanitize_field( $_POST[ $post_var . '_len' ], 'int' ) ) : '';
|
554 |
+
$arr[ $post_type ]['text'] = ( isset( $_POST[ $post_var . '_text' ] ) ) ? sanitize_text_field( $_POST[ $post_var . '_text' ] ) : '';
|
555 |
+
} else {
|
556 |
+
// All other settings are 0|1.
|
557 |
+
$arr[ $post_type ] = ( isset( $_POST[ $post_var ] ) ) ? wpmem_sanitize_field( $_POST[ $post_var ], 'int' ) : 0;
|
558 |
+
}
|
559 |
+
}
|
560 |
+
$wpmem_newsettings[ $option_group_item ] = $arr;
|
561 |
+
}
|
562 |
+
|
563 |
+
/*
|
564 |
+
* If we are setting registration to be moderated,
|
565 |
+
* check to see if the current admin has been
|
566 |
+
* activated so they don't accidentally lock themselves
|
567 |
+
* out later.
|
568 |
+
*/
|
569 |
+
if ( isset( $_POST['wpmem_settings_moderate'] ) == 1 ) {
|
570 |
+
update_user_meta( get_current_user_id(), 'active', 1 );
|
571 |
+
}
|
572 |
+
|
573 |
+
if ( isset( $_POST['wpmem_settings_act_link'] ) == 1 ) {
|
574 |
+
update_user_meta( get_current_user_id(), '_wpmem_activation_confirm', time() );
|
575 |
+
}
|
576 |
+
|
577 |
+
WP_Members_Admin_Tab_Options::save_settings( $wpmem_newsettings );
|
578 |
+
|
579 |
+
return __( 'WP-Members settings were updated', 'wp-members' );
|
580 |
+
}
|
581 |
+
}
|
582 |
+
|
583 |
+
/**
|
584 |
+
* Puts new settings into the current object.
|
585 |
+
*
|
586 |
+
* @since 3.0.9
|
587 |
+
* @since 3.3.0 Ported from wpmem_admin_new_settings().
|
588 |
+
*
|
589 |
+
* @global $wpmem
|
590 |
+
* @param $new
|
591 |
+
* @return $settings
|
592 |
+
*/
|
593 |
+
static function save_settings( $new ) {
|
594 |
+
|
595 |
+
// Update saved settings.
|
596 |
+
update_option( 'wpmembers_settings', $new );
|
597 |
+
|
598 |
+
// Update the current WP_Members object with the new settings.
|
599 |
+
global $wpmem;
|
600 |
+
foreach ( $new as $key => $val ) {
|
601 |
+
if ( 'user_pages' == $key ) {
|
602 |
+
foreach ( $val as $subkey => $subval ) {
|
603 |
+
$val[ $subkey ] = ( is_numeric( $subval ) ) ? get_page_link( $subval ) : $subval;
|
604 |
+
}
|
605 |
+
}
|
606 |
+
$wpmem->{$key} = $val;
|
607 |
+
}
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Create the stylesheet dropdown selection.
|
612 |
+
*
|
613 |
+
* @since 2.8.0
|
614 |
+
* @since 3.3.0 Ported from wpmem_admin_style_list().
|
615 |
+
*
|
616 |
+
* @param $style string The stored stylesheet setting.
|
617 |
+
*/
|
618 |
+
static function style_list( $style ) {
|
619 |
+
|
620 |
+
$list = array(
|
621 |
+
'No Float' => 'generic-no-float',
|
622 |
+
'Rigid' => 'generic-rigid',
|
623 |
+
'Twenty Sixteen - no float' => 'wp-members-2016-no-float',
|
624 |
+
'Twenty Fifteen' => 'wp-members-2015',
|
625 |
+
'Twenty Fifteen - no float' => 'wp-members-2015-no-float',
|
626 |
+
'Twenty Fourteen' => 'wp-members-2014',
|
627 |
+
'Twenty Fourteen - no float' => 'wp-members-2014-no-float',
|
628 |
+
//'Twenty Thirteen' => WPMEM_DIR . 'css/wp-members-2013.css',
|
629 |
+
//'Twenty Twelve' => WPMEM_DIR . 'css/wp-members-2012.css',
|
630 |
+
//'Twenty Eleven' => WPMEM_DIR . 'css/wp-members-2011.css',
|
631 |
+
//'Twenty Ten' => WPMEM_DIR . 'css/wp-members.css',
|
632 |
+
//'Kubrick' => WPMEM_DIR . 'css/wp-members-kubrick.css',
|
633 |
+
);
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Filters the list of stylesheets in the plugin options dropdown.
|
637 |
+
*
|
638 |
+
* @since 2.8.0
|
639 |
+
* @deprecated 3.3.0 There is no way to manage custom values in the dropdown with the new setting rules.
|
640 |
+
*
|
641 |
+
* @param array $list An array of stylesheets that can be applied to the plugin's forms.
|
642 |
+
*/
|
643 |
+
//$list = apply_filters( 'wpmem_admin_style_list', $list );
|
644 |
+
|
645 |
+
$selected = false;
|
646 |
+
foreach ( $list as $name => $location ) {
|
647 |
+
$selected = ( $location == $style ) ? true : $selected;
|
648 |
+
echo '<option value="' . $location . '" ' . selected( $location, $style ) . '>' . $name . "</option>\n";
|
649 |
+
}
|
650 |
+
$selected = ( ! $selected ) ? ' selected' : '';
|
651 |
+
echo '<option value="use_custom"' . $selected . '>' . __( 'USE CUSTOM URL BELOW', 'wp-members' ) . '</option>';
|
652 |
+
|
653 |
+
return;
|
654 |
+
}
|
655 |
+
|
656 |
+
/**
|
657 |
+
* Create a dropdown selection of pages.
|
658 |
+
*
|
659 |
+
* @since 2.8.1
|
660 |
+
* @since 3.3.0 Ported from wpmem_admin_page_list().
|
661 |
+
*
|
662 |
+
* @todo Consider wp_dropdown_pages. Can be retrieved as HTML (echo=false) and str_replaced to add custom values.
|
663 |
+
*
|
664 |
+
* @param string $val
|
665 |
+
*/
|
666 |
+
static function page_list( $val, $show_custom_url = true ) {
|
667 |
+
|
668 |
+
$selected = ( $val == 'http://' || $val == 'https://' ) ? 'select a page' : false;
|
669 |
+
$pages = get_pages();
|
670 |
+
|
671 |
+
echo '<option value=""'; echo ( $selected == 'select a page' ) ? ' selected' : ''; echo '>'; echo esc_attr( __( 'Select a page', 'wp-members' ) ); echo '</option>';
|
672 |
+
|
673 |
+
foreach ( $pages as $page ) {
|
674 |
+
$selected = ( get_page_link( $page->ID ) == $val ) ? true : $selected; //echo "VAL: " . $val . ' PAGE LINK: ' . get_page_link( $page->ID );
|
675 |
+
$option = '<option value="' . $page->ID . '"' . selected( get_page_link( $page->ID ), $val, 'select' ) . '>';
|
676 |
+
$option .= $page->post_title;
|
677 |
+
$option .= '</option>';
|
678 |
+
echo $option;
|
679 |
+
}
|
680 |
+
if ( $show_custom_url ) {
|
681 |
+
$selected = ( ! $selected ) ? ' selected' : '';
|
682 |
+
echo '<option value="use_custom"' . $selected . '>' . __( 'USE CUSTOM URL BELOW', 'wp-members' ) . '</option>';
|
683 |
+
}
|
684 |
+
}
|
685 |
+
|
|
|
|
|
|
|
|
|
|
|
686 |
} // End of file.
|
@@ -4,12 +4,12 @@
|
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @author Chad Butler
|
12 |
-
* @copyright 2006-
|
13 |
*/
|
14 |
|
15 |
// Exit if accessed directly.
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @author Chad Butler
|
12 |
+
* @copyright 2006-2021
|
13 |
*/
|
14 |
|
15 |
// Exit if accessed directly.
|
@@ -1,168 +1,168 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members WP_Members_Fields_Table class
|
4 |
-
*
|
5 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
-
*
|
10 |
-
* @package WP-Members
|
11 |
-
* @author Chad Butler
|
12 |
-
* @copyright 2006-
|
13 |
-
*/
|
14 |
-
|
15 |
-
// Exit if accessed directly.
|
16 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
-
exit();
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Extends the WP_List_Table to create a table of form fields.
|
22 |
-
*
|
23 |
-
* @since 3.1.8
|
24 |
-
*/
|
25 |
-
class WP_Members_Fields_Table extends WP_List_Table {
|
26 |
-
|
27 |
-
private $excludes = array( 'user_registered', '_wpmem_user_confirmed', 'active', 'wpmem_reg_ip', 'exp_type', 'expires', 'user_id' );
|
28 |
-
|
29 |
-
private $no_delete = array( 'username', 'user_email', 'first_name', 'last_name', 'user_url' );
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Checkbox at start of row.
|
33 |
-
*
|
34 |
-
* @since 3.1.8
|
35 |
-
*
|
36 |
-
* @param $item
|
37 |
-
* @return string The checkbox.
|
38 |
-
*/
|
39 |
-
function column_cb( $item ) {
|
40 |
-
if ( in_array( $item['meta'], $this->no_delete ) || in_array( $item['meta'], $this->excludes ) ) {
|
41 |
-
return;
|
42 |
-
} else {
|
43 |
-
return sprintf( '<input type="checkbox" name="delete[]" value="%s" title="%s" />', $item['meta'], __( 'delete', 'wp-members' ) );
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Returns table columns.
|
49 |
-
*
|
50 |
-
* @since 3.1.8
|
51 |
-
*
|
52 |
-
* @return array
|
53 |
-
*/
|
54 |
-
function get_columns() {
|
55 |
-
return array(
|
56 |
-
'cb' => '<input type="checkbox" />',
|
57 |
-
'label' => __( 'Display Label', 'wp-members' ),
|
58 |
-
'meta' => __( 'Meta Key', 'wp-members' ),
|
59 |
-
'type' => __( 'Field Type', 'wp-members' ),
|
60 |
-
'display' => __( 'Display?', 'wp-members' ), // __( 'Registration', 'wp-members' ), @todo Wait until fix
|
61 |
-
'req' => __( 'Required', 'wp-members' ),
|
62 |
-
//'profile' => __( 'Profile', 'wp-members' ), @todo Wait until fix
|
63 |
-
'userscrn' => __( 'Users Screen', 'wp-members' ),
|
64 |
-
'usearch' => __( 'Users Search', 'wp-members' ),
|
65 |
-
'edit' => __( 'Edit', 'wp-members' ),
|
66 |
-
'sort' => __( 'Sort', 'wp-members' ),
|
67 |
-
);
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Set up table columns.
|
72 |
-
*
|
73 |
-
* @since 3.1.8
|
74 |
-
*/
|
75 |
-
function prepare_items() {
|
76 |
-
$columns = $this->get_columns();
|
77 |
-
$hidden = array();
|
78 |
-
$sortable = array();
|
79 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Iterates through the columns
|
84 |
-
*
|
85 |
-
* @since 3.1.8
|
86 |
-
*
|
87 |
-
* @param array $item
|
88 |
-
* @param string $column_name
|
89 |
-
* @return string $item[ $column_name ]
|
90 |
-
*/
|
91 |
-
function column_default( $item, $column_name ) {
|
92 |
-
switch( $column_name ) {
|
93 |
-
default:
|
94 |
-
return $item[ $column_name ];
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Sets actions in the bulk menu.
|
100 |
-
*
|
101 |
-
* @since 3.1.8
|
102 |
-
*
|
103 |
-
* @return array $actions
|
104 |
-
*/
|
105 |
-
function get_bulk_actions() {
|
106 |
-
$actions = array(
|
107 |
-
'delete' => __( 'Delete Selected', 'wp-members' ),
|
108 |
-
'save' => __( 'Save Settings', 'wp-members' ),
|
109 |
-
);
|
110 |
-
return $actions;
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Handles "delete" column - checkbox
|
115 |
-
*
|
116 |
-
* @since 3.1.8
|
117 |
-
*
|
118 |
-
* @param array $item
|
119 |
-
* @return string
|
120 |
-
*/
|
121 |
-
function column_delete( $item ) {
|
122 |
-
$can_delete = ( $item['meta_key'] == 'user_nicename' || $item['meta_key'] == 'display_name' || $item['meta_key'] == 'nickname' ) ? true : false;
|
123 |
-
return ( ( $can_delete ) || ! $item['native'] ) ? sprintf( $item['native'] . '<input type="checkbox" name="field[%s]" value="delete" />', $item['meta'] ) : '';
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Sets rows so that they have field IDs in the id.
|
128 |
-
*
|
129 |
-
* @since 3.1.8
|
130 |
-
*
|
131 |
-
* @global wpmem
|
132 |
-
* @param array $columns
|
133 |
-
*/
|
134 |
-
function single_row( $columns ) {
|
135 |
-
if ( in_array( $columns['meta'], $this->excludes ) ) {
|
136 |
-
echo '<tr id="' . esc_attr( $columns['meta'] ) . '" class="nodrag nodrop">';
|
137 |
-
echo $this->single_row_columns( $columns );
|
138 |
-
echo "</tr>\n";
|
139 |
-
} else {
|
140 |
-
echo '<tr id="list_items_' . esc_attr( $columns['order'] ) . '" class="list_item" list_item="' . esc_attr( $columns['order'] ) . '">';
|
141 |
-
echo $this->single_row_columns( $columns );
|
142 |
-
echo "</tr>\n";
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
public function process_bulk_action() {
|
147 |
-
|
148 |
-
//nonce validations,etc
|
149 |
-
|
150 |
-
$action = $this->current_action();
|
151 |
-
|
152 |
-
switch ( $action ) {
|
153 |
-
|
154 |
-
case 'delete':
|
155 |
-
|
156 |
-
// Do whatever you want
|
157 |
-
wp_safe_redirect( esc_url( add_query_arg() ) );
|
158 |
-
break;
|
159 |
-
|
160 |
-
default:
|
161 |
-
// do nothing or something else
|
162 |
-
return;
|
163 |
-
break;
|
164 |
-
}
|
165 |
-
return;
|
166 |
-
}
|
167 |
-
|
168 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members WP_Members_Fields_Table class
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @author Chad Butler
|
12 |
+
* @copyright 2006-2021
|
13 |
+
*/
|
14 |
+
|
15 |
+
// Exit if accessed directly.
|
16 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
17 |
+
exit();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Extends the WP_List_Table to create a table of form fields.
|
22 |
+
*
|
23 |
+
* @since 3.1.8
|
24 |
+
*/
|
25 |
+
class WP_Members_Fields_Table extends WP_List_Table {
|
26 |
+
|
27 |
+
private $excludes = array( 'user_registered', '_wpmem_user_confirmed', 'active', 'wpmem_reg_ip', 'exp_type', 'expires', 'user_id' );
|
28 |
+
|
29 |
+
private $no_delete = array( 'username', 'user_email', 'first_name', 'last_name', 'user_url' );
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Checkbox at start of row.
|
33 |
+
*
|
34 |
+
* @since 3.1.8
|
35 |
+
*
|
36 |
+
* @param $item
|
37 |
+
* @return string The checkbox.
|
38 |
+
*/
|
39 |
+
function column_cb( $item ) {
|
40 |
+
if ( in_array( $item['meta'], $this->no_delete ) || in_array( $item['meta'], $this->excludes ) ) {
|
41 |
+
return;
|
42 |
+
} else {
|
43 |
+
return sprintf( '<input type="checkbox" name="delete[]" value="%s" title="%s" />', $item['meta'], __( 'delete', 'wp-members' ) );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Returns table columns.
|
49 |
+
*
|
50 |
+
* @since 3.1.8
|
51 |
+
*
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
function get_columns() {
|
55 |
+
return array(
|
56 |
+
'cb' => '<input type="checkbox" />',
|
57 |
+
'label' => __( 'Display Label', 'wp-members' ),
|
58 |
+
'meta' => __( 'Meta Key', 'wp-members' ),
|
59 |
+
'type' => __( 'Field Type', 'wp-members' ),
|
60 |
+
'display' => __( 'Display?', 'wp-members' ), // __( 'Registration', 'wp-members' ), @todo Wait until fix
|
61 |
+
'req' => __( 'Required', 'wp-members' ),
|
62 |
+
//'profile' => __( 'Profile', 'wp-members' ), @todo Wait until fix
|
63 |
+
'userscrn' => __( 'Users Screen', 'wp-members' ),
|
64 |
+
'usearch' => __( 'Users Search', 'wp-members' ),
|
65 |
+
'edit' => __( 'Edit', 'wp-members' ),
|
66 |
+
'sort' => __( 'Sort', 'wp-members' ),
|
67 |
+
);
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Set up table columns.
|
72 |
+
*
|
73 |
+
* @since 3.1.8
|
74 |
+
*/
|
75 |
+
function prepare_items() {
|
76 |
+
$columns = $this->get_columns();
|
77 |
+
$hidden = array();
|
78 |
+
$sortable = array();
|
79 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Iterates through the columns
|
84 |
+
*
|
85 |
+
* @since 3.1.8
|
86 |
+
*
|
87 |
+
* @param array $item
|
88 |
+
* @param string $column_name
|
89 |
+
* @return string $item[ $column_name ]
|
90 |
+
*/
|
91 |
+
function column_default( $item, $column_name ) {
|
92 |
+
switch( $column_name ) {
|
93 |
+
default:
|
94 |
+
return $item[ $column_name ];
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Sets actions in the bulk menu.
|
100 |
+
*
|
101 |
+
* @since 3.1.8
|
102 |
+
*
|
103 |
+
* @return array $actions
|
104 |
+
*/
|
105 |
+
function get_bulk_actions() {
|
106 |
+
$actions = array(
|
107 |
+
'delete' => __( 'Delete Selected', 'wp-members' ),
|
108 |
+
'save' => __( 'Save Settings', 'wp-members' ),
|
109 |
+
);
|
110 |
+
return $actions;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Handles "delete" column - checkbox
|
115 |
+
*
|
116 |
+
* @since 3.1.8
|
117 |
+
*
|
118 |
+
* @param array $item
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
function column_delete( $item ) {
|
122 |
+
$can_delete = ( $item['meta_key'] == 'user_nicename' || $item['meta_key'] == 'display_name' || $item['meta_key'] == 'nickname' ) ? true : false;
|
123 |
+
return ( ( $can_delete ) || ! $item['native'] ) ? sprintf( $item['native'] . '<input type="checkbox" name="field[%s]" value="delete" />', $item['meta'] ) : '';
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Sets rows so that they have field IDs in the id.
|
128 |
+
*
|
129 |
+
* @since 3.1.8
|
130 |
+
*
|
131 |
+
* @global wpmem
|
132 |
+
* @param array $columns
|
133 |
+
*/
|
134 |
+
function single_row( $columns ) {
|
135 |
+
if ( in_array( $columns['meta'], $this->excludes ) ) {
|
136 |
+
echo '<tr id="' . esc_attr( $columns['meta'] ) . '" class="nodrag nodrop">';
|
137 |
+
echo $this->single_row_columns( $columns );
|
138 |
+
echo "</tr>\n";
|
139 |
+
} else {
|
140 |
+
echo '<tr id="list_items_' . esc_attr( $columns['order'] ) . '" class="list_item" list_item="' . esc_attr( $columns['order'] ) . '">';
|
141 |
+
echo $this->single_row_columns( $columns );
|
142 |
+
echo "</tr>\n";
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
public function process_bulk_action() {
|
147 |
+
|
148 |
+
//nonce validations,etc
|
149 |
+
|
150 |
+
$action = $this->current_action();
|
151 |
+
|
152 |
+
switch ( $action ) {
|
153 |
+
|
154 |
+
case 'delete':
|
155 |
+
|
156 |
+
// Do whatever you want
|
157 |
+
wp_safe_redirect( esc_url( add_query_arg() ) );
|
158 |
+
break;
|
159 |
+
|
160 |
+
default:
|
161 |
+
// do nothing or something else
|
162 |
+
return;
|
163 |
+
break;
|
164 |
+
}
|
165 |
+
return;
|
166 |
+
}
|
167 |
+
|
168 |
}
|
@@ -4,13 +4,13 @@
|
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @subpackage WP-Members API Functions
|
12 |
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
*/
|
15 |
|
16 |
/**
|
@@ -41,6 +41,25 @@ function wpmem_mail_from_name() {
|
|
41 |
return $wpmem->email->from_name;
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
/**
|
45 |
* Builds emails for the user.
|
46 |
*
|
@@ -81,11 +100,11 @@ function wpmem_email_to_user( $args, $password = null, $tag = null, $wpmem_field
|
|
81 |
global $wpmem;
|
82 |
if ( is_array( $args ) ) {
|
83 |
$user_id = $args['user_id'];
|
84 |
-
$password = $args['password'];
|
85 |
$tag = $args['tag'];
|
86 |
-
$
|
87 |
-
$
|
88 |
-
$
|
|
|
89 |
} else {
|
90 |
$user_id = $args;
|
91 |
}
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @subpackage WP-Members API Functions
|
12 |
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
*/
|
15 |
|
16 |
/**
|
41 |
return $wpmem->email->from_name;
|
42 |
}
|
43 |
|
44 |
+
/**
|
45 |
+
* Returns the wp_mail content type (if set).
|
46 |
+
*
|
47 |
+
* @since 3.4.0
|
48 |
+
*
|
49 |
+
* @global object $wpmem
|
50 |
+
* @return string $wpmem_mail_content_type
|
51 |
+
*
|
52 |
+
* @note Currently checks for existing function. Advanced Options set up for
|
53 |
+
* backward compatibility could potentially load first if wp-members directory
|
54 |
+
* is named something other than "wp-members".
|
55 |
+
*/
|
56 |
+
if ( ! function_exists( 'wpmem_mail_content_type' ) ):
|
57 |
+
function wpmem_mail_content_type() {
|
58 |
+
global $wpmem;
|
59 |
+
return $wpmem->email->content_type();
|
60 |
+
}
|
61 |
+
endif;
|
62 |
+
|
63 |
/**
|
64 |
* Builds emails for the user.
|
65 |
*
|
100 |
global $wpmem;
|
101 |
if ( is_array( $args ) ) {
|
102 |
$user_id = $args['user_id'];
|
|
|
103 |
$tag = $args['tag'];
|
104 |
+
$password = ( isset( $args['password'] ) ) ? $args['password'] : '';
|
105 |
+
$wpmem_fields = ( isset( $args['wpmem_fields'] ) ) ? $args['wpmem_fields'] : '';
|
106 |
+
$field_data = ( isset( $args['field_data'] ) ) ? $args['field_data'] : '';
|
107 |
+
$custom = ( isset( $args['custom'] ) ) ? $args['custom'] : '';
|
108 |
} else {
|
109 |
$user_id = $args;
|
110 |
}
|
@@ -1,582 +1,634 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members API Functions
|
4 |
-
*
|
5 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
-
*
|
10 |
-
* @package WP-Members
|
11 |
-
* @subpackage WP-Members API Functions
|
12 |
-
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*/
|
15 |
-
|
16 |
-
if ( ! function_exists( 'wpmem_login_form' ) ):
|
17 |
-
/**
|
18 |
-
* Invokes a login form.
|
19 |
-
*
|
20 |
-
* Note: The original pluggable version of this function used a $page param
|
21 |
-
* and an array. This function should (1) no longer be considered pluggable
|
22 |
-
* and (2) should pass all arguments in the form if a single array. The previous
|
23 |
-
* methods are maintained for legacy reasons, but should be updated to apply
|
24 |
-
* to the current function documentation.
|
25 |
-
*
|
26 |
-
* @since 2.5.1
|
27 |
-
* @since 3.1.7 Now
|
28 |
-
* @since 3.3.0 Added to API.
|
29 |
-
*
|
30 |
-
*
|
31 |
-
* @
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
* @type string $
|
36 |
-
* @type string $
|
37 |
-
* @type string $
|
38 |
-
*
|
39 |
-
*
|
40 |
-
*
|
41 |
-
*
|
42 |
-
*
|
43 |
-
*
|
44 |
-
* @type string $
|
45 |
-
* @type string $
|
46 |
-
* @type
|
47 |
-
*
|
48 |
-
*
|
49 |
-
*
|
50 |
-
*
|
51 |
-
*
|
52 |
-
* @type string $
|
53 |
-
* @type string $
|
54 |
-
* @type string $
|
55 |
-
* @type string $
|
56 |
-
*
|
57 |
-
*
|
58 |
-
*
|
59 |
-
*
|
60 |
-
*
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
*
|
97 |
-
*
|
98 |
-
*
|
99 |
-
*
|
100 |
-
*
|
101 |
-
*
|
102 |
-
*
|
103 |
-
*
|
104 |
-
* @type string
|
105 |
-
*
|
106 |
-
*
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
*
|
122 |
-
*
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
*
|
180 |
-
*
|
181 |
-
*
|
182 |
-
*
|
183 |
-
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
*
|
205 |
-
*
|
206 |
-
*
|
207 |
-
*
|
208 |
-
*
|
209 |
-
*
|
210 |
-
*
|
211 |
-
* @type string $
|
212 |
-
* @type string $
|
213 |
-
* @type string $
|
214 |
-
* @type string $
|
215 |
-
* @type string $
|
216 |
-
* @type
|
217 |
-
* @type string $
|
218 |
-
*
|
219 |
-
*
|
220 |
-
*
|
221 |
-
*
|
222 |
-
*
|
223 |
-
*
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
*
|
252 |
-
*
|
253 |
-
*
|
254 |
-
*
|
255 |
-
*
|
256 |
-
*
|
257 |
-
*
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
*
|
273 |
-
*
|
274 |
-
* @
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
*
|
310 |
-
*
|
311 |
-
*
|
312 |
-
*
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
*
|
321 |
-
*
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
*
|
329 |
-
*
|
330 |
-
*
|
331 |
-
*
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
*
|
340 |
-
*
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
*
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
*
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
'
|
386 |
-
'
|
387 |
-
'
|
388 |
-
'
|
389 |
-
'
|
390 |
-
'
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
case '
|
494 |
-
update_user_meta( $user_id, $meta_key,
|
495 |
-
break;
|
496 |
-
case '
|
497 |
-
|
498 |
-
break;
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
break;
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
}
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
* @type string $
|
523 |
-
* @type string $
|
524 |
-
* @type string $
|
525 |
-
* @type string $
|
526 |
-
* @type string $
|
527 |
-
* @type
|
528 |
-
* @type string $
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
'type'
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
+
*/
|
15 |
+
|
16 |
+
if ( ! function_exists( 'wpmem_login_form' ) ):
|
17 |
+
/**
|
18 |
+
* Invokes a login form.
|
19 |
+
*
|
20 |
+
* Note: The original pluggable version of this function used a $page param
|
21 |
+
* and an array. This function should (1) no longer be considered pluggable
|
22 |
+
* and (2) should pass all arguments in the form if a single array. The previous
|
23 |
+
* methods are maintained for legacy reasons, but should be updated to apply
|
24 |
+
* to the current function documentation.
|
25 |
+
*
|
26 |
+
* @since 2.5.1
|
27 |
+
* @since 3.1.7 Now an alias for $wpmem->forms->login_form()
|
28 |
+
* @since 3.3.0 Added to API.
|
29 |
+
* @since 3.4.0 Main API function for displaying login form.
|
30 |
+
*
|
31 |
+
* @global object $wpmem
|
32 |
+
* @param array $args {
|
33 |
+
* Possible arguments for creating the form.
|
34 |
+
*
|
35 |
+
* @type string $id
|
36 |
+
* @type string $tag
|
37 |
+
* @type string $form
|
38 |
+
* @type string $redirect_to
|
39 |
+
* }
|
40 |
+
* @param array $arr {
|
41 |
+
* Maintained only for legacy reasons.
|
42 |
+
* The elements needed to generate the form (login|reset password|forgotten password).
|
43 |
+
*
|
44 |
+
* @type string $heading Form heading text.
|
45 |
+
* @type string $action The form action (login|pwdchange|pwdreset).
|
46 |
+
* @type string $button_text Form submit button text.
|
47 |
+
* @type array $inputs {
|
48 |
+
* The form input values.
|
49 |
+
*
|
50 |
+
* @type array {
|
51 |
+
*
|
52 |
+
* @type string $name The field label.
|
53 |
+
* @type string $type Input type.
|
54 |
+
* @type string $tag Input tag name.
|
55 |
+
* @type string $class Input tag class.
|
56 |
+
* @type string $div Div wrapper class.
|
57 |
+
* }
|
58 |
+
* }
|
59 |
+
* @type string $redirect_to Optional. URL to redirect to.
|
60 |
+
* }
|
61 |
+
* @return string $form The HTML for the form as a string.
|
62 |
+
*/
|
63 |
+
function wpmem_login_form( $args = array(), $arr = false ) {
|
64 |
+
global $wpmem;
|
65 |
+
|
66 |
+
/*
|
67 |
+
// Convert legacy values.
|
68 |
+
if ( ( ! is_array( $args ) && is_array( $arr ) ) || ( is_array( $args ) && empty( $args ) ) ) {
|
69 |
+
$page = $args;
|
70 |
+
$args = $arr;
|
71 |
+
$args['page'] = $page;
|
72 |
+
}
|
73 |
+
$args['form'] = ( isset( $args['form'] ) ) ? $args['form'] : 'login';
|
74 |
+
// @todo Work on making this $wpmem->forms->do_login_form( $args );
|
75 |
+
return $wpmem->forms->login_form( $args );
|
76 |
+
*/
|
77 |
+
|
78 |
+
return $wpmem->forms->do_shortform( 'login', $args );
|
79 |
+
}
|
80 |
+
endif;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Use the WP login form.
|
84 |
+
*
|
85 |
+
* @since 3.3.2
|
86 |
+
*
|
87 |
+
* @global stdClass $wpmem
|
88 |
+
* @param array $args
|
89 |
+
*/
|
90 |
+
function wpmem_wp_login_form( $args ) {
|
91 |
+
global $wpmem;
|
92 |
+
return $wpmem->forms->wp_login_form( $args );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Invokes a registration or user profile update form.
|
97 |
+
*
|
98 |
+
* @since 3.2.0
|
99 |
+
*
|
100 |
+
* @global object $wpmem
|
101 |
+
* @param array $args {
|
102 |
+
* Possible arguments for creating the form.
|
103 |
+
*
|
104 |
+
* @type string id
|
105 |
+
* @type string tag
|
106 |
+
* @type string form
|
107 |
+
* @type string product
|
108 |
+
* @type string include_fields
|
109 |
+
* @type string exclude_fields
|
110 |
+
* @type string redirect_to
|
111 |
+
* @type string heading
|
112 |
+
* }
|
113 |
+
* @return string $html
|
114 |
+
*/
|
115 |
+
function wpmem_register_form( $args = 'new' ) {
|
116 |
+
global $wpmem;
|
117 |
+
return $wpmem->forms->register_form( $args );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Change Password Form.
|
122 |
+
*
|
123 |
+
* @since 3.3.0 Replaces wpmem_inc_changepassword().
|
124 |
+
* @since 3.3.0 Added $action argument.
|
125 |
+
*
|
126 |
+
* @global stdClass $wpmem The WP_Members object.
|
127 |
+
*
|
128 |
+
* @param string $action Determine if it is password change or reset.
|
129 |
+
* @return string $str The generated html for the change password form.
|
130 |
+
*/
|
131 |
+
function wpmem_change_password_form() {
|
132 |
+
global $wpmem;
|
133 |
+
return $wpmem->forms->do_shortform( 'changepassword' );
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Reset Password Form.
|
138 |
+
*
|
139 |
+
* @since 3.3.0 Replaced wpmem_inc_resetpassword().
|
140 |
+
*
|
141 |
+
* @global object $wpmem The WP_Members object.
|
142 |
+
* @return string $str The generated html fo the reset password form.
|
143 |
+
*/
|
144 |
+
function wpmem_reset_password_form() {
|
145 |
+
global $wpmem;
|
146 |
+
return $wpmem->forms->do_shortform( 'resetpassword' );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Forgot Username Form.
|
151 |
+
*
|
152 |
+
* @since 3.3.0 Replaced wpmem_inc_forgotusername().
|
153 |
+
*
|
154 |
+
* @global object $wpmem The WP_Members object class.
|
155 |
+
* @return string $str The generated html for the forgot username form.
|
156 |
+
*/
|
157 |
+
function wpmem_forgot_username_form() {
|
158 |
+
global $wpmem;
|
159 |
+
return $wpmem->forms->do_shortform( 'forgotusername' );
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Add registration fields to the native WP registration.
|
164 |
+
*
|
165 |
+
* @since 2.8.3
|
166 |
+
* @since 3.1.8 Added $process argument.
|
167 |
+
* @since 3.3.0 Moved to forms API.
|
168 |
+
*
|
169 |
+
* @global stdClass $wpmem
|
170 |
+
* @param string $process
|
171 |
+
*/
|
172 |
+
function wpmem_wp_register_form( $process = 'register_wp' ) {
|
173 |
+
global $wpmem;
|
174 |
+
$wpmem->forms->wp_register_form( $process );
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Add registration fields to WooCommerce registration.
|
179 |
+
*
|
180 |
+
* As of WooCommerce 3.0, the WC registration process no longer includes the
|
181 |
+
* WP register_form action hook. It only includes woocommerce_register_form.
|
182 |
+
* In previous versions, WP-Members hooked to register_form for both WP and
|
183 |
+
* WC registration. To provide backward compatibility with users who may
|
184 |
+
* continue to use updated WP-Members with pre-3.0 WooCommerce, this function
|
185 |
+
* checks for WC version and if it is older than 3.0 it will ignore adding
|
186 |
+
* the WP-Members form fields as they would have already been added when the
|
187 |
+
* register_form action hook fired.
|
188 |
+
*
|
189 |
+
* @since 3.1.8
|
190 |
+
* @since 3.3.0 Moved to forms API.
|
191 |
+
*
|
192 |
+
* @global stdClass $woocommerce
|
193 |
+
*/
|
194 |
+
function wpmem_woo_register_form() {
|
195 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
196 |
+
global $woocommerce;
|
197 |
+
if ( version_compare( $woocommerce->version, '3.0', ">=" ) ) {
|
198 |
+
wpmem_wp_register_form( 'woo' );
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Alias for $wpmem->create_form_field().
|
205 |
+
*
|
206 |
+
* @since 3.1.2
|
207 |
+
* @since 3.2.0 Accepts wpmem_create_formfield() arguments.
|
208 |
+
*
|
209 |
+
* @global object $wpmem The WP_Members object class.
|
210 |
+
* @param string|array $args {
|
211 |
+
* @type string $name (required) The field meta key.
|
212 |
+
* @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
|
213 |
+
* @type string $value (optional) The field's value (can be a null value).
|
214 |
+
* @type string $compare (optional) Compare value.
|
215 |
+
* @type string $class (optional) Class identifier for the field.
|
216 |
+
* @type boolean $required (optional) If a value is required default: true).
|
217 |
+
* @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
|
218 |
+
* @type string $placeholder (optional) Defines the placeholder attribute.
|
219 |
+
* @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
|
220 |
+
* @type string $title (optional) Defines the title attribute.
|
221 |
+
* @type string $min (optional) Adds a min attribute (HTML5).
|
222 |
+
* @type string $max (optional) Adds a max attribute (HTML5).
|
223 |
+
* @type string $rows (optional) Adds rows attribute to textarea.
|
224 |
+
* @type string $cols (optional) Adds cols attribute to textarea.
|
225 |
+
* }
|
226 |
+
* @param string $type The field type.
|
227 |
+
* @param string $value The default value for the field.
|
228 |
+
* @param string $valtochk Optional for comparing the default value of the field.
|
229 |
+
* @param string $class Optional for setting a specific CSS class for the field.
|
230 |
+
* @return string The HTML of the form field.
|
231 |
+
*/
|
232 |
+
//function wpmem_form_field( $args ) {
|
233 |
+
function wpmem_form_field( $name, $type=null, $value=null, $valtochk=null, $class='textbox' ) {
|
234 |
+
global $wpmem;
|
235 |
+
if ( is_array( $name ) ) {
|
236 |
+
$args = $name;
|
237 |
+
} else {
|
238 |
+
$args = array(
|
239 |
+
'name' => $name,
|
240 |
+
'type' => $type,
|
241 |
+
'value' => $value,
|
242 |
+
'compare' => $valtochk,
|
243 |
+
'class' => $class,
|
244 |
+
);
|
245 |
+
}
|
246 |
+
return $wpmem->forms->create_form_field( $args );
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Wrapper for $wpmem->create_form_label().
|
251 |
+
*
|
252 |
+
* @since 3.1.7
|
253 |
+
*
|
254 |
+
* @global object $wpmem
|
255 |
+
* @param array $args {
|
256 |
+
* @type string $meta_key
|
257 |
+
* @type string $label
|
258 |
+
* @type string $type
|
259 |
+
* @type string $id (optional)
|
260 |
+
* @type string $class (optional)
|
261 |
+
* @type string $required (optional)
|
262 |
+
* @type string $req_mark (optional)
|
263 |
+
* }
|
264 |
+
* @return string The HTML of the form label.
|
265 |
+
*/
|
266 |
+
function wpmem_form_label( $args ) {
|
267 |
+
global $wpmem;
|
268 |
+
return $wpmem->forms->create_form_label( $args );
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Wrapper to get form fields.
|
273 |
+
*
|
274 |
+
* @since 3.1.1
|
275 |
+
* @since 3.1.5 Checks if fields array is set or empty before returning.
|
276 |
+
* @since 3.1.7 Added wpmem_form_fields filter.
|
277 |
+
* @since 3.3.9 load_fields() moved to forms object class.
|
278 |
+
*
|
279 |
+
* @global object $wpmem The WP_Members object.
|
280 |
+
* @param string $tag The action being used (default: null).
|
281 |
+
* @param string $form The form being generated.
|
282 |
+
* @return array $fields The form fields.
|
283 |
+
*/
|
284 |
+
function wpmem_fields( $tag = '', $form = 'default' ) {
|
285 |
+
global $wpmem;
|
286 |
+
// Load fields if none are loaded.
|
287 |
+
if ( ! isset( $wpmem->fields ) || empty( $wpmem->fields ) ) {
|
288 |
+
$wpmem->forms->load_fields( $form );
|
289 |
+
}
|
290 |
+
|
291 |
+
// @todo Review for removal.
|
292 |
+
$tag = $wpmem->convert_tag( $tag );
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Filters the fields array.
|
296 |
+
*
|
297 |
+
* @since 3.1.7
|
298 |
+
* @since 3.3.2 Change object var and return.
|
299 |
+
*
|
300 |
+
* @param array $wpmem->fields
|
301 |
+
* @param string $tag (optional)
|
302 |
+
*/
|
303 |
+
$wpmem->fields = apply_filters( 'wpmem_fields', $wpmem->fields, $tag );
|
304 |
+
|
305 |
+
return $wpmem->fields;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Sanitizes classes passed to the WP-Members form building functions.
|
310 |
+
*
|
311 |
+
* This generally uses just sanitize_html_class() but allows for
|
312 |
+
* whitespace so multiple classes can be passed (such as "regular-text code").
|
313 |
+
* This is an API wrapper for WP_Members_Forms::sanitize_class().
|
314 |
+
*
|
315 |
+
* @since 3.2.9
|
316 |
+
* @since 3.4.0 Now an alias for rktgk_sanitize_class().
|
317 |
+
*
|
318 |
+
* @global object $wpmem
|
319 |
+
*
|
320 |
+
* @param string $class
|
321 |
+
* @return string sanitized_class
|
322 |
+
*/
|
323 |
+
function wpmem_sanitize_class( $class ) {
|
324 |
+
return rktgk_sanitize_class( $class );
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Sanitizes the text in an array.
|
329 |
+
*
|
330 |
+
* This is an API wrapper for WP_Members_Forms::sanitize_array().
|
331 |
+
*
|
332 |
+
* @since 3.2.9
|
333 |
+
* @since 3.3.7 Added optional $type
|
334 |
+
* @since 3.4.0 Now an alias for rktgk_sanitize_array().
|
335 |
+
*
|
336 |
+
* @global object $wpmem
|
337 |
+
*
|
338 |
+
* @param array $data
|
339 |
+
* @param string $type The data type integer|int (default: false)
|
340 |
+
* @return array $data
|
341 |
+
*/
|
342 |
+
function wpmem_sanitize_array( $data, $type = false ) {
|
343 |
+
return rktgk_sanitize_array( $data, $type );
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* A multi use sanitization function.
|
348 |
+
*
|
349 |
+
* @since 3.3.0
|
350 |
+
*
|
351 |
+
* @global object $wpmem
|
352 |
+
*
|
353 |
+
* @param string $data
|
354 |
+
* @param string $type (multiselect|multicheckbox|textarea|email|file|image|int|integer|number)
|
355 |
+
* @return string $sanitized_data
|
356 |
+
*/
|
357 |
+
function wpmem_sanitize_field( $data, $type = 'text' ) {
|
358 |
+
return rktgk_sanitize_field( $data, $type );
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Generate a form nonce.
|
363 |
+
*
|
364 |
+
* @since 3.3.0
|
365 |
+
*
|
366 |
+
* @param string $nonce
|
367 |
+
* @param boolean $echo
|
368 |
+
* @return string The nonce.
|
369 |
+
*/
|
370 |
+
function wpmem_form_nonce( $nonce, $echo = false ) {
|
371 |
+
$form = ( 'update' == $nonce || 'register' == $nonce ) ? 'longform' : 'shortform';
|
372 |
+
return wp_nonce_field( 'wpmem_' . $form . '_nonce', '_wpmem_' . $nonce . '_nonce', true, $echo );
|
373 |
+
}
|
374 |
+
|
375 |
+
// @todo Experimental
|
376 |
+
/**
|
377 |
+
* Create WP-Members fields set for woo checkout.
|
378 |
+
*
|
379 |
+
* @since 3.3.4
|
380 |
+
*
|
381 |
+
* @param array $checkout_fields
|
382 |
+
*/
|
383 |
+
function wpmem_woo_checkout_fields( $checkout_fields = false ) {
|
384 |
+
$woo_checkout = array(
|
385 |
+
'billing_first_name',
|
386 |
+
'billing_last_name',
|
387 |
+
'billing_company',
|
388 |
+
'billing_country',
|
389 |
+
'billing_address_1',
|
390 |
+
'billing_address_2',
|
391 |
+
'billing_city',
|
392 |
+
'billing_state',
|
393 |
+
'billing_postcode',
|
394 |
+
'billing_phone',
|
395 |
+
'billing_email',
|
396 |
+
'account_username',
|
397 |
+
'account_password',
|
398 |
+
);
|
399 |
+
$fields = wpmem_fields();
|
400 |
+
|
401 |
+
if ( ! $checkout_fields ) {
|
402 |
+
$checkout_fields = WC()->checkout()->checkout_fields;
|
403 |
+
}
|
404 |
+
|
405 |
+
foreach ( $fields as $meta_key => $field ) {
|
406 |
+
|
407 |
+
if ( 1 != $fields[ $meta_key ]['register'] ) {
|
408 |
+
unset( $fields[ $meta_key ] );
|
409 |
+
} else {
|
410 |
+
if ( isset( $checkout_fields['billing'][ $meta_key ] ) ) {
|
411 |
+
unset( $fields[ $meta_key ] );
|
412 |
+
}
|
413 |
+
if ( isset( $checkout_fields['shipping'][ $meta_key ] ) ) {
|
414 |
+
unset( $fields[ $meta_key ] );
|
415 |
+
}
|
416 |
+
if ( isset( $checkout_fields['account'][ $meta_key ] ) ) {
|
417 |
+
unset( $fields[ $meta_key ] );
|
418 |
+
}
|
419 |
+
if ( isset( $checkout_fields['order'][ $meta_key ] ) ) {
|
420 |
+
unset( $fields[ $meta_key ] );
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
// @todo For now, remove any unsupported field types.
|
425 |
+
if ( 'hidden' == $field['type'] || 'image' == $field['type'] || 'file' == $field['type'] || 'membership' == $field['type'] ) {
|
426 |
+
unset( $fields[ $meta_key ] );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
unset( $fields['username'] );
|
430 |
+
unset( $fields['password'] );
|
431 |
+
unset( $fields['confirm_password'] );
|
432 |
+
unset( $fields['confirm_email'] );
|
433 |
+
unset( $fields['user_email'] );
|
434 |
+
unset( $fields['first_name'] );
|
435 |
+
unset( $fields['last_name'] );
|
436 |
+
|
437 |
+
return $fields;
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* Adds WP-Members custom fields to woo checkout.
|
442 |
+
*
|
443 |
+
* @since 3.3.4
|
444 |
+
*
|
445 |
+
* @param array $checkout_fields
|
446 |
+
*/
|
447 |
+
function wpmem_woo_checkout_form( $checkout_fields ) {
|
448 |
+
global $wpmem;
|
449 |
+
$fields = wpmem_woo_checkout_fields( $checkout_fields );
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Filters the initial WC priority of the WP-members added fields.
|
453 |
+
*
|
454 |
+
* @since 3.3.7
|
455 |
+
*
|
456 |
+
* @param int
|
457 |
+
*/
|
458 |
+
$priority = apply_filters( 'wpmem_wc_checkout_field_priority_seed', 10 );
|
459 |
+
|
460 |
+
foreach ( $fields as $meta_key => $field ) {
|
461 |
+
$checkout_fields['order'][ $meta_key ] = array(
|
462 |
+
'type' => $fields[ $meta_key ]['type'],
|
463 |
+
'label' => ( 'tos' == $meta_key ) ? $wpmem->forms->get_tos_link( $field, 'woo' ) : $fields[ $meta_key ]['label'],
|
464 |
+
'required' => $fields[ $meta_key ]['required'],
|
465 |
+
'priority' => $priority,
|
466 |
+
);
|
467 |
+
if ( isset( $fields[ $meta_key ]['placeholder'] ) ) {
|
468 |
+
$checkout_fields['order'][ $meta_key ]['placeholder'] = $fields[ $meta_key ]['placeholder'];
|
469 |
+
}
|
470 |
+
$priority = $priority + 10;
|
471 |
+
}
|
472 |
+
return $checkout_fields;
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Saves WP-Members custom fields for woo checkout.
|
477 |
+
*
|
478 |
+
* @since 3.3.4
|
479 |
+
*
|
480 |
+
* @param int $order_id
|
481 |
+
*/
|
482 |
+
function wpmem_woo_checkout_update_meta( $order_id ) {
|
483 |
+
|
484 |
+
// Get user id from order.
|
485 |
+
$order = wc_get_order( $order_id );
|
486 |
+
$user_id = $order->get_user_id();
|
487 |
+
|
488 |
+
$checkout_fields = WC()->checkout()->checkout_fields;
|
489 |
+
$fields = wpmem_fields();
|
490 |
+
foreach ( $fields as $meta_key => $field ) {
|
491 |
+
if ( isset( $checkout_fields['order'][ $meta_key ] ) && isset( $_POST[ $meta_key ] ) ) {
|
492 |
+
switch ( $fields[ $meta_key ]['type'] ) {
|
493 |
+
case 'checkbox':
|
494 |
+
update_user_meta( $user_id, $meta_key, $field['checked_value'] );
|
495 |
+
break;
|
496 |
+
case 'textarea':
|
497 |
+
update_user_meta( $user_id, $meta_key, sanitize_textarea_field( $_POST[ $meta_key ] ) );
|
498 |
+
break;
|
499 |
+
case 'multicheckbox':
|
500 |
+
case 'multiselect':
|
501 |
+
update_user_meta( $user_id, $meta_key, wpmem_sanitize_array( $_POST[ $meta_key ] ) );
|
502 |
+
break;
|
503 |
+
case 'membership':
|
504 |
+
wpmem_set_user_product( wpmem_sanitize_array( $_POST[ $meta_key ] ), $user_id );
|
505 |
+
break;
|
506 |
+
default:
|
507 |
+
if ( 'user_url' == $meta_key ) {
|
508 |
+
wp_update_user( array( 'ID' => $user_id, 'user_url' => sanitize_text_field( $_POST[ $meta_key ] ) ) );
|
509 |
+
} else {
|
510 |
+
update_user_meta( $user_id, $meta_key, sanitize_text_field( $_POST[ $meta_key ] ) );
|
511 |
+
}
|
512 |
+
break;
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
function wpmem_form_field_wc_custom_field_types( $field, $key, $args, $value ) {
|
519 |
+
|
520 |
+
$wpmem_fields = wpmem_fields();
|
521 |
+
/**
|
522 |
+
* @type string $name (required) The field meta key.
|
523 |
+
* @type string $type (required) The field HTML type (url, email, image, file, checkbox, text, textarea, password, hidden, select, multiselect, multicheckbox, radio).
|
524 |
+
* @type string $value (optional) The field's value (can be a null value).
|
525 |
+
* @type string $compare (optional) Compare value.
|
526 |
+
* @type string $class (optional) Class identifier for the field.
|
527 |
+
* @type boolean $required (optional) If a value is required default: true).
|
528 |
+
* @type string $delimiter (optional) The field delimiter (pipe or comma, default: | ).
|
529 |
+
* @type string $placeholder (optional) Defines the placeholder attribute.
|
530 |
+
* @type string $pattern (optional) Adds a regex pattern to the field (HTML5).
|
531 |
+
* @type string $title (optional) Defines the title attribute.
|
532 |
+
* @type string $min (optional) Adds a min attribute (HTML5).
|
533 |
+
* @type string $max (optional) Adds a max attribute (HTML5).
|
534 |
+
* @type string $rows (optional) Adds rows attribute to textarea.
|
535 |
+
* @type string $cols (optional) Adds cols attribute to textarea.
|
536 |
+
*/
|
537 |
+
|
538 |
+
// Let's only mess with WP-Members fields (in case another checkout fields plugin is used).
|
539 |
+
if ( array_key_exists( $key, $wpmem_fields ) ) {
|
540 |
+
|
541 |
+
// If it is a checkbox.
|
542 |
+
if ( 'checkbox' == $wpmem_fields[ $key ]['type'] ) {
|
543 |
+
|
544 |
+
if ( ! $_POST && $wpmem_fields[ $key ]['checked_default'] ) {
|
545 |
+
$field = str_replace( '<input type="checkbox"', '<input type="checkbox" checked ', $field );
|
546 |
+
}
|
547 |
+
|
548 |
+
} else {
|
549 |
+
|
550 |
+
$field_args = array(
|
551 |
+
'name' => $key,
|
552 |
+
'type' => $wpmem_fields[ $key ]['type'],
|
553 |
+
'required' => $wpmem_fields[ $key ]['required'],
|
554 |
+
'delimiter' => $wpmem_fields[ $key ]['delimiter'],
|
555 |
+
'value' => $wpmem_fields[ $key ]['values'],
|
556 |
+
);
|
557 |
+
|
558 |
+
$field_html = wpmem_form_field( $field_args );
|
559 |
+
$field_html = str_replace( 'class="' . $wpmem_fields[ $key ]['type'] . '"', 'class="' . $wpmem_fields[ $key ]['type'] . '" style="display:initial;"', $field_html );
|
560 |
+
$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">
|
561 |
+
<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label'] . ( ( 1 == $wpmem_fields[ $key ]['required'] ) ? ' <abbr class="required" title="required">*</abbr>' : '' ) . '</label>';
|
562 |
+
$field .= $field_html;
|
563 |
+
$field .= '</p>';
|
564 |
+
}
|
565 |
+
|
566 |
+
}
|
567 |
+
|
568 |
+
return $field;
|
569 |
+
}
|
570 |
+
|
571 |
+
function wpmem_woo_reg_validate( $username, $email, $errors ) {
|
572 |
+
|
573 |
+
$fields = wpmem_woo_checkout_fields();
|
574 |
+
|
575 |
+
unset( $fields['username'] );
|
576 |
+
unset( $fields['password'] );
|
577 |
+
unset( $fields['confirm_password'] );
|
578 |
+
unset( $fields['user_email'] );
|
579 |
+
unset( $fields['first_name'] );
|
580 |
+
unset( $fields['last_name'] );
|
581 |
+
|
582 |
+
foreach ( $fields as $key => $field_args ) {
|
583 |
+
if ( 1 == $field_args['required'] && empty( $_POST[ $key ] ) ) {
|
584 |
+
$message = sprintf( __( '%s is a required field.', 'wp-members' ), '<strong>' . $field_args['label'] . '</strong>' );
|
585 |
+
$errors->add( $key, $message );
|
586 |
+
}
|
587 |
+
}
|
588 |
+
return $errors;
|
589 |
+
}
|
590 |
+
|
591 |
+
function wpmem_is_reg_form_showing() {
|
592 |
+
global $wpmem;
|
593 |
+
return ( true === $wpmem->reg_form_showing ) ? true : false;
|
594 |
+
}
|
595 |
+
|
596 |
+
function wpmem_field_display_value( $field, $type, $value, $echo = false ) {
|
597 |
+
$fields = wpmem_fields();
|
598 |
+
/**
|
599 |
+
* Filter the value.
|
600 |
+
*
|
601 |
+
* @since 3.4.0
|
602 |
+
*
|
603 |
+
* @param string $display_value
|
604 |
+
* @param string $field
|
605 |
+
* @param string $type
|
606 |
+
*/
|
607 |
+
$display_value = apply_filters( 'wpmem_' . $type . '_field_display', $fields[ $field ]['options'][ $value ], $field, $type );
|
608 |
+
if ( $echo ) {
|
609 |
+
echo $display_value;
|
610 |
+
} else {
|
611 |
+
return $display_value;
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
function wpmem_checkbox_field_display( $field, $value, $echo = false ) {
|
616 |
+
wpmem_field_display_value( $field, 'checkbox', $value, $echo );
|
617 |
+
}
|
618 |
+
|
619 |
+
function wpmem_select_field_display( $field, $value, $echo = false ) {
|
620 |
+
wpmem_field_display_value( $field, 'select', $value, $echo );
|
621 |
+
}
|
622 |
+
|
623 |
+
function wpmem_get_user_meta_select( $user_id, $field ) {
|
624 |
+
$value = wpmem_get_user_meta( $user_id, $field );
|
625 |
+
return wpmem_select_field_display( $field, $value );
|
626 |
+
}
|
627 |
+
|
628 |
+
function wpmem_get_user_meta_radio( $user_id, $field ) {
|
629 |
+
return wpmem_get_user_meta_select( $user_id, $field );
|
630 |
+
}
|
631 |
+
|
632 |
+
function wpmem_get_user_meta_multi( $user_id, $field ) {
|
633 |
+
|
634 |
}
|
@@ -1,42 +1,65 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members API Functions
|
4 |
-
*
|
5 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
-
*
|
10 |
-
* @package WP-Members
|
11 |
-
* @subpackage WP-Members API Functions
|
12 |
-
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Gets all posts by product key.
|
18 |
-
*
|
19 |
-
* @since Unknown
|
20 |
-
*
|
21 |
-
* @global stdClass $wpmem
|
22 |
-
* @param string $product_key
|
23 |
-
* @return array
|
24 |
-
*/
|
25 |
-
function wpmem_get_product_post_list( $product_key ) {
|
26 |
-
global $wpmem;
|
27 |
-
return $wpmem->membership->get_all_posts( $product_key );
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Gets the membership products for a given post.
|
32 |
-
*
|
33 |
-
* @since 3.3.7
|
34 |
-
*
|
35 |
-
* @global stdClass $wpmem
|
36 |
-
* @param integer $post_id
|
37 |
-
* @return array
|
38 |
-
*/
|
39 |
-
function wpmem_get_post_products( $post_id ) {
|
40 |
-
global $wpmem;
|
41 |
-
return $wpmem->membership->get_post_products( $post_id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Gets all posts by product key.
|
18 |
+
*
|
19 |
+
* @since Unknown
|
20 |
+
*
|
21 |
+
* @global stdClass $wpmem
|
22 |
+
* @param string $product_key
|
23 |
+
* @return array
|
24 |
+
*/
|
25 |
+
function wpmem_get_product_post_list( $product_key ) {
|
26 |
+
global $wpmem;
|
27 |
+
return $wpmem->membership->get_all_posts( $product_key );
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Gets the membership products for a given post.
|
32 |
+
*
|
33 |
+
* @since 3.3.7
|
34 |
+
*
|
35 |
+
* @global stdClass $wpmem
|
36 |
+
* @param integer $post_id
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
function wpmem_get_post_products( $post_id ) {
|
40 |
+
global $wpmem;
|
41 |
+
return $wpmem->membership->get_post_products( $post_id );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Gets access message if user does not have required membership.
|
46 |
+
*
|
47 |
+
* @since 3.4.0
|
48 |
+
*
|
49 |
+
* @global stdClass $wpmem
|
50 |
+
* @param array $post_products
|
51 |
+
* @return string $message
|
52 |
+
*/
|
53 |
+
function wpmem_get_access_message( $post_products ) {
|
54 |
+
global $wpmem;
|
55 |
+
return $wpmem->membership->get_access_message( $post_products );
|
56 |
+
}
|
57 |
+
|
58 |
+
function wpmem_get_products() {
|
59 |
+
return wpmem_get_memberships();
|
60 |
+
}
|
61 |
+
|
62 |
+
function wpmem_get_memberships() {
|
63 |
+
global $wpmem;
|
64 |
+
return ( ! empty( $wpmem->membership->products ) ) ? $wpmem->membership->products : false;
|
65 |
}
|
@@ -1,943 +1,971 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WP-Members User API Functions
|
4 |
-
*
|
5 |
-
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
-
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
-
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
-
*
|
10 |
-
* @package WP-Members
|
11 |
-
* @subpackage WP-Members API Functions
|
12 |
-
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*/
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Checks if a user exists.
|
18 |
-
*
|
19 |
-
* @since 3.2.5
|
20 |
-
*
|
21 |
-
* @param $user_id
|
22 |
-
* @return boolean
|
23 |
-
*/
|
24 |
-
function wpmem_is_user( $user_id ) {
|
25 |
-
$user = get_userdata( $user_id );
|
26 |
-
return ( $user ) ? true : false;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Returns the current user's current role.
|
31 |
-
*
|
32 |
-
* Note that users may have more than one role. This returns
|
33 |
-
* whatever the internal pointer is set to. Usually, this will
|
34 |
-
* be the first element in the array, but not always.
|
35 |
-
* @see: https://www.php.net/manual/en/function.current.php
|
36 |
-
*
|
37 |
-
* @since 3.3.0
|
38 |
-
*
|
39 |
-
* @param int $user_id
|
40 |
-
* @
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
*
|
51 |
-
*
|
52 |
-
*
|
53 |
-
*
|
54 |
-
*
|
55 |
-
*
|
56 |
-
*
|
57 |
-
*
|
58 |
-
* @since 3.1.
|
59 |
-
* @since 3.
|
60 |
-
*
|
61 |
-
* @
|
62 |
-
*
|
63 |
-
* @
|
64 |
-
* @
|
65 |
-
* @
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
$user = (
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
*
|
93 |
-
*
|
94 |
-
*
|
95 |
-
*
|
96 |
-
*
|
97 |
-
*
|
98 |
-
*
|
99 |
-
* @
|
100 |
-
*
|
101 |
-
* @
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
*
|
111 |
-
*
|
112 |
-
* @since 3.
|
113 |
-
*
|
114 |
-
* @
|
115 |
-
*
|
116 |
-
* @
|
117 |
-
*
|
118 |
-
* @param
|
119 |
-
* @
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
*
|
155 |
-
*
|
156 |
-
* @
|
157 |
-
*
|
158 |
-
* @param
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
*
|
167 |
-
*
|
168 |
-
*
|
169 |
-
* @
|
170 |
-
*
|
171 |
-
* @
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
*
|
182 |
-
*
|
183 |
-
*
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
* @
|
188 |
-
*
|
189 |
-
* @
|
190 |
-
* @
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
*
|
201 |
-
*
|
202 |
-
*
|
203 |
-
*
|
204 |
-
*
|
205 |
-
*
|
206 |
-
* @
|
207 |
-
*
|
208 |
-
* @
|
209 |
-
* @param
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
*
|
220 |
-
*
|
221 |
-
*
|
222 |
-
* @
|
223 |
-
*
|
224 |
-
* @
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
*
|
235 |
-
*
|
236 |
-
*
|
237 |
-
*
|
238 |
-
*
|
239 |
-
* @
|
240 |
-
*
|
241 |
-
* @
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
*
|
253 |
-
*
|
254 |
-
* @
|
255 |
-
* @
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
*
|
299 |
-
*
|
300 |
-
* @since 3.
|
301 |
-
*
|
302 |
-
* @
|
303 |
-
*
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
*
|
316 |
-
*
|
317 |
-
*
|
318 |
-
* @since
|
319 |
-
* @since
|
320 |
-
* @since
|
321 |
-
*
|
322 |
-
* @
|
323 |
-
* @
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
*
|
337 |
-
*
|
338 |
-
*
|
339 |
-
* @
|
340 |
-
*
|
341 |
-
* @
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
*
|
355 |
-
*
|
356 |
-
*
|
357 |
-
* @
|
358 |
-
*
|
359 |
-
*
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
*
|
373 |
-
*
|
374 |
-
*
|
375 |
-
* @
|
376 |
-
*
|
377 |
-
*
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
*
|
390 |
-
*
|
391 |
-
*
|
392 |
-
*
|
393 |
-
*
|
394 |
-
*
|
395 |
-
*
|
396 |
-
*
|
397 |
-
*
|
398 |
-
* @return string $
|
399 |
-
*/
|
400 |
-
function
|
401 |
-
global $wpmem;
|
402 |
-
return $wpmem->
|
403 |
-
}
|
404 |
-
|
405 |
-
/**
|
406 |
-
*
|
407 |
-
*
|
408 |
-
*
|
409 |
-
*
|
410 |
-
*
|
411 |
-
*
|
412 |
-
*
|
413 |
-
*
|
414 |
-
*
|
415 |
-
*
|
416 |
-
*
|
417 |
-
*
|
418 |
-
*
|
419 |
-
* @
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
//
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
*
|
492 |
-
*
|
493 |
-
* @since
|
494 |
-
* @since 3.
|
495 |
-
*
|
496 |
-
*
|
497 |
-
*
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
*
|
514 |
-
*
|
515 |
-
* @since
|
516 |
-
* @since 3.
|
517 |
-
*
|
518 |
-
*
|
519 |
-
*
|
520 |
-
*
|
521 |
-
* @
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
$
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
*
|
628 |
-
*
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
$wpmem->user->post_data['
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
$
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
*
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
*
|
798 |
-
*
|
799 |
-
*
|
800 |
-
*
|
801 |
-
* @param
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
$
|
806 |
-
|
807 |
-
}
|
808 |
-
|
809 |
-
/**
|
810 |
-
* Gets user
|
811 |
-
*
|
812 |
-
* @since 3.3.5
|
813 |
-
*
|
814 |
-
* @param mixed $user
|
815 |
-
* @return mixed
|
816 |
-
*/
|
817 |
-
function
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
*
|
885 |
-
*
|
886 |
-
* @
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
*
|
896 |
-
*
|
897 |
-
* @
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
*
|
907 |
-
*
|
908 |
-
* @
|
909 |
-
*
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
}
|
915 |
-
|
916 |
-
/**
|
917 |
-
* Sets user as
|
918 |
-
*
|
919 |
-
* @since 3.3.
|
920 |
-
*
|
921 |
-
* @param int
|
922 |
-
* @return void
|
923 |
-
*/
|
924 |
-
function
|
925 |
-
global $wpmem;
|
926 |
-
$wpmem->act_newreg->
|
927 |
-
}
|
928 |
-
|
929 |
-
/**
|
930 |
-
*
|
931 |
-
*
|
932 |
-
* @since 3.3.8
|
933 |
-
*
|
934 |
-
* @
|
935 |
-
* @
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
// End of file.
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WP-Members User API Functions
|
4 |
+
*
|
5 |
+
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
+
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
+
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
+
*
|
10 |
+
* @package WP-Members
|
11 |
+
* @subpackage WP-Members API Functions
|
12 |
+
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Checks if a user exists.
|
18 |
+
*
|
19 |
+
* @since 3.2.5
|
20 |
+
*
|
21 |
+
* @param $user_id
|
22 |
+
* @return boolean
|
23 |
+
*/
|
24 |
+
function wpmem_is_user( $user_id ) {
|
25 |
+
$user = get_userdata( $user_id );
|
26 |
+
return ( $user ) ? true : false;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns the current user's current role.
|
31 |
+
*
|
32 |
+
* Note that users may have more than one role. This returns
|
33 |
+
* whatever the internal pointer is set to. Usually, this will
|
34 |
+
* be the first element in the array, but not always.
|
35 |
+
* @see: https://www.php.net/manual/en/function.current.php
|
36 |
+
*
|
37 |
+
* @since 3.3.0
|
38 |
+
*
|
39 |
+
* @param int $user_id
|
40 |
+
* @param boolean $all If true, all roles as an array; if false, just the current role.
|
41 |
+
* @return mixed If the user is set and has roles, the current user role, otherwise false.
|
42 |
+
*/
|
43 |
+
function wpmem_get_user_role( $user_id = false, $all = false ) {
|
44 |
+
$user = ( $user_id ) ? get_userdata( $user_id ) : wp_get_current_user();
|
45 |
+
$role = ( ! $all ) ? current( $user->roles ) : $user->roles;
|
46 |
+
return ( $user ) ? $role : false;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Checks if user has a particular role.
|
51 |
+
*
|
52 |
+
* Utility function to check if a given user has a specific role. Users can
|
53 |
+
* have multiple roles assigned, so it checks the role array rather than using
|
54 |
+
* the incorrect method of current_user_can( 'role_name' ). The function can
|
55 |
+
* check the role of the current user (default) or a specific user (if $user_id
|
56 |
+
* is passed).
|
57 |
+
*
|
58 |
+
* @since 3.1.1
|
59 |
+
* @since 3.1.6 Include accepting an array of roles to check.
|
60 |
+
* @since 3.1.9 Return false if user is not logged in.
|
61 |
+
* @since 3.2.0 Change return false to not logged in AND no user id.
|
62 |
+
*
|
63 |
+
* @global object $current_user Current user object.
|
64 |
+
* @global object $wpmem WP_Members object.
|
65 |
+
* @param string|array $role Slug or array of slugs of the role being checked.
|
66 |
+
* @param int $user_id ID of the user being checked (optional).
|
67 |
+
* @return boolean $has_role True if user has the role, otherwise false.
|
68 |
+
*/
|
69 |
+
function wpmem_user_has_role( $role, $user_id = false ) {
|
70 |
+
if ( ! is_user_logged_in() && ! $user_id ) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
global $current_user, $wpmem;
|
74 |
+
$has_role = false;
|
75 |
+
if ( $user_id ) {
|
76 |
+
$user = get_userdata( $user_id );
|
77 |
+
} else {
|
78 |
+
$user = ( isset( $current_user ) ) ? $current_user : wp_get_current_user();
|
79 |
+
}
|
80 |
+
if ( is_array( $role ) ) {
|
81 |
+
foreach ( $role as $r ) {
|
82 |
+
if ( in_array( $r, $user->roles ) ) {
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
return ( in_array( $role, $user->roles ) ) ? true : $has_role;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Gets user meta.
|
93 |
+
*
|
94 |
+
* It may seem like WP already has this feature. And it does. But most user meta
|
95 |
+
* are single, and WP's get_user_meta() defaults to "false" for the $single
|
96 |
+
* argument. This function provides a shorthand that assumes a string value for
|
97 |
+
* the meta result and drops the $single argument.
|
98 |
+
*
|
99 |
+
* @since 3.3.0
|
100 |
+
*
|
101 |
+
* @param int $user_id
|
102 |
+
* @param string $meta_key
|
103 |
+
* @return string $result
|
104 |
+
*/
|
105 |
+
function wpmem_get_user_meta( $user_id, $meta_key ) {
|
106 |
+
return get_user_meta( $user_id, $meta_key, true );
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Checks if a user has a given meta value.
|
111 |
+
*
|
112 |
+
* @since 3.1.8
|
113 |
+
* @since 3.3.0 Added wpmem_user_has_meta filter.
|
114 |
+
* @since 3.3.0 Added array check for multi-value fields (multicheckbox and multiselect).
|
115 |
+
*
|
116 |
+
* @global object $wpmem WP_Members object.
|
117 |
+
*
|
118 |
+
* @param string $meta Meta key being checked.
|
119 |
+
* @param string $value Value the meta key should have (optional).
|
120 |
+
* @param int $user_id ID of the user being checked (optional).
|
121 |
+
* @return boolean $has_meta True if user has the meta value, otherwise false.
|
122 |
+
*/
|
123 |
+
function wpmem_user_has_meta( $meta, $value = false, $user_id = false ) {
|
124 |
+
|
125 |
+
global $wpmem;
|
126 |
+
|
127 |
+
// Get the user ID.
|
128 |
+
$user_id = ( $user_id ) ? $user_id : get_current_user_id();
|
129 |
+
|
130 |
+
// Get field type.
|
131 |
+
$fields = wpmem_fields();
|
132 |
+
$multi = ( ( isset( $fields[ $meta ] ) ) && ( 'multicheckbox' == $fields[ $meta ]['type'] || 'multiselect' == $fields[ $meta ]['type'] ) ) ? true : false;
|
133 |
+
|
134 |
+
// Get meta.
|
135 |
+
$has_meta = false;
|
136 |
+
$user_value = get_user_meta( $user_id, $meta, true );
|
137 |
+
|
138 |
+
// Check meta.
|
139 |
+
if ( $value ) {
|
140 |
+
if ( $multi ) {
|
141 |
+
// Check array of values.
|
142 |
+
$user_value = explode( $fields[ $meta ]['delimiter'], $user_value );
|
143 |
+
$has_meta = ( in_array( $value, $user_value ) ) ? true : $has_meta;
|
144 |
+
} else {
|
145 |
+
// Straight comparison.
|
146 |
+
$has_meta = ( $user_value == $value ) ? true : $has_meta;
|
147 |
+
}
|
148 |
+
} else {
|
149 |
+
// Check if the user has any meta value (regardless of actual value).
|
150 |
+
$has_meta = ( $user_value ) ? true : $has_meta;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Filter the user has meta result.
|
155 |
+
*
|
156 |
+
* @since 3.3.0
|
157 |
+
*
|
158 |
+
* @param bool $has_meta True if the user has the value, otherwise false.
|
159 |
+
* @param int $user_id The user ID being checked.
|
160 |
+
* @param string $user_value The user's stored meta value (false if none).
|
161 |
+
*/
|
162 |
+
return apply_filters( 'wpmem_user_has_meta', $has_meta, $user_id, $user_value );
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Checks if a user is activated.
|
167 |
+
*
|
168 |
+
* @since 3.1.7
|
169 |
+
* @since 3.2.3 Now an alias for WP_Members_Users::is_user_activated().
|
170 |
+
*
|
171 |
+
* @global object $wpmem
|
172 |
+
* @param int $user_id
|
173 |
+
* @return bool
|
174 |
+
*/
|
175 |
+
function wpmem_is_user_activated( $user_id = false ) {
|
176 |
+
global $wpmem;
|
177 |
+
return $wpmem->user->is_user_activated( $user_id );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Gets an array of the user's registration data.
|
182 |
+
*
|
183 |
+
* Returns an array keyed by meta keys of the user's registration data for
|
184 |
+
* all fields in the WP-Members Fields. Returns the current user unless
|
185 |
+
* a user ID is specified.
|
186 |
+
*
|
187 |
+
* @since 3.2.0
|
188 |
+
*
|
189 |
+
* @global object $wpmem
|
190 |
+
* @param integer $user_id
|
191 |
+
* @param bool $all
|
192 |
+
* @return array $user_fields
|
193 |
+
*/
|
194 |
+
function wpmem_user_data( $user_id = false, $all = false ) {
|
195 |
+
global $wpmem;
|
196 |
+
return $wpmem->user->user_data( $user_id, $all );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Updates a user's role.
|
201 |
+
*
|
202 |
+
* This is an alias for $wpmem->update_user_role(). It can add a role to a
|
203 |
+
* user, change or remove the user's role. If no action is specified it will
|
204 |
+
* change the role.
|
205 |
+
*
|
206 |
+
* @since 3.2.0
|
207 |
+
*
|
208 |
+
* @global object $wpmem
|
209 |
+
* @param integer $user_id (required)
|
210 |
+
* @param string $role (required)
|
211 |
+
* @param string $action (optional add|remove|set default:set)
|
212 |
+
*/
|
213 |
+
function wpmem_update_user_role( $user_id, $role, $action = 'set' ) {
|
214 |
+
global $wpmem;
|
215 |
+
$wpmem->user->update_user_role( $user_id, $role, $action );
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* A function for checking user access criteria.
|
220 |
+
*
|
221 |
+
* @since 3.2.0
|
222 |
+
* @since 3.2.3 Reversed order of arguments.
|
223 |
+
*
|
224 |
+
* @param mixed $product Accepts a single membership slug/meta, or an array of multiple memberships.
|
225 |
+
* @param integer $user_id User ID (optional|default: false).
|
226 |
+
* @return boolean $access True if user has access, otherwise false.
|
227 |
+
*/
|
228 |
+
function wpmem_user_has_access( $product, $user_id = false ) {
|
229 |
+
global $wpmem;
|
230 |
+
return $wpmem->user->has_access( $product, $user_id );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Checks if user expiration is current.
|
235 |
+
*
|
236 |
+
* Similar to wpmem_user_has_access(), but specifically checks the
|
237 |
+
* expiration date for a specified product (must be expiration product).
|
238 |
+
*
|
239 |
+
* @since 3.3.9
|
240 |
+
*
|
241 |
+
* @param mixed $product
|
242 |
+
* @param integer $user_id
|
243 |
+
* @return boolean
|
244 |
+
*/
|
245 |
+
function wpmem_user_is_current( $product, $user_id = false ) {
|
246 |
+
global $wpmem;
|
247 |
+
// @todo Finish this.
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Sets product access for a user.
|
253 |
+
*
|
254 |
+
* @since 3.2.3
|
255 |
+
* @since 3.2.6 Added $date to set a specific expiration date.
|
256 |
+
*
|
257 |
+
* @global object $wpmem
|
258 |
+
* @param string $product The meta key of the product.
|
259 |
+
* @param int $user_id
|
260 |
+
* @param string $date Expiration date (optional) format: MySQL timestamp
|
261 |
+
* @return bool $result
|
262 |
+
*/
|
263 |
+
function wpmem_set_user_product( $product, $user_id = false, $date = false ) {
|
264 |
+
global $wpmem;
|
265 |
+
return $wpmem->user->set_user_product( $product, $user_id, $date );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Removes product access for a user.
|
270 |
+
*
|
271 |
+
* @since 3.2.3
|
272 |
+
*
|
273 |
+
* @global object $wpmem
|
274 |
+
* @param string $product
|
275 |
+
* @param int $user_id
|
276 |
+
*/
|
277 |
+
function wpmem_remove_user_product( $product, $user_id = false ) {
|
278 |
+
global $wpmem;
|
279 |
+
$wpmem->user->remove_user_product( $product, $user_id );
|
280 |
+
return;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Gets memberships a user has.
|
285 |
+
*
|
286 |
+
* @since 3.3.0
|
287 |
+
*
|
288 |
+
* @global stdClass $wpmem
|
289 |
+
* @param int $user_id
|
290 |
+
* @return array
|
291 |
+
*/
|
292 |
+
function wpmem_get_user_products( $user_id = false ) {
|
293 |
+
global $wpmem;
|
294 |
+
return ( $user_id ) ? $wpmem->user->get_user_products( $user_id ) : $wpmem->user->access;
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* Sets a user as logged in.
|
299 |
+
*
|
300 |
+
* @since 3.2.3
|
301 |
+
*
|
302 |
+
* @global object $wpmem
|
303 |
+
* @param int $user_id
|
304 |
+
*/
|
305 |
+
function wpmem_set_as_logged_in( $user_id ) {
|
306 |
+
global $wpmem;
|
307 |
+
$wpmem->user->set_as_logged_in( $user_id );
|
308 |
+
}
|
309 |
+
|
310 |
+
if ( ! function_exists( 'wpmem_login' ) ):
|
311 |
+
/**
|
312 |
+
* Logs in the user.
|
313 |
+
*
|
314 |
+
* Logs in the the user using wp_signon (since 2.5.2). If login is
|
315 |
+
* successful, it will set a cookie using wp_set_auth_cookie (since 2.7.7),
|
316 |
+
* then it redirects and exits; otherwise "loginfailed" is returned.
|
317 |
+
*
|
318 |
+
* @since 0.1.0
|
319 |
+
* @since 2.5.2 Now uses wp_signon().
|
320 |
+
* @since 2.7.7 Sets cookie using wp_set_auth_cookie().
|
321 |
+
* @since 3.0.0 Removed wp_set_auth_cookie(), this already happens in wp_signon().
|
322 |
+
* @since 3.1.7 Now an alias for login() in WP_Members_Users Class.
|
323 |
+
* @since 3.2.4 Moved to user API (could be deprecated).
|
324 |
+
*
|
325 |
+
* @global object $wpmem
|
326 |
+
* @return string Returns "loginfailed" if the login fails.
|
327 |
+
*/
|
328 |
+
function wpmem_login() {
|
329 |
+
global $wpmem;
|
330 |
+
return $wpmem->user->login();
|
331 |
+
} // End of login function.
|
332 |
+
endif;
|
333 |
+
|
334 |
+
if ( ! function_exists( 'wpmem_logout' ) ):
|
335 |
+
/**
|
336 |
+
* Logs the user out then redirects.
|
337 |
+
*
|
338 |
+
* @since 2.0.0
|
339 |
+
* @since 3.1.6 Added wp_destroy_current_session(), removed nocache_headers().
|
340 |
+
* @since 3.1.7 Now an alias for logout() in WP_Members_Users Class.
|
341 |
+
* @since 3.2.4 Moved to user API (could be deprecated).
|
342 |
+
*
|
343 |
+
* @global object $wpmem
|
344 |
+
* @param string $redirect_to The URL to redirect to at logout.
|
345 |
+
*/
|
346 |
+
function wpmem_logout( $redirect_to = false ) {
|
347 |
+
global $wpmem;
|
348 |
+
$wpmem->user->logout( $redirect_to );
|
349 |
+
}
|
350 |
+
endif;
|
351 |
+
|
352 |
+
if ( ! function_exists( 'wpmem_change_password' ) ):
|
353 |
+
/**
|
354 |
+
* Handles user password change (not reset).
|
355 |
+
*
|
356 |
+
* @since 2.1.0
|
357 |
+
* @since 3.1.7 Now an alias for password_update() in WP_Members_Users Class.
|
358 |
+
* @since 3.2.4 Moved to user API (could be deprecated).
|
359 |
+
*
|
360 |
+
* @global int $user_ID The WordPress user ID.
|
361 |
+
*
|
362 |
+
* @return string The value for $wpmem->regchk
|
363 |
+
*/
|
364 |
+
function wpmem_change_password() {
|
365 |
+
global $wpmem;
|
366 |
+
return $wpmem->user->password_update( 'change' );
|
367 |
+
}
|
368 |
+
endif;
|
369 |
+
|
370 |
+
if ( ! function_exists( 'wpmem_reset_password' ) ):
|
371 |
+
/**
|
372 |
+
* Resets a forgotten password.
|
373 |
+
*
|
374 |
+
* @since 2.1.0
|
375 |
+
* @since 3.1.7 Now an alias for password_update() in WP_Members_Users Class.
|
376 |
+
* @since 3.2.4 Moved to user API (could be deprecated).
|
377 |
+
*
|
378 |
+
* @global object $wpmem The WP-Members object class.
|
379 |
+
*
|
380 |
+
* @return string The value for $wpmem->regchk
|
381 |
+
*/
|
382 |
+
function wpmem_reset_password() {
|
383 |
+
global $wpmem;
|
384 |
+
return $wpmem->user->password_update( 'reset' );
|
385 |
+
}
|
386 |
+
endif;
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Handles retrieving a forgotten username.
|
390 |
+
*
|
391 |
+
* @since 3.0.8
|
392 |
+
* @since 3.1.6 Dependencies now loaded by object.
|
393 |
+
* @since 3.1.8 Now an alias for $wpmem->retrieve_username() in WP_Members_Users Class.
|
394 |
+
* @since 3.2.4 Moved to user API (could be deprecated).
|
395 |
+
*
|
396 |
+
* @global object $wpmem The WP-Members object class.
|
397 |
+
*
|
398 |
+
* @return string $regchk The regchk value.
|
399 |
+
*/
|
400 |
+
function wpmem_retrieve_username() {
|
401 |
+
global $wpmem;
|
402 |
+
return $wpmem->user->retrieve_username();
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Creates a membership number.
|
407 |
+
*
|
408 |
+
* @since 3.1.1
|
409 |
+
* @since 3.2.0 Changed "lead" to "pad".
|
410 |
+
*
|
411 |
+
* @param array $args {
|
412 |
+
* @type string $option The wp_options name for the counter setting (required).
|
413 |
+
* @type string $meta_key The field's meta key (required).
|
414 |
+
* @type int $start Number to start with (optional, default 0).
|
415 |
+
* @type int $increment Number to increment by (optional, default 1).
|
416 |
+
* @type int $digits Number of digits for the number (optional).
|
417 |
+
* @type boolen $pad Pad leading zeros (optional, default true).
|
418 |
+
* }
|
419 |
+
* @return string $membersip_number
|
420 |
+
*/
|
421 |
+
function wpmem_create_membership_number( $args ) {
|
422 |
+
global $wpmem;
|
423 |
+
return $wpmem->api->generate_membership_number( $args );
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* Activates a user.
|
428 |
+
*
|
429 |
+
* If registration is moderated, sets the activated flag
|
430 |
+
* in the usermeta. Flag prevents login when $wpmem->mod_reg
|
431 |
+
* is true (1). Function is fired from bulk user edit or
|
432 |
+
* user profile update.
|
433 |
+
*
|
434 |
+
* @uses $wpdb WordPress Database object.
|
435 |
+
*
|
436 |
+
* @since 2.4
|
437 |
+
* @since 3.1.6 Dependencies now loaded by object.
|
438 |
+
* @since 3.2.4 Renamed from wpmem_a_activate_user().
|
439 |
+
* @since 3.3.0 Moved to user API.
|
440 |
+
* @since 3.3.5 Added $notify argument.
|
441 |
+
* @since 3.4.0 Added $set_pwd argument.
|
442 |
+
*
|
443 |
+
* @param int $user_id
|
444 |
+
* @param bool $notify Send notification to user (optional, default: true).
|
445 |
+
*/
|
446 |
+
function wpmem_activate_user( $user_id, $notify = true, $set_pwd = false ) {
|
447 |
+
|
448 |
+
global $wpmem;
|
449 |
+
|
450 |
+
// Define new_pass.
|
451 |
+
$new_pass = '';
|
452 |
+
|
453 |
+
// If passwords are user defined skip this.
|
454 |
+
if ( true == $set_pwd || ! wpmem_user_sets_password() ) {
|
455 |
+
$new_pass = wp_generate_password();
|
456 |
+
wp_set_password( $new_pass, $user_id );
|
457 |
+
}
|
458 |
+
|
459 |
+
// @todo this should be taken out, use the wpmem_user_activated hook instead.
|
460 |
+
// If subscriptions can expire, and the user has no expiration date, set one.
|
461 |
+
if ( $wpmem->use_exp == 1 && ! get_user_meta( $user_id, 'expires', true ) ) {
|
462 |
+
if ( function_exists( 'wpmem_set_exp' ) ) {
|
463 |
+
wpmem_set_exp( $user_id );
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
// Generate and send user approved email to user.
|
468 |
+
if ( true === $notify ) {
|
469 |
+
wpmem_email_to_user( $user_id, $new_pass, 2 );
|
470 |
+
}
|
471 |
+
|
472 |
+
// Set the active flag in usermeta.
|
473 |
+
update_user_meta( $user_id, 'active', 1 );
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Fires after the user activation process is complete.
|
477 |
+
*
|
478 |
+
* @since 2.8.2
|
479 |
+
*
|
480 |
+
* @param int $user_id The user's ID.
|
481 |
+
*/
|
482 |
+
do_action( 'wpmem_user_activated', $user_id );
|
483 |
+
|
484 |
+
return;
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Deactivates a user.
|
489 |
+
*
|
490 |
+
* Reverses the active flag from the activation process
|
491 |
+
* preventing login when registration is moderated.
|
492 |
+
*
|
493 |
+
* @since 2.7.1
|
494 |
+
* @since 3.2.4 Renamed from wpmem_a_deactivate_user().
|
495 |
+
* @since 3.3.0 Moved to user API.
|
496 |
+
*
|
497 |
+
* @param int $user_id
|
498 |
+
*/
|
499 |
+
function wpmem_deactivate_user( $user_id ) {
|
500 |
+
update_user_meta( $user_id, 'active', 0 );
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Fires after the user deactivation process is complete.
|
504 |
+
*
|
505 |
+
* @since 2.9.9
|
506 |
+
*
|
507 |
+
* @param int $user_id The user's ID.
|
508 |
+
*/
|
509 |
+
do_action( 'wpmem_user_deactivated', $user_id );
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Updates the user_status value in the wp_users table.
|
514 |
+
*
|
515 |
+
* @since Unknown
|
516 |
+
* @since 3.3.0 Moved to User API.
|
517 |
+
*
|
518 |
+
* @global object $wpdb
|
519 |
+
*
|
520 |
+
* @param int $user_id
|
521 |
+
* @param string $status
|
522 |
+
*/
|
523 |
+
function wpmem_set_user_status( $user_id, $status ) {
|
524 |
+
global $wpdb;
|
525 |
+
$wpdb->update( $wpdb->users, array( 'user_status' => $status ), array( 'ID' => $user_id ) );
|
526 |
+
return;
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Register function.
|
531 |
+
*
|
532 |
+
* Handles registering new users and updating existing users.
|
533 |
+
*
|
534 |
+
* @since 2.2.1
|
535 |
+
* @since 2.7.2 Added pre/post process actions.
|
536 |
+
* @since 2.8.2 Added validation and data filters.
|
537 |
+
* @since 2.9.3 Added validation for multisite.
|
538 |
+
* @since 3.0.0 Moved from wp-members-register.php to /inc/register.php.
|
539 |
+
* @since 3.3.0 Ported from wpmem_registration in /inc/register.php (now deprecated).
|
540 |
+
*
|
541 |
+
* @todo Review what should be in the API function and what should be moved to object classes.
|
542 |
+
*
|
543 |
+
* @global int $user_ID
|
544 |
+
* @global object $wpmem
|
545 |
+
* @global string $wpmem_themsg
|
546 |
+
* @global array $userdata
|
547 |
+
*
|
548 |
+
* @param string $tag Identifies 'register' or 'update'.
|
549 |
+
* @return string $wpmem_themsg|success|editsuccess
|
550 |
+
*/
|
551 |
+
function wpmem_user_register( $tag ) {
|
552 |
+
|
553 |
+
// Get the globals.
|
554 |
+
global $user_ID, $wpmem, $wpmem_themsg, $userdata;
|
555 |
+
|
556 |
+
$wpmem->user->register_validate( $tag );
|
557 |
+
|
558 |
+
// @todo Added as a fix for legacy versions of security extension and any wpmem_pre_register_data action that might null $wpmem_themsg.
|
559 |
+
if ( $wpmem_themsg ) {
|
560 |
+
return $wpmem_themsg;
|
561 |
+
}
|
562 |
+
|
563 |
+
switch ( $tag ) {
|
564 |
+
|
565 |
+
case "register":
|
566 |
+
|
567 |
+
/**
|
568 |
+
* Filter registration data after validation before data insertion.
|
569 |
+
*
|
570 |
+
* @since 2.8.2
|
571 |
+
*
|
572 |
+
* @param array $wpmem->user->post_data An array of the registration field data.
|
573 |
+
* @param string $tag A switch to indicate the action (new|edit).
|
574 |
+
*/
|
575 |
+
$wpmem->user->post_data = apply_filters( 'wpmem_register_data', $wpmem->user->post_data, 'new' );
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Fires before any insertion/emails.
|
579 |
+
*
|
580 |
+
* This action is the final step in pre registering a user. This
|
581 |
+
* can be used for attaching custom validation to the registration
|
582 |
+
* process. It cannot be used for changing any user registration
|
583 |
+
* data. Use the wpmem_register_data filter for that.
|
584 |
+
*
|
585 |
+
* @since 2.7.2
|
586 |
+
*
|
587 |
+
* @param array $wpmem->user->post_data The user's submitted registration data.
|
588 |
+
*/
|
589 |
+
do_action( 'wpmem_pre_register_data', $wpmem->user->post_data );
|
590 |
+
|
591 |
+
// If the _pre_register_data hook sends back an error message.
|
592 |
+
if ( $wpmem_themsg ) {
|
593 |
+
return $wpmem_themsg;
|
594 |
+
}
|
595 |
+
|
596 |
+
// Main new user fields are ready.
|
597 |
+
$new_user_fields = array (
|
598 |
+
'user_pass' => $wpmem->user->post_data['password'],
|
599 |
+
'user_login' => $wpmem->user->post_data['username'],
|
600 |
+
'user_nicename' => $wpmem->user->post_data['user_nicename'],
|
601 |
+
'user_email' => $wpmem->user->post_data['user_email'],
|
602 |
+
'display_name' => $wpmem->user->post_data['display_name'],
|
603 |
+
'nickname' => $wpmem->user->post_data['nickname'],
|
604 |
+
'user_registered' => $wpmem->user->post_data['user_registered'],
|
605 |
+
'role' => $wpmem->user->post_data['user_role']
|
606 |
+
);
|
607 |
+
|
608 |
+
// Get any excluded meta fields.
|
609 |
+
$wpmem->excluded_meta = wpmem_get_excluded_meta( 'register' );
|
610 |
+
|
611 |
+
// Fields for wp_insert_user: user_url, first_name, last_name, description.
|
612 |
+
$new_user_fields_meta = array( 'user_url', 'first_name', 'last_name', 'description' );
|
613 |
+
foreach ( $wpmem->fields as $meta_key => $field ) {
|
614 |
+
if ( in_array( $meta_key, $new_user_fields_meta ) ) {
|
615 |
+
if ( $field['register'] && ! in_array( $meta_key, $wpmem->excluded_meta ) ) {
|
616 |
+
$new_user_fields[ $meta_key ] = $wpmem->user->post_data[ $meta_key ];
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
+
|
621 |
+
// Inserts to wp_users table.
|
622 |
+
$user = wp_insert_user( $new_user_fields );
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Fires after registration is complete.
|
626 |
+
*
|
627 |
+
* @since 2.7.1
|
628 |
+
* @since 3.1.0 Added $fields
|
629 |
+
* @since 3.1.7 Changed $fields to $this->post_data
|
630 |
+
* @since 3.3.0 Moved to registration function.
|
631 |
+
* @since 3.3.8 Added $user parameter.
|
632 |
+
*
|
633 |
+
* @param array $wpmem->user->post_data The user's submitted registration data.
|
634 |
+
*/
|
635 |
+
do_action( 'wpmem_register_redirect', $wpmem->user->post_data, $user );
|
636 |
+
|
637 |
+
// successful registration message
|
638 |
+
return "success";
|
639 |
+
break;
|
640 |
+
|
641 |
+
case "update":
|
642 |
+
|
643 |
+
if ( $wpmem_themsg ) {
|
644 |
+
return "updaterr";
|
645 |
+
exit();
|
646 |
+
}
|
647 |
+
|
648 |
+
/*
|
649 |
+
* Doing a check for existing email is not the same as a new reg. check first to
|
650 |
+
* see if it's different, then check if it is a valid address and it exists.
|
651 |
+
*/
|
652 |
+
global $current_user; wp_get_current_user();
|
653 |
+
if ( isset( $wpmem->user->post_data['user_email'] ) ) {
|
654 |
+
if ( $wpmem->user->post_data['user_email'] != $current_user->user_email ) {
|
655 |
+
if ( email_exists( $wpmem->user->post_data['user_email'] ) ) {
|
656 |
+
return "email";
|
657 |
+
exit();
|
658 |
+
}
|
659 |
+
if ( in_array( 'user_email', $wpmem->fields ) && ! is_email( $wpmem->user->post_data['user_email']) ) {
|
660 |
+
$wpmem_themsg = wpmem_get_text( 'reg_valid_email' );
|
661 |
+
return "updaterr";
|
662 |
+
exit();
|
663 |
+
}
|
664 |
+
}
|
665 |
+
}
|
666 |
+
|
667 |
+
// If form includes email confirmation, validate that they match.
|
668 |
+
if ( array_key_exists( 'confirm_email', $wpmem->user->post_data ) && $wpmem->user->post_data['confirm_email'] != $wpmem->user->post_data ['user_email'] ) {
|
669 |
+
$wpmem_themsg = wpmem_get_text( 'reg_email_match' );
|
670 |
+
return "updaterr";
|
671 |
+
exit();
|
672 |
+
}
|
673 |
+
|
674 |
+
// Add the user_ID to the fields array.
|
675 |
+
$wpmem->user->post_data['ID'] = $user_ID;
|
676 |
+
|
677 |
+
/** This filter is documented in register.php */
|
678 |
+
$wpmem->user->post_data = apply_filters( 'wpmem_register_data', $wpmem->user->post_data, 'edit' );
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Fires before data insertion.
|
682 |
+
*
|
683 |
+
* This action is the final step in pre updating a user. This
|
684 |
+
* can be used for attaching custom validation to the update
|
685 |
+
* process. It cannot be used for changing any user update
|
686 |
+
* data. Use the wpmem_register_data filter for that.
|
687 |
+
*
|
688 |
+
* @since 2.7.2
|
689 |
+
*
|
690 |
+
* @param array $wpmem->user->post_data The user's submitted update data.
|
691 |
+
*/
|
692 |
+
do_action( 'wpmem_pre_update_data', $wpmem->user->post_data );
|
693 |
+
|
694 |
+
// If the _pre_update_data hook sends back an error message.
|
695 |
+
if ( $wpmem_themsg ){
|
696 |
+
return "updaterr";
|
697 |
+
}
|
698 |
+
|
699 |
+
// A list of fields that can be updated by wp_update_user.
|
700 |
+
$native_fields = array(
|
701 |
+
'user_nicename',
|
702 |
+
'user_url',
|
703 |
+
'user_email',
|
704 |
+
'display_name',
|
705 |
+
'nickname',
|
706 |
+
'first_name',
|
707 |
+
'last_name',
|
708 |
+
'description',
|
709 |
+
'role',
|
710 |
+
);
|
711 |
+
$native_update = array( 'ID' => $wpmem->user->post_data['ID'] );
|
712 |
+
|
713 |
+
foreach ( $wpmem->fields as $meta_key => $field ) {
|
714 |
+
// If the field is not excluded, update accordingly.
|
715 |
+
if ( ! in_array( $meta_key, wpmem_get_excluded_meta( 'update' ) ) ) {
|
716 |
+
if ( 'file' != $field['type'] && 'image' != $field['type'] ) {
|
717 |
+
switch ( $meta_key ) {
|
718 |
+
|
719 |
+
// If the field can be updated by wp_update_user.
|
720 |
+
case( in_array( $meta_key, $native_fields ) ):
|
721 |
+
if ( 1 == $field['profile'] ) {
|
722 |
+
$wpmem->user->post_data[ $meta_key ] = ( isset( $wpmem->user->post_data[ $meta_key ] ) ) ? $wpmem->user->post_data[ $meta_key ] : '';
|
723 |
+
$native_update[ $meta_key ] = $wpmem->user->post_data[ $meta_key ];
|
724 |
+
}
|
725 |
+
break;
|
726 |
+
|
727 |
+
// If the field is password.
|
728 |
+
case( 'password' ):
|
729 |
+
// Do nothing.
|
730 |
+
break;
|
731 |
+
|
732 |
+
// Everything else goes into wp_usermeta.
|
733 |
+
default:
|
734 |
+
if ( ( 'register' == $tag && true == $field['register'] ) || ( 'update' == $tag && true == $field['profile'] ) ) {
|
735 |
+
update_user_meta( $wpmem->user->post_data['ID'], $meta_key, $wpmem->user->post_data[ $meta_key ] );
|
736 |
+
}
|
737 |
+
break;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
}
|
741 |
+
}
|
742 |
+
|
743 |
+
// Handle file uploads, if any.
|
744 |
+
if ( ! empty( $_FILES ) ) {
|
745 |
+
$wpmem->user->upload_user_files( $wpmem->user->post_data['ID'], $wpmem->fields );
|
746 |
+
}
|
747 |
+
|
748 |
+
// Update wp_update_user fields.
|
749 |
+
wp_update_user( $native_update );
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Fires at the end of user update data insertion.
|
753 |
+
*
|
754 |
+
* @since 2.7.2
|
755 |
+
*
|
756 |
+
* @param array $wpmem->user->post_data The user's submitted registration data.
|
757 |
+
*/
|
758 |
+
do_action( 'wpmem_post_update_data', $wpmem->user->post_data );
|
759 |
+
|
760 |
+
return "editsuccess"; exit();
|
761 |
+
break;
|
762 |
+
}
|
763 |
+
} // End registration function.
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Get user IP address.
|
767 |
+
*
|
768 |
+
* From Pippin.
|
769 |
+
* @link https://gist.github.com/pippinsplugins/9641841
|
770 |
+
*
|
771 |
+
* @since 3.3.0
|
772 |
+
* @since 3.4.0 Now an alias for rktgk_get_user_ip();
|
773 |
+
*
|
774 |
+
* @return string $ip.
|
775 |
+
*/
|
776 |
+
function wpmem_get_user_ip() {
|
777 |
+
/**
|
778 |
+
* Filter the IP result.
|
779 |
+
*
|
780 |
+
* @since 3.3.0
|
781 |
+
*
|
782 |
+
* @param string $ip
|
783 |
+
*/
|
784 |
+
return apply_filters( 'wpmem_get_ip', rktgk_get_user_ip( $ip ) );
|
785 |
+
}
|
786 |
+
|
787 |
+
/**
|
788 |
+
* Export all or selected users
|
789 |
+
*
|
790 |
+
* @since 2.9.7
|
791 |
+
* @since 3.2.0 Updated to use fputcsv.
|
792 |
+
* @since 3.2.1 Added user data filters.
|
793 |
+
* @since 3.3.0 Call object class static method.
|
794 |
+
* @since 3.3.4 Moved into general API.
|
795 |
+
*
|
796 |
+
* @todo Move object class file to main /includes/
|
797 |
+
*
|
798 |
+
* @global object $wpmem
|
799 |
+
*
|
800 |
+
* @param array $args
|
801 |
+
* @param array $users
|
802 |
+
*/
|
803 |
+
function wpmem_export_users( $args = array(), $users = array() ) {
|
804 |
+
global $wpmem;
|
805 |
+
include_once( $wpmem->path . 'includes/admin/class-wp-members-user-export.php' );
|
806 |
+
WP_Members_User_Export::export_users( $args, $users );
|
807 |
+
}
|
808 |
+
|
809 |
+
/**
|
810 |
+
* Gets user ID based on request.
|
811 |
+
*
|
812 |
+
* @since 3.3.5
|
813 |
+
*
|
814 |
+
* @param mixed $user
|
815 |
+
* @return mixed
|
816 |
+
*/
|
817 |
+
function wpmem_get_user_id( $user ) {
|
818 |
+
$user_obj = wpmem_get_user_obj( $user );
|
819 |
+
return ( is_object( $user_obj ) ) ? $user_obj->ID : false;
|
820 |
+
}
|
821 |
+
|
822 |
+
/**
|
823 |
+
* Gets user object based on request.
|
824 |
+
*
|
825 |
+
* @since 3.3.5
|
826 |
+
*
|
827 |
+
* @param mixed $user
|
828 |
+
* @return mixed
|
829 |
+
*/
|
830 |
+
function wpmem_get_user_obj( $user ) {
|
831 |
+
if ( is_numeric( $user ) ) {
|
832 |
+
$user_obj = get_userdata( $user );
|
833 |
+
if ( $user_obj ) {
|
834 |
+
return $user_obj;
|
835 |
+
}
|
836 |
+
}
|
837 |
+
if ( strpos( $user, '@' ) ) {
|
838 |
+
$user_obj = get_user_by( 'email', $user );
|
839 |
+
if ( $user_obj ) {
|
840 |
+
return $user_obj;
|
841 |
+
}
|
842 |
+
}
|
843 |
+
if ( is_string( $user ) ) {
|
844 |
+
$user_obj = get_user_by( 'login', $user );
|
845 |
+
if ( $user_obj ) {
|
846 |
+
return $user_obj;
|
847 |
+
}
|
848 |
+
}
|
849 |
+
return false;
|
850 |
+
}
|
851 |
+
|
852 |
+
/**
|
853 |
+
* Get all users by a meta value.
|
854 |
+
*
|
855 |
+
* @since 3.3.5
|
856 |
+
*
|
857 |
+
* @param string $meta The meta key to search fo.
|
858 |
+
* @param string $value The meta value to search for (defaul:false).
|
859 |
+
* @return array $users An array of user IDs who have the requested meta.
|
860 |
+
*/
|
861 |
+
function wpmem_get_users_by_meta( $meta, $value = "EXISTS" ) {
|
862 |
+
$args = array( 'fields' => array( 'ID' ), 'meta_key' => $meta );
|
863 |
+
if ( false === $value ) {
|
864 |
+
$args['meta_value'] = '';
|
865 |
+
$args['meta_compare'] = 'NOT EXISTS';
|
866 |
+
} elseif ( "EXISTS" === $value ) {
|
867 |
+
$args['meta_value'] = '';
|
868 |
+
$args['meta_compare'] = '>';
|
869 |
+
} else {
|
870 |
+
$args['meta_value'] = $value;
|
871 |
+
}
|
872 |
+
$results = get_users( $args );
|
873 |
+
if ( $results ) {
|
874 |
+
foreach( $results as $result ) {
|
875 |
+
$users[] = $result->ID;
|
876 |
+
}
|
877 |
+
return $users;
|
878 |
+
} else {
|
879 |
+
return array();
|
880 |
+
}
|
881 |
+
}
|
882 |
+
|
883 |
+
/**
|
884 |
+
* Gets a list of all pending users.
|
885 |
+
*
|
886 |
+
* @since 3.3.5
|
887 |
+
*
|
888 |
+
* @return array $users An array of user IDs where meta key "active" does not exist.
|
889 |
+
*/
|
890 |
+
function wpmem_get_pending_users() {
|
891 |
+
return wpmem_get_users_by_meta( 'active', false );
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* Gets a list of all activated users.
|
896 |
+
*
|
897 |
+
* @since 3.3.5
|
898 |
+
*
|
899 |
+
* @return array $users An array of user IDs who have the meta key active=1
|
900 |
+
*/
|
901 |
+
function wpmem_get_activated_users() {
|
902 |
+
return wpmem_get_users_by_meta( 'active', 1 );
|
903 |
+
}
|
904 |
+
|
905 |
+
/**
|
906 |
+
* Gets a list of all deactivated users.
|
907 |
+
*
|
908 |
+
* @since 3.3.5
|
909 |
+
*
|
910 |
+
* @return array $users An array of users IDs who have the meta key active=0
|
911 |
+
*/
|
912 |
+
function wpmem_get_deactivated_users() {
|
913 |
+
return wpmem_get_users_by_meta( 'active', 0 );
|
914 |
+
}
|
915 |
+
|
916 |
+
/**
|
917 |
+
* Sets a user as validated.
|
918 |
+
*
|
919 |
+
* @since 3.3.5
|
920 |
+
*
|
921 |
+
* @param int $user_id
|
922 |
+
* @return void
|
923 |
+
*/
|
924 |
+
function wpmem_set_user_as_confirmed( $user_id ) {
|
925 |
+
global $wpmem;
|
926 |
+
$wpmem->act_newreg->set_as_confirmed( $user_id );
|
927 |
+
}
|
928 |
+
|
929 |
+
/**
|
930 |
+
* Sets user as unconfirmed (not validated).
|
931 |
+
*
|
932 |
+
* @since 3.3.8
|
933 |
+
*
|
934 |
+
* @param int $user_id
|
935 |
+
* @return void
|
936 |
+
*/
|
937 |
+
function wpmem_set_user_as_unconfirmed( $user_id ) {
|
938 |
+
global $wpmem;
|
939 |
+
$wpmem->act_newreg->set_as_unconfirmed( $user_id );
|
940 |
+
}
|
941 |
+
|
942 |
+
/**
|
943 |
+
* Checks if a user is confirmed.
|
944 |
+
*
|
945 |
+
* @since 3.3.8
|
946 |
+
*
|
947 |
+
* @global object $wpmem
|
948 |
+
* @param int $user_id
|
949 |
+
* @return bool
|
950 |
+
*/
|
951 |
+
function wpmem_is_user_confirmed( $user_id = false ) {
|
952 |
+
global $wpmem;
|
953 |
+
$user_id = ( false === $user_id ) ? get_current_user_id() : $user_id;
|
954 |
+
return ( get_user_meta( $user_id, $wpmem->act_newreg->validation_confirm, true ) ) ? true : false;
|
955 |
+
}
|
956 |
+
|
957 |
+
/**
|
958 |
+
* Adds WP-Members custom fields to the WP Add New User form.
|
959 |
+
*
|
960 |
+
* @since 2.9.1
|
961 |
+
* @since 3.4.0 Moved from admin.php
|
962 |
+
*
|
963 |
+
* @global stdClass $wpmem
|
964 |
+
*/
|
965 |
+
function wpmem_admin_add_new_user() {
|
966 |
+
global $wpmem;
|
967 |
+
// Output the custom registration fields.
|
968 |
+
echo $wpmem->forms->wp_newuser_form();
|
969 |
+
return;
|
970 |
+
}
|
971 |
// End of file.
|
@@ -7,13 +7,13 @@
|
|
7 |
*
|
8 |
* This file is part of the WP-Members plugin by Chad Butler
|
9 |
* You can find out more about this plugin at https://rocketgeek.com
|
10 |
-
* Copyright (c) 2006-
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP-Members Utility Functions
|
15 |
* @author Chad Butler
|
16 |
-
* @copyright 2006-
|
17 |
*/
|
18 |
|
19 |
if ( ! function_exists( 'wpmem_securify' ) ):
|
@@ -22,10 +22,10 @@ if ( ! function_exists( 'wpmem_securify' ) ):
|
|
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
|
26 |
*
|
27 |
* @since 2.0.0
|
28 |
-
* @since 3.0.0 Now
|
29 |
* @since 3.2.4 Moved to utility API (could be deprecated).
|
30 |
*
|
31 |
* @global object $wpmem The WP-Members object class.
|
@@ -43,53 +43,40 @@ endif;
|
|
43 |
* Sets an array of user meta fields to be excluded from update/insert.
|
44 |
*
|
45 |
* @since 2.9.3
|
46 |
-
* @since Unknown Now
|
|
|
47 |
*
|
48 |
* @param string $tag A tag so we know where the function is being used.
|
49 |
* @return array Array of fields to be excluded from the registration form.
|
50 |
*/
|
51 |
function wpmem_get_excluded_meta( $tag ) {
|
52 |
global $wpmem;
|
53 |
-
return $wpmem->excluded_fields( $tag );
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Returns http:// or https:// depending on ssl.
|
58 |
-
*
|
59 |
-
* @since 2.9.8
|
60 |
-
* @deprecated 3.2.3 Use wpmem_force_ssl() instead.
|
61 |
-
*
|
62 |
-
* @return string https://|http:// depending on whether ssl is being used.
|
63 |
-
*/
|
64 |
-
function wpmem_use_ssl() {
|
65 |
-
return ( is_ssl() ) ? 'https://' : 'http://';
|
66 |
}
|
67 |
|
68 |
/**
|
69 |
* Forces a URL to be secure (ssl).
|
70 |
*
|
71 |
* @since 3.2.3
|
|
|
72 |
*
|
73 |
* @param string $url URL to be make secure.
|
74 |
* @return string The secure URL.
|
75 |
*/
|
76 |
function wpmem_force_ssl( $url ) {
|
77 |
-
return (
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
* Log debugging errors.
|
82 |
*
|
83 |
* @since 3.1.2
|
|
|
84 |
*
|
85 |
* @param mixed (string|array|object) $log Information to write in the WP debug file.
|
86 |
*/
|
87 |
-
function wpmem_write_log
|
88 |
-
|
89 |
-
error_log( print_r( $log, true ) );
|
90 |
-
} else {
|
91 |
-
error_log( $log );
|
92 |
-
}
|
93 |
}
|
94 |
|
95 |
/**
|
@@ -102,6 +89,7 @@ function wpmem_write_log ( $log ) {
|
|
102 |
* the parts before, after, and the "needle" are returned.
|
103 |
*
|
104 |
* @since 3.2.0
|
|
|
105 |
*
|
106 |
* @param string $needle
|
107 |
* @param string $haystack
|
@@ -116,27 +104,7 @@ function wpmem_write_log ( $log ) {
|
|
116 |
* }
|
117 |
*/
|
118 |
function wpmem_get_sub_str( $needle, $haystack, $position = 'after', $keep_needle = true ) {
|
119 |
-
|
120 |
-
if ( false === $pos ) {
|
121 |
-
return $haystack;
|
122 |
-
} else {
|
123 |
-
if ( 'before' == $position ) {
|
124 |
-
$new = ( substr( $haystack, 0, $pos ) );
|
125 |
-
$new = ( $keep_needle ) ? $string . $needle : $new;
|
126 |
-
} elseif ( 'after' == $position ) {
|
127 |
-
$new = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
128 |
-
$new = ( $keep_needle ) ? $needle . $string : $new;
|
129 |
-
} elseif ( 'split' == $position ) {
|
130 |
-
$before = ( substr( $haystack, 0, $pos ) );
|
131 |
-
$after = ( substr( $haystack, $pos+strlen( $needle ) ) );
|
132 |
-
$new = array(
|
133 |
-
'before' => $before,
|
134 |
-
'after' => $after,
|
135 |
-
'needle' => $needle,
|
136 |
-
);
|
137 |
-
}
|
138 |
-
}
|
139 |
-
return $new;
|
140 |
}
|
141 |
|
142 |
if ( ! function_exists( 'wpmem_do_excerpt' ) ):
|
@@ -144,7 +112,7 @@ if ( ! function_exists( 'wpmem_do_excerpt' ) ):
|
|
144 |
* Creates an excerpt on the fly if there is no 'more' tag.
|
145 |
*
|
146 |
* @since 2.6
|
147 |
-
* @since 3.2.3 Now
|
148 |
*
|
149 |
* @global object $wpmem The WP_Members object.
|
150 |
*
|
@@ -165,7 +133,8 @@ if ( ! function_exists( 'wpmem_texturize' ) ):
|
|
165 |
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
166 |
*
|
167 |
* @since 2.6.4
|
168 |
-
* @since 3.2.3 Now
|
|
|
169 |
*
|
170 |
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
171 |
*
|
@@ -175,7 +144,8 @@ if ( ! function_exists( 'wpmem_texturize' ) ):
|
|
175 |
*/
|
176 |
function wpmem_texturize( $content ) {
|
177 |
global $wpmem;
|
178 |
-
return $wpmem->texturize( $content );
|
|
|
179 |
}
|
180 |
endif;
|
181 |
|
@@ -184,6 +154,7 @@ endif;
|
|
184 |
*
|
185 |
* @since 3.1.6
|
186 |
* @since 3.2.3 Moved to utilities api.
|
|
|
187 |
*
|
188 |
* @param array $array Original array.
|
189 |
* @param array $new Array of new items to insert into $array.
|
@@ -192,14 +163,7 @@ endif;
|
|
192 |
* @return array Original array with new items inserted.
|
193 |
*/
|
194 |
function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
|
195 |
-
|
196 |
-
if ( 'before' == $loc ) {
|
197 |
-
$pos = (int) array_search( $key, $keys );
|
198 |
-
} else {
|
199 |
-
$index = array_search( $key, $keys );
|
200 |
-
$pos = ( false === $index ) ? count( $array ) : $index + 1;
|
201 |
-
}
|
202 |
-
return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
|
203 |
}
|
204 |
|
205 |
/**
|
@@ -219,34 +183,22 @@ function wpmem_load_dropins() {
|
|
219 |
* Display a localized date based on the WP date format setting.
|
220 |
*
|
221 |
* @since 3.2.4
|
|
|
222 |
*
|
223 |
* @param mixed $args
|
224 |
* @return date $date
|
225 |
*/
|
226 |
function wpmem_format_date( $args ) {
|
227 |
-
if ( ! is_array( $args ) ) {
|
228 |
-
$args = array( 'date' => $args );
|
229 |
-
}
|
230 |
-
|
231 |
-
$defaults = array(
|
232 |
-
'date_format' => get_option( 'date_format' ),
|
233 |
-
'localize' => true,
|
234 |
-
'timestamp' => false,
|
235 |
-
);
|
236 |
-
|
237 |
-
$args = wp_parse_args( $args, $deafults );
|
238 |
-
|
239 |
/**
|
240 |
* Filter the date display and format settings.
|
241 |
*
|
242 |
* @since 3.2.4
|
|
|
243 |
*
|
244 |
* @param arrag $args
|
245 |
*/
|
246 |
$args = apply_filters( 'wpmem_format_date_args', $args );
|
247 |
-
|
248 |
-
$date = ( true === $args['localize'] ) ? date_i18n( $args['date_format'], $date ) : date( $args['date_format'], $date );
|
249 |
-
return $date;
|
250 |
}
|
251 |
|
252 |
/**
|
@@ -265,6 +217,7 @@ function wpmem_format_date( $args ) {
|
|
265 |
* @link https://codesymphony.co/dont-do_shortcode/
|
266 |
*
|
267 |
* @since 3.2.5
|
|
|
268 |
*
|
269 |
* @param string $tag The shortcode whose function to call.
|
270 |
* @param array $atts The attributes to pass to the shortcode function. Optional.
|
@@ -273,14 +226,7 @@ function wpmem_format_date( $args ) {
|
|
273 |
* @return string|bool False on failure, the result of the shortcode on success.
|
274 |
*/
|
275 |
function wpmem_do_shortcode( $tag, array $atts = array(), $content = null ) {
|
276 |
-
|
277 |
-
global $shortcode_tags;
|
278 |
-
|
279 |
-
if ( ! isset( $shortcode_tags[ $tag ] ) ) {
|
280 |
-
return false;
|
281 |
-
}
|
282 |
-
|
283 |
-
return call_user_func( $shortcode_tags[ $tag ], $atts, $content, $tag );
|
284 |
}
|
285 |
|
286 |
/**
|
@@ -312,41 +258,59 @@ function wpmem_user_sets_password() {
|
|
312 |
* sanitizes each individual array element.
|
313 |
*
|
314 |
* @since 3.3.0
|
|
|
315 |
*
|
316 |
* @param mixed $original
|
317 |
* @return mixed $original
|
318 |
*/
|
319 |
function wpmem_maybe_unserialize( $original ) {
|
320 |
-
|
321 |
-
$original = unserialize( $original );
|
322 |
-
}
|
323 |
-
return ( is_array( $original ) ) ? wpmem_sanitize_array( $original ) : $original;
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
* Determines whether to use a .min suffix for a script/style file.
|
328 |
*
|
329 |
* @since 3.3.0
|
|
|
330 |
*
|
331 |
* @param boolean $echo
|
332 |
*/
|
333 |
function wpmem_get_suffix( $echo = false ) {
|
334 |
-
|
335 |
-
if ( true === $echo ) {
|
336 |
-
echo $suffix;
|
337 |
-
return;
|
338 |
-
} else {
|
339 |
-
return $suffix;
|
340 |
-
}
|
341 |
}
|
342 |
|
343 |
/**
|
344 |
* Checks if WooCommerce is active.
|
345 |
*
|
346 |
* @since 3.3.7
|
|
|
347 |
*
|
348 |
* @return boolean
|
349 |
*/
|
350 |
function wpmem_is_woo_active() {
|
351 |
-
return (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
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-2021 Chad Butler
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP-Members Utility Functions
|
15 |
* @author Chad Butler
|
16 |
+
* @copyright 2006-2021
|
17 |
*/
|
18 |
|
19 |
if ( ! function_exists( 'wpmem_securify' ) ):
|
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 an alias for $wpmem->do_securify().
|
26 |
*
|
27 |
* @since 2.0.0
|
28 |
+
* @since 3.0.0 Now an alias 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.
|
43 |
* Sets an array of user meta fields to be excluded from update/insert.
|
44 |
*
|
45 |
* @since 2.9.3
|
46 |
+
* @since Unknown Now an alias for get_excluded_fields().
|
47 |
+
* @since 3.3.9 excluded_fields() moved to forms object class.
|
48 |
*
|
49 |
* @param string $tag A tag so we know where the function is being used.
|
50 |
* @return array Array of fields to be excluded from the registration form.
|
51 |
*/
|
52 |
function wpmem_get_excluded_meta( $tag ) {
|
53 |
global $wpmem;
|
54 |
+
return $wpmem->forms->excluded_fields( $tag );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
* Forces a URL to be secure (ssl).
|
59 |
*
|
60 |
* @since 3.2.3
|
61 |
+
* @since 3.4.0 Now an alias for rktgk_force_ssl()
|
62 |
*
|
63 |
* @param string $url URL to be make secure.
|
64 |
* @return string The secure URL.
|
65 |
*/
|
66 |
function wpmem_force_ssl( $url ) {
|
67 |
+
return rktgk_force_ssl( $url );
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
* Log debugging errors.
|
72 |
*
|
73 |
* @since 3.1.2
|
74 |
+
* @since 3.4.0 Now an alias for rktgk_write_log().
|
75 |
*
|
76 |
* @param mixed (string|array|object) $log Information to write in the WP debug file.
|
77 |
*/
|
78 |
+
function wpmem_write_log( $log ) {
|
79 |
+
rktgk_write_log( $log );
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
|
82 |
/**
|
89 |
* the parts before, after, and the "needle" are returned.
|
90 |
*
|
91 |
* @since 3.2.0
|
92 |
+
* @since 3.4.0 Now an alias for rktgk_get_sub_str().
|
93 |
*
|
94 |
* @param string $needle
|
95 |
* @param string $haystack
|
104 |
* }
|
105 |
*/
|
106 |
function wpmem_get_sub_str( $needle, $haystack, $position = 'after', $keep_needle = true ) {
|
107 |
+
return rktgk_get_sub_str( $needle, $haystack, $position, $keep_needle );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
109 |
|
110 |
if ( ! function_exists( 'wpmem_do_excerpt' ) ):
|
112 |
* Creates an excerpt on the fly if there is no 'more' tag.
|
113 |
*
|
114 |
* @since 2.6
|
115 |
+
* @since 3.2.3 Now an alias for WP_Members::do_excerpt().
|
116 |
*
|
117 |
* @global object $wpmem The WP_Members object.
|
118 |
*
|
133 |
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
134 |
*
|
135 |
* @since 2.6.4
|
136 |
+
* @since 3.2.3 Now an alias for WP_Members::texturize().
|
137 |
+
* @deprecated 3.4.0. No replacement available.
|
138 |
*
|
139 |
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
140 |
*
|
144 |
*/
|
145 |
function wpmem_texturize( $content ) {
|
146 |
global $wpmem;
|
147 |
+
//return $wpmem->texturize( $content );
|
148 |
+
return $content;
|
149 |
}
|
150 |
endif;
|
151 |
|
154 |
*
|
155 |
* @since 3.1.6
|
156 |
* @since 3.2.3 Moved to utilities api.
|
157 |
+
* @since 3.4.0 Now an alias for rktgk_array_insert()
|
158 |
*
|
159 |
* @param array $array Original array.
|
160 |
* @param array $new Array of new items to insert into $array.
|
163 |
* @return array Original array with new items inserted.
|
164 |
*/
|
165 |
function wpmem_array_insert( array $array, array $new, $key, $loc = 'after' ) {
|
166 |
+
return rktgk_array_insert( $array, $new, $key, $loc );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
|
169 |
/**
|
183 |
* Display a localized date based on the WP date format setting.
|
184 |
*
|
185 |
* @since 3.2.4
|
186 |
+
* @since 3.4.0 Now an alias for rktgk_format_date().
|
187 |
*
|
188 |
* @param mixed $args
|
189 |
* @return date $date
|
190 |
*/
|
191 |
function wpmem_format_date( $args ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
/**
|
193 |
* Filter the date display and format settings.
|
194 |
*
|
195 |
* @since 3.2.4
|
196 |
+
* @deprecated 3.4.0 Use rktgk_format_date instead.
|
197 |
*
|
198 |
* @param arrag $args
|
199 |
*/
|
200 |
$args = apply_filters( 'wpmem_format_date_args', $args );
|
201 |
+
return rktgk_format_date( $args );
|
|
|
|
|
202 |
}
|
203 |
|
204 |
/**
|
217 |
* @link https://codesymphony.co/dont-do_shortcode/
|
218 |
*
|
219 |
* @since 3.2.5
|
220 |
+
* @since 3.4.0 Now an alias for rktgk_do_shortcode().
|
221 |
*
|
222 |
* @param string $tag The shortcode whose function to call.
|
223 |
* @param array $atts The attributes to pass to the shortcode function. Optional.
|
226 |
* @return string|bool False on failure, the result of the shortcode on success.
|
227 |
*/
|
228 |
function wpmem_do_shortcode( $tag, array $atts = array(), $content = null ) {
|
229 |
+
return rktgk_do_shortcode( $tag, $atts, $content );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
|
232 |
/**
|
258 |
* sanitizes each individual array element.
|
259 |
*
|
260 |
* @since 3.3.0
|
261 |
+
* @since 3.4.0 Now an alias for rktgk_maybe_unserialize().
|
262 |
*
|
263 |
* @param mixed $original
|
264 |
* @return mixed $original
|
265 |
*/
|
266 |
function wpmem_maybe_unserialize( $original ) {
|
267 |
+
return rktgk_maybe_unserialize( $original );
|
|
|
|
|
|
|
268 |
}
|
269 |
|
270 |
/**
|
271 |
* Determines whether to use a .min suffix for a script/style file.
|
272 |
*
|
273 |
* @since 3.3.0
|
274 |
+
* @since 3.4.0 Now an alias for rktgk_get_suffix().
|
275 |
*
|
276 |
* @param boolean $echo
|
277 |
*/
|
278 |
function wpmem_get_suffix( $echo = false ) {
|
279 |
+
return rktgk_get_suffix( $echo );
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
* Checks if WooCommerce is active.
|
284 |
*
|
285 |
* @since 3.3.7
|
286 |
+
* @since 3.4.0 Now an alias for rktgk_is_woo_active().
|
287 |
*
|
288 |
* @return boolean
|
289 |
*/
|
290 |
function wpmem_is_woo_active() {
|
291 |
+
return rktgk_is_woo_active();
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* A utility to determine a redirect_to param.
|
296 |
+
*
|
297 |
+
* @since 3.4.0
|
298 |
+
*
|
299 |
+
* @param array $args
|
300 |
+
* @return string $redirect_to
|
301 |
+
*/
|
302 |
+
function wpmem_get_redirect_to( $args = array() ) {
|
303 |
+
// redirect_to in the form or URL will override a redirect set in the form args.
|
304 |
+
if ( isset( $_REQUEST['redirect_to'] ) ) {
|
305 |
+
$redirect_to = $_REQUEST['redirect_to'];
|
306 |
+
} else {
|
307 |
+
if ( isset( $args['redirect_to'] ) ) {
|
308 |
+
$raw_redirect_to = $args['redirect_to'];
|
309 |
+
// Is it a URL?
|
310 |
+
$redirect_to = ( false == filter_var( $raw_redirect_to, FILTER_VALIDATE_URL ) ) ? home_url( $raw_redirect_to ) : $raw_redirect_to;
|
311 |
+
} else {
|
312 |
+
$redirect_to = ( isset( $_SERVER['REQUEST_URI'] ) ) ? $_SERVER['REQUEST_URI'] : get_permalink();
|
313 |
+
}
|
314 |
+
}
|
315 |
+
return $redirect_to;
|
316 |
}
|
@@ -4,29 +4,13 @@
|
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
-
* Copyright (c) 2006-
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @subpackage WP-Members API Functions
|
12 |
* @author Chad Butler
|
13 |
-
* @copyright 2006-
|
14 |
-
*
|
15 |
-
* Functions included:
|
16 |
-
* - wpmem_redirect_to_login
|
17 |
-
* - wpmem_is_blocked
|
18 |
-
* - wpmem_login_url
|
19 |
-
* - wpmem_register_url
|
20 |
-
* - wpmem_profile_url
|
21 |
-
* - wpmem_current_url
|
22 |
-
* - wpmem_current_post_id
|
23 |
-
* - wpmem_gettext
|
24 |
-
* - wpmem_use_custom_dialog
|
25 |
-
* - wpmem_login_status
|
26 |
-
* - wpmem_get
|
27 |
-
* - wpmem_is_reg_page
|
28 |
-
* - wpmem_loginout
|
29 |
-
* - wpmem_display_message
|
30 |
*/
|
31 |
|
32 |
// Exit if accessed directly.
|
@@ -101,6 +85,7 @@ function wpmem_get_block_setting( $post_id ) {
|
|
101 |
*
|
102 |
* @since 3.1.1
|
103 |
* @since 3.1.2 Added redirect_to parameter.
|
|
|
104 |
*
|
105 |
* @global object $wpmem The WP_Members object.
|
106 |
* @param string $redirect_to URL to return to (optional).
|
@@ -108,10 +93,12 @@ function wpmem_get_block_setting( $post_id ) {
|
|
108 |
*/
|
109 |
function wpmem_login_url( $redirect_to = false ) {
|
110 |
global $wpmem;
|
|
|
|
|
111 |
if ( $redirect_to ) {
|
112 |
-
$url = add_query_arg( 'redirect_to', urlencode( $redirect_to ), $
|
113 |
} else {
|
114 |
-
$url = $
|
115 |
}
|
116 |
return $url;
|
117 |
}
|
@@ -200,20 +187,19 @@ function wpmem_current_post_id() {
|
|
200 |
/**
|
201 |
* Wrapper to return a string from the get_text function.
|
202 |
*
|
203 |
-
* @since 3.
|
204 |
-
* @since 3.1.2 Added $echo argument.
|
205 |
*
|
206 |
* @global object $wpmem The WP_Members object.
|
207 |
* @param string $str The string to retrieve.
|
208 |
* @param bool $echo Print the string (default: false).
|
209 |
* @return string $str The localized string.
|
210 |
*/
|
211 |
-
function
|
212 |
global $wpmem;
|
213 |
if ( $echo ) {
|
214 |
-
echo $wpmem->get_text( $str );
|
215 |
} else {
|
216 |
-
return $wpmem->get_text( $str );
|
217 |
}
|
218 |
}
|
219 |
|
@@ -238,17 +224,58 @@ function wpmem_use_custom_dialog( $defaults, $tag, $dialogs ) {
|
|
238 |
* @since 2.0.0
|
239 |
* @since 3.1.2 Moved to api.php, no longer pluggable.
|
240 |
* @since 3.1.6 Dependencies now loaded by object.
|
|
|
241 |
*
|
242 |
-
* @
|
243 |
-
* @
|
|
|
244 |
*/
|
245 |
-
function wpmem_login_status( $echo = true ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
-
|
248 |
-
$status =
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
return $status;
|
253 |
}
|
254 |
}
|
@@ -260,6 +287,7 @@ function wpmem_login_status( $echo = true ) {
|
|
260 |
* sanitized or escaped depending on how it is used.
|
261 |
*
|
262 |
* @since 3.1.3
|
|
|
263 |
*
|
264 |
* @param string $tag The form field or query string.
|
265 |
* @param string $default The default value (optional).
|
@@ -267,17 +295,7 @@ function wpmem_login_status( $echo = true ) {
|
|
267 |
* @return string
|
268 |
*/
|
269 |
function wpmem_get( $tag, $default = '', $type = 'post' ) {
|
270 |
-
|
271 |
-
case 'get':
|
272 |
-
return ( isset( $_GET[ $tag ] ) ) ? $_GET[ $tag ] : $default;
|
273 |
-
break;
|
274 |
-
case 'request':
|
275 |
-
return ( isset( $_REQUEST[ $tag ] ) ) ? $_REQUEST[ $tag ] : $default;
|
276 |
-
break;
|
277 |
-
default: // case 'post':
|
278 |
-
return ( isset( $_POST[ $tag ] ) ) ? $_POST[ $tag ] : $default;
|
279 |
-
break;
|
280 |
-
}
|
281 |
}
|
282 |
|
283 |
/**
|
@@ -326,19 +344,62 @@ function wpmem_loginout( $args = array(), $echo = false ) {
|
|
326 |
return $wpmem->loginout_args( $args );
|
327 |
}
|
328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
/**
|
330 |
* Dispalays requested dialog.
|
|
|
|
|
|
|
331 |
*
|
332 |
* @since 3.2.0
|
|
|
333 |
*
|
334 |
-
* @todo
|
|
|
|
|
|
|
|
|
|
|
335 |
*/
|
336 |
-
function wpmem_display_message( $tag, $
|
337 |
-
|
338 |
-
echo wpmem_inc_regmessage( $tag );
|
339 |
-
} else {
|
340 |
-
return wpmem_inc_regmessage( $tag );
|
341 |
-
}
|
342 |
}
|
343 |
|
344 |
/**
|
@@ -415,4 +476,16 @@ function wpmem_is_reg_type( $type ) {
|
|
415 |
return $wpmem->reg_type[ 'is_' . $type ];
|
416 |
}
|
417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
// End of file.
|
4 |
*
|
5 |
* This file is part of the WP-Members plugin by Chad Butler
|
6 |
* You can find out more about this plugin at https://rocketgeek.com
|
7 |
+
* Copyright (c) 2006-2021 Chad Butler
|
8 |
* WP-Members(tm) is a trademark of butlerblog.com
|
9 |
*
|
10 |
* @package WP-Members
|
11 |
* @subpackage WP-Members API Functions
|
12 |
* @author Chad Butler
|
13 |
+
* @copyright 2006-2021
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
*/
|
15 |
|
16 |
// Exit if accessed directly.
|
85 |
*
|
86 |
* @since 3.1.1
|
87 |
* @since 3.1.2 Added redirect_to parameter.
|
88 |
+
* @since 3.4.0 If no login page is set, return the wp_login_url().
|
89 |
*
|
90 |
* @global object $wpmem The WP_Members object.
|
91 |
* @param string $redirect_to URL to return to (optional).
|
93 |
*/
|
94 |
function wpmem_login_url( $redirect_to = false ) {
|
95 |
global $wpmem;
|
96 |
+
// If no login page is set, get WP login url.
|
97 |
+
$login_url = ( isset( $wpmem->user_pages['login'] ) ) ? $wpmem->user_pages['login'] : wp_login_url();
|
98 |
if ( $redirect_to ) {
|
99 |
+
$url = add_query_arg( 'redirect_to', urlencode( $redirect_to ), $login_url );
|
100 |
} else {
|
101 |
+
$url = $login_url;
|
102 |
}
|
103 |
return $url;
|
104 |
}
|
187 |
/**
|
188 |
* Wrapper to return a string from the get_text function.
|
189 |
*
|
190 |
+
* @since 3.4.0
|
|
|
191 |
*
|
192 |
* @global object $wpmem The WP_Members object.
|
193 |
* @param string $str The string to retrieve.
|
194 |
* @param bool $echo Print the string (default: false).
|
195 |
* @return string $str The localized string.
|
196 |
*/
|
197 |
+
function wpmem_get_text( $str, $echo = false ) {
|
198 |
global $wpmem;
|
199 |
if ( $echo ) {
|
200 |
+
echo $wpmem->dialogs->get_text( $str );
|
201 |
} else {
|
202 |
+
return $wpmem->dialogs->get_text( $str );
|
203 |
}
|
204 |
}
|
205 |
|
224 |
* @since 2.0.0
|
225 |
* @since 3.1.2 Moved to api.php, no longer pluggable.
|
226 |
* @since 3.1.6 Dependencies now loaded by object.
|
227 |
+
* @since 3.4.0 Added $tag for id'ing useage, to be passed through filter.
|
228 |
*
|
229 |
+
* @global string $user_login
|
230 |
+
* @param boolean $echo Determines whether function should print result or not (default: true).
|
231 |
+
* @return string $status The user status string produced by wpmem_inc_memberlinks().
|
232 |
*/
|
233 |
+
function wpmem_login_status( $echo = true, $tag = false ) {
|
234 |
+
if ( is_user_logged_in() ) {
|
235 |
+
|
236 |
+
global $user_login;
|
237 |
+
|
238 |
+
$args = array(
|
239 |
+
'wrapper_before' => '<p>',
|
240 |
+
'wrapper_after' => '</p>',
|
241 |
+
'user_login' => $user_login,
|
242 |
+
'welcome' => wpmem_gettext( 'status_welcome' ),
|
243 |
+
'logout_text' => wpmem_gettext( 'status_logout' ),
|
244 |
+
'logout_link' => '<a href="' . esc_url( wpmem_logout_link() ) . '">%s</a>',
|
245 |
+
'separator' => ' | ',
|
246 |
+
);
|
247 |
+
/**
|
248 |
+
* Filter the status message parts.
|
249 |
+
*
|
250 |
+
* @since 2.9.9
|
251 |
+
* @since 3.4.0 Added $tag as a parameter (most often will be false).
|
252 |
+
*
|
253 |
+
* @param array $args {
|
254 |
+
* The components of the links.
|
255 |
+
*
|
256 |
+
* @type string $wrapper_before The wrapper opening tag (default: <p>).
|
257 |
+
* @type string $wrapper_after The wrapper closing tag (default: </p>).
|
258 |
+
* @type string $user_login
|
259 |
+
* @type string $welcome
|
260 |
+
* @type string $logout_text
|
261 |
+
* @type string $logout_link
|
262 |
+
* @type string $separator
|
263 |
+
* }
|
264 |
+
* @param string $tag
|
265 |
+
*/
|
266 |
+
$args = apply_filters( 'wpmem_status_msg_args', $args, $tag );
|
267 |
|
268 |
+
// Assemble the message string.
|
269 |
+
$status = $args['wrapper_before']
|
270 |
+
. sprintf( $args['welcome'], $args['user_login'] )
|
271 |
+
. $args['separator']
|
272 |
+
. sprintf( $args['logout_link'], $args['logout_text'] )
|
273 |
+
. $args['wrapper_after'];
|
274 |
+
}
|
275 |
+
|
276 |
+
if ( $echo ) {
|
277 |
+
echo $status;
|
278 |
+
} else {
|
279 |
return $status;
|
280 |
}
|
281 |
}
|
287 |
* sanitized or escaped depending on how it is used.
|
288 |
*
|
289 |
* @since 3.1.3
|
290 |
+
* @since 3.4.0 Now an alias for rktgk_get().
|
291 |
*
|
292 |
* @param string $tag The form field or query string.
|
293 |
* @param string $default The default value (optional).
|
295 |
* @return string
|
296 |
*/
|
297 |
function wpmem_get( $tag, $default = '', $type = 'post' ) {
|
298 |
+
return rktgk_get( $tag, $default, $type );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
|
301 |
/**
|
344 |
return $wpmem->loginout_args( $args );
|
345 |
}
|
346 |
|
347 |
+
/**
|
348 |
+
* Gets a logout link.
|
349 |
+
*
|
350 |
+
* @since 3.4.0
|
351 |
+
*
|
352 |
+
* @return string Logout link.
|
353 |
+
*/
|
354 |
+
function wpmem_logout_link() {
|
355 |
+
/**
|
356 |
+
* Filter the log out link.
|
357 |
+
*
|
358 |
+
* @since 2.8.3
|
359 |
+
*
|
360 |
+
* @param string The default logout link.
|
361 |
+
*/
|
362 |
+
return apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Gets requested dialog.
|
367 |
+
*
|
368 |
+
* @since 3.4.0
|
369 |
+
*
|
370 |
+
* @note It is being relased now as tentative.
|
371 |
+
* There may be some changes to how this is applied.
|
372 |
+
*
|
373 |
+
* @todo What about wpmem_use_custom_dialog()?
|
374 |
+
*
|
375 |
+
* @global stdClass $wpmem
|
376 |
+
* @param string $tag
|
377 |
+
* @param string $custom
|
378 |
+
* @return
|
379 |
+
*/
|
380 |
+
function wpmem_get_display_message( $tag, $custom = false ) {
|
381 |
+
global $wpmem;
|
382 |
+
return $wpmem->dialogs->get_message( $tag, $custom );
|
383 |
+
}
|
384 |
+
|
385 |
/**
|
386 |
* Dispalays requested dialog.
|
387 |
+
*
|
388 |
+
* @note It is being relased now as tentative.
|
389 |
+
* There may be some changes to how this is applied.
|
390 |
*
|
391 |
* @since 3.2.0
|
392 |
+
* @since 3.4.0 Now echos the message. Added $custom argument
|
393 |
*
|
394 |
+
* @todo What about wpmem_use_custom_dialog()?
|
395 |
+
*
|
396 |
+
* @global stdClass $wpmem
|
397 |
+
* @param string $tag
|
398 |
+
* @param string $custom
|
399 |
+
* @return
|
400 |
*/
|
401 |
+
function wpmem_display_message( $tag, $custom = false ) {
|
402 |
+
echo wpmem_get_display_message( $tag, $custom );
|
|
|
|
|
|
|
|
|
403 |
}
|
404 |
|
405 |
/**
|
476 |
return $wpmem->reg_type[ 'is_' . $type ];
|
477 |
}
|
478 |
|
479 |
+
/**
|
480 |
+
* Displays the post restricted message.
|
481 |
+
*
|
482 |
+
* @since 3.4.0
|
483 |
+
*
|
484 |
+
* @return string
|
485 |
+
*/
|
486 |
+
function wpmem_restricted_message() {
|
487 |
+
global $wpmem;
|
488 |
+
return $wpmem->forms->add_restricted_msg();
|
489 |
+
}
|
490 |
+
|
491 |
// End of file.
|
@@ -216,13 +216,13 @@ class WP_Members_Captcha {
|
|
216 |
* @param array
|
217 |
*/
|
218 |
$rows = apply_filters( 'wpmem_rs_captcha_rows', array(
|
219 |
-
'label_text' =>
|
220 |
'code_size' => esc_attr( $size ),
|
221 |
'prefix' => $pre,
|
222 |
'img_src' => esc_url( $src ),
|
223 |
'img_w' => esc_attr( $img_w ),
|
224 |
'img_h' => esc_attr( $img_h ),
|
225 |
-
'label' => '<label class="text" for="captcha">' .
|
226 |
'field' => '<input id="captcha_code" name="captcha_code" size="' . esc_attr( $size ) . '" type="text" class="textbox" required />',
|
227 |
'hidden' => '<input id="captcha_prefix" name="captcha_prefix" type="hidden" value="' . esc_attr( $pre ) . '" />',
|
228 |
'img' => '<img src="' . esc_url( $src ) . '" alt="captcha" width="' . esc_attr( $img_w ) . '" height="' . esc_attr( $img_h ) . '" />',
|
@@ -290,7 +290,7 @@ class WP_Members_Captcha {
|
|
290 |
|
291 |
// If there is no captcha value, return error.
|
292 |
if ( false === $captcha ) {
|
293 |
-
$wpmem_themsg =
|
294 |
return false;
|
295 |
}
|
296 |
|
@@ -307,7 +307,7 @@ class WP_Members_Captcha {
|
|
307 |
if ( $response->success ) {
|
308 |
// your success code goes here
|
309 |
} else {
|
310 |
-
$wpmem_themsg =
|
311 |
return false;
|
312 |
}
|
313 |
|
@@ -328,7 +328,7 @@ class WP_Members_Captcha {
|
|
328 |
|
329 |
// If there is no captcha value, return error.
|
330 |
if ( false === $captcha ) {
|
331 |
-
$wpmem_themsg =
|
332 |
return false;
|
333 |
}
|
334 |
|
@@ -347,7 +347,7 @@ class WP_Members_Captcha {
|
|
347 |
|
348 |
// If captcha validation was unsuccessful.
|
349 |
if ( false == $response['success'] ) {
|
350 |
-
$wpmem_themsg =
|
351 |
if ( WP_DEBUG && isset( $response['error-codes'] ) ) {
|
352 |
$wpmem_themsg.= '<br /><br />';
|
353 |
foreach( $response['error-codes'] as $code ) {
|
@@ -360,7 +360,7 @@ class WP_Members_Captcha {
|
|
360 |
$captcha = wpmem_get( 'recaptcha_response', false );
|
361 |
|
362 |
if ( false === $captcha ) {
|
363 |
-
$wpmem_themsg =
|
364 |
return false;
|
365 |
}
|
366 |
|
@@ -374,11 +374,20 @@ class WP_Members_Captcha {
|
|
374 |
$recaptcha = file_get_contents( $url );
|
375 |
$recaptcha = json_decode( $recaptcha );
|
376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
// Take action based on the score returned:
|
378 |
-
if ( $recaptcha->score >=
|
379 |
-
|
380 |
} else {
|
381 |
-
$wpmem_themsg =
|
382 |
return false;
|
383 |
}
|
384 |
} else {
|
216 |
* @param array
|
217 |
*/
|
218 |
$rows = apply_filters( 'wpmem_rs_captcha_rows', array(
|
219 |
+
'label_text' => wpmem_get_text( 'register_rscaptcha' ),
|
220 |
'code_size' => esc_attr( $size ),
|
221 |
'prefix' => $pre,
|
222 |
'img_src' => esc_url( $src ),
|
223 |
'img_w' => esc_attr( $img_w ),
|
224 |
'img_h' => esc_attr( $img_h ),
|
225 |
+
'label' => '<label class="text" for="captcha">' . wpmem_get_text( 'register_rscaptcha' ) . '</label>',
|
226 |
'field' => '<input id="captcha_code" name="captcha_code" size="' . esc_attr( $size ) . '" type="text" class="textbox" required />',
|
227 |
'hidden' => '<input id="captcha_prefix" name="captcha_prefix" type="hidden" value="' . esc_attr( $pre ) . '" />',
|
228 |
'img' => '<img src="' . esc_url( $src ) . '" alt="captcha" width="' . esc_attr( $img_w ) . '" height="' . esc_attr( $img_h ) . '" />',
|
290 |
|
291 |
// If there is no captcha value, return error.
|
292 |
if ( false === $captcha ) {
|
293 |
+
$wpmem_themsg = wpmem_get_text( 'reg_empty_captcha' );
|
294 |
return false;
|
295 |
}
|
296 |
|
307 |
if ( $response->success ) {
|
308 |
// your success code goes here
|
309 |
} else {
|
310 |
+
$wpmem_themsg = wpmem_get_text( 'reg_invalid_captcha' );
|
311 |
return false;
|
312 |
}
|
313 |
|
328 |
|
329 |
// If there is no captcha value, return error.
|
330 |
if ( false === $captcha ) {
|
331 |
+
$wpmem_themsg = wpmem_get_text( 'reg_empty_captcha' );
|
332 |
return false;
|
333 |
}
|
334 |
|
347 |
|
348 |
// If captcha validation was unsuccessful.
|
349 |
if ( false == $response['success'] ) {
|
350 |
+
$wpmem_themsg = wpmem_get_text( 'reg_invalid_captcha' );
|
351 |
if ( WP_DEBUG && isset( $response['error-codes'] ) ) {
|
352 |
$wpmem_themsg.= '<br /><br />';
|
353 |
foreach( $response['error-codes'] as $code ) {
|
360 |
$captcha = wpmem_get( 'recaptcha_response', false );
|
361 |
|
362 |
if ( false === $captcha ) {
|
363 |
+
$wpmem_themsg = wpmem_get_text( 'reg_empty_captcha' );
|
364 |
return false;
|
365 |
}
|
366 |
|
374 |
$recaptcha = file_get_contents( $url );
|
375 |
$recaptcha = json_decode( $recaptcha );
|
376 |
|
377 |
+
/**
|
378 |
+
* Filters the reCAPTCHA v3 score.
|
379 |
+
* @link https://developers.google.com/recaptcha/docs/v3
|
380 |
+
*
|
381 |
+
* @since 3.3.9
|
382 |
+
*
|
383 |
+
* @param int $score
|
384 |
+
*/
|
385 |
+
$score = apply_filters( 'wpmem_recaptcha_score', 0.5 );
|
386 |
// Take action based on the score returned:
|
387 |
+
if ( $recaptcha->score >= $score ) {
|
388 |
+
return true;
|
389 |
} else {
|
390 |
+
$wpmem_themsg = wpmem_get_text( 'reg_invalid_captcha' );
|
391 |
return false;
|
392 |
}
|
393 |
} else {
|
@@ -6,6 +6,7 @@
|
|
6 |
* @subpackage WP_Members Clone Menus Object Class
|
7 |
* @since 3.2.0
|
8 |
* @since 3.3.0 Renamed WP_Members_Clone_Menus
|
|
|
9 |
*/
|
10 |
|
11 |
// Exit if accessed directly.
|
@@ -16,9 +17,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
class WP_Members_Clone_Menus {
|
17 |
|
18 |
function __construct() {
|
19 |
-
add_action( 'init',
|
20 |
-
add_filter( 'wp_nav_menu_args',
|
21 |
-
add_filter( 'jetpack_mobile_theme_menu', array( $this, 'jetpack_mobile_theme_menu' ) );
|
22 |
}
|
23 |
|
24 |
/**
|
@@ -95,24 +95,4 @@ class WP_Members_Clone_Menus {
|
|
95 |
return $args;
|
96 |
}
|
97 |
|
98 |
-
/**
|
99 |
-
* Handles Jetpack mobile theme, if enabled.
|
100 |
-
*
|
101 |
-
* Jetpack mobile theme uses a custom mobile theme called Minileven. This theme uses
|
102 |
-
* the default primary menu for the main menu. If this is enabled, the Logged-in
|
103 |
-
* Menus extension uses the jetpack_mobile_theme_menu filter hook to apply the default
|
104 |
-
* primary menu if the user is not logged in or the logged in primary menu if they are.
|
105 |
-
*
|
106 |
-
* @since 3.2.0
|
107 |
-
*/
|
108 |
-
function jetpack_mobile_theme_menu() {
|
109 |
-
// Get menus
|
110 |
-
$menu_locs = get_nav_menu_locations();
|
111 |
-
if ( is_user_logged_in() ) {
|
112 |
-
return $menu_locs['primary_wpmem_loggedin'];
|
113 |
-
} else {
|
114 |
-
return $menu_locs['primary'];
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
}
|
6 |
* @subpackage WP_Members Clone Menus Object Class
|
7 |
* @since 3.2.0
|
8 |
* @since 3.3.0 Renamed WP_Members_Clone_Menus
|
9 |
+
* @deprecated 3.4.0 No longer supported.
|
10 |
*/
|
11 |
|
12 |
// Exit if accessed directly.
|
17 |
class WP_Members_Clone_Menus {
|
18 |
|
19 |
function __construct() {
|
20 |
+
add_action( 'init', array( $this, 'register_menus' ), 99 );
|
21 |
+
add_filter( 'wp_nav_menu_args', array( $this, 'serve_menu' ) );
|
|
|
22 |
}
|
23 |
|
24 |
/**
|
95 |
return $args;
|
96 |
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
@@ -0,0 +1,398 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members_Dialogs Class.
|
4 |
+
*
|
5 |
+
* This class contains functions for handling dialongs and messaging..
|
6 |
+
*
|
7 |
+
* @package WP-Members
|
8 |
+
* @subpackage WP_Members_Dialogs Object Class
|
9 |
+
* @since 3.0.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly.
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
14 |
+
exit();
|
15 |
+
}
|
16 |
+
|
17 |
+
class WP_Members_Dialogs {
|
18 |
+
|
19 |
+
function __construct() {
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Returns a requested text string.
|
25 |
+
*
|
26 |
+
* This function manages all of the front-end facing text.
|
27 |
+
* All defaults can be filtered using wpmem_default_text_strings.
|
28 |
+
*
|
29 |
+
* @since 3.1.0
|
30 |
+
*
|
31 |
+
* @global object $wpmem
|
32 |
+
*
|
33 |
+
* @param string $str
|
34 |
+
* @return string $text
|
35 |
+
*/
|
36 |
+
function get_text( $str ) {
|
37 |
+
global $wpmem;
|
38 |
+
|
39 |
+
// Default Form Fields.
|
40 |
+
$default_form_fields = array(
|
41 |
+
'first_name' => __( 'First Name', 'wp-members' ),
|
42 |
+
'last_name' => __( 'Last Name', 'wp-members' ),
|
43 |
+
'addr1' => __( 'Address 1', 'wp-members' ),
|
44 |
+
'addr2' => __( 'Address 2', 'wp-members' ),
|
45 |
+
'city' => __( 'City', 'wp-members' ),
|
46 |
+
'thestate' => __( 'State', 'wp-members' ),
|
47 |
+
'zip' => __( 'Zip', 'wp-members' ),
|
48 |
+
'country' => __( 'Country', 'wp-members' ),
|
49 |
+
'phone1' => __( 'Day Phone', 'wp-members' ),
|
50 |
+
'user_email' => __( 'Email', 'wp-members' ),
|
51 |
+
'confirm_email' => __( 'Confirm Email', 'wp-members' ),
|
52 |
+
'user_url' => __( 'Website', 'wp-members' ),
|
53 |
+
'description' => __( 'Biographical Info', 'wp-members' ),
|
54 |
+
'password' => __( 'Password', 'wp-members' ),
|
55 |
+
'confirm_password' => __( 'Confirm Password', 'wp-members' ),
|
56 |
+
'tos' => __( 'TOS', 'wp-members' ),
|
57 |
+
);
|
58 |
+
|
59 |
+
/*
|
60 |
+
* Strings to be added or removed in future versions, included so they will
|
61 |
+
* be in the translation template.
|
62 |
+
* @todo Check whether any of these should be removed.
|
63 |
+
*/
|
64 |
+
$benign_strings = array(
|
65 |
+
__( 'No fields selected for deletion', 'wp-members' ),
|
66 |
+
__( 'You are not logged in.', 'wp-members' ), // Technically removed 3.5
|
67 |
+
);
|
68 |
+
|
69 |
+
$defaults = array(
|
70 |
+
|
71 |
+
// Login form.
|
72 |
+
'login_heading' => __( 'Existing Users Log In', 'wp-members' ),
|
73 |
+
'login_username' => __( 'Username or Email', 'wp-members' ),
|
74 |
+
'login_password' => __( 'Password', 'wp-members' ),
|
75 |
+
'login_button' => __( 'Log In', 'wp-members' ),
|
76 |
+
'remember_me' => __( 'Remember Me', 'wp-members' ),
|
77 |
+
'forgot_link_before' => __( 'Forgot password?', 'wp-members' ) . ' ',
|
78 |
+
'forgot_link' => __( 'Click here to reset', 'wp-members' ),
|
79 |
+
'register_link_before' => __( 'New User?', 'wp-members' ) . ' ',
|
80 |
+
'register_link' => __( 'Click here to register', 'wp-members' ),
|
81 |
+
|
82 |
+
// Password change form.
|
83 |
+
'pwdchg_heading' => __( 'Change Password', 'wp-members' ),
|
84 |
+
'pwdchg_password1' => __( 'New password', 'wp-members' ),
|
85 |
+
'pwdchg_password2' => __( 'Confirm new password', 'wp-members' ),
|
86 |
+
'pwdchg_button' => __( 'Update Password', 'wp-members' ),
|
87 |
+
'pwdchg_update' => __( 'Password successfully changed!', 'wp-members' ),
|
88 |
+
|
89 |
+
// Password reset form.
|
90 |
+
'pwdreset_heading' => __( 'Reset Forgotten Password', 'wp-members' ),
|
91 |
+
'pwdreset_username' => __( 'Username', 'wp-members' ),
|
92 |
+
'pwdreset_email' => __( 'Email', 'wp-members' ),
|
93 |
+
'pwdreset_button' => __( 'Reset Password' ),
|
94 |
+
'username_link_before' => __( 'Forgot username?', 'wp-members' ) . ' ',
|
95 |
+
'username_link' => __( 'Click here', 'wp-members' ),
|
96 |
+
|
97 |
+
// Retrieve username form.
|
98 |
+
'username_heading' => __( 'Retrieve username', 'wp-members' ),
|
99 |
+
'username_email' => __( 'Email Address', 'wp-members' ),
|
100 |
+
'username_button' => __( 'Retrieve username', 'wp-members' ),
|
101 |
+
|
102 |
+
// Register form.
|
103 |
+
'register_heading' => __( 'New User Registration', 'wp-members' ),
|
104 |
+
'register_username' => __( 'Choose a Username', 'wp-members' ),
|
105 |
+
'register_rscaptcha' => __( 'Input the code:', 'wp-members' ),
|
106 |
+
'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.
|
107 |
+
'register_clear' => __( 'Reset Form', 'wp-members' ),
|
108 |
+
'register_submit' => __( 'Register', 'wp-members' ),
|
109 |
+
'register_req_mark' => '<span class="req">*</span>',
|
110 |
+
'register_required' => '<span class="req">*</span>' . __( 'Required field', 'wp-members' ),
|
111 |
+
|
112 |
+
// User profile update form.
|
113 |
+
'profile_heading' => __( 'Edit Your Information', 'wp-members' ),
|
114 |
+
'profile_username' => __( 'Username', 'wp-members' ),
|
115 |
+
'profile_submit' => __( 'Update Profile', 'wp-members' ),
|
116 |
+
'profile_upload' => __( 'Update this file', 'wp-members' ),
|
117 |
+
|
118 |
+
// Error messages and dialogs.
|
119 |
+
'login_failed_heading' => __( 'Login Failed!', 'wp-members' ), // @deprecated 3.4.0
|
120 |
+
'login_failed' => __( 'You entered an invalid username or password.', 'wp-members' ),
|
121 |
+
'login_failed_link' => __( 'Click here to continue.', 'wp-members' ), // @deprecated 3.4.0
|
122 |
+
'pwdchangempty' => __( 'Password fields cannot be empty', 'wp-members' ),
|
123 |
+
'usernamefailed' => __( 'Sorry, that email address was not found.', 'wp-members' ),
|
124 |
+
'usernamesuccess' => __( 'An email was sent to %s with your username.', 'wp-members' ),
|
125 |
+
'reg_empty_field' => __( 'Sorry, %s is a required field.', 'wp-members' ),
|
126 |
+
'reg_valid_email' => __( 'You must enter a valid email address.', 'wp-members' ),
|
127 |
+
'reg_non_alphanumeric' => __( 'The username cannot include non-alphanumeric characters.', 'wp-members' ),
|
128 |
+
'reg_empty_username' => __( 'Sorry, username is a required field', 'wp-members' ),
|
129 |
+
'reg_username_taken' => __( 'Sorry, that username is taken, Please try another.', 'wp-members' ),
|
130 |
+
'reg_email_taken' => __( 'Sorry, that email address already has an account. Please try another.', 'wp-members' ),
|
131 |
+
'reg_password_match' => __( 'Passwords did not match.', 'wp-members' ),
|
132 |
+
'reg_email_match' => __( 'Emails did not match.', 'wp-members' ),
|
133 |
+
'reg_empty_captcha' => __( 'You must complete the CAPTCHA form.', 'wp-members' ),
|
134 |
+
'reg_invalid_captcha' => __( 'CAPTCHA was not valid.', 'wp-members' ),
|
135 |
+
'reg_generic' => __( 'There was an error processing the form.', 'wp-members' ),
|
136 |
+
'reg_captcha_err' => __( 'There was an error with the CAPTCHA form.', 'wp-members' ),
|
137 |
+
'reg_file_type' => __( 'Sorry, you can only upload the following file types for the %s field: %s.', 'wp-members' ),
|
138 |
+
'profile_update' => __( 'Your information was updated!', 'wp-members' ),
|
139 |
+
|
140 |
+
// Links.
|
141 |
+
'profile_edit' => __( 'Edit My Information', 'wp-members' ),
|
142 |
+
'profile_password' => __( 'Change Password', 'wp-members' ),
|
143 |
+
'register_status' => __( 'You are logged in as %s', 'wp-members' ),
|
144 |
+
'register_logout' => __( 'Log out', 'wp-members' ),
|
145 |
+
'register_continue' => ( isset( $wpmem->user_pages['profile'] ) && '' != $wpmem->user_pages['profile'] ) ? __( 'Edit profile', 'wp-members' ) : __( 'Begin using the site.', 'wp-members' ),
|
146 |
+
'login_welcome' => __( 'You are logged in as %s', 'wp-members' ),
|
147 |
+
'login_logout' => __( 'Click to log out', 'wp-members' ),
|
148 |
+
'status_welcome' => __( 'You are logged in as %s', 'wp-members' ),
|
149 |
+
'status_logout' => __( 'click to log out', 'wp-members' ),
|
150 |
+
'menu_logout' => __( 'Log Out', 'wp-members' ),
|
151 |
+
|
152 |
+
// Widget.
|
153 |
+
'widget_status' => __( 'You are logged in as %s', 'wp-members' ),
|
154 |
+
'widget_logout' => __( 'click here to log out', 'wp-members' ),
|
155 |
+
'widget_login_failed' => __( 'Login Failed!<br />You entered an invalid username or password.', 'wp-members' ),
|
156 |
+
'widget_login_failed_new' => __( 'Invalid username or password.', 'wp-members' ), // @todo New string replacement. Replace widget_login_failed when translated.
|
157 |
+
'widget_not_logged_in' => '',
|
158 |
+
'widget_login_username' => __( 'Username or Email', 'wp-members' ),
|
159 |
+
'widget_login_password' => __( 'Password', 'wp-members' ),
|
160 |
+
'widget_login_button' => __( 'log in', 'wp-members' ),
|
161 |
+
'widget_login_forgot' => __( 'Forgot?', 'wp-members' ),
|
162 |
+
'widget_login_register' => __( 'Register', 'wp-members' ),
|
163 |
+
|
164 |
+
// Default Dialogs.
|
165 |
+
'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' ),
|
166 |
+
'success' => __( "Congratulations! Your registration was successful.<br /><br />You may now log in using the password that was emailed to you.", 'wp-members' ),
|
167 |
+
|
168 |
+
// @todo Under consideration for removal from the Dialogs tab.
|
169 |
+
'user' => __( "Sorry, that username is taken, please try another.", 'wp-members' ),
|
170 |
+
'email' => __( "Sorry, that email address already has an account.<br />Please try another.", 'wp-members' ),
|
171 |
+
'editsuccess' => __( "Your information was updated!", 'wp-members' ),
|
172 |
+
|
173 |
+
// @todo These are defaults and are under consideration for removal from the dialogs tab, possibly as we change the password reset to a link based process.
|
174 |
+
'pwdchangerr' => __( "Passwords did not match.", 'wp-members' ),
|
175 |
+
'pwdchangesuccess' => __( "Password successfully changed.", 'wp-members' ),
|
176 |
+
'pwdreseterr' => __( "Invalid username or email address.", 'wp-members' ),
|
177 |
+
'pwdresetsuccess' => __( "Password successfully reset! An email containing a new password has been sent to the email address on file for your account.", 'wp-members' ),
|
178 |
+
'pwdresetsuccess_alt' => __( "Reset request received. An email with instructions to complete the password reset has been sent.", 'wp-members' ),
|
179 |
+
|
180 |
+
'product_restricted_single' => __( "This content requires the following membership: ", 'wp-members' ),
|
181 |
+
'product_restricted_multiple' => __( "This content requires one of the following memberships: ", 'wp-members' ),
|
182 |
+
|
183 |
+
); // End of $defaults array.
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Filter default terms.
|
187 |
+
*
|
188 |
+
* @since 3.1.0
|
189 |
+
* @deprecated 3.2.7 Use wpmem_default_text instead.
|
190 |
+
*/
|
191 |
+
$text = apply_filters( 'wpmem_default_text_strings', '' );
|
192 |
+
|
193 |
+
// Merge filtered $terms with $defaults.
|
194 |
+
$text = wp_parse_args( $text, $defaults );
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Filter the default terms.
|
198 |
+
*
|
199 |
+
* Replaces 'wpmem_default_text_strings' so that multiple filters could
|
200 |
+
* be run. This allows for custom filters when also running the Text
|
201 |
+
* String Editor extension.
|
202 |
+
*
|
203 |
+
* @since 3.2.7
|
204 |
+
*/
|
205 |
+
$text = apply_filters( 'wpmem_default_text', $text );
|
206 |
+
|
207 |
+
// Manage legacy keys (i.e. sb_ to widget_ ).
|
208 |
+
// @todo Legacy keys to be obsolete by 3.5.0
|
209 |
+
$str = ( false !== strpos( $str, 'sb_' ) ) ? str_replace( 'sb_', 'widget_', $str ) : $str;
|
210 |
+
foreach ( $text as $key => $value ) {
|
211 |
+
if ( false !== strpos( $key, 'sb_' ) ) {
|
212 |
+
$new_key = str_replace( 'sb_', 'widget_', $key );
|
213 |
+
$text[ $new_key ] = $text[ $key ];
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
// Return the requested text string.
|
218 |
+
return $text[ $str ];
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Login Failed Dialog.
|
223 |
+
*
|
224 |
+
* Returns the login failed error message.
|
225 |
+
*
|
226 |
+
* @since 1.8
|
227 |
+
* @since 3.4.0 Removed "continue" (return) link (login form now displays by default under the error message).
|
228 |
+
*
|
229 |
+
* @todo 3.5.0 will fold this into the main message function and this functions associated filters will be obsolete.
|
230 |
+
*
|
231 |
+
* @global object $wpmem The WP_Members object.
|
232 |
+
* @return string $str The generated html for the login failed message.
|
233 |
+
*/
|
234 |
+
function login_failed() {
|
235 |
+
|
236 |
+
global $wpmem;
|
237 |
+
|
238 |
+
// Defaults.
|
239 |
+
$defaults = array(
|
240 |
+
'div_before' => '',
|
241 |
+
'div_after' => '',
|
242 |
+
'heading_before' => '',
|
243 |
+
'heading' => '', //wpmem_get_text( 'login_failed_heading' ),
|
244 |
+
'heading_after' => '',
|
245 |
+
'p_before' => '',
|
246 |
+
'message' => ( $wpmem->error && 1 == $wpmem->login_error ) ? $wpmem->error : wpmem_get_text( 'login_failed' ), // @todo $this->error
|
247 |
+
'p_after' => '',
|
248 |
+
//'link' => '<a href="' . esc_url( $_SERVER['REQUEST_URI'] ) . '">' . wpmem_get_text( 'login_failed_link' ) . '</a>',
|
249 |
+
);
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Filter the login failed dialog arguments.
|
253 |
+
*
|
254 |
+
* @since 2.9.0
|
255 |
+
* @since 3.3.3 Should pass defaults to filter.
|
256 |
+
* @deprecated 3.4.0
|
257 |
+
*
|
258 |
+
* @param array An array of arguments to merge with defaults.
|
259 |
+
*/
|
260 |
+
$args = apply_filters( 'wpmem_login_failed_args', $defaults );
|
261 |
+
|
262 |
+
// Merge $args with defaults.
|
263 |
+
$args = wp_parse_args( $args, $defaults );
|
264 |
+
|
265 |
+
$str = $args['div_before']
|
266 |
+
. $args['heading_before'] . $args['heading'] . $args['heading_after']
|
267 |
+
. $args['p_before'] . $args['message'] . $args['p_after']
|
268 |
+
//. $args['p_before'] . $args['link'] . $args['p_after']
|
269 |
+
. $args['div_after'];
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Filter the login failed dialog.
|
273 |
+
*
|
274 |
+
* @since 2.7.3
|
275 |
+
*
|
276 |
+
* @param string $str The login failed dialog.
|
277 |
+
*/
|
278 |
+
$str = apply_filters( 'wpmem_login_failed', $str );
|
279 |
+
|
280 |
+
return $str;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Gets the message to display.
|
285 |
+
*
|
286 |
+
* @since 3.4.0
|
287 |
+
*
|
288 |
+
* @todo This replaces some other functions and usage seems to be inconsistent.
|
289 |
+
* Review and replace useage as needed.
|
290 |
+
*
|
291 |
+
* @param $tag string
|
292 |
+
* @param $custom string
|
293 |
+
* @return $message string
|
294 |
+
*/
|
295 |
+
function get_message( $tag, $custom = false ) {
|
296 |
+
|
297 |
+
// defaults
|
298 |
+
$defaults = array(
|
299 |
+
'div_before' => '<div class="wpmem_msg">',
|
300 |
+
'div_after' => '</div>',
|
301 |
+
'p_before' => '', // @deprecated 3.4.0
|
302 |
+
'p_after' => '', // @deprecated 3.4.0
|
303 |
+
'tags' => array(
|
304 |
+
'user',
|
305 |
+
'email',
|
306 |
+
'success',
|
307 |
+
'editsuccess',
|
308 |
+
'pwdchangerr',
|
309 |
+
'pwdchangesuccess',
|
310 |
+
'pwdreseterr',
|
311 |
+
'pwdresetsuccess',
|
312 |
+
'loginfailed',
|
313 |
+
),
|
314 |
+
);
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Filter the message arguments.
|
318 |
+
*
|
319 |
+
* @since 2.9.0
|
320 |
+
* @deprecated 3.3.0 Use wpmem_msg_defaults instead.
|
321 |
+
* @todo Obsolete in 3.5.0
|
322 |
+
*
|
323 |
+
* @param array An array of arguments to merge with defaults.
|
324 |
+
*/
|
325 |
+
$args = apply_filters( 'wpmem_msg_args', '' );
|
326 |
+
|
327 |
+
/** This filter is documented in /includes/class-wp-members-admin-api.php */
|
328 |
+
$dialogs = apply_filters( 'wpmem_dialogs', get_option( 'wpmembers_dialogs' ) );
|
329 |
+
|
330 |
+
// @todo Temporary(?) workaround for custom dialogs as an array (WP-Members Security).
|
331 |
+
if ( array_key_exists( $tag, $dialogs ) ) {
|
332 |
+
if ( is_array( $dialogs[ $tag ] ) ) {
|
333 |
+
$msg = stripslashes( $dialogs[ $tag ]['value'] );
|
334 |
+
} else {
|
335 |
+
$msg = wpmem_get_text( $tag );
|
336 |
+
$msg = ( $dialogs[ $tag ] == $msg ) ? $msg : __( stripslashes( $dialogs[ $tag ] ), 'wp-members' );
|
337 |
+
}
|
338 |
+
} elseif ( 'loginfailed' == $tag ) {
|
339 |
+
$msg = $this->login_failed();
|
340 |
+
} elseif ( $custom ) {
|
341 |
+
$msg = $custom;
|
342 |
+
} else {
|
343 |
+
// It must be a custom message ("custom" in that it is not included in the dialogs array).
|
344 |
+
$msg = $tag;
|
345 |
+
}
|
346 |
+
|
347 |
+
$defaults['msg'] = $msg;
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Filter the message array
|
351 |
+
*
|
352 |
+
* @since 2.9.2
|
353 |
+
* @since 3.1.1 added $dialogs parameter.
|
354 |
+
* @deprecated 3.3.0 Use wpmem_msg_defaults instead.
|
355 |
+
* @todo Obsolete in 3.5.0
|
356 |
+
*
|
357 |
+
* @param array $defaults An array of the defaults.
|
358 |
+
* @param string $tag The tag that we are on, if any.
|
359 |
+
* @param array $dialogs
|
360 |
+
*/
|
361 |
+
$defaults = apply_filters( 'wpmem_msg_dialog_arr', $defaults, $tag, $dialogs );
|
362 |
+
|
363 |
+
// Merge $args with defaults.
|
364 |
+
$args = wp_parse_args( $args, $defaults );
|
365 |
+
|
366 |
+
// Backwards compatibility for 'toggles'.
|
367 |
+
if ( isset( $args['toggles'] ) ) {
|
368 |
+
$args['tags'] = $args['toggles'];
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Filter the message settings.
|
373 |
+
*
|
374 |
+
* @since 3.3.0
|
375 |
+
*
|
376 |
+
* @param array $defaults An array of the defaults.
|
377 |
+
* @param string $tag The tag that we are on, if any.
|
378 |
+
* @param array $dialogs
|
379 |
+
*/
|
380 |
+
$args = apply_filters( 'wpmem_msg_defaults', $defaults, $tag, $dialogs );
|
381 |
+
|
382 |
+
// @todo Temporary(?) workaround for custom dialogs as an array (WP-Members Security).
|
383 |
+
$display_msg = ( is_array( $args['msg'] ) ) ? $args['msg']['value'] : $args['msg'];
|
384 |
+
|
385 |
+
$str = $args['div_before'] . stripslashes( $display_msg ) . $args['div_after'];
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Filter the message.
|
389 |
+
*
|
390 |
+
* @since 2.7.4
|
391 |
+
* @since 3.1.0 Added tag.
|
392 |
+
*
|
393 |
+
* @param string $str The message.
|
394 |
+
* @param string $tag The tag of the message being displayed.
|
395 |
+
*/
|
396 |
+
return apply_filters( 'wpmem_msg_dialog', $str, $tag );
|
397 |
+
}
|
398 |
+
}
|
@@ -7,13 +7,13 @@
|
|
7 |
*
|
8 |
* This file is part of the WP-Members plugin by Chad Butler
|
9 |
* You can find out more about this plugin at https://rocketgeek.com
|
10 |
-
* Copyright (c) 2006-
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP_Members_Shortcodes
|
15 |
* @author Chad Butler
|
16 |
-
* @copyright 2006-
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
@@ -50,14 +50,33 @@ class WP_Members_Email {
|
|
50 |
*/
|
51 |
public $settings;
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
/**
|
54 |
* Load custom from address.
|
55 |
*
|
56 |
* @since 3.3.0
|
57 |
*/
|
58 |
-
function load_from() {
|
59 |
$this->from = get_option( 'wpmembers_email_wpfrom', '' );
|
60 |
$this->from_name = get_option( 'wpmembers_email_wpname', '' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -83,12 +102,13 @@ class WP_Members_Email {
|
|
83 |
* @param array $fields Array of the registration data (defaults to null).
|
84 |
* @param array $custom Array of custom email information (defaults to null).
|
85 |
*/
|
86 |
-
function to_user( $user_id, $password, $tag, $wpmem_fields = null, $field_data = null, $custom = null ) {
|
87 |
|
88 |
global $wpmem;
|
89 |
|
90 |
-
// Load
|
91 |
$this->load_from();
|
|
|
92 |
|
93 |
// Handle backward compatibility for customizations that may call the email function directly.
|
94 |
$wpmem_fields = wpmem_fields();
|
@@ -116,6 +136,11 @@ class WP_Members_Email {
|
|
116 |
$this->settings['tag'] = ( isset( $custom['tag'] ) ) ? $custom['tag'] : '';
|
117 |
break;
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
// Get the user ID.
|
121 |
$user = new WP_User( $user_id );
|
@@ -133,7 +158,7 @@ class WP_Members_Email {
|
|
133 |
$this->settings['reg_link'] = esc_url( get_user_meta( $user_id, 'wpmem_reg_url', true ) );
|
134 |
$this->settings['do_shortcodes'] = true;
|
135 |
$this->settings['add_footer'] = true;
|
136 |
-
$this->settings['footer'] = get_option( 'wpmembers_email_footer' );
|
137 |
$this->settings['disable'] = false;
|
138 |
$this->settings['toggle'] = $this->settings['tag']; // Deprecated since 3.2.0, but remains in the array for legacy reasons.
|
139 |
$this->settings['reset_link'] = esc_url_raw( add_query_arg( array( 'a' => 'pwdreset', 'key' => $password, 'id' => $user_id ), wpmem_profile_url() ) );
|
@@ -283,7 +308,7 @@ class WP_Members_Email {
|
|
283 |
* @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
|
284 |
* @param array $field_data Array of the registration data (defaults to null).
|
285 |
*/
|
286 |
-
function notify_admin( $user_id, $wpmem_fields = null, $field_data = null ) {
|
287 |
|
288 |
global $wpmem;
|
289 |
|
@@ -342,7 +367,6 @@ class WP_Members_Email {
|
|
342 |
} else {
|
343 |
$val = ( is_array( $field_data ) ) ? esc_html( $field_data[ $meta_key ] ) : esc_html( get_user_meta( $user_id, $meta_key, true ) );
|
344 |
}
|
345 |
-
// $field_arr[ $field['label'] ] = $val; // @todo Consider (1) if this should be implemented, and (2) if it should be done here or location "B".
|
346 |
$field_arr[ __( $field['label'], 'wp-members' ) ] = $val;
|
347 |
}
|
348 |
}
|
@@ -375,6 +399,7 @@ class WP_Members_Email {
|
|
375 |
* data from the register function.
|
376 |
*
|
377 |
* @since 2.9.8
|
|
|
378 |
*
|
379 |
* @param array $this->settings P
|
380 |
* An array containing email body, subject, user id, and additional settings.
|
@@ -398,10 +423,11 @@ class WP_Members_Email {
|
|
398 |
* @type string $headers
|
399 |
* @type string $admin_email
|
400 |
* }
|
401 |
-
* @param array
|
402 |
-
* @param array
|
|
|
403 |
*/
|
404 |
-
$this->settings = apply_filters( 'wpmem_notify_filter', $this->settings, $wpmem_fields, $field_data );
|
405 |
|
406 |
// If emails are not disabled, continue the email process.
|
407 |
if ( ! $this->settings['disable'] ) {
|
@@ -410,8 +436,6 @@ class WP_Members_Email {
|
|
410 |
$field_str = '';
|
411 |
foreach ( $this->settings['field_arr'] as $key => $val ) {
|
412 |
$field_str.= $key . ': ' . $val . "\r\n";
|
413 |
-
// @todo Location "B" to to label translation. Could be as follows:
|
414 |
-
// $field_str.= __( $key, 'wp-members' ) . ": " . $val . "\r\n";
|
415 |
}
|
416 |
|
417 |
// Get the email footer if needed.
|
@@ -476,12 +500,6 @@ class WP_Members_Email {
|
|
476 |
/**
|
477 |
* Filters the admin notification email.
|
478 |
*
|
479 |
-
* This is the last chance to filter the message body. At this point
|
480 |
-
* it is just the text that will be in the message.
|
481 |
-
* @todo Consider deprecating this filter as it could be accomplished
|
482 |
-
* by the wp_mail filter, or a universal filter could be added
|
483 |
-
* to the new email send function.
|
484 |
-
*
|
485 |
* @since 2.8.2
|
486 |
*
|
487 |
* @param string $this->settings['body'] The admin notification email body.
|
@@ -500,13 +518,10 @@ class WP_Members_Email {
|
|
500 |
* @since 3.1.0 Converted to use email var in object.
|
501 |
* @since 3.2.0 Moved to WP_Members_Email::from().
|
502 |
*
|
503 |
-
* @global object $wpmem
|
504 |
-
*
|
505 |
* @param string $email
|
506 |
* @return string $wpmem_mail_from|$email
|
507 |
*/
|
508 |
-
function from( $email ) {
|
509 |
-
global $wpmem;
|
510 |
return ( $this->from ) ? $this->from : $email;
|
511 |
}
|
512 |
|
@@ -517,15 +532,23 @@ class WP_Members_Email {
|
|
517 |
* @since 3.1.0 Converted to use email var in object.
|
518 |
* @since 3.2.0 Moved to WP_Members_Email::from_name().
|
519 |
*
|
520 |
-
* @global object $wpmem
|
521 |
-
*
|
522 |
* @param string $name
|
523 |
* @return string $wpmem_mail_from_name|$name
|
524 |
*/
|
525 |
-
function from_name( $name ) {
|
526 |
-
global $wpmem;
|
527 |
return ( $this->from_name ) ? stripslashes( $this->from_name ) : stripslashes( $name );
|
528 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
|
530 |
/**
|
531 |
* Sends email.
|
@@ -535,7 +558,7 @@ class WP_Members_Email {
|
|
535 |
* @param string $to
|
536 |
* @return bool $result
|
537 |
*/
|
538 |
-
function send( $to ) {
|
539 |
$args['to'] = ( 'user' == $to ) ? $this->settings['user_email'] : $this->settings['admin_email'];
|
540 |
$args['subject'] = $this->settings['subj'];
|
541 |
$args['message'] = $this->settings['body'];
|
@@ -551,10 +574,21 @@ class WP_Members_Email {
|
|
551 |
* @param array $this->settings
|
552 |
*/
|
553 |
$args = apply_filters( 'wpmem_email_send_args', $args, $to, $this->settings );
|
554 |
-
|
555 |
-
|
556 |
-
add_filter( '
|
557 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
return $result;
|
559 |
}
|
560 |
}
|
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-2021 Chad Butler
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP_Members_Shortcodes
|
15 |
* @author Chad Butler
|
16 |
+
* @copyright 2006-2021
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
50 |
*/
|
51 |
public $settings;
|
52 |
|
53 |
+
/**
|
54 |
+
* Setting for HTML email.
|
55 |
+
*
|
56 |
+
* @since 3.4.0
|
57 |
+
* @access public
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
public $html = 0;
|
61 |
+
|
62 |
/**
|
63 |
* Load custom from address.
|
64 |
*
|
65 |
* @since 3.3.0
|
66 |
*/
|
67 |
+
public function load_from() {
|
68 |
$this->from = get_option( 'wpmembers_email_wpfrom', '' );
|
69 |
$this->from_name = get_option( 'wpmembers_email_wpname', '' );
|
70 |
+
$this->html = get_option( 'wpmembers_email_html', '' );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Load plugin HTML email setting.
|
75 |
+
*
|
76 |
+
* @since 3.4.0
|
77 |
+
*/
|
78 |
+
private function load_format() {
|
79 |
+
$this->html = get_option( 'wpmembers_email_html', 0 );
|
80 |
}
|
81 |
|
82 |
/**
|
102 |
* @param array $fields Array of the registration data (defaults to null).
|
103 |
* @param array $custom Array of custom email information (defaults to null).
|
104 |
*/
|
105 |
+
public function to_user( $user_id, $password, $tag, $wpmem_fields = null, $field_data = null, $custom = null ) {
|
106 |
|
107 |
global $wpmem;
|
108 |
|
109 |
+
// Load settings.
|
110 |
$this->load_from();
|
111 |
+
$this->load_format();
|
112 |
|
113 |
// Handle backward compatibility for customizations that may call the email function directly.
|
114 |
$wpmem_fields = wpmem_fields();
|
136 |
$this->settings['tag'] = ( isset( $custom['tag'] ) ) ? $custom['tag'] : '';
|
137 |
break;
|
138 |
}
|
139 |
+
|
140 |
+
// wpautop() the content if we are doing HTML email.
|
141 |
+
if ( 1 == $this->html ) {
|
142 |
+
$this->settings['body'] = wpautop( $this->settings['body'] );
|
143 |
+
}
|
144 |
|
145 |
// Get the user ID.
|
146 |
$user = new WP_User( $user_id );
|
158 |
$this->settings['reg_link'] = esc_url( get_user_meta( $user_id, 'wpmem_reg_url', true ) );
|
159 |
$this->settings['do_shortcodes'] = true;
|
160 |
$this->settings['add_footer'] = true;
|
161 |
+
$this->settings['footer'] = ( 1 == $this->html ) ? wpautop( get_option( 'wpmembers_email_footer' ) ) : get_option( 'wpmembers_email_footer' );
|
162 |
$this->settings['disable'] = false;
|
163 |
$this->settings['toggle'] = $this->settings['tag']; // Deprecated since 3.2.0, but remains in the array for legacy reasons.
|
164 |
$this->settings['reset_link'] = esc_url_raw( add_query_arg( array( 'a' => 'pwdreset', 'key' => $password, 'id' => $user_id ), wpmem_profile_url() ) );
|
308 |
* @param array $wpmem_fields Array of the WP-Members fields (defaults to null).
|
309 |
* @param array $field_data Array of the registration data (defaults to null).
|
310 |
*/
|
311 |
+
public function notify_admin( $user_id, $wpmem_fields = null, $field_data = null ) {
|
312 |
|
313 |
global $wpmem;
|
314 |
|
367 |
} else {
|
368 |
$val = ( is_array( $field_data ) ) ? esc_html( $field_data[ $meta_key ] ) : esc_html( get_user_meta( $user_id, $meta_key, true ) );
|
369 |
}
|
|
|
370 |
$field_arr[ __( $field['label'], 'wp-members' ) ] = $val;
|
371 |
}
|
372 |
}
|
399 |
* data from the register function.
|
400 |
*
|
401 |
* @since 2.9.8
|
402 |
+
* @since 3.3.9 Added $user param.
|
403 |
*
|
404 |
* @param array $this->settings P
|
405 |
* An array containing email body, subject, user id, and additional settings.
|
423 |
* @type string $headers
|
424 |
* @type string $admin_email
|
425 |
* }
|
426 |
+
* @param array $wpmem_fields An array of the WP-Members fields.
|
427 |
+
* @param array $field_data An array of the posted registration data.
|
428 |
+
* @param stdClass $user WP user object for the specific user.
|
429 |
*/
|
430 |
+
$this->settings = apply_filters( 'wpmem_notify_filter', $this->settings, $wpmem_fields, $field_data, $user );
|
431 |
|
432 |
// If emails are not disabled, continue the email process.
|
433 |
if ( ! $this->settings['disable'] ) {
|
436 |
$field_str = '';
|
437 |
foreach ( $this->settings['field_arr'] as $key => $val ) {
|
438 |
$field_str.= $key . ': ' . $val . "\r\n";
|
|
|
|
|
439 |
}
|
440 |
|
441 |
// Get the email footer if needed.
|
500 |
/**
|
501 |
* Filters the admin notification email.
|
502 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
* @since 2.8.2
|
504 |
*
|
505 |
* @param string $this->settings['body'] The admin notification email body.
|
518 |
* @since 3.1.0 Converted to use email var in object.
|
519 |
* @since 3.2.0 Moved to WP_Members_Email::from().
|
520 |
*
|
|
|
|
|
521 |
* @param string $email
|
522 |
* @return string $wpmem_mail_from|$email
|
523 |
*/
|
524 |
+
public function from( $email ) {
|
|
|
525 |
return ( $this->from ) ? $this->from : $email;
|
526 |
}
|
527 |
|
532 |
* @since 3.1.0 Converted to use email var in object.
|
533 |
* @since 3.2.0 Moved to WP_Members_Email::from_name().
|
534 |
*
|
|
|
|
|
535 |
* @param string $name
|
536 |
* @return string $wpmem_mail_from_name|$name
|
537 |
*/
|
538 |
+
public function from_name( $name ) {
|
|
|
539 |
return ( $this->from_name ) ? stripslashes( $this->from_name ) : stripslashes( $name );
|
540 |
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Returns HTML content type for email.
|
544 |
+
*
|
545 |
+
* @since 3.4.0
|
546 |
+
*
|
547 |
+
* @return string Always returns "text/html"
|
548 |
+
*/
|
549 |
+
public function content_type( $content_type ) {
|
550 |
+
return ( 1 == $this->html ) ? 'text/html' : $content_type;
|
551 |
+
}
|
552 |
|
553 |
/**
|
554 |
* Sends email.
|
558 |
* @param string $to
|
559 |
* @return bool $result
|
560 |
*/
|
561 |
+
private function send( $to ) {
|
562 |
$args['to'] = ( 'user' == $to ) ? $this->settings['user_email'] : $this->settings['admin_email'];
|
563 |
$args['subject'] = $this->settings['subj'];
|
564 |
$args['message'] = $this->settings['body'];
|
574 |
* @param array $this->settings
|
575 |
*/
|
576 |
$args = apply_filters( 'wpmem_email_send_args', $args, $to, $this->settings );
|
577 |
+
|
578 |
+
// Apply filters.
|
579 |
+
add_filter( 'wp_mail_from', array( $this, 'from' ) );
|
580 |
+
add_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
|
581 |
+
add_filter( 'wp_mail_content_type', array( $this, 'content_type' ) );
|
582 |
+
|
583 |
+
// Send message.
|
584 |
+
$result = wp_mail( $args['to'], stripslashes( $args['subject'] ), stripslashes( $args['message'] ) );
|
585 |
+
|
586 |
+
// Remove customizations.
|
587 |
+
remove_filter( 'wp_mail_from', array( $this, 'from' ) );
|
588 |
+
remove_filter( 'wp_mail_from_name', array( $this, 'from_name' ) );
|
589 |
+
remove_filter( 'wp_mail_content_type', array( $this, 'content_type' ) );
|
590 |
+
|
591 |
+
// Return result (does not necessarily indicate message was sent).
|
592 |
return $result;
|
593 |
}
|
594 |
}
|
@@ -1,2129 +1,2181 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members Forms Class.
|
4 |
-
*
|
5 |
-
* @package WP-Members
|
6 |
-
* @subpackage WP_Members Forms Object Class
|
7 |
-
* @since 3.1.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly.
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit();
|
13 |
-
}
|
14 |
-
|
15 |
-
class WP_Members_Forms {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Plugin initialization function.
|
19 |
-
*
|
20 |
-
* @since 3.1.0
|
21 |
-
*/
|
22 |
-
function __construct() {
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
* @since 3.
|
32 |
-
*
|
33 |
-
* @
|
34 |
-
* @
|
35 |
-
* @
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
$
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
*
|
237 |
-
*
|
238 |
-
*
|
239 |
-
*
|
240 |
-
*
|
241 |
-
*
|
242 |
-
*
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
$
|
256 |
-
$
|
257 |
-
$
|
258 |
-
$
|
259 |
-
$
|
260 |
-
$
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
*
|
432 |
-
*
|
433 |
-
*
|
434 |
-
*
|
435 |
-
*
|
436 |
-
*
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
$
|
456 |
-
|
457 |
-
$
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
'
|
544 |
-
'
|
545 |
-
'
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
*
|
654 |
-
*
|
655 |
-
*
|
656 |
-
*
|
657 |
-
* @
|
658 |
-
* @
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
*
|
672 |
-
*
|
673 |
-
*
|
674 |
-
*
|
675 |
-
*
|
676 |
-
*
|
677 |
-
*
|
678 |
-
*
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
$
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
$form =
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
*
|
796 |
-
*
|
797 |
-
*
|
798 |
-
*
|
799 |
-
*
|
800 |
-
* @
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
*
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
$
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
)
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
'
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
$
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
*
|
1304 |
-
*
|
1305 |
-
*
|
1306 |
-
*
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
<
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
*
|
1400 |
-
*
|
1401 |
-
*
|
1402 |
-
*
|
1403 |
-
* @param
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
*
|
1416 |
-
*
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
//
|
1480 |
-
$
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
*
|
1518 |
-
*
|
1519 |
-
* @
|
1520 |
-
*
|
1521 |
-
* @param
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
*
|
1528 |
-
*
|
1529 |
-
*
|
1530 |
-
*
|
1531 |
-
*
|
1532 |
-
* @type string
|
1533 |
-
* @type string
|
1534 |
-
* @type string
|
1535 |
-
* @type string
|
1536 |
-
* @type
|
1537 |
-
*
|
1538 |
-
*
|
1539 |
-
*
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
$
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
'
|
1951 |
-
array(
|
1952 |
-
'name' =>
|
1953 |
-
'type' => 'text',
|
1954 |
-
'tag' => '
|
1955 |
-
'class' => 'username',
|
1956 |
-
'div' => 'div_text',
|
1957 |
-
),
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
*
|
2012 |
-
*
|
2013 |
-
* @
|
2014 |
-
*
|
2015 |
-
* @param array $
|
2016 |
-
*/
|
2017 |
-
$
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
*
|
2075 |
-
*
|
2076 |
-
*
|
2077 |
-
*
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
$
|
2088 |
-
|
2089 |
-
|
2090 |
-
$
|
2091 |
-
$
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2129 |
} // End of WP_Members_Forms class.
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members Forms Class.
|
4 |
+
*
|
5 |
+
* @package WP-Members
|
6 |
+
* @subpackage WP_Members Forms Object Class
|
7 |
+
* @since 3.1.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly.
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit();
|
13 |
+
}
|
14 |
+
|
15 |
+
class WP_Members_Forms {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Plugin initialization function.
|
19 |
+
*
|
20 |
+
* @since 3.1.0
|
21 |
+
*/
|
22 |
+
function __construct() {
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Sets the registration fields.
|
28 |
+
*
|
29 |
+
* @since 3.0.0
|
30 |
+
* @since 3.1.5 Added $form argument.
|
31 |
+
* @since 3.3.0 Added $tag argument.
|
32 |
+
*
|
33 |
+
* @global stdClass $wpmem
|
34 |
+
* @param string $tag
|
35 |
+
* @param string $form The form being generated.
|
36 |
+
*/
|
37 |
+
function load_fields( $tag = 'new', $form = 'default' ) {
|
38 |
+
|
39 |
+
global $wpmem;
|
40 |
+
|
41 |
+
// Get stored fields settings.
|
42 |
+
$fields = get_option( 'wpmembers_fields' );
|
43 |
+
|
44 |
+
// Validate fields settings.
|
45 |
+
if ( ! isset( $fields ) || empty( $fields ) ) {
|
46 |
+
// Update settings.
|
47 |
+
$fields = array( array( 10, 'Email', 'user_email', 'email', 'y', 'y', 'y', 'profile'=>true ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
// Add new field array keys
|
51 |
+
foreach ( $fields as $key => $val ) {
|
52 |
+
|
53 |
+
// Key fields with meta key.
|
54 |
+
$meta_key = $val[2];
|
55 |
+
|
56 |
+
// Old format, new key.
|
57 |
+
foreach ( $val as $subkey => $subval ) {
|
58 |
+
$wpmem->fields[ $meta_key ][ $subkey ] = $subval;
|
59 |
+
}
|
60 |
+
|
61 |
+
// Setup field properties.
|
62 |
+
$wpmem->fields[ $meta_key ]['label'] = $val[1];
|
63 |
+
$wpmem->fields[ $meta_key ]['type'] = $val[3];
|
64 |
+
$wpmem->fields[ $meta_key ]['register'] = ( 'y' == $val[4] ) ? true : false;
|
65 |
+
$wpmem->fields[ $meta_key ]['required'] = ( 'y' == $val[5] ) ? true : false;
|
66 |
+
$wpmem->fields[ $meta_key ]['profile'] = ( 'y' == $val[4] ) ? true : false;// ( isset( $val['profile'] ) ) ? $val['profile'] : true ; // // @todo Wait for profile fix
|
67 |
+
$wpmem->fields[ $meta_key ]['native'] = ( 'y' == $val[6] ) ? true : false;
|
68 |
+
|
69 |
+
// Certain field types have additional properties.
|
70 |
+
switch ( $val[3] ) {
|
71 |
+
|
72 |
+
case 'checkbox':
|
73 |
+
$wpmem->fields[ $meta_key ]['checked_value'] = $val[7];
|
74 |
+
$wpmem->fields[ $meta_key ]['checked_default'] = ( 'y' == $val[8] ) ? true : false;
|
75 |
+
$wpmem->fields[ $meta_key ]['checkbox_label'] = ( isset( $val['checkbox_label'] ) ) ? $val['checkbox_label'] : 0;
|
76 |
+
break;
|
77 |
+
|
78 |
+
case 'select':
|
79 |
+
case 'multiselect':
|
80 |
+
case 'multicheckbox':
|
81 |
+
case 'radio':
|
82 |
+
case 'membership':
|
83 |
+
if ( 'membership' == $val[3] ) {
|
84 |
+
$val[7] = array( __( 'Choose membership', 'wp-members' ) . '|' );
|
85 |
+
foreach( $wpmem->membership->products as $membership_key => $membership_value ) {
|
86 |
+
$val[7][] = $membership_value['title'] . '|' . $membership_key;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
// Correct a malformed value (if last value is empty due to a trailing comma).
|
90 |
+
if ( '' == end( $val[7] ) ) {
|
91 |
+
array_pop( $val[7] );
|
92 |
+
$wpmem->fields[ $meta_key ][7] = $val[7];
|
93 |
+
}
|
94 |
+
$wpmem->fields[ $meta_key ]['values'] = $val[7];
|
95 |
+
$wpmem->fields[ $meta_key ]['delimiter'] = ( isset( $val[8] ) ) ? $val[8] : '|';
|
96 |
+
$wpmem->fields[ $meta_key ]['options'] = array();
|
97 |
+
foreach ( $val[7] as $value ) {
|
98 |
+
$pieces = explode( '|', trim( $value ) );
|
99 |
+
if ( isset( $pieces[1] ) && $pieces[1] != '' ) {
|
100 |
+
$wpmem->fields[ $meta_key ]['options'][ $pieces[1] ] = $pieces[0];
|
101 |
+
}
|
102 |
+
}
|
103 |
+
break;
|
104 |
+
|
105 |
+
case 'file':
|
106 |
+
case 'image':
|
107 |
+
$wpmem->fields[ $meta_key ]['file_types'] = $val[7];
|
108 |
+
break;
|
109 |
+
|
110 |
+
case 'hidden':
|
111 |
+
$wpmem->fields[ $meta_key ]['value'] = $val[7];
|
112 |
+
break;
|
113 |
+
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Filter custom fields for localization.
|
120 |
+
*
|
121 |
+
* @since 3.3.9
|
122 |
+
*
|
123 |
+
* @param array $fields
|
124 |
+
*/
|
125 |
+
function localize_fields( $fields ) {
|
126 |
+
if ( function_exists( 'wpmem_custom_translation_strings' ) ) {
|
127 |
+
$string_map = wpmem_custom_translation_strings( get_locale() );
|
128 |
+
foreach ( $string_map as $meta_key => $value ) {
|
129 |
+
if ( is_array( $value ) ) {
|
130 |
+
if ( isset( $fields[ $meta_key ]['placeholder'] ) && isset( $value['placeholder'] ) ) {
|
131 |
+
$fields[ $meta_key ]['placeholder'] = $string_map[ $meta_key ]['placeholder'];
|
132 |
+
}
|
133 |
+
if ( isset( $fields[ $meta_key ]['title'] ) && isset( $value['title'] ) ) {
|
134 |
+
$fields[ $meta_key ]['title'] = $string_map[ $meta_key ]['title'];
|
135 |
+
}
|
136 |
+
if ( isset( $fields[ $meta_key ]['label'] ) && isset( $value['label'] ) ) {
|
137 |
+
$fields[ $meta_key ]['label'] = $string_map[ $meta_key ]['label'];
|
138 |
+
}
|
139 |
+
} else {
|
140 |
+
$fields[ $meta_key ]['label'] = $string_map[ $meta_key ];
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
return $fields;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get excluded meta fields.
|
149 |
+
*
|
150 |
+
* @since 3.0.0
|
151 |
+
* @since 3.3.3 Update $tag to match wpmem_fields() tags.
|
152 |
+
*
|
153 |
+
* @param string $tag A tag so we know where the function is being used.
|
154 |
+
* @return array The excluded fields.
|
155 |
+
*/
|
156 |
+
function excluded_fields( $tag ) {
|
157 |
+
|
158 |
+
// Default excluded fields.
|
159 |
+
$excluded_fields = array( 'password', 'confirm_password', 'confirm_email', 'password_confirm', 'email_confirm' );
|
160 |
+
|
161 |
+
if ( 'update' == $tag || 'admin-profile' == $tag || 'user-profile' == $tag || 'wp-register' == $tag ) {
|
162 |
+
$excluded_fields[] = 'username';
|
163 |
+
}
|
164 |
+
|
165 |
+
if ( 'admin-profile' == $tag || 'user-profile' == $tag ) {
|
166 |
+
array_push( $excluded_fields, 'first_name', 'last_name', 'nickname', 'display_name', 'user_email', 'description', 'user_url' );
|
167 |
+
|
168 |
+
// If WooCommerce is used, remove these meta - WC already adds them in their own section.
|
169 |
+
if ( class_exists( 'woocommerce' ) ) {
|
170 |
+
array_push( $excluded_fields,
|
171 |
+
'billing_first_name',
|
172 |
+
'billing_last_name',
|
173 |
+
'billing_company',
|
174 |
+
'billing_address_1',
|
175 |
+
'billing_address_2',
|
176 |
+
'billing_city',
|
177 |
+
'billing_postcode',
|
178 |
+
'billing_country',
|
179 |
+
'billing_state',
|
180 |
+
'billing_email',
|
181 |
+
'billing_phone',
|
182 |
+
'shipping_first_name',
|
183 |
+
'shipping_last_name',
|
184 |
+
'shipping_company',
|
185 |
+
'shipping_address_1',
|
186 |
+
'shipping_address_2',
|
187 |
+
'shipping_city',
|
188 |
+
'shipping_postcode',
|
189 |
+
'shipping_country',
|
190 |
+
'shipping_state'
|
191 |
+
);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Filter excluded meta fields.
|
197 |
+
*
|
198 |
+
* @since 2.9.3
|
199 |
+
* @since 3.0.0 Moved to new method in WP_Members Class.
|
200 |
+
* @since 3.3.3 Update $tag to match wpmem_fields() tags.
|
201 |
+
*
|
202 |
+
* @param array An array of the field meta names to exclude.
|
203 |
+
* @param string $tag A tag so we know where the function is being used.
|
204 |
+
*/
|
205 |
+
$excluded_fields = apply_filters( 'wpmem_exclude_fields', $excluded_fields, $tag );
|
206 |
+
|
207 |
+
// Return excluded fields.
|
208 |
+
return $excluded_fields;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Creates form fields
|
213 |
+
*
|
214 |
+
* Creates various form fields and returns them as a string.
|
215 |
+
*
|
216 |
+
* @since 3.1.0
|
217 |
+
* @since 3.1.1 Added $delimiter.
|
218 |
+
* @since 3.1.2 Changed $valtochk to $compare.
|
219 |
+
* @since 3.1.6 Added $placeholder.
|
220 |
+
* @since 3.1.7 Added number type & $min, $max, $title and $pattern attributes.
|
221 |
+
* @since 3.2.0 Added $id argument.
|
222 |
+
* @since 3.2.4 Added radio group and multiple checkbox individual item labels.
|
223 |
+
*
|
224 |
+
* @global object $wpmem The WP_Members object class.
|
225 |
+
* @param array $args {
|
226 |
+
* @type string $id
|
227 |
+
* @type string $name
|
228 |
+
* @type string $type
|
229 |
+
* @type string $value
|
230 |
+
* @type string $compare
|
231 |
+
* @type string $class
|
232 |
+
* @type boolean $required
|
233 |
+
* @type string $delimiter
|
234 |
+
* @type string $placeholder
|
235 |
+
* @type string $pattern
|
236 |
+
* @type string $title
|
237 |
+
* @type string $min
|
238 |
+
* @type string $max
|
239 |
+
* @type string $rows Number of rows for a textarea (default:5).
|
240 |
+
* @type string $cols Number of columns for a textarea (default:20).
|
241 |
+
* }
|
242 |
+
* @return string $str The field returned as a string.
|
243 |
+
*/
|
244 |
+
function create_form_field( $args ) {
|
245 |
+
|
246 |
+
global $wpmem;
|
247 |
+
|
248 |
+
// Set defaults for most possible $args.
|
249 |
+
$id = ( isset( $args['id'] ) ) ? esc_attr( $args['id'] ) : esc_attr( $args['name'] );
|
250 |
+
$name = esc_attr( $args['name'] );
|
251 |
+
$type = esc_attr( $args['type'] );
|
252 |
+
$value = ( isset( $args['value'] ) ) ? $args['value'] : '';
|
253 |
+
$compare = ( isset( $args['compare'] ) ) ? $args['compare'] : '';
|
254 |
+
$class = ( isset( $args['class'] ) ) ? $args['class'] : 'textbox';
|
255 |
+
$required = ( isset( $args['required'] ) ) ? $args['required'] : false;
|
256 |
+
$delimiter = ( isset( $args['delimiter'] ) ) ? $args['delimiter'] : '|';
|
257 |
+
$placeholder = ( isset( $args['placeholder'] ) ) ? $args['placeholder'] : false;
|
258 |
+
$pattern = ( isset( $args['pattern'] ) ) ? $args['pattern'] : false;
|
259 |
+
$title = ( isset( $args['title'] ) ) ? $args['title'] : false;
|
260 |
+
$file_types = ( isset( $args['file_types'] ) ) ? $args['file_types'] : false;
|
261 |
+
|
262 |
+
// Handle field creation by type.
|
263 |
+
switch ( $type ) {
|
264 |
+
|
265 |
+
/*
|
266 |
+
* Field types text|url|email|number|date are all handled essentially the
|
267 |
+
* same. The primary differences are CSS class (with a default fallback
|
268 |
+
* of 'textbox'), how values are escaped, and the application of min|max
|
269 |
+
* values for number fields.
|
270 |
+
*/
|
271 |
+
case "text":
|
272 |
+
case "url":
|
273 |
+
case "email":
|
274 |
+
case "number":
|
275 |
+
case "date":
|
276 |
+
$class = ( 'textbox' == $class ) ? "textbox" : wpmem_sanitize_class( $class );
|
277 |
+
switch ( $type ) {
|
278 |
+
case 'url':
|
279 |
+
$value = esc_url( $value );
|
280 |
+
break;
|
281 |
+
case 'email':
|
282 |
+
$value = esc_attr( wp_unslash( $value ) );
|
283 |
+
break;
|
284 |
+
default:
|
285 |
+
$value = stripslashes( esc_attr( $value ) ); // @todo Could email and default be combined? Both seem to unslash and esc_attr().
|
286 |
+
break;
|
287 |
+
}
|
288 |
+
$required = ( $required ) ? ' required' : '';
|
289 |
+
$placeholder = ( $placeholder ) ? ' placeholder="' . esc_attr( __( $placeholder, 'wp-members' ) ) . '"' : '';
|
290 |
+
$title = ( $title ) ? ' title="' . esc_attr( __( $title, 'wp-members' ) ) . '"' : '';
|
291 |
+
$pattern = ( $pattern && 'number' != $type ) ? ' pattern="' . esc_attr( $pattern ) . '"' : '';
|
292 |
+
$min = ( isset( $args['min'] ) && $args['min'] != '' ) ? ' min="' . esc_attr( $args['min'] ) . '"' : '';
|
293 |
+
$max = ( isset( $args['max'] ) && $args['max'] != '' ) ? ' max="' . esc_attr( $args['max'] ). '"' : '';
|
294 |
+
$str = "<input name=\"$name\" type=\"$type\" id=\"$id\" value=\"$value\" class=\"$class\"$placeholder$title$pattern$min$max" . ( ( $required ) ? " required " : "" ) . " />";
|
295 |
+
break;
|
296 |
+
|
297 |
+
case "password":
|
298 |
+
$class = wpmem_sanitize_class( $class );
|
299 |
+
$placeholder = ( $placeholder ) ? ' placeholder="' . esc_attr( __( $placeholder, 'wp-members' ) ) . '"' : '';
|
300 |
+
$pattern = ( $pattern ) ? ' pattern="' . esc_attr( $pattern ) . '"' : '';
|
301 |
+
$title = ( $title ) ? ' title="' . esc_attr( __( $title, 'wp-members' ) ) . '"' : '';
|
302 |
+
$str = "<input name=\"$name\" type=\"$type\" id=\"$id\" class=\"$class\"$placeholder$title$pattern" . ( ( $required ) ? " required " : "" ) . " />";
|
303 |
+
break;
|
304 |
+
|
305 |
+
case "image":
|
306 |
+
case "file":
|
307 |
+
if ( $file_types ) {
|
308 |
+
$file_types = explode( '|', $file_types );
|
309 |
+
foreach( $file_types as $file_type ) {
|
310 |
+
$array[] = "." . $file_type;
|
311 |
+
}
|
312 |
+
$accept = ' accept="' . implode( ",", $array ) . '"';
|
313 |
+
} else {
|
314 |
+
$accept = '';
|
315 |
+
}
|
316 |
+
$class = ( 'textbox' == $class ) ? "file" : wpmem_sanitize_class( $class );
|
317 |
+
$str = "<input name=\"$name\" type=\"file\" id=\"$id\" value=\"" . esc_attr( $value ) . "\" class=\"$class\"$accept" . ( ( $required ) ? " required " : "" ) . ( ( 'image' == $type ) ? ' onchange="loadFile(event, this.id)"' : '' ) . ' />';
|
318 |
+
break;
|
319 |
+
|
320 |
+
case "checkbox":
|
321 |
+
$class = ( 'textbox' == $class ) ? "checkbox" : wpmem_sanitize_class( $class );
|
322 |
+
$str = "<input name=\"$name\" type=\"$type\" id=\"$id\" value=\"" . esc_attr( $value ) . "\"" . checked( $value, $compare, false ) . ( ( $required ) ? " required " : "" ) . " />";
|
323 |
+
break;
|
324 |
+
|
325 |
+
case "textarea":
|
326 |
+
$value = esc_textarea( stripslashes( $value ) ); // stripslashes( esc_textarea( $value ) );
|
327 |
+
$class = ( 'textbox' == $class ) ? "textarea" : wpmem_sanitize_class( $class );
|
328 |
+
$placeholder = ( $placeholder ) ? ' placeholder="' . esc_attr( __( $placeholder, 'wp-members' ) ) . '"' : '';
|
329 |
+
$rows = ( isset( $args['rows'] ) && $args['rows'] ) ? esc_attr( $args['rows'] ) : '5';
|
330 |
+
$cols = ( isset( $args['cols'] ) && $args['cols'] ) ? esc_attr( $args['cols'] ) : '20';
|
331 |
+
$str = "<textarea cols=\"$cols\" rows=\"$rows\" name=\"$name\" id=\"$id\" class=\"$class\"$placeholder" . ( ( $required ) ? " required " : "" ) . ">$value</textarea>";
|
332 |
+
break;
|
333 |
+
|
334 |
+
case "hidden":
|
335 |
+
$str = "<input name=\"$name\" type=\"$type\" value=\"" . esc_attr( $value ) . "\" />";
|
336 |
+
break;
|
337 |
+
|
338 |
+
case "option":
|
339 |
+
$str = "<option value=\"" . esc_attr( $value ) . "\" " . selected( $value, $compare, false ) . " >" . __( $name, 'wp-members' ) . "</option>";
|
340 |
+
break;
|
341 |
+
|
342 |
+
case "select":
|
343 |
+
case "multiselect":
|
344 |
+
case "membership":
|
345 |
+
$class = ( 'textbox' == $class && 'multiselect' != $type ) ? "dropdown" : $class;
|
346 |
+
$class = ( 'textbox' == $class && 'multiselect' == $type ) ? "multiselect" : $class;
|
347 |
+
$pname = ( 'multiselect' == $type ) ? $name . "[]" : $name;
|
348 |
+
$str = "<select name=\"$pname\" id=\"$id\" class=\"$class\"" . ( ( 'multiselect' == $type ) ? " multiple " : "" ) . ( ( $required ) ? " required " : "" ) . ">\n";
|
349 |
+
if ( 'membership' == $type ) {
|
350 |
+
$value = array( __( 'Choose membership', 'wp-members' ) . '|' );
|
351 |
+
foreach( $wpmem->membership->products as $membership_key => $membership_value ) {
|
352 |
+
$value[] = $membership_value['title'] . '|' . $membership_key;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
foreach ( $value as $option ) {
|
356 |
+
$pieces = array_map( 'trim', explode( '|', $option ) );
|
357 |
+
if ( 'multiselect' == $type ) {
|
358 |
+
$chk = '';
|
359 |
+
$values = ( empty( $compare ) ) ? array() : ( is_array( $compare ) ? $compare : explode( $delimiter, $compare ) );
|
360 |
+
} else {
|
361 |
+
$chk = $compare;
|
362 |
+
$values = array();
|
363 |
+
}
|
364 |
+
if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
|
365 |
+
$chk = ( ( isset( $pieces[2] ) && '' == $compare ) || in_array( $pieces[1], $values ) ) ? $pieces[1] : $chk;
|
366 |
+
} else {
|
367 |
+
$chk = 'not selected';
|
368 |
+
}
|
369 |
+
$pieces[1] = ( isset( $pieces[1] ) ) ? $pieces[1] : ''; // If someone skipped a pipe, treat it as empty.
|
370 |
+
$str = $str . "<option value=\"$pieces[1]\"" . selected( $pieces[1], $chk, false ) . ">" . esc_attr( __( $pieces[0], 'wp-members' ) ) . "</option>\n";
|
371 |
+
}
|
372 |
+
$str = $str . "</select>";
|
373 |
+
break;
|
374 |
+
|
375 |
+
case "multicheckbox":
|
376 |
+
$class = ( 'textbox' == $class ) ? "checkbox" : $class;
|
377 |
+
$str = '';
|
378 |
+
$num = 1;
|
379 |
+
foreach ( $value as $option ) {
|
380 |
+
$pieces = explode( '|', $option );
|
381 |
+
$values = ( empty( $compare ) ) ? array() : ( is_array( $compare ) ? $compare : explode( $delimiter, $compare ) );
|
382 |
+
$chk = ( isset( $pieces[2] ) && '' == $compare ) ? $pieces[1] : '';
|
383 |
+
if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
|
384 |
+
$id_value = esc_attr( $id . '[' . $pieces[1] . ']' );
|
385 |
+
$label = wpmem_form_label( array( 'meta_key'=>$id_value, 'label'=>esc_html( __( $pieces[0], 'wp-members' ) ), 'type'=>'multicheckbox', 'id'=>$id_value ) );
|
386 |
+
$str = $str . wpmem_form_field( array(
|
387 |
+
'id' => $id_value,
|
388 |
+
'name' => $name . '[]',
|
389 |
+
'type' => 'checkbox',
|
390 |
+
'value' => $pieces[1],
|
391 |
+
'compare' => ( in_array( $pieces[1], $values ) ) ? $pieces[1] : $chk,
|
392 |
+
) ) . " " . $label . "<br />\n";
|
393 |
+
} else {
|
394 |
+
$str = $str . '<span class="div_multicheckbox_separator">' . esc_html( __( $pieces[0], 'wp-members' ) ) . "</span><br />\n";
|
395 |
+
}
|
396 |
+
}
|
397 |
+
break;
|
398 |
+
|
399 |
+
case "radio":
|
400 |
+
$class = ( 'textbox' == $class ) ? "radio" : wpmem_sanitize_class( $class );
|
401 |
+
$str = '';
|
402 |
+
$num = 1;
|
403 |
+
foreach ( $value as $option ) {
|
404 |
+
$pieces = explode( '|', $option );
|
405 |
+
$id_num = $id . '_' . $num;
|
406 |
+
if ( isset( $pieces[1] ) && '' != $pieces[1] ) {
|
407 |
+
$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 ) ) );
|
408 |
+
$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";
|
409 |
+
$num++;
|
410 |
+
} else {
|
411 |
+
$str = $str . '<span class="div_radio_separator">' . esc_html( __( $pieces[0], 'wp-members' ) ) . "</span><br />\n";
|
412 |
+
}
|
413 |
+
}
|
414 |
+
break;
|
415 |
+
|
416 |
+
}
|
417 |
+
|
418 |
+
return $str;
|
419 |
+
} // End create_form_field()
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Create form label.
|
423 |
+
*
|
424 |
+
* @since 3.1.7
|
425 |
+
* @since 3.2.4 Added $id
|
426 |
+
*
|
427 |
+
* @param array $args {
|
428 |
+
* @type string $meta_key
|
429 |
+
* @type string $label
|
430 |
+
* @type string $type
|
431 |
+
* @type string $id (optional)
|
432 |
+
* @type string $class (optional)
|
433 |
+
* @type string $required (optional)
|
434 |
+
* @type string $req_mark (optional)
|
435 |
+
* }
|
436 |
+
* @return string $label
|
437 |
+
*/
|
438 |
+
function create_form_label( $args ) {
|
439 |
+
global $wpmem;
|
440 |
+
|
441 |
+
$meta_key = $args['meta_key'];
|
442 |
+
$label = $args['label'];
|
443 |
+
$type = $args['type'];
|
444 |
+
$class = ( isset( $args['class'] ) ) ? $args['class'] : false;
|
445 |
+
$id = ( isset( $args['id'] ) ) ? $args['id'] : false;
|
446 |
+
$required = ( isset( $args['required'] ) ) ? $args['required'] : false;
|
447 |
+
$req_mark = ( isset( $args['req_mark'] ) ) ? $args['req_mark'] : false;
|
448 |
+
|
449 |
+
//$req_mark = ( ! $req_mark ) ? wpmem_get_text( 'register_req_mark' ) : '*';
|
450 |
+
|
451 |
+
if ( ! $class ) {
|
452 |
+
$class = ( $type == 'password' || $type == 'email' || $type == 'url' ) ? 'text' : $type;
|
453 |
+
}
|
454 |
+
|
455 |
+
$id = ( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
|
456 |
+
|
457 |
+
$label = '<label for="' . esc_attr( $meta_key ) . '"' . $id . ' class="' . wpmem_sanitize_class( $class ) . '">' . __( $label, 'wp-members' );
|
458 |
+
$label = ( $required ) ? $label . $req_mark : $label;
|
459 |
+
$label = $label . '</label>';
|
460 |
+
|
461 |
+
return $label;
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Uploads file from the user.
|
466 |
+
*
|
467 |
+
* @since 3.1.0
|
468 |
+
*
|
469 |
+
* @param array $file
|
470 |
+
* @param int $user_id
|
471 |
+
* @return int|bool
|
472 |
+
*/
|
473 |
+
function do_file_upload( $file = array(), $user_id = false ) {
|
474 |
+
|
475 |
+
// Filter the upload directory.
|
476 |
+
add_filter( 'upload_dir', array( &$this, 'file_upload_dir' ) );
|
477 |
+
|
478 |
+
// Set up user ID for use in upload process.
|
479 |
+
$this->file_user_id = ( $user_id ) ? $user_id : 0;
|
480 |
+
|
481 |
+
// Get WordPress file upload processing scripts.
|
482 |
+
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
483 |
+
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
484 |
+
|
485 |
+
$file_return = wp_handle_upload( $file, array( 'test_form' => false ) );
|
486 |
+
|
487 |
+
if ( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
|
488 |
+
return false;
|
489 |
+
} else {
|
490 |
+
|
491 |
+
$attachment = array(
|
492 |
+
'post_mime_type' => $file_return['type'],
|
493 |
+
'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $file_return['file'] ) ),
|
494 |
+
'post_content' => '',
|
495 |
+
'post_status' => 'inherit',
|
496 |
+
'guid' => $file_return['url'],
|
497 |
+
'post_author' => ( $user_id ) ? $user_id : '',
|
498 |
+
);
|
499 |
+
|
500 |
+
$attachment_id = wp_insert_attachment( $attachment, $file_return['url'] );
|
501 |
+
|
502 |
+
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
503 |
+
$attachment_data = wp_generate_attachment_metadata( $attachment_id, $file_return['file'] );
|
504 |
+
wp_update_attachment_metadata( $attachment_id, $attachment_data );
|
505 |
+
|
506 |
+
if ( 0 < intval( $attachment_id ) ) {
|
507 |
+
// Returns an array with file information.
|
508 |
+
return $attachment_id;
|
509 |
+
}
|
510 |
+
}
|
511 |
+
|
512 |
+
return false;
|
513 |
+
} // End upload_file()
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Sets the file upload directory.
|
517 |
+
*
|
518 |
+
* This is a filter function for upload_dir.
|
519 |
+
*
|
520 |
+
* @link https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_dir
|
521 |
+
*
|
522 |
+
* @since 3.1.0
|
523 |
+
*
|
524 |
+
* @param array $param {
|
525 |
+
* The directory information for upload.
|
526 |
+
*
|
527 |
+
* @type string $path
|
528 |
+
* @type string $url
|
529 |
+
* @type string $subdir
|
530 |
+
* @type string $basedir
|
531 |
+
* @type string $baseurl
|
532 |
+
* @type string $error
|
533 |
+
* }
|
534 |
+
* @return array $param
|
535 |
+
*/
|
536 |
+
function file_upload_dir( $param ) {
|
537 |
+
|
538 |
+
global $wpmem;
|
539 |
+
|
540 |
+
$user_id = ( isset( $this->file_user_id ) ) ? $this->file_user_id : null;
|
541 |
+
|
542 |
+
$args = array(
|
543 |
+
'user_id' => $user_id,
|
544 |
+
'wpmem_dir' => $wpmem->upload_base,
|
545 |
+
'user_dir' => 'user_files/' . $user_id,
|
546 |
+
);
|
547 |
+
|
548 |
+
/**
|
549 |
+
* Filter the user directory elements.
|
550 |
+
*
|
551 |
+
* @since 3.1.0
|
552 |
+
*
|
553 |
+
* @param array $args
|
554 |
+
*/
|
555 |
+
$args = apply_filters( 'wpmem_user_upload_dir', $args );
|
556 |
+
|
557 |
+
$param['subdir'] = '/' . $args['wpmem_dir'] . '/' . $args['user_dir'];
|
558 |
+
$param['path'] = $param['basedir'] . '/' . $args['wpmem_dir'] . '/' . $args['user_dir'];
|
559 |
+
$param['url'] = $param['baseurl'] . '/' . $args['wpmem_dir'] . '/' . $args['user_dir'];
|
560 |
+
|
561 |
+
return $param;
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Login Form Builder.
|
566 |
+
*
|
567 |
+
* Builds the form used for login, change password, and reset password.
|
568 |
+
*
|
569 |
+
* @since 2.5.1
|
570 |
+
* @since 3.1.7 Moved to forms object class as login_form().
|
571 |
+
* @since 3.1.7 Added WP action login_form.
|
572 |
+
* @since 3.2.6 Added nonce to the short form.
|
573 |
+
*
|
574 |
+
* @param string $page
|
575 |
+
* @param array $arr {
|
576 |
+
* The elements needed to generate the form (login|reset password|forgotten password).
|
577 |
+
*
|
578 |
+
* @type string $heading Form heading text.
|
579 |
+
* @type string $action The form action (login|pwdchange|pwdreset|getusername).
|
580 |
+
* @type string $button_text Form submit button text.
|
581 |
+
* @type array $inputs {
|
582 |
+
* The form input values.
|
583 |
+
*
|
584 |
+
* @type array {
|
585 |
+
*
|
586 |
+
* @type string $name The field label.
|
587 |
+
* @type string $type Input type.
|
588 |
+
* @type string $tag Input tag name.
|
589 |
+
* @type string $class Input tag class.
|
590 |
+
* @type string $div Div wrapper class.
|
591 |
+
* }
|
592 |
+
* }
|
593 |
+
* @type string $redirect_to Optional. URL to redirect to.
|
594 |
+
* }
|
595 |
+
* @return string $form The HTML for the form as a string.
|
596 |
+
*/
|
597 |
+
function login_form( $mixed, $arr = array() ) {
|
598 |
+
|
599 |
+
global $wpmem;
|
600 |
+
|
601 |
+
// Handle legacy use.
|
602 |
+
if ( is_array( $mixed ) ) {
|
603 |
+
$page = ( isset( $mixed['page'] ) ) ? $mixed['page'] : 'login';
|
604 |
+
$arr = $mixed;
|
605 |
+
} else {
|
606 |
+
$page = $mixed;
|
607 |
+
}
|
608 |
+
|
609 |
+
$action = ( ! isset( $arr['action'] ) ) ? 'login' : $arr['action'];
|
610 |
+
|
611 |
+
// Set up redirect_to @todo This could be done in a separate method usable by both login & reg.
|
612 |
+
$redirect_to = wpmem_get_redirect_to( $arr );
|
613 |
+
|
614 |
+
// Set up default wrappers.
|
615 |
+
// NOTE: DO NOT EDIT! There is a filter hook for this -> wpmem_login_form_args.
|
616 |
+
$defaults = array(
|
617 |
+
|
618 |
+
// wrappers
|
619 |
+
'heading_before' => '<legend>',
|
620 |
+
'heading_after' => '</legend>',
|
621 |
+
'fieldset_before' => '<fieldset>',
|
622 |
+
'fieldset_after' => '</fieldset>',
|
623 |
+
'main_div_before' => '<div id="wpmem_login">',
|
624 |
+
'main_div_after' => '</div>',
|
625 |
+
'row_before' => '',
|
626 |
+
'row_after' => '',
|
627 |
+
'buttons_before' => '<div class="button_div">',
|
628 |
+
'buttons_after' => '</div>',
|
629 |
+
'link_before' => '<div class="link-text">',
|
630 |
+
'link_after' => '</div>',
|
631 |
+
'link_span_before' => '<span class="link-text-%s">',
|
632 |
+
'link_span_after' => '</span>',
|
633 |
+
|
634 |
+
// classes & ids
|
635 |
+
'form_id' => 'wpmem_' . $action . '_form',
|
636 |
+
'form_class' => 'form',
|
637 |
+
'button_id' => '',
|
638 |
+
'button_class' => 'buttons',
|
639 |
+
|
640 |
+
// other
|
641 |
+
'strip_breaks' => true,
|
642 |
+
'wrap_inputs' => true,
|
643 |
+
'remember_check' => true,
|
644 |
+
'n' => "\n",
|
645 |
+
't' => "\t",
|
646 |
+
'redirect_to' => $redirect_to,
|
647 |
+
'login_form_action' => true,
|
648 |
+
|
649 |
+
);
|
650 |
+
|
651 |
+
/**
|
652 |
+
* Filter the default form arguments.
|
653 |
+
*
|
654 |
+
* This filter accepts an array of various elements to replace the form defaults. This
|
655 |
+
* includes default tags, labels, text, and small items including various booleans.
|
656 |
+
*
|
657 |
+
* @since 2.9.0
|
658 |
+
* @since 3.3.0 Passes $defaults as an argument.
|
659 |
+
*
|
660 |
+
* @param array $args {
|
661 |
+
* An array of arguments to merge with defaults.
|
662 |
+
*
|
663 |
+
* @type string $heading_before Default: '<legend>'
|
664 |
+
* @type string $heading_after Default: '</legend>'
|
665 |
+
* @type string $fieldset_before Default: '<fieldset>'
|
666 |
+
* @type string $fieldset_after Default: '</fieldset>'
|
667 |
+
* @type string $main_div_before Default: '<div id="wpmem_login">'
|
668 |
+
* @type string $main_div_after Default: '</div>'
|
669 |
+
* @type string $row_before Default: ''
|
670 |
+
* @type string $row_after Default: ''
|
671 |
+
* @type string $buttons_before Default: '<div class="button_div">'
|
672 |
+
* @type string $buttons_after Default: '</div>'
|
673 |
+
* @type string $link_before Default: '<div class="link-text">'
|
674 |
+
* @type string $link_after Default: '</div>'
|
675 |
+
* @type string $link_span_before Default: '<span class="link-text-%s">'
|
676 |
+
* @type string $link_span_after Default: '</span>'
|
677 |
+
* @type string $form_id Default: 'wpmem_' . $action . '_form' (for example, wpmem_login_form or wpmem_pwdreset_form)
|
678 |
+
* @type string $form_class Default: 'form'
|
679 |
+
* @type string $button_id Default: ''
|
680 |
+
* @type string $button_class Default: buttons'
|
681 |
+
* @type boolean $strip_breaks Default: true (if true, strips all line breaks from the generated HTML)
|
682 |
+
* @type boolean $wrap_inputs Default: true (if true, includes main_div_before/after wrappers around input tags)
|
683 |
+
* @type boolean $remember_check Default: true
|
684 |
+
* @type string $n Default: "\n" (the new line character if breaks are not stripped (see $strip_breaks))
|
685 |
+
* @type string $t Default: "\t" (the line indent character if breaks are not stripped (see $strip_breaks))
|
686 |
+
* @type string $redirect_to Default: (the $redirec_to argument passed to the function)
|
687 |
+
* @type boolean $login_form_action Default: true (if true, adds the WP login_form action)
|
688 |
+
* }
|
689 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
690 |
+
*/
|
691 |
+
$args = apply_filters( 'wpmem_login_form_args', $defaults, $action );
|
692 |
+
|
693 |
+
// Merge $args with defaults.
|
694 |
+
$args = wp_parse_args( $args, $defaults );
|
695 |
+
|
696 |
+
// Build the input rows.
|
697 |
+
foreach ( $arr['inputs'] as $input ) {
|
698 |
+
$label = '<label for="' . esc_attr( $input['tag'] ) . '">' . $input['name'] . '</label>';
|
699 |
+
$field = wpmem_form_field( array(
|
700 |
+
'name' => $input['tag'],
|
701 |
+
'type' => $input['type'],
|
702 |
+
'class' => $input['class'],
|
703 |
+
'required' => true,
|
704 |
+
) );
|
705 |
+
$field_before = ( $args['wrap_inputs'] ) ? '<div class="' . wpmem_sanitize_class( $input['div'] ) . '">' : '';
|
706 |
+
$field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
|
707 |
+
$rows[] = array(
|
708 |
+
'row_before' => $args['row_before'],
|
709 |
+
'label' => $label,
|
710 |
+
'field_before' => $field_before,
|
711 |
+
'field' => $field,
|
712 |
+
'field_after' => $field_after,
|
713 |
+
'row_after' => $args['row_after'],
|
714 |
+
);
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* Filter the array of form rows.
|
719 |
+
*
|
720 |
+
* This filter receives an array of the main rows in the form, each array element being
|
721 |
+
* an array of that particular row's pieces. This allows making changes to individual
|
722 |
+
* parts of a row without needing to parse through a string of HTML.
|
723 |
+
*
|
724 |
+
* @since 2.9.0
|
725 |
+
* @since 3.2.6 Added $arr parameter so all settings are passed.
|
726 |
+
*
|
727 |
+
* @param array $rows An array containing the form rows.
|
728 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
729 |
+
* @param array $arr An array containing all of the form settings.
|
730 |
+
*/
|
731 |
+
$rows = apply_filters( 'wpmem_login_form_rows', $rows, $action, $arr );
|
732 |
+
|
733 |
+
// Put the rows from the array into $form.
|
734 |
+
$form = '';
|
735 |
+
foreach ( $rows as $row_item ) {
|
736 |
+
$row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
|
737 |
+
$row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
|
738 |
+
$row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
|
739 |
+
$form.= $row;
|
740 |
+
}
|
741 |
+
|
742 |
+
// Handle outside elements added to the login form (currently ONLY for login).
|
743 |
+
if ( 'login' == $action && $args['login_form_action'] ) {
|
744 |
+
ob_start();
|
745 |
+
/** This action is documented in wp-login.php */
|
746 |
+
do_action( 'login_form' );
|
747 |
+
$add_to_form = ob_get_contents();
|
748 |
+
ob_end_clean();
|
749 |
+
$form.= $add_to_form;
|
750 |
+
}
|
751 |
+
|
752 |
+
// Build hidden fields, filter, and add to the form.
|
753 |
+
$hidden[] = wpmem_form_field( array( 'name' => 'redirect_to', 'type' => 'hidden', 'value' => esc_url( $args['redirect_to'] ) ) ) . $args['n'];
|
754 |
+
$hidden[] = wpmem_form_field( array( 'name' => 'a', 'type' => 'hidden', 'value' => $action ) ) . $args['n'];
|
755 |
+
if ( $action != 'login' ) {
|
756 |
+
$hidden[] = wpmem_form_field( array( 'name' => 'formsubmit', 'type' => 'hidden', 'value' => '1' ) );
|
757 |
+
}
|
758 |
+
|
759 |
+
/**
|
760 |
+
* Filter hidden fields array.
|
761 |
+
*
|
762 |
+
* @since 3.4.0
|
763 |
+
*
|
764 |
+
* @param array $hidden
|
765 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
766 |
+
*/
|
767 |
+
$hidden = apply_filters( 'wpmem_login_hidden_field_rows', $hidden, $action );
|
768 |
+
|
769 |
+
$hidden_field_string = '';
|
770 |
+
foreach ( $hidden as $field ) {
|
771 |
+
$hidden_field_string .= $field;
|
772 |
+
}
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Filter the hidden field HTML.
|
776 |
+
*
|
777 |
+
* @since 2.9.0
|
778 |
+
*
|
779 |
+
* @param string $hidden The generated HTML of hidden fields.
|
780 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
781 |
+
*/
|
782 |
+
$form = $form . apply_filters( 'wpmem_login_hidden_fields', $hidden_field_string, $action );
|
783 |
+
|
784 |
+
// Build the buttons, filter, and add to the form.
|
785 |
+
if ( $action == 'login' ) {
|
786 |
+
$args['remember_check'] = ( $args['remember_check'] ) ? $args['t'] . wpmem_form_field( array( 'name' => 'rememberme', 'type' => 'checkbox', 'value' => 'forever' ) ) . ' ' . '<label for="rememberme">' . wpmem_get_text( 'remember_me' ) . '</label> ' . $args['n'] : '';
|
787 |
+
$buttons = $args['remember_check'] . $args['t'] . '<input type="submit" name="Submit" value="' . esc_attr( $arr['button_text'] ) . '" class="' . wpmem_sanitize_class( $args['button_class'] ) . '" />' . $args['n'];
|
788 |
+
} else {
|
789 |
+
$buttons = '<input type="submit" name="Submit" value="' . esc_attr( $arr['button_text'] ) . '" class="' . wpmem_sanitize_class( $args['button_class'] ) . '" />' . $args['n'];
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Filter the HTML for form buttons.
|
794 |
+
*
|
795 |
+
* The string includes the buttons, as well as the before/after wrapper elements.
|
796 |
+
*
|
797 |
+
* @since 2.9.0
|
798 |
+
*
|
799 |
+
* @param string $buttons The generated HTML of the form buttons.
|
800 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
801 |
+
*/
|
802 |
+
$form = $form . apply_filters( 'wpmem_login_form_buttons', $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'], $action );
|
803 |
+
|
804 |
+
$links_array = array(
|
805 |
+
'forgot' => array(
|
806 |
+
'tag' => 'forgot',
|
807 |
+
'link' => add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ),
|
808 |
+
'page' => 'profile',
|
809 |
+
'action' => 'login',
|
810 |
+
),
|
811 |
+
'register' => array(
|
812 |
+
'tag' => 'reg',
|
813 |
+
'link' => $wpmem->user_pages['register'],
|
814 |
+
'page' => 'register',
|
815 |
+
'action' => 'login',
|
816 |
+
),
|
817 |
+
'username' => array(
|
818 |
+
'tag' => 'username',
|
819 |
+
'link' => add_query_arg( 'a', 'getusername', $wpmem->user_pages['profile'] ),
|
820 |
+
'page' => 'profile',
|
821 |
+
'action' => 'pwdreset',
|
822 |
+
),
|
823 |
+
);
|
824 |
+
foreach ( $links_array as $key => $value ) {
|
825 |
+
$tag = $value['tag'];
|
826 |
+
if ( ( $wpmem->user_pages[ $value['page'] ] || 'profile' == $page ) && $value['action'] == $action ) {
|
827 |
+
/**
|
828 |
+
* Filters register, forgot password, and forgot username links.
|
829 |
+
*
|
830 |
+
* @since 2.8.0
|
831 |
+
* @since 3.1.7 Combined all to a single process.
|
832 |
+
* @since 3.2.5 Added $tag parameter.
|
833 |
+
*
|
834 |
+
* @param string The raw link.
|
835 |
+
* @param string $tag forgot|reg|pwdreset|username.
|
836 |
+
*/
|
837 |
+
$link = apply_filters( "wpmem_{$tag}_link", $value['link'], $tag );
|
838 |
+
$str = wpmem_get_text( "{$key}_link_before" ) . '<a href="' . esc_url( $link ) . '">' . wpmem_get_text( "{$key}_link" ) . '</a>';
|
839 |
+
$link_str = $args['link_before'];
|
840 |
+
$link_str.= ( '' != $args['link_span_before'] ) ? sprintf( $args['link_span_before'], $key ) : '';
|
841 |
+
/**
|
842 |
+
* Filters the register, forgot password, and forgot username links HTML.
|
843 |
+
*
|
844 |
+
* @since 2.9.0
|
845 |
+
* @since 3.0.9 Added $link parameter.
|
846 |
+
* @since 3.1.7 Combined all to a single process.
|
847 |
+
* @since 3.2.5 Added $tag parameter.
|
848 |
+
*
|
849 |
+
* @param string $str The link HTML.
|
850 |
+
* @param string $link The link.
|
851 |
+
* @param string $tag forgot|reg|pwdreset.
|
852 |
+
*/
|
853 |
+
$link_str.= apply_filters( "wpmem_{$tag}_link_str", $str, $link, $tag );
|
854 |
+
$link_str.= ( '' != $args['link_span_after'] ) ? $args['link_span_after'] : '';
|
855 |
+
$link_str.= $args['link_after'] . $args['n'];
|
856 |
+
/*
|
857 |
+
* If this is the register link, and the current post type is set to
|
858 |
+
* display the register form, and the current page is not the login
|
859 |
+
* page, then do not add the register link, otherwise add the link.
|
860 |
+
*/
|
861 |
+
if ( 'register' == $key ) {
|
862 |
+
if ( ! isset( $wpmem->user_pages['register'] ) || '' == $wpmem->user_pages['register'] ) {
|
863 |
+
$form = $form;
|
864 |
+
} else {
|
865 |
+
if ( isset( $wpmem->user_pages['login'] ) && '' != $wpmem->user_pages['login'] ) {
|
866 |
+
$form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && wpmem_current_url( true, false ) != wpmem_login_url() ) ? $form : $form . $link_str;
|
867 |
+
} else {
|
868 |
+
global $post;
|
869 |
+
if ( has_shortcode( $post->post_content, 'wpmem_profile' ) ) {
|
870 |
+
$form = $form;
|
871 |
+
} else {
|
872 |
+
$form = ( 1 == $wpmem->show_reg[ get_post_type( get_the_ID() ) ] && ! has_shortcode( $post->post_content, 'wpmem_form' ) ) ? $form : $form . $link_str;
|
873 |
+
}
|
874 |
+
}
|
875 |
+
}
|
876 |
+
} else {
|
877 |
+
$form = $form . $link_str;
|
878 |
+
}
|
879 |
+
}
|
880 |
+
}
|
881 |
+
|
882 |
+
// Apply the heading.
|
883 |
+
$form = $args['heading_before'] . $arr['heading'] . $args['heading_after'] . $args['n'] . $form;
|
884 |
+
|
885 |
+
// Apply fieldset wrapper.
|
886 |
+
$form = $args['fieldset_before'] . $args['n'] . $form . $args['fieldset_after'] . $args['n'];
|
887 |
+
|
888 |
+
// Apply nonce.
|
889 |
+
$form = wp_nonce_field( 'wpmem_shortform_nonce', '_wpmem_' . $action . '_nonce', true, false ) . $args['n'] . $form;
|
890 |
+
|
891 |
+
// Apply form wrapper.
|
892 |
+
$form = '<form action="' . esc_url( get_permalink() ) . '" method="POST" id="' . wpmem_sanitize_class( $args['form_id'] ) . '" class="' . wpmem_sanitize_class( $args['form_class'] ) . '">' . $args['n'] . $form . '</form>';
|
893 |
+
|
894 |
+
// Apply anchor.
|
895 |
+
$form = '<a id="' . esc_attr( $action ) . '"></a>' . $args['n'] . $form;
|
896 |
+
|
897 |
+
// Apply main wrapper.
|
898 |
+
$form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'];
|
899 |
+
|
900 |
+
// Remove line breaks.
|
901 |
+
$form = ( $args['strip_breaks'] ) ? str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
|
902 |
+
|
903 |
+
/**
|
904 |
+
* Filter the generated HTML of the entire form.
|
905 |
+
*
|
906 |
+
* @since 2.7.4
|
907 |
+
*
|
908 |
+
* @param string $form The HTML of the final generated form.
|
909 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
910 |
+
*/
|
911 |
+
$form = apply_filters( 'wpmem_login_form', $form, $action );
|
912 |
+
|
913 |
+
/**
|
914 |
+
* Filter before the form.
|
915 |
+
*
|
916 |
+
* This rarely used filter allows you to stick any string onto the front of
|
917 |
+
* the generated form.
|
918 |
+
*
|
919 |
+
* @since 2.7.4
|
920 |
+
*
|
921 |
+
* @param string $str The HTML to add before the form. Default null.
|
922 |
+
* @param string $action The action being performed by the form. login|pwdreset|pwdchange|getusername.
|
923 |
+
*/
|
924 |
+
$form = apply_filters( 'wpmem_login_form_before', '', $action ) . $form;
|
925 |
+
|
926 |
+
return $form;
|
927 |
+
} // End login_form.
|
928 |
+
|
929 |
+
/**
|
930 |
+
* Registration Form Builder.
|
931 |
+
*
|
932 |
+
* Outputs the form for new user registration and existing user edits.
|
933 |
+
*
|
934 |
+
* @since 2.5.1
|
935 |
+
* @since 3.1.7 Moved to forms object class as register_form().
|
936 |
+
* @since 3.2.5 use_nonce now obsolete (nonce is added automatically).
|
937 |
+
* @since 3.3.0 $heading argument obsolete.
|
938 |
+
* @since 3.3.3 Image field type now shows the preview image when "choose file" is clicked.
|
939 |
+
*
|
940 |
+
* @global object $wpmem The WP_Members object.
|
941 |
+
* @global array $userdata Used to get the user's registration data if they are logged in (user profile edit).
|
942 |
+
* @param mixed $mixed (optional) String toggles between new registration ('new') and user profile edit ('edit'), or array containing settings arguments.
|
943 |
+
* @return string $form The HTML for the entire form as a string.
|
944 |
+
*/
|
945 |
+
function register_form( $mixed = 'new', $redirect_to = null ) {
|
946 |
+
|
947 |
+
/*
|
948 |
+
* Removes the action to load form elements for the WP registration
|
949 |
+
* form. Otherwise, when the register_form action is fired in this
|
950 |
+
* form, we'd get a duplication of all custom fields.
|
951 |
+
*/
|
952 |
+
remove_action( 'register_form', 'wpmem_wp_register_form' );
|
953 |
+
|
954 |
+
// Handle legacy use.
|
955 |
+
if ( is_array( $mixed ) ) {
|
956 |
+
$id = ( isset( $mixed['id'] ) ) ? $mixed['id'] : '';
|
957 |
+
$tag = ( isset( $mixed['tag'] ) ) ? $mixed['tag'] : 'new';
|
958 |
+
$heading = ( isset( $mixed['heading'] ) ) ? $mixed['heading'] : '';
|
959 |
+
$redirect_to = ( isset( $mixed['redirect_to'] ) ) ? $mixed['redirect_to'] : '';
|
960 |
+
$fields = ( isset( $mixed['fields'] ) ) ? $mixed['fields'] : false;
|
961 |
+
} else {
|
962 |
+
$id = 'default';
|
963 |
+
$tag = $mixed;
|
964 |
+
}
|
965 |
+
|
966 |
+
global $wpmem, $userdata;
|
967 |
+
|
968 |
+
// Set up default wrappers.
|
969 |
+
$defaults = array(
|
970 |
+
|
971 |
+
// Wrappers.
|
972 |
+
'heading_before' => '<legend>',
|
973 |
+
'heading_after' => '</legend>',
|
974 |
+
'fieldset_before' => '<fieldset>',
|
975 |
+
'fieldset_after' => '</fieldset>',
|
976 |
+
'main_div_before' => '<div id="wpmem_reg">',
|
977 |
+
'main_div_after' => '</div>',
|
978 |
+
'row_before' => '',
|
979 |
+
'row_after' => '',
|
980 |
+
'buttons_before' => '<div class="button_div">',
|
981 |
+
'buttons_after' => '</div>',
|
982 |
+
|
983 |
+
// Classes & ids.
|
984 |
+
'form_id' => ( 'new' == $tag ) ? 'wpmem_register_form' : 'wpmem_profile_form',
|
985 |
+
'form_class' => 'form',
|
986 |
+
'button_id' => '',
|
987 |
+
'button_class' => 'buttons',
|
988 |
+
|
989 |
+
// Required field tags and text.
|
990 |
+
'req_mark' => wpmem_get_text( 'register_req_mark' ),
|
991 |
+
'req_label' => wpmem_get_text( 'register_required' ),
|
992 |
+
'req_label_before' => '<div class="req-text">',
|
993 |
+
'req_label_after' => '</div>',
|
994 |
+
|
995 |
+
// Buttons.
|
996 |
+
'show_clear_form' => false,
|
997 |
+
'clear_form' => wpmem_get_text( 'register_clear' ),
|
998 |
+
'submit_register' => wpmem_get_text( 'register_submit' ),
|
999 |
+
'submit_update' => wpmem_get_text( 'profile_submit' ),
|
1000 |
+
|
1001 |
+
// Other.
|
1002 |
+
'post_to' => get_permalink(),
|
1003 |
+
'strip_breaks' => true,
|
1004 |
+
'wrap_inputs' => true,
|
1005 |
+
'n' => "\n",
|
1006 |
+
't' => "\t",
|
1007 |
+
|
1008 |
+
'register_form_action' => true,
|
1009 |
+
|
1010 |
+
);
|
1011 |
+
|
1012 |
+
/**
|
1013 |
+
* Filter the default form arguments.
|
1014 |
+
*
|
1015 |
+
* This filter accepts an array of various elements to replace the form defaults. This
|
1016 |
+
* includes default tags, labels, text, and small items including various booleans.
|
1017 |
+
*
|
1018 |
+
* @since 2.9.0
|
1019 |
+
* @since 3.2.5 Added $id
|
1020 |
+
* @since 3.3.0 Passes $defaults as an argument.
|
1021 |
+
*
|
1022 |
+
* @param array An array of arguments to merge with defaults. Default null.
|
1023 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1024 |
+
* @param string $id An id for the form (optional).
|
1025 |
+
*/
|
1026 |
+
$args = apply_filters( 'wpmem_register_form_args', $defaults, $tag, $id );
|
1027 |
+
|
1028 |
+
// Merge $args with defaults.
|
1029 |
+
$args = wp_parse_args( $args, $defaults );
|
1030 |
+
|
1031 |
+
// Get fields.
|
1032 |
+
$wpmem_fields = wpmem_fields( $tag );
|
1033 |
+
|
1034 |
+
// Fields to skip for user profile update.
|
1035 |
+
|
1036 |
+
if ( 'edit' == $tag ) {
|
1037 |
+
$pass_arr = array( 'username', 'password', 'confirm_password', 'password_confirm' );
|
1038 |
+
// Skips tos on user edit page, unless they haven't got a value for tos.
|
1039 |
+
if ( isset( $wpmem_fields['tos'] ) && ( $wpmem_fields['tos']['checked_value'] == get_user_meta( $userdata->ID, 'tos', true ) ) ) {
|
1040 |
+
$pass_arr[] = 'tos';
|
1041 |
+
}
|
1042 |
+
foreach ( $pass_arr as $pass ) {
|
1043 |
+
unset( $wpmem_fields[ $pass ] );
|
1044 |
+
}
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
/**
|
1048 |
+
* Filter the array of form fields.
|
1049 |
+
*
|
1050 |
+
* The form fields are stored in the WP options table as wpmembers_fields. This
|
1051 |
+
* filter can filter that array after the option is retreived before the fields
|
1052 |
+
* are parsed. This allows you to change the fields that may be used in the form
|
1053 |
+
* on the fly.
|
1054 |
+
*
|
1055 |
+
* @since 2.9.0
|
1056 |
+
* @deprecated 3.1.7 Use wpmem_fields instead.
|
1057 |
+
*
|
1058 |
+
* @param array The array of form fields.
|
1059 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1060 |
+
*/
|
1061 |
+
$wpmem_fields = apply_filters( 'wpmem_register_fields_arr', $wpmem_fields, $tag );
|
1062 |
+
|
1063 |
+
$hidden_rows = array();
|
1064 |
+
$form_has_file = false;
|
1065 |
+
|
1066 |
+
// Loop through the remaining fields.
|
1067 |
+
foreach ( $wpmem_fields as $meta_key => $field ) {
|
1068 |
+
|
1069 |
+
// Start with a clean row.
|
1070 |
+
$val = ''; $label = ''; $input = ''; $field_before = ''; $field_after = '';
|
1071 |
+
|
1072 |
+
// If the field is set to display and we aren't skipping, construct the row.
|
1073 |
+
// if ( ( 'new' == $tag && $field['register'] ) || ( 'edit' == $tag && $field['profile'] ) ) { // @todo Wait for profile fix
|
1074 |
+
if ( $field['register'] ) {
|
1075 |
+
|
1076 |
+
// Handle hidden fields
|
1077 |
+
if ( 'hidden' == $field['type'] ) {
|
1078 |
+
$do_row = false;
|
1079 |
+
$hidden_rows[ $meta_key ] = wpmem_form_field( array(
|
1080 |
+
'name' => $meta_key,
|
1081 |
+
'type' => $field['type'],
|
1082 |
+
'value' => $field['value'],
|
1083 |
+
'compare' => $valtochk,
|
1084 |
+
'required' => $field['required'],
|
1085 |
+
) );
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
// Label for all but TOS and hidden fields.
|
1089 |
+
if ( 'tos' != $meta_key && 'hidden' != $field['type'] ) {
|
1090 |
+
|
1091 |
+
$class = ( $field['type'] == 'password' || $field['type'] == 'email' || $field['type'] == 'url' ) ? 'text' : $field['type'];
|
1092 |
+
|
1093 |
+
$label = wpmem_form_label( array(
|
1094 |
+
'meta_key' => $meta_key, //( 'username' == $meta_key ) ? 'user_login' : $meta_key,
|
1095 |
+
'label' => __( $field['label'], 'wp-members' ),
|
1096 |
+
'type' => $field['type'],
|
1097 |
+
'class' => $class,
|
1098 |
+
'required' => $field['required'],
|
1099 |
+
'req_mark' => $args['req_mark']
|
1100 |
+
) );
|
1101 |
+
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
// Gets the field value for edit profile.
|
1105 |
+
if ( ( 'edit' == $tag ) && ( '' == $wpmem->regchk ) ) {
|
1106 |
+
switch ( $meta_key ) {
|
1107 |
+
case( 'description' ):
|
1108 |
+
case( 'textarea' == $field['type'] ):
|
1109 |
+
$val = get_user_meta( $userdata->ID, $meta_key, 'true' ); // esc_textarea() is run when field is created.
|
1110 |
+
break;
|
1111 |
+
|
1112 |
+
case 'user_email':
|
1113 |
+
case 'confirm_email':
|
1114 |
+
$val = sanitize_email( $userdata->user_email );
|
1115 |
+
break;
|
1116 |
+
|
1117 |
+
case 'user_url':
|
1118 |
+
$val = $userdata->user_url; // esc_url() is run when the field is created.
|
1119 |
+
break;
|
1120 |
+
|
1121 |
+
case 'display_name':
|
1122 |
+
$val = sanitize_text_field( $userdata->display_name );
|
1123 |
+
break;
|
1124 |
+
|
1125 |
+
default:
|
1126 |
+
$val = sanitize_text_field( get_user_meta( $userdata->ID, $meta_key, 'true' ) );
|
1127 |
+
break;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
} else {
|
1131 |
+
if ( 'file' == $field['type'] ) {
|
1132 |
+
$val = ( isset( $_FILES[ $meta_key ]['name'] ) ) ? sanitize_file_name( $_FILES[ $meta_key ]['name'] ) : '' ;
|
1133 |
+
} else {
|
1134 |
+
$val = ( isset( $_POST[ $meta_key ] ) ) ? wpmem_sanitize_field( $_POST[ $meta_key ], $field['type'] ) : '';
|
1135 |
+
}
|
1136 |
+
}
|
1137 |
+
|
1138 |
+
// Does the tos field.
|
1139 |
+
if ( 'tos' == $meta_key ) {
|
1140 |
+
|
1141 |
+
// $val = sanitize_text_field( wpmem_get( $meta_key, '' ) );
|
1142 |
+
|
1143 |
+
// Should be checked by default? and only if form hasn't been submitted.
|
1144 |
+
$val = ( ! $_POST && $field['checked_default'] ) ? $field['checked_value'] : $val;
|
1145 |
+
$input = wpmem_form_field( array(
|
1146 |
+
'name' => $meta_key,
|
1147 |
+
'type' => $field['type'],
|
1148 |
+
'value' => $field['checked_value'],
|
1149 |
+
'compare' => $val,
|
1150 |
+
'required' => $field['required'],
|
1151 |
+
) );
|
1152 |
+
|
1153 |
+
$input .= ' ' . $this->get_tos_link( $field, $tag );
|
1154 |
+
|
1155 |
+
$input = ( $field['required'] ) ? $input . $args['req_mark'] : $input;
|
1156 |
+
|
1157 |
+
// In previous versions, the div class would end up being the same as the row before.
|
1158 |
+
$field_before = ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '';
|
1159 |
+
$field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
|
1160 |
+
|
1161 |
+
} elseif ( 'hidden' != $field['type'] ) {
|
1162 |
+
|
1163 |
+
// For checkboxes.
|
1164 |
+
if ( 'checkbox' == $field['type'] ) {
|
1165 |
+
$valtochk = $val;
|
1166 |
+
$val = $field['checked_value'];
|
1167 |
+
// if it should it be checked by default (& only if form not submitted), then override above...
|
1168 |
+
if ( $field['checked_default'] && ( ! $_POST && $tag != 'edit' ) ) {
|
1169 |
+
$val = $valtochk = $field['checked_value'];
|
1170 |
+
}
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
// For dropdown select.
|
1174 |
+
if ( 'select' == $field['type'] || 'radio' == $field['type'] || 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] || 'membership' == $field['type'] ) {
|
1175 |
+
$valtochk = $val;
|
1176 |
+
$val = $field['values'];
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
if ( ! isset( $valtochk ) ) {
|
1180 |
+
$valtochk = '';
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) ) {
|
1184 |
+
|
1185 |
+
$form_has_file = true;
|
1186 |
+
|
1187 |
+
// Handle files differently for multisite vs. single install.
|
1188 |
+
// @see: https://core.trac.wordpress.org/ticket/32145
|
1189 |
+
if ( is_multisite() ) {
|
1190 |
+
$attachment = get_post( $val );
|
1191 |
+
$attachment_url = $attachment->guid;
|
1192 |
+
} else {
|
1193 |
+
$attachment_url = wp_get_attachment_url( $val );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
$empty_file = '<span class="description">' . __( 'None' ) . '</span>';
|
1197 |
+
if ( 'edit' == $tag ) {
|
1198 |
+
if ( 'file' == $field['type'] ) {
|
1199 |
+
$input = ( $attachment_url ) ? '<a href="' . esc_url( $attachment_url ) . '" id="' . $meta_key . '_file">' . get_the_title( $val ) . '</a>' : $empty_file;
|
1200 |
+
} else {
|
1201 |
+
$input = ( $attachment_url ) ? '<img src="' . esc_url( $attachment_url ) . '" id="' . $meta_key . '_img" />' : $empty_file;
|
1202 |
+
}
|
1203 |
+
$input.= '<br />' . wpmem_get_text( 'profile_upload' ) . '<br />';
|
1204 |
+
} else {
|
1205 |
+
if ( 'image' == $field['type'] ) {
|
1206 |
+
$input = '<img src="" id="' . $meta_key . '_img" />';
|
1207 |
+
}
|
1208 |
+
}
|
1209 |
+
$input.= wpmem_form_field( array(
|
1210 |
+
'name' => $meta_key,
|
1211 |
+
'type' => $field['type'],
|
1212 |
+
'value' => $val,
|
1213 |
+
'compare' => $valtochk,
|
1214 |
+
'file_types' => $field['file_types'],
|
1215 |
+
) );
|
1216 |
+
|
1217 |
+
} else {
|
1218 |
+
|
1219 |
+
// For all other input types.
|
1220 |
+
$formfield_args = array(
|
1221 |
+
'name' => $meta_key, // ( 'username' == $meta_key ) ? 'user_login' : $meta_key,
|
1222 |
+
'type' => $field['type'],
|
1223 |
+
'value' => $val,
|
1224 |
+
'compare' => $valtochk,
|
1225 |
+
//'class' => ( $class ) ? $class : 'textbox',
|
1226 |
+
'required' => $field['required'],
|
1227 |
+
'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
|
1228 |
+
'pattern' => ( isset( $field['pattern'] ) ) ? $field['pattern'] : false,
|
1229 |
+
'title' => ( isset( $field['title'] ) ) ? $field['title'] : false,
|
1230 |
+
'min' => ( isset( $field['min'] ) ) ? $field['min'] : false,
|
1231 |
+
'max' => ( isset( $field['max'] ) ) ? $field['max'] : false,
|
1232 |
+
'rows' => ( isset( $field['rows'] ) ) ? $field['rows'] : false,
|
1233 |
+
'cols' => ( isset( $field['cols'] ) ) ? $field['cols'] : false,
|
1234 |
+
'file_types' => ( isset( $field['file_types'] ) ) ? $field['file_types'] : false,
|
1235 |
+
);
|
1236 |
+
if ( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
|
1237 |
+
$formfield_args['delimiter'] = $field['delimiter'];
|
1238 |
+
}
|
1239 |
+
$input = wpmem_form_field( $formfield_args );
|
1240 |
+
|
1241 |
+
// If checkbox label option is enabled.
|
1242 |
+
if ( 'checkbox' == $field['type'] && 1 == $field['checkbox_label'] ) {
|
1243 |
+
$input = $input . ' <label for="' . $meta_key . '">' . $label . '</label>';
|
1244 |
+
$fields[ $meta_key ]['label'] = $field['label'] = $label = '';
|
1245 |
+
}
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
// Determine input wrappers.
|
1249 |
+
$field_before = ( $args['wrap_inputs'] ) ? '<div class="div_' . $class . '">' : '';
|
1250 |
+
$field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
// If the row is set to display, add the row to the form array.
|
1256 |
+
if ( ( 'new' == $tag && $field['register'] ) || ( 'edit' == $tag && $field['profile'] ) ) {
|
1257 |
+
//if ( $field['register'] && 'hidden' != $field['type'] ) {
|
1258 |
+
if ( 'hidden' != $field['type'] ) {
|
1259 |
+
|
1260 |
+
$values = '';
|
1261 |
+
if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
|
1262 |
+
$values = $val;
|
1263 |
+
$val = $valtochk;
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
$rows[ $meta_key ] = array(
|
1267 |
+
'meta' => $meta_key,
|
1268 |
+
'type' => $field['type'],
|
1269 |
+
'value' => $val,
|
1270 |
+
'values' => $values,
|
1271 |
+
'label_text' => __( $field['label'], 'wp-members' ),
|
1272 |
+
'row_before' => $args['row_before'],
|
1273 |
+
'label' => $label,
|
1274 |
+
'field_before' => $field_before,
|
1275 |
+
'field' => $input,
|
1276 |
+
'field_after' => $field_after,
|
1277 |
+
'row_after' => $args['row_after'],
|
1278 |
+
);
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
// If captcha is Really Simple CAPTCHA.
|
1284 |
+
if ( 2 == $wpmem->captcha && 'edit' != $tag ) {
|
1285 |
+
// Build the captcha.
|
1286 |
+
$row = WP_Members_Captcha::rs_captcha( 'array' );
|
1287 |
+
$rows['captcha'] = array(
|
1288 |
+
'meta' => '',
|
1289 |
+
'type' => 'text',
|
1290 |
+
'value' => '',
|
1291 |
+
'values' => '',
|
1292 |
+
'label_text' => $row['label_text'],
|
1293 |
+
'row_before' => $args['row_before'],
|
1294 |
+
'label' => $row['label'],
|
1295 |
+
'field_before' => ( $args['wrap_inputs'] ) ? '<div class="div_text">' : '',
|
1296 |
+
'field' => $row['img'] . $row['hidden'] . $row['field'],
|
1297 |
+
'field_after' => ( $args['wrap_inputs'] ) ? '</div>' : '',
|
1298 |
+
'row_after' => $args['row_after'],
|
1299 |
+
);
|
1300 |
+
}
|
1301 |
+
|
1302 |
+
/**
|
1303 |
+
* Filter the array of form rows.
|
1304 |
+
*
|
1305 |
+
* This filter receives an array of the main rows in the form, each array element being
|
1306 |
+
* an array of that particular row's pieces. This allows making changes to individual
|
1307 |
+
* parts of a row without needing to parse through a string of HTML.
|
1308 |
+
*
|
1309 |
+
* @since 2.9.0
|
1310 |
+
* @since 3.0.9 Added $rows['label_text'].
|
1311 |
+
* @since 3.1.0 Added $rows['key'].
|
1312 |
+
* @since 3.1.6 Deprecated $rows['order'].
|
1313 |
+
*
|
1314 |
+
* @param array $rows {
|
1315 |
+
* An array containing the form rows.
|
1316 |
+
*
|
1317 |
+
* @type string order Field display order. (deprecated as of 3.1.6)
|
1318 |
+
* @type string meta Field meta tag (not used for display).
|
1319 |
+
* @type string type Input field type (not used for display).
|
1320 |
+
* @type string value Input field value (not used for display).
|
1321 |
+
* @type string values Possible field values (dropdown, multiple select/check, radio).
|
1322 |
+
* @type string label_text Raw text for the label (not used for display).
|
1323 |
+
* @type string row_before Opening wrapper tag around the row.
|
1324 |
+
* @type string label Label tag.
|
1325 |
+
* @type string field_before Opening wrapper tag before the input tag.
|
1326 |
+
* @type string field The field input tag.
|
1327 |
+
* @type string field_after Closing wrapper tag around the input tag.
|
1328 |
+
* @type string row_after Closing wrapper tag around the row.
|
1329 |
+
* }
|
1330 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1331 |
+
*/
|
1332 |
+
$rows = apply_filters( 'wpmem_register_form_rows', $rows, $tag );
|
1333 |
+
|
1334 |
+
// Put the rows from the array into $form.
|
1335 |
+
$form = ''; $enctype = '';
|
1336 |
+
foreach ( $rows as $meta_key => $row_item ) {
|
1337 |
+
// Make sure all keys are set just in case someone didn't return a proper array through the filter.
|
1338 |
+
foreach ( $this->get_reg_row_keys() as $check_key ) {
|
1339 |
+
if ( ! isset( $rows[ $meta_key ][ $check_key ] ) ) {
|
1340 |
+
$rows[ $meta_key ][ $check_key ] = '';
|
1341 |
+
}
|
1342 |
+
}
|
1343 |
+
// Check form to see if we need multipart enctype.
|
1344 |
+
$enctype = ( $row_item['type'] == 'file' || $row_item['type'] == 'image' ) ? "multipart/form-data" : $enctype;
|
1345 |
+
// Assemble row pieces.
|
1346 |
+
$row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
|
1347 |
+
$row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
|
1348 |
+
$row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
|
1349 |
+
$form.= $row;
|
1350 |
+
}
|
1351 |
+
|
1352 |
+
// Handle outside elements added to the register form with register_form.
|
1353 |
+
if ( 'new' == $tag && $args['register_form_action'] ) {
|
1354 |
+
ob_start();
|
1355 |
+
/** This action is documented in wp-login.php */
|
1356 |
+
do_action( 'register_form' );
|
1357 |
+
$add_to_form = ob_get_contents();
|
1358 |
+
ob_end_clean();
|
1359 |
+
$form.= $add_to_form;
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
// Do recaptcha if enabled.
|
1363 |
+
if ( ( 1 == $wpmem->captcha || 3 == $wpmem->captcha || 4 == $wpmem->captcha ) && $tag != 'edit' ) { // don't show on edit page!
|
1364 |
+
|
1365 |
+
$row = WP_Members_Captcha::recaptcha();
|
1366 |
+
|
1367 |
+
if ( 4 != $wpmem->captcha ) {
|
1368 |
+
$row = '<div class="clear"></div><div class="captcha">' . $row . '</div>';
|
1369 |
+
}
|
1370 |
+
|
1371 |
+
// Add the captcha row to the form.
|
1372 |
+
/**
|
1373 |
+
* Filter the HTML for the CAPTCHA row.
|
1374 |
+
*
|
1375 |
+
* @since 2.9.0
|
1376 |
+
*
|
1377 |
+
* @param string The HTML for the entire row (includes HTML tags plus reCAPTCHA).
|
1378 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1379 |
+
*/
|
1380 |
+
$form.= apply_filters( 'wpmem_register_captcha_row', $args['row_before'] . $row . $args['row_after'], $tag );
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
if ( 5 == $wpmem->captcha && 'edit' != $tag ) {
|
1384 |
+
$row = WP_Members_Captcha::hcaptcha();
|
1385 |
+
/** This filter is documented in /includes/class-wp-members-forms.php */
|
1386 |
+
$form.= apply_filters( 'wpmem_register_captcha_row', $args['row_before'] . $row . $args['row_after'], $tag );
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
// Create hidden fields.
|
1390 |
+
$var = ( $tag == 'edit' ) ? 'update' : 'register';
|
1391 |
+
$redirect_to = ( isset( $_REQUEST['redirect_to'] ) ) ? $_REQUEST['redirect_to'] : ( ( $redirect_to ) ? $redirect_to : get_permalink() );
|
1392 |
+
$hidden_rows['_wpmem_a'] = '<input name="a" type="hidden" value="' . esc_attr( $var ) . '" />';
|
1393 |
+
$hidden_rows['_wpmem_reg_page'] = '<input name="wpmem_reg_page" type="hidden" value="' . esc_url( get_permalink() ) . '" />';
|
1394 |
+
if ( $redirect_to != get_permalink() ) {
|
1395 |
+
$hidden_rows['_wpmem_redirect_to'] = '<input name="redirect_to" type="hidden" value="' . esc_url( $redirect_to ) . '" />';
|
1396 |
+
}
|
1397 |
+
|
1398 |
+
/**
|
1399 |
+
* Filter the hidden form rows.
|
1400 |
+
*
|
1401 |
+
* @since 3.2.0
|
1402 |
+
*
|
1403 |
+
* @param array $hidden_rows
|
1404 |
+
* @param string $tag
|
1405 |
+
*/
|
1406 |
+
$hidden_rows = apply_filters( 'wpmem_register_hidden_rows', $hidden_rows, $tag );
|
1407 |
+
|
1408 |
+
// Assemble hidden fields HTML.
|
1409 |
+
$hidden = '';
|
1410 |
+
foreach ( $hidden_rows as $hidden_row ) {
|
1411 |
+
$hidden .= $hidden_row . $args['n'];
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
/**
|
1415 |
+
* Filter the hidden field HTML.
|
1416 |
+
*
|
1417 |
+
* @since 2.9.0
|
1418 |
+
*
|
1419 |
+
* @param string $hidden The generated HTML of hidden fields.
|
1420 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1421 |
+
*/
|
1422 |
+
$hidden = apply_filters( 'wpmem_register_hidden_fields', $hidden, $tag );
|
1423 |
+
|
1424 |
+
// Add the hidden fields to the form.
|
1425 |
+
$form.= $hidden;
|
1426 |
+
|
1427 |
+
// Create buttons and wrapper.
|
1428 |
+
$button_text = ( $tag == 'edit' ) ? $args['submit_update'] : $args['submit_register'];
|
1429 |
+
$button_html = array(
|
1430 |
+
'reset' => ( $args['show_clear_form'] ) ? '<input name="reset" type="reset" value="' . esc_attr( $args['clear_form'] ) . '" class="' . wpmem_sanitize_class( $args['button_class'] ) . '" /> ' : '',
|
1431 |
+
'submit' => '<input name="submit" type="submit" value="' . esc_attr( $button_text ) . '" class="' . wpmem_sanitize_class( $args['button_class'] ) . '" />',
|
1432 |
+
);
|
1433 |
+
$buttons = $button_html['reset'] . $args['n'] . $button_html['submit'] . $args['n'];
|
1434 |
+
|
1435 |
+
/**
|
1436 |
+
* Filter the HTML for form buttons.
|
1437 |
+
*
|
1438 |
+
* The string passed through the filter includes the buttons, as well as the HTML wrapper elements.
|
1439 |
+
*
|
1440 |
+
* @since 2.9.0
|
1441 |
+
* @since 3.2.6 Added $button_html parameter
|
1442 |
+
*
|
1443 |
+
* @param string $buttons The generated HTML of the form buttons.
|
1444 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1445 |
+
* @param array $button_html The individual button html.
|
1446 |
+
*/
|
1447 |
+
$buttons = apply_filters( 'wpmem_register_form_buttons', $buttons, $tag, $button_html );
|
1448 |
+
|
1449 |
+
// Add the buttons to the form.
|
1450 |
+
$form.= $args['buttons_before'] . $args['n'] . $buttons . $args['buttons_after'] . $args['n'];
|
1451 |
+
|
1452 |
+
// Add the required field notation to the bottom of the form.
|
1453 |
+
$form.= $args['req_label_before'] . $args['req_label'] . $args['req_label_after'];
|
1454 |
+
|
1455 |
+
// Apply the heading.
|
1456 |
+
if ( 'edit' == $tag ) {
|
1457 |
+
/**
|
1458 |
+
* Filter the default heading in User Profile edit mode.
|
1459 |
+
*
|
1460 |
+
* @since 2.7.5
|
1461 |
+
* @since 3.3.0 Moved into main registration function (from profile shortcode).
|
1462 |
+
*
|
1463 |
+
* @param string The default edit mode heading.
|
1464 |
+
*/
|
1465 |
+
$heading = ( isset( $heading ) && '' != $heading ) ? $heading : apply_filters( 'wpmem_user_edit_heading', wpmem_get_text( 'profile_heading' ) );
|
1466 |
+
} else {
|
1467 |
+
/**
|
1468 |
+
* Filter the registration form heading.
|
1469 |
+
*
|
1470 |
+
* @since 2.8.2
|
1471 |
+
*
|
1472 |
+
* @param string $str
|
1473 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1474 |
+
*/
|
1475 |
+
$heading = ( isset( $heading ) && '' != $heading ) ? $heading : apply_filters( 'wpmem_register_heading', wpmem_get_text( 'register_heading' ), $tag );
|
1476 |
+
}
|
1477 |
+
$form = $args['heading_before'] . $heading . $args['heading_after'] . $args['n'] . $form;
|
1478 |
+
|
1479 |
+
// Apply fieldset wrapper.
|
1480 |
+
$form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
|
1481 |
+
|
1482 |
+
// Apply attribution if enabled.
|
1483 |
+
$form = $form . $this->attribution();
|
1484 |
+
|
1485 |
+
// Apply nonce. Nonce uses $tag value of the form processor, NOT the form builder.
|
1486 |
+
$nonce = ( $tag == 'edit' ) ? 'update' : 'register';
|
1487 |
+
$form = wp_nonce_field( 'wpmem_longform_nonce', '_wpmem_' . $nonce . '_nonce', true, false ) . $args['n'] . $form;
|
1488 |
+
|
1489 |
+
// Apply form wrapper.
|
1490 |
+
$enctype = ( $enctype == 'multipart/form-data' ) ? ' enctype="multipart/form-data"' : '';
|
1491 |
+
$form = '<form name="form" method="post"' . $enctype . ' action="' . esc_attr( $args['post_to'] ) . '" id="' . wpmem_sanitize_class( $args['form_id'] ) . '" class="' . wpmem_sanitize_class( $args['form_class'] ) . '">' . $args['n'] . $form . $args['n'] . '</form>';
|
1492 |
+
|
1493 |
+
// Apply anchor.
|
1494 |
+
$form = '<a id="register"></a>' . $args['n'] . $form;
|
1495 |
+
|
1496 |
+
// Apply main div wrapper.
|
1497 |
+
$form = $args['main_div_before'] . $args['n'] . $form . $args['n'] . $args['main_div_after'] . $args['n'];
|
1498 |
+
|
1499 |
+
// Remove line breaks if enabled for easier filtering later.
|
1500 |
+
$form = ( $args['strip_breaks'] ) ? $this->strip_breaks( $form, $rows ) : $form; //str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form ) : $form;
|
1501 |
+
|
1502 |
+
// If there is an image input type, include the following script.
|
1503 |
+
$form = ( $form_has_file ) ? $form . '
|
1504 |
+
<script>
|
1505 |
+
var loadFile = function(event, clicked_id) {
|
1506 |
+
var reader = new FileReader();
|
1507 |
+
var the_id = clicked_id + "_img";
|
1508 |
+
reader.onload = function() {
|
1509 |
+
var output = document.getElementById(the_id);
|
1510 |
+
output.src = reader.result;
|
1511 |
+
};
|
1512 |
+
reader.readAsDataURL(event.target.files[0]);
|
1513 |
+
};
|
1514 |
+
</script>' : $form;
|
1515 |
+
|
1516 |
+
/**
|
1517 |
+
* Filter the generated HTML of the entire form.
|
1518 |
+
*
|
1519 |
+
* @since 2.7.4
|
1520 |
+
*
|
1521 |
+
* @param string $form The HTML of the final generated form.
|
1522 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1523 |
+
* @param array $rows {
|
1524 |
+
* An array containing the form rows.
|
1525 |
+
*
|
1526 |
+
* @type string order Field display order.
|
1527 |
+
* @type string meta Field meta tag (not used for display).
|
1528 |
+
* @type string type Input field type (not used for display).
|
1529 |
+
* @type string value Input field value (not used for display).
|
1530 |
+
* @type string values The possible values for the field (dropdown, multiple select/checkbox, radio group).
|
1531 |
+
* @type string label_text Raw text for the label (not used for display).
|
1532 |
+
* @type string row_before Opening wrapper tag around the row.
|
1533 |
+
* @type string label Label tag.
|
1534 |
+
* @type string field_before Opening wrapper tag before the input tag.
|
1535 |
+
* @type string field The field input tag.
|
1536 |
+
* @type string field_after Closing wrapper tag around the input tag.
|
1537 |
+
* @type string row_after Closing wrapper tag around the row.
|
1538 |
+
* }
|
1539 |
+
* @param string $hidden The HTML string of hidden fields
|
1540 |
+
*/
|
1541 |
+
$form = apply_filters( 'wpmem_register_form', $form, $tag, $rows, $hidden );
|
1542 |
+
|
1543 |
+
/**
|
1544 |
+
* Filter before the form.
|
1545 |
+
*
|
1546 |
+
* This rarely used filter allows you to stick any string onto the front of
|
1547 |
+
* the generated form.
|
1548 |
+
*
|
1549 |
+
* @since 2.7.4
|
1550 |
+
*
|
1551 |
+
* @param string $str The HTML to add before the form. Default null.
|
1552 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
1553 |
+
*/
|
1554 |
+
$form = apply_filters( 'wpmem_register_form_before', '', $tag ) . $form;
|
1555 |
+
|
1556 |
+
$wpmem->reg_form_showing = true;
|
1557 |
+
|
1558 |
+
// Return the generated form.
|
1559 |
+
return $form;
|
1560 |
+
} // End register_form().
|
1561 |
+
|
1562 |
+
/**
|
1563 |
+
* Strip line breaks from form.
|
1564 |
+
*
|
1565 |
+
* Function removes line breaks and tabs. Checks for textarea fields
|
1566 |
+
* before stripping line breaks.
|
1567 |
+
*
|
1568 |
+
* @since 3.1.8
|
1569 |
+
*
|
1570 |
+
* @param string $form
|
1571 |
+
* @param array $rows
|
1572 |
+
* @return string $form
|
1573 |
+
*/
|
1574 |
+
function strip_breaks( $form, $rows ) {
|
1575 |
+
foreach( $rows as $key => $row ) {
|
1576 |
+
if ( 'textarea' == $row['type'] ) {
|
1577 |
+
$textareas[ $key ] = $row['field'];
|
1578 |
+
}
|
1579 |
+
}
|
1580 |
+
$form = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $form );
|
1581 |
+
if ( ! empty ( $textareas ) ) {
|
1582 |
+
foreach ( $textareas as $textarea ) {
|
1583 |
+
$stripped = str_replace( array( "\n", "\r", "\t" ), array( '','','' ), $textarea );
|
1584 |
+
$form = str_replace( $stripped, $textarea, $form );
|
1585 |
+
}
|
1586 |
+
}
|
1587 |
+
return $form;
|
1588 |
+
}
|
1589 |
+
|
1590 |
+
/**
|
1591 |
+
* Appends WP-Members registration fields to wp-login.php registration form.
|
1592 |
+
*
|
1593 |
+
* @since 2.8.7
|
1594 |
+
* @since 3.1.1 Updated to support new (3.1.0) field types.
|
1595 |
+
* @since 3.1.6 Updated to support new fields array. Added WC classes.
|
1596 |
+
* @since 3.1.8 Added $process parameter.
|
1597 |
+
* @since 3.3.0 Ported from wpmem_do_wp_register_form() in wp-registration.php.
|
1598 |
+
*
|
1599 |
+
* @global stdClass $wpmem
|
1600 |
+
* @param string $process
|
1601 |
+
*/
|
1602 |
+
function wp_register_form( $process = 'wp' ) {
|
1603 |
+
|
1604 |
+
global $wpmem;
|
1605 |
+
$wpmem_fields = wpmem_fields( $process );
|
1606 |
+
|
1607 |
+
// Check if this is WooCommerce account page.
|
1608 |
+
$is_woo = false;
|
1609 |
+
if ( 'woo' == $process ) {
|
1610 |
+
$is_woo = true;
|
1611 |
+
} else {
|
1612 |
+
if ( function_exists( 'is_account_page' ) ) {
|
1613 |
+
$is_woo = ( is_account_page() ) ? true : $is_woo;
|
1614 |
+
}
|
1615 |
+
}
|
1616 |
+
|
1617 |
+
if ( isset( $wpmem_fields ) && is_array( $wpmem_fields ) ) {
|
1618 |
+
|
1619 |
+
unset( $wpmem_fields['username'] );
|
1620 |
+
|
1621 |
+
if ( $is_woo ) {
|
1622 |
+
// Woo has its own setting for password fields.
|
1623 |
+
unset( $wpmem_fields['password'] );
|
1624 |
+
unset( $wpmem_fields['confirm_password'] );
|
1625 |
+
}
|
1626 |
+
|
1627 |
+
foreach ( $wpmem_fields as $meta_key => $field ) {
|
1628 |
+
|
1629 |
+
$req = ( $field['required'] ) ? ( ( $is_woo ) ? ' <span class="required">*</span>' : ' <span class="req">' . __( '(required)' ) . '</span>' ) : '';
|
1630 |
+
|
1631 |
+
// File fields not yet supported for this form.
|
1632 |
+
if ( $field['register'] && $meta_key != 'user_email' && $field['type'] != 'file' && $field['type'] != 'image' ) {
|
1633 |
+
|
1634 |
+
if ( 'checkbox' == $field['type'] ) {
|
1635 |
+
|
1636 |
+
if ( 'tos' == $meta_key ) {
|
1637 |
+
$tos_link_text = $this->get_tos_link( $field, 'woo' );
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
$label = ( 'tos' == $meta_key ) ? $tos_link_text : __( $field['label'], 'wp-members' );
|
1641 |
+
|
1642 |
+
$val = ( isset( $_POST[ $meta_key ] ) ) ? esc_attr( $_POST[ $meta_key ] ) : '';
|
1643 |
+
$val = ( ! $_POST && $field['checked_default'] ) ? $field['checked_value'] : $val;
|
1644 |
+
|
1645 |
+
$row_before = '<p class="wpmem-checkbox">';
|
1646 |
+
$label = '<label for="' . $meta_key . '">' . $label . $req . '</label>';
|
1647 |
+
$input = wpmem_form_field( $meta_key, $field['type'], $field['checked_value'], $val );
|
1648 |
+
$row_after = '</p>';
|
1649 |
+
|
1650 |
+
} elseif ( 'hidden' == $field['type'] ) {
|
1651 |
+
|
1652 |
+
// Handle hidden fields
|
1653 |
+
$row_before = '';
|
1654 |
+
$label = '';
|
1655 |
+
$input = wpmem_form_field( array(
|
1656 |
+
'name' => $meta_key,
|
1657 |
+
'type' => $field['type'],
|
1658 |
+
'value' => $field['value'],
|
1659 |
+
'compare' => $valtochk,
|
1660 |
+
'required' => $field['required'],
|
1661 |
+
) );
|
1662 |
+
$row_after = '';
|
1663 |
+
|
1664 |
+
} else {
|
1665 |
+
|
1666 |
+
$row_before = ( $is_woo ) ? '<p class="woocommerce-FormRow woocommerce-FormRow--wide form-row form-row-wide">' : '<p>';
|
1667 |
+
$label = '<label for="' . $meta_key . '">' . __( $field['label'], 'wp-members' ) . $req . '</label>';
|
1668 |
+
$label .= ( 'multicheckbox' == $field['type'] ) ? '<br />' : '';
|
1669 |
+
|
1670 |
+
// determine the field type and generate accordingly...
|
1671 |
+
|
1672 |
+
switch ( $field['type'] ) {
|
1673 |
+
|
1674 |
+
case( 'textarea' ):
|
1675 |
+
$input = '<textarea name="' . $meta_key . '" id="' . $meta_key . '" class="textarea">';
|
1676 |
+
$input.= ( isset( $_POST[ $meta_key ] ) ) ? esc_textarea( $_POST[ $meta_key ] ) : '';
|
1677 |
+
$input.= '</textarea>';
|
1678 |
+
break;
|
1679 |
+
|
1680 |
+
case( 'select' ):
|
1681 |
+
case( 'multiselect' ):
|
1682 |
+
case( 'multicheckbox' ):
|
1683 |
+
case( 'radio' ):
|
1684 |
+
case( 'membership' ):
|
1685 |
+
$row_before = ( $is_woo && ( 'select' == $field['type'] || 'multiselect' == $field['type'] || 'membership' == $field['type'] ) ) ? $row_before : '<p class="' . $field['type'] . '">';
|
1686 |
+
$valtochk = ( isset( $_POST[ $meta_key ] ) ) ? sanitize_text_field( $_POST[ $meta_key ] ) : '';
|
1687 |
+
$formfield_args = array(
|
1688 |
+
'name' => $meta_key,
|
1689 |
+
'type' => $field['type'],
|
1690 |
+
'value' => $field['values'],
|
1691 |
+
'compare' => $valtochk,
|
1692 |
+
'required' => $field['required'],
|
1693 |
+
'class' => ( $is_woo && ( 'select' == $field['type'] || 'multiselect' == $field['type'] || 'membership' == $field['type'] ) ) ? 'woocommerce-Input woocommerce-Input--text input-text' : $field['type'],
|
1694 |
+
);
|
1695 |
+
if ( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
|
1696 |
+
$formfield_args['delimiter'] = $field['delimiter'];
|
1697 |
+
}
|
1698 |
+
$input = wpmem_form_field( $formfield_args );
|
1699 |
+
break;
|
1700 |
+
|
1701 |
+
case( 'file' ):
|
1702 |
+
case( 'image' ):
|
1703 |
+
// Field type not supported for this yet.
|
1704 |
+
break;
|
1705 |
+
|
1706 |
+
default:
|
1707 |
+
$class = ( $is_woo ) ? 'woocommerce-Input woocommerce-Input--text input-text' : 'input';
|
1708 |
+
//$input = '<input type="' . $field['type'] . '" name="' . $meta_key . '" id="' . $meta_key . '" class="' . $class . '" value="';
|
1709 |
+
$formfield_args = array(
|
1710 |
+
'name' => $meta_key,
|
1711 |
+
'type' => $field['type'],
|
1712 |
+
'value' => wpmem_sanitize_field( wpmem_get( $meta_key, '' ), $field['type'] ),
|
1713 |
+
'compare' => ( isset( $field['compare'] ) ) ? $field['compare'] : '',
|
1714 |
+
'required' => $field['required'],
|
1715 |
+
'class' => $class,
|
1716 |
+
'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
|
1717 |
+
'pattern' => ( isset( $field['pattern'] ) ) ? $field['pattern'] : false,
|
1718 |
+
'title' => ( isset( $field['title'] ) ) ? $field['title'] : false,
|
1719 |
+
'min' => ( isset( $field['min'] ) ) ? $field['min'] : false,
|
1720 |
+
'max' => ( isset( $field['max'] ) ) ? $field['max'] : false,
|
1721 |
+
'rows' => ( isset( $field['rows'] ) ) ? $field['rows'] : false,
|
1722 |
+
'cols' => ( isset( $field['cols'] ) ) ? $field['cols'] : false,
|
1723 |
+
);
|
1724 |
+
$input = wpmem_form_field( $formfield_args );
|
1725 |
+
//$input.= ( isset( $_POST[ $meta_key ] ) ) ? esc_attr( $_POST[ $meta_key ] ) : '';
|
1726 |
+
//$input.= '" size="25" />';
|
1727 |
+
break;
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
$row_after = '</p>';
|
1731 |
+
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
// if the row is set to display, add the row to the form array
|
1735 |
+
$rows[ $meta_key ] = array(
|
1736 |
+
'type' => $field['type'],
|
1737 |
+
'row_before' => $row_before,
|
1738 |
+
'label' => $label,
|
1739 |
+
'field' => $input,
|
1740 |
+
'row_after' => $row_after,
|
1741 |
+
);
|
1742 |
+
}
|
1743 |
+
}
|
1744 |
+
|
1745 |
+
// Do recaptcha if enabled.
|
1746 |
+
if ( ! $is_woo && isset( $wpmem->captcha ) && $wpmem->captcha != 0 ) {
|
1747 |
+
|
1748 |
+
$row_before = '<p>';
|
1749 |
+
$row_after = '</p>';
|
1750 |
+
$label = '';
|
1751 |
+
$captcha = '';
|
1752 |
+
|
1753 |
+
if ( in_array( $wpmem->captcha, array( 1, 3, 4 ) ) ) {
|
1754 |
+
$captcha = WP_Members_Captcha::recaptcha();
|
1755 |
+
} elseif ( 5 == $wpmem->captcha ) {
|
1756 |
+
$captcha = WP_Members_Captcha::hcaptcha();
|
1757 |
+
} elseif ( 2 == $wpmem->captcha ) {
|
1758 |
+
$row = WP_Members_Captcha::rs_captcha( 'array' );
|
1759 |
+
$label = $row['label']; //$row['label_text'];
|
1760 |
+
$captcha = $row['img'] . $row['hidden'] . $row['field'];
|
1761 |
+
}
|
1762 |
+
if ( 4 == $wpmem->captcha ) {
|
1763 |
+
$row_before = '';
|
1764 |
+
$row_after = '';
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
$rows['captcha'] = array(
|
1768 |
+
'type' => '',
|
1769 |
+
'row_before' => $row_before,
|
1770 |
+
'row_after' => $row_after,
|
1771 |
+
'label' => $label,
|
1772 |
+
'field' => $captcha,
|
1773 |
+
);
|
1774 |
+
}
|
1775 |
+
|
1776 |
+
if ( isset( $rows ) && is_array( $rows ) ) {
|
1777 |
+
|
1778 |
+
/**
|
1779 |
+
* Filter the native registration form rows.
|
1780 |
+
*
|
1781 |
+
* @since 2.9.3.
|
1782 |
+
*
|
1783 |
+
* @param array $rows The custom rows added to the form.
|
1784 |
+
*/
|
1785 |
+
$rows = apply_filters( 'wpmem_native_form_rows', $rows );
|
1786 |
+
|
1787 |
+
foreach ( $rows as $row_item ) {
|
1788 |
+
if ( $row_item['type'] == 'checkbox' ) {
|
1789 |
+
echo $row_item['row_before'] . $row_item['field'] . $row_item['label'] . $row_item['row_after'];
|
1790 |
+
} else {
|
1791 |
+
echo $row_item['row_before'] . $row_item['label'] . $row_item['field'] . $row_item['row_after'];
|
1792 |
+
}
|
1793 |
+
}
|
1794 |
+
}
|
1795 |
+
}
|
1796 |
+
}
|
1797 |
+
|
1798 |
+
|
1799 |
+
/**
|
1800 |
+
* Appends WP-Members registration fields to Users > Add New User screen.
|
1801 |
+
*
|
1802 |
+
* @since 2.9.0
|
1803 |
+
* @since 3.1.1 Updated to support new (3.1.0) field types and user activation.
|
1804 |
+
* @since 3.1.6 Updated to support new fields array.
|
1805 |
+
* @since 3.3.0 Ported from wpmem_do_wp_newuser_form() in wp-registration.php.
|
1806 |
+
*
|
1807 |
+
* @global stdClass $wpmem
|
1808 |
+
*/
|
1809 |
+
function wp_newuser_form() {
|
1810 |
+
|
1811 |
+
global $wpmem;
|
1812 |
+
echo '<table class="form-table"><tbody>';
|
1813 |
+
|
1814 |
+
$wpmem_fields = wpmem_fields( 'add_new' );
|
1815 |
+
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
1816 |
+
|
1817 |
+
foreach ( $wpmem_fields as $meta_key => $field ) {
|
1818 |
+
|
1819 |
+
if ( ! $field['native'] && ! in_array( $meta_key, $exclude ) ) {
|
1820 |
+
|
1821 |
+
$req = ( $field['required'] ) ? ' <span class="description">' . __( '(required)' ) . '</span>' : '';
|
1822 |
+
|
1823 |
+
$class = ( 'radio' == $field['type']
|
1824 |
+
|| 'checkbox' == $field['type']
|
1825 |
+
|| 'date' == $field['type'] ) ? '' : ' class="form-field" ';
|
1826 |
+
echo '<tr' . $class . '>
|
1827 |
+
<th scope="row">
|
1828 |
+
<label for="' . $meta_key . '">' . __( $field['label'], 'wp-members' ) . $req . '</label>
|
1829 |
+
</th>
|
1830 |
+
<td>';
|
1831 |
+
|
1832 |
+
// determine the field type and generate accordingly.
|
1833 |
+
|
1834 |
+
// All fields use the following:
|
1835 |
+
$args['name'] = $meta_key;
|
1836 |
+
$args['type'] = $field['type'];
|
1837 |
+
$args['required'] = $field['required'];
|
1838 |
+
|
1839 |
+
$args['placeholder'] = ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '';
|
1840 |
+
$args['pattern'] = ( isset( $field['pattern'] ) ) ? $field['pattern'] : '';
|
1841 |
+
$args['title'] = ( isset( $field['title'] ) ) ? $field['title'] : '';
|
1842 |
+
|
1843 |
+
switch ( $field['type'] ) {
|
1844 |
+
|
1845 |
+
case( 'select' ):
|
1846 |
+
$val = ( isset( $_POST[ $meta_key ] ) ) ? sanitize_text_field( $_POST[ $meta_key ] ) : '';
|
1847 |
+
$args['value'] = $field['values'];
|
1848 |
+
$args['compare'] = $val;
|
1849 |
+
echo wpmem_form_field( $args );
|
1850 |
+
break;
|
1851 |
+
|
1852 |
+
case( 'textarea' ):
|
1853 |
+
$args['value'] = ( isset( $_POST[ $meta_key ] ) ) ? esc_textarea( $_POST[ $meta_key ] ) : '';
|
1854 |
+
echo wpmem_form_field( $args );
|
1855 |
+
break;
|
1856 |
+
|
1857 |
+
case( 'checkbox' ):
|
1858 |
+
$val = ( isset( $_POST[ $meta_key ] ) ) ? sanitize_text_field( $_POST[ $meta_key ] ) : '';
|
1859 |
+
$val = ( ! $_POST && $field['checked_default'] ) ? $field['checked_value'] : $val;
|
1860 |
+
$args['value'] = $field['checked_value'];
|
1861 |
+
$args['compare'] = $val;
|
1862 |
+
echo wpmem_form_field( $args );
|
1863 |
+
break;
|
1864 |
+
|
1865 |
+
case( 'multiselect' ):
|
1866 |
+
case( 'multicheckbox' ):
|
1867 |
+
case( 'radio' ):
|
1868 |
+
case( 'membership' );
|
1869 |
+
$args['value'] = $field['values'];
|
1870 |
+
$args['compare'] = ( isset( $_POST[ $meta_key ] ) ) ? sanitize_text_field( $_POST[ $meta_key ] ) : '';
|
1871 |
+
if ( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
|
1872 |
+
$args['delimiter'] = $field['delimiter'];
|
1873 |
+
}
|
1874 |
+
echo wpmem_form_field( $args );
|
1875 |
+
break;
|
1876 |
+
|
1877 |
+
case( 'file' ):
|
1878 |
+
case( 'image' ):
|
1879 |
+
echo 'Not currently supported for this form';
|
1880 |
+
break;
|
1881 |
+
|
1882 |
+
default:
|
1883 |
+
$args['value'] = ( isset( $_POST[ $meta_key ] ) ) ? esc_attr( $_POST[ $meta_key ] ) : '';
|
1884 |
+
echo wpmem_form_field( $args );
|
1885 |
+
break;
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
echo '</td>
|
1889 |
+
</tr>';
|
1890 |
+
|
1891 |
+
}
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
// If moderated registration is enabled, add checkbox to set user as active.
|
1895 |
+
if ( 1 == $wpmem->mod_reg ) {
|
1896 |
+
echo '<tr>
|
1897 |
+
<th scope="row">
|
1898 |
+
<label for="activate_user">' . __( 'Activate this user?', 'wp-members' ) . '</label>
|
1899 |
+
</th>
|
1900 |
+
<td>' . wpmem_form_field( array( 'name' => 'activate_user', 'type' => 'checkbox', 'value' => 1, 'compare' => '' ) ) . '</td>
|
1901 |
+
</tr>';
|
1902 |
+
}
|
1903 |
+
|
1904 |
+
echo '</tbody></table>';
|
1905 |
+
|
1906 |
+
}
|
1907 |
+
|
1908 |
+
/**
|
1909 |
+
* Create an attribution link in the form.
|
1910 |
+
*
|
1911 |
+
* @since 2.6.0
|
1912 |
+
* @since 3.1.1 Updated to use new object setting.
|
1913 |
+
* @since 3.3.0 Ported from wpmem_inc_attribution() in forms.php.
|
1914 |
+
*
|
1915 |
+
* @global object $wpmem
|
1916 |
+
* @return string $str
|
1917 |
+
*/
|
1918 |
+
function attribution() {
|
1919 |
+
|
1920 |
+
global $wpmem;
|
1921 |
+
$str = '
|
1922 |
+
<div align="center">
|
1923 |
+
<small>Powered by <a href="https://rocketgeek.com" target="_blank">WP-Members</a></small>
|
1924 |
+
</div>';
|
1925 |
+
|
1926 |
+
return ( 1 == $wpmem->attrib ) ? $str : '';
|
1927 |
+
}
|
1928 |
+
|
1929 |
+
/**
|
1930 |
+
* Settings for building Short Form (login).
|
1931 |
+
*
|
1932 |
+
* Replaces individual legacy functions and filters for
|
1933 |
+
* the short forms, combined into a single method.
|
1934 |
+
*
|
1935 |
+
* @since 3.3.0
|
1936 |
+
* @since 3.4.0 Change inputs.
|
1937 |
+
*
|
1938 |
+
* @global stdClass $post
|
1939 |
+
* @global stdClass $wpmem
|
1940 |
+
*
|
1941 |
+
* @param string $form login|changepassword|resetpassword|forgotusername
|
1942 |
+
* @param array $args
|
1943 |
+
* @return string $form
|
1944 |
+
*/
|
1945 |
+
function do_shortform( $form, $args = array() ) {
|
1946 |
+
|
1947 |
+
global $post, $wpmem;
|
1948 |
+
|
1949 |
+
$input_arrays = array(
|
1950 |
+
'login' => array(
|
1951 |
+
array(
|
1952 |
+
'name' => wpmem_get_text( 'login_username' ),
|
1953 |
+
'type' => 'text',
|
1954 |
+
'tag' => 'log',
|
1955 |
+
'class' => 'username',
|
1956 |
+
'div' => 'div_text',
|
1957 |
+
),
|
1958 |
+
array(
|
1959 |
+
'name' => wpmem_get_text( 'login_password' ),
|
1960 |
+
'type' => 'password',
|
1961 |
+
'tag' => 'pwd',
|
1962 |
+
'class' => 'password',
|
1963 |
+
'div' => 'div_text',
|
1964 |
+
),
|
1965 |
+
),
|
1966 |
+
'changepassword' => array(
|
1967 |
+
array(
|
1968 |
+
'name' => wpmem_get_text( 'pwdchg_password1' ),
|
1969 |
+
'type' => 'password',
|
1970 |
+
'tag' => 'pass1',
|
1971 |
+
'class' => 'password',
|
1972 |
+
'div' => 'div_text',
|
1973 |
+
),
|
1974 |
+
array(
|
1975 |
+
'name' => wpmem_get_text( 'pwdchg_password2' ),
|
1976 |
+
'type' => 'password',
|
1977 |
+
'tag' => 'pass2',
|
1978 |
+
'class' => 'password',
|
1979 |
+
'div' => 'div_text',
|
1980 |
+
),
|
1981 |
+
),
|
1982 |
+
'resetpassword' => array(
|
1983 |
+
array(
|
1984 |
+
'name' => wpmem_get_text( 'pwdreset_username' ),
|
1985 |
+
'type' => 'text',
|
1986 |
+
'tag' => 'user',
|
1987 |
+
'class' => 'username',
|
1988 |
+
'div' => 'div_text',
|
1989 |
+
),
|
1990 |
+
array(
|
1991 |
+
'name' => wpmem_get_text( 'pwdreset_email' ),
|
1992 |
+
'type' => 'text',
|
1993 |
+
'tag' => 'email',
|
1994 |
+
'class' => 'textbox',
|
1995 |
+
'div' => 'div_text',
|
1996 |
+
),
|
1997 |
+
),
|
1998 |
+
'forgotusername' => array(
|
1999 |
+
array(
|
2000 |
+
'name' => wpmem_get_text( 'username_email' ),
|
2001 |
+
'type' => 'text',
|
2002 |
+
'tag' => 'user_email',
|
2003 |
+
'class' => 'username',
|
2004 |
+
'div' => 'div_text',
|
2005 |
+
),
|
2006 |
+
),
|
2007 |
+
);
|
2008 |
+
|
2009 |
+
/**
|
2010 |
+
* Filter the array of change password form fields.
|
2011 |
+
*
|
2012 |
+
* @since 2.9.0
|
2013 |
+
* @deprecated 3.3.0 Use wpmem_{$form}_form_defaults instead.
|
2014 |
+
*
|
2015 |
+
* @param array $default_inputs An array matching the elements used by default.
|
2016 |
+
*/
|
2017 |
+
$default_inputs = apply_filters( 'wpmem_inc_' . $form . '_inputs', $input_arrays[ $form ] );
|
2018 |
+
|
2019 |
+
$form_arrays = array(
|
2020 |
+
'login' => array(
|
2021 |
+
'heading' => wpmem_get_text( 'login_heading' ),
|
2022 |
+
'action' => 'login',
|
2023 |
+
'button_text' => wpmem_get_text( 'login_button' ),
|
2024 |
+
'inputs' => $default_inputs,
|
2025 |
+
'redirect_to' => ( isset( $args['redirect_to'] ) ) ? $args['redirect_to'] : get_permalink(),
|
2026 |
+
),
|
2027 |
+
'changepassword' => array(
|
2028 |
+
'heading' => wpmem_get_text( 'pwdchg_heading' ),
|
2029 |
+
'action' => 'pwdchange',
|
2030 |
+
'button_text' => wpmem_get_text( 'pwdchg_button' ),
|
2031 |
+
'inputs' => $default_inputs,
|
2032 |
+
),
|
2033 |
+
'resetpassword' => array(
|
2034 |
+
'heading' => wpmem_get_text( 'pwdreset_heading' ),
|
2035 |
+
'action' => 'pwdreset',
|
2036 |
+
'button_text' => wpmem_get_text( 'pwdreset_button' ),
|
2037 |
+
'inputs' => $default_inputs,
|
2038 |
+
),
|
2039 |
+
'forgotusername' => array(
|
2040 |
+
'heading' => wpmem_get_text( 'username_heading' ),
|
2041 |
+
'action' => 'getusername',
|
2042 |
+
'button_text' => wpmem_get_text( 'username_button' ),
|
2043 |
+
'inputs' => $default_inputs,
|
2044 |
+
),
|
2045 |
+
);
|
2046 |
+
|
2047 |
+
/**
|
2048 |
+
* Filter the arguments to override form defaults.
|
2049 |
+
*
|
2050 |
+
* @since 2.9.0
|
2051 |
+
* @deprecated 3.3.0 Use wpmem_inc_{$form}_defaults instead.
|
2052 |
+
*
|
2053 |
+
* @param array $args An array of arguments to use. Default null. (login|changepassword|resetpassword|forgotusername)
|
2054 |
+
*/
|
2055 |
+
$args = apply_filters( 'wpmem_inc_' . $form . '_args', '' );
|
2056 |
+
$arr = wp_parse_args( $args, $form_arrays[ $form ] );
|
2057 |
+
|
2058 |
+
/**
|
2059 |
+
* Filter the arguments to override change password form defaults.
|
2060 |
+
*
|
2061 |
+
* @since 3.3.0
|
2062 |
+
*
|
2063 |
+
* @param array $args An array of arguments to use. Default null. (login|changepassword|resetpassword|forgotusername)
|
2064 |
+
*/
|
2065 |
+
$arr = apply_filters( 'wpmem_' . $form . '_form_defaults', $arr );
|
2066 |
+
|
2067 |
+
return $this->login_form( '', $arr );
|
2068 |
+
}
|
2069 |
+
|
2070 |
+
/**
|
2071 |
+
* Applies the post restricted message above the short form.
|
2072 |
+
*
|
2073 |
+
* @since 3.3.0
|
2074 |
+
*
|
2075 |
+
* @global stdClass $wpmem
|
2076 |
+
*
|
2077 |
+
* @return string $str The generated message.
|
2078 |
+
*/
|
2079 |
+
public function add_restricted_msg() {
|
2080 |
+
|
2081 |
+
global $wpmem;
|
2082 |
+
|
2083 |
+
$str = '';
|
2084 |
+
|
2085 |
+
if ( $wpmem->regchk != "success" ) {
|
2086 |
+
|
2087 |
+
$dialogs = get_option( 'wpmembers_dialogs' );
|
2088 |
+
|
2089 |
+
// This shown above blocked content.
|
2090 |
+
$msg = wpmem_get_text( 'restricted_msg' );
|
2091 |
+
$msg = ( $dialogs['restricted_msg'] == $msg ) ? $msg : __( stripslashes( $dialogs['restricted_msg'] ), 'wp-members' );
|
2092 |
+
$str = '<div id="wpmem_restricted_msg"><p>' . $msg . '</p></div>';
|
2093 |
+
|
2094 |
+
/**
|
2095 |
+
* Filter the post restricted message.
|
2096 |
+
*
|
2097 |
+
* @since 2.7.3
|
2098 |
+
* @since 3.2.0 Added raw message string and HTML as separate params.
|
2099 |
+
*
|
2100 |
+
* @param string $str The post restricted message with HTML.
|
2101 |
+
* @param string $msg The raw message string.
|
2102 |
+
* @param string The 'before' HTML wrapper.
|
2103 |
+
* @param string The 'after' HTML wrapper.
|
2104 |
+
*/
|
2105 |
+
$str = apply_filters( 'wpmem_restricted_msg', $str, $msg, '<div id="wpmem_restricted_msg"><p>', '</p></div>' );
|
2106 |
+
}
|
2107 |
+
|
2108 |
+
return $str;
|
2109 |
+
}
|
2110 |
+
|
2111 |
+
/**
|
2112 |
+
* Wrapper for handing the default WP login form.
|
2113 |
+
*
|
2114 |
+
* @since 3.3.2
|
2115 |
+
*/
|
2116 |
+
function wp_login_form( $args ) {
|
2117 |
+
|
2118 |
+
return wp_login_form( $args );
|
2119 |
+
}
|
2120 |
+
|
2121 |
+
/**
|
2122 |
+
* Generate TOS field with link.
|
2123 |
+
*
|
2124 |
+
* @since 3.3.5
|
2125 |
+
*
|
2126 |
+
* @param array $field
|
2127 |
+
* @param string $tag
|
2128 |
+
* @return string
|
2129 |
+
*/
|
2130 |
+
function get_tos_link( $field, $tag = 'new' ) {
|
2131 |
+
global $wpmem;
|
2132 |
+
// Determine if TOS is a WP page or not.
|
2133 |
+
$tos_content = stripslashes( get_option( 'wpmembers_tos' ) );
|
2134 |
+
if ( has_shortcode( $tos_content, 'wpmem_tos' ) || has_shortcode( $tos_content, 'wp-members' ) ) {
|
2135 |
+
$tos_link_url = do_shortcode( $tos_content );
|
2136 |
+
$tos_link_tag = '<a href="' . esc_url( $tos_link_url ) . '" target="_blank">';
|
2137 |
+
} else {
|
2138 |
+
$tos_link_url = add_query_arg( 'tos', 'display' );
|
2139 |
+
$tos_link_tag = "<a href=\"#\" onClick=\"window.open('" . $tos_link_url . "','tos');\">";
|
2140 |
+
}
|
2141 |
+
|
2142 |
+
/**
|
2143 |
+
* Filter the TOS link.
|
2144 |
+
*
|
2145 |
+
* @since 3.2.6
|
2146 |
+
*
|
2147 |
+
* @param string $tos_link_tag
|
2148 |
+
* @param string $tos_link_url
|
2149 |
+
*/
|
2150 |
+
$tos_link_tag = apply_filters( 'wpmem_tos_link_tag', $tos_link_tag, $tos_link_url );
|
2151 |
+
|
2152 |
+
/**
|
2153 |
+
* Filter the TOS link text.
|
2154 |
+
*
|
2155 |
+
* @since 2.7.5
|
2156 |
+
*
|
2157 |
+
* @param string The link text.
|
2158 |
+
* @param string $tag Toggle new registration or profile update. new|edit.
|
2159 |
+
*/
|
2160 |
+
$tos_link_text = apply_filters( 'wpmem_tos_link_txt', wpmem_get_text( 'register_tos' ), $tag );
|
2161 |
+
|
2162 |
+
// If filtered value is not the default label, use that, otherwise use label.
|
2163 |
+
// @note: if default changes, this check must change.
|
2164 |
+
if ( __( 'Please indicate that you agree to the %s Terms of Service %s', 'wp-members' ) == $tos_link_text ) {
|
2165 |
+
if ( __( 'TOS', 'wp-members' ) != $field['label'] && __( 'Terms of Service', 'wp-members' ) != $field['label'] ) {
|
2166 |
+
$tos_link_text = $field['label'];
|
2167 |
+
}
|
2168 |
+
}
|
2169 |
+
|
2170 |
+
// If tos string does not contain link identifiers (%s), wrap the whole string.
|
2171 |
+
if ( ! strpos( $tos_link_text, '%s' ) ) {
|
2172 |
+
$tos_link_text = '%s' . $tos_link_text . '%s';
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
return sprintf( $tos_link_text, $tos_link_tag, '</a>' );
|
2176 |
+
}
|
2177 |
+
|
2178 |
+
function get_reg_row_keys() {
|
2179 |
+
return array( 'meta', 'type', 'value', 'values', 'label_text', 'row_before', 'label', 'field_before', 'field', 'field_after', 'row_after' );
|
2180 |
+
}
|
2181 |
} // End of WP_Members_Forms class.
|
@@ -1,527 +1,541 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members Membership Products 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 Membership Products 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_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 |
-
* Array of membership product information.
|
55 |
-
*
|
56 |
-
* @type array $product_slug {
|
57 |
-
* Array of membership product settings.
|
58 |
-
*
|
59 |
-
* @type string $title The product title (user view).
|
60 |
-
* @type string $role User role, if a role is required.
|
61 |
-
* @type string $name The product slug.
|
62 |
-
* @type string $default
|
63 |
-
* @type array $expires {
|
64 |
-
* If the membership has expiration periods.
|
65 |
-
*
|
66 |
-
* $type string number|period Number of periods|Period (year/month/week/day).
|
67 |
-
* }
|
68 |
-
* }
|
69 |
-
* }
|
70 |
-
*/
|
71 |
-
public $products = array();
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Product meta keyed by ID.
|
75 |
-
*
|
76 |
-
* @since 3.2.4
|
77 |
-
* @access public
|
78 |
-
* @var array {
|
79 |
-
* Array of membership products keyed by CPT ID.
|
80 |
-
*
|
81 |
-
* @type string $ID The membership product slug.
|
82 |
-
* }
|
83 |
-
*/
|
84 |
-
public $product_by_id = array();
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Class constructor.
|
88 |
-
*
|
89 |
-
* @since 3.2.0
|
90 |
-
*
|
91 |
-
* @global object $wpmem The WP_Members object class.
|
92 |
-
*/
|
93 |
-
function __construct() {
|
94 |
-
|
95 |
-
$this->load_products();
|
96 |
-
|
97 |
-
add_filter( 'wpmem_securify', array( $this, 'product_access' ) );
|
98 |
-
add_filter( 'wpmem_product_restricted_msg', array( $this, '
|
99 |
-
add_filter( 'wpmem_restricted_msg', array( $this, '
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Loads product settings.
|
104 |
-
*
|
105 |
-
* @since 3.2.0
|
106 |
-
*
|
107 |
-
* @global object $wpdb The WPDB object class.
|
108 |
-
*/
|
109 |
-
function load_products() {
|
110 |
-
global $wpdb;
|
111 |
-
$sql = "SELECT ID, post_title, post_name FROM "
|
112 |
-
. $wpdb->prefix
|
113 |
-
. "posts WHERE post_type = 'wpmem_product' AND post_status = 'publish';";
|
114 |
-
$result = $wpdb->get_results( $sql );
|
115 |
-
foreach ( $result as $plan ) {
|
116 |
-
$this->product_by_id[ $plan->ID ] = $plan->post_name;
|
117 |
-
$this->products[ $plan->post_name ]['title'] = $plan->post_title;
|
118 |
-
$post_meta = get_post_meta( $plan->ID );
|
119 |
-
foreach ( $post_meta as $key => $meta ) {
|
120 |
-
if ( false !== strpos( $key, 'wpmem_product' ) ) {
|
121 |
-
if ( 'wpmem_product_expires' == $key ) {
|
122 |
-
$meta[0] = unserialize( $meta[0] );
|
123 |
-
}
|
124 |
-
if ( 'wpmem_product_fixed_period' == $key ) {
|
125 |
-
$meta[0] = $this->explode_fixed_period( $meta[0] );
|
126 |
-
}
|
127 |
-
$this->products[ $plan->post_name ][ str_replace( 'wpmem_product_', '', $key ) ] = $meta[0];
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Gets products assigned to a post.
|
135 |
-
*
|
136 |
-
* @since 3.2.4
|
137 |
-
*
|
138 |
-
* @param integer $post_id
|
139 |
-
* @return array $products {
|
140 |
-
* Membership product slugs the post is restricted to.
|
141 |
-
*
|
142 |
-
* @type string $slug
|
143 |
-
* }
|
144 |
-
*/
|
145 |
-
function get_post_products( $post_id ) {
|
146 |
-
$products = get_post_meta( $post_id, $this->post_meta, true );
|
147 |
-
/**
|
148 |
-
* Filter product access by post ID.
|
149 |
-
*
|
150 |
-
* @since 3.3.5
|
151 |
-
*
|
152 |
-
* @param array $post_products
|
153 |
-
* @param int $post_id
|
154 |
-
*/
|
155 |
-
$products = apply_filters( 'wpmem_post_products', $products, $post_id );
|
156 |
-
return $products;
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Gets default membership products.
|
161 |
-
*
|
162 |
-
* @since 3.3.0
|
163 |
-
*
|
164 |
-
* @return array $defaults
|
165 |
-
*/
|
166 |
-
function get_default_products() {
|
167 |
-
// Get any default membership products.
|
168 |
-
$args = array(
|
169 |
-
'numberposts' => -1,
|
170 |
-
'post_type' => $this->post_type,
|
171 |
-
'meta_key' => 'wpmem_product_default',
|
172 |
-
'meta_value' => 1,
|
173 |
-
'fields' => array( 'post_name' ),
|
174 |
-
);
|
175 |
-
$default_products = get_posts( $args );
|
176 |
-
$defaults = array();
|
177 |
-
if ( $default_products ) {
|
178 |
-
foreach ( $default_products as $product ) {
|
179 |
-
$defaults[] = $product->post_name;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
return $defaults;
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Sets up custom access restriction by product.
|
187 |
-
*
|
188 |
-
* @since 3.2.0
|
189 |
-
* @since 3.2.2 Merged check_product_access() logic for better messaging.
|
190 |
-
*
|
191 |
-
* @global object $post The WordPress Post object.
|
192 |
-
* @global object $wpmem The WP_Members object class.
|
193 |
-
* @param string $content
|
194 |
-
* @return string $content
|
195 |
-
*/
|
196 |
-
function product_access( $content ) {
|
197 |
-
|
198 |
-
global $post, $wpmem;
|
199 |
-
// Is the user logged in and is this blocked content?
|
200 |
-
if ( ! is_admin() && is_user_logged_in() && wpmem_is_blocked() && 1 == $wpmem->enable_products ) { // @todo Should is_admin() check be run on securify in general?
|
201 |
-
|
202 |
-
// Get the post access products.
|
203 |
-
$post_products = $this->get_post_products( $post->ID );
|
204 |
-
// If the post is restricted to a product.
|
205 |
-
if ( is_array( $post_products ) && ! empty( $post_products ) ) {
|
206 |
-
$access = ( wpmem_user_has_access( $post_products ) ) ? true : false;
|
207 |
-
} else {
|
208 |
-
$access = true;
|
209 |
-
}
|
210 |
-
|
211 |
-
// Only produce the product restricted message if access is false.
|
212 |
-
if ( false === $access ) {
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
*
|
226 |
-
*
|
227 |
-
* @
|
228 |
-
*
|
229 |
-
*
|
230 |
-
*
|
231 |
-
*
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
$
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
'
|
340 |
-
'
|
341 |
-
|
342 |
-
|
343 |
-
'
|
344 |
-
'
|
345 |
-
'
|
346 |
-
'
|
347 |
-
'
|
348 |
-
'
|
349 |
-
'
|
350 |
-
'
|
351 |
-
'
|
352 |
-
'
|
353 |
-
'
|
354 |
-
'
|
355 |
-
|
356 |
-
|
357 |
-
'
|
358 |
-
'
|
359 |
-
'
|
360 |
-
'
|
361 |
-
'
|
362 |
-
'
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
'
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
return $
|
411 |
-
}
|
412 |
-
|
413 |
-
/**
|
414 |
-
*
|
415 |
-
*
|
416 |
-
* @since 3.3.5
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
//
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members Membership Products 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 Membership Products 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_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 |
+
* Array of membership product information.
|
55 |
+
*
|
56 |
+
* @type array $product_slug {
|
57 |
+
* Array of membership product settings.
|
58 |
+
*
|
59 |
+
* @type string $title The product title (user view).
|
60 |
+
* @type string $role User role, if a role is required.
|
61 |
+
* @type string $name The product slug.
|
62 |
+
* @type string $default
|
63 |
+
* @type array $expires {
|
64 |
+
* If the membership has expiration periods.
|
65 |
+
*
|
66 |
+
* $type string number|period Number of periods|Period (year/month/week/day).
|
67 |
+
* }
|
68 |
+
* }
|
69 |
+
* }
|
70 |
+
*/
|
71 |
+
public $products = array();
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Product meta keyed by ID.
|
75 |
+
*
|
76 |
+
* @since 3.2.4
|
77 |
+
* @access public
|
78 |
+
* @var array {
|
79 |
+
* Array of membership products keyed by CPT ID.
|
80 |
+
*
|
81 |
+
* @type string $ID The membership product slug.
|
82 |
+
* }
|
83 |
+
*/
|
84 |
+
public $product_by_id = array();
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Class constructor.
|
88 |
+
*
|
89 |
+
* @since 3.2.0
|
90 |
+
*
|
91 |
+
* @global object $wpmem The WP_Members object class.
|
92 |
+
*/
|
93 |
+
function __construct() {
|
94 |
+
|
95 |
+
$this->load_products();
|
96 |
+
|
97 |
+
add_filter( 'wpmem_securify', array( $this, 'product_access' ) );
|
98 |
+
add_filter( 'wpmem_product_restricted_msg', array( $this, 'apply_custom_access_message' ) );
|
99 |
+
add_filter( 'wpmem_restricted_msg', array( $this, 'apply_custom_access_message' ) );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Loads product settings.
|
104 |
+
*
|
105 |
+
* @since 3.2.0
|
106 |
+
*
|
107 |
+
* @global object $wpdb The WPDB object class.
|
108 |
+
*/
|
109 |
+
function load_products() {
|
110 |
+
global $wpdb;
|
111 |
+
$sql = "SELECT ID, post_title, post_name FROM "
|
112 |
+
. $wpdb->prefix
|
113 |
+
. "posts WHERE post_type = 'wpmem_product' AND post_status = 'publish';";
|
114 |
+
$result = $wpdb->get_results( $sql );
|
115 |
+
foreach ( $result as $plan ) {
|
116 |
+
$this->product_by_id[ $plan->ID ] = $plan->post_name;
|
117 |
+
$this->products[ $plan->post_name ]['title'] = $plan->post_title;
|
118 |
+
$post_meta = get_post_meta( $plan->ID );
|
119 |
+
foreach ( $post_meta as $key => $meta ) {
|
120 |
+
if ( false !== strpos( $key, 'wpmem_product' ) ) {
|
121 |
+
if ( 'wpmem_product_expires' == $key ) {
|
122 |
+
$meta[0] = unserialize( $meta[0] );
|
123 |
+
}
|
124 |
+
if ( 'wpmem_product_fixed_period' == $key ) {
|
125 |
+
$meta[0] = $this->explode_fixed_period( $meta[0] );
|
126 |
+
}
|
127 |
+
$this->products[ $plan->post_name ][ str_replace( 'wpmem_product_', '', $key ) ] = $meta[0];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Gets products assigned to a post.
|
135 |
+
*
|
136 |
+
* @since 3.2.4
|
137 |
+
*
|
138 |
+
* @param integer $post_id
|
139 |
+
* @return array $products {
|
140 |
+
* Membership product slugs the post is restricted to.
|
141 |
+
*
|
142 |
+
* @type string $slug
|
143 |
+
* }
|
144 |
+
*/
|
145 |
+
function get_post_products( $post_id ) {
|
146 |
+
$products = get_post_meta( $post_id, $this->post_meta, true );
|
147 |
+
/**
|
148 |
+
* Filter product access by post ID.
|
149 |
+
*
|
150 |
+
* @since 3.3.5
|
151 |
+
*
|
152 |
+
* @param array $post_products
|
153 |
+
* @param int $post_id
|
154 |
+
*/
|
155 |
+
$products = apply_filters( 'wpmem_post_products', $products, $post_id );
|
156 |
+
return $products;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Gets default membership products.
|
161 |
+
*
|
162 |
+
* @since 3.3.0
|
163 |
+
*
|
164 |
+
* @return array $defaults
|
165 |
+
*/
|
166 |
+
function get_default_products() {
|
167 |
+
// Get any default membership products.
|
168 |
+
$args = array(
|
169 |
+
'numberposts' => -1,
|
170 |
+
'post_type' => $this->post_type,
|
171 |
+
'meta_key' => 'wpmem_product_default',
|
172 |
+
'meta_value' => 1,
|
173 |
+
'fields' => array( 'post_name' ),
|
174 |
+
);
|
175 |
+
$default_products = get_posts( $args );
|
176 |
+
$defaults = array();
|
177 |
+
if ( $default_products ) {
|
178 |
+
foreach ( $default_products as $product ) {
|
179 |
+
$defaults[] = $product->post_name;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
return $defaults;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Sets up custom access restriction by product.
|
187 |
+
*
|
188 |
+
* @since 3.2.0
|
189 |
+
* @since 3.2.2 Merged check_product_access() logic for better messaging.
|
190 |
+
*
|
191 |
+
* @global object $post The WordPress Post object.
|
192 |
+
* @global object $wpmem The WP_Members object class.
|
193 |
+
* @param string $content
|
194 |
+
* @return string $content
|
195 |
+
*/
|
196 |
+
function product_access( $content ) {
|
197 |
+
|
198 |
+
global $post, $wpmem;
|
199 |
+
// Is the user logged in and is this blocked content?
|
200 |
+
if ( ! is_admin() && is_user_logged_in() && wpmem_is_blocked() && 1 == $wpmem->enable_products ) { // @todo Should is_admin() check be run on securify in general?
|
201 |
+
|
202 |
+
// Get the post access products.
|
203 |
+
$post_products = $this->get_post_products( $post->ID );
|
204 |
+
// If the post is restricted to a product.
|
205 |
+
if ( is_array( $post_products ) && ! empty( $post_products ) ) {
|
206 |
+
$access = ( wpmem_user_has_access( $post_products ) ) ? true : false;
|
207 |
+
} else {
|
208 |
+
$access = true;
|
209 |
+
}
|
210 |
+
|
211 |
+
// Only produce the product restricted message if access is false.
|
212 |
+
if ( false === $access ) {
|
213 |
+
|
214 |
+
$message = wpmem_get_access_message( $post_products );
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Filter the product restricted message HTML.
|
218 |
+
*
|
219 |
+
* @since 3.3.3
|
220 |
+
* @since 3.3.4 Added $post_products
|
221 |
+
*
|
222 |
+
* @param array $product_restricted {
|
223 |
+
* $type string $wrapper_before
|
224 |
+
* $type string $message
|
225 |
+
* $type string $wrapper_after
|
226 |
+
* }
|
227 |
+
* @param array $post_products {
|
228 |
+
* Membership product slugs the post is restricted to.
|
229 |
+
*
|
230 |
+
* @type string $slug
|
231 |
+
* }
|
232 |
+
*/
|
233 |
+
$product_restricted = apply_filters( 'wpmem_product_restricted_args', array(
|
234 |
+
'wrapper_before' => '<div class="wpmem_msg">',
|
235 |
+
'message' => $message,
|
236 |
+
'wrapper_after' => '</div>',
|
237 |
+
), $post_products );
|
238 |
+
|
239 |
+
$content = $product_restricted['wrapper_before'] . $product_restricted['message'] . $product_restricted['wrapper_after'];
|
240 |
+
|
241 |
+
// Handle comments.
|
242 |
+
add_filter( 'wpmem_securify_comments', '__return_false' );
|
243 |
+
}
|
244 |
+
|
245 |
+
}
|
246 |
+
|
247 |
+
return $content;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Gets the access message if user does not have required membership.
|
252 |
+
*
|
253 |
+
* @since 3.4.0
|
254 |
+
*
|
255 |
+
* @param array $post_products
|
256 |
+
* @return string $message
|
257 |
+
*/
|
258 |
+
function get_access_message( $post_products ) {
|
259 |
+
// Singular message if post only has one membership, otherwise multiple.
|
260 |
+
if ( 1 == count( $post_products ) ) {
|
261 |
+
$message = wpmem_get_text( 'product_restricted_single' )
|
262 |
+
. "<br />" . $this->products[ $post_products[0] ]['title'];
|
263 |
+
} else {
|
264 |
+
$message = wpmem_get_text( 'product_restricted_multiple' ) . "<br />";
|
265 |
+
foreach ( $post_products as $post_product ) {
|
266 |
+
$message .= $this->products[ $post_product ]['title'] . "<br />";
|
267 |
+
}
|
268 |
+
}
|
269 |
+
/**
|
270 |
+
* Filter the product restricted message.
|
271 |
+
*
|
272 |
+
* @since 3.2.3
|
273 |
+
*
|
274 |
+
* @param string The message.
|
275 |
+
* @param array $post_products {
|
276 |
+
* Membership product slugs the post is restricted to.
|
277 |
+
*
|
278 |
+
* @type string $slug
|
279 |
+
* }
|
280 |
+
*/
|
281 |
+
$message = apply_filters( 'wpmem_product_restricted_msg', $message, $post_products );
|
282 |
+
return $message;
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Filters the access message if the user does not have
|
287 |
+
* access to this membership.
|
288 |
+
*
|
289 |
+
* @since 3.3.4
|
290 |
+
* @since 3.4.0 Renamed from access_message().
|
291 |
+
*
|
292 |
+
* @global stdClass $post
|
293 |
+
* @param string $msg
|
294 |
+
* @return string $msg
|
295 |
+
*/
|
296 |
+
function apply_custom_access_message( $msg ) {
|
297 |
+
global $post;
|
298 |
+
$post_products = $this->get_post_products( $post->ID );
|
299 |
+
if ( $post_products ) {
|
300 |
+
foreach( $post_products as $post_product ) {
|
301 |
+
$membership_id = array_search( $post_product, $this->product_by_id );
|
302 |
+
$message = wpautop( get_post_meta( $membership_id, 'wpmem_product_message', true ) );
|
303 |
+
if ( $message ) {
|
304 |
+
$product_message = ( isset( $product_message ) ) ? $product_message . $message : $message;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
if ( isset( $product_message ) ) {
|
308 |
+
$msg = $product_message;
|
309 |
+
}
|
310 |
+
}
|
311 |
+
return $msg;
|
312 |
+
}
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Register Membership Plans Custom Post Type
|
316 |
+
*
|
317 |
+
* @since 3.2.0
|
318 |
+
*
|
319 |
+
* @global object $wpmem The WP_Members object class.
|
320 |
+
*/
|
321 |
+
function add_cpt() {
|
322 |
+
|
323 |
+
global $wpmem;
|
324 |
+
|
325 |
+
$args = array( 'capabilities' => 'manage_options', );
|
326 |
+
/**
|
327 |
+
* Filter customizable elements of the membership custom post type.
|
328 |
+
*
|
329 |
+
* @since 3.3.5
|
330 |
+
*
|
331 |
+
* @param array
|
332 |
+
*/
|
333 |
+
$args = apply_filters( 'wpmem_membership_cpt_args', $args );
|
334 |
+
|
335 |
+
$singular = __( 'Product', 'wp-members' );
|
336 |
+
$plural = __( 'Products', 'wp-members' );
|
337 |
+
|
338 |
+
$labels = array(
|
339 |
+
'name' => $plural,
|
340 |
+
'singular_name' => $singular,
|
341 |
+
'menu_name' => __( 'Memberships', 'wp-members' ),
|
342 |
+
'all_items' => sprintf( __( 'All %s', 'wp-members' ), $plural ),
|
343 |
+
'add_new_item' => sprintf( __( 'Add New %s', 'wp-members' ), $singular ),
|
344 |
+
'add_new' => __( 'Add New', 'wp-members' ),
|
345 |
+
'new_item' => sprintf( __( 'New %s', 'wp-members' ), $singular ),
|
346 |
+
'edit_item' => sprintf( __( 'Edit %s', 'wp-members' ), $singular ),
|
347 |
+
'update_item' => sprintf( __( 'Update %s', 'wp-members' ), $singular ),
|
348 |
+
'view_item' => sprintf( __( 'View %s', 'wp-members' ), $singular ),
|
349 |
+
'view_items' => sprintf( __( 'View %s', 'wp-members' ), $plural ),
|
350 |
+
'search_items' => sprintf( __( 'Search %s', 'wp-members' ), $plural ),
|
351 |
+
'not_found' => __( 'Not found', 'wp-members' ),
|
352 |
+
'not_found_in_trash' => __( 'Not found in Trash', 'wp-members' ),
|
353 |
+
'insert_into_item' => __( 'Insert into item', 'wp-members' ),
|
354 |
+
'publish' => sprintf( __( 'Save %s Details', 'wp-members' ), $singular ),
|
355 |
+
);
|
356 |
+
$args = array(
|
357 |
+
'label' => __( 'Membership Product', 'wp-members' ),
|
358 |
+
'description' => __( 'WP-Members Membership Products', 'wp-members' ),
|
359 |
+
'labels' => $labels,
|
360 |
+
'supports' => array( 'title', 'page-attributes' ),
|
361 |
+
'hierarchical' => true,
|
362 |
+
'public' => false,
|
363 |
+
'show_ui' => ( $wpmem->enable_products ) ? true : false,
|
364 |
+
'show_in_menu' => ( $wpmem->enable_products ) ? true : false,
|
365 |
+
'menu_position' => 58,
|
366 |
+
'menu_icon' => 'dashicons-groups',
|
367 |
+
'show_in_admin_bar' => false,
|
368 |
+
'show_in_nav_menus' => false,
|
369 |
+
'can_export' => true,
|
370 |
+
'has_archive' => false,
|
371 |
+
'exclude_from_search' => true,
|
372 |
+
'publicly_queryable' => false,
|
373 |
+
'query_var' => 'membership_product',
|
374 |
+
'rewrite' => false,
|
375 |
+
'capability_type' => 'page',
|
376 |
+
'capabilities' => array(
|
377 |
+
'publish_posts' => $args['capabilities'],
|
378 |
+
'edit_posts' => $args['capabilities'],
|
379 |
+
'delete_posts' => $args['capabilities'],
|
380 |
+
'edit_post' => $args['capabilities'],
|
381 |
+
'delete_post' => $args['capabilities'],
|
382 |
+
'read_post' => $args['capabilities'],
|
383 |
+
),
|
384 |
+
'show_in_rest' => false,
|
385 |
+
//'register_meta_box_cb' => '', // callback for meta box
|
386 |
+
);
|
387 |
+
register_post_type( $this->post_type, $args );
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Get all posts tagged to a specified product.
|
392 |
+
*
|
393 |
+
* @since 3.3.0
|
394 |
+
*
|
395 |
+
* @global stdClass $wpdb
|
396 |
+
*
|
397 |
+
* @param string $product_meta
|
398 |
+
* @return array $post_ids
|
399 |
+
*/
|
400 |
+
function get_all_posts( $product_meta ) {
|
401 |
+
global $wpdb;
|
402 |
+
$results = $wpdb->get_results( $wpdb->prepare( "
|
403 |
+
SELECT post_id
|
404 |
+
FROM {$wpdb->postmeta}
|
405 |
+
WHERE meta_key = %s
|
406 |
+
", $this->post_stem . $product_meta ), ARRAY_N );
|
407 |
+
foreach ( $results as $result ) {
|
408 |
+
$post_ids[] = $result[0];
|
409 |
+
}
|
410 |
+
return $post_ids;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Utility to explode fixed period.
|
415 |
+
*
|
416 |
+
* @since 3.3.5
|
417 |
+
*/
|
418 |
+
function explode_fixed_period( $array ) {
|
419 |
+
$period_parts = explode( "-", $array );
|
420 |
+
$period['start'] = ( $period_parts ) ? $period_parts[0] . '-' . $period_parts[1] : '';
|
421 |
+
$period['end'] = ( $period_parts ) ? $period_parts[2] . '-' . $period_parts[3] : '';
|
422 |
+
$period['grace']['num'] = ( $period_parts && isset( $period_parts[4] ) ) ? $period_parts[4] : '';
|
423 |
+
$period['grace']['per'] = ( $period_parts && isset( $period_parts[5] ) ) ? $period_parts[5] : '';
|
424 |
+
return $period;
|
425 |
+
}
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Set an expiration date.
|
429 |
+
*
|
430 |
+
* @since 3.3.5
|
431 |
+
*
|
432 |
+
* @param string $product
|
433 |
+
* @param int $user_id
|
434 |
+
* @param mixed $set_date
|
435 |
+
* @param mixed $pre_value
|
436 |
+
* @param boolean $renew
|
437 |
+
* @return mixed $new_value
|
438 |
+
*/
|
439 |
+
function set_product_expiration( $product, $user_id, $set_date, $prev_value, $renew ) {
|
440 |
+
// If this is setting a specific date.
|
441 |
+
if ( $set_date ) {
|
442 |
+
$new_value = strtotime( $set_date );
|
443 |
+
} else {
|
444 |
+
// Either setting initial expiration based on set time period, or adding to the existing date (renewal/extending).
|
445 |
+
$raw_add = explode( "|", $this->products[ $product ]['expires'][0] );
|
446 |
+
$add_period = ( 1 < $raw_add[0] ) ? $raw_add[0] . " " . $raw_add[1] . "s" : $raw_add[0] . " " . $raw_add[1];
|
447 |
+
|
448 |
+
if ( $prev_value ) {
|
449 |
+
if ( isset( $this->products[ $product ]['no_gap'] ) && 1 == $this->products[ $product ]['no_gap'] ) {
|
450 |
+
// Add to the user's existing date (no gap).
|
451 |
+
$new_value = strtotime( $add_period, $prev_value );
|
452 |
+
} else {
|
453 |
+
// Add to the user either from end or now (whichever is later; i.e. allow gaps (default)).
|
454 |
+
if ( wpmem_user_has_access( $product, $user_id ) ) {
|
455 |
+
// if not expired, set from when they expire.
|
456 |
+
$new_value = strtotime( $add_period, $prev_value );
|
457 |
+
} else {
|
458 |
+
// if expired, set from today.
|
459 |
+
$new_value = strtotime( $add_period );
|
460 |
+
}
|
461 |
+
}
|
462 |
+
} else {
|
463 |
+
// User doesn't have this membershp. Go ahead and add it.
|
464 |
+
|
465 |
+
// If we are using fixed period expiration, calculate the expiration date
|
466 |
+
if ( isset( $this->products[ $product ] ) && isset( $this->products[ $product ]['fixed_period'] ) ) {
|
467 |
+
// Calculate the fixed period expiration.
|
468 |
+
$new_value = $this->calculate_fixed_period ( $product );
|
469 |
+
} else {
|
470 |
+
// Just add to the existing expiration.
|
471 |
+
$new_value = strtotime( $add_period );
|
472 |
+
}
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Filter the expiration date.
|
478 |
+
*
|
479 |
+
* @since 3.3.2
|
480 |
+
*
|
481 |
+
* @param int|boolean $new_value Unix timestamp of new expiration, true|false if not an expiry product.
|
482 |
+
* @param int|boolean $prev_value The user's current value (prior to updating).
|
483 |
+
* @param boolean $renew Is this a renewal transaction?
|
484 |
+
*/
|
485 |
+
$new_value = apply_filters( 'wpmem_user_product_set_expiration', $new_value, $prev_value, $renew );
|
486 |
+
|
487 |
+
return $new_value;
|
488 |
+
}
|
489 |
+
|
490 |
+
/**
|
491 |
+
* Calculate a fixed period expiration.
|
492 |
+
*
|
493 |
+
* @since 3.3.5
|
494 |
+
*
|
495 |
+
* @param string $product
|
496 |
+
* @return string $timestamp
|
497 |
+
*/
|
498 |
+
function calculate_fixed_period( $product ) {
|
499 |
+
// Use fixed period expiration.
|
500 |
+
$end = $this->products[ $product ]['fixed_period']['end'];
|
501 |
+
|
502 |
+
// Get the current year.
|
503 |
+
$current_year = date( 'Y' );
|
504 |
+
|
505 |
+
// Format period end date for current year.
|
506 |
+
$cur_date = DateTime::createFromFormat( 'd-m-Y', $end . '-' . $current_year ); //DateTime( $start_date );
|
507 |
+
|
508 |
+
// Where are we now?
|
509 |
+
$now = new DateTime();
|
510 |
+
|
511 |
+
// If date is past, set next period.
|
512 |
+
if ( $cur_date < $now ) {
|
513 |
+
// Date is past.
|
514 |
+
$next_year = date( 'Y', strtotime( '+1 year' ) );
|
515 |
+
$next_date = DateTime::createFromFormat( 'd-m-Y', $end . '-' . $next_year );
|
516 |
+
$new_value = $next_date->format( 'U' );
|
517 |
+
} else {
|
518 |
+
// Date is not past.
|
519 |
+
// Are we using a grace period?
|
520 |
+
if ( isset( $this->products[ $product ]['fixed_period']['grace'] ) && $this->products[ $product ]['fixed_period']['grace']['num'] > 0 ) {
|
521 |
+
// Are we in the grace period?
|
522 |
+
$grace_period = "-" . $this->products[ $product ]['fixed_period']['grace']['num'] . " " . $this->products[ $product ]['fixed_period']['grace']['per'];
|
523 |
+
$grace_date = DateTime::createFromFormat( 'U', strtotime( $grace_period, strtotime( $cur_date->format( 'd-m-Y' ) ) ) );
|
524 |
+
if ( $grace_date < $now ) {
|
525 |
+
// We are in grace period, set expiration as next year.
|
526 |
+
$next_year = date( 'Y', strtotime( '+1 year' ) );
|
527 |
+
$next_date = DateTime::createFromFormat( 'd-m-Y', $end . '-' . $next_year );
|
528 |
+
$new_value = $next_date->format( 'U' );
|
529 |
+
} else {
|
530 |
+
// Not in grace period, set the current year.
|
531 |
+
$new_value = $cur_date->format( 'U' );
|
532 |
+
}
|
533 |
+
} else {
|
534 |
+
// No grace period, and date is not past. Use current year.
|
535 |
+
$new_value = $cur_date->format( 'U' );
|
536 |
+
}
|
537 |
+
}
|
538 |
+
|
539 |
+
return $new_value;
|
540 |
+
}
|
541 |
}
|
@@ -1,289 +1,302 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* An object class for WP-Members Password Reset.
|
4 |
-
*
|
5 |
-
* @since 3.3.5
|
6 |
-
* @since 3.3.8 Rebuild processing to utilize WP native functions and user_activation_key.
|
7 |
-
*/
|
8 |
-
class WP_Members_Pwd_Reset {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Message containers.
|
12 |
-
*
|
13 |
-
* @since 3.3.5
|
14 |
-
*/
|
15 |
-
public $form_submitted_key_not_found;
|
16 |
-
public $form_load_key_not_found;
|
17 |
-
public $key_is_expired;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Meta containers
|
21 |
-
*
|
22 |
-
* @since 3.3.5
|
23 |
-
*/
|
24 |
-
public $reset_key_nonce = "_wpmem_pwd_reset";
|
25 |
-
public $form_action = 'set_password_from_key';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Initialize the class.
|
29 |
-
*
|
30 |
-
* @since 3.3.5
|
31 |
-
*/
|
32 |
-
function __construct() {
|
33 |
-
|
34 |
-
$defaults = array(
|
35 |
-
'form_submitted_key_not_found' => __( "Sorry, no password reset key was found. Please check your email and try again.", 'wp-members' ),
|
36 |
-
'form_load_key_not_found' => __( "Sorry, no password reset key was found. Please check your email and try again.", 'wp-members' ),
|
37 |
-
'key_is_expired' => __( "Sorry, the password reset key is expired.", 'wp-members' ),
|
38 |
-
);
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Filter default dialogs.
|
42 |
-
*
|
43 |
-
* @since 3.3.8
|
44 |
-
*
|
45 |
-
* @param array $defaults
|
46 |
-
*/
|
47 |
-
$defaults = apply_filters( 'wpmem_pwd_reset_default_dialogs', $defaults );
|
48 |
-
|
49 |
-
foreach ( $defaults as $key => $value ) {
|
50 |
-
$this->{$key} = $value;
|
51 |
-
}
|
52 |
-
|
53 |
-
add_filter( 'wpmem_email_filter', array( $this, 'add_reset_key_to_email' ), 10, 3 );
|
54 |
-
add_filter( 'the_content', array( $this, 'display_content' ), 100 );
|
55 |
-
add_filter( 'wpmem_login_hidden_fields', array( $this, 'add_hidden_form_field' ), 10, 2 );
|
56 |
-
add_action( 'wpmem_get_action', array( $this, 'get_wpmem_action' ) );
|
57 |
-
add_filter( 'wpmem_regchk', array( $this, 'change_regchk' ), 10, 2 );
|
58 |
-
add_filter( 'wpmem_resetpassword_form_defaults', array( $this, 'reset_password_form' ) );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Add reset key to the email.
|
63 |
-
*
|
64 |
-
* @since 3.3.5
|
65 |
-
*
|
66 |
-
* @param array $arr
|
67 |
-
* @param array $wpmem_fields
|
68 |
-
* @param array $field_data
|
69 |
-
* @return array $arr
|
70 |
-
*/
|
71 |
-
function add_reset_key_to_email( $arr, $wpmem_fields, $field_data ) {
|
72 |
-
|
73 |
-
if ( $arr['toggle'] == 'repass' ) {
|
74 |
-
|
75 |
-
$user = get_user_by( 'ID', $arr['user_id'] );
|
76 |
-
|
77 |
-
// Get the stored key.
|
78 |
-
$key = $this->get_password_reset_key( $user );
|
79 |
-
$query_args = array(
|
80 |
-
'a' => $this->form_action,
|
81 |
-
'key' => $key,
|
82 |
-
'login' => $user->user_login,
|
83 |
-
);
|
84 |
-
|
85 |
-
//
|
86 |
-
$
|
87 |
-
|
88 |
-
//
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
$arr['body'] = $arr['body']
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
*
|
105 |
-
*
|
106 |
-
* @
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
$
|
121 |
-
|
122 |
-
|
123 |
-
$
|
124 |
-
|
125 |
-
|
126 |
-
$
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
*
|
133 |
-
*
|
134 |
-
*
|
135 |
-
*
|
136 |
-
*
|
137 |
-
*
|
138 |
-
*
|
139 |
-
*
|
140 |
-
*
|
141 |
-
*
|
142 |
-
* @
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
$
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
*
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
*
|
278 |
-
*
|
279 |
-
*
|
280 |
-
*
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* An object class for WP-Members Password Reset.
|
4 |
+
*
|
5 |
+
* @since 3.3.5
|
6 |
+
* @since 3.3.8 Rebuild processing to utilize WP native functions and user_activation_key.
|
7 |
+
*/
|
8 |
+
class WP_Members_Pwd_Reset {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Message containers.
|
12 |
+
*
|
13 |
+
* @since 3.3.5
|
14 |
+
*/
|
15 |
+
public $form_submitted_key_not_found;
|
16 |
+
public $form_load_key_not_found;
|
17 |
+
public $key_is_expired;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Meta containers
|
21 |
+
*
|
22 |
+
* @since 3.3.5
|
23 |
+
*/
|
24 |
+
public $reset_key_nonce = "_wpmem_pwd_reset";
|
25 |
+
public $form_action = 'set_password_from_key';
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Initialize the class.
|
29 |
+
*
|
30 |
+
* @since 3.3.5
|
31 |
+
*/
|
32 |
+
function __construct() {
|
33 |
+
|
34 |
+
$defaults = array(
|
35 |
+
'form_submitted_key_not_found' => __( "Sorry, no password reset key was found. Please check your email and try again.", 'wp-members' ),
|
36 |
+
'form_load_key_not_found' => __( "Sorry, no password reset key was found. Please check your email and try again.", 'wp-members' ),
|
37 |
+
'key_is_expired' => __( "Sorry, the password reset key is expired.", 'wp-members' ),
|
38 |
+
);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Filter default dialogs.
|
42 |
+
*
|
43 |
+
* @since 3.3.8
|
44 |
+
*
|
45 |
+
* @param array $defaults
|
46 |
+
*/
|
47 |
+
$defaults = apply_filters( 'wpmem_pwd_reset_default_dialogs', $defaults );
|
48 |
+
|
49 |
+
foreach ( $defaults as $key => $value ) {
|
50 |
+
$this->{$key} = $value;
|
51 |
+
}
|
52 |
+
|
53 |
+
add_filter( 'wpmem_email_filter', array( $this, 'add_reset_key_to_email' ), 10, 3 );
|
54 |
+
add_filter( 'the_content', array( $this, 'display_content' ), 100 );
|
55 |
+
add_filter( 'wpmem_login_hidden_fields', array( $this, 'add_hidden_form_field' ), 10, 2 );
|
56 |
+
add_action( 'wpmem_get_action', array( $this, 'get_wpmem_action' ) );
|
57 |
+
add_filter( 'wpmem_regchk', array( $this, 'change_regchk' ), 10, 2 );
|
58 |
+
add_filter( 'wpmem_resetpassword_form_defaults', array( $this, 'reset_password_form' ) );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Add reset key to the email.
|
63 |
+
*
|
64 |
+
* @since 3.3.5
|
65 |
+
*
|
66 |
+
* @param array $arr
|
67 |
+
* @param array $wpmem_fields
|
68 |
+
* @param array $field_data
|
69 |
+
* @return array $arr
|
70 |
+
*/
|
71 |
+
function add_reset_key_to_email( $arr, $wpmem_fields, $field_data ) {
|
72 |
+
|
73 |
+
if ( $arr['toggle'] == 'repass' ) {
|
74 |
+
|
75 |
+
$user = get_user_by( 'ID', $arr['user_id'] );
|
76 |
+
|
77 |
+
// Get the stored key.
|
78 |
+
$key = $this->get_password_reset_key( $user );
|
79 |
+
$query_args = array(
|
80 |
+
'a' => $this->form_action,
|
81 |
+
'key' => $key,
|
82 |
+
'login' => $user->user_login,
|
83 |
+
);
|
84 |
+
|
85 |
+
// urlencode, primarily for user_login with a space.
|
86 |
+
$query_args = array_map( 'rawurlencode', $query_args );
|
87 |
+
|
88 |
+
// Generate reset link.
|
89 |
+
$link = add_query_arg( $query_args, trailingslashit( wpmem_profile_url() ) );
|
90 |
+
|
91 |
+
// Does email body have the [reset_link] shortcode?
|
92 |
+
if ( strpos( $arr['body'], '[reset_link]' ) ) {
|
93 |
+
$arr['body'] = str_replace( '[reset_link]', $link, $arr['body'] );
|
94 |
+
} else {
|
95 |
+
// Add text and link to the email body.
|
96 |
+
$arr['body'] = $arr['body'] . "\r\n"
|
97 |
+
. $link;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
return $arr;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Display page content to user.
|
105 |
+
*
|
106 |
+
* @since 3.3.5
|
107 |
+
*
|
108 |
+
* @param string $content
|
109 |
+
* @return string $content
|
110 |
+
*/
|
111 |
+
function display_content( $content ) {
|
112 |
+
|
113 |
+
global $wpmem;
|
114 |
+
|
115 |
+
if ( ! is_user_logged_in() && in_the_loop() && $this->form_action == wpmem_get( 'a', false, 'request' ) ) {
|
116 |
+
// Define variables
|
117 |
+
$result = '';
|
118 |
+
$user_id = false;
|
119 |
+
$msg = '';
|
120 |
+
$form = '';
|
121 |
+
|
122 |
+
// Check for key.
|
123 |
+
$key = sanitize_text_field( wpmem_get( 'key', false, 'request' ) );
|
124 |
+
$user_login = sanitize_text_field( wpmem_get( 'login', false, 'request' ) );
|
125 |
+
$pass1 = wpmem_get( 'pass1', false );
|
126 |
+
$pass2 = wpmem_get( 'pass2', false );
|
127 |
+
|
128 |
+
// Set an error container.
|
129 |
+
$errors = new WP_Error();
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Validate the key.
|
133 |
+
*
|
134 |
+
* WP_Error will be invalid_key or expired_key. Process triggers password_reset_expiration filter
|
135 |
+
* filtering DAY_IN_SECONDS default. Filter password_reset_key_expired is also triggered filtering
|
136 |
+
* the return value (which can be used to override the expired/invalid check based on user_id).
|
137 |
+
*
|
138 |
+
* WP filter/actions triggered:
|
139 |
+
* - password_reset_expiration
|
140 |
+
* - password_reset_key_expired
|
141 |
+
*
|
142 |
+
* @see https://developer.wordpress.org/reference/functions/check_password_reset_key/
|
143 |
+
* @param string Hash to validate sending user's password.
|
144 |
+
* @param string The user login.
|
145 |
+
* @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys (invalid_key|expired_key).
|
146 |
+
*/
|
147 |
+
$user = check_password_reset_key( $key, $user_login );
|
148 |
+
|
149 |
+
if ( $user->has_errors() ) {
|
150 |
+
$errors->add( 'user_not_found', $this->form_load_key_not_found );
|
151 |
+
}
|
152 |
+
|
153 |
+
// Validate
|
154 |
+
if ( 1 == wpmem_get( 'formsubmit' ) && false !== wpmem_get( 'a', false, $this->form_action ) ) {
|
155 |
+
|
156 |
+
// Verify nonce.
|
157 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpmem_pwdchange_nonce'], 'wpmem_shortform_nonce' ) ) {
|
158 |
+
$errors->add( 'reg_generic', wpmem_get_text( 'reg_generic' ) );
|
159 |
+
}
|
160 |
+
|
161 |
+
// Make sure submitted passwords match.
|
162 |
+
if ( $pass1 !== $pass2 ) {
|
163 |
+
// Legacy WP-Members error.
|
164 |
+
$result = 'pwdchangerr';
|
165 |
+
$msg = wpmem_get_display_message( 'pwdchangerr' );
|
166 |
+
// WP Error.
|
167 |
+
$errors->add( 'password_reset_mismatch', __( 'The passwords do not match.' ) );
|
168 |
+
}
|
169 |
+
|
170 |
+
/** This action is documented in wp-login.php */
|
171 |
+
// do_action( 'validate_password_reset', $errors, $user );
|
172 |
+
|
173 |
+
if ( ( ! $errors->has_errors() ) && isset( $pass1 ) && ! empty( $pass1 ) ) {
|
174 |
+
reset_password( $user, $pass1 );
|
175 |
+
$msg = wpmem_get_display_message( 'pwdchangesuccess' ) . wpmem_login_form( 'pwdreset' );
|
176 |
+
$result = 'pwdchangesuccess';
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
if ( $result != 'pwdchangesuccess' ) {
|
181 |
+
|
182 |
+
if ( 'invalid_key' == $user->get_error_code() ) {
|
183 |
+
// If somehow the form was submitted but the key not found.
|
184 |
+
$pwd_reset_link = wpmem_profile_url( 'pwdreset' );
|
185 |
+
$msg = wpmem_get_display_message( 'invalid_key', $this->form_submitted_key_not_found . '<br /><a href="' . $pwd_reset_link . '">Request a new reset key.</a>' );
|
186 |
+
$form = '';
|
187 |
+
} else {
|
188 |
+
$form = wpmem_change_password_form();
|
189 |
+
}
|
190 |
+
|
191 |
+
}
|
192 |
+
|
193 |
+
$content = $msg . $form;
|
194 |
+
}
|
195 |
+
|
196 |
+
return $content;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Add hidden form field for form action.
|
201 |
+
*
|
202 |
+
* @since 3.3.5
|
203 |
+
*
|
204 |
+
* @param string $hidden_fields
|
205 |
+
* @return string $hidden_fields
|
206 |
+
*/
|
207 |
+
function add_hidden_form_field( $hidden_fields, $action ) {
|
208 |
+
if ( $this->form_action == wpmem_get( 'a', false, 'request' ) ) {
|
209 |
+
$hidden_fields = str_replace( 'pwdchange', $this->form_action, $hidden_fields );
|
210 |
+
$hidden_fields.= wpmem_form_field( array( 'name' => 'key', 'type' => 'hidden', 'value' => sanitize_text_field( wpmem_get( 'key', null, 'request' ) ) ) );
|
211 |
+
$hidden_fields.= wpmem_form_field( array( 'name' => 'login', 'type' => 'hidden', 'value' => sanitize_user( wpmem_get( 'login', null, 'request' ) ) ) );
|
212 |
+
}
|
213 |
+
return $hidden_fields;
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Get the wpmem action variable.
|
218 |
+
*
|
219 |
+
* @since 3.3.5
|
220 |
+
*/
|
221 |
+
function get_wpmem_action() {
|
222 |
+
global $wpmem;
|
223 |
+
if ( 'pwdreset' == $wpmem->action && isset( $_POST['formsubmit'] ) ) {
|
224 |
+
|
225 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpmem_pwdreset_nonce'], 'wpmem_shortform_nonce' ) ) {
|
226 |
+
return "reg_generic";
|
227 |
+
}
|
228 |
+
|
229 |
+
$user_to_check = wpmem_get( 'user', false );
|
230 |
+
$user_to_check = ( strpos( $user_to_check, '@' ) ) ? sanitize_email( $user_to_check ) : sanitize_user( $user_to_check );
|
231 |
+
|
232 |
+
if ( username_exists( $user_to_check ) ) {
|
233 |
+
$user = get_user_by( 'login', $user_to_check );
|
234 |
+
if ( ( 1 == $wpmem->mod_reg ) && ( 1 != get_user_meta( $user->ID, 'active', true ) ) ) {
|
235 |
+
$user = false;
|
236 |
+
}
|
237 |
+
} elseif ( email_exists( $user_to_check ) ) {
|
238 |
+
$user = get_user_by( 'email', $user_to_check );
|
239 |
+
} else {
|
240 |
+
$user = false;
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( false === $user ) {
|
244 |
+
return "pwdreseterr";
|
245 |
+
}
|
246 |
+
|
247 |
+
$new_pass = '';
|
248 |
+
wpmem_email_to_user( $user->ID, $new_pass, 3 );
|
249 |
+
/** This action is documented in /includes/class-wp-members-user.php */
|
250 |
+
do_action( 'wpmem_pwd_reset', $user->ID, $new_pass );
|
251 |
+
$wpmem->action = 'pwdreset_link';
|
252 |
+
$wpmem->regchk = 'pwdresetsuccess';
|
253 |
+
return "pwdresetsuccess";
|
254 |
+
}
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Changes the wpmem_regchk value.
|
260 |
+
*
|
261 |
+
* @since 3.3.5
|
262 |
+
*
|
263 |
+
* @param string $regchk
|
264 |
+
*/
|
265 |
+
function change_regchk( $regchk, $action ) {
|
266 |
+
global $wpmem;
|
267 |
+
if ( 'pwdreset_link' == $action && 'pwdresetsuccess' == $wpmem->regchk ) {
|
268 |
+
global $wpmem;
|
269 |
+
$wpmem->action = 'pwdreset';
|
270 |
+
return 'pwdresetsuccess';
|
271 |
+
}
|
272 |
+
return $regchk;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Filter the reset password form.
|
277 |
+
*
|
278 |
+
* @since 3.3.5
|
279 |
+
*
|
280 |
+
* @param array $args
|
281 |
+
*/
|
282 |
+
function reset_password_form( $args ) {
|
283 |
+
global $wpmem;
|
284 |
+
$args['inputs'][0]['name'] = wpmem_get_text( 'login_username' );
|
285 |
+
unset( $args['inputs'][1] );
|
286 |
+
return $args;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Sets and gets the password reset key.
|
291 |
+
*
|
292 |
+
* This function is an alias for the WP function get_password_reset_key().
|
293 |
+
*
|
294 |
+
* @since 3.3.8
|
295 |
+
*
|
296 |
+
* @param object $user
|
297 |
+
* @return string The reset key.
|
298 |
+
*/
|
299 |
+
private function get_password_reset_key( $user ) {
|
300 |
+
return get_password_reset_key( $user );
|
301 |
+
}
|
302 |
}
|
@@ -7,13 +7,13 @@
|
|
7 |
*
|
8 |
* This file is part of the WP-Members plugin by Chad Butler
|
9 |
* You can find out more about this plugin at https://rocketgeek.com
|
10 |
-
* Copyright (c) 2006-
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP_Members_Shortcodes
|
15 |
* @author Chad Butler
|
16 |
-
* @copyright 2006-
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
@@ -57,7 +57,7 @@ class WP_Members_Shortcodes {
|
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
*
|
61 |
*
|
62 |
* @since 3.0.0
|
63 |
* @since 3.1.3 Added forgot_username shortcode.
|
@@ -75,138 +75,124 @@ class WP_Members_Shortcodes {
|
|
75 |
* Possible shortcode attributes (some vary by form).
|
76 |
*
|
77 |
* @type string $id An ID for the form.
|
78 |
-
* @type string $login
|
79 |
-
* @type string $password
|
80 |
-
* @type string $user_edit
|
81 |
-
* @type string $forgot_username
|
82 |
-
* @type string $register
|
83 |
-
* @type string $
|
84 |
-
* @type string $
|
85 |
-
* @type string $
|
86 |
-
* @type string $
|
|
|
87 |
* @type string $product Register for specific product (if products are enabled).
|
88 |
* }
|
89 |
-
* @param string $content
|
90 |
-
* @param string $tag
|
91 |
-
* @return string
|
92 |
*/
|
93 |
-
function forms( $atts, $content
|
94 |
|
95 |
global $wpmem, $wpmem_themsg;
|
96 |
|
97 |
// Defaults.
|
98 |
-
$
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
$
|
|
|
102 |
|
103 |
-
|
104 |
-
* The [wpmem_form] shortcode requires additional tags (login, register, etc) that
|
105 |
-
* will be in the $atts array. If $atts is not an array, no additional tags were
|
106 |
-
* given, so there is nothing to render.
|
107 |
-
*/
|
108 |
-
if ( is_array( $atts ) ) {
|
109 |
|
110 |
-
|
111 |
-
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
case in_array( 'login', $atts ):
|
118 |
-
if ( is_user_logged_in() && '1' != $customizer ) {
|
119 |
-
/*
|
120 |
-
* If the user is logged in, return any nested content (if any)
|
121 |
-
* or the default bullet links if no nested content.
|
122 |
-
*/
|
123 |
-
$content = ( $content ) ? $content : wpmem_inc_memberlinks( 'login' );
|
124 |
-
} else {
|
125 |
-
/*
|
126 |
-
* If the user is not logged in, return an error message if a login
|
127 |
-
* error state exists, or return the login form.
|
128 |
-
*/
|
129 |
-
$content = ( $wpmem->regchk == 'loginfailed' || ( is_customize_preview() && get_theme_mod( 'wpmem_show_form_message_dialog', false ) ) ) ? wpmem_inc_loginfailed() : wpmem_inc_login( 'login', $redirect_to );
|
130 |
-
}
|
131 |
-
break;
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
-
|
141 |
-
if (
|
142 |
-
|
143 |
-
|
144 |
-
* or the default bullet links if no nested content.
|
145 |
-
*/
|
146 |
-
$content = ( $content ) ? $content : wpmem_inc_memberlinks( 'register' );
|
147 |
-
} elseif ( is_user_logged_in() && is_customize_preview() && get_theme_mod( 'wpmem_show_form_message_dialog', false ) ) {
|
148 |
-
$wpmem_themsg = __( "This is a generic message to display the form message dialog in the Customizer.", 'wp-members' );
|
149 |
-
$content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
|
150 |
-
$content .= wpmem_register_form( $reg_form_args );
|
151 |
-
} else {
|
152 |
-
if ( $wpmem->regchk == 'loginfailed' ) {
|
153 |
-
$content = wpmem_inc_loginfailed() . wpmem_inc_login( 'login', $redirect_to );
|
154 |
-
break;
|
155 |
-
}
|
156 |
-
// @todo Can this be moved into another function? Should $wpmem get an error message handler?
|
157 |
-
if ( $wpmem->regchk == 'captcha' ) {
|
158 |
-
global $wpmem_captcha_err;
|
159 |
-
$wpmem_themsg = __( 'There was an error with the CAPTCHA form.' ) . '<br /><br />' . $wpmem_captcha_err;
|
160 |
-
}
|
161 |
-
$content = ( $wpmem_themsg || $wpmem->regchk == 'success' ) ? wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg ) : '';
|
162 |
-
$content .= ( $wpmem->regchk == 'success' ) ? wpmem_inc_login( 'login', $redirect_to ) : wpmem_register_form( $reg_form_args );
|
163 |
}
|
164 |
-
|
|
|
|
|
|
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
case in_array( 'customizer_login', $atts ):
|
179 |
-
$content = wpmem_inc_login( 'login', $redirect_to );
|
180 |
-
break;
|
181 |
-
|
182 |
-
case in_array( 'customizer_register', $atts ):
|
183 |
-
$content = wpmem_register_form( 'new', $redirect_to );
|
184 |
-
break;
|
185 |
|
186 |
-
|
|
|
|
|
|
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
202 |
}
|
203 |
-
|
|
|
204 |
}
|
|
|
205 |
return do_shortcode( $content );
|
206 |
}
|
207 |
|
208 |
/**
|
209 |
-
*
|
210 |
*
|
211 |
* There are several attributes that can be used with the shortcode:
|
212 |
* in|out, sub for subscription only info, id, and role. IDs and roles
|
@@ -221,22 +207,23 @@ class WP_Members_Shortcodes {
|
|
221 |
* @global object $wpmem The WP_Members object.
|
222 |
*
|
223 |
* @param array $atts {
|
224 |
-
*
|
225 |
*
|
226 |
-
* @type string $status
|
227 |
-
* @type int $id
|
228 |
-
* @type string $role
|
229 |
-
* @type string $sub
|
230 |
-
* @type string $meta_key
|
231 |
-
* @type string $meta_value
|
232 |
-
* @
|
233 |
-
* @type string $membership
|
|
|
234 |
* }
|
235 |
-
* @param string $content
|
236 |
-
* @param string $tag
|
237 |
-
* @return string
|
238 |
*/
|
239 |
-
function logged_in( $atts, $content
|
240 |
|
241 |
global $wpmem;
|
242 |
|
@@ -320,7 +307,7 @@ class WP_Members_Shortcodes {
|
|
320 |
$do_return = true;
|
321 |
$settings = array(
|
322 |
'wrapper_before' => '<div class="product_restricted_msg">',
|
323 |
-
'msg' => sprintf(
|
324 |
'wrapper_after' => '</div>',
|
325 |
);
|
326 |
/**
|
@@ -350,22 +337,22 @@ class WP_Members_Shortcodes {
|
|
350 |
}
|
351 |
|
352 |
/**
|
353 |
-
*
|
354 |
*
|
355 |
* @since 3.0.0
|
356 |
* @since 3.2.0 Moved to WP_Members_Shortcodes::logged_out().
|
357 |
*
|
358 |
-
* @param array $atts
|
359 |
-
* @param string $content
|
360 |
-
* @param string $tag
|
361 |
-
* @return string $content
|
362 |
*/
|
363 |
-
function logged_out( $atts, $content
|
364 |
return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : '';
|
365 |
}
|
366 |
|
367 |
/**
|
368 |
-
*
|
369 |
*
|
370 |
* User count displays a total user count or a count of users by specific
|
371 |
* role (role="some_role"). It also accepts attributes for counting users
|
@@ -380,15 +367,16 @@ class WP_Members_Shortcodes {
|
|
380 |
* @param array $atts {
|
381 |
* The shortcode attributes.
|
382 |
*
|
383 |
-
* @type string $key
|
384 |
-
* @type string $value
|
385 |
-
* @type string $role
|
386 |
-
* @type string $label
|
387 |
* }
|
388 |
-
|
389 |
-
* @
|
|
|
390 |
*/
|
391 |
-
function user_count( $atts, $content
|
392 |
if ( isset( $atts['key'] ) && isset( $atts['value'] ) ) {
|
393 |
// If by meta key.
|
394 |
global $wpdb;
|
@@ -439,11 +427,7 @@ class WP_Members_Shortcodes {
|
|
439 |
|
440 |
if ( $wpmem->regchk == "captcha" ) {
|
441 |
global $wpmem_captcha_err;
|
442 |
-
$wpmem_themsg =
|
443 |
-
}
|
444 |
-
|
445 |
-
if ( $wpmem->regchk == "loginfailed" ) {
|
446 |
-
return wpmem_inc_loginfailed();
|
447 |
}
|
448 |
|
449 |
if ( is_user_logged_in() ) {
|
@@ -457,18 +441,18 @@ class WP_Members_Shortcodes {
|
|
457 |
case "update":
|
458 |
// Determine if there are any errors/empty fields.
|
459 |
if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) {
|
460 |
-
$content = $content .
|
461 |
$content = $content . wpmem_register_form( 'edit' );
|
462 |
} else {
|
463 |
//Case "editsuccess".
|
464 |
-
$content = $content .
|
465 |
-
$content = $content .
|
466 |
}
|
467 |
break;
|
468 |
|
469 |
case "pwdchange":
|
470 |
$content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
|
471 |
-
$content = ( 'pwdchangesuccess' == $wpmem->regchk ) ? $content .
|
472 |
break;
|
473 |
|
474 |
case "renew":
|
@@ -480,38 +464,28 @@ class WP_Members_Shortcodes {
|
|
480 |
break;
|
481 |
|
482 |
default:
|
483 |
-
$content =
|
484 |
break;
|
485 |
}
|
486 |
|
487 |
} else {
|
488 |
|
489 |
-
if ( $wpmem->action
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
$content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
|
495 |
-
$content = $content . wpmem_inc_login();
|
496 |
-
break;
|
497 |
-
|
498 |
-
default:
|
499 |
-
$content = wpmem_inc_regmessage( $wpmem->regchk, $wpmem_themsg );
|
500 |
-
$content = $content . wpmem_register_form();
|
501 |
-
break;
|
502 |
-
}
|
503 |
-
|
504 |
} elseif ( $wpmem->action == 'pwdreset' ) {
|
505 |
|
506 |
-
$content =
|
507 |
|
508 |
} elseif( $wpmem->action == 'getusername' ) {
|
509 |
|
510 |
-
$content =
|
511 |
|
512 |
} else {
|
513 |
|
514 |
-
$content = $content .
|
515 |
$content = ( ! $hide_register ) ? $content . wpmem_register_form() : $content;
|
516 |
}
|
517 |
}
|
@@ -587,7 +561,7 @@ class WP_Members_Shortcodes {
|
|
587 |
* @param string $tag The shortcode tag (wpmem_form).
|
588 |
* @return string $content Content to return.
|
589 |
*/
|
590 |
-
function fields( $atts, $content
|
591 |
|
592 |
// What field?
|
593 |
$field = ( isset( $atts[0] ) ) ? $atts[0] : $atts['field'];
|
@@ -605,18 +579,19 @@ class WP_Members_Shortcodes {
|
|
605 |
|
606 |
global $wpmem;
|
607 |
$fields = wpmem_fields();
|
608 |
-
|
609 |
-
|
610 |
$user_info_field = ( isset( $field ) && is_object( $user_info ) ) ? $user_info->{$field} : '';
|
611 |
$result = false;
|
612 |
-
|
613 |
// Handle each field type.
|
614 |
switch ( $field_type ) {
|
615 |
|
616 |
// Select and radio groups have single selections.
|
617 |
case 'select':
|
618 |
case 'radio':
|
619 |
-
|
|
|
620 |
break;
|
621 |
|
622 |
// Multiple select and multiple checkbox have multiple selections.
|
@@ -629,7 +604,7 @@ class WP_Members_Shortcodes {
|
|
629 |
$result = ''; $x = 1;
|
630 |
foreach ( $saved_vals as $value ) {
|
631 |
$result.= ( $x > 1 ) ? ', ' : ''; $x++;
|
632 |
-
$result.=
|
633 |
}
|
634 |
}
|
635 |
break;
|
@@ -743,7 +718,7 @@ class WP_Members_Shortcodes {
|
|
743 |
* @retrun string $content
|
744 |
*/
|
745 |
function tos( $atts, $content, $tag ) {
|
746 |
-
$url = ( strpos( $atts['url'], 'http' ) ) ? $atts['url'] : home_url( $atts['url'] );
|
747 |
return esc_url( $url );
|
748 |
}
|
749 |
|
@@ -841,6 +816,344 @@ class WP_Members_Shortcodes {
|
|
841 |
$content = wpmem_form_nonce( $nonce, false );
|
842 |
return do_shortcode( $content );
|
843 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
844 |
}
|
845 |
|
846 |
// End of file.
|
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-2021 Chad Butler
|
11 |
* WP-Members(tm) is a trademark of butlerblog.com
|
12 |
*
|
13 |
* @package WP-Members
|
14 |
* @subpackage WP_Members_Shortcodes
|
15 |
* @author Chad Butler
|
16 |
+
* @copyright 2006-2021
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
+
* Renders forms called by [wpmem_form] shortcode.
|
61 |
*
|
62 |
* @since 3.0.0
|
63 |
* @since 3.1.3 Added forgot_username shortcode.
|
75 |
* Possible shortcode attributes (some vary by form).
|
76 |
*
|
77 |
* @type string $id An ID for the form.
|
78 |
+
* @type string $login Renders a login form.
|
79 |
+
* @type string $password Renders a reset/change password form (login state dependent).
|
80 |
+
* @type string $user_edit Renders a user profile edit form.
|
81 |
+
* @type string $forgot_username Renders a forgot username form.
|
82 |
+
* @type string $register Renders a register form.
|
83 |
+
* @type string $wp_login Renders the WP login form.
|
84 |
+
* @type string $redirect_to URL to redirect to on form submit (used for login and register forms).
|
85 |
+
* @type string $texturize Add/fix texturization for the from HTML (usually not necessary).
|
86 |
+
* @type string $exclude_fields Fields to exclude as comma separated meta keys (register/user_edit forms only).
|
87 |
+
* @type string $include_fields Fields to include as comma separated meta keys (register/user_edit forms only).
|
88 |
* @type string $product Register for specific product (if products are enabled).
|
89 |
* }
|
90 |
+
* @param string $content Nested content displayed if the shortcode is in the logged in state (optional).
|
91 |
+
* @param string $tag The shortcode's tag (wpmem_form).
|
92 |
+
* @return string The form HTML (or nested content, if used and the user is logged in).
|
93 |
*/
|
94 |
+
function forms( $atts, $content, $tag ) {
|
95 |
|
96 |
global $wpmem, $wpmem_themsg;
|
97 |
|
98 |
// Defaults.
|
99 |
+
$defaults = array(
|
100 |
+
'form' => '',
|
101 |
+
'redirect_to' => null,
|
102 |
+
'texturize' => false,
|
103 |
+
'form_id' => false,
|
104 |
+
);
|
105 |
+
$atts = wp_parse_args( $atts, $defaults );
|
106 |
|
107 |
+
$atts['form'] = ( isset( $atts[0] ) ) ? $atts[0] : 'login';
|
108 |
+
unset( $atts[0] );
|
109 |
|
110 |
+
$customizer = ( is_customize_preview() ) ? get_theme_mod( 'wpmem_show_logged_out_state', false ) : false;
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
+
// If $atts is an array, get the tag from the array so we know what form to render.
|
113 |
+
switch ( $atts['form'] ) {
|
114 |
|
115 |
+
case 'wp_login':
|
116 |
+
$content = wpmem_wp_login_form( $atts );
|
117 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
+
case 'register':
|
120 |
+
|
121 |
+
// Set up register form args.
|
122 |
+
$reg_form_args = array( 'tag' => 'new' );
|
123 |
+
if ( isset( $redirect_to ) ) {
|
124 |
+
$reg_form_args['redirect_to'] = $redirect_to;
|
125 |
+
}
|
126 |
+
|
127 |
+
if ( is_user_logged_in() && '1' != $customizer ) {
|
128 |
+
/*
|
129 |
+
* If the user is logged in, return any nested content (if any)
|
130 |
+
* or the default bullet links if no nested content.
|
131 |
+
*/
|
132 |
+
$content = ( $content ) ? $content : $this->render_links( 'register' );
|
133 |
+
} elseif ( is_user_logged_in() && is_customize_preview() && get_theme_mod( 'wpmem_show_form_message_dialog', false ) ) {
|
134 |
+
$wpmem_themsg = __( "This is a generic message to display the form message dialog in the Customizer.", 'wp-members' );
|
135 |
+
$content = wpmem_get_display_message( $wpmem->regchk, $wpmem_themsg );
|
136 |
+
$content .= wpmem_register_form( $reg_form_args );
|
137 |
+
} else {
|
138 |
+
if ( $wpmem->regchk == 'loginfailed' ) {
|
139 |
+
$content = $wpmem->dialogs->login_failed() . wpmem_login_form();
|
140 |
+
break;
|
141 |
}
|
142 |
+
// @todo Can this be moved into another function? Should $wpmem get an error message handler?
|
143 |
+
if ( $wpmem->regchk == 'captcha' ) {
|
144 |
+
global $wpmem_captcha_err;
|
145 |
+
$wpmem_themsg = wpmem_get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
+
$content = ( $wpmem_themsg || $wpmem->regchk == 'success' ) ? wpmem_get_display_message( $wpmem->regchk, $wpmem_themsg ) : '';
|
148 |
+
$content .= ( $wpmem->regchk == 'success' ) ? wpmem_login_form() : wpmem_register_form( $reg_form_args );
|
149 |
+
}
|
150 |
+
break;
|
151 |
|
152 |
+
case 'password':
|
153 |
+
$content = $this->render_pwd_reset( $wpmem->regchk, $content );
|
154 |
+
break;
|
155 |
|
156 |
+
case 'user_edit':
|
157 |
+
$content = $this->render_user_edit( $wpmem->regchk, $content, $atts );
|
158 |
+
break;
|
159 |
|
160 |
+
case 'forgot_username':
|
161 |
+
$content = $this->render_forgot_username( $wpmem->regchk, $content );
|
162 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
+
// @todo Review - is this actually ever triggered?
|
165 |
+
case 'customizer_login':
|
166 |
+
$content = wpmem_login_form();
|
167 |
+
break;
|
168 |
|
169 |
+
// @todo Review - is this actually ever triggered?
|
170 |
+
case 'customizer_register':
|
171 |
+
$content = wpmem_register_form( 'new' );
|
172 |
+
break;
|
173 |
+
|
174 |
+
case 'login':
|
175 |
+
default:
|
176 |
+
if ( is_user_logged_in() && '1' != $customizer ) {
|
177 |
+
// If the user is logged in, return any nested content (if any) or the default bullet links if no nested content.
|
178 |
+
$content = ( $content ) ? $content : $this->render_links( 'login' );
|
179 |
+
} else {
|
180 |
+
$content = '';
|
181 |
+
if ( $wpmem->regchk == 'loginfailed' || ( is_customize_preview() && get_theme_mod( 'wpmem_show_form_message_dialog', false ) ) ) {
|
182 |
+
$content = wpmem_get_display_message( 'loginfailed' );
|
183 |
+
}
|
184 |
+
$form_id = ( $atts['form_id'] ) ? $atts['form_id'] : 'wpmem_login_form';
|
185 |
+
$content .= wpmem_login_form( array( 'redirect_to'=>$atts['redirect_to'], 'form_id'=>$form_id ) );
|
186 |
}
|
187 |
+
break;
|
188 |
+
|
189 |
}
|
190 |
+
|
191 |
return do_shortcode( $content );
|
192 |
}
|
193 |
|
194 |
/**
|
195 |
+
* Restricts content to logged in users using the shortcode [wpmem_logged_in].
|
196 |
*
|
197 |
* There are several attributes that can be used with the shortcode:
|
198 |
* in|out, sub for subscription only info, id, and role. IDs and roles
|
207 |
* @global object $wpmem The WP_Members object.
|
208 |
*
|
209 |
* @param array $atts {
|
210 |
+
* Attributes of the wpmem_logged_in shortcode.
|
211 |
*
|
212 |
+
* @type string $status User status to check (in|out) (optional).
|
213 |
+
* @type int $id The user's ID. Restricts to a specified user by ID (optional).
|
214 |
+
* @type string $role The user's role. Restrictes to a specific role (optional).
|
215 |
+
* @type string $sub If the user is a current subscriber (for use with the PayPal extension) (optional).
|
216 |
+
* @type string $meta_key If the user has a specified meta key (use with meta_value) (optional).
|
217 |
+
* @type string $meta_value If the user has a specific meta key value (use with meta_key) (optional).
|
218 |
+
* @tryp string $compare Can specify a comparison operator when using meta_key/meta_value (optional).
|
219 |
+
* @type string $product If the user has a specific product/membership (optional).
|
220 |
+
* @type string $membership If the user has a specific product/membership (optional).
|
221 |
* }
|
222 |
+
* @param string $content Shortcode content.
|
223 |
+
* @param string $tag The shortcode's tag (wpmem_logged_in).
|
224 |
+
* @return string|void The restricted content to display if the user meets the criteria.
|
225 |
*/
|
226 |
+
function logged_in( $atts, $content, $tag ) {
|
227 |
|
228 |
global $wpmem;
|
229 |
|
307 |
$do_return = true;
|
308 |
$settings = array(
|
309 |
'wrapper_before' => '<div class="product_restricted_msg">',
|
310 |
+
'msg' => sprintf( wpmem_get_text( 'product_restricted' ), $wpmem->membership->products[ $membership ]['title'] ),
|
311 |
'wrapper_after' => '</div>',
|
312 |
);
|
313 |
/**
|
337 |
}
|
338 |
|
339 |
/**
|
340 |
+
* Renders the [wpmem_logged_out] shortcode.
|
341 |
*
|
342 |
* @since 3.0.0
|
343 |
* @since 3.2.0 Moved to WP_Members_Shortcodes::logged_out().
|
344 |
*
|
345 |
+
* @param array $atts There are no attributes for this shortcode.
|
346 |
+
* @param string $content Conent to display if user is logged out.
|
347 |
+
* @param string $tag The shortcode tab (wpmem_logged_out).
|
348 |
+
* @return string $content The content, if the user is logged out, otherwise an empty string.
|
349 |
*/
|
350 |
+
function logged_out( $atts, $content, $tag ) {
|
351 |
return ( ! is_user_logged_in() ) ? do_shortcode( $content ) : '';
|
352 |
}
|
353 |
|
354 |
/**
|
355 |
+
* Displays the user count shortcode [wpmem_show_count].
|
356 |
*
|
357 |
* User count displays a total user count or a count of users by specific
|
358 |
* role (role="some_role"). It also accepts attributes for counting users
|
367 |
* @param array $atts {
|
368 |
* The shortcode attributes.
|
369 |
*
|
370 |
+
* @type string $key The user meta key, if displaying count by meta key.
|
371 |
+
* @type string $value The user meta value, if displaying count by meta key.
|
372 |
+
* @type string $role The user role, if displaying count by role.
|
373 |
+
* @type string $label Label to display with the count (optional).
|
374 |
* }
|
375 |
+
* @param string $content Does not accept nested content.
|
376 |
+
* @param string $tag The shortcode's tag (wpmem_show_count).
|
377 |
+
* @return string $content The user count.
|
378 |
*/
|
379 |
+
function user_count( $atts, $content, $tag ) {
|
380 |
if ( isset( $atts['key'] ) && isset( $atts['value'] ) ) {
|
381 |
// If by meta key.
|
382 |
global $wpdb;
|
427 |
|
428 |
if ( $wpmem->regchk == "captcha" ) {
|
429 |
global $wpmem_captcha_err;
|
430 |
+
$wpmem_themsg = wpmem_get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
|
|
|
|
|
|
|
|
|
431 |
}
|
432 |
|
433 |
if ( is_user_logged_in() ) {
|
441 |
case "update":
|
442 |
// Determine if there are any errors/empty fields.
|
443 |
if ( $wpmem->regchk == "updaterr" || $wpmem->regchk == "email" ) {
|
444 |
+
$content = $content . wpmem_get_display_message( $wpmem->regchk, $wpmem_themsg );
|
445 |
$content = $content . wpmem_register_form( 'edit' );
|
446 |
} else {
|
447 |
//Case "editsuccess".
|
448 |
+
$content = $content . wpmem_get_display_message( $wpmem->regchk, $wpmem_themsg );
|
449 |
+
$content = $content . $this->render_links();
|
450 |
}
|
451 |
break;
|
452 |
|
453 |
case "pwdchange":
|
454 |
$content = wpmem_page_pwd_reset( $wpmem->regchk, $content );
|
455 |
+
$content = ( 'pwdchangesuccess' == $wpmem->regchk ) ? $content . $this->render_links() : $content;
|
456 |
break;
|
457 |
|
458 |
case "renew":
|
464 |
break;
|
465 |
|
466 |
default:
|
467 |
+
$content = $this->render_links();
|
468 |
break;
|
469 |
}
|
470 |
|
471 |
} else {
|
472 |
|
473 |
+
if ( ( 'login' == $wpmem->action ) || ( 'register' == $wpmem->action && ! $hide_register ) ) {
|
474 |
+
|
475 |
+
$content = wpmem_get_display_message( $wpmem->regchk, $wpmem_themsg );
|
476 |
+
$content.= ( 'loginfailed' == $wpmem->regchk || 'success' == $wpmem->regchk ) ? wpmem_login_form() : wpmem_register_form();
|
477 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
} elseif ( $wpmem->action == 'pwdreset' ) {
|
479 |
|
480 |
+
$content = $this->render_pwd_reset( $wpmem->regchk, $content );
|
481 |
|
482 |
} elseif( $wpmem->action == 'getusername' ) {
|
483 |
|
484 |
+
$content = $this->render_forgot_username( $wpmem->regchk, $content );
|
485 |
|
486 |
} else {
|
487 |
|
488 |
+
$content = $content . wpmem_login_form( 'profile' );
|
489 |
$content = ( ! $hide_register ) ? $content . wpmem_register_form() : $content;
|
490 |
}
|
491 |
}
|
561 |
* @param string $tag The shortcode tag (wpmem_form).
|
562 |
* @return string $content Content to return.
|
563 |
*/
|
564 |
+
function fields( $atts, $content, $tag ) {
|
565 |
|
566 |
// What field?
|
567 |
$field = ( isset( $atts[0] ) ) ? $atts[0] : $atts['field'];
|
579 |
|
580 |
global $wpmem;
|
581 |
$fields = wpmem_fields();
|
582 |
+
|
583 |
+
$field_type = ( 'user_login' == $field ) ? 'text' : $fields[ $field ]['type'];
|
584 |
$user_info_field = ( isset( $field ) && is_object( $user_info ) ) ? $user_info->{$field} : '';
|
585 |
$result = false;
|
586 |
+
|
587 |
// Handle each field type.
|
588 |
switch ( $field_type ) {
|
589 |
|
590 |
// Select and radio groups have single selections.
|
591 |
case 'select':
|
592 |
case 'radio':
|
593 |
+
case 'membership':
|
594 |
+
$result = ( isset( $atts['display'] ) && 'raw' == $atts['display'] ) ? $user_info_field : wpmem_select_field_display( $field, $user_info_field );
|
595 |
break;
|
596 |
|
597 |
// Multiple select and multiple checkbox have multiple selections.
|
604 |
$result = ''; $x = 1;
|
605 |
foreach ( $saved_vals as $value ) {
|
606 |
$result.= ( $x > 1 ) ? ', ' : ''; $x++;
|
607 |
+
$result.= wpmem_select_field_display( $field, $value );;
|
608 |
}
|
609 |
}
|
610 |
break;
|
718 |
* @retrun string $content
|
719 |
*/
|
720 |
function tos( $atts, $content, $tag ) {
|
721 |
+
$url = ( strpos( $atts['url'], 'http://' ) || strpos( $atts['url'], 'https://' ) ) ? $atts['url'] : home_url( $atts['url'] );
|
722 |
return esc_url( $url );
|
723 |
}
|
724 |
|
816 |
$content = wpmem_form_nonce( $nonce, false );
|
817 |
return do_shortcode( $content );
|
818 |
}
|
819 |
+
|
820 |
+
/**
|
821 |
+
* Password reset forms.
|
822 |
+
*
|
823 |
+
* This function creates both password reset and forgotten
|
824 |
+
* password forms for page=password shortcode.
|
825 |
+
*
|
826 |
+
* @since 2.7.6
|
827 |
+
* @since 3.2.6 Added nonce validation.
|
828 |
+
* @since 3.4.0 Moved to shortcodes as private function, renamed from wpmem_page_pwd_reset().
|
829 |
+
*
|
830 |
+
* @global object $wpmem
|
831 |
+
* @param string $wpmem_regchk
|
832 |
+
* @param string $content
|
833 |
+
* @return string $content
|
834 |
+
*/
|
835 |
+
function render_pwd_reset( $wpmem_regchk, $content ) {
|
836 |
+
|
837 |
+
global $wpmem;
|
838 |
+
|
839 |
+
if ( is_user_logged_in() ) {
|
840 |
+
|
841 |
+
switch ( $wpmem_regchk ) {
|
842 |
+
|
843 |
+
case "pwdchangesuccess":
|
844 |
+
$content = $content . wpmem_get_display_message( $wpmem_regchk );
|
845 |
+
break;
|
846 |
+
|
847 |
+
default:
|
848 |
+
if ( isset( $wpmem_regchk ) && '' != $wpmem_regchk ) {
|
849 |
+
$content .= wpmem_get_display_message( $wpmem_regchk, wpmem_get_text( $wpmem_regchk ) );
|
850 |
+
}
|
851 |
+
$content = $content . wpmem_change_password_form();
|
852 |
+
break;
|
853 |
+
}
|
854 |
+
|
855 |
+
} else {
|
856 |
+
|
857 |
+
// If the password shortcode page is set as User Profile page.
|
858 |
+
if ( 'getusername' == $wpmem->action ) {
|
859 |
+
|
860 |
+
return wpmem_page_forgot_username( $wpmem_regchk, $content );
|
861 |
+
|
862 |
+
} else {
|
863 |
+
|
864 |
+
switch( $wpmem_regchk ) {
|
865 |
+
|
866 |
+
case "pwdresetsuccess":
|
867 |
+
$content = $content . wpmem_get_display_message( $wpmem_regchk );
|
868 |
+
$wpmem_regchk = ''; // Clear regchk.
|
869 |
+
break;
|
870 |
+
|
871 |
+
default:
|
872 |
+
if ( isset( $wpmem_regchk ) && '' != $wpmem_regchk ) {
|
873 |
+
$content = wpmem_get_display_message( $wpmem_regchk, wpmem_get_text( $wpmem_regchk ) );
|
874 |
+
}
|
875 |
+
$content = $content . wpmem_reset_password_form();
|
876 |
+
break;
|
877 |
+
}
|
878 |
+
|
879 |
+
}
|
880 |
+
|
881 |
+
}
|
882 |
+
|
883 |
+
return $content;
|
884 |
+
|
885 |
+
}
|
886 |
+
|
887 |
+
/**
|
888 |
+
* Creates a user edit page.
|
889 |
+
*
|
890 |
+
* @since 2.7.6
|
891 |
+
* @since 3.3.9 Added $atts
|
892 |
+
* @since 3.4.0 Moved to shortcodes as private function, renamed from wpmem_page_user_edit
|
893 |
+
*
|
894 |
+
* @global object $wpmem
|
895 |
+
* @global string $wpmem_a
|
896 |
+
* @global string $wpmem_themsg
|
897 |
+
* @param string $wpmem_regchk
|
898 |
+
* @param string $content
|
899 |
+
* @return string $content
|
900 |
+
*/
|
901 |
+
function render_user_edit( $wpmem_regchk, $content, $atts = false ) {
|
902 |
+
|
903 |
+
global $wpmem, $wpmem_a, $wpmem_themsg;
|
904 |
+
/**
|
905 |
+
* Filter the default User Edit heading for shortcode.
|
906 |
+
*
|
907 |
+
* @since 2.7.6
|
908 |
+
*
|
909 |
+
* @param string The default edit mode heading.
|
910 |
+
*/
|
911 |
+
$heading = apply_filters( 'wpmem_user_edit_heading', wpmem_get_text( 'profile_heading' ) );
|
912 |
+
|
913 |
+
if ( $wpmem_a == "update") {
|
914 |
+
$content.= wpmem_get_display_message( $wpmem_regchk, $wpmem_themsg );
|
915 |
+
}
|
916 |
+
|
917 |
+
$args['tag'] = 'edit';
|
918 |
+
$args['heading'] = $heading;
|
919 |
+
if ( false !== $atts && isset( $atts['fields'] ) ) {
|
920 |
+
$args['fields'] = $atts['fields'];
|
921 |
+
}
|
922 |
+
|
923 |
+
$content = $content . wpmem_register_form( $args );
|
924 |
+
|
925 |
+
return $content;
|
926 |
+
}
|
927 |
+
|
928 |
+
/**
|
929 |
+
* Forgot username form.
|
930 |
+
*
|
931 |
+
* This function creates a form for retrieving a forgotten username.
|
932 |
+
*
|
933 |
+
* @since 3.0.8
|
934 |
+
* @since 3.4.0 Moved to shortcodes as private function, renamed from wpmem_page_forgot_username().
|
935 |
+
*
|
936 |
+
* @param string $wpmem_regchk
|
937 |
+
* @param string $content
|
938 |
+
* @return string $content
|
939 |
+
*/
|
940 |
+
function render_forgot_username( $wpmem_regchk, $content ) {
|
941 |
+
|
942 |
+
if ( ! is_user_logged_in() ) {
|
943 |
+
|
944 |
+
global $wpmem;
|
945 |
+
switch( $wpmem->regchk ) {
|
946 |
+
|
947 |
+
case "usernamefailed":
|
948 |
+
$msg = wpmem_get_text( 'usernamefailed' );
|
949 |
+
$content = $content
|
950 |
+
. wpmem_get_display_message( 'usernamefailed', $msg )
|
951 |
+
. wpmem_forgot_username_form();
|
952 |
+
$wpmem->regchk = ''; // Clear regchk.
|
953 |
+
break;
|
954 |
+
|
955 |
+
case "usernamesuccess":
|
956 |
+
$email = ( isset( $_POST['user_email'] ) ) ? sanitize_email( $_POST['user_email'] ) : '';
|
957 |
+
$msg = sprintf( wpmem_get_text( 'usernamesuccess' ), $email );
|
958 |
+
$content = $content . wpmem_get_display_message( 'usernamesuccess', $msg );
|
959 |
+
$wpmem->regchk = ''; // Clear regchk.
|
960 |
+
break;
|
961 |
+
|
962 |
+
default:
|
963 |
+
$content = $content . wpmem_forgot_username_form();
|
964 |
+
break;
|
965 |
+
}
|
966 |
+
|
967 |
+
}
|
968 |
+
|
969 |
+
return $content;
|
970 |
+
|
971 |
+
}
|
972 |
+
|
973 |
+
/**
|
974 |
+
* Member Links Dialog.
|
975 |
+
*
|
976 |
+
* Outputs the links used on the members area.
|
977 |
+
*
|
978 |
+
* @since 2.0
|
979 |
+
* @since 3.4.0 Replaces wpmem_inc_memberlinks().
|
980 |
+
*
|
981 |
+
* @gloabl $user_login
|
982 |
+
* @global object $wpmem
|
983 |
+
* @param string $page
|
984 |
+
* @return string $str
|
985 |
+
*/
|
986 |
+
function render_links( $page = 'member' ) {
|
987 |
+
|
988 |
+
global $user_login, $wpmem;
|
989 |
+
|
990 |
+
$logout = wpmem_logout_link();
|
991 |
+
|
992 |
+
switch ( $page ) {
|
993 |
+
|
994 |
+
case 'register':
|
995 |
+
|
996 |
+
$url = ( isset( $wpmem->user_pages['profile'] ) && '' != $wpmem->user_pages['profile'] ) ? $wpmem->user_pages['profile'] : get_option( 'home' );
|
997 |
+
|
998 |
+
// NOTE: DO NOT EDIT THESE. Use the filter below.
|
999 |
+
$arr = array(
|
1000 |
+
'before_wrapper' => '<p class="register_status">' . sprintf( wpmem_get_text( 'register_status' ), $user_login ) . '</p>',
|
1001 |
+
'wrapper_before' => '<ul class="register_links">',
|
1002 |
+
'wrapper_after' => '</ul>',
|
1003 |
+
'rows' => array(
|
1004 |
+
'<li><a href="' . esc_url( $logout ) . '">' . wpmem_get_text( 'register_logout' ) . '</a></li>',
|
1005 |
+
'<li><a href="' . esc_url( $url ) . '">' . wpmem_get_text( 'register_continue' ) . '</a></li>',
|
1006 |
+
),
|
1007 |
+
'after_wrapper' => '',
|
1008 |
+
);
|
1009 |
+
|
1010 |
+
/**
|
1011 |
+
* Filter the register links array.
|
1012 |
+
*
|
1013 |
+
* @since 3.0.9
|
1014 |
+
* @since 3.1.0 Added after_wrapper
|
1015 |
+
*
|
1016 |
+
* @param array $arr {
|
1017 |
+
* The components of the links.
|
1018 |
+
*
|
1019 |
+
* @type string $before_wrapper HTML before the wrapper (default: login status).
|
1020 |
+
* @type string $wrapper_before The wrapper opening tag (default: <ul>).
|
1021 |
+
* @type string $wrapper_after The wrapper closing tag (default: </ul>).
|
1022 |
+
* @type array $rows Row items HTML.
|
1023 |
+
* @type string $after_wrapper Anything that comes after the wrapper.
|
1024 |
+
* }
|
1025 |
+
*/
|
1026 |
+
$arr = apply_filters( "wpmem_{$page}_links_args", $arr );
|
1027 |
+
|
1028 |
+
$str = $arr['before_wrapper'];
|
1029 |
+
$str.= $arr['wrapper_before'];
|
1030 |
+
foreach ( $arr['rows'] as $row ) {
|
1031 |
+
$str.= $row;
|
1032 |
+
}
|
1033 |
+
$str.= $arr['wrapper_after'];
|
1034 |
+
$str.= $arr['after_wrapper'];
|
1035 |
+
|
1036 |
+
/**
|
1037 |
+
* Filter the links displayed on the Register page (logged in state).
|
1038 |
+
*
|
1039 |
+
* @since 2.8.3
|
1040 |
+
*
|
1041 |
+
* @param string $str The default links.
|
1042 |
+
*/
|
1043 |
+
$str = apply_filters( "wpmem_{$page}_links", $str );
|
1044 |
+
break;
|
1045 |
+
|
1046 |
+
case 'login':
|
1047 |
+
|
1048 |
+
$logout = urldecode( $logout );
|
1049 |
+
// NOTE: DO NOT EDIT THESE. Use the filter hook below.
|
1050 |
+
$args = array(
|
1051 |
+
'wrapper_before' => '<p class="login_status">',
|
1052 |
+
'wrapper_after' => '</p>',
|
1053 |
+
'user_login' => $user_login,
|
1054 |
+
'welcome' => wpmem_get_text( 'login_welcome' ),
|
1055 |
+
'logout_text' => wpmem_get_text( 'login_logout' ),
|
1056 |
+
'logout_link' => '<a href="' . esc_url( $logout ) . '">%s</a>',
|
1057 |
+
'separator' => '<br />',
|
1058 |
+
);
|
1059 |
+
/**
|
1060 |
+
* Filter the status message parts.
|
1061 |
+
*
|
1062 |
+
* @since 2.9.9
|
1063 |
+
*
|
1064 |
+
* @param array $args {
|
1065 |
+
* The components of the links.
|
1066 |
+
*
|
1067 |
+
* @type string $wrapper_before The wrapper opening tag (default: <p>).
|
1068 |
+
* @type string $wrapper_after The wrapper closing tag (default: </p>).
|
1069 |
+
* @type string $user_login
|
1070 |
+
* @type string $welcome
|
1071 |
+
* @type string $logout_text
|
1072 |
+
* @type string $logout_link
|
1073 |
+
* @type string $separator
|
1074 |
+
* }
|
1075 |
+
*/
|
1076 |
+
$args = apply_filters( "wpmem_{$page}_links_args", $args );
|
1077 |
+
|
1078 |
+
// Assemble the message string.
|
1079 |
+
$str = $args['wrapper_before']
|
1080 |
+
. sprintf( $args['welcome'], $args['user_login'] )
|
1081 |
+
. $args['separator']
|
1082 |
+
. sprintf( $args['logout_link'], $args['logout_text'] )
|
1083 |
+
. $args['wrapper_after'];
|
1084 |
+
|
1085 |
+
/**
|
1086 |
+
* Filter the links displayed on the Log In page (logged in state).
|
1087 |
+
*
|
1088 |
+
* @since 2.8.3
|
1089 |
+
*
|
1090 |
+
* @param string $str The default links.
|
1091 |
+
*/
|
1092 |
+
$str = apply_filters( "wpmem_{$page}_links", $str );
|
1093 |
+
break;
|
1094 |
+
|
1095 |
+
case 'member':
|
1096 |
+
default:
|
1097 |
+
|
1098 |
+
// NOTE: DO NOT EDIT. Use the filter below.
|
1099 |
+
$arr = array(
|
1100 |
+
'before_wrapper' => '',
|
1101 |
+
'wrapper_before' => '<ul>',
|
1102 |
+
'wrapper_after' => '</ul>',
|
1103 |
+
'rows' => array(
|
1104 |
+
'<li><a href="' . esc_url( add_query_arg( 'a', 'edit', remove_query_arg( 'key' ) ) ) . '">' . wpmem_get_text( 'profile_edit' ) . '</a></li>',
|
1105 |
+
'<li><a href="' . esc_url( add_query_arg( 'a', 'pwdchange', remove_query_arg( 'key' ) ) ) . '">' . wpmem_get_text( 'profile_password' ) . '</a></li>',
|
1106 |
+
),
|
1107 |
+
'after_wrapper' => '',
|
1108 |
+
);
|
1109 |
+
|
1110 |
+
if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 && function_exists( 'wpmem_user_page_detail' ) ) {
|
1111 |
+
$arr['rows'][] = wpmem_user_page_detail();
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
/**
|
1115 |
+
* Filter the member links array.
|
1116 |
+
*
|
1117 |
+
* @since 3.0.9
|
1118 |
+
* @since 3.1.0 Added after_wrapper
|
1119 |
+
*
|
1120 |
+
* @param array $arr {
|
1121 |
+
* The components of the links.
|
1122 |
+
*
|
1123 |
+
* @type string $before_wrapper Anything that comes before the wrapper.
|
1124 |
+
* @type string $wrapper_before The wrapper opening tag (default: <ul>).
|
1125 |
+
* @type string $wrapper_after The wrapper closing tag (default: </ul>).
|
1126 |
+
* @type array $rows Row items HTML.
|
1127 |
+
* @type string $after_wrapper Anything that comes after the wrapper.
|
1128 |
+
* }
|
1129 |
+
*/
|
1130 |
+
$arr = apply_filters( "wpmem_{$page}_links_args", $arr );
|
1131 |
+
|
1132 |
+
$str = $arr['before_wrapper'];
|
1133 |
+
$str.= $arr['wrapper_before'];
|
1134 |
+
foreach ( $arr['rows'] as $row ) {
|
1135 |
+
$str.= $row;
|
1136 |
+
}
|
1137 |
+
$str.= $arr['wrapper_after'];
|
1138 |
+
$str.= $arr['after_wrapper'];
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* Filter the links displayed on the User Profile page (logged in state).
|
1142 |
+
*
|
1143 |
+
* @since 2.8.3
|
1144 |
+
*
|
1145 |
+
* @param string $str The default links.
|
1146 |
+
*/
|
1147 |
+
$str = apply_filters( "wpmem_{$page}_links", $str );
|
1148 |
+
break;
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
return $str;
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
function render_links_filter_args( $page, $args ) {
|
1155 |
+
|
1156 |
+
}
|
1157 |
}
|
1158 |
|
1159 |
// End of file.
|
@@ -1,610 +1,612 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members User Profile Class.
|
4 |
-
*
|
5 |
-
* @package WP-Members
|
6 |
-
* @subpackage WP_Members Admin User Profile Object Class
|
7 |
-
* @since 3.1.8
|
8 |
-
*/
|
9 |
-
|
10 |
-
// Exit if accessed directly.
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit();
|
13 |
-
}
|
14 |
-
|
15 |
-
class WP_Members_User_Profile {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Remove "admin only" fields if dashboard user profile.
|
19 |
-
*
|
20 |
-
* @since 3.3.6
|
21 |
-
*
|
22 |
-
* @param string $tag
|
23 |
-
* @return array $fields
|
24 |
-
*/
|
25 |
-
static function get_fields( $tag ) {
|
26 |
-
$fields = wpmem_fields( $tag );
|
27 |
-
if ( 'profile_dashboard' == $tag && false === current_user_can( 'edit_users' ) ) {
|
28 |
-
foreach( $fields as $key => $field ) {
|
29 |
-
if ( false == $field['profile'] ) {
|
30 |
-
unset( $fields[ $key ] );
|
31 |
-
}
|
32 |
-
}
|
33 |
-
}
|
34 |
-
return $fields;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Static function to display WP-Members fields on the admin/dashboard user profile.
|
39 |
-
*
|
40 |
-
* Function was created in 3.1.9 as a merge of wpmem_admin_fields()
|
41 |
-
* and wpmem_user_profile().
|
42 |
-
*
|
43 |
-
* @since 3.1.9
|
44 |
-
*
|
45 |
-
* @global object $current_screen
|
46 |
-
* @global string $user_ID
|
47 |
-
* @global object $wpmem
|
48 |
-
* @param object $user_obj
|
49 |
-
*/
|
50 |
-
static function profile( $user_obj ) {
|
51 |
-
|
52 |
-
global $current_screen, $user_ID, $wpmem;
|
53 |
-
$user_id = ( 'profile' == $current_screen->id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT );
|
54 |
-
$display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin';
|
55 |
-
$display = ( current_user_can( 'edit_users' ) ) ? 'admin' : $display; ?>
|
56 |
-
|
57 |
-
<h3><?php
|
58 |
-
$heading = ( 'admin' == $display ) ? __( 'WP-Members Additional Fields', 'wp-members' ) : __( 'Additional Information', 'wp-members' );
|
59 |
-
/**
|
60 |
-
* Filter the heading for additional profile fields.
|
61 |
-
*
|
62 |
-
* Filter is applied for the admin user edit ("wpmem_admin_profile_heading")
|
63 |
-
* and the user profile edit ("wpmem_user_profile_heading").
|
64 |
-
*
|
65 |
-
* @since 2.8.2 Admin Profile
|
66 |
-
* @since 2.9.1 Dashboard Profile
|
67 |
-
* @since 3.1.9 Merged admin/dashboard profile
|
68 |
-
*
|
69 |
-
* @param string The default additional fields heading.
|
70 |
-
*/
|
71 |
-
echo apply_filters( 'wpmem_' . $display . '_profile_heading', $heading ); ?></h3>
|
72 |
-
<table class="form-table">
|
73 |
-
<?php
|
74 |
-
// Get fields.
|
75 |
-
$wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'profile_admin' ) : self::get_fields( 'profile_dashboard' );
|
76 |
-
// Get excluded meta.
|
77 |
-
$exclude = wpmem_get_excluded_meta( $display . '-profile' );
|
78 |
-
|
79 |
-
// If tos is an active field.
|
80 |
-
if ( isset( $wpmem_fields['tos'] ) ) {
|
81 |
-
if ( 1 != $wpmem_fields['tos']['register'] ) {
|
82 |
-
unset( $wpmem_fields['tos'] );
|
83 |
-
}
|
84 |
-
// This is the dashboard profile, and user has current field value.
|
85 |
-
if ( 'user' == $display
|
86 |
-
&& isset( $wpmem_fields['tos'] )
|
87 |
-
&& ( get_user_meta( $user_ID, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) ) {
|
88 |
-
unset( $wpmem_fields['tos'] );
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Fires at the beginning of generating the WP-Members fields in the user profile.
|
94 |
-
*
|
95 |
-
* Action fires for the admin user edit ("wpmem_admin_before_profile")
|
96 |
-
* and the user profile edit ("wpmem_user_before_profile").
|
97 |
-
*
|
98 |
-
* @since 2.9.3 Created for admin profile.
|
99 |
-
* @since 3.1.9 Added to dashboard profile.
|
100 |
-
*
|
101 |
-
* @param int $user_id The user's ID.
|
102 |
-
* @param array $wpmem_fields The WP-Members fields.
|
103 |
-
*/
|
104 |
-
do_action( 'wpmem_' . $display . '_before_profile', $user_id, $wpmem_fields );
|
105 |
-
|
106 |
-
// Assemble form rows array.
|
107 |
-
$rows = array();
|
108 |
-
foreach ( $wpmem_fields as $meta => $field ) {
|
109 |
-
|
110 |
-
$valtochk = ''; $values = '';
|
111 |
-
|
112 |
-
// Determine which fields to show in the additional fields area.
|
113 |
-
$show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false;
|
114 |
-
//$show = ( 'tos' == $meta && $field['register'] ) ? null : $show;
|
115 |
-
|
116 |
-
if ( $show ) {
|
117 |
-
|
118 |
-
$val = get_user_meta( $user_id, $meta, true );
|
119 |
-
$val = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? $val : htmlspecialchars( $val );
|
120 |
-
if ( $field['type'] == 'checkbox' ) {
|
121 |
-
$valtochk = $val;
|
122 |
-
$val = $field['checked_value'];
|
123 |
-
}
|
124 |
-
|
125 |
-
if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
|
126 |
-
$values = $field['values'];
|
127 |
-
$valtochk = $val;
|
128 |
-
}
|
129 |
-
|
130 |
-
// Is this an image or a file?
|
131 |
-
if ( 'file' == $field['type'] || 'image' == $field['type'] ) {
|
132 |
-
$empty_file = '<span class="description">' . __( 'None' ) . '</span>';
|
133 |
-
if ( 'file' == $field['type'] ) {
|
134 |
-
$attachment_url = wp_get_attachment_url( $val );
|
135 |
-
$input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file;
|
136 |
-
} else {
|
137 |
-
$attachment_url = wp_get_attachment_image( $val, 'medium' );
|
138 |
-
if ( 'admin' == $display ) {
|
139 |
-
$edit_url = admin_url( 'upload.php?item=' . $val );
|
140 |
-
$input = ( $attachment_url ) ? '<a href="' . $edit_url . '">' . $attachment_url . '</a>' : $empty_file;
|
141 |
-
} else {
|
142 |
-
$input = ( $attachment_url ) ? $attachment_url : $empty_file;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
$input.= '<br />' .
|
146 |
-
$input.= wpmem_form_field( array(
|
147 |
-
'name' => $meta,
|
148 |
-
'type' => $field['type'],
|
149 |
-
'value' => $val,
|
150 |
-
'compare' => $valtochk,
|
151 |
-
) );
|
152 |
-
} else {
|
153 |
-
if ( 'select' == $field['type'] || 'radio' == $field['type'] ) {
|
154 |
-
$input = wpmem_form_field( $meta, $field['type'], $values, $valtochk );
|
155 |
-
} elseif( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
|
156 |
-
$input = wpmem_form_field( array( 'name'=>$meta, 'type'=>$field['type'], 'value'=>$values, 'compare'=>$valtochk, 'delimiter'=>$field['delimiter'] ) );
|
157 |
-
} else {
|
158 |
-
$field['type'] = ( 'hidden' == $field['type'] ) ? 'text' : $field['type'];
|
159 |
-
|
160 |
-
$formfield_args = array(
|
161 |
-
'name' => $meta,
|
162 |
-
'type' => $field['type'],
|
163 |
-
'value' => $val,
|
164 |
-
'compare' => $valtochk,
|
165 |
-
'required' => $field['required'],
|
166 |
-
'
|
167 |
-
'
|
168 |
-
'
|
169 |
-
'
|
170 |
-
'
|
171 |
-
'
|
172 |
-
'
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
$
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
'
|
187 |
-
'
|
188 |
-
'
|
189 |
-
'
|
190 |
-
'
|
191 |
-
'
|
192 |
-
'
|
193 |
-
'
|
194 |
-
'
|
195 |
-
'
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
*
|
203 |
-
*
|
204 |
-
|
205 |
-
|
206 |
-
*
|
207 |
-
* @since 3.1.
|
208 |
-
*
|
209 |
-
*
|
210 |
-
*
|
211 |
-
*
|
212 |
-
*
|
213 |
-
* @type string $
|
214 |
-
* @type string $
|
215 |
-
* @type string $
|
216 |
-
* @type string $
|
217 |
-
* @type string $
|
218 |
-
* @type string $
|
219 |
-
* @type string $
|
220 |
-
* @type string $
|
221 |
-
* @type string $
|
222 |
-
* @type string $
|
223 |
-
*
|
224 |
-
*
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
$row['
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
*
|
239 |
-
*
|
240 |
-
*
|
241 |
-
*
|
242 |
-
*
|
243 |
-
* @since
|
244 |
-
*
|
245 |
-
*
|
246 |
-
* @param string $
|
247 |
-
* @param
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
*
|
255 |
-
*
|
256 |
-
*
|
257 |
-
*
|
258 |
-
*
|
259 |
-
*
|
260 |
-
*
|
261 |
-
* @param
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
*
|
271 |
-
*
|
272 |
-
*
|
273 |
-
*
|
274 |
-
*
|
275 |
-
*
|
276 |
-
* @param
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
*
|
285 |
-
*
|
286 |
-
*
|
287 |
-
*
|
288 |
-
*
|
289 |
-
*
|
290 |
-
*
|
291 |
-
* @global
|
292 |
-
* @global
|
293 |
-
* @
|
294 |
-
* @
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
&&
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
*
|
330 |
-
*
|
331 |
-
*
|
332 |
-
*
|
333 |
-
*
|
334 |
-
* @since
|
335 |
-
*
|
336 |
-
*
|
337 |
-
* @param
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
&& $field['type'] != '
|
346 |
-
&& $field['type'] != '
|
347 |
-
&& $field['type'] != '
|
348 |
-
&& $field['type'] != '
|
349 |
-
&& $field['type'] != '
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
*
|
376 |
-
*
|
377 |
-
*
|
378 |
-
*
|
379 |
-
*
|
380 |
-
* @since
|
381 |
-
*
|
382 |
-
*
|
383 |
-
* @param
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
*
|
448 |
-
*
|
449 |
-
*
|
450 |
-
*
|
451 |
-
*
|
452 |
-
*
|
453 |
-
*
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
*
|
463 |
-
*
|
464 |
-
*
|
465 |
-
*
|
466 |
-
*
|
467 |
-
* @since 3.1.
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
*
|
483 |
-
*
|
484 |
-
* @since 3.
|
485 |
-
*
|
486 |
-
*
|
487 |
-
* @
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
if
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
$
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
$
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
<
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
*
|
524 |
-
*
|
525 |
-
* @since 3.
|
526 |
-
*
|
527 |
-
*
|
528 |
-
* @
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
* If
|
536 |
-
*
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
*
|
551 |
-
*
|
552 |
-
* @since 3.
|
553 |
-
*
|
554 |
-
*
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
<
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
*
|
567 |
-
*
|
568 |
-
*
|
569 |
-
*
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
*
|
578 |
-
*
|
579 |
-
*
|
580 |
-
*
|
581 |
-
*
|
582 |
-
* @type string $
|
583 |
-
*
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
echo '
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
|
|
|
|
610 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members User Profile Class.
|
4 |
+
*
|
5 |
+
* @package WP-Members
|
6 |
+
* @subpackage WP_Members Admin User Profile Object Class
|
7 |
+
* @since 3.1.8
|
8 |
+
*/
|
9 |
+
|
10 |
+
// Exit if accessed directly.
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit();
|
13 |
+
}
|
14 |
+
|
15 |
+
class WP_Members_User_Profile {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Remove "admin only" fields if dashboard user profile.
|
19 |
+
*
|
20 |
+
* @since 3.3.6
|
21 |
+
*
|
22 |
+
* @param string $tag
|
23 |
+
* @return array $fields
|
24 |
+
*/
|
25 |
+
static function get_fields( $tag ) {
|
26 |
+
$fields = wpmem_fields( $tag );
|
27 |
+
if ( 'profile_dashboard' == $tag && false === current_user_can( 'edit_users' ) ) {
|
28 |
+
foreach( $fields as $key => $field ) {
|
29 |
+
if ( false == $field['profile'] ) {
|
30 |
+
unset( $fields[ $key ] );
|
31 |
+
}
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return $fields;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Static function to display WP-Members fields on the admin/dashboard user profile.
|
39 |
+
*
|
40 |
+
* Function was created in 3.1.9 as a merge of wpmem_admin_fields()
|
41 |
+
* and wpmem_user_profile().
|
42 |
+
*
|
43 |
+
* @since 3.1.9
|
44 |
+
*
|
45 |
+
* @global object $current_screen
|
46 |
+
* @global string $user_ID
|
47 |
+
* @global object $wpmem
|
48 |
+
* @param object $user_obj
|
49 |
+
*/
|
50 |
+
static function profile( $user_obj ) {
|
51 |
+
|
52 |
+
global $current_screen, $user_ID, $wpmem;
|
53 |
+
$user_id = ( 'profile' == $current_screen->id ) ? $user_ID : filter_var( $_REQUEST['user_id'], FILTER_SANITIZE_NUMBER_INT );
|
54 |
+
$display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin';
|
55 |
+
$display = ( current_user_can( 'edit_users' ) ) ? 'admin' : $display; ?>
|
56 |
+
|
57 |
+
<h3><?php
|
58 |
+
$heading = ( 'admin' == $display ) ? __( 'WP-Members Additional Fields', 'wp-members' ) : __( 'Additional Information', 'wp-members' );
|
59 |
+
/**
|
60 |
+
* Filter the heading for additional profile fields.
|
61 |
+
*
|
62 |
+
* Filter is applied for the admin user edit ("wpmem_admin_profile_heading")
|
63 |
+
* and the user profile edit ("wpmem_user_profile_heading").
|
64 |
+
*
|
65 |
+
* @since 2.8.2 Admin Profile
|
66 |
+
* @since 2.9.1 Dashboard Profile
|
67 |
+
* @since 3.1.9 Merged admin/dashboard profile
|
68 |
+
*
|
69 |
+
* @param string The default additional fields heading.
|
70 |
+
*/
|
71 |
+
echo apply_filters( 'wpmem_' . $display . '_profile_heading', $heading ); ?></h3>
|
72 |
+
<table class="form-table">
|
73 |
+
<?php
|
74 |
+
// Get fields.
|
75 |
+
$wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'profile_admin' ) : self::get_fields( 'profile_dashboard' );
|
76 |
+
// Get excluded meta.
|
77 |
+
$exclude = wpmem_get_excluded_meta( $display . '-profile' );
|
78 |
+
|
79 |
+
// If tos is an active field.
|
80 |
+
if ( isset( $wpmem_fields['tos'] ) ) {
|
81 |
+
if ( 1 != $wpmem_fields['tos']['register'] ) {
|
82 |
+
unset( $wpmem_fields['tos'] );
|
83 |
+
}
|
84 |
+
// This is the dashboard profile, and user has current field value.
|
85 |
+
if ( 'user' == $display
|
86 |
+
&& isset( $wpmem_fields['tos'] )
|
87 |
+
&& ( get_user_meta( $user_ID, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) ) {
|
88 |
+
unset( $wpmem_fields['tos'] );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Fires at the beginning of generating the WP-Members fields in the user profile.
|
94 |
+
*
|
95 |
+
* Action fires for the admin user edit ("wpmem_admin_before_profile")
|
96 |
+
* and the user profile edit ("wpmem_user_before_profile").
|
97 |
+
*
|
98 |
+
* @since 2.9.3 Created for admin profile.
|
99 |
+
* @since 3.1.9 Added to dashboard profile.
|
100 |
+
*
|
101 |
+
* @param int $user_id The user's ID.
|
102 |
+
* @param array $wpmem_fields The WP-Members fields.
|
103 |
+
*/
|
104 |
+
do_action( 'wpmem_' . $display . '_before_profile', $user_id, $wpmem_fields );
|
105 |
+
|
106 |
+
// Assemble form rows array.
|
107 |
+
$rows = array();
|
108 |
+
foreach ( $wpmem_fields as $meta => $field ) {
|
109 |
+
|
110 |
+
$valtochk = ''; $values = '';
|
111 |
+
|
112 |
+
// Determine which fields to show in the additional fields area.
|
113 |
+
$show = ( ! $field['native'] && ! in_array( $meta, $exclude ) ) ? true : false;
|
114 |
+
//$show = ( 'tos' == $meta && $field['register'] ) ? null : $show;
|
115 |
+
|
116 |
+
if ( $show ) {
|
117 |
+
|
118 |
+
$val = get_user_meta( $user_id, $meta, true );
|
119 |
+
$val = ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) ? $val : htmlspecialchars( $val );
|
120 |
+
if ( $field['type'] == 'checkbox' ) {
|
121 |
+
$valtochk = $val;
|
122 |
+
$val = $field['checked_value'];
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( 'multicheckbox' == $field['type'] || 'select' == $field['type'] || 'multiselect' == $field['type'] || 'radio' == $field['type'] ) {
|
126 |
+
$values = $field['values'];
|
127 |
+
$valtochk = $val;
|
128 |
+
}
|
129 |
+
|
130 |
+
// Is this an image or a file?
|
131 |
+
if ( 'file' == $field['type'] || 'image' == $field['type'] ) {
|
132 |
+
$empty_file = '<span class="description">' . __( 'None' ) . '</span>';
|
133 |
+
if ( 'file' == $field['type'] ) {
|
134 |
+
$attachment_url = wp_get_attachment_url( $val );
|
135 |
+
$input = ( $attachment_url ) ? '<a href="' . $attachment_url . '">' . $attachment_url . '</a>' : $empty_file;
|
136 |
+
} else {
|
137 |
+
$attachment_url = wp_get_attachment_image( $val, 'medium' );
|
138 |
+
if ( 'admin' == $display ) {
|
139 |
+
$edit_url = admin_url( 'upload.php?item=' . $val );
|
140 |
+
$input = ( $attachment_url ) ? '<a href="' . $edit_url . '">' . $attachment_url . '</a>' : $empty_file;
|
141 |
+
} else {
|
142 |
+
$input = ( $attachment_url ) ? $attachment_url : $empty_file;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
$input.= '<br />' . wpmem_get_text( 'profile_upload' ) . '<br />';
|
146 |
+
$input.= wpmem_form_field( array(
|
147 |
+
'name' => $meta,
|
148 |
+
'type' => $field['type'],
|
149 |
+
'value' => $val,
|
150 |
+
'compare' => $valtochk,
|
151 |
+
) );
|
152 |
+
} else {
|
153 |
+
if ( 'select' == $field['type'] || 'radio' == $field['type'] ) {
|
154 |
+
$input = wpmem_form_field( $meta, $field['type'], $values, $valtochk );
|
155 |
+
} elseif( 'multicheckbox' == $field['type'] || 'multiselect' == $field['type'] ) {
|
156 |
+
$input = wpmem_form_field( array( 'name'=>$meta, 'type'=>$field['type'], 'value'=>$values, 'compare'=>$valtochk, 'delimiter'=>$field['delimiter'] ) );
|
157 |
+
} else {
|
158 |
+
$field['type'] = ( 'hidden' == $field['type'] ) ? 'text' : $field['type'];
|
159 |
+
|
160 |
+
$formfield_args = array(
|
161 |
+
'name' => $meta,
|
162 |
+
'type' => $field['type'],
|
163 |
+
'value' => $val,
|
164 |
+
'compare' => $valtochk,
|
165 |
+
'required' => $field['required'],
|
166 |
+
'class' => 'regular-text',
|
167 |
+
'placeholder' => ( isset( $field['placeholder'] ) ) ? $field['placeholder'] : '',
|
168 |
+
'pattern' => ( isset( $field['pattern'] ) ) ? $field['pattern'] : false,
|
169 |
+
'title' => ( isset( $field['title'] ) ) ? $field['title'] : false,
|
170 |
+
'min' => ( isset( $field['min'] ) ) ? $field['min'] : false,
|
171 |
+
'max' => ( isset( $field['max'] ) ) ? $field['max'] : false,
|
172 |
+
'rows' => ( isset( $field['rows'] ) ) ? $field['rows'] : false,
|
173 |
+
'cols' => ( isset( $field['cols'] ) ) ? $field['cols'] : false,
|
174 |
+
);
|
175 |
+
|
176 |
+
$input = wpmem_form_field( $formfield_args );
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
// Is the field required?
|
181 |
+
$req = ( $field['required'] ) ? ' <span class="description">' . __( '(required)' ) . '</span>' : '';
|
182 |
+
$label = '<label>' . __( $field['label'], 'wp-members' ) . $req . '</label>';
|
183 |
+
|
184 |
+
// Build the form rows for filtering.
|
185 |
+
$rows[ $meta ] = array(
|
186 |
+
'meta' => $meta,
|
187 |
+
'type' => $field['type'],
|
188 |
+
'value' => $val,
|
189 |
+
'values' => $values,
|
190 |
+
'label_text' => __( $field['label'], 'wp-members' ),
|
191 |
+
'row_before' => '<tr>',
|
192 |
+
'label' => '<th>' . $label . '</th>',
|
193 |
+
'field_before' => '<td>',
|
194 |
+
'field' => $input,
|
195 |
+
'field_after' => '</td>',
|
196 |
+
'row_after' => '</tr>',
|
197 |
+
);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Filter for rows.
|
203 |
+
*
|
204 |
+
* Filter is applied for the admin user edit ("wpmem_register_form_rows_admin")
|
205 |
+
* and the user profile edit ("wpmem_register_form_rows_user").
|
206 |
+
*
|
207 |
+
* @since 3.1.0
|
208 |
+
* @since 3.1.6 Deprecated $order.
|
209 |
+
*
|
210 |
+
* @param array $rows {
|
211 |
+
* An array of the profile rows.
|
212 |
+
*
|
213 |
+
* @type string $meta The meta key.
|
214 |
+
* @type string $type The field type.
|
215 |
+
* @type string $value Value if set.
|
216 |
+
* @type string $values Possible values (select, multiselect, multicheckbox, radio).
|
217 |
+
* @type string $label_text Raw label text (no HTML).
|
218 |
+
* @type string $row_before HTML before the row.
|
219 |
+
* @type string $label HTML label.
|
220 |
+
* @type string $field_before HTML before the field input tag.
|
221 |
+
* @type string $field HTML for field input.
|
222 |
+
* @type string $field_after HTML after the field.
|
223 |
+
* @type string $row_after HTML after the row.
|
224 |
+
* }
|
225 |
+
* @param string $tag adminprofile|userprofile
|
226 |
+
*/
|
227 |
+
$rows = apply_filters( 'wpmem_register_form_rows_' . $display, $rows, $display . 'profile' );
|
228 |
+
|
229 |
+
// Handle form rows display from array.
|
230 |
+
foreach ( $rows as $row ) {
|
231 |
+
$show_field =
|
232 |
+
$row['row_before'] .
|
233 |
+
$row['label'] .
|
234 |
+
$row['field_before'] . $row['field'] . $row['field_after'] .
|
235 |
+
$row['field_after'];
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Filter the profile field.
|
239 |
+
*
|
240 |
+
* Filter is applied for the admin user edit ("wpmem_admin_profile_field")
|
241 |
+
* and the user profile edit ("wpmem_user_profile_field").
|
242 |
+
*
|
243 |
+
* @since 2.8.2
|
244 |
+
* @since 3.1.1 Added $user_id and $row
|
245 |
+
*
|
246 |
+
* @param string $show_field The HTML string for the additional profile field.
|
247 |
+
* @param string $user_id
|
248 |
+
* @param array $row
|
249 |
+
*/
|
250 |
+
echo apply_filters( 'wpmem_' . $display . '_profile_field', $show_field, $user_id, $row );
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Fires after generating the WP-Members fields in the user profile.
|
255 |
+
*
|
256 |
+
* Action fires for the admin user edit ("wpmem_admin_after_profile")
|
257 |
+
* and the user profile edit ("wpmem_user_after_profile").
|
258 |
+
*
|
259 |
+
* @since 2.9.3
|
260 |
+
*
|
261 |
+
* @param int $user_id The user's ID.
|
262 |
+
* @param array $wpmem_fields The WP-Members fields.
|
263 |
+
*/
|
264 |
+
do_action( 'wpmem_' . $display . '_after_profile', $user_id, $wpmem_fields ); ?>
|
265 |
+
|
266 |
+
</table><?php
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Fires after the user profile table.
|
270 |
+
*
|
271 |
+
* Action fires for the admin user edit ("wpmem_admin_after_profile_table")
|
272 |
+
* and the user profile edit ("wpmem_user_after_profile_table").
|
273 |
+
*
|
274 |
+
* @since 3.2.6
|
275 |
+
*
|
276 |
+
* @param int $user_id The user's ID.
|
277 |
+
* @param array $wpmem_fields The WP-Members fields.
|
278 |
+
*/
|
279 |
+
do_action( 'wpmem_' . $display . '_after_profile_table', $user_id, $wpmem_fields );
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Static function to update admin/dashboard user profile.
|
285 |
+
*
|
286 |
+
* Function was created in 3.1.9 as a merge of wpmem_admin_update()
|
287 |
+
* and wpmem_profile_update().
|
288 |
+
*
|
289 |
+
* @since 3.1.9
|
290 |
+
*
|
291 |
+
* @global object $current_screen
|
292 |
+
* @global string $user_id
|
293 |
+
* @global object $wpmem
|
294 |
+
* @param string $user_id
|
295 |
+
* @return
|
296 |
+
*/
|
297 |
+
static function update( $user_id ) {
|
298 |
+
|
299 |
+
global $current_screen, $user_id, $wpmem;
|
300 |
+
$display = ( 'profile' == $current_screen->base ) ? 'user' : 'admin';
|
301 |
+
|
302 |
+
if ( ! $user_id ) {
|
303 |
+
$user_id = filter_var( wpmem_get( 'user_id', -1, 'request' ), FILTER_SANITIZE_NUMBER_INT );
|
304 |
+
if ( 1 > $user_id ) {
|
305 |
+
// Still no user id? User cannot be updated.
|
306 |
+
return;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
$wpmem_fields = ( 'admin' == $display ) ? self::get_fields( 'profile_admin' ) : self::get_fields( 'profile_dashboard' );
|
311 |
+
|
312 |
+
// Check for password field before exclusions, just in case we are activating a user (otherwise password is removed on user/admin profiles).
|
313 |
+
$chk_pass = ( array_key_exists( 'password', $wpmem_fields ) && true === $wpmem_fields['password']['register'] ) ? true : false;
|
314 |
+
|
315 |
+
$exclude = wpmem_get_excluded_meta( $display . '-profile' );
|
316 |
+
|
317 |
+
foreach ( $exclude as $excluded ) {
|
318 |
+
unset( $wpmem_fields[ $excluded ] );
|
319 |
+
}
|
320 |
+
|
321 |
+
// If tos is an active field, this is the dashboard profile, and user has current field value.
|
322 |
+
if ( isset( $wpmem_fields['tos'] )
|
323 |
+
&& 'user' == $display
|
324 |
+
&& get_user_meta( $user_id, 'tos', true ) == $wpmem_fields['tos']['checked_value'] ) {
|
325 |
+
unset( $wpmem_fields['tos'] );
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Fires before the user profile is updated.
|
330 |
+
*
|
331 |
+
* Action fires for the admin user edit ("wpmem_admin_pre_user_update")
|
332 |
+
* and the user profile edit ("wpmem_user_pre_user_update").
|
333 |
+
*
|
334 |
+
* @since 2.9.2 Added for admin profile update.
|
335 |
+
* @since 3.1.9 Added for user profile update.
|
336 |
+
*
|
337 |
+
* @param int $user_id The user ID.
|
338 |
+
* @param array $wpmem_fields Array of the custom fields.
|
339 |
+
*/
|
340 |
+
do_action( 'wpmem_' . $display . '_pre_user_update', $user_id, $wpmem_fields );
|
341 |
+
|
342 |
+
$fields = array();
|
343 |
+
foreach ( $wpmem_fields as $meta => $field ) {
|
344 |
+
if ( ! $field['native']
|
345 |
+
&& $field['type'] != 'password'
|
346 |
+
&& $field['type'] != 'checkbox'
|
347 |
+
&& $field['type'] != 'multiselect'
|
348 |
+
&& $field['type'] != 'multicheckbox'
|
349 |
+
&& $field['type'] != 'file'
|
350 |
+
&& $field['type'] != 'image'
|
351 |
+
&& $field['type'] != 'textarea' ) {
|
352 |
+
( isset( $_POST[ $meta ] ) && 'password' != $field['type'] ) ? $fields[ $meta ] = sanitize_text_field( $_POST[ $meta ] ) : false;
|
353 |
+
|
354 |
+
// For user profile (not admin).
|
355 |
+
$chk = false;
|
356 |
+
if ( 'admin' != $display ) {
|
357 |
+
// Check for required fields.
|
358 |
+
if ( ! $field['required'] ) {
|
359 |
+
$chk = 'ok';
|
360 |
+
}
|
361 |
+
if ( $field['required'] && $_POST[ $meta ] != '' ) {
|
362 |
+
$chk = 'ok';
|
363 |
+
}
|
364 |
+
}
|
365 |
+
} elseif ( $field['type'] == 'checkbox' ) {
|
366 |
+
$fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? sanitize_text_field( $_POST[ $meta ] ) : '';
|
367 |
+
} elseif ( $field['type'] == 'multiselect' || $field['type'] == 'multicheckbox' ) {
|
368 |
+
$fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? implode( $field['delimiter'], wp_unslash( $_POST[ $meta ] ) ) : '';
|
369 |
+
} elseif ( $field['type'] == 'textarea' ) {
|
370 |
+
$fields[ $meta ] = ( isset( $_POST[ $meta ] ) ) ? sanitize_textarea_field( $_POST[ $meta ] ) : '';
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
/**
|
375 |
+
* Filter the submitted field values for backend profile update.
|
376 |
+
*
|
377 |
+
* Filters is applied for the admin user edit ("wpmem_admin_profile_update")
|
378 |
+
* and the user profile edit ("wpmem_user_profile_update").
|
379 |
+
*
|
380 |
+
* @since 2.8.2 Added for Admin profile update.
|
381 |
+
* @since 3.1.9 Added for User profile update.
|
382 |
+
*
|
383 |
+
* @param array $fields An array of the posted form values.
|
384 |
+
* @param int $user_id The ID of the user being updated.
|
385 |
+
*/
|
386 |
+
$fields = apply_filters( 'wpmem_' . $display . '_profile_update', $fields, $user_id );
|
387 |
+
|
388 |
+
// Handle meta update, skip excluded fields.
|
389 |
+
foreach ( $fields as $key => $val ) {
|
390 |
+
if ( ! in_array( $key, $exclude ) ) {
|
391 |
+
if ( ( 'admin' != $display && 'ok' == $chk ) || 'admin' == $display ) {
|
392 |
+
update_user_meta( $user_id, $key, $val );
|
393 |
+
}
|
394 |
+
}
|
395 |
+
}
|
396 |
+
|
397 |
+
if ( ! empty( $_FILES ) ) {
|
398 |
+
$wpmem->user->upload_user_files( $user_id, $wpmem->fields );
|
399 |
+
}
|
400 |
+
|
401 |
+
if ( 'admin' == $display || current_user_can( 'edit_users' ) ) {
|
402 |
+
if ( $wpmem->mod_reg == 1 ) {
|
403 |
+
|
404 |
+
$wpmem_activate_user = ( isset( $_POST['activate_user'] ) == '' ) ? -1 : filter_var( $_POST['activate_user'], FILTER_SANITIZE_NUMBER_INT );
|
405 |
+
|
406 |
+
if ( $wpmem_activate_user == 1 ) {
|
407 |
+
wpmem_activate_user( $user_id );
|
408 |
+
} elseif ( $wpmem_activate_user == 0 ) {
|
409 |
+
wpmem_deactivate_user( $user_id );
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
|
414 |
+
if ( function_exists( 'wpmem_a_extenduser' ) ) {
|
415 |
+
wpmem_a_extenduser( $user_id );
|
416 |
+
}
|
417 |
+
}
|
418 |
+
|
419 |
+
if ( 1 == $wpmem->enable_products ) {
|
420 |
+
// Update products.
|
421 |
+
if ( isset( $_POST['_wpmem_membership_product'] ) ) {
|
422 |
+
foreach ( $_POST['_wpmem_membership_product'] as $product_key => $product_value ) {
|
423 |
+
// Sanitize.
|
424 |
+
$product_key = sanitize_text_field( $product_key );
|
425 |
+
// Enable or Disable?
|
426 |
+
if ( 'enable' == $product_value ) {
|
427 |
+
// Does product require a role?
|
428 |
+
if ( false !== $wpmem->membership->products[ $product_key ]['role'] ) {
|
429 |
+
wpmem_update_user_role( $user_id, $wpmem->membership->products[ $product_key ]['role'], 'add' );
|
430 |
+
}
|
431 |
+
// Do we need to set a specific date?
|
432 |
+
if ( isset( $_POST[ '_wpmem_membership_expiration_' . $product_key ] ) ) {
|
433 |
+
wpmem_set_user_product( $product_key, $user_id, sanitize_text_field( $_POST[ '_wpmem_membership_expiration_' . $product_key ] ) );
|
434 |
+
} else {
|
435 |
+
wpmem_set_user_product( $product_key, $user_id );
|
436 |
+
}
|
437 |
+
}
|
438 |
+
if ( 'disable' == $product_value ) {
|
439 |
+
$wpmem->user->remove_user_product( $product_key, $user_id );
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Fires after the user profile is updated.
|
448 |
+
*
|
449 |
+
* Action fires for the admin user edit ("wpmem_admin_after_user_update")
|
450 |
+
* and the user profile edit ("wpmem_user_after_user_update").
|
451 |
+
*
|
452 |
+
* @since 2.9.2
|
453 |
+
*
|
454 |
+
* @param int $user_id The user ID.
|
455 |
+
*/
|
456 |
+
do_action( 'wpmem_' . $display . '_after_user_update', $user_id );
|
457 |
+
|
458 |
+
return;
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Sets user profile update to multipart form data.
|
463 |
+
*
|
464 |
+
* If the fields array has a file or image field, this will echo the
|
465 |
+
* necessary "multipart/form-data" enctype for the form tag.
|
466 |
+
*
|
467 |
+
* @since 3.1.8 (as wpmem_profile_multipart()).
|
468 |
+
* @since 3.1.9 Moved to User Profile object.
|
469 |
+
*/
|
470 |
+
public static function add_multipart() {
|
471 |
+
$has_file = false;
|
472 |
+
foreach ( wpmem_fields() as $field ) {
|
473 |
+
if ( $field['type'] == 'file' || $field['type'] == 'image' ) {
|
474 |
+
$has_file = true;
|
475 |
+
break;
|
476 |
+
}
|
477 |
+
}
|
478 |
+
echo ( $has_file ) ? " enctype=\"multipart/form-data\"" : '';
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Adds user activation to the user profile.
|
483 |
+
*
|
484 |
+
* @since 3.1.1
|
485 |
+
* @since 3.2.0 Moved to WP_Members_User_Profile object
|
486 |
+
*
|
487 |
+
* @global object $wpmem
|
488 |
+
* @param int $user_id
|
489 |
+
*/
|
490 |
+
public static function _show_activate( $user_id ) {
|
491 |
+
global $wpmem;
|
492 |
+
// See if reg is moderated, and if the user has been activated.
|
493 |
+
if ( $wpmem->mod_reg == 1 ) {
|
494 |
+
// Make sure this isn't an admin looking at their own profile.
|
495 |
+
if ( current_user_can( 'edit_users' ) && $user_id != get_current_user_id() ) {
|
496 |
+
$user_active_flag = get_user_meta( $user_id, 'active', true );
|
497 |
+
switch( $user_active_flag ) {
|
498 |
+
|
499 |
+
case "0":
|
500 |
+
$label = __( 'Reactivate this user?', 'wp-members' );
|
501 |
+
$action = 1;
|
502 |
+
break;
|
503 |
+
|
504 |
+
case "1":
|
505 |
+
$label = __( 'Deactivate this user?', 'wp-members' );
|
506 |
+
$action = 0;
|
507 |
+
break;
|
508 |
+
|
509 |
+
default:
|
510 |
+
$label = __( 'Activate this user?', 'wp-members' );
|
511 |
+
$action = 1;
|
512 |
+
break;
|
513 |
+
} ?>
|
514 |
+
<tr>
|
515 |
+
<th><label><?php echo $label; ?></label></th>
|
516 |
+
<td><input id="activate_user" type="checkbox" class="input" name="activate_user" value="<?php echo $action; ?>" /></td>
|
517 |
+
</tr>
|
518 |
+
<?php }
|
519 |
+
}
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Adds user expiration to the user profile.
|
524 |
+
*
|
525 |
+
* @since 3.1.1
|
526 |
+
* @since 3.2.0 Moved to WP_Members_User_Profile object
|
527 |
+
*
|
528 |
+
* @global object $wpmem
|
529 |
+
* @param int $user_id
|
530 |
+
*/
|
531 |
+
public static function _show_expiration( $user_id ) {
|
532 |
+
|
533 |
+
global $wpmem;
|
534 |
+
/*
|
535 |
+
* If using subscription model, show expiration.
|
536 |
+
* If registration is moderated, this doesn't show
|
537 |
+
* if user is not active yet.
|
538 |
+
*/
|
539 |
+
if ( defined( 'WPMEM_EXP_MODULE' ) && $wpmem->use_exp == 1 ) {
|
540 |
+
if ( ( $wpmem->mod_reg == 1 && get_user_meta( $user_id, 'active', true ) == 1 ) || ( $wpmem->mod_reg != 1 ) ) {
|
541 |
+
if ( function_exists( 'wpmem_a_extend_user' ) ) {
|
542 |
+
wpmem_a_extend_user( $user_id );
|
543 |
+
}
|
544 |
+
}
|
545 |
+
}
|
546 |
+
}
|
547 |
+
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Adds user registration IP to the user profile.
|
551 |
+
*
|
552 |
+
* @since 3.1.1
|
553 |
+
* @since 3.2.0 Moved to WP_Members_User_Profile object
|
554 |
+
*
|
555 |
+
* @param int $user_id
|
556 |
+
*/
|
557 |
+
public static function _show_ip( $user_id ) { ?>
|
558 |
+
<tr>
|
559 |
+
<th><label><?php _e( 'IP @ registration', 'wp-members' ); ?></label></th>
|
560 |
+
<td><?php echo get_user_meta( $user_id, 'wpmem_reg_ip', true ); ?></td>
|
561 |
+
</tr>
|
562 |
+
<?php
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Add jquery ui tabs to user profile.
|
567 |
+
*
|
568 |
+
* @since 3.2.5
|
569 |
+
*
|
570 |
+
* @param int $user_id
|
571 |
+
*/
|
572 |
+
static function _profile_tabs( $user_id ) {
|
573 |
+
|
574 |
+
if ( current_user_can( 'edit_users' ) ) {
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Add tabs to user profile tabs.
|
578 |
+
*
|
579 |
+
* @since 3.2.5
|
580 |
+
*
|
581 |
+
* @param array {
|
582 |
+
* @type string $tab (required)
|
583 |
+
* @type string $content (optional)
|
584 |
+
* }
|
585 |
+
*/
|
586 |
+
$tabs = apply_filters( 'wpmem_user_profile_tabs', array() );
|
587 |
+
|
588 |
+
if ( ! empty( $tabs ) ) {
|
589 |
+
?>
|
590 |
+
<script>
|
591 |
+
jQuery(document).ready(function($){
|
592 |
+
$("#wpmem_user_profile_tabs").tabs();
|
593 |
+
});
|
594 |
+
</script>
|
595 |
+
<?php
|
596 |
+
echo '<div id="wpmem_user_profile_tabs">';
|
597 |
+
echo '<ul>';
|
598 |
+
foreach ( $tabs as $key => $value ) {
|
599 |
+
echo '<li><a href="#wpmem_user_profile_tabs-' . ( $key ) . '">' . $value['tab'] . '</a></li>';
|
600 |
+
}
|
601 |
+
echo '</ul>';
|
602 |
+
foreach ( $tabs as $key => $value ) {
|
603 |
+
echo '<div id="wpmem_user_profile_tabs-' . ( $key ) . '">';
|
604 |
+
echo ( isset( $value['content'] ) ) ? $value['content'] : '';
|
605 |
+
do_action( 'wpmem_user_profile_tabs_content', $key );
|
606 |
+
echo '</div>';
|
607 |
+
}
|
608 |
+
echo '</div>';
|
609 |
+
}
|
610 |
+
}
|
611 |
+
}
|
612 |
}
|
@@ -1,1177 +1,1229 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The WP_Members_User Class.
|
4 |
-
*
|
5 |
-
* This is the WP_Members User object class. This class contains functions
|
6 |
-
* for login, logout, registration and other user related methods.
|
7 |
-
*
|
8 |
-
* @package WP-Members
|
9 |
-
* @subpackage WP_Members_User Object Class
|
10 |
-
* @since 3.0.0
|
11 |
-
*/
|
12 |
-
|
13 |
-
// Exit if accessed directly.
|
14 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
15 |
-
exit();
|
16 |
-
}
|
17 |
-
|
18 |
-
class WP_Members_User {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Container for reg form data.
|
22 |
-
*
|
23 |
-
* @since 3.1.7
|
24 |
-
* @access public
|
25 |
-
* @var array
|
26 |
-
*/
|
27 |
-
public $post_data = array();
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Container for user access information.
|
31 |
-
*
|
32 |
-
* @since 3.2.0
|
33 |
-
* @access public
|
34 |
-
* @var array
|
35 |
-
*/
|
36 |
-
public $access = array();
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Initilize the User object.
|
40 |
-
*
|
41 |
-
* @since 3.1.7
|
42 |
-
*
|
43 |
-
* @param object $settings The WP_Members Object
|
44 |
-
*/
|
45 |
-
function __construct( $settings ) {
|
46 |
-
|
47 |
-
add_action( '
|
48 |
-
|
49 |
-
add_action( 'user_register', array( $this, '
|
50 |
-
add_action( 'user_register', array( $this, '
|
51 |
-
add_action( 'user_register', array( $this, '
|
52 |
-
|
53 |
-
add_action( '
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
*
|
69 |
-
*
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
*
|
79 |
-
*
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
*
|
112 |
-
*
|
113 |
-
*
|
114 |
-
*
|
115 |
-
*
|
116 |
-
*
|
117 |
-
*
|
118 |
-
*
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
*
|
134 |
-
*
|
135 |
-
*
|
136 |
-
*
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
//
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$
|
331 |
-
$
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
$
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
//
|
488 |
-
if (
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
*
|
526 |
-
*
|
527 |
-
* @
|
528 |
-
*
|
529 |
-
* @param
|
530 |
-
*/
|
531 |
-
function
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
*
|
546 |
-
*
|
547 |
-
* @
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
*
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
*
|
602 |
-
*
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
*
|
638 |
-
*
|
639 |
-
* @
|
640 |
-
* @
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
/**
|
655 |
-
*
|
656 |
-
*
|
657 |
-
* @since 2.
|
658 |
-
* @since 3.
|
659 |
-
*
|
660 |
-
*
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
*
|
771 |
-
*
|
772 |
-
*
|
773 |
-
*
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
*
|
832 |
-
*
|
833 |
-
* @
|
834 |
-
*
|
835 |
-
* @param
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
*
|
866 |
-
*
|
867 |
-
*
|
868 |
-
*
|
869 |
-
* @
|
870 |
-
*
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
*
|
964 |
-
*
|
965 |
-
*
|
966 |
-
*
|
967 |
-
*
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
$
|
1004 |
-
$
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
*
|
1022 |
-
*
|
1023 |
-
* @since 3.2.
|
1024 |
-
* @since 3.3.0 Updated
|
1025 |
-
*
|
1026 |
-
*
|
1027 |
-
* @param
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
$
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
*
|
1113 |
-
*
|
1114 |
-
*
|
1115 |
-
*
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
*
|
1139 |
-
*
|
1140 |
-
* @
|
1141 |
-
*
|
1142 |
-
* @
|
1143 |
-
*
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
if (
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
*
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1177 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The WP_Members_User Class.
|
4 |
+
*
|
5 |
+
* This is the WP_Members User object class. This class contains functions
|
6 |
+
* for login, logout, registration and other user related methods.
|
7 |
+
*
|
8 |
+
* @package WP-Members
|
9 |
+
* @subpackage WP_Members_User Object Class
|
10 |
+
* @since 3.0.0
|
11 |
+
*/
|
12 |
+
|
13 |
+
// Exit if accessed directly.
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
15 |
+
exit();
|
16 |
+
}
|
17 |
+
|
18 |
+
class WP_Members_User {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Container for reg form data.
|
22 |
+
*
|
23 |
+
* @since 3.1.7
|
24 |
+
* @access public
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
public $post_data = array();
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Container for user access information.
|
31 |
+
*
|
32 |
+
* @since 3.2.0
|
33 |
+
* @access public
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
public $access = array();
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Initilize the User object.
|
40 |
+
*
|
41 |
+
* @since 3.1.7
|
42 |
+
*
|
43 |
+
* @param object $settings The WP_Members Object
|
44 |
+
*/
|
45 |
+
function __construct( $settings ) {
|
46 |
+
|
47 |
+
add_action( 'wpmem_after_init', array( $this, 'load_user_products' ) );
|
48 |
+
|
49 |
+
add_action( 'user_register', array( $this, 'set_reg_type' ), 1 );
|
50 |
+
add_action( 'user_register', array( $this, 'register_finalize' ), 5 );
|
51 |
+
add_action( 'user_register', array( $this, 'post_register_data' ), 9 ); // Changed this to 9 so custom user meta is saved before the default (10) priority.
|
52 |
+
add_action( 'user_register', array( $this, 'set_user_exp' ), 25 );
|
53 |
+
add_action( 'user_register', array( $this, 'register_email_to_user' ), 25 );
|
54 |
+
add_action( 'user_register', array( $this, 'register_email_to_admin' ), 25 );
|
55 |
+
|
56 |
+
add_action( 'wpmem_register_redirect', array( $this, 'register_redirect' ), 20 ); // Adds a nonce to the redirect if there is a "redirect_to" attribute in the reg form.
|
57 |
+
|
58 |
+
add_filter( 'registration_errors', array( $this, 'wp_register_validate' ), 10, 3 ); // native registration validation
|
59 |
+
|
60 |
+
// Load anything the user as access to.
|
61 |
+
if ( 1 == $settings->enable_products ) {
|
62 |
+
add_action( 'user_register', array( $this, 'set_default_product' ), 6 );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Loads the current user's membership products on init.
|
68 |
+
*
|
69 |
+
* @since 3.4.0
|
70 |
+
*/
|
71 |
+
function load_user_products() {
|
72 |
+
if ( is_user_logged_in() ) {
|
73 |
+
$this->access = wpmem_get_user_products( get_current_user_id() );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Handle user login.
|
79 |
+
*
|
80 |
+
* Built from, but replaces, the original wpmem_login() function
|
81 |
+
* from core.php. wpmem_login() is currently maintained as a
|
82 |
+
* wrapper and is the direct function called for login.
|
83 |
+
*
|
84 |
+
* @since 3.1.7
|
85 |
+
* @since 3.2.3 Removed wpmem_login_fields filter.
|
86 |
+
* @since 3.2.3 Replaced form collection with WP script to facilitate login with username OR email.
|
87 |
+
* @since 3.2.3 Changed to wp_safe_redirect().
|
88 |
+
* @since 3.3.9 Added wpmem_set_as_logged_in() to make sure user is set.
|
89 |
+
*
|
90 |
+
* @return string Returns "loginfailed" if failed login.
|
91 |
+
*/
|
92 |
+
function login() {
|
93 |
+
|
94 |
+
global $wpmem;
|
95 |
+
|
96 |
+
$user = wp_signon( array(), is_ssl() );
|
97 |
+
|
98 |
+
if ( is_wp_error( $user ) ) {
|
99 |
+
$wpmem->error = $user->get_error_message();
|
100 |
+
return "loginfailed";
|
101 |
+
} else {
|
102 |
+
|
103 |
+
// Make sure current user is set.
|
104 |
+
wpmem_set_as_logged_in( $user->ID );
|
105 |
+
|
106 |
+
$redirect_to = wpmem_get( 'redirect_to', false );
|
107 |
+
$redirect_to = ( $redirect_to ) ? esc_url_raw( trim( $redirect_to ) ) : esc_url_raw( wpmem_current_url() );
|
108 |
+
/** This filter defined in wp-login.php */
|
109 |
+
$redirect_to = apply_filters( 'login_redirect', $redirect_to, '', $user );
|
110 |
+
/**
|
111 |
+
* Filter the redirect url.
|
112 |
+
*
|
113 |
+
* This is the plugin's original redirect filter. In 3.1.7,
|
114 |
+
* WP's login_redirect filter hook was added to provide better
|
115 |
+
* integration support for other plugins and also for users
|
116 |
+
* who may already be using WP's filter(s). login_redirect
|
117 |
+
* comes first, then wpmem_login_redirect. So wpmem_login_redirect
|
118 |
+
* can be used to override a default in login_redirect.
|
119 |
+
*
|
120 |
+
* @since 2.7.7
|
121 |
+
* @since 2.9.2 Added $user_id
|
122 |
+
*
|
123 |
+
* @param string $redirect_to The url to direct to.
|
124 |
+
* @param int $user->ID The user's primary key ID.
|
125 |
+
*/
|
126 |
+
$redirect_to = apply_filters( 'wpmem_login_redirect', $redirect_to, $user->ID );
|
127 |
+
wp_safe_redirect( $redirect_to );
|
128 |
+
exit();
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Handle user logout.
|
134 |
+
*
|
135 |
+
* Built from, but replaces, the original wpmem_logout() function
|
136 |
+
* from core.php. wpmem_logout() is currently maintained as a
|
137 |
+
* wrapper and is the direct function called for logout.
|
138 |
+
*
|
139 |
+
* @since 3.1.7
|
140 |
+
* @since 3.2.0 Added logout_redirect filter
|
141 |
+
* @since 3.4.0 Added $user_id for wp_logout action (to match WP, which added this in 5.5.0).
|
142 |
+
*
|
143 |
+
* @param string $redirect_to URL to redirect the user to (default: false).
|
144 |
+
*/
|
145 |
+
function logout( $redirect_to = false ) {
|
146 |
+
|
147 |
+
// Get the user ID for when the action is fired.
|
148 |
+
$user_id = get_current_user_id();
|
149 |
+
|
150 |
+
// Default redirect URL.
|
151 |
+
$redirect_to = ( $redirect_to ) ? $redirect_to : home_url();
|
152 |
+
|
153 |
+
/** This filter is documented in /wp-login.php */
|
154 |
+
$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $redirect_to, wp_get_current_user() );
|
155 |
+
/**
|
156 |
+
* Filter where the user goes when logged out.
|
157 |
+
*
|
158 |
+
* @since 2.7.1
|
159 |
+
* @since 3.1.7 Moved to WP_Members_Users Class.
|
160 |
+
* @since 3.4.0 Added $user_id param.
|
161 |
+
*
|
162 |
+
* @param string The blog home page.
|
163 |
+
*/
|
164 |
+
$redirect_to = apply_filters( 'wpmem_logout_redirect', $redirect_to, $user_id );
|
165 |
+
|
166 |
+
wp_destroy_current_session();
|
167 |
+
wp_clear_auth_cookie();
|
168 |
+
wp_set_current_user( 0 );
|
169 |
+
|
170 |
+
/** This action is defined in /wp-includes/pluggable.php. */
|
171 |
+
do_action( 'wp_logout', $user_id );
|
172 |
+
|
173 |
+
wp_safe_redirect( $redirect_to );
|
174 |
+
exit();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Sets the registration type.
|
179 |
+
*
|
180 |
+
* @since 3.3.0
|
181 |
+
*/
|
182 |
+
function set_reg_type() {
|
183 |
+
// Is this a WP-Members registration?
|
184 |
+
$this->reg_type['is_wpmem'] = ( 'register' == wpmem_get( 'a' ) ) ? true : false;
|
185 |
+
// Is this WP's native registration? Checks the native submit button.
|
186 |
+
$this->reg_type['is_native'] = ( __( 'Register' ) == wpmem_get( 'wp-submit' ) ) ? true : false;
|
187 |
+
// Is this a Users > Add New process? Checks the post action.
|
188 |
+
$this->reg_type['is_add_new'] = ( 'createuser' == wpmem_get( 'action' ) ) ? true : false;
|
189 |
+
// Is this a WooCommerce my account registration? Checks for WC fields.
|
190 |
+
$this->reg_type['is_woo'] = ( wpmem_get( 'woocommerce-register-nonce' ) ) ? true : false;
|
191 |
+
// Is this a WooCommerce checkout?
|
192 |
+
$this->reg_type['is_woo_checkout'] = ( wpmem_get( 'woocommerce_checkout_place_order' ) ) ? true : false;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Validate user registration.
|
197 |
+
*
|
198 |
+
* @since 3.3.0
|
199 |
+
*
|
200 |
+
* @global int $user_ID
|
201 |
+
* @global string $wpmem_themsg
|
202 |
+
* @global array $userdata
|
203 |
+
*
|
204 |
+
* @param string $tag
|
205 |
+
*/
|
206 |
+
function register_validate( $tag ) {
|
207 |
+
|
208 |
+
// Get the globals.
|
209 |
+
global $user_ID, $wpmem, $wpmem_themsg, $userdata;
|
210 |
+
|
211 |
+
// Check the nonce.
|
212 |
+
if ( empty( $_POST ) || ! wp_verify_nonce( $_REQUEST[ '_wpmem_' . $tag . '_nonce' ], 'wpmem_longform_nonce' ) ) {
|
213 |
+
$wpmem_themsg = wpmem_get_text( 'reg_generic' );
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
// Make sure fields are loaded.
|
218 |
+
wpmem_fields( $tag );
|
219 |
+
|
220 |
+
// Is this a registration or a user profile update?
|
221 |
+
if ( 'register' == $tag ) {
|
222 |
+
$this->post_data['username'] = sanitize_user( wpmem_get( 'username' ) );
|
223 |
+
}
|
224 |
+
|
225 |
+
// Add the user email to the $this->post_data array for _data hooks.
|
226 |
+
if ( isset( $wpmem->fields['user_email'] ) ) {
|
227 |
+
$this->post_data['user_email'] = sanitize_email( wpmem_get( 'user_email' ) );
|
228 |
+
}
|
229 |
+
|
230 |
+
// If this is an update, and tos is a field, and the user has the correct saved value, remove tos.
|
231 |
+
if ( 'update' == $tag && isset( $wpmem->fields['tos'] ) ) {
|
232 |
+
if ( get_user_meta( $user_ID, 'tos', true ) == $wpmem->fields['tos']['checked_value'] ) {
|
233 |
+
unset( $wpmem->fields['tos'] );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
// Build the $this->post_data array from $_POST data.
|
238 |
+
foreach ( $wpmem->fields as $meta_key => $field ) {
|
239 |
+
if ( ( 'register' == $tag && true == $field['register'] ) || ( 'update' == $tag && true == $field['profile'] ) ) {
|
240 |
+
if ( 'password' != $meta_key && 'confirm_password' != $meta_key && 'username' != $meta_key ) {
|
241 |
+
if ( isset( $_POST[ $meta_key ] ) ) {
|
242 |
+
switch ( $field['type'] ) {
|
243 |
+
case 'checkbox':
|
244 |
+
$this->post_data[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
|
245 |
+
break;
|
246 |
+
case 'multiselect':
|
247 |
+
case 'multicheckbox':
|
248 |
+
$delimiter = ( isset( $field['delimiter'] ) ) ? $field['delimiter'] : '|';
|
249 |
+
$this->post_data[ $meta_key ] = ( isset( $_POST[ $meta_key ] ) ) ? implode( $delimiter, wpmem_sanitize_array( $_POST[ $meta_key ] ) ) : '';
|
250 |
+
break;
|
251 |
+
case 'textarea':
|
252 |
+
$this->post_data[ $meta_key ] = sanitize_textarea_field( $_POST[ $meta_key ] );
|
253 |
+
break;
|
254 |
+
default:
|
255 |
+
$this->post_data[ $meta_key ] = sanitize_text_field( $_POST[ $meta_key ] );
|
256 |
+
break;
|
257 |
+
}
|
258 |
+
} else {
|
259 |
+
$this->post_data[ $meta_key ] = '';
|
260 |
+
}
|
261 |
+
} else {
|
262 |
+
// We do have password as part of the registration form.
|
263 |
+
if ( isset( $_POST['password'] ) ) {
|
264 |
+
$this->post_data['password'] = $_POST['password'];
|
265 |
+
}
|
266 |
+
if ( isset( $_POST['confirm_password'] ) ) {
|
267 |
+
$this->post_data['confirm_password'] = $_POST['confirm_password'];
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Filter the submitted form fields prior to validation.
|
275 |
+
*
|
276 |
+
* @since 2.8.2
|
277 |
+
* @since 3.1.7 Added $tag
|
278 |
+
* @since 3.2.0 Moved to regiser_validate() method in user object class.
|
279 |
+
*
|
280 |
+
* @param array $this->post_data An array of the posted form field data.
|
281 |
+
* @param string $tag
|
282 |
+
*/
|
283 |
+
$this->post_data = apply_filters( 'wpmem_pre_validate_form', $this->post_data, $tag );
|
284 |
+
|
285 |
+
// Adds integration for custom error codes triggered by "register_post" or contained in "registration_errors"
|
286 |
+
// @todo This will move towards integrating all WP-Members registration errors into the "registration_errors" filter
|
287 |
+
// and allow for more standardized custom validation.
|
288 |
+
$errors = new WP_Error();
|
289 |
+
do_action( 'register_post', $sanitized_user_login, $user_email, $errors );
|
290 |
+
$errors = apply_filters( 'registration_errors', $errors, $this->post_data['username'], $this->post_data['user_email'] );
|
291 |
+
if ( count( $errors->get_error_messages() ) > 0 ) {
|
292 |
+
$wpmem_themsg = $errors->get_error_message();
|
293 |
+
return;
|
294 |
+
}
|
295 |
+
|
296 |
+
if ( 'update' == $tag ) {
|
297 |
+
$pass_arr = array( 'username', 'password', 'confirm_password', 'password_confirm' );
|
298 |
+
foreach ( $pass_arr as $pass ) {
|
299 |
+
unset( $wpmem->fields[ $pass ] );
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
// Check for required fields, reverse the array for logical error message order.
|
304 |
+
foreach ( array_reverse( $wpmem->fields ) as $meta_key => $field ) {
|
305 |
+
// Validation if the field is required.
|
306 |
+
if ( true == $field['required'] ) {
|
307 |
+
if ( 'file' == $field['type'] || 'image' == $field['type'] ) {
|
308 |
+
// If this is a new registration.
|
309 |
+
if ( 'register' == $tag ) {
|
310 |
+
// If the required field is a file type.
|
311 |
+
if ( empty( $_FILES[ $meta_key ]['name'] ) ) {
|
312 |
+
$wpmem_themsg = sprintf( wpmem_get_text( 'reg_empty_field' ), __( $field['label'], 'wp-members' ) );
|
313 |
+
}
|
314 |
+
}
|
315 |
+
} else {
|
316 |
+
// If the required field is any other field type.
|
317 |
+
if ( ( 'register' == $tag && true == $field['register'] ) || ( 'update' == $tag && true == $field['profile'] ) ) {
|
318 |
+
if ( null == $this->post_data[ $meta_key ] ) {
|
319 |
+
$wpmem_themsg = sprintf( wpmem_get_text( 'reg_empty_field' ), __( $field['label'], 'wp-members' ) );
|
320 |
+
}
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
// Validate file field type.
|
326 |
+
if ( 'file' == $field['type'] || 'image' == $field['type'] ) {
|
327 |
+
if ( '' == $field['file_types'] ) {
|
328 |
+
$field['file_types'] = ( 'image' == $field['type'] ) ? 'gif|png|jpg|jpeg|bmp' : 'doc|docx|pdf|zip';
|
329 |
+
}
|
330 |
+
$allowed_file_types = explode( '|', $field['file_types'] );
|
331 |
+
$msg_types = implode( ', ', $allowed_file_types );
|
332 |
+
if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) {
|
333 |
+
$extension = pathinfo( $_FILES[ $meta_key ]['name'], PATHINFO_EXTENSION );
|
334 |
+
if ( ! in_array( $extension, $allowed_file_types ) ) {
|
335 |
+
$wpmem_themsg = sprintf( wpmem_get_text( 'reg_file_type' ), __( $field['label'], 'wp-members' ), str_replace( '|', ',', $msg_types ) );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
if ( 'register' == $tag ) {
|
342 |
+
if ( is_multisite() ) {
|
343 |
+
// Multisite has different requirements.
|
344 |
+
$result = wpmu_validate_user_signup( $this->post_data['username'], $this->post_data['user_email'] );
|
345 |
+
$errors = $result['errors'];
|
346 |
+
if ( $errors->errors ) {
|
347 |
+
$wpmem_themsg = $errors->get_error_message();
|
348 |
+
return $wpmem_themsg;
|
349 |
+
exit();
|
350 |
+
}
|
351 |
+
|
352 |
+
} else {
|
353 |
+
// Validate username and email fields.
|
354 |
+
$wpmem_themsg = ( email_exists( $this->post_data['user_email'] ) ) ? "email" : $wpmem_themsg;
|
355 |
+
$wpmem_themsg = ( username_exists( $this->post_data['username'] ) ) ? "user" : $wpmem_themsg;
|
356 |
+
$wpmem_themsg = ( ! is_email( $this->post_data['user_email']) ) ? wpmem_get_text( 'reg_valid_email' ) : $wpmem_themsg;
|
357 |
+
$wpmem_themsg = ( ! validate_username( $this->post_data['username'] ) ) ? wpmem_get_text( 'reg_non_alphanumeric' ) : $wpmem_themsg;
|
358 |
+
$wpmem_themsg = ( ! $this->post_data['username'] ) ? wpmem_get_text( 'reg_empty_username' ) : $wpmem_themsg;
|
359 |
+
|
360 |
+
// If there is an error from username, email, or required field validation, stop registration and return the error.
|
361 |
+
if ( $wpmem_themsg ) {
|
362 |
+
return $wpmem_themsg;
|
363 |
+
exit();
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
// If form contains password and email confirmation, validate that they match.
|
368 |
+
if ( array_key_exists( 'confirm_password', $this->post_data ) && $this->post_data['confirm_password'] != $this->post_data ['password'] ) {
|
369 |
+
$wpmem_themsg = wpmem_get_text( 'reg_password_match' );
|
370 |
+
}
|
371 |
+
if ( array_key_exists( 'confirm_email', $this->post_data ) && $this->post_data['confirm_email'] != $this->post_data ['user_email'] ) {
|
372 |
+
$wpmem_themsg = wpmem_get_text( 'reg_email_match' );
|
373 |
+
}
|
374 |
+
|
375 |
+
// Process CAPTCHA.
|
376 |
+
if ( 0 != $wpmem->captcha ) {
|
377 |
+
$check_captcha = WP_Members_Captcha::validate();
|
378 |
+
if ( false === $check_captcha ) {
|
379 |
+
return "empty"; // @todo Return and/or set error object. For now changed to return original value.
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
// Check for user defined password.
|
384 |
+
$this->post_data['password'] = wpmem_get( 'password', wp_generate_password() );
|
385 |
+
|
386 |
+
// Add for _data hooks
|
387 |
+
$this->post_data['user_registered'] = current_time( 'mysql', 1 );
|
388 |
+
$this->post_data['user_role'] = get_option( 'default_role' );
|
389 |
+
$this->post_data['wpmem_reg_ip'] = wpmem_get_user_ip();
|
390 |
+
$this->post_data['wpmem_reg_url'] = esc_url_raw( wpmem_get( 'wpmem_reg_page', wpmem_get( 'redirect_to', false, 'request' ), 'request' ) );
|
391 |
+
|
392 |
+
/*
|
393 |
+
* These native fields are not installed by default, but if they
|
394 |
+
* are added, use the $_POST value - otherwise, default to username.
|
395 |
+
* Value can be filtered with wpmem_register_data.
|
396 |
+
*/
|
397 |
+
$this->post_data['user_nicename'] = sanitize_title( wpmem_get( 'user_nicename', $this->post_data['username'] ) );
|
398 |
+
$this->post_data['display_name'] = sanitize_text_field( wpmem_get( 'display_name', $this->post_data['username'] ) );
|
399 |
+
$this->post_data['nickname'] = sanitize_text_field( wpmem_get( 'nickname', $this->post_data['username'] ) );
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Validates registration fields in the native WP registration.
|
405 |
+
*
|
406 |
+
* @since 2.8.3
|
407 |
+
* @since 3.3.0 Ported from wpmem_wp_reg_validate() in wp-registration.php.
|
408 |
+
*
|
409 |
+
* @global object $wpmem The WP-Members object class.
|
410 |
+
*
|
411 |
+
* @param array $errors A WP_Error object containing any errors encountered during registration.
|
412 |
+
* @param string $sanitized_user_login User's username after it has been sanitized.
|
413 |
+
* @param string $user_email User's email.
|
414 |
+
* @return array $errors A WP_Error object containing any errors encountered during registration.
|
415 |
+
*/
|
416 |
+
function wp_register_validate( $errors, $sanitized_user_login, $user_email ) {
|
417 |
+
|
418 |
+
global $wpmem;
|
419 |
+
|
420 |
+
// Get any meta fields that should be excluded.
|
421 |
+
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
422 |
+
|
423 |
+
foreach ( wpmem_fields( 'register_wp' ) as $meta_key => $field ) {
|
424 |
+
$is_error = false;
|
425 |
+
if ( true == $field['required'] && true == $field['register'] && $meta_key != 'user_email' && ! in_array( $meta_key, $exclude ) ) {
|
426 |
+
if ( ( $field['type'] == 'checkbox' || $field['type'] == 'multicheckbox' || $field['type'] == 'multiselect' || $field['type'] == 'radio' ) && ( ! isset( $_POST[ $meta_key ] ) ) ) {
|
427 |
+
$is_error = true;
|
428 |
+
}
|
429 |
+
if ( ( $field['type'] != 'checkbox' && $field['type'] != 'multicheckbox' && $field['type'] != 'multiselect' && $field['type'] != 'radio' ) && ( ! $_POST[ $meta_key ] ) ) {
|
430 |
+
$is_error = true;
|
431 |
+
}
|
432 |
+
if ( $is_error ) {
|
433 |
+
$errors->add( 'wpmem_error', sprintf( wpmem_get_text( 'reg_empty_field' ), __( $field['label'], 'wp-members' ) ) );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
// Process CAPTCHA.
|
439 |
+
if ( $wpmem->captcha > 0 ) {
|
440 |
+
$check_captcha = WP_Members_Captcha::validate();
|
441 |
+
if ( false === $check_captcha ) {
|
442 |
+
$errors->add( 'wpmem_captcha_error', sprintf( wpmem_get_text( 'reg_captcha_err' ), __( $field['label'], 'wp-members' ) ) );
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
return $errors;
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* User registration functions.
|
451 |
+
*
|
452 |
+
* @since 3.1.7
|
453 |
+
* @since 3.2.6 Added handler for membership field type.
|
454 |
+
* @since 3.3.0 Changed from register() to register_finalize().
|
455 |
+
*
|
456 |
+
* @global object $wpmem
|
457 |
+
* @param int $user_id
|
458 |
+
*/
|
459 |
+
function register_finalize( $user_id ) {
|
460 |
+
|
461 |
+
global $wpmem;
|
462 |
+
|
463 |
+
// If this is WP-Members registration.
|
464 |
+
if ( $this->reg_type['is_wpmem'] ) {
|
465 |
+
// Put user ID into post_data array.
|
466 |
+
$this->post_data['ID'] = $user_id;
|
467 |
+
|
468 |
+
// Set remaining fields to wp_usermeta table.
|
469 |
+
$new_user_fields_meta = array( 'user_url', 'first_name', 'last_name', 'description' );
|
470 |
+
foreach ( $wpmem->fields as $meta_key => $field ) {
|
471 |
+
// If the field is not excluded, update accordingly.
|
472 |
+
if ( ! in_array( $meta_key, wpmem_get_excluded_meta( 'register' ) ) && ! in_array( $meta_key, $new_user_fields_meta ) ) {
|
473 |
+
if ( $field['register'] && 'user_email' != $meta_key ) {
|
474 |
+
// Assign memberships, if applicable.
|
475 |
+
if ( 'membership' == $field['type'] && 1 == $wpmem->enable_products ) {
|
476 |
+
wpmem_set_user_product( $this->post_data[ $meta_key ], $user_id );
|
477 |
+
} else {
|
478 |
+
update_user_meta( $user_id, $meta_key, $this->post_data[ $meta_key ] );
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
// Store the registration url.
|
485 |
+
update_user_meta( $user_id, 'wpmem_reg_url', $this->post_data['wpmem_reg_url'] );
|
486 |
+
|
487 |
+
// Handle file uploads, if any.
|
488 |
+
if ( ! empty( $_FILES ) ) {
|
489 |
+
$this->upload_user_files( $user_id, $wpmem->fields );
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
// If this is native WP (wp-login.php), Users > Add New, or WooCommerce registration.
|
494 |
+
if ( $this->reg_type['is_native'] || $this->reg_type['is_add_new'] || $this->reg_type['is_woo'] ) {
|
495 |
+
// Get any excluded meta fields.
|
496 |
+
$exclude = wpmem_get_excluded_meta( 'wp-register' );
|
497 |
+
foreach ( wpmem_fields( 'register_wp' ) as $meta_key => $field ) {
|
498 |
+
$value = wpmem_get( $meta_key, false );
|
499 |
+
if ( false !== $value && ! in_array( $meta_key, $exclude ) && 'file' != $field['type'] && 'image' != $field['type'] ) {
|
500 |
+
if ( 'multiselect' == $field['type'] || 'multicheckbox' == $field['type'] ) {
|
501 |
+
$value = implode( $field['delimiter'], $value );
|
502 |
+
}
|
503 |
+
$sanitized_value = sanitize_text_field( $value );
|
504 |
+
update_user_meta( $user_id, $meta_key, $sanitized_value );
|
505 |
+
}
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
// If this is Users > Add New.
|
510 |
+
if ( is_admin() && $this->reg_type['is_add_new'] ) {
|
511 |
+
// If moderated registration and activate is checked, set active flags.
|
512 |
+
if ( 1 == $wpmem->mod_reg && isset( $_POST['activate_user'] ) ) {
|
513 |
+
update_user_meta( $user_id, 'active', 1 );
|
514 |
+
wpmem_set_user_status( $user_id, 0 );
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
// Capture IP address of all users at registration.
|
519 |
+
$user_ip = ( $this->reg_type['is_wpmem'] ) ? $this->post_data['wpmem_reg_ip'] : wpmem_get_user_ip();
|
520 |
+
update_user_meta( $user_id, 'wpmem_reg_ip', $user_ip );
|
521 |
+
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* Fires wpmem_post_register_data action.
|
526 |
+
*
|
527 |
+
* @since 3.3.2
|
528 |
+
*
|
529 |
+
* @param int $user_id
|
530 |
+
*/
|
531 |
+
function post_register_data( $user_id ) {
|
532 |
+
$this->post_data['ID'] = $user_id;
|
533 |
+
/**
|
534 |
+
* Fires after user insertion but before email.
|
535 |
+
*
|
536 |
+
* @since 2.7.2
|
537 |
+
* @since 3.3.2 Hooked to user_register.
|
538 |
+
*
|
539 |
+
* @param array $this->post_data The user's submitted registration data.
|
540 |
+
*/
|
541 |
+
do_action( 'wpmem_post_register_data', $this->post_data );
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Sends emails on registration.
|
546 |
+
*
|
547 |
+
* @since 3.3.0
|
548 |
+
*
|
549 |
+
* @global object $wpmem
|
550 |
+
*
|
551 |
+
* @param int $user_id
|
552 |
+
*/
|
553 |
+
function register_email_to_user( $user_id ) {
|
554 |
+
global $wpmem;
|
555 |
+
if ( $this->reg_type['is_wpmem'] ) {
|
556 |
+
// @todo Work out a better method for this so that it is optional and can be turned on/off for native reg
|
557 |
+
// Send a notification email to the user.
|
558 |
+
wpmem_email_to_user( $user_id, $this->post_data['password'], $wpmem->mod_reg, $wpmem->fields, $this->post_data );
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Sends admin notifiction on registration.
|
564 |
+
*
|
565 |
+
* @since 3.3.0
|
566 |
+
*
|
567 |
+
* @global object $wpmem
|
568 |
+
*
|
569 |
+
* @param int $user_id
|
570 |
+
*/
|
571 |
+
function register_email_to_admin( $user_id ) {
|
572 |
+
global $wpmem;
|
573 |
+
if ( $this->reg_type['is_wpmem'] ) {
|
574 |
+
// @todo Work out a better method for this so that it is optional and can be turned on/off for native reg
|
575 |
+
// Notify admin of new reg, if needed.
|
576 |
+
if ( 1 == $wpmem->notify ) {
|
577 |
+
$wpmem->email->notify_admin( $user_id, $wpmem->fields, $this->post_data );
|
578 |
+
}
|
579 |
+
}
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* Redirects user on registration.
|
584 |
+
*
|
585 |
+
* @since 3.1.7
|
586 |
+
*/
|
587 |
+
function register_redirect() {
|
588 |
+
$redirect_to = wpmem_get( 'redirect_to', false );
|
589 |
+
if ( $redirect_to ) {
|
590 |
+
$nonce_url = wp_nonce_url( $redirect_to, 'register_redirect', 'reg_nonce' );
|
591 |
+
wp_safe_redirect( $nonce_url );
|
592 |
+
exit();
|
593 |
+
}
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* Password change or reset.
|
598 |
+
*
|
599 |
+
* @since 3.1.7
|
600 |
+
*
|
601 |
+
* @param string $action
|
602 |
+
* @return string $result
|
603 |
+
*/
|
604 |
+
function password_update( $action ) {
|
605 |
+
if ( isset( $_POST['formsubmit'] ) ) {
|
606 |
+
if ( 'reset' == $action ) {
|
607 |
+
$args = array(
|
608 |
+
'user' => sanitize_user( wpmem_get( 'user', false ) ),
|
609 |
+
'email' => sanitize_email( wpmem_get( 'email', false ) ),
|
610 |
+
);
|
611 |
+
} else {
|
612 |
+
$args = array(
|
613 |
+
'pass1' => wpmem_get( 'pass1', false ),
|
614 |
+
'pass2' => wpmem_get( 'pass2', false ),
|
615 |
+
);
|
616 |
+
}
|
617 |
+
return ( 'reset' == $action ) ? $this->password_reset( $args ) : $this->password_change( $args );
|
618 |
+
}
|
619 |
+
return;
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Change a user's password()
|
624 |
+
*
|
625 |
+
* @since 3.1.7
|
626 |
+
*
|
627 |
+
* @return
|
628 |
+
*/
|
629 |
+
function password_change( $args ) {
|
630 |
+
global $user_ID;
|
631 |
+
$is_error = false;
|
632 |
+
// Check for both fields being empty.
|
633 |
+
$is_error = ( ! $args['pass1'] && ! $args['pass2'] ) ? "pwdchangempty" : $is_error;
|
634 |
+
// Make sure the fields match.
|
635 |
+
$is_error = ( $args['pass1'] != $args['pass2'] ) ? "pwdchangerr" : $is_error;
|
636 |
+
/**
|
637 |
+
* Filters the password change error.
|
638 |
+
*
|
639 |
+
* @since 3.1.5
|
640 |
+
* @since 3.1.7 Moved to user object.
|
641 |
+
*
|
642 |
+
* @param string $is_error
|
643 |
+
* @param int $user_ID The user's numeric ID.
|
644 |
+
* @param string $args['pass1'] The user's new plain text password.
|
645 |
+
*/
|
646 |
+
$is_error = apply_filters( 'wpmem_pwd_change_error', $is_error, $user_ID, $args['pass1'] );
|
647 |
+
// User must be logged in.
|
648 |
+
$is_error = ( ! is_user_logged_in() ) ? "loggedin" : $is_error;
|
649 |
+
// Verify nonce.
|
650 |
+
$is_error = ( ! wp_verify_nonce( $_REQUEST['_wpmem_pwdchange_nonce'], 'wpmem_shortform_nonce' ) ) ? "reg_generic" : $is_error;
|
651 |
+
if ( $is_error ) {
|
652 |
+
return $is_error;
|
653 |
+
}
|
654 |
+
/**
|
655 |
+
* Fires after password change.
|
656 |
+
*
|
657 |
+
* @since 2.9.0
|
658 |
+
* @since 3.0.5 Added $args['pass1'] to arguments passed.
|
659 |
+
* @since 3.1.7 Moved to user object.
|
660 |
+
*
|
661 |
+
* @param int $user_ID The user's numeric ID.
|
662 |
+
* @param string $args['pass1'] The user's new plain text password.
|
663 |
+
*/
|
664 |
+
do_action( 'wpmem_pwd_change', $user_ID, $args['pass1'] );
|
665 |
+
return "pwdchangesuccess";
|
666 |
+
}
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Reset a user's password.
|
670 |
+
*
|
671 |
+
* @since 3.1.7
|
672 |
+
*
|
673 |
+
*/
|
674 |
+
function password_reset( $args ) {
|
675 |
+
global $wpmem;
|
676 |
+
/**
|
677 |
+
* Filter the password reset arguments.
|
678 |
+
*
|
679 |
+
* @since 2.7.1
|
680 |
+
* @since 3.1.7 Moved to user object.
|
681 |
+
*
|
682 |
+
* @param array The username and email.
|
683 |
+
*/
|
684 |
+
$arr = apply_filters( 'wpmem_pwdreset_args', $args );
|
685 |
+
if ( ! $arr['user'] || ! $arr['email'] ) {
|
686 |
+
// There was an empty field.
|
687 |
+
return "pwdreseterr";
|
688 |
+
|
689 |
+
} else {
|
690 |
+
|
691 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpmem_pwdreset_nonce'], 'wpmem_shortform_nonce' ) ) {
|
692 |
+
return "reg_generic";
|
693 |
+
}
|
694 |
+
if ( username_exists( $arr['user'] ) ) {
|
695 |
+
$user = get_user_by( 'login', $arr['user'] );
|
696 |
+
if ( strtolower( $user->user_email ) !== strtolower( $arr['email'] ) || ( ( $wpmem->mod_reg == 1 ) && ( get_user_meta( $user->ID, 'active', true ) != 1 ) ) ) {
|
697 |
+
// The username was there, but the email did not match OR the user hasn't been activated.
|
698 |
+
return "pwdreseterr";
|
699 |
+
} else {
|
700 |
+
// Generate a new password.
|
701 |
+
$new_pass = wp_generate_password();
|
702 |
+
// Update the users password.
|
703 |
+
wp_set_password( $new_pass, $user->ID );
|
704 |
+
// Send it in an email.
|
705 |
+
wpmem_email_to_user( $user->ID, $new_pass, 3 );
|
706 |
+
/**
|
707 |
+
* Fires after password reset.
|
708 |
+
*
|
709 |
+
* @since 2.9.0
|
710 |
+
* @since 3.0.5 Added $new_pass to arguments passed.
|
711 |
+
* @since 3.1.7 Moved to user object.
|
712 |
+
*
|
713 |
+
* @param int $user_ID The user's numeric ID.
|
714 |
+
* @param string $new_pass The new plain text password.
|
715 |
+
*/
|
716 |
+
do_action( 'wpmem_pwd_reset', $user->ID, $new_pass );
|
717 |
+
return "pwdresetsuccess";
|
718 |
+
}
|
719 |
+
} else {
|
720 |
+
// Username did not exist.
|
721 |
+
return "pwdreseterr";
|
722 |
+
}
|
723 |
+
}
|
724 |
+
return;
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Handles retrieving a forgotten username.
|
729 |
+
*
|
730 |
+
* @since 3.0.8
|
731 |
+
* @since 3.1.6 Dependencies now loaded by object.
|
732 |
+
* @since 3.1.8 Moved to user object.
|
733 |
+
*
|
734 |
+
* @global object $wpmem
|
735 |
+
* @return string $regchk The regchk value.
|
736 |
+
*/
|
737 |
+
function retrieve_username() {
|
738 |
+
global $wpmem;
|
739 |
+
if ( isset( $_POST['formsubmit'] ) ) {
|
740 |
+
|
741 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpmem_getusername_nonce'], 'wpmem_shortform_nonce' ) ) {
|
742 |
+
return "reg_generic";
|
743 |
+
}
|
744 |
+
|
745 |
+
$email = sanitize_email( $_POST['user_email'] );
|
746 |
+
$user = ( isset( $_POST['user_email'] ) ) ? get_user_by( 'email', $email ) : false;
|
747 |
+
if ( $user ) {
|
748 |
+
// Send it in an email.
|
749 |
+
wpmem_email_to_user( $user->ID, '', 4 );
|
750 |
+
/**
|
751 |
+
* Fires after retrieving username.
|
752 |
+
*
|
753 |
+
* @since 3.0.8
|
754 |
+
*
|
755 |
+
* @param int $user_ID The user's numeric ID.
|
756 |
+
*/
|
757 |
+
do_action( 'wpmem_get_username', $user->ID );
|
758 |
+
return 'usernamesuccess';
|
759 |
+
} else {
|
760 |
+
return 'usernamefailed';
|
761 |
+
}
|
762 |
+
}
|
763 |
+
return;
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Handle user file uploads for registration and profile update.
|
768 |
+
*
|
769 |
+
* @since 3.1.8
|
770 |
+
* @since 3.2.6 Add file's post ID to $this->post_data.
|
771 |
+
*
|
772 |
+
* @param string $user_id
|
773 |
+
* @param array $fields
|
774 |
+
*/
|
775 |
+
function upload_user_files( $user_id, $fields ) {
|
776 |
+
global $wpmem;
|
777 |
+
foreach ( $fields as $meta_key => $field ) {
|
778 |
+
if ( ( 'file' == $field['type'] || 'image' == $field['type'] ) && isset( $_FILES[ $meta_key ] ) && is_array( $_FILES[ $meta_key ] ) ) {
|
779 |
+
if ( ! empty( $_FILES[ $meta_key ]['name'] ) ) {
|
780 |
+
// Upload the file and save it as an attachment.
|
781 |
+
$file_post_id = $wpmem->forms->do_file_upload( $_FILES[ $meta_key ], $user_id );
|
782 |
+
// Save the attachment ID as user meta.
|
783 |
+
update_user_meta( $user_id, $meta_key, $file_post_id );
|
784 |
+
// Add attachement ID to post data array.
|
785 |
+
$this->post_data[ $meta_key ] = $file_post_id;
|
786 |
+
}
|
787 |
+
}
|
788 |
+
}
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Get user data for all fields in WP-Members.
|
793 |
+
*
|
794 |
+
* Retrieves user data for all WP-Members fields (and WP default fields)
|
795 |
+
* in an array keyed by WP-Members field meta keys.
|
796 |
+
*
|
797 |
+
* @since 3.2.0
|
798 |
+
* @since 3.2.6 Added option for "all" fields (default:false).
|
799 |
+
*
|
800 |
+
* @param string $user_id optional (defaults to current user)
|
801 |
+
* @param string $all optional (default to false)
|
802 |
+
* @return array $user_fields
|
803 |
+
*/
|
804 |
+
function user_data( $user_id = false, $all = false ) {
|
805 |
+
$user_id = ( $user_id ) ? $user_id : get_current_user_id();
|
806 |
+
if ( true == $all ) {
|
807 |
+
$user_info = get_user_meta( $user_id );
|
808 |
+
foreach( $user_info as $key => $value ) {
|
809 |
+
$formatted = maybe_unserialize( $value[0] );
|
810 |
+
$user_fields[ $key ] = $formatted;
|
811 |
+
}
|
812 |
+
} else {
|
813 |
+
$fields = wpmem_fields();
|
814 |
+
$user_data = get_userdata( $user_id );
|
815 |
+
$excludes = array( 'first_name', 'last_name', 'description', 'nickname' );
|
816 |
+
foreach ( $fields as $meta => $field ) {
|
817 |
+
$meta = ( 'username' == $meta ) ? 'user_login' : $meta;
|
818 |
+
if ( $field['native'] == 1 && ! in_array( $meta, $excludes ) ) {
|
819 |
+
$user_fields[ $meta ] = $user_data->data->{$meta};
|
820 |
+
} else {
|
821 |
+
$user_fields[ $meta ] = get_user_meta( $user_id, $meta, true );
|
822 |
+
}
|
823 |
+
}
|
824 |
+
}
|
825 |
+
return $user_fields;
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Sets the role for the specified user.
|
830 |
+
*
|
831 |
+
* @since 3.2.0
|
832 |
+
*
|
833 |
+
* @param integer $user_id
|
834 |
+
* @param string $role
|
835 |
+
* @param string $action (set|add|remove)
|
836 |
+
*/
|
837 |
+
public function update_user_role( $user_id, $role, $action = 'set' ) {
|
838 |
+
$user = new WP_User( $user_id );
|
839 |
+
switch ( $action ) {
|
840 |
+
case 'add':
|
841 |
+
$user->add_role( $role );
|
842 |
+
break;
|
843 |
+
case 'remove':
|
844 |
+
$user->remove_role( $role );
|
845 |
+
break;
|
846 |
+
default:
|
847 |
+
$user->set_role( $role );
|
848 |
+
break;
|
849 |
+
}
|
850 |
+
}
|
851 |
+
|
852 |
+
/**
|
853 |
+
* Sets a user's password.
|
854 |
+
*
|
855 |
+
* @since 3.2.3
|
856 |
+
*
|
857 |
+
* @param int $user_id
|
858 |
+
* @param string $password
|
859 |
+
*/
|
860 |
+
function set_password( $user_id, $password ) {
|
861 |
+
wp_set_password( $password, $user_id );
|
862 |
+
}
|
863 |
+
|
864 |
+
/**
|
865 |
+
* Sets user as logged on password change.
|
866 |
+
*
|
867 |
+
* (Hooked to wpmem_pwd_change)
|
868 |
+
*
|
869 |
+
* @since 3.2.0
|
870 |
+
*
|
871 |
+
* @param int $user_id
|
872 |
+
* @param string $password
|
873 |
+
*/
|
874 |
+
function set_as_logged_in( $user_id ) {
|
875 |
+
$user = get_user_by( 'id', $user_id );
|
876 |
+
wp_set_current_user( $user_id, $user->user_login );
|
877 |
+
wp_set_auth_cookie( $user_id, wpmem_get( 'rememberme', false, 'request' ) );
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Validates user access to content.
|
882 |
+
*
|
883 |
+
* @since 3.2.0
|
884 |
+
* @todo Currently checks in this order: expiration, role, "other". If expiration product,
|
885 |
+
* and the user is current, then access is granted. This doesn't consider if the
|
886 |
+
* user is current but does not have a required role (if BOTH an expiration and role
|
887 |
+
* product). Maybe add role checking to the expiration block if both exist.
|
888 |
+
*
|
889 |
+
* @global object $wpmem
|
890 |
+
* @param mixed $product Accepts a single membership slug/meta, or an array of multiple memberships.
|
891 |
+
* @param int $user_id (optional)
|
892 |
+
* @return bool $access
|
893 |
+
*/
|
894 |
+
function has_access( $product, $user_id = false ) {
|
895 |
+
global $wpmem;
|
896 |
+
if ( false === $user_id && ! is_user_logged_in() ) {
|
897 |
+
return false;
|
898 |
+
}
|
899 |
+
|
900 |
+
// Product must be an array.
|
901 |
+
$product_array = ( ! is_array( $product ) ) ? array( $product ) : $product;
|
902 |
+
|
903 |
+
$product_array = $this->get_product_children( $product_array );
|
904 |
+
|
905 |
+
// Current user or requested user.
|
906 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
907 |
+
|
908 |
+
// Load user memberships array.
|
909 |
+
$memberships = ( false == $user_id ) ? $this->access : wpmem_get_user_products( $user_id );
|
910 |
+
|
911 |
+
// Start by assuming no access.
|
912 |
+
$access = false;
|
913 |
+
|
914 |
+
foreach ( $product_array as $prod ) {
|
915 |
+
$expiration_product = false;
|
916 |
+
$role_product = false;
|
917 |
+
if ( isset( $memberships[ $prod ] ) ) {
|
918 |
+
// Is this an expiration product?
|
919 |
+
if ( isset( $wpmem->membership->products[ $prod ]['expires'][0] ) && ! is_bool( $memberships[ $prod ] ) ) {
|
920 |
+
$expiration_product = true;
|
921 |
+
if ( $this->is_current( $memberships[ $prod ] ) ) {
|
922 |
+
$access = true;
|
923 |
+
break;
|
924 |
+
}
|
925 |
+
}
|
926 |
+
// Is this a role product?
|
927 |
+
if ( '' != $wpmem->membership->products[ $prod ]['role'] ) {
|
928 |
+
$role_product = true;
|
929 |
+
if ( $memberships[ $prod ] && wpmem_user_has_role( $wpmem->membership->products[ $prod ]['role'] ) ) {
|
930 |
+
if ( $expiration_product && ! $this->is_current( $memberships[ $prod ] ) ) {
|
931 |
+
$access = false;
|
932 |
+
break;
|
933 |
+
}
|
934 |
+
$access = true;
|
935 |
+
break;
|
936 |
+
}
|
937 |
+
}
|
938 |
+
if ( ! $expiration_product && ! $role_product && $memberships[ $prod ] ) {
|
939 |
+
$access = true;
|
940 |
+
break;
|
941 |
+
}
|
942 |
+
}
|
943 |
+
}
|
944 |
+
|
945 |
+
/**
|
946 |
+
* Filter the access result.
|
947 |
+
*
|
948 |
+
* @since 3.2.0
|
949 |
+
* @since 3.2.3 Added $product argument.
|
950 |
+
*
|
951 |
+
* @param boolean $access
|
952 |
+
* @param array $product
|
953 |
+
* @param integer $user_id
|
954 |
+
* @param array $args
|
955 |
+
*/
|
956 |
+
return apply_filters( 'wpmem_user_has_access', $access, $product_array, $user_id );
|
957 |
+
|
958 |
+
}
|
959 |
+
|
960 |
+
/**
|
961 |
+
* Gets product children (if any).
|
962 |
+
*
|
963 |
+
* @since 3.4.0
|
964 |
+
*
|
965 |
+
* @global stdClass $wpmem
|
966 |
+
* @param array $product_array
|
967 |
+
* $return array $product_array Product array with child products added.
|
968 |
+
*/
|
969 |
+
function get_product_children( $product_array ) {
|
970 |
+
|
971 |
+
global $wpmem;
|
972 |
+
$membership_ids = array_flip( $wpmem->membership->product_by_id );
|
973 |
+
foreach ( $product_array as $product ) {
|
974 |
+
$args = array(
|
975 |
+
'post_type' => $wpmem->membership->post_type,
|
976 |
+
'post_parent' => $membership_ids[ $product ], // Current post's ID
|
977 |
+
);
|
978 |
+
$children = get_children( $args );
|
979 |
+
if ( ! empty( $children ) ) {
|
980 |
+
foreach ( $children as $child ) {
|
981 |
+
$product_array[] = $child->post_name;
|
982 |
+
}
|
983 |
+
}
|
984 |
+
}
|
985 |
+
|
986 |
+
return $product_array;
|
987 |
+
}
|
988 |
+
|
989 |
+
/**
|
990 |
+
* Loads anything the user has access to.
|
991 |
+
*
|
992 |
+
* @since 3.2.0
|
993 |
+
* @since 3.2.6 Updated to return empty array if no products exist for this user.
|
994 |
+
* @since 3.3.0 Updated to use individual meta for product access.
|
995 |
+
*
|
996 |
+
* @global object $wpmem
|
997 |
+
*
|
998 |
+
* @param int $user_id
|
999 |
+
* @return array $products
|
1000 |
+
*/
|
1001 |
+
function get_user_products( $user_id = false, $obj = false ) {
|
1002 |
+
global $wpmem;
|
1003 |
+
$product_array = ( $obj ) ? $obj->membership->products : $wpmem->membership->products;
|
1004 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
1005 |
+
foreach ( $product_array as $product_meta => $product ) {
|
1006 |
+
$user_product = get_user_meta( $user_id, '_wpmem_products_' . $product_meta, true );
|
1007 |
+
if ( $user_product ) {
|
1008 |
+
$products[ $product_meta ] = $user_product;
|
1009 |
+
}
|
1010 |
+
$user_product = '';
|
1011 |
+
}
|
1012 |
+
return ( isset( $products ) ) ? $products : array();
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
/**
|
1016 |
+
* Sets a product as active for a user.
|
1017 |
+
*
|
1018 |
+
* If the product expires, it sets an expiration date
|
1019 |
+
* based on the time period. Otherwise the value is
|
1020 |
+
* set to "true" (which does not expire).
|
1021 |
+
*
|
1022 |
+
* @since 3.2.0
|
1023 |
+
* @since 3.2.6 Added $date to set a specific expiration date.
|
1024 |
+
* @since 3.3.0 Updated to new single meta, keeps legacy array for rollback.
|
1025 |
+
* @since 3.3.1 Added no gap renewal option, @todo Needs some possible condensing.
|
1026 |
+
*
|
1027 |
+
* @param string $product
|
1028 |
+
* @param int $user_id
|
1029 |
+
* @param string $set_date Formatted date should be MySQL timestamp, or simply YYYY-MM-DD.
|
1030 |
+
*/
|
1031 |
+
function set_user_product( $product, $user_id = false, $set_date = false ) {
|
1032 |
+
|
1033 |
+
global $wpmem;
|
1034 |
+
|
1035 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
1036 |
+
|
1037 |
+
// New single meta format. @todo This remains when legacy array is removed.
|
1038 |
+
$prev_value = get_user_meta( $user_id, '_wpmem_products_' . $product, true );
|
1039 |
+
|
1040 |
+
// Convert date to add.
|
1041 |
+
$expiration_period = ( isset( $wpmem->membership->products[ $product ]['expires'] ) ) ? $wpmem->membership->products[ $product ]['expires'] : false;
|
1042 |
+
|
1043 |
+
$renew = ( $prev_value ) ? true : false;
|
1044 |
+
|
1045 |
+
// If membership is an expiration product.
|
1046 |
+
if ( is_array( $expiration_period ) ) {
|
1047 |
+
$new_value = $wpmem->membership->set_product_expiration( $product, $user_id, $set_date, $prev_value, $renew );
|
1048 |
+
} else {
|
1049 |
+
$new_value = true;
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
// Update product setting.
|
1053 |
+
update_user_meta( $user_id, '_wpmem_products_' . $product, $new_value );
|
1054 |
+
|
1055 |
+
// Update the legacy setting.
|
1056 |
+
$user_products = get_user_meta( $user_id, '_wpmem_products', true );
|
1057 |
+
$user_products = ( $user_products ) ? $user_products : array();
|
1058 |
+
$user_products[ $product ] = ( true === $new_value ) ? true : date( 'Y-m-d H:i:s', $new_value );
|
1059 |
+
update_user_meta( $user_id, '_wpmem_products', $user_products );
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* Fires when a user product has been set.
|
1063 |
+
*
|
1064 |
+
* @since 3.3.0
|
1065 |
+
*
|
1066 |
+
* @param int $user_id
|
1067 |
+
* @param string $product
|
1068 |
+
*/
|
1069 |
+
do_action( 'wpmem_user_product_set', $user_id, $product, $new_value, $prev_value, $renew );
|
1070 |
+
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
/**
|
1074 |
+
* Removes a product from a user.
|
1075 |
+
*
|
1076 |
+
* @since 3.2.0
|
1077 |
+
* @since 3.3.0 Updated for new single meta, keeps legacy array for rollback.
|
1078 |
+
*
|
1079 |
+
* @param string $product
|
1080 |
+
* @param int $user_id
|
1081 |
+
*/
|
1082 |
+
function remove_user_product( $product, $user_id = false ) {
|
1083 |
+
global $wpmem;
|
1084 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
1085 |
+
|
1086 |
+
// @todo Legacy version.
|
1087 |
+
$user_products = get_user_meta( $user_id, '_wpmem_products', true );
|
1088 |
+
$user_products = ( $user_products ) ? $user_products : array();
|
1089 |
+
if ( $user_products ) {
|
1090 |
+
unset( $user_products[ $product ] );
|
1091 |
+
update_user_meta( $user_id, '_wpmem_products', $user_products );
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
// @todo New version.
|
1095 |
+
return delete_user_meta( $user_id, '_wpmem_products_' . $product );
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
/**
|
1099 |
+
* Utility for expiration validation.
|
1100 |
+
*
|
1101 |
+
* @since 3.2.0
|
1102 |
+
* @since 3.3.0 Validates date or epoch time.
|
1103 |
+
*
|
1104 |
+
* @param date $date
|
1105 |
+
*/
|
1106 |
+
function is_current( $date ) {
|
1107 |
+
$date = ( is_numeric( $date ) ) ? $date : strtotime( $date );
|
1108 |
+
return ( time() < $date ) ? true : false;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* Check if a user is activated.
|
1113 |
+
*
|
1114 |
+
* @since 3.2.2
|
1115 |
+
*
|
1116 |
+
* @param int $user_id
|
1117 |
+
* @return bool $active
|
1118 |
+
*/
|
1119 |
+
function is_user_activated( $user_id = false ) {
|
1120 |
+
$user_id = ( ! $user_id ) ? get_current_user_id() : $user_id;
|
1121 |
+
$active = get_user_meta( $user_id, 'active', true );
|
1122 |
+
$is_activated = ( 1 == $active ) ? true : false;
|
1123 |
+
/**
|
1124 |
+
* Filter whether the user is active or not.
|
1125 |
+
*
|
1126 |
+
* @since 3.3.5
|
1127 |
+
*
|
1128 |
+
* @param bool $is_activated
|
1129 |
+
* @param int $user_id
|
1130 |
+
*/
|
1131 |
+
return apply_filters( 'wpmem_is_user_activated', $is_activated, $user_id );
|
1132 |
+
}
|
1133 |
+
|
1134 |
+
/**
|
1135 |
+
* Checks if a user is activated during user authentication.
|
1136 |
+
*
|
1137 |
+
* @since 2.7.1
|
1138 |
+
* @since 3.2.0 Moved from core to user object.
|
1139 |
+
*
|
1140 |
+
* @param object $user The WordPress User object.
|
1141 |
+
* @param string $username The user's username (user_login).
|
1142 |
+
* @param string $password The user's password.
|
1143 |
+
* @return object $user The WordPress User object.
|
1144 |
+
*/
|
1145 |
+
function check_activated( $user, $username, $password ) {
|
1146 |
+
// Password must be validated.
|
1147 |
+
$pass = ( ( ! is_wp_error( $user ) ) && $password ) ? wp_check_password( $password, $user->user_pass, $user->ID ) : false;
|
1148 |
+
|
1149 |
+
if ( ! $pass ) {
|
1150 |
+
return $user;
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
// Activation flag must be validated.
|
1154 |
+
if ( ! $this->is_user_activated( $user->ID ) ) {
|
1155 |
+
return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not been activated.', 'wp-members' ) );
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
// If the user is validated, return the $user object.
|
1159 |
+
return $user;
|
1160 |
+
}
|
1161 |
+
|
1162 |
+
/**
|
1163 |
+
* Prevents users not activated from resetting their password.
|
1164 |
+
*
|
1165 |
+
* @since 2.5.1
|
1166 |
+
* @since 3.2.0 Moved to user object, renamed no_reset().
|
1167 |
+
*
|
1168 |
+
* @return bool Returns false if the user is not activated, otherwise true.
|
1169 |
+
*/
|
1170 |
+
function no_reset() {
|
1171 |
+
global $wpmem;
|
1172 |
+
$raw_val = wpmem_get( 'user_login', false );
|
1173 |
+
if ( $raw_val ) {
|
1174 |
+
if ( strpos( $raw_val, '@' ) ) {
|
1175 |
+
$user = get_user_by( 'email', sanitize_email( $raw_val ) );
|
1176 |
+
} else {
|
1177 |
+
$username = sanitize_user( $raw_val );
|
1178 |
+
$user = get_user_by( 'login', $username );
|
1179 |
+
}
|
1180 |
+
if ( $wpmem->mod_reg == 1 ) {
|
1181 |
+
if ( get_user_meta( $user->ID, 'active', true ) != 1 ) {
|
1182 |
+
return false;
|
1183 |
+
}
|
1184 |
+
}
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
return true;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
/**
|
1191 |
+
* Set expiration for PayPal Subscriptions extension.
|
1192 |
+
*
|
1193 |
+
* @since 3.3.0
|
1194 |
+
*
|
1195 |
+
* @global object $wpmem
|
1196 |
+
*
|
1197 |
+
* @param int $user_id
|
1198 |
+
*/
|
1199 |
+
function set_user_exp( $user_id ) {
|
1200 |
+
global $wpmem;
|
1201 |
+
// Set user expiration, if used.
|
1202 |
+
if ( 1 == $wpmem->use_exp && 1 != $wpmem->mod_reg ) {
|
1203 |
+
if ( function_exists( 'wpmem_set_exp' ) ) {
|
1204 |
+
wpmem_set_exp( $user_id );
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
/**
|
1210 |
+
* Sets default membership product access (if applicable).
|
1211 |
+
*
|
1212 |
+
* @since 3.3.0
|
1213 |
+
*
|
1214 |
+
* @global object $wpmem
|
1215 |
+
*
|
1216 |
+
* @param int $user_id
|
1217 |
+
*/
|
1218 |
+
function set_default_product( $user_id ) {
|
1219 |
+
global $wpmem;
|
1220 |
+
|
1221 |
+
// Get default memberships.
|
1222 |
+
$default_products = $wpmem->membership->get_default_products();
|
1223 |
+
|
1224 |
+
// Assign any default memberships to user.
|
1225 |
+
foreach ( $default_products as $product ) {
|
1226 |
+
wpmem_set_user_product( $product, $user_id );
|
1227 |
+
}
|
1228 |
+
}
|
1229 |
}
|
@@ -1,350 +1,386 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*/
|
6 |
-
class WP_Members_Validation_Link {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Meta containers
|
10 |
-
*
|
11 |
-
* @since 3.3.5
|
12 |
-
*/
|
13 |
-
public $validation_confirm = '_wpmem_user_confirmed';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Options.
|
17 |
-
*
|
18 |
-
* @since 3.3.5
|
19 |
-
*/
|
20 |
-
public $send_welcome = true;
|
21 |
-
public $show_success = true;
|
22 |
-
public $send_notify = true;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Initialize validation link feature.
|
26 |
-
*
|
27 |
-
* @since 3.3.5
|
28 |
-
*/
|
29 |
-
public function __construct() {
|
30 |
-
|
31 |
-
$defaults = array(
|
32 |
-
'email_text' => __( 'Click to validate your account: ', 'wp-members' ),
|
33 |
-
'success_message' => __( 'Thank you for validating your account.', 'wp-members' ),
|
34 |
-
'invalid_message' => __( 'Validation key was expired or invalid', 'wp-members' ),
|
35 |
-
'moderated_message' => __( 'Your account is now pending approval', 'wp-members' ),
|
36 |
-
);
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Filter default dialogs.
|
40 |
-
*
|
41 |
-
* @since 3.3.8
|
42 |
-
*
|
43 |
-
* @param array $defaults
|
44 |
-
*/
|
45 |
-
$defaults = apply_filters( 'wpmem_validation_link_default_dialogs', $defaults );
|
46 |
-
|
47 |
-
foreach ( $defaults as $key => $value ) {
|
48 |
-
$this->{$key} = $value;
|
49 |
-
}
|
50 |
-
|
51 |
-
add_action( 'template_redirect', array( $this, 'validate_key' ) );
|
52 |
-
add_filter( 'authenticate', array( $this, 'check_validated' ), 99, 3 );
|
53 |
-
add_filter( 'wpmem_email_filter', array( $this, 'add_key_to_email' ), 10, 3 );
|
54 |
-
add_filter( 'the_content', array( $this, 'validation_success' ), 100 );
|
55 |
-
|
56 |
-
add_action( 'wpmem_account_validation_success', array( $this, 'send_welcome' ) );
|
57 |
-
add_action( 'wpmem_account_validation_success', array( $this, 'notify_admin' ) );
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Include the validation key in the new user registration email as a validation link.
|
62 |
-
*
|
63 |
-
* @since 3.3.5
|
64 |
-
*
|
65 |
-
* @global stdClass $wpmem
|
66 |
-
* @param array $arr
|
67 |
-
* @param array $wpmem_fields
|
68 |
-
* @param array $field_data
|
69 |
-
* @return array
|
70 |
-
*/
|
71 |
-
public function add_key_to_email( $arr, $wpmem_fields, $field_data ) {
|
72 |
-
|
73 |
-
global $wpmem;
|
74 |
-
|
75 |
-
// Only do this for new registrations.
|
76 |
-
$email_type = ( 1 == $wpmem->mod_reg ) ? 'newmod' : 'newreg';
|
77 |
-
if ( $arr['toggle'] == $email_type ) {
|
78 |
-
|
79 |
-
$user = get_user_by( 'ID', $arr['user_id'] );
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Gets the user based on the password key.
|
83 |
-
*
|
84 |
-
* WP filters/actions triggered:
|
85 |
-
* - retrieve_password
|
86 |
-
* - allow_password_reset
|
87 |
-
* - retrieve_password_key
|
88 |
-
*
|
89 |
-
* @see: https://developer.wordpress.org/reference/functions/get_password_reset_key/
|
90 |
-
* @param WP_User User to retrieve password reset key for.
|
91 |
-
* @return string|WP_Error Password reset key on success. WP_Error on error.
|
92 |
-
*/
|
93 |
-
$key = $this->set_validation_key( $user );
|
94 |
-
|
95 |
-
// Generate confirm link.
|
96 |
-
/**
|
97 |
-
* Filter the return url
|
98 |
-
*
|
99 |
-
* @since 3.3.5
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
*
|
185 |
-
*
|
186 |
-
*
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
if ( $
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
*
|
293 |
-
*
|
294 |
-
* @
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
*
|
308 |
-
*
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
*
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
*
|
5 |
+
*/
|
6 |
+
class WP_Members_Validation_Link {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Meta containers
|
10 |
+
*
|
11 |
+
* @since 3.3.5
|
12 |
+
*/
|
13 |
+
public $validation_confirm = '_wpmem_user_confirmed';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Options.
|
17 |
+
*
|
18 |
+
* @since 3.3.5
|
19 |
+
*/
|
20 |
+
public $send_welcome = true;
|
21 |
+
public $show_success = true;
|
22 |
+
public $send_notify = true;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Initialize validation link feature.
|
26 |
+
*
|
27 |
+
* @since 3.3.5
|
28 |
+
*/
|
29 |
+
public function __construct() {
|
30 |
+
|
31 |
+
$defaults = array(
|
32 |
+
'email_text' => __( 'Click to validate your account: ', 'wp-members' ),
|
33 |
+
'success_message' => __( 'Thank you for validating your account.', 'wp-members' ),
|
34 |
+
'invalid_message' => __( 'Validation key was expired or invalid', 'wp-members' ),
|
35 |
+
'moderated_message' => __( 'Your account is now pending approval', 'wp-members' ),
|
36 |
+
);
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Filter default dialogs.
|
40 |
+
*
|
41 |
+
* @since 3.3.8
|
42 |
+
*
|
43 |
+
* @param array $defaults
|
44 |
+
*/
|
45 |
+
$defaults = apply_filters( 'wpmem_validation_link_default_dialogs', $defaults );
|
46 |
+
|
47 |
+
foreach ( $defaults as $key => $value ) {
|
48 |
+
$this->{$key} = $value;
|
49 |
+
}
|
50 |
+
|
51 |
+
add_action( 'template_redirect', array( $this, 'validate_key' ) );
|
52 |
+
add_filter( 'authenticate', array( $this, 'check_validated' ), 99, 3 );
|
53 |
+
add_filter( 'wpmem_email_filter', array( $this, 'add_key_to_email' ), 10, 3 );
|
54 |
+
add_filter( 'the_content', array( $this, 'validation_success' ), 100 );
|
55 |
+
|
56 |
+
add_action( 'wpmem_account_validation_success', array( $this, 'send_welcome' ) );
|
57 |
+
add_action( 'wpmem_account_validation_success', array( $this, 'notify_admin' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Include the validation key in the new user registration email as a validation link.
|
62 |
+
*
|
63 |
+
* @since 3.3.5
|
64 |
+
*
|
65 |
+
* @global stdClass $wpmem
|
66 |
+
* @param array $arr
|
67 |
+
* @param array $wpmem_fields
|
68 |
+
* @param array $field_data
|
69 |
+
* @return array
|
70 |
+
*/
|
71 |
+
public function add_key_to_email( $arr, $wpmem_fields, $field_data ) {
|
72 |
+
|
73 |
+
global $wpmem;
|
74 |
+
|
75 |
+
// Only do this for new registrations.
|
76 |
+
$email_type = ( 1 == $wpmem->mod_reg ) ? 'newmod' : 'newreg';
|
77 |
+
if ( $arr['toggle'] == $email_type ) {
|
78 |
+
|
79 |
+
$user = get_user_by( 'ID', $arr['user_id'] );
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Gets the user based on the password key.
|
83 |
+
*
|
84 |
+
* WP filters/actions triggered:
|
85 |
+
* - retrieve_password
|
86 |
+
* - allow_password_reset
|
87 |
+
* - retrieve_password_key
|
88 |
+
*
|
89 |
+
* @see: https://developer.wordpress.org/reference/functions/get_password_reset_key/
|
90 |
+
* @param WP_User User to retrieve password reset key for.
|
91 |
+
* @return string|WP_Error Password reset key on success. WP_Error on error.
|
92 |
+
*/
|
93 |
+
$key = $this->set_validation_key( $user );
|
94 |
+
|
95 |
+
// Generate confirm link.
|
96 |
+
/**
|
97 |
+
* Filter the return url
|
98 |
+
*
|
99 |
+
* @since 3.3.5
|
100 |
+
* @since 3.3.9 Added $user object
|
101 |
+
*
|
102 |
+
* @param string The link URL (trailing slash recommended).
|
103 |
+
* @param object $user
|
104 |
+
*/
|
105 |
+
$url = apply_filters( 'wpmem_validation_link_return_url', trailingslashit( wpmem_profile_url() ), $user );
|
106 |
+
$query_args = array(
|
107 |
+
'a' => 'confirm',
|
108 |
+
'key' => $key,
|
109 |
+
'login' => $user->user_login,
|
110 |
+
);
|
111 |
+
|
112 |
+
// urlencode, primarily for user_login with a space.
|
113 |
+
$query_args = array_map( 'rawurlencode', $query_args );
|
114 |
+
|
115 |
+
$link = add_query_arg( $query_args, trailingslashit( $url ) );
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Filter the confirmation link.
|
119 |
+
*
|
120 |
+
* @since 3.3.9
|
121 |
+
*
|
122 |
+
* @param string $link
|
123 |
+
* @param string $url
|
124 |
+
* @param array $query_args
|
125 |
+
*/
|
126 |
+
$link = apply_filters( 'wpmem_validation_link', $link, $url, $query_args );
|
127 |
+
|
128 |
+
// Does email body have the [confirm_link] shortcode?
|
129 |
+
if ( strpos( $arr['body'], '[confirm_link]' ) ) {
|
130 |
+
$arr['body'] = str_replace( '[confirm_link]', $link, $arr['body'] );
|
131 |
+
} else {
|
132 |
+
// Add text and link to the email body.
|
133 |
+
$arr['body'] = $arr['body'] . "\r\n"
|
134 |
+
. $this->email_text . ' ' . $link;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
return $arr;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Check for a validation key and if one exists, validate and log in user.
|
143 |
+
*
|
144 |
+
* @since 3.3.5
|
145 |
+
*/
|
146 |
+
public function validate_key() {
|
147 |
+
|
148 |
+
global $wpmem;
|
149 |
+
|
150 |
+
// Check for validation key.
|
151 |
+
$key = ( 'confirm' == wpmem_get( 'a', false, 'get' ) ) ? wpmem_get( 'key', false, 'get' ) : false;
|
152 |
+
$login = ( 'confirm' == wpmem_get( 'a', false, 'get' ) ) ? wpmem_get( 'login', false, 'get' ) : false;
|
153 |
+
|
154 |
+
if ( false !== $key ) {
|
155 |
+
|
156 |
+
// Set an error container.
|
157 |
+
$errors = new WP_Error();
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Validate the key.
|
161 |
+
*
|
162 |
+
* WP_Error will be invalid_key or expired_key. Process triggers password_reset_expiration filter
|
163 |
+
* filtering DAY_IN_SECONDS default. Filter password_reset_key_expired is also triggered filtering
|
164 |
+
* the return value (which can be used to override the expired/invalid check based on user_id).
|
165 |
+
*
|
166 |
+
* WP filter/actions triggered:
|
167 |
+
* - password_reset_expiration
|
168 |
+
* - password_reset_key_expired
|
169 |
+
*
|
170 |
+
* @see https://developer.wordpress.org/reference/functions/check_password_reset_key/
|
171 |
+
* @param string Hash to validate sending user's password.
|
172 |
+
* @param string The user login.
|
173 |
+
* @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys (invalid_key|expired_key).
|
174 |
+
*/
|
175 |
+
$user = check_password_reset_key( $key, $login );
|
176 |
+
|
177 |
+
if ( ! is_wp_error( $user ) ) {
|
178 |
+
|
179 |
+
$this->validated = true;
|
180 |
+
|
181 |
+
// If registration is not moderated, set the user as logged in.
|
182 |
+
if ( 1 != $wpmem->mod_reg ) {
|
183 |
+
/**
|
184 |
+
* Sets the WP auth cookie.
|
185 |
+
*
|
186 |
+
* May trigger the following WP filter/actions:
|
187 |
+
* - auth_cookie_expiration
|
188 |
+
* - secure_auth_cookie
|
189 |
+
* - secure_logged_in_cookie
|
190 |
+
* - set_auth_cookie
|
191 |
+
* - set_logged_in_cookie
|
192 |
+
* - send_auth_cookies
|
193 |
+
*
|
194 |
+
* @see https://developer.wordpress.org/reference/functions/wp_set_auth_cookie/
|
195 |
+
*/
|
196 |
+
wp_set_auth_cookie( $user->ID, true );
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Sets the user as logged in.
|
200 |
+
*
|
201 |
+
* May trigger the folloiwng WP filter/actions:
|
202 |
+
* - set_current_user
|
203 |
+
*
|
204 |
+
* @see https://developer.wordpress.org/reference/functions/wp_set_current_user/
|
205 |
+
*/
|
206 |
+
wp_set_current_user( $user->ID );
|
207 |
+
}
|
208 |
+
|
209 |
+
// Delete validation_key meta and set active.
|
210 |
+
$this->clear_activation_key( $user->ID );
|
211 |
+
$this->set_as_confirmed( $user->ID );
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Fires when a user has successfully validated their account.
|
215 |
+
*
|
216 |
+
* @since 3.3.5
|
217 |
+
*
|
218 |
+
* @param int $user_id
|
219 |
+
*/
|
220 |
+
do_action( 'wpmem_account_validation_success', $user->ID );
|
221 |
+
|
222 |
+
} else {
|
223 |
+
$this->validated = false;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Display messaging.
|
230 |
+
*
|
231 |
+
* Shows success if key validates, expired if it does not.
|
232 |
+
*
|
233 |
+
* @since 3.3.5
|
234 |
+
*
|
235 |
+
* @param string $content
|
236 |
+
* @return string $content
|
237 |
+
*/
|
238 |
+
public function validation_success( $content ) {
|
239 |
+
|
240 |
+
global $wpmem;
|
241 |
+
|
242 |
+
if ( $this->show_success && 'confirm' == wpmem_get( 'a', false, 'get' ) && isset( $this->validated ) ) {
|
243 |
+
|
244 |
+
if ( true === $this->validated ) {
|
245 |
+
$msg = $this->success_message;
|
246 |
+
|
247 |
+
if ( 1 == $wpmem->mod_reg ) {
|
248 |
+
$msg = $msg . $this->moderated_message;
|
249 |
+
}
|
250 |
+
} elseif ( false === $this->validated ) {
|
251 |
+
$msg = $this->invalid_message;
|
252 |
+
} else {
|
253 |
+
$msg = '';
|
254 |
+
}
|
255 |
+
|
256 |
+
$content = wpmem_get_display_message( 'custom', $msg ) . $content;
|
257 |
+
}
|
258 |
+
|
259 |
+
return $content;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Checks if a user is activated during user authentication.
|
264 |
+
*
|
265 |
+
* This prevents access via login if the user has not confirmed their email.
|
266 |
+
*
|
267 |
+
* @since 3.3.5 Moved from core to user object.
|
268 |
+
*
|
269 |
+
* @param object $user The WordPress User object.
|
270 |
+
* @param string $username The user's username (user_login).
|
271 |
+
* @param string $password The user's password.
|
272 |
+
* @return object $user The WordPress User object.
|
273 |
+
*/
|
274 |
+
function check_validated( $user, $username, $password ) {
|
275 |
+
// Password must be validated.
|
276 |
+
$pass = ( ( ! is_wp_error( $user ) ) && $password ) ? wp_check_password( $password, $user->user_pass, $user->ID ) : false;
|
277 |
+
|
278 |
+
if ( ! $pass ) {
|
279 |
+
return $user;
|
280 |
+
}
|
281 |
+
|
282 |
+
// Validation flag must be confirmed.
|
283 |
+
if ( false == wpmem_is_user_confirmed( $user->ID ) ) {
|
284 |
+
return new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: User has not confirmed their account.', 'wp-members' ) );
|
285 |
+
}
|
286 |
+
|
287 |
+
// If the user is validated, return the $user object.
|
288 |
+
return $user;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Sends the welcome email to the user upon validation of their email.
|
293 |
+
*
|
294 |
+
* @since 3.3.5
|
295 |
+
* @since 3.3.8 Sends email specific to email validation (previously was moderated approved email).
|
296 |
+
*
|
297 |
+
* @param int $user_id
|
298 |
+
*/
|
299 |
+
public function send_welcome( $user_id ) {
|
300 |
+
if ( $this->send_welcome ) {
|
301 |
+
$email_to_send = ( get_option( 'wpmembers_email_validated' ) ) ? 6 : 2;
|
302 |
+
wpmem_email_to_user( $user_id, '', $email_to_send );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Sends notification email to the admin upon validation of the user's email.
|
308 |
+
*
|
309 |
+
* @since 3.3.5
|
310 |
+
*
|
311 |
+
* @param int $user_id
|
312 |
+
*/
|
313 |
+
public function notify_admin( $user_id ) {
|
314 |
+
if ( $this->send_notify ) {
|
315 |
+
// global $wpmem;
|
316 |
+
wpmem_notify_admin( $user_id ); //, $wpmem->fields );
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Clears user_activation_key.
|
322 |
+
*
|
323 |
+
* @since 3.3.8
|
324 |
+
*
|
325 |
+
* @param int $user_id
|
326 |
+
*/
|
327 |
+
public function clear_activation_key( $user_id ) {
|
328 |
+
global $wpdb;
|
329 |
+
$result = $wpdb->update( $wpdb->users, array( 'user_activation_key' => '', ), array( 'ID' => $user_id ) );
|
330 |
+
//clean_user_cache( $user_id );
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Sets a user activation key.
|
335 |
+
*
|
336 |
+
* @since 3.3.8
|
337 |
+
*
|
338 |
+
* @param mixed $user user ID (int)|WP_User (object).
|
339 |
+
*/
|
340 |
+
public function set_validation_key( $user ) {
|
341 |
+
$user = ( is_object( $user ) ) ? $user : get_user_by( 'ID', $user );
|
342 |
+
return get_password_reset_key( $user );
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* Sets user as having validated their email.
|
347 |
+
*
|
348 |
+
* @since 3.3.8
|
349 |
+
*
|
350 |
+
* @param int $user_id
|
351 |
+
*/
|
352 |
+
public function set_as_confirmed( $user_id ) {
|
353 |
+
update_user_meta( $user_id, $this->validation_confirm, time() );
|
354 |
+
/**
|
355 |
+
* Fires when user is set as confirmed (either manually or by user).
|
356 |
+
*
|
357 |
+
* @since 3.3.9
|
358 |
+
*
|
359 |
+
* @param int $user_id
|
360 |
+
* @param string time()
|
361 |
+
*/
|
362 |
+
do_action( 'wpmem_user_set_as_confirmed', $user_id, time() );
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Sets user as NOT having validated their email.
|
367 |
+
*
|
368 |
+
* @since 3.3.8
|
369 |
+
*
|
370 |
+
* @param int $user_id
|
371 |
+
*/
|
372 |
+
public function set_as_unconfirmed( $user_id ) {
|
373 |
+
delete_user_meta( $user_id, $this->validation_confirm );
|
374 |
+
$validation_key = $this->set_validation_key( $user_id );
|
375 |
+
/**
|
376 |
+
* Fires when user is set as confirmed (either manually or by user).
|
377 |
+
*
|
378 |
+
* @since 3.3.9
|
379 |
+
*
|
380 |
+
* @param int $user_id
|
381 |
+
* @param string time()
|
382 |
+
* @param string $key
|
383 |
+
*/
|
384 |
+
do_action( 'wpmem_user_set_as_unconfirmed', $user_id, time(), $key );
|
385 |
+
}
|
386 |
}
|
@@ -34,14 +34,14 @@ class widget_wpmemwidget extends WP_Widget {
|
|
34 |
*/
|
35 |
function form( $instance ) {
|
36 |
|
37 |
-
|
38 |
$defaults = array(
|
39 |
'title' => __( 'Login Status', 'wp-members' ),
|
40 |
'redirect_to' => '',
|
41 |
);
|
42 |
$instance = wp_parse_args( ( array ) $instance, $defaults );
|
43 |
|
44 |
-
|
45 |
<p>
|
46 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-members' ); ?></label>
|
47 |
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:95%;" />
|
@@ -124,13 +124,14 @@ class widget_wpmemwidget extends WP_Widget {
|
|
124 |
* @since 3.0.0 Added $post_to argument.
|
125 |
* @since 3.1.0 Changed $post_to to $redirect_to.
|
126 |
* @since 3.2.0 Moved to widget_wpmemwidget class as do_sidebar().
|
|
|
127 |
*
|
128 |
* @param string $redirect_to A URL to redirect to upon login, default null.
|
129 |
* @param bool $customizer Whether to show the form for the customizer.
|
130 |
* @global string $wpmem_regchk
|
131 |
* @global string $user_login
|
132 |
*/
|
133 |
-
|
134 |
|
135 |
global $wpmem, $wpmem_regchk;
|
136 |
|
@@ -167,15 +168,22 @@ class widget_wpmemwidget extends WP_Widget {
|
|
167 |
'error_after' => '</p>',
|
168 |
'fieldset_before' => '<fieldset>',
|
169 |
'fieldset_after' => '</fieldset>',
|
|
|
|
|
170 |
'inputs_before' => '<div class="div_texbox">',
|
171 |
'inputs_after' => '</div>',
|
172 |
'buttons_before' => '<div class="button_div">',
|
173 |
'buttons_after' => '</div>',
|
174 |
|
175 |
// Messages.
|
176 |
-
'error_msg' =>
|
177 |
-
'status_msg' =>
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
179 |
// Other.
|
180 |
'strip_breaks' => true,
|
181 |
'wrap_inputs' => true,
|
@@ -206,21 +214,61 @@ class widget_wpmemwidget extends WP_Widget {
|
|
206 |
*/
|
207 |
$args = apply_filters( 'wpmem_login_widget_args', $args );
|
208 |
|
209 |
-
$
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
// Handle outside elements added to the login form (currently ONLY for login).
|
226 |
if ( $args['login_form_action'] ) {
|
@@ -239,42 +287,71 @@ class widget_wpmemwidget extends WP_Widget {
|
|
239 |
* Filter sidebar login form hidden fields.
|
240 |
*
|
241 |
* @since 2.9.0
|
|
|
242 |
*
|
243 |
* @param string $hidden The HTML for the hidden fields.
|
244 |
*/
|
245 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
-
$buttons = '<input type="submit" name="Submit" class="
|
248 |
|
249 |
if ( $wpmem->user_pages['profile'] != null ) {
|
250 |
-
/** This filter is documented in wp-members/
|
251 |
$link = apply_filters( 'wpmem_forgot_link', add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ) );
|
252 |
-
$link_html = ' <a href="' . $link . '">' .
|
253 |
/**
|
254 |
* Filter the sidebar forgot password.
|
255 |
*
|
256 |
* @since 3.0.9
|
|
|
257 |
*
|
258 |
* @param string $link_html
|
259 |
* @param string $link
|
260 |
*/
|
261 |
$link_html = apply_filters( 'wpmem_sb_forgot_link_str', $link_html, $link );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
$buttons.= $link_html;
|
263 |
}
|
264 |
|
265 |
if ( $wpmem->user_pages['register'] != null ) {
|
266 |
-
/** This filter is documented in wp-members/
|
267 |
$link = apply_filters( 'wpmem_reg_link', $wpmem->user_pages['register'] );
|
268 |
-
$link_html = ' <a href="' . $link . '">' .
|
269 |
/**
|
270 |
* Filter the sidebar register link.
|
271 |
*
|
272 |
* @since 3.0.9
|
|
|
273 |
*
|
274 |
* @param string $link_html
|
275 |
* @param string $link
|
276 |
*/
|
277 |
$link_html = apply_filters( 'wpmem_sb_reg_link_str', $link_html, $link );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
$buttons.= $link_html;
|
279 |
}
|
280 |
|
@@ -282,7 +359,7 @@ class widget_wpmemwidget extends WP_Widget {
|
|
282 |
|
283 |
$form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
|
284 |
|
285 |
-
$form = '<form name="form" method="post" action="' . $post_to . '">' . $args['n'] . $form . $args['n'] . '</form>';
|
286 |
|
287 |
// Add status message, if one exists.
|
288 |
if ( '' == $args['status_msg'] ) {
|
@@ -296,10 +373,19 @@ class widget_wpmemwidget extends WP_Widget {
|
|
296 |
* Filter the sidebar form.
|
297 |
*
|
298 |
* @since unknown
|
|
|
299 |
*
|
300 |
* @param string $form The HTML for the sidebar login form.
|
301 |
*/
|
302 |
$form = apply_filters( 'wpmem_sidebar_form', $form );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
$do_error_msg = '';
|
305 |
$error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
|
@@ -315,10 +401,19 @@ class widget_wpmemwidget extends WP_Widget {
|
|
315 |
* Filter the sidebar login failed message.
|
316 |
*
|
317 |
* @since unknown
|
|
|
318 |
*
|
319 |
* @param string $error_msg The error message.
|
320 |
*/
|
321 |
$error_msg = apply_filters( 'wpmem_login_failed_sb', $error_msg );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
322 |
$form = $error_msg . $form;
|
323 |
}
|
324 |
|
@@ -328,15 +423,15 @@ class widget_wpmemwidget extends WP_Widget {
|
|
328 |
|
329 |
global $user_login;
|
330 |
|
331 |
-
/** This filter is
|
332 |
$logout = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout', $url ) );
|
333 |
|
334 |
// Defaults.
|
335 |
$defaults = array(
|
336 |
'user_login' => $user_login,
|
337 |
-
'wrapper_before' => '<p>',
|
338 |
-
'status_text' => sprintf(
|
339 |
-
'link_text' =>
|
340 |
'wrapper_after' => '</p>',
|
341 |
);
|
342 |
|
@@ -345,11 +440,21 @@ class widget_wpmemwidget extends WP_Widget {
|
|
345 |
*
|
346 |
* @since 3.1.0
|
347 |
* @since 3.1.2 Pass default args.
|
|
|
348 |
*
|
349 |
* @param array $defaults
|
350 |
* @return array
|
351 |
*/
|
352 |
$args = apply_filters( 'wpmem_sidebar_status_args', $defaults );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
|
354 |
// Merge $args with $defaults.
|
355 |
$args = wp_parse_args( $args, $defaults );
|
@@ -361,10 +466,19 @@ class widget_wpmemwidget extends WP_Widget {
|
|
361 |
* Filter the sidebar user login status.
|
362 |
*
|
363 |
* @since unknown
|
|
|
364 |
*
|
365 |
* @param string $str The login status for the user.
|
366 |
*/
|
367 |
$str = apply_filters( 'wpmem_sidebar_status', $str );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
|
369 |
echo $str;
|
370 |
}
|
34 |
*/
|
35 |
function form( $instance ) {
|
36 |
|
37 |
+
// Default widget settings.
|
38 |
$defaults = array(
|
39 |
'title' => __( 'Login Status', 'wp-members' ),
|
40 |
'redirect_to' => '',
|
41 |
);
|
42 |
$instance = wp_parse_args( ( array ) $instance, $defaults );
|
43 |
|
44 |
+
// Title input. ?>
|
45 |
<p>
|
46 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'wp-members' ); ?></label>
|
47 |
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:95%;" />
|
124 |
* @since 3.0.0 Added $post_to argument.
|
125 |
* @since 3.1.0 Changed $post_to to $redirect_to.
|
126 |
* @since 3.2.0 Moved to widget_wpmemwidget class as do_sidebar().
|
127 |
+
* @since 3.4.0 Revise form for consitency with main body form.
|
128 |
*
|
129 |
* @param string $redirect_to A URL to redirect to upon login, default null.
|
130 |
* @param bool $customizer Whether to show the form for the customizer.
|
131 |
* @global string $wpmem_regchk
|
132 |
* @global string $user_login
|
133 |
*/
|
134 |
+
function do_sidebar( $redirect_to = null, $customizer = false ) {
|
135 |
|
136 |
global $wpmem, $wpmem_regchk;
|
137 |
|
168 |
'error_after' => '</p>',
|
169 |
'fieldset_before' => '<fieldset>',
|
170 |
'fieldset_after' => '</fieldset>',
|
171 |
+
'row_before' => '',
|
172 |
+
'row_after' => '',
|
173 |
'inputs_before' => '<div class="div_texbox">',
|
174 |
'inputs_after' => '</div>',
|
175 |
'buttons_before' => '<div class="button_div">',
|
176 |
'buttons_after' => '</div>',
|
177 |
|
178 |
// Messages.
|
179 |
+
'error_msg' => wpmem_get_text( 'widget_login_failed' ),
|
180 |
+
'status_msg' => wpmem_get_text( 'widget_not_logged_in' ) . '<br />',
|
181 |
+
|
182 |
+
'form_id' => 'wpmem_login_widget_form',
|
183 |
+
'form_class' => 'widget_form',
|
184 |
+
'button_id' => '',
|
185 |
+
'button_class' => 'buttons',
|
186 |
+
|
187 |
// Other.
|
188 |
'strip_breaks' => true,
|
189 |
'wrap_inputs' => true,
|
214 |
*/
|
215 |
$args = apply_filters( 'wpmem_login_widget_args', $args );
|
216 |
|
217 |
+
$inputs = array(
|
218 |
+
array(
|
219 |
+
'name' => wpmem_get_text( 'widget_login_username' ),
|
220 |
+
'type' => 'text',
|
221 |
+
'tag' => 'log',
|
222 |
+
'class' => 'username',
|
223 |
+
'div' => 'div_text'
|
224 |
+
),
|
225 |
+
array(
|
226 |
+
'name' => wpmem_get_text( 'widget_login_password' ),
|
227 |
+
'type' => 'password',
|
228 |
+
'tag' => 'pwd',
|
229 |
+
'class' => 'password',
|
230 |
+
'div' => 'div_text',
|
231 |
+
),
|
232 |
+
);
|
233 |
+
|
234 |
+
// Build the input rows.
|
235 |
+
foreach ( $inputs as $input ) {
|
236 |
+
$label = '<label for="' . esc_attr( $input['tag'] ) . '">' . $input['name'] . '</label>';
|
237 |
+
$field = wpmem_form_field( array(
|
238 |
+
'name' => $input['tag'],
|
239 |
+
'type' => $input['type'],
|
240 |
+
'class' => $input['class'],
|
241 |
+
'required' => true,
|
242 |
+
) );
|
243 |
+
$field_before = ( $args['wrap_inputs'] ) ? '<div class="' . wpmem_sanitize_class( $input['div'] ) . '">' : '';
|
244 |
+
$field_after = ( $args['wrap_inputs'] ) ? '</div>' : '';
|
245 |
+
$rows[] = array(
|
246 |
+
'row_before' => $args['row_before'],
|
247 |
+
'label' => $label,
|
248 |
+
'field_before' => $field_before,
|
249 |
+
'field' => $field,
|
250 |
+
'field_after' => $field_after,
|
251 |
+
'row_after' => $args['row_after'],
|
252 |
+
);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Filter the array of form rows. Works like wpmem_login_form_rows.
|
257 |
+
*
|
258 |
+
* @since 3.4.0
|
259 |
+
*
|
260 |
+
* @param array $rows An array containing the form rows.
|
261 |
+
*/
|
262 |
+
$rows = apply_filters( 'wpmem_login_widget_form_rows', $rows );
|
263 |
|
264 |
+
// Put the rows from the array into $form.
|
265 |
+
$form = '';
|
266 |
+
foreach ( $rows as $row_item ) {
|
267 |
+
$row = ( $row_item['row_before'] != '' ) ? $row_item['row_before'] . $args['n'] . $row_item['label'] . $args['n'] : $row_item['label'] . $args['n'];
|
268 |
+
$row .= ( $row_item['field_before'] != '' ) ? $row_item['field_before'] . $args['n'] . $args['t'] . $row_item['field'] . $args['n'] . $row_item['field_after'] . $args['n'] : $row_item['field'] . $args['n'];
|
269 |
+
$row .= ( $row_item['row_after'] != '' ) ? $row_item['row_after'] . $args['n'] : '';
|
270 |
+
$form.= $row;
|
271 |
+
}
|
272 |
|
273 |
// Handle outside elements added to the login form (currently ONLY for login).
|
274 |
if ( $args['login_form_action'] ) {
|
287 |
* Filter sidebar login form hidden fields.
|
288 |
*
|
289 |
* @since 2.9.0
|
290 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_hidden_fields instead.
|
291 |
*
|
292 |
* @param string $hidden The HTML for the hidden fields.
|
293 |
*/
|
294 |
+
$hidden = apply_filters( 'wpmem_sb_hidden_fields', $hidden );
|
295 |
+
/**
|
296 |
+
* Filter sidebar login form hidden fields.
|
297 |
+
*
|
298 |
+
* @since 3.4.0
|
299 |
+
*
|
300 |
+
* @param string $hidden The HTML for the hidden fields.
|
301 |
+
*/
|
302 |
+
$form = $form . apply_filters( 'wpmem_login_widget_hidden_fields', $hidden );
|
303 |
|
304 |
+
$buttons = '<input type="submit" name="Submit" class="' . wpmem_sanitize_class( $args['button_class'] ) . '" value="' . wpmem_get_text( 'widget_login_button' ) . '" />';
|
305 |
|
306 |
if ( $wpmem->user_pages['profile'] != null ) {
|
307 |
+
/** This filter is documented in wp-members/includes/class-wp-members-forms.php */
|
308 |
$link = apply_filters( 'wpmem_forgot_link', add_query_arg( 'a', 'pwdreset', $wpmem->user_pages['profile'] ) );
|
309 |
+
$link_html = ' <a href="' . $link . '">' . wpmem_get_text( 'widget_login_forgot' ) . '</a> ';
|
310 |
/**
|
311 |
* Filter the sidebar forgot password.
|
312 |
*
|
313 |
* @since 3.0.9
|
314 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_forgot_link_str instead.
|
315 |
*
|
316 |
* @param string $link_html
|
317 |
* @param string $link
|
318 |
*/
|
319 |
$link_html = apply_filters( 'wpmem_sb_forgot_link_str', $link_html, $link );
|
320 |
+
/**
|
321 |
+
* Filter the sidebar forgot password.
|
322 |
+
*
|
323 |
+
* @since 3.4.0
|
324 |
+
*
|
325 |
+
* @param string $link_html
|
326 |
+
* @param string $link
|
327 |
+
*/
|
328 |
+
$link_html = apply_filters( 'wpmem_login_widget_forgot_link_str', $link_html, $link );
|
329 |
$buttons.= $link_html;
|
330 |
}
|
331 |
|
332 |
if ( $wpmem->user_pages['register'] != null ) {
|
333 |
+
/** This filter is documented in wp-members/includes/class-wp-members-forms.php */
|
334 |
$link = apply_filters( 'wpmem_reg_link', $wpmem->user_pages['register'] );
|
335 |
+
$link_html = ' <a href="' . $link . '">' . wpmem_get_text( 'widget_login_register' ) . '</a>';
|
336 |
/**
|
337 |
* Filter the sidebar register link.
|
338 |
*
|
339 |
* @since 3.0.9
|
340 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_reg_link_str instead.
|
341 |
*
|
342 |
* @param string $link_html
|
343 |
* @param string $link
|
344 |
*/
|
345 |
$link_html = apply_filters( 'wpmem_sb_reg_link_str', $link_html, $link );
|
346 |
+
/**
|
347 |
+
* Filter the sidebar register link.
|
348 |
+
*
|
349 |
+
* @since 3.4.0
|
350 |
+
*
|
351 |
+
* @param string $link_html
|
352 |
+
* @param string $link
|
353 |
+
*/
|
354 |
+
$link_html = apply_filters( 'wpmem_login_widget_reg_link_str', $link_html, $link );
|
355 |
$buttons.= $link_html;
|
356 |
}
|
357 |
|
359 |
|
360 |
$form = $args['fieldset_before'] . $args['n'] . $form . $args['n'] . $args['fieldset_after'];
|
361 |
|
362 |
+
$form = '<form name="form" method="post" action="' . $post_to . '" id="' . wpmem_sanitize_class( $args['form_id'] ) . '" class="' . wpmem_sanitize_class( $args['form_class'] ) . '">' . $args['n'] . $form . $args['n'] . '</form>';
|
363 |
|
364 |
// Add status message, if one exists.
|
365 |
if ( '' == $args['status_msg'] ) {
|
373 |
* Filter the sidebar form.
|
374 |
*
|
375 |
* @since unknown
|
376 |
+
* @deprecated 3.3.9 Use wpmem_login_widget_form instead.
|
377 |
*
|
378 |
* @param string $form The HTML for the sidebar login form.
|
379 |
*/
|
380 |
$form = apply_filters( 'wpmem_sidebar_form', $form );
|
381 |
+
/**
|
382 |
+
* Filter the sidebar form.
|
383 |
+
*
|
384 |
+
* @since 3.3.9
|
385 |
+
*
|
386 |
+
* @param string $form The HTML for the sidebar login form.
|
387 |
+
*/
|
388 |
+
$form = apply_filters( 'wpmem_login_widget_form', $form );
|
389 |
|
390 |
$do_error_msg = '';
|
391 |
$error_msg = $args['error_before'] . $args['error_msg'] . $args['error_after'];
|
401 |
* Filter the sidebar login failed message.
|
402 |
*
|
403 |
* @since unknown
|
404 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_login_failed instead.
|
405 |
*
|
406 |
* @param string $error_msg The error message.
|
407 |
*/
|
408 |
$error_msg = apply_filters( 'wpmem_login_failed_sb', $error_msg );
|
409 |
+
/**
|
410 |
+
* Filter the sidebar login failed message.
|
411 |
+
*
|
412 |
+
* @since 3.4.0
|
413 |
+
*
|
414 |
+
* @param string $error_msg The error message.
|
415 |
+
*/
|
416 |
+
$error_msg = apply_filters( 'wpmem_login_widget_login_failed', $error_msg );
|
417 |
$form = $error_msg . $form;
|
418 |
}
|
419 |
|
423 |
|
424 |
global $user_login;
|
425 |
|
426 |
+
/** This filter is defined in /includes/api/api.php */
|
427 |
$logout = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout', $url ) );
|
428 |
|
429 |
// Defaults.
|
430 |
$defaults = array(
|
431 |
'user_login' => $user_login,
|
432 |
+
'wrapper_before' => '<p class="login_widget_status">',
|
433 |
+
'status_text' => sprintf( wpmem_get_text( 'widget_status' ), $user_login ) . '<br />',
|
434 |
+
'link_text' => wpmem_get_text( 'widget_logout' ),
|
435 |
'wrapper_after' => '</p>',
|
436 |
);
|
437 |
|
440 |
*
|
441 |
* @since 3.1.0
|
442 |
* @since 3.1.2 Pass default args.
|
443 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_status_args instead.
|
444 |
*
|
445 |
* @param array $defaults
|
446 |
* @return array
|
447 |
*/
|
448 |
$args = apply_filters( 'wpmem_sidebar_status_args', $defaults );
|
449 |
+
/**
|
450 |
+
* Filter sidebar login status arguments.
|
451 |
+
*
|
452 |
+
* @since 3.4.0
|
453 |
+
*
|
454 |
+
* @param array $defaults
|
455 |
+
* @return array
|
456 |
+
*/
|
457 |
+
$args = apply_filters( 'wpmem_login_widget_status_args', $defaults );
|
458 |
|
459 |
// Merge $args with $defaults.
|
460 |
$args = wp_parse_args( $args, $defaults );
|
466 |
* Filter the sidebar user login status.
|
467 |
*
|
468 |
* @since unknown
|
469 |
+
* @deprecated 3.4.0 Use wpmem_login_widget_status instead.
|
470 |
*
|
471 |
* @param string $str The login status for the user.
|
472 |
*/
|
473 |
$str = apply_filters( 'wpmem_sidebar_status', $str );
|
474 |
+
/**
|
475 |
+
* Filter the sidebar user login status.
|
476 |
+
*
|
477 |
+
* @since 3.4.0
|
478 |
+
*
|
479 |
+
* @param string $str The login status for the user.
|
480 |
+
*/
|
481 |
+
$str = apply_filters( 'wpmem_login_widget_status', $str );
|
482 |
|
483 |
echo $str;
|
484 |
}
|
@@ -1,2129 +1,1791 @@
|
|
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 |
-
* Plugin path.
|
41 |
-
*
|
42 |
-
* @since 3.3.0
|
43 |
-
* @access public
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
public $path;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Plugin __FILE__.
|
50 |
-
*
|
51 |
-
* @since 3.3.0
|
52 |
-
* @access public
|
53 |
-
* @var string
|
54 |
-
*/
|
55 |
-
public $name;
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Plugin slug.
|
59 |
-
*
|
60 |
-
* @since 3.3.0
|
61 |
-
* @access public
|
62 |
-
* @var string
|
63 |
-
*/
|
64 |
-
public $slug;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Plugin URL.
|
68 |
-
*
|
69 |
-
* @since 3.3.0
|
70 |
-
* @access public
|
71 |
-
* @var string
|
72 |
-
*/
|
73 |
-
public $url;
|
74 |
-
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Content block settings.
|
78 |
-
*
|
79 |
-
* @since 3.0.0
|
80 |
-
* @access public
|
81 |
-
* @var array
|
82 |
-
*/
|
83 |
-
public $block;
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Excerpt settings.
|
87 |
-
*
|
88 |
-
* @since 3.0.0
|
89 |
-
* @access public
|
90 |
-
* @var array
|
91 |
-
*/
|
92 |
-
public $show_excerpt;
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Show login form settings.
|
96 |
-
*
|
97 |
-
* @since 3.0.0
|
98 |
-
* @access public
|
99 |
-
* @var array
|
100 |
-
*/
|
101 |
-
public $show_login;
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Show registration form settings.
|
105 |
-
*
|
106 |
-
* @since 3.0.0
|
107 |
-
* @access public
|
108 |
-
* @var array
|
109 |
-
*/
|
110 |
-
public $show_reg;
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Auto-excerpt settings.
|
114 |
-
*
|
115 |
-
* @since 3.0.0
|
116 |
-
* @access public
|
117 |
-
* @var array
|
118 |
-
*/
|
119 |
-
public $autoex;
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Notify admin settings.
|
123 |
-
*
|
124 |
-
* @since 3.0.0
|
125 |
-
* @access public
|
126 |
-
* @var string
|
127 |
-
*/
|
128 |
-
public $notify;
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Moderated registration settings.
|
132 |
-
*
|
133 |
-
* @since 3.0.0
|
134 |
-
* @access public
|
135 |
-
* @var string
|
136 |
-
*/
|
137 |
-
public $mod_reg;
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Captcha settings.
|
141 |
-
*
|
142 |
-
* @since 3.0.0
|
143 |
-
* @access public
|
144 |
-
* @var array
|
145 |
-
*/
|
146 |
-
public $captcha;
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Enable expiration extension settings.
|
150 |
-
*
|
151 |
-
* @since 3.0.0
|
152 |
-
* @access public
|
153 |
-
* @var string
|
154 |
-
*/
|
155 |
-
public $use_exp;
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Expiration extension enable trial period.
|
159 |
-
*
|
160 |
-
* @since 3.0.0
|
161 |
-
* @access public
|
162 |
-
* @var string
|
163 |
-
*/
|
164 |
-
public $use_trial;
|
165 |
-
|
166 |
-
/**
|
167 |
-
*
|
168 |
-
*
|
169 |
-
* @since 3.0.0
|
170 |
-
* @access public
|
171 |
-
* @var array
|
172 |
-
*/
|
173 |
-
public $warnings;
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Enable drop-ins setting.
|
177 |
-
*
|
178 |
-
* @since 3.1.9
|
179 |
-
* @access public
|
180 |
-
* @var string
|
181 |
-
*/
|
182 |
-
public $dropins = 0;
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Container for enabled dropins.
|
186 |
-
*
|
187 |
-
* @since 3.1.9
|
188 |
-
* @access public
|
189 |
-
* @var array
|
190 |
-
*/
|
191 |
-
public $dropins_enabled = array();
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Current plugin action container.
|
195 |
-
*
|
196 |
-
* @since 3.0.0
|
197 |
-
* @access public
|
198 |
-
* @var string
|
199 |
-
*/
|
200 |
-
public $action;
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Regchk container.
|
204 |
-
*
|
205 |
-
* @since 3.0.0
|
206 |
-
* @access public
|
207 |
-
* @var string
|
208 |
-
*/
|
209 |
-
public $regchk;
|
210 |
-
|
211 |
-
/**
|
212 |
-
* User page settings.
|
213 |
-
*
|
214 |
-
* @since 3.0.0
|
215 |
-
* @access public
|
216 |
-
* @var array
|
217 |
-
*/
|
218 |
-
public $user_pages;
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Custom Post Type settings.
|
222 |
-
*
|
223 |
-
* @since 3.0.0
|
224 |
-
* @access public
|
225 |
-
* @var array
|
226 |
-
*/
|
227 |
-
public $post_types;
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Setting for applying texturization.
|
231 |
-
*
|
232 |
-
* @since 3.1.7
|
233 |
-
* @access public
|
234 |
-
* @var boolean
|
235 |
-
*/
|
236 |
-
public $texturize;
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Enable product creation.
|
240 |
-
*
|
241 |
-
* @since 3.2.0
|
242 |
-
* @access public
|
243 |
-
* @var boolean
|
244 |
-
*/
|
245 |
-
public $enable_products;
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Enable logged-in menu clones.
|
249 |
-
*
|
250 |
-
* @since 3.2.0
|
251 |
-
* @access public
|
252 |
-
* @var string
|
253 |
-
*/
|
254 |
-
public $clone_menus;
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Container for error messages.
|
258 |
-
*
|
259 |
-
* @since 3.2.0
|
260 |
-
* @access public
|
261 |
-
* @var string
|
262 |
-
*/
|
263 |
-
public $error;
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Container for admin notices.
|
267 |
-
*
|
268 |
-
* @since 3.3.0
|
269 |
-
* @access public
|
270 |
-
* @var array
|
271 |
-
*/
|
272 |
-
public $admin_notices;
|
273 |
-
|
274 |
-
/**
|
275 |
-
* Container for stylesheet setting.
|
276 |
-
*
|
277 |
-
* @since 3.2.7
|
278 |
-
* @access public
|
279 |
-
* @var string
|
280 |
-
*/
|
281 |
-
public $select_style;
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Container for dropin folder location.
|
285 |
-
*
|
286 |
-
* @since 3.3.0
|
287 |
-
* @access public
|
288 |
-
* @var string
|
289 |
-
*/
|
290 |
-
public $dropin_dir;
|
291 |
-
|
292 |
-
/**
|
293 |
-
* REST conditional.
|
294 |
-
*
|
295 |
-
* @since 3.3.2
|
296 |
-
* @access public
|
297 |
-
* @var boolean
|
298 |
-
*/
|
299 |
-
public $is_rest = false;
|
300 |
-
|
301 |
-
/**
|
302 |
-
* Temporary setting for activation link.
|
303 |
-
* Will default to 0 until 3.4.0, then 1 until 3.5.0
|
304 |
-
* at which point we'll remove the old process.
|
305 |
-
*
|
306 |
-
* @since 3.3.5
|
307 |
-
* @access public
|
308 |
-
* @var string
|
309 |
-
*/
|
310 |
-
public $act_link = 0;
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Temporary setting for password reset.
|
314 |
-
* Will default to 0 until 3.4.0, then 1 until 3.5.0
|
315 |
-
* at which point we'll remove the old process.
|
316 |
-
*
|
317 |
-
* @since 3.3.5
|
318 |
-
* @access public
|
319 |
-
* @var string
|
320 |
-
*/
|
321 |
-
public $pwd_link =
|
322 |
-
|
323 |
-
/**
|
324 |
-
* Temporary settings for login errors.
|
325 |
-
* Will default to 0 until 3.4.0.
|
326 |
-
*
|
327 |
-
* @since 3.3.5
|
328 |
-
* @access public
|
329 |
-
* @var string
|
330 |
-
*/
|
331 |
-
public $login_error =
|
332 |
-
|
333 |
-
/**
|
334 |
-
* Default file upload directory.
|
335 |
-
*
|
336 |
-
* @since 3.3.8
|
337 |
-
* @access public
|
338 |
-
* @var string
|
339 |
-
*/
|
340 |
-
public $upload_base = 'wpmembers';
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Plugin initialization function.
|
344 |
-
*
|
345 |
-
* @since 3.0.0
|
346 |
-
* @since 3.1.6 Dependencies now loaded by object.
|
347 |
-
*/
|
348 |
-
function __construct() {
|
349 |
-
|
350 |
-
// Constants.
|
351 |
-
$this->path = plugin_dir_path( __DIR__ );
|
352 |
-
$this->name = $this->path . 'wp-members.php';
|
353 |
-
$this->slug = substr( basename( $this->name ), 0, -4 );
|
354 |
-
$this->url = plugin_dir_url ( __DIR__ );
|
355 |
-
|
356 |
-
// Load dependent files.
|
357 |
-
$this->load_dependencies();
|
358 |
-
|
359 |
-
/**
|
360 |
-
* Filter the options before they are loaded into constants.
|
361 |
-
*
|
362 |
-
* @since 2.9.0
|
363 |
-
* @since 3.0.0 Moved to the WP_Members class.
|
364 |
-
*
|
365 |
-
* @param array $this->settings An array of the WP-Members settings.
|
366 |
-
*/
|
367 |
-
$settings = apply_filters( 'wpmem_settings', get_option( 'wpmembers_settings' ) );
|
368 |
-
|
369 |
-
// Validate that v3 settings are loaded.
|
370 |
-
if ( ! isset( $settings['version'] )
|
371 |
-
|| $settings['version'] != $this->version
|
372 |
-
|| ! isset( $settings['db_version'] )
|
373 |
-
|| $settings['db_version'] != $this->db_version ) {
|
374 |
-
/**
|
375 |
-
* Load installation routine.
|
376 |
-
*/
|
377 |
-
require_once( $this->path . 'includes/install.php' );
|
378 |
-
// Update settings.
|
379 |
-
/** This filter is documented in /inc/class-wp-members.php */
|
380 |
-
$settings = apply_filters( 'wpmem_settings', wpmem_do_install() );
|
381 |
-
}
|
382 |
-
|
383 |
-
// Assemble settings.
|
384 |
-
foreach ( $settings as $key => $val ) {
|
385 |
-
$this->$key = $val;
|
386 |
-
}
|
387 |
-
|
388 |
-
$this->load_user_pages();
|
389 |
-
$this->set_style();
|
390 |
-
|
391 |
-
$this->forms = new WP_Members_Forms; // Load forms.
|
392 |
-
$this->api = new WP_Members_API; // Load api.
|
393 |
-
$this->shortcodes = new WP_Members_Shortcodes(); // Load shortcodes.
|
394 |
-
$this->membership = new WP_Members_Products(); // Load membership plans
|
395 |
-
$this->email = new WP_Members_Email; // Load email functions
|
396 |
-
$this->user = new WP_Members_User( $this ); // Load user functions.
|
397 |
-
$this->menus = new WP_Members_Menus();
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
*
|
414 |
-
*
|
415 |
-
* @
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
$
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
*
|
446 |
-
*
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
*
|
453 |
-
*
|
454 |
-
* @since 3.
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
add_action( 'init', array( $this
|
462 |
-
add_action( '
|
463 |
-
add_action( '
|
464 |
-
add_action( '
|
465 |
-
add_action( '
|
466 |
-
add_action( '
|
467 |
-
add_action( '
|
468 |
-
add_action( 'wp_enqueue_scripts', array( $this, '
|
469 |
-
add_action( '
|
470 |
-
add_action( '
|
471 |
-
add_action( '
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
add_action( '
|
493 |
-
add_action( '
|
494 |
-
add_action( '
|
495 |
-
add_action( '
|
496 |
-
add_action( '
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
add_filter( '
|
504 |
-
add_filter( '
|
505 |
-
add_filter( '
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
add_filter( '
|
513 |
-
add_filter( '
|
514 |
-
add_filter( '
|
515 |
-
add_filter( '
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
/**
|
554 |
-
*
|
555 |
-
*
|
556 |
-
* @since 3.0.0
|
557 |
-
* @since 3.
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
require_once( $this->path . 'includes/
|
627 |
-
require_once( $this->path . 'includes/class-wp-members-
|
628 |
-
require_once( $this->path . 'includes/class-wp-members-
|
629 |
-
require_once( $this->path . 'includes/class-wp-members-
|
630 |
-
require_once( $this->path . 'includes/class-wp-members-
|
631 |
-
require_once( $this->path . 'includes/
|
632 |
-
require_once( $this->path . 'includes/
|
633 |
-
require_once( $this->path . 'includes/
|
634 |
-
require_once( $this->path . 'includes/
|
635 |
-
require_once( $this->path . 'includes/
|
636 |
-
require_once( $this->path . 'includes/
|
637 |
-
require_once( $this->path . 'includes/
|
638 |
-
require_once( $this->path . 'includes/
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
//
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
*
|
722 |
-
*
|
723 |
-
*
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
*
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
)
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
*
|
892 |
-
*
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
$len = strpos( $content, '<span id="more' );
|
943 |
-
if ( false === $len ) {
|
944 |
-
$content = wpmem_do_excerpt( $content );
|
945 |
-
} else {
|
946 |
-
$content = substr( $content, 0, $len );
|
947 |
-
}
|
948 |
-
|
949 |
-
} else {
|
950 |
-
|
951 |
-
// Empty all content.
|
952 |
-
$content = '';
|
953 |
-
|
954 |
-
}
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
$content = ( isset( $this->
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
*
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
*
|
1053 |
-
*
|
1054 |
-
* @
|
1055 |
-
*
|
1056 |
-
* @
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
*
|
1082 |
-
*
|
1083 |
-
* @
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
$
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
*
|
1118 |
-
*
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
$
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
*
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
*
|
1144 |
-
*
|
1145 |
-
* @
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
$hidden
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
*
|
1416 |
-
*
|
1417 |
-
*
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
*
|
1517 |
-
*
|
1518 |
-
*
|
1519 |
-
* @
|
1520 |
-
* @
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
*
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
*
|
1720 |
-
*
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
*
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
$
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
'
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
}
|
1791 |
-
|
1792 |
-
/**
|
1793 |
-
* Overrides the wptexturize filter.
|
1794 |
-
*
|
1795 |
-
* Currently only used for the login form to remove the <br> tag that WP puts in after the "Remember Me".
|
1796 |
-
*
|
1797 |
-
* @since 2.6.4
|
1798 |
-
* @since 3.2.3 Moved to WP_Members class.
|
1799 |
-
*
|
1800 |
-
* @todo Possibly deprecate or severely alter this process as its need may be obsolete.
|
1801 |
-
*
|
1802 |
-
* @param string $content
|
1803 |
-
* @return string $new_content
|
1804 |
-
*/
|
1805 |
-
function texturize( $content ) {
|
1806 |
-
|
1807 |
-
$new_content = '';
|
1808 |
-
$pattern_full = '{(\[wpmem_txt\].*?\[/wpmem_txt\])}is';
|
1809 |
-
$pattern_contents = '{\[wpmem_txt\](.*?)\[/wpmem_txt\]}is';
|
1810 |
-
$pieces = preg_split( $pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE );
|
1811 |
-
|
1812 |
-
foreach ( $pieces as $piece ) {
|
1813 |
-
if ( preg_match( $pattern_contents, $piece, $matches ) ) {
|
1814 |
-
$new_content .= $matches[1];
|
1815 |
-
} else {
|
1816 |
-
$new_content .= wptexturize( wpautop( $piece ) );
|
1817 |
-
}
|
1818 |
-
}
|
1819 |
-
|
1820 |
-
return $new_content;
|
1821 |
-
}
|
1822 |
-
|
1823 |
-
/**
|
1824 |
-
* Loads the stylesheet for tableless forms.
|
1825 |
-
*
|
1826 |
-
* @since 2.6
|
1827 |
-
* @since 3.2.3 Moved to WP_Members class.
|
1828 |
-
*
|
1829 |
-
* @global object $wpmem The WP_Members object.
|
1830 |
-
*/
|
1831 |
-
function enqueue_style() {
|
1832 |
-
global $wpmem;
|
1833 |
-
wp_enqueue_style ( 'wp-members', wpmem_force_ssl( $wpmem->cssurl ), false, $wpmem->version );
|
1834 |
-
}
|
1835 |
-
|
1836 |
-
/**
|
1837 |
-
* Loads the wp-login.php stylesheet.
|
1838 |
-
*
|
1839 |
-
* @since 3.3.0
|
1840 |
-
*
|
1841 |
-
* @global stdClass $wpmem
|
1842 |
-
*/
|
1843 |
-
function enqueue_style_wp_login() {
|
1844 |
-
global $wpmem;
|
1845 |
-
wp_enqueue_style( 'wp-members', $wpmem->url . 'assets/css/wp-login' . wpmem_get_suffix() . '.css', false, $wpmem->version );
|
1846 |
-
}
|
1847 |
-
|
1848 |
-
/**
|
1849 |
-
* Creates an excerpt on the fly if there is no 'more' tag.
|
1850 |
-
*
|
1851 |
-
* @since 2.6
|
1852 |
-
* @since 3.2.3 Moved to WP_Members class.
|
1853 |
-
* @since 3.2.5 Check if post object exists.
|
1854 |
-
*
|
1855 |
-
* @global object $post The post object.
|
1856 |
-
* @global object $wpmem The WP_Members object.
|
1857 |
-
*
|
1858 |
-
* @param string $content
|
1859 |
-
* @return string $content
|
1860 |
-
*/
|
1861 |
-
function do_excerpt( $content ) {
|
1862 |
-
|
1863 |
-
global $post, $more, $wpmem;
|
1864 |
-
|
1865 |
-
if ( is_object( $post ) ) {
|
1866 |
-
|
1867 |
-
$post_id = $post->ID;
|
1868 |
-
$post_type = $post->post_type;
|
1869 |
-
|
1870 |
-
$autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
|
1871 |
-
|
1872 |
-
// Is there already a 'more' link in the content?
|
1873 |
-
$has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
|
1874 |
-
|
1875 |
-
// If auto_ex is on.
|
1876 |
-
if ( $autoex ) {
|
1877 |
-
|
1878 |
-
// Build an excerpt if one does not exist.
|
1879 |
-
if ( ! $has_more_link ) {
|
1880 |
-
|
1881 |
-
$is_singular = ( is_singular( $post->post_type ) ) ? true : false;
|
1882 |
-
|
1883 |
-
if ( $is_singular ) {
|
1884 |
-
// If it's a single post, we don't need the 'more' link.
|
1885 |
-
$more_link_text = '';
|
1886 |
-
$more_link = '';
|
1887 |
-
} else {
|
1888 |
-
// The default $more_link_text.
|
1889 |
-
if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
|
1890 |
-
$more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
|
1891 |
-
} else {
|
1892 |
-
$more_link_text = __( '(more…)' );
|
1893 |
-
}
|
1894 |
-
// The default $more_link.
|
1895 |
-
$more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
|
1896 |
-
}
|
1897 |
-
|
1898 |
-
// Apply the_content_more_link filter if one exists (will match up all 'more' link text).
|
1899 |
-
/** This filter is documented in /wp-includes/post-template.php */
|
1900 |
-
$more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
|
1901 |
-
|
1902 |
-
$defaults = array(
|
1903 |
-
'length' => $autoex['length'],
|
1904 |
-
'more_link' => $more_link,
|
1905 |
-
'blocked_only' => false,
|
1906 |
-
);
|
1907 |
-
/**
|
1908 |
-
* Filter auto excerpt defaults.
|
1909 |
-
*
|
1910 |
-
* @since 3.0.9
|
1911 |
-
* @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
|
1912 |
-
*
|
1913 |
-
* @param array {
|
1914 |
-
* An array of settings to override the function defaults.
|
1915 |
-
*
|
1916 |
-
* @type int $length The default length of the excerpt.
|
1917 |
-
* @type string $more_link The more link HTML.
|
1918 |
-
* @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
|
1919 |
-
* }
|
1920 |
-
* @param string $post->ID The post ID.
|
1921 |
-
* @param string $post->post_type The content's post type.
|
1922 |
-
*/
|
1923 |
-
$args = apply_filters( 'wpmem_auto_excerpt_args', '', $post->ID, $post->post_type );
|
1924 |
-
|
1925 |
-
// Merge settings.
|
1926 |
-
$args = wp_parse_args( $args, $defaults );
|
1927 |
-
|
1928 |
-
// Are we only excerpting blocked content?
|
1929 |
-
if ( $args['blocked_only'] ) {
|
1930 |
-
$post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
|
1931 |
-
if ( 1 == $wpmem->block[ $post->post_type ] ) {
|
1932 |
-
// Post type is blocked, if post meta unblocks it, don't do excerpt.
|
1933 |
-
$do_excerpt = ( "0" == $post_meta ) ? false : true;
|
1934 |
-
} else {
|
1935 |
-
// Post type is unblocked, if post meta blocks it, do excerpt.
|
1936 |
-
$do_excerpt = ( "1" == $post_meta ) ? true : false;
|
1937 |
-
}
|
1938 |
-
} else {
|
1939 |
-
$do_excerpt = true;
|
1940 |
-
}
|
1941 |
-
|
1942 |
-
if ( true === $do_excerpt ) {
|
1943 |
-
$content = wp_trim_words( $content, $args['length'], $args['more_link'] );
|
1944 |
-
// Check if the more link was added (note: singular has no more_link):
|
1945 |
-
if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
|
1946 |
-
$content = $content . $args['more_link'];
|
1947 |
-
}
|
1948 |
-
}
|
1949 |
-
}
|
1950 |
-
}
|
1951 |
-
} else {
|
1952 |
-
$post_id = false;
|
1953 |
-
$post_type = false;
|
1954 |
-
}
|
1955 |
-
|
1956 |
-
/**
|
1957 |
-
* Filter the auto excerpt.
|
1958 |
-
*
|
1959 |
-
* @since 2.8.1
|
1960 |
-
* @since 3.0.9 Added post ID and post type parameters.
|
1961 |
-
* @since 3.2.5 Post ID and post type may be false if there is no post object.
|
1962 |
-
*
|
1963 |
-
* @param string $content The content excerpt.
|
1964 |
-
* @param string $post_id The post ID.
|
1965 |
-
* @param string $post_type The content's post type.
|
1966 |
-
*/
|
1967 |
-
$content = apply_filters( 'wpmem_auto_excerpt', $content, $post_id, $post_type );
|
1968 |
-
|
1969 |
-
// Return the excerpt.
|
1970 |
-
return $content;
|
1971 |
-
}
|
1972 |
-
|
1973 |
-
/**
|
1974 |
-
* Convert form tag.
|
1975 |
-
*
|
1976 |
-
* @todo This is temporary to handle form tag conversion.
|
1977 |
-
*
|
1978 |
-
* @since 3.1.7
|
1979 |
-
* @since 3.2.3 Moved to WP_Members class.
|
1980 |
-
* @since 3.3.0 Removed unnecessary tags.
|
1981 |
-
*
|
1982 |
-
* @param string $tag
|
1983 |
-
* @return string $tag
|
1984 |
-
*/
|
1985 |
-
function convert_tag( $tag ) {
|
1986 |
-
switch ( $tag ) {
|
1987 |
-
case 'new':
|
1988 |
-
return 'register';
|
1989 |
-
break;
|
1990 |
-
case 'edit':
|
1991 |
-
case 'update':
|
1992 |
-
return 'profile';
|
1993 |
-
break;
|
1994 |
-
default:
|
1995 |
-
return $tag;
|
1996 |
-
break;
|
1997 |
-
}
|
1998 |
-
return $tag;
|
1999 |
-
}
|
2000 |
-
|
2001 |
-
/**
|
2002 |
-
* Loads translation files.
|
2003 |
-
*
|
2004 |
-
* @since 3.0.0
|
2005 |
-
* @since 3.2.5 Moved to main object, dropped wpmem_ stem.
|
2006 |
-
*/
|
2007 |
-
function load_textdomain() {
|
2008 |
-
|
2009 |
-
// @see: https://ulrich.pogson.ch/load-theme-plugin-translations for notes on changes.
|
2010 |
-
|
2011 |
-
// Plugin textdomain.
|
2012 |
-
$domain = 'wp-members';
|
2013 |
-
|
2014 |
-
// Wordpress locale.
|
2015 |
-
/** This filter is documented in wp-includes/l10n.php */
|
2016 |
-
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
2017 |
-
|
2018 |
-
/**
|
2019 |
-
* Filter translation file.
|
2020 |
-
*
|
2021 |
-
* If the translate.wordpress.org language pack is available, it will
|
2022 |
-
* be /wp-content/languages/plugins/wp-members-{locale}.mo by default.
|
2023 |
-
* You can filter this if you want to load a language pack from a
|
2024 |
-
* different location (or different file name).
|
2025 |
-
*
|
2026 |
-
* @since 3.0.0
|
2027 |
-
* @since 3.2.0 Added locale as a parameter.
|
2028 |
-
*
|
2029 |
-
* @param string $file The translation file to load.
|
2030 |
-
* @param string $locale The current locale.
|
2031 |
-
*/
|
2032 |
-
$file = apply_filters( 'wpmem_localization_file', trailingslashit( WP_LANG_DIR ) . 'plugins/' . $domain . '-' . $locale . '.mo', $locale );
|
2033 |
-
|
2034 |
-
$loaded = load_textdomain( $domain, $file );
|
2035 |
-
if ( $loaded ) {
|
2036 |
-
return $loaded;
|
2037 |
-
} else {
|
2038 |
-
/**
|
2039 |
-
* Filter translation directory.
|
2040 |
-
*
|
2041 |
-
* @since 3.0.3
|
2042 |
-
* @since 3.2.0 Added locale as a parameter.
|
2043 |
-
*
|
2044 |
-
* @param string $dir The translation directory.
|
2045 |
-
* @param string $locale The current locale.
|
2046 |
-
*/
|
2047 |
-
$dir = apply_filters( 'wpmem_localization_dir', basename( $this->path ) . '/i18n/languages/', $locale );
|
2048 |
-
load_plugin_textdomain( $domain, FALSE, $dir );
|
2049 |
-
}
|
2050 |
-
return;
|
2051 |
-
}
|
2052 |
-
|
2053 |
-
/**
|
2054 |
-
* Load default tos template.
|
2055 |
-
*
|
2056 |
-
* @since 3.2.8
|
2057 |
-
*/
|
2058 |
-
function load_default_tos() {
|
2059 |
-
// Check for custom template or load default.
|
2060 |
-
$custom_template = get_stylesheet_directory() . '/wp-members/templates/tos.php';
|
2061 |
-
if ( file_exists( $custom_template ) ) {
|
2062 |
-
require_once( $custom_template );
|
2063 |
-
} else {
|
2064 |
-
require_once( $this->path . 'templates/tos.php' );
|
2065 |
-
}
|
2066 |
-
}
|
2067 |
-
|
2068 |
-
/**
|
2069 |
-
* Builds defaults for login/out links/buttons.
|
2070 |
-
*
|
2071 |
-
* @since 3.3.5
|
2072 |
-
*
|
2073 |
-
* @param array $args
|
2074 |
-
* @return string $html
|
2075 |
-
*/
|
2076 |
-
function loginout_args( $args = array() ) {
|
2077 |
-
$defaults = array(
|
2078 |
-
'format' => ( isset( $args['format'] ) ) ? $args['format'] : 'link',
|
2079 |
-
'login_redirect_to' => ( isset( $args['login_redirect_to'] ) ) ? $args['login_redirect_to'] : wpmem_current_url(),
|
2080 |
-
'logout_redirect_to' => ( isset( $args['logout_redirect_to'] ) ) ? $args['logout_redirect_to'] : wpmem_current_url(), // @todo - This is not currently active.
|
2081 |
-
'login_text' => ( isset( $args['login_text'] ) ) ? $args['login_text'] : __( 'log in', 'wp-members' ),
|
2082 |
-
'logout_text' => ( isset( $args['logout_text'] ) ) ? $args['logout_text'] : __( 'log out', 'wp-members' ),
|
2083 |
-
'class' => ( isset( $args['class'] ) ) ? $args['class'] : 'wpmem_loginout_link',
|
2084 |
-
'id' => ( isset( $args['id'] ) ) ? $args['id'] : 'wpmem_loginout_link',
|
2085 |
-
);
|
2086 |
-
$args = wp_parse_args( $args, $defaults );
|
2087 |
-
$redirect = ( is_user_logged_in() ) ? $args['logout_redirect_to'] : $args['login_redirect_to'];
|
2088 |
-
$text = ( is_user_logged_in() ) ? $args['logout_text'] : $args['login_text'];
|
2089 |
-
if ( is_user_logged_in() ) {
|
2090 |
-
/** This filter is defined in /inc/dialogs.php */
|
2091 |
-
$link = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
|
2092 |
-
} else {
|
2093 |
-
$link = wpmem_login_url( $redirect );
|
2094 |
-
}
|
2095 |
-
|
2096 |
-
if ( 'button' == $args['format'] ) {
|
2097 |
-
$html = '<form action="' . $link . '" id="' . $args['id'] . '" class="' . $args['class'] . '">';
|
2098 |
-
$html.= ( is_user_logged_in() ) ? '<input type="hidden" name="a" value="logout" />' : '';
|
2099 |
-
$html.= '<input type="submit" value="' . $text . '" /></form>';
|
2100 |
-
} else {
|
2101 |
-
$html = sprintf( '<a href="%s" id="%" class="%s">%s</a>', $link, $args['id'], $args['class'], $text );
|
2102 |
-
}
|
2103 |
-
return $html;
|
2104 |
-
}
|
2105 |
-
|
2106 |
-
/**
|
2107 |
-
* Filters the password URL to point to the WP-Members process.
|
2108 |
-
*
|
2109 |
-
* @since 3.3.5
|
2110 |
-
*/
|
2111 |
-
function lost_pwd_url( $lostpwd_url, $redirect ) {
|
2112 |
-
return wpmem_profile_url( 'pwdreset' );
|
2113 |
-
}
|
2114 |
-
|
2115 |
-
/**
|
2116 |
-
* Filters the login error message to display the WP login error.
|
2117 |
-
*
|
2118 |
-
* @since 3.3.5
|
2119 |
-
*/
|
2120 |
-
function login_error( $args = array() ) {
|
2121 |
-
if ( $this->error ) {
|
2122 |
-
$args['heading_before'] = '';
|
2123 |
-
$args['heading'] = '';
|
2124 |
-
$args['heading_after'] = '';
|
2125 |
-
$args['message'] = $this->error;
|
2126 |
-
}
|
2127 |
-
return $args;
|
2128 |
-
}
|
2129 |
} // 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 |
+
* Plugin path.
|
41 |
+
*
|
42 |
+
* @since 3.3.0
|
43 |
+
* @access public
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
public $path;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Plugin __FILE__.
|
50 |
+
*
|
51 |
+
* @since 3.3.0
|
52 |
+
* @access public
|
53 |
+
* @var string
|
54 |
+
*/
|
55 |
+
public $name;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Plugin slug.
|
59 |
+
*
|
60 |
+
* @since 3.3.0
|
61 |
+
* @access public
|
62 |
+
* @var string
|
63 |
+
*/
|
64 |
+
public $slug;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Plugin URL.
|
68 |
+
*
|
69 |
+
* @since 3.3.0
|
70 |
+
* @access public
|
71 |
+
* @var string
|
72 |
+
*/
|
73 |
+
public $url;
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Content block settings.
|
78 |
+
*
|
79 |
+
* @since 3.0.0
|
80 |
+
* @access public
|
81 |
+
* @var array
|
82 |
+
*/
|
83 |
+
public $block;
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Excerpt settings.
|
87 |
+
*
|
88 |
+
* @since 3.0.0
|
89 |
+
* @access public
|
90 |
+
* @var array
|
91 |
+
*/
|
92 |
+
public $show_excerpt;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Show login form settings.
|
96 |
+
*
|
97 |
+
* @since 3.0.0
|
98 |
+
* @access public
|
99 |
+
* @var array
|
100 |
+
*/
|
101 |
+
public $show_login;
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Show registration form settings.
|
105 |
+
*
|
106 |
+
* @since 3.0.0
|
107 |
+
* @access public
|
108 |
+
* @var array
|
109 |
+
*/
|
110 |
+
public $show_reg;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Auto-excerpt settings.
|
114 |
+
*
|
115 |
+
* @since 3.0.0
|
116 |
+
* @access public
|
117 |
+
* @var array
|
118 |
+
*/
|
119 |
+
public $autoex;
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Notify admin settings.
|
123 |
+
*
|
124 |
+
* @since 3.0.0
|
125 |
+
* @access public
|
126 |
+
* @var string
|
127 |
+
*/
|
128 |
+
public $notify;
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Moderated registration settings.
|
132 |
+
*
|
133 |
+
* @since 3.0.0
|
134 |
+
* @access public
|
135 |
+
* @var string
|
136 |
+
*/
|
137 |
+
public $mod_reg;
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Captcha settings.
|
141 |
+
*
|
142 |
+
* @since 3.0.0
|
143 |
+
* @access public
|
144 |
+
* @var array
|
145 |
+
*/
|
146 |
+
public $captcha;
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Enable expiration extension settings.
|
150 |
+
*
|
151 |
+
* @since 3.0.0
|
152 |
+
* @access public
|
153 |
+
* @var string
|
154 |
+
*/
|
155 |
+
public $use_exp;
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Expiration extension enable trial period.
|
159 |
+
*
|
160 |
+
* @since 3.0.0
|
161 |
+
* @access public
|
162 |
+
* @var string
|
163 |
+
*/
|
164 |
+
public $use_trial;
|
165 |
+
|
166 |
+
/**
|
167 |
+
*
|
168 |
+
*
|
169 |
+
* @since 3.0.0
|
170 |
+
* @access public
|
171 |
+
* @var array
|
172 |
+
*/
|
173 |
+
public $warnings;
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Enable drop-ins setting.
|
177 |
+
*
|
178 |
+
* @since 3.1.9
|
179 |
+
* @access public
|
180 |
+
* @var string
|
181 |
+
*/
|
182 |
+
public $dropins = 0;
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Container for enabled dropins.
|
186 |
+
*
|
187 |
+
* @since 3.1.9
|
188 |
+
* @access public
|
189 |
+
* @var array
|
190 |
+
*/
|
191 |
+
public $dropins_enabled = array();
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Current plugin action container.
|
195 |
+
*
|
196 |
+
* @since 3.0.0
|
197 |
+
* @access public
|
198 |
+
* @var string
|
199 |
+
*/
|
200 |
+
public $action;
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Regchk container.
|
204 |
+
*
|
205 |
+
* @since 3.0.0
|
206 |
+
* @access public
|
207 |
+
* @var string
|
208 |
+
*/
|
209 |
+
public $regchk;
|
210 |
+
|
211 |
+
/**
|
212 |
+
* User page settings.
|
213 |
+
*
|
214 |
+
* @since 3.0.0
|
215 |
+
* @access public
|
216 |
+
* @var array
|
217 |
+
*/
|
218 |
+
public $user_pages;
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Custom Post Type settings.
|
222 |
+
*
|
223 |
+
* @since 3.0.0
|
224 |
+
* @access public
|
225 |
+
* @var array
|
226 |
+
*/
|
227 |
+
public $post_types;
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Setting for applying texturization.
|
231 |
+
*
|
232 |
+
* @since 3.1.7
|
233 |
+
* @access public
|
234 |
+
* @var boolean
|
235 |
+
*/
|
236 |
+
public $texturize;
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Enable product creation.
|
240 |
+
*
|
241 |
+
* @since 3.2.0
|
242 |
+
* @access public
|
243 |
+
* @var boolean
|
244 |
+
*/
|
245 |
+
public $enable_products;
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Enable logged-in menu clones.
|
249 |
+
*
|
250 |
+
* @since 3.2.0
|
251 |
+
* @access public
|
252 |
+
* @var string
|
253 |
+
*/
|
254 |
+
public $clone_menus;
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Container for error messages.
|
258 |
+
*
|
259 |
+
* @since 3.2.0
|
260 |
+
* @access public
|
261 |
+
* @var string
|
262 |
+
*/
|
263 |
+
public $error;
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Container for admin notices.
|
267 |
+
*
|
268 |
+
* @since 3.3.0
|
269 |
+
* @access public
|
270 |
+
* @var array
|
271 |
+
*/
|
272 |
+
public $admin_notices;
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Container for stylesheet setting.
|
276 |
+
*
|
277 |
+
* @since 3.2.7
|
278 |
+
* @access public
|
279 |
+
* @var string
|
280 |
+
*/
|
281 |
+
public $select_style;
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Container for dropin folder location.
|
285 |
+
*
|
286 |
+
* @since 3.3.0
|
287 |
+
* @access public
|
288 |
+
* @var string
|
289 |
+
*/
|
290 |
+
public $dropin_dir;
|
291 |
+
|
292 |
+
/**
|
293 |
+
* REST conditional.
|
294 |
+
*
|
295 |
+
* @since 3.3.2
|
296 |
+
* @access public
|
297 |
+
* @var boolean
|
298 |
+
*/
|
299 |
+
public $is_rest = false;
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Temporary setting for activation link.
|
303 |
+
* Will default to 0 until 3.4.0, then 1 until 3.5.0
|
304 |
+
* at which point we'll remove the old process.
|
305 |
+
*
|
306 |
+
* @since 3.3.5
|
307 |
+
* @access public
|
308 |
+
* @var string
|
309 |
+
*/
|
310 |
+
public $act_link = 0;
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Temporary setting for password reset.
|
314 |
+
* Will default to 0 until 3.4.0, then 1 until 3.5.0
|
315 |
+
* at which point we'll remove the old process.
|
316 |
+
*
|
317 |
+
* @since 3.3.5
|
318 |
+
* @access public
|
319 |
+
* @var string
|
320 |
+
*/
|
321 |
+
public $pwd_link = 1;
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Temporary settings for login errors.
|
325 |
+
* Will default to 0 until 3.4.0.
|
326 |
+
*
|
327 |
+
* @since 3.3.5
|
328 |
+
* @access public
|
329 |
+
* @var string
|
330 |
+
*/
|
331 |
+
public $login_error = 1;
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Default file upload directory.
|
335 |
+
*
|
336 |
+
* @since 3.3.8
|
337 |
+
* @access public
|
338 |
+
* @var string
|
339 |
+
*/
|
340 |
+
public $upload_base = 'wpmembers';
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Plugin initialization function.
|
344 |
+
*
|
345 |
+
* @since 3.0.0
|
346 |
+
* @since 3.1.6 Dependencies now loaded by object.
|
347 |
+
*/
|
348 |
+
function __construct() {
|
349 |
+
|
350 |
+
// Constants.
|
351 |
+
$this->path = plugin_dir_path( __DIR__ );
|
352 |
+
$this->name = $this->path . 'wp-members.php';
|
353 |
+
$this->slug = substr( basename( $this->name ), 0, -4 );
|
354 |
+
$this->url = plugin_dir_url ( __DIR__ );
|
355 |
+
|
356 |
+
// Load dependent files.
|
357 |
+
$this->load_dependencies();
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Filter the options before they are loaded into constants.
|
361 |
+
*
|
362 |
+
* @since 2.9.0
|
363 |
+
* @since 3.0.0 Moved to the WP_Members class.
|
364 |
+
*
|
365 |
+
* @param array $this->settings An array of the WP-Members settings.
|
366 |
+
*/
|
367 |
+
$settings = apply_filters( 'wpmem_settings', get_option( 'wpmembers_settings' ) );
|
368 |
+
|
369 |
+
// Validate that v3 settings are loaded.
|
370 |
+
if ( ! isset( $settings['version'] )
|
371 |
+
|| $settings['version'] != $this->version
|
372 |
+
|| ! isset( $settings['db_version'] )
|
373 |
+
|| $settings['db_version'] != $this->db_version ) {
|
374 |
+
/**
|
375 |
+
* Load installation routine.
|
376 |
+
*/
|
377 |
+
require_once( $this->path . 'includes/install.php' );
|
378 |
+
// Update settings.
|
379 |
+
/** This filter is documented in /inc/class-wp-members.php */
|
380 |
+
$settings = apply_filters( 'wpmem_settings', wpmem_do_install() );
|
381 |
+
}
|
382 |
+
|
383 |
+
// Assemble settings.
|
384 |
+
foreach ( $settings as $key => $val ) {
|
385 |
+
$this->$key = $val;
|
386 |
+
}
|
387 |
+
|
388 |
+
$this->load_user_pages();
|
389 |
+
$this->set_style();
|
390 |
+
|
391 |
+
$this->forms = new WP_Members_Forms; // Load forms.
|
392 |
+
$this->api = new WP_Members_API; // Load api.
|
393 |
+
$this->shortcodes = new WP_Members_Shortcodes(); // Load shortcodes.
|
394 |
+
$this->membership = new WP_Members_Products(); // Load membership plans
|
395 |
+
$this->email = new WP_Members_Email; // Load email functions
|
396 |
+
$this->user = new WP_Members_User( $this ); // Load user functions.
|
397 |
+
$this->menus = new WP_Members_Menus();
|
398 |
+
$this->dialogs = new WP_Members_Dialogs();
|
399 |
+
if ( $this->clone_menus ) {
|
400 |
+
$this->menus_clone = new WP_Members_Clone_Menus(); // Load clone menus.
|
401 |
+
}
|
402 |
+
if ( 1 == $this->pwd_link ) {
|
403 |
+
$this->pwd_reset = new WP_Members_Pwd_Reset;
|
404 |
+
}
|
405 |
+
if ( 1 == $this->act_link ) {
|
406 |
+
$this->act_newreg = new WP_Members_Validation_Link;
|
407 |
+
}
|
408 |
+
|
409 |
+
// @todo Is this a temporary fix?
|
410 |
+
$this->email->load_from();
|
411 |
+
|
412 |
+
/**
|
413 |
+
* Fires after main settings are loaded.
|
414 |
+
*
|
415 |
+
* @since 3.0
|
416 |
+
* @deprecated 3.2.0 Use wpmem_after_init instead.
|
417 |
+
*/
|
418 |
+
do_action( 'wpmem_settings_loaded' );
|
419 |
+
|
420 |
+
// Preload the expiration module, if available.
|
421 |
+
$exp_active = ( function_exists( 'wpmem_exp_init' ) || function_exists( 'wpmem_set_exp' ) ) ? true : false;
|
422 |
+
define( 'WPMEM_EXP_MODULE', $exp_active );
|
423 |
+
|
424 |
+
// Load actions and filters.
|
425 |
+
$this->load_hooks();
|
426 |
+
|
427 |
+
// Load contants.
|
428 |
+
$this->load_constants();
|
429 |
+
|
430 |
+
// Load dropins.
|
431 |
+
if ( $this->dropins ) {
|
432 |
+
$this->load_dropins();
|
433 |
+
}
|
434 |
+
|
435 |
+
// Check for anything that we should stop execution for (currently just the default tos).
|
436 |
+
if ( 'display' == wpmem_get( 'tos', false, 'get' ) ) {
|
437 |
+
// If themes are not loaded, we don't need them.
|
438 |
+
$user_themes = ( ! defined( 'WP_USE_THEMES' ) ) ? define( 'WP_USE_THEMES', false ) : '';
|
439 |
+
$this->load_default_tos();
|
440 |
+
die();
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Plugin initialization function to load hooks.
|
446 |
+
*
|
447 |
+
* @since 3.0.0
|
448 |
+
*/
|
449 |
+
function load_hooks() {
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Fires before action and filter hooks load.
|
453 |
+
*
|
454 |
+
* @since 3.0.0
|
455 |
+
* @since 3.1.6 Fires before hooks load.
|
456 |
+
*/
|
457 |
+
do_action( 'wpmem_load_hooks' );
|
458 |
+
|
459 |
+
// Add actions.
|
460 |
+
|
461 |
+
add_action( 'init', array( $this, 'load_textdomain' ) ); //add_action( 'plugins_loaded', 'wpmem_load_textdomain' );
|
462 |
+
add_action( 'init', array( $this->membership, 'add_cpt' ), 0 ); // Adds membership plans custom post type.
|
463 |
+
add_action( 'widgets_init', array( $this, 'widget_init' ) ); // initializes the widget
|
464 |
+
add_action( 'admin_init', array( $this, 'load_admin' ) ); // check user role to load correct dashboard
|
465 |
+
add_action( 'rest_api_init', array( $this, 'rest_init' ) );
|
466 |
+
add_action( 'template_redirect', array( $this, 'get_action' ) );
|
467 |
+
add_action( 'login_enqueue_scripts', array( $this, 'enqueue_style_wp_login' ) ); // styles the native registration
|
468 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); // Enqueues the stylesheet.
|
469 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'loginout_script' ) );
|
470 |
+
add_action( 'pre_get_posts', array( $this, 'do_hide_posts' ), 20 );
|
471 |
+
add_action( 'customize_register', array( $this, 'customizer_settings' ) );
|
472 |
+
add_action( 'admin_menu', 'wpmem_admin_options' ); // adds admin menu
|
473 |
+
add_action( 'wp_footer', array( $this, 'invisible_captcha' ) );
|
474 |
+
|
475 |
+
if ( is_user_logged_in() ) {
|
476 |
+
add_action( 'wpmem_pwd_change', array( $this->user, 'set_password' ), 9, 2 );
|
477 |
+
add_action( 'wpmem_pwd_change', array( $this->user, 'set_as_logged_in' ), 10 );
|
478 |
+
}
|
479 |
+
|
480 |
+
add_action( 'register_form', 'wpmem_wp_register_form' ); // adds fields to the default wp registration
|
481 |
+
|
482 |
+
if ( wpmem_is_woo_active() ) {
|
483 |
+
|
484 |
+
// Handle "My Account" page registration.
|
485 |
+
if ( isset( $this->woo['add_my_account_fields'] ) && 1 == $this->woo['add_my_account_fields'] ) {
|
486 |
+
add_action( 'woocommerce_register_form', 'wpmem_woo_register_form' );
|
487 |
+
add_action( 'woocommerce_register_post', 'wpmem_woo_reg_validate', 10, 3 );
|
488 |
+
}
|
489 |
+
// Handle Registration checkout
|
490 |
+
if ( isset( $this->woo['add_checkout_fields'] ) && 1 == $this->woo['add_checkout_fields'] && ! is_user_logged_in() ) {
|
491 |
+
add_filter( 'woocommerce_checkout_fields', 'wpmem_woo_checkout_form' );
|
492 |
+
add_action( 'woocommerce_checkout_update_order_meta', 'wpmem_woo_checkout_update_meta' );
|
493 |
+
//add_action( 'woocommerce_save_account_details_errors', 'wpmem_woo_reg_validate' );
|
494 |
+
add_action( 'woocommerce_form_field_multicheckbox', 'wpmem_form_field_wc_custom_field_types', 10, 4 );
|
495 |
+
add_action( 'woocommerce_form_field_multiselect', 'wpmem_form_field_wc_custom_field_types', 10, 4 );
|
496 |
+
add_action( 'woocommerce_form_field_radio', 'wpmem_form_field_wc_custom_field_types', 10, 4 );
|
497 |
+
add_action( 'woocommerce_form_field_select', 'wpmem_form_field_wc_custom_field_types', 10, 4 );
|
498 |
+
add_action( 'woocommerce_form_field_checkbox', 'wpmem_form_field_wc_custom_field_types', 10, 4 );
|
499 |
+
}
|
500 |
+
}
|
501 |
+
|
502 |
+
// Add filters.
|
503 |
+
add_filter( 'the_content', array( $this, 'do_securify' ), 99 );
|
504 |
+
add_filter( 'comments_open', array( $this, 'do_securify_comments' ), 99, 2 ); // securifies the comments
|
505 |
+
add_filter( 'wpmem_securify', array( $this, 'reg_securify' ) ); // adds success message on login form if redirected
|
506 |
+
add_filter( 'rest_prepare_post', array( $this, 'do_securify_rest' ), 10, 3 );
|
507 |
+
add_filter( 'rest_prepare_page', array( $this, 'do_securify_rest' ), 10, 3 );
|
508 |
+
foreach( $this->post_types as $post_type ) {
|
509 |
+
add_filter( "rest_prepare_{$post_type}", array( $this, 'do_securify_rest' ), 10, 3 );
|
510 |
+
}
|
511 |
+
|
512 |
+
//add_filter( 'query_vars', array( $this, 'add_query_vars' ), 10, 2 ); // adds custom query vars
|
513 |
+
add_filter( 'get_pages', array( $this, 'filter_get_pages' ) );
|
514 |
+
add_filter( 'wp_get_nav_menu_items', array( $this, 'filter_nav_menu_items' ), null, 3 );
|
515 |
+
add_filter( 'get_previous_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
|
516 |
+
add_filter( 'get_next_post_where', array( $this, 'filter_get_adjacent_post_where' ) );
|
517 |
+
add_filter( 'allow_password_reset', array( $this->user, 'no_reset' ) ); // no password reset for non-activated users
|
518 |
+
|
519 |
+
// If registration is moderated, check for activation (blocks backend login by non-activated users).
|
520 |
+
if ( $this->mod_reg == 1 ) {
|
521 |
+
add_filter( 'authenticate', array( $this->user, 'check_activated' ), 99, 3 );
|
522 |
+
}
|
523 |
+
|
524 |
+
// Replace login error object.
|
525 |
+
if ( 1 == $this->login_error ) {
|
526 |
+
// @todo I think we can do this without the filter now that
|
527 |
+
// the main messaging function has been updated.
|
528 |
+
// add_filter( 'wpmem_login_failed_args', array( $this->dialogs, 'login_error' ) );
|
529 |
+
add_filter( 'lostpassword_url', array( $this, 'lost_pwd_url' ), 10, 2 );
|
530 |
+
}
|
531 |
+
|
532 |
+
if ( function_exists( 'wpmem_custom_translation_strings' ) ) {
|
533 |
+
add_filter( 'wpmem_fields', array( $this->forms, 'localize_fields' ), 9 );
|
534 |
+
}
|
535 |
+
/**
|
536 |
+
* Fires after action and filter hooks load.
|
537 |
+
*
|
538 |
+
* @since 3.0.0
|
539 |
+
* @since 3.1.6 Was wpmem_load_hooks, now wpmem_hooks_loaded.
|
540 |
+
*/
|
541 |
+
do_action( 'wpmem_hooks_loaded' );
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Load drop-ins.
|
546 |
+
*
|
547 |
+
* @since 3.0.0
|
548 |
+
*
|
549 |
+
* @todo This is experimental. The function and its operation is subject to change.
|
550 |
+
*/
|
551 |
+
function load_dropins() {
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Fires before dropins load (for adding additional drop-ins).
|
555 |
+
*
|
556 |
+
* @since 3.0.0
|
557 |
+
* @since 3.1.6 Fires before dropins.
|
558 |
+
*/
|
559 |
+
do_action( 'wpmem_load_dropins' );
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Filters the drop-in file directory.
|
563 |
+
*
|
564 |
+
* @since 3.0.0
|
565 |
+
* @since 3.3.0 Filter previously unpublished, changed hook name.
|
566 |
+
*
|
567 |
+
* @param string $wpmem->dropin_dir The drop-in file directory.
|
568 |
+
*/
|
569 |
+
$dir = apply_filters( 'wpmem_dropin_dir', $this->dropin_dir );
|
570 |
+
|
571 |
+
// Load any drop-ins.
|
572 |
+
$settings = get_option( 'wpmembers_dropins' );
|
573 |
+
$this->dropins_enabled = ( $settings ) ? $settings : array();
|
574 |
+
if ( ! empty( $this->dropins_enabled ) ) {
|
575 |
+
foreach ( $this->dropins_enabled as $filename ) {
|
576 |
+
$dropin = $dir . $filename;
|
577 |
+
if ( file_exists( $dropin ) ) {
|
578 |
+
include_once( $dropin );
|
579 |
+
}
|
580 |
+
}
|
581 |
+
}
|
582 |
+
|
583 |
+
/**
|
584 |
+
* Fires before dropins load (for adding additional drop-ins).
|
585 |
+
*
|
586 |
+
* @since 3.0.0
|
587 |
+
* @since 3.1.6 Was wpmem_load_dropins, now wpmem_dropins_loaded.
|
588 |
+
*/
|
589 |
+
do_action( 'wpmem_dropins_loaded' );
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
+
* Loads pre-3.0 constants (included primarily for add-on compatibility).
|
594 |
+
*
|
595 |
+
* @since 3.0.0
|
596 |
+
* @since 3.3.0 Deprecated all but exp and trl constants.
|
597 |
+
*/
|
598 |
+
function load_constants() {
|
599 |
+
( ! defined( 'WPMEM_MOD_REG' ) ) ? define( 'WPMEM_MOD_REG', $this->mod_reg ) : '';
|
600 |
+
( ! defined( 'WPMEM_USE_EXP' ) ) ? define( 'WPMEM_USE_EXP', $this->use_exp ) : '';
|
601 |
+
( ! defined( 'WPMEM_USE_TRL' ) ) ? define( 'WPMEM_USE_TRL', $this->use_trial ) : '';
|
602 |
+
}
|
603 |
+
|
604 |
+
/**
|
605 |
+
* Load dependent files.
|
606 |
+
*
|
607 |
+
* @since 3.1.6
|
608 |
+
*/
|
609 |
+
function load_dependencies() {
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Filter the location and name of the pluggable file.
|
613 |
+
*
|
614 |
+
* @since 2.9.0
|
615 |
+
* @since 3.1.6 Moved in load order to come before dependencies.
|
616 |
+
*
|
617 |
+
* @param string The path to WP-Members plugin functions file.
|
618 |
+
*/
|
619 |
+
$wpmem_pluggable = apply_filters( 'wpmem_plugins_file', WP_PLUGIN_DIR . '/wp-members-pluggable.php' );
|
620 |
+
|
621 |
+
// Preload any custom functions, if available.
|
622 |
+
if ( file_exists( $wpmem_pluggable ) ) {
|
623 |
+
include( $wpmem_pluggable );
|
624 |
+
}
|
625 |
+
|
626 |
+
require_once( $this->path . 'includes/libraries/rocketgeek-utilities/loader.php' );
|
627 |
+
require_once( $this->path . 'includes/class-wp-members-api.php' );
|
628 |
+
require_once( $this->path . 'includes/class-wp-members-clone-menus.php' );
|
629 |
+
require_once( $this->path . 'includes/class-wp-members-captcha.php' );
|
630 |
+
require_once( $this->path . 'includes/class-wp-members-dialogs.php' );
|
631 |
+
require_once( $this->path . 'includes/class-wp-members-email.php' );
|
632 |
+
require_once( $this->path . 'includes/class-wp-members-forms.php' );
|
633 |
+
require_once( $this->path . 'includes/class-wp-members-menus.php' );
|
634 |
+
require_once( $this->path . 'includes/class-wp-members-products.php' );
|
635 |
+
require_once( $this->path . 'includes/class-wp-members-pwd-reset.php' );
|
636 |
+
require_once( $this->path . 'includes/class-wp-members-shortcodes.php' );
|
637 |
+
require_once( $this->path . 'includes/class-wp-members-user.php' );
|
638 |
+
require_once( $this->path . 'includes/class-wp-members-user-profile.php' );
|
639 |
+
require_once( $this->path . 'includes/class-wp-members-validation-link.php' );
|
640 |
+
require_once( $this->path . 'includes/class-wp-members-widget.php' );
|
641 |
+
require_once( $this->path . 'includes/api/api.php' );
|
642 |
+
require_once( $this->path . 'includes/api/api-email.php' );
|
643 |
+
require_once( $this->path . 'includes/api/api-forms.php' );
|
644 |
+
require_once( $this->path . 'includes/api/api-products.php' );
|
645 |
+
require_once( $this->path . 'includes/api/api-users.php' );
|
646 |
+
require_once( $this->path . 'includes/api/api-utilities.php' );
|
647 |
+
require_once( $this->path . 'includes/deprecated.php' );
|
648 |
+
|
649 |
+
require_once( $this->path . 'includes/legacy/dialogs.php' ); // File is totally deprecated at this point; eval for removal.
|
650 |
+
|
651 |
+
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
652 |
+
require_once( $this->path . 'includes/cli/class-wp-members-cli.php' );
|
653 |
+
require_once( $this->path . 'includes/cli/class-wp-members-cli-user.php' );
|
654 |
+
require_once( $this->path . 'includes/cli/class-wp-members-cli-settings.php' );
|
655 |
+
}
|
656 |
+
}
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Load admin API and dependencies.
|
660 |
+
*
|
661 |
+
* Determines which scripts to load and actions to use based on the
|
662 |
+
* current users capabilities.
|
663 |
+
*
|
664 |
+
* @since 2.5.2
|
665 |
+
* @since 3.1.0 Added admin api object.
|
666 |
+
* @since 3.1.7 Moved from main plugin file as wpmem_chk_admin() to main object.
|
667 |
+
*/
|
668 |
+
function load_admin() {
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Fires before initialization of admin options.
|
672 |
+
*
|
673 |
+
* @since 2.9.0
|
674 |
+
*/
|
675 |
+
do_action( 'wpmem_pre_admin_init' );
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Load the admin api class.
|
679 |
+
*
|
680 |
+
* @since 3.1.0
|
681 |
+
*/
|
682 |
+
include_once( $this->path . 'includes/admin/class-wp-members-admin-api.php' );
|
683 |
+
$this->admin = new WP_Members_Admin_API;
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Fires after initialization of admin options.
|
687 |
+
*
|
688 |
+
* @since 2.9.0
|
689 |
+
*/
|
690 |
+
do_action( 'wpmem_after_admin_init' );
|
691 |
+
}
|
692 |
+
|
693 |
+
/**
|
694 |
+
* Gets the requested action.
|
695 |
+
*
|
696 |
+
* @since 3.0.0
|
697 |
+
*
|
698 |
+
* @global string $wpmem_a The WP-Members action variable.
|
699 |
+
*/
|
700 |
+
function get_action() {
|
701 |
+
|
702 |
+
// Get the action being done (if any).
|
703 |
+
$this->action = sanitize_text_field( wpmem_get( 'a', '', 'request' ) );
|
704 |
+
|
705 |
+
// For backward compatibility with processes that check $wpmem_a.
|
706 |
+
global $wpmem_a;
|
707 |
+
$wpmem_a = $this->action;
|
708 |
+
|
709 |
+
/**
|
710 |
+
* Fires when the wpmem action is retrieved.
|
711 |
+
*
|
712 |
+
* @since 3.1.7
|
713 |
+
*/
|
714 |
+
do_action( 'wpmem_get_action' );
|
715 |
+
|
716 |
+
// Get the regchk value (if any).
|
717 |
+
$this->regchk = $this->get_regchk( $this->action );
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Gets the regchk value.
|
722 |
+
*
|
723 |
+
* regchk is a legacy variable that contains information about the current
|
724 |
+
* action being performed. Login, logout, password, registration, profile
|
725 |
+
* update functions all return a specific value that is stored in regchk.
|
726 |
+
* This value and information about the current action can then be used to
|
727 |
+
* determine what content is to be displayed by the securify function.
|
728 |
+
*
|
729 |
+
* @since 3.0.0
|
730 |
+
*
|
731 |
+
* @global string $wpmem_a The WP-Members action variable.
|
732 |
+
*
|
733 |
+
* @param string $action The current action.
|
734 |
+
* @return string The regchk value.
|
735 |
+
*/
|
736 |
+
function get_regchk( $action ) {
|
737 |
+
|
738 |
+
switch ( $action ) {
|
739 |
+
|
740 |
+
case 'login':
|
741 |
+
$regchk = $this->user->login();
|
742 |
+
break;
|
743 |
+
|
744 |
+
case 'logout':
|
745 |
+
$regchk = $this->user->logout();
|
746 |
+
break;
|
747 |
+
|
748 |
+
case 'pwdchange':
|
749 |
+
$regchk = $this->user->password_update( 'change' );
|
750 |
+
break;
|
751 |
+
|
752 |
+
case 'pwdreset':
|
753 |
+
$regchk = $this->user->password_update( 'reset' );
|
754 |
+
break;
|
755 |
+
|
756 |
+
case 'getusername':
|
757 |
+
$regchk = $this->user->retrieve_username();
|
758 |
+
break;
|
759 |
+
|
760 |
+
case 'register':
|
761 |
+
case 'update':
|
762 |
+
$regchk = wpmem_user_register( $action );
|
763 |
+
break;
|
764 |
+
|
765 |
+
default:
|
766 |
+
$regchk = ( isset( $regchk ) ) ? $regchk : '';
|
767 |
+
break;
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Filter wpmem_regchk.
|
772 |
+
*
|
773 |
+
* The value of regchk is determined by functions that may be run in the get_regchk function.
|
774 |
+
* This value determines what happens in the wpmem_securify() function.
|
775 |
+
*
|
776 |
+
* @since 2.9.0
|
777 |
+
* @since 3.0.0 Moved to get_regchk() in WP_Members object.
|
778 |
+
*
|
779 |
+
* @param string $this->regchk The value of wpmem_regchk.
|
780 |
+
* @param string $this->action The $wpmem_a action.
|
781 |
+
*/
|
782 |
+
$regchk = apply_filters( 'wpmem_regchk', $regchk, $action );
|
783 |
+
|
784 |
+
// Legacy global variable for use with older extensions.
|
785 |
+
global $wpmem_regchk;
|
786 |
+
$wpmem_regchk = $regchk;
|
787 |
+
|
788 |
+
return $regchk;
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Determines if content should be blocked.
|
793 |
+
*
|
794 |
+
* This function was originally stand alone in the core file and
|
795 |
+
* was moved to the WP_Members class in 3.0.
|
796 |
+
*
|
797 |
+
* @since 3.0.0
|
798 |
+
* @since 3.3.0 Added $post_id
|
799 |
+
* @since 3.4.0 Added $is_post_check to allow for individual post checking.
|
800 |
+
*
|
801 |
+
* @global object $post The WordPress Post object.
|
802 |
+
*
|
803 |
+
* @param int $post_id
|
804 |
+
* @return bool $block true|false
|
805 |
+
*/
|
806 |
+
function is_blocked( $post_id = false ) {
|
807 |
+
|
808 |
+
global $post;
|
809 |
+
|
810 |
+
$is_post_check = ( false === $post_id ) ? false : true;
|
811 |
+
|
812 |
+
if ( $post || $post_id ) {
|
813 |
+
|
814 |
+
$the_post = ( false === $post_id ) ? $post : get_post( $post_id );
|
815 |
+
|
816 |
+
$meta = wpmem_get_block_setting( $the_post->ID );
|
817 |
+
|
818 |
+
// Backward compatibility for old block/unblock meta.
|
819 |
+
if ( ! $meta ) {
|
820 |
+
// Check for old meta.
|
821 |
+
$old_block = get_post_meta( $the_post->ID, 'block', true );
|
822 |
+
$old_unblock = get_post_meta( $the_post->ID, 'unblock', true );
|
823 |
+
$meta = ( $old_block ) ? 1 : ( ( $old_unblock ) ? 0 : $meta );
|
824 |
+
}
|
825 |
+
|
826 |
+
// Setup defaults.
|
827 |
+
$defaults = array(
|
828 |
+
'post_id' => $the_post->ID,
|
829 |
+
'post_type' => $the_post->post_type,
|
830 |
+
'block' => ( isset( $this->block[ $the_post->post_type ] ) && $this->block[ $the_post->post_type ] == 1 ) ? true : false,
|
831 |
+
'block_meta' => $meta,
|
832 |
+
'block_type' => ( isset( $this->block[ $the_post->post_type ] ) ) ? $this->block[ $the_post->post_type ] : 0,
|
833 |
+
);
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Filter the block arguments.
|
837 |
+
*
|
838 |
+
* @since 2.9.8
|
839 |
+
* @since 3.0.0 Moved to is_blocked() in WP_Members object.
|
840 |
+
* @since 3.3.0 Passes $defaults, second argument deprecated.
|
841 |
+
*
|
842 |
+
* @param array $args $defaults.
|
843 |
+
* @param array $defaults Deprecated 3.3.0.
|
844 |
+
*/
|
845 |
+
$args = apply_filters( 'wpmem_block_args', $defaults, $defaults );
|
846 |
+
|
847 |
+
// Merge $args with defaults.
|
848 |
+
$args = ( wp_parse_args( $args, $defaults ) );
|
849 |
+
|
850 |
+
if ( $is_post_check || is_single() || is_page() || wpmem_is_rest() ) {
|
851 |
+
switch( $args['block_type'] ) {
|
852 |
+
case 1: // If content is blocked by default.
|
853 |
+
$args['block'] = ( $args['block_meta'] == '0' ) ? false : $args['block'];
|
854 |
+
break;
|
855 |
+
case 0 : // If content is unblocked by default.
|
856 |
+
$args['block'] = ( $args['block_meta'] == '1' ) ? true : $args['block'];
|
857 |
+
break;
|
858 |
+
}
|
859 |
+
|
860 |
+
} else {
|
861 |
+
$args['block'] = false;
|
862 |
+
}
|
863 |
+
|
864 |
+
} else {
|
865 |
+
$args = array( 'block' => false );
|
866 |
+
}
|
867 |
+
|
868 |
+
// Don't block user pages.
|
869 |
+
$args['block'] = ( in_array( get_permalink(), $this->user_pages ) ) ? false : $args['block'];
|
870 |
+
|
871 |
+
/**
|
872 |
+
* Filter the block boolean.
|
873 |
+
*
|
874 |
+
* @since 2.7.5
|
875 |
+
*
|
876 |
+
* @param bool $args['block']
|
877 |
+
* @param array $args {
|
878 |
+
* An array of arguments used in the function.
|
879 |
+
*
|
880 |
+
* @type string $post_id
|
881 |
+
* @type string $post_type
|
882 |
+
* @type string $block
|
883 |
+
* @type string $block_meta
|
884 |
+
* @tyep string $block_type
|
885 |
+
* }
|
886 |
+
*/
|
887 |
+
return apply_filters( 'wpmem_block', $args['block'], $args );
|
888 |
+
}
|
889 |
+
|
890 |
+
/**
|
891 |
+
* The Securify Content Filter.
|
892 |
+
*
|
893 |
+
* This is the primary function that picks up where get_action() leaves off.
|
894 |
+
* Determines whether content is shown or hidden for both post and pages. This
|
895 |
+
* is a filter function for the_content.
|
896 |
+
*
|
897 |
+
* @link https://developer.wordpress.org/reference/functions/the_content/
|
898 |
+
* @link https://developer.wordpress.org/reference/hooks/the_content/
|
899 |
+
*
|
900 |
+
* @since 3.0.0
|
901 |
+
*
|
902 |
+
* @global object $post The WordPress Post object.
|
903 |
+
* @global object $wpmem The WP_Members object.
|
904 |
+
* @global string $wpmem_themsg Contains messages to be output.
|
905 |
+
* @param string $content
|
906 |
+
* @return string $content
|
907 |
+
*/
|
908 |
+
function do_securify( $content = null ) {
|
909 |
+
|
910 |
+
global $post, $wpmem, $wpmem_themsg;
|
911 |
+
|
912 |
+
$orig_content = $content;
|
913 |
+
|
914 |
+
$content = ( is_single() || is_page() ) ? $content : wpmem_do_excerpt( $content );
|
915 |
+
|
916 |
+
if ( $this->regchk == "captcha" ) {
|
917 |
+
global $wpmem_captcha_err;
|
918 |
+
$wpmem_themsg = wpmem_get_text( 'reg_captcha_err' ) . '<br /><br />' . $wpmem_captcha_err;
|
919 |
+
}
|
920 |
+
|
921 |
+
// Block/unblock Posts.
|
922 |
+
if ( ! is_user_logged_in() && true == $this->is_blocked() ) {
|
923 |
+
|
924 |
+
// If there is a regchk action, show the login and/or registration forms.
|
925 |
+
if ( $this->regchk ) {
|
926 |
+
|
927 |
+
$content = wpmem_get_display_message( $this->regchk, $wpmem_themsg );
|
928 |
+
$content .= ( 'loginfailed' == $this->regchk || 'success' == $this->regchk ) ? wpmem_login_form() : wpmem_register_form();
|
929 |
+
|
930 |
+
} else {
|
931 |
+
|
932 |
+
// Toggle shows excerpt above login/reg on posts/pages.
|
933 |
+
global $wp_query;
|
934 |
+
if ( isset( $wp_query->query_vars['page'] ) && $wp_query->query_vars['page'] > 1 ) {
|
935 |
+
|
936 |
+
// Shuts down excerpts on multipage posts if not on first page.
|
937 |
+
$content = '';
|
938 |
+
|
939 |
+
} elseif ( isset( $this->show_excerpt[ $post->post_type ] ) && 1 == $this->show_excerpt[ $post->post_type ] ) {
|
940 |
+
|
941 |
+
// @todo Can this be condensed or eliminated?
|
942 |
+
$len = strpos( $content, '<span id="more' );
|
943 |
+
if ( false === $len ) {
|
944 |
+
$content = wpmem_do_excerpt( $content );
|
945 |
+
} else {
|
946 |
+
$content = substr( $content, 0, $len );
|
947 |
+
}
|
948 |
+
|
949 |
+
} else {
|
950 |
+
|
951 |
+
// Empty all content.
|
952 |
+
$content = '';
|
953 |
+
|
954 |
+
}
|
955 |
+
|
956 |
+
// Build up default view based on settings.
|
957 |
+
$content = $content . wpmem_restricted_message();
|
958 |
+
$content = ( isset( $this->show_login[ $post->post_type ] ) && 1 == $this->show_login[ $post->post_type ] ) ? $content . wpmem_login_form() : $content;
|
959 |
+
$content = ( isset( $this->show_reg[ $post->post_type ] ) && 1 == $this->show_reg[ $post->post_type ] ) ? $content . wpmem_register_form() : $content;
|
960 |
+
}
|
961 |
+
|
962 |
+
// Protects comments if expiration module is used and user is expired.
|
963 |
+
} elseif ( is_user_logged_in() && true == $this->is_blocked() ) {
|
964 |
+
|
965 |
+
// Allows for a view of the forms in the Customizer.
|
966 |
+
if ( is_customize_preview() ) {
|
967 |
+
|
968 |
+
if ( get_theme_mod( 'wpmem_show_logged_out_state', false ) ) {
|
969 |
+
$content = '';
|
970 |
+
if ( get_theme_mod( 'wpmem_show_form_message_dialog', false ) ) {
|
971 |
+
$content = $this->dialogs->login_failed();
|
972 |
+
} else {
|
973 |
+
$content = wpmem_restricted_message();
|
974 |
+
}
|
975 |
+
$content = ( isset( $this->show_login[ $post->post_type ] ) && 1 == $this->show_login[ $post->post_type ] ) ? $content . wpmem_login_form() : $content;
|
976 |
+
$content = ( isset( $this->show_reg[ $post->post_type ] ) && 1 == $this->show_reg[ $post->post_type ] ) ? $content . wpmem_register_form() : $content;
|
977 |
+
}
|
978 |
+
} else {
|
979 |
+
|
980 |
+
// @todo Test with expired membership.
|
981 |
+
if ( 1 == $this->use_exp && function_exists( 'wpmem_do_expmessage' ) ) {
|
982 |
+
/**
|
983 |
+
* Filters the user expired message used by the PayPal extension.
|
984 |
+
*
|
985 |
+
* @since 3.2.0
|
986 |
+
*
|
987 |
+
* @param string $message
|
988 |
+
* @param string $content
|
989 |
+
*/
|
990 |
+
$content = apply_filters( 'wpmem_do_expmessage', wpmem_do_expmessage( $content ), $content );
|
991 |
+
}
|
992 |
+
}
|
993 |
+
}
|
994 |
+
|
995 |
+
/**
|
996 |
+
* Filter the value of $content after wpmem_securify has run.
|
997 |
+
*
|
998 |
+
* @since 2.7.7
|
999 |
+
* @since 3.0.0 Moved to new method in WP_Members Class.
|
1000 |
+
* @since 3.4.0 Added $orig_content param.
|
1001 |
+
*
|
1002 |
+
* @param string $content The content after securify has run.
|
1003 |
+
*/
|
1004 |
+
$content = apply_filters( 'wpmem_securify', $content, $orig_content );
|
1005 |
+
|
1006 |
+
return $content;
|
1007 |
+
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
/**
|
1011 |
+
* Securifies the comments.
|
1012 |
+
*
|
1013 |
+
* If the user is not logged in and the content is blocked
|
1014 |
+
* (i.e. wpmem->is_blocked() returns true), function loads a
|
1015 |
+
* dummy/empty comments template.
|
1016 |
+
*
|
1017 |
+
* @since 2.9.9
|
1018 |
+
* @since 3.2.0 Moved wpmem_securify_comments() to main class, renamed.
|
1019 |
+
* @since 3.3.2 Added $post_id.
|
1020 |
+
*
|
1021 |
+
* @param bool $open Whether the current post is open for comments.
|
1022 |
+
* @param int $post_id The post ID.
|
1023 |
+
* @return bool $open True if current post is open for comments, otherwise false.
|
1024 |
+
*/
|
1025 |
+
function do_securify_comments( $open, $post_id ) {
|
1026 |
+
|
1027 |
+
$open = ( ! is_user_logged_in() && wpmem_is_blocked( $post_id ) ) ? false : $open;
|
1028 |
+
|
1029 |
+
/**
|
1030 |
+
* Filters whether comments are open or not.
|
1031 |
+
*
|
1032 |
+
* @since 3.0.0
|
1033 |
+
* @since 3.2.0 Moved to main class.
|
1034 |
+
* @since 3.3.2 Added $post_id.
|
1035 |
+
*
|
1036 |
+
* @param bool $open true if current post is open for comments, otherwise false.
|
1037 |
+
*/
|
1038 |
+
$open = apply_filters( 'wpmem_securify_comments', $open, $post_id );
|
1039 |
+
|
1040 |
+
if ( ! $open ) {
|
1041 |
+
/** This filter is documented in wp-includes/comment-template.php */
|
1042 |
+
add_filter( 'comments_array', array( $this, 'do_securify_comments_array' ), 10, 2 );
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
return $open;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
/**
|
1049 |
+
* Empties the comments array if content is blocked.
|
1050 |
+
*
|
1051 |
+
* @since 3.0.1
|
1052 |
+
* @since 3.2.0 Moved wpmem_securify_comments_array() to main class, renamed.
|
1053 |
+
*
|
1054 |
+
* @param array $comments
|
1055 |
+
* @param int $post_id
|
1056 |
+
* @return array $comments The comments array.
|
1057 |
+
*/
|
1058 |
+
function do_securify_comments_array( $comments , $post_id ) {
|
1059 |
+
$comments = ( ! is_user_logged_in() && wpmem_is_blocked( $post_id ) ) ? array() : $comments;
|
1060 |
+
return $comments;
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
/**
|
1064 |
+
* Handles REST request.
|
1065 |
+
*
|
1066 |
+
* @since 3.3.2
|
1067 |
+
*
|
1068 |
+
* @param WP_REST_Response $response The response object.
|
1069 |
+
* @param WP_Post $post Post object.
|
1070 |
+
* @param WP_REST_Request $request Request object.
|
1071 |
+
* @return
|
1072 |
+
*/
|
1073 |
+
function do_securify_rest( $response, $post, $request ) {
|
1074 |
+
|
1075 |
+
if ( ! is_user_logged_in() ) { // @todo This needs to be changed to check for whether the user has access (for internal requests).
|
1076 |
+
// Response for restricted content
|
1077 |
+
$block_value = wpmem_is_blocked( $response->data['id'] );
|
1078 |
+
if ( $block_value ) {
|
1079 |
+
if ( isset( $response->data['content']['rendered'] ) ) {
|
1080 |
+
/**
|
1081 |
+
* Filters restricted content message.
|
1082 |
+
*
|
1083 |
+
* @since 3.3.2
|
1084 |
+
* @since 3.3.4 Added $response, $post, and $request
|
1085 |
+
*
|
1086 |
+
* @param string $message
|
1087 |
+
*/
|
1088 |
+
$response->data['content']['rendered'] = apply_filters( "wpmem_securify_rest_{$post->post_type}_content", __( "You must be logged in to view this content.", 'wp-members' ), $response, $post, $request );
|
1089 |
+
}
|
1090 |
+
if ( isset( $response->data['excerpt']['rendered'] ) ) {
|
1091 |
+
/**
|
1092 |
+
* Filters restricted excerpt message.
|
1093 |
+
*
|
1094 |
+
* @since 3.3.2
|
1095 |
+
* @since 3.3.4 Added $response, $post, and $request
|
1096 |
+
*
|
1097 |
+
* @param string $message
|
1098 |
+
*/
|
1099 |
+
$response->data['excerpt']['rendered'] = apply_filters( "wpmem_securify_rest_{$post->post_type}_excerpt", __( "You must be logged in to view this content.", 'wp-members' ), $response, $post, $request );
|
1100 |
+
}
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
// Response for hidden content. @todo This needs to be changed to check for whether the user has access (for internal requests).
|
1104 |
+
if ( ! is_admin() && in_array( $post->ID, $this->hidden_posts() ) ) {
|
1105 |
+
return new WP_REST_Response( __( 'The page you are looking for does not exist', 'wp-members' ), 404 );
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
return $response;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
/**
|
1112 |
+
* Adds the successful registration message on the login page if reg_nonce validates.
|
1113 |
+
*
|
1114 |
+
* @since 3.1.7
|
1115 |
+
* @since 3.2.0 Moved to wpmem object, renamed reg_securify()
|
1116 |
+
*
|
1117 |
+
* @param string $content
|
1118 |
+
* @return string $content
|
1119 |
+
*/
|
1120 |
+
function reg_securify( $content ) {
|
1121 |
+
global $wpmem, $wpmem_themsg;
|
1122 |
+
$nonce = wpmem_get( 'reg_nonce', false, 'get' );
|
1123 |
+
if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
|
1124 |
+
$content = wpmem_get_display_message( 'success', $wpmem_themsg );
|
1125 |
+
$content = $content . wpmem_login_form();
|
1126 |
+
}
|
1127 |
+
return $content;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
/**
|
1131 |
+
* Runs if the REST API is initialized.
|
1132 |
+
*
|
1133 |
+
* @since 3.3.2
|
1134 |
+
*/
|
1135 |
+
function rest_init() {
|
1136 |
+
$this->is_rest = true;
|
1137 |
+
}
|
1138 |
+
|
1139 |
+
/**
|
1140 |
+
* Gets an array of hidden post IDs.
|
1141 |
+
*
|
1142 |
+
* @since 3.2.0
|
1143 |
+
*
|
1144 |
+
* @global object $wpdb
|
1145 |
+
* @return array $hidden
|
1146 |
+
*/
|
1147 |
+
function hidden_posts() {
|
1148 |
+
global $wpdb;
|
1149 |
+
$hidden = get_option( 'wpmem_hidden_posts' );
|
1150 |
+
if ( false === $hidden ) {
|
1151 |
+
$hidden = $this->update_hidden_posts();
|
1152 |
+
}
|
1153 |
+
return $hidden;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
/**
|
1157 |
+
* Updates the hidden post array transient.
|
1158 |
+
*
|
1159 |
+
* @since 3.2.0
|
1160 |
+
* @since 3.3.3 Don't include posts from post types not set as handled by WP-Members.
|
1161 |
+
*
|
1162 |
+
* @global object $wpdb
|
1163 |
+
* @return array $hidden
|
1164 |
+
*/
|
1165 |
+
function update_hidden_posts() {
|
1166 |
+
global $wpdb;
|
1167 |
+
$hidden = array();
|
1168 |
+
$default_post_types = array( 'post'=>'Posts', 'page'=>'Page' );
|
1169 |
+
$post_types = array_merge( $this->post_types, $default_post_types );
|
1170 |
+
// $results = $wpdb->get_results( "SELECT post_id FROM " . $wpdb->prefix . "postmeta WHERE meta_key = '_wpmem_block' AND meta_value = 2" );
|
1171 |
+
$results = $wpdb->get_results(
|
1172 |
+
"SELECT
|
1173 |
+
p1.id,
|
1174 |
+
p1.post_type,
|
1175 |
+
m1.meta_key AS _wpmem_block
|
1176 |
+
FROM " . $wpdb->prefix . "posts p1
|
1177 |
+
JOIN " . $wpdb->prefix . "postmeta m1 ON (m1.post_id = p1.id AND m1.meta_key = '_wpmem_block')
|
1178 |
+
WHERE m1.meta_value = '2';"
|
1179 |
+
);
|
1180 |
+
foreach( $results as $result ) {
|
1181 |
+
if ( array_key_exists( $result->post_type, $post_types ) ) {
|
1182 |
+
$hidden[] = $result->id;
|
1183 |
+
}
|
1184 |
+
}
|
1185 |
+
update_option( 'wpmem_hidden_posts', $hidden );
|
1186 |
+
return $hidden;
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
/**
|
1190 |
+
* Gets an array of hidden post IDs.
|
1191 |
+
*
|
1192 |
+
* @since 3.2.0
|
1193 |
+
*
|
1194 |
+
* @global stdClass $wpdb
|
1195 |
+
* @return array $hidden
|
1196 |
+
*/
|
1197 |
+
function get_hidden_posts() {
|
1198 |
+
$hidden = array();
|
1199 |
+
|
1200 |
+
// Return empty array if this is the admin and user can edit posts.
|
1201 |
+
if ( is_admin() && current_user_can( 'edit_posts' ) ) {
|
1202 |
+
return $hidden;
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
// If the user is not logged in, return all hidden posts.
|
1206 |
+
if ( ! is_user_logged_in() ) {
|
1207 |
+
$hidden = $this->hidden_posts();
|
1208 |
+
} else {
|
1209 |
+
// If the user is logged in.
|
1210 |
+
if ( 1 == $this->enable_products ) {
|
1211 |
+
// Get user product access.
|
1212 |
+
$hidden = $this->hidden_posts();
|
1213 |
+
$hidden = ( is_array( $hidden ) ) ? $hidden : array();
|
1214 |
+
|
1215 |
+
// Remove posts with a product the user has access to.
|
1216 |
+
foreach ( $this->membership->products as $key => $value ) {
|
1217 |
+
if ( isset( $this->user->access[ $key ] ) && ( true == $this->user->access[ $key ] || $this->user->is_current( $this->user->access[ $key ] ) ) ) {
|
1218 |
+
foreach ( $hidden as $post_id ) {
|
1219 |
+
if ( 1 == get_post_meta( $post_id, $this->membership->post_stem . $key, true ) ) {
|
1220 |
+
$hidden_key = array_search( $post_id, $hidden );
|
1221 |
+
unset( $hidden[ $hidden_key ] );
|
1222 |
+
}
|
1223 |
+
}
|
1224 |
+
}
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
// Remove posts that don't have a product assignment (general login).
|
1228 |
+
foreach( $hidden as $hidden_key ) {
|
1229 |
+
$unattached = get_post_meta( $hidden_key, '_wpmem_products', true );
|
1230 |
+
if ( false == $unattached ) {
|
1231 |
+
$hidden_key = array_search( $hidden_key, $hidden );
|
1232 |
+
unset( $hidden[ $hidden_key ] );
|
1233 |
+
}
|
1234 |
+
}
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
/**
|
1238 |
+
* Filter the hidden posts array.
|
1239 |
+
*
|
1240 |
+
* @since 3.3.4
|
1241 |
+
*
|
1242 |
+
* @param array $hidden
|
1243 |
+
*/
|
1244 |
+
return apply_filters( 'wpmem_hidden_posts', $hidden );
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
/**
|
1248 |
+
* Hides posts based on settings and meta.
|
1249 |
+
*
|
1250 |
+
* @since 3.2.0
|
1251 |
+
*
|
1252 |
+
* @param array $query
|
1253 |
+
* @return array $query
|
1254 |
+
*/
|
1255 |
+
function do_hide_posts( $query ) {
|
1256 |
+
$hidden_posts = $this->get_hidden_posts();
|
1257 |
+
if ( ! empty( $hidden_posts ) ) {
|
1258 |
+
// Add hidden posts to post__not_in while maintaining any existing exclusions.
|
1259 |
+
$post__not_in = array_merge( $query->query_vars['post__not_in'], $hidden_posts );
|
1260 |
+
/**
|
1261 |
+
* Filter post__not_in.
|
1262 |
+
*
|
1263 |
+
* @since 3.3.4
|
1264 |
+
*
|
1265 |
+
* @param array $post__not_in
|
1266 |
+
*/
|
1267 |
+
$post__not_in = apply_filters( 'wpmem_post__not_in', $post__not_in );
|
1268 |
+
$query->set( 'post__not_in', $post__not_in );
|
1269 |
+
}
|
1270 |
+
return $query;
|
1271 |
+
}
|
1272 |
+
|
1273 |
+
/**
|
1274 |
+
* Filter to hide pages for get_pages().
|
1275 |
+
*
|
1276 |
+
* @since 3.2.0
|
1277 |
+
*
|
1278 |
+
* @global object $wpdb
|
1279 |
+
* @param array $pages
|
1280 |
+
* @return array $pages
|
1281 |
+
*/
|
1282 |
+
function filter_get_pages( $pages ) {
|
1283 |
+
$hidden_posts = $this->get_hidden_posts();
|
1284 |
+
if ( ! empty ( $hidden_posts ) ) {
|
1285 |
+
$new_pages = array();
|
1286 |
+
foreach ( $pages as $key => $page ) {
|
1287 |
+
if ( ! in_array( $page->ID, $hidden_posts ) ) {
|
1288 |
+
$new_pages[ $key ] = $page;
|
1289 |
+
}
|
1290 |
+
}
|
1291 |
+
$pages = $new_pages;
|
1292 |
+
}
|
1293 |
+
return $pages;
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
/**
|
1297 |
+
* Filter to hide menu items.
|
1298 |
+
*
|
1299 |
+
* @since 3.2.0
|
1300 |
+
*
|
1301 |
+
* @param array $items
|
1302 |
+
* @param $menu
|
1303 |
+
* @param array $args
|
1304 |
+
* @return array $items
|
1305 |
+
*/
|
1306 |
+
function filter_nav_menu_items( $items, $menu, $args ) {
|
1307 |
+
$hidden_posts = $this->get_hidden_posts();
|
1308 |
+
if ( ! empty( $hidden_posts ) ) {
|
1309 |
+
foreach ( $items as $key => $item ) {
|
1310 |
+
if ( in_array( $item->object_id, $hidden_posts ) ) {
|
1311 |
+
unset( $items[ $key ] );
|
1312 |
+
}
|
1313 |
+
}
|
1314 |
+
}
|
1315 |
+
return $items;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
/**
|
1319 |
+
* Filter to remove hidden posts from prev/next links.
|
1320 |
+
*
|
1321 |
+
* @since 3.2.4
|
1322 |
+
*
|
1323 |
+
* @global object $wpmem
|
1324 |
+
* @param string $where
|
1325 |
+
* @return string $where
|
1326 |
+
*/
|
1327 |
+
function filter_get_adjacent_post_where( $where ) {
|
1328 |
+
global $wpmem;
|
1329 |
+
if ( ! is_user_logged_in() ) {
|
1330 |
+
$hidden_posts = $this->get_hidden_posts();
|
1331 |
+
if ( ! empty( $hidden_posts ) ) {
|
1332 |
+
$hidden = implode( ",", $hidden_posts );
|
1333 |
+
$where = $where . " AND p.ID NOT IN ( $hidden )";
|
1334 |
+
}
|
1335 |
+
}
|
1336 |
+
return $where;
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
/**
|
1340 |
+
* Set page locations.
|
1341 |
+
*
|
1342 |
+
* Handles numeric page IDs while maintaining
|
1343 |
+
* compatibility with old full url settings.
|
1344 |
+
*
|
1345 |
+
* @since 3.0.8
|
1346 |
+
*/
|
1347 |
+
function load_user_pages() {
|
1348 |
+
foreach ( $this->user_pages as $key => $val ) {
|
1349 |
+
if ( is_numeric( $val ) ) {
|
1350 |
+
if ( false !== get_post_status( $val ) ) {
|
1351 |
+
$this->user_pages[ $key ] = get_page_link( $val );
|
1352 |
+
} else {
|
1353 |
+
$notice = sprintf( __( 'You have a linked page in the WP-Members page settings that corresponds to a post ID that no longer exists. Please %s review and update the %s page settings %s.', 'wp-members' ), '<a href="' . esc_url( get_admin_url() . '/options-general.php?page=wpmem-settings&tab=options' ) . '">', $key, '</a>' );
|
1354 |
+
$this->admin_notices[] = array(
|
1355 |
+
'type'=>'error',
|
1356 |
+
'notice'=>$notice
|
1357 |
+
);
|
1358 |
+
}
|
1359 |
+
}
|
1360 |
+
}
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
/**
|
1364 |
+
* Sets the stylesheet URL.
|
1365 |
+
*
|
1366 |
+
* @since 3.3.0
|
1367 |
+
*/
|
1368 |
+
function set_style() {
|
1369 |
+
$this->cssurl = ( 'use_custom' == $this->select_style ) ? $this->cssurl : $this->url . 'assets/css/forms/' . $this->select_style . wpmem_get_suffix() . '.css'; // Set the stylesheet.
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
/**
|
1373 |
+
* Returns a requested text string.
|
1374 |
+
*
|
1375 |
+
* This function manages all of the front-end facing text.
|
1376 |
+
* All defaults can be filtered using wpmem_default_text_strings.
|
1377 |
+
*
|
1378 |
+
* @since 3.1.0
|
1379 |
+
*
|
1380 |
+
* @global object $wpmem
|
1381 |
+
*
|
1382 |
+
* @param string $str
|
1383 |
+
* @return string $text
|
1384 |
+
*/
|
1385 |
+
function get_text( $str ) {
|
1386 |
+
global $wpmem;
|
1387 |
+
return $wpmem->dialogs->get_text( $str );
|
1388 |
+
} // End of get_text().
|
1389 |
+
|
1390 |
+
/**
|
1391 |
+
* Initializes the WP-Members widget.
|
1392 |
+
*
|
1393 |
+
* @since 3.2.0 Replaces widget_wpmemwidget_init
|
1394 |
+
*/
|
1395 |
+
public function widget_init() {
|
1396 |
+
// Register the WP-Members widget.
|
1397 |
+
register_widget( 'widget_wpmemwidget' );
|
1398 |
+
}
|
1399 |
+
|
1400 |
+
/**
|
1401 |
+
* Adds WP-Members query vars to WP's public query vars.
|
1402 |
+
*
|
1403 |
+
* @since 3.2.0
|
1404 |
+
*
|
1405 |
+
* @see https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
|
1406 |
+
*
|
1407 |
+
* @param array $qvars
|
1408 |
+
*/
|
1409 |
+
public function add_query_vars ( $qvars ) {
|
1410 |
+
$qvars[] = 'a'; // The WP-Members action variable.
|
1411 |
+
return $qvars;
|
1412 |
+
}
|
1413 |
+
|
1414 |
+
/**
|
1415 |
+
* Enqueues login/out script for the footer.
|
1416 |
+
*
|
1417 |
+
* @since 3.2.0
|
1418 |
+
*/
|
1419 |
+
public function loginout_script() {
|
1420 |
+
if ( is_user_logged_in() ) {
|
1421 |
+
wp_enqueue_script( 'jquery' );
|
1422 |
+
add_action( 'wp_footer', array( $this, 'do_loginout_script' ), 50 );
|
1423 |
+
}
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
/**
|
1427 |
+
* Outputs login/out script for the footer.
|
1428 |
+
*
|
1429 |
+
* @since 3.2.0
|
1430 |
+
*
|
1431 |
+
* @global object $wpmem
|
1432 |
+
*/
|
1433 |
+
public function do_loginout_script() {
|
1434 |
+
global $wpmem;
|
1435 |
+
/** This filter is defined in /includes/api/api.php */
|
1436 |
+
$logout = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
|
1437 |
+
?><script type="text/javascript">
|
1438 |
+
jQuery('.wpmem_loginout').html('<a class="login_button" href="<?php echo esc_url( $logout ); ?>"><?php echo $this->get_text( 'menu_logout' ); ?></a>');
|
1439 |
+
</script><?php
|
1440 |
+
}
|
1441 |
+
|
1442 |
+
/**
|
1443 |
+
* Adds WP-Members controls to the Customizer
|
1444 |
+
*
|
1445 |
+
* @since 3.2.0
|
1446 |
+
*
|
1447 |
+
* @param object $wp_customize The Customizer object.
|
1448 |
+
*/
|
1449 |
+
function customizer_settings( $wp_customize ) {
|
1450 |
+
$wp_customize->add_section( 'wp_members' , array(
|
1451 |
+
'title' => 'WP-Members',
|
1452 |
+
'priority' => 190,
|
1453 |
+
) );
|
1454 |
+
|
1455 |
+
// Add settings for output description
|
1456 |
+
$wp_customize->add_setting( 'wpmem_show_logged_out_state', array(
|
1457 |
+
'default' => '1',
|
1458 |
+
'type' => 'theme_mod', //'option'
|
1459 |
+
'capability' => 'edit_theme_options',
|
1460 |
+
'transport' => 'refresh',
|
1461 |
+
) );
|
1462 |
+
|
1463 |
+
// Add settings for output description
|
1464 |
+
$wp_customize->add_setting( 'wpmem_show_form_message_dialog', array(
|
1465 |
+
'default' => '1',
|
1466 |
+
'type' => 'theme_mod', //'option'
|
1467 |
+
'capability' => 'edit_theme_options',
|
1468 |
+
'transport' => 'refresh',
|
1469 |
+
) );
|
1470 |
+
|
1471 |
+
// Add control and output for select field
|
1472 |
+
$wp_customize->add_control( 'wpmem_show_form_logged_out', array(
|
1473 |
+
'label' => __( 'Show forms as logged out', 'wp-members' ),
|
1474 |
+
'section' => 'wp_members',
|
1475 |
+
'settings' => 'wpmem_show_logged_out_state',
|
1476 |
+
'type' => 'checkbox',
|
1477 |
+
'std' => '1'
|
1478 |
+
) );
|
1479 |
+
|
1480 |
+
// Add control for showing dialog
|
1481 |
+
$wp_customize->add_control( 'wpmem_show_form_dialog', array(
|
1482 |
+
'label' => __( 'Show form message dialog', 'wp-members' ),
|
1483 |
+
'section' => 'wp_members',
|
1484 |
+
'settings' => 'wpmem_show_form_message_dialog',
|
1485 |
+
'type' => 'checkbox',
|
1486 |
+
'std' => '0'
|
1487 |
+
) );
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
/**
|
1491 |
+
* Loads the stylesheet for tableless forms.
|
1492 |
+
*
|
1493 |
+
* @since 2.6
|
1494 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1495 |
+
*
|
1496 |
+
* @global object $wpmem The WP_Members object.
|
1497 |
+
*/
|
1498 |
+
function enqueue_style() {
|
1499 |
+
global $wpmem;
|
1500 |
+
wp_enqueue_style ( 'wp-members', wpmem_force_ssl( $wpmem->cssurl ), false, $wpmem->version );
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
/**
|
1504 |
+
* Loads the wp-login.php stylesheet.
|
1505 |
+
*
|
1506 |
+
* @since 3.3.0
|
1507 |
+
*
|
1508 |
+
* @global stdClass $wpmem
|
1509 |
+
*/
|
1510 |
+
function enqueue_style_wp_login() {
|
1511 |
+
global $wpmem;
|
1512 |
+
wp_enqueue_style( 'wp-members', $wpmem->url . 'assets/css/wp-login' . wpmem_get_suffix() . '.css', false, $wpmem->version );
|
1513 |
+
}
|
1514 |
+
|
1515 |
+
/**
|
1516 |
+
* Creates an excerpt on the fly if there is no 'more' tag.
|
1517 |
+
*
|
1518 |
+
* @since 2.6
|
1519 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1520 |
+
* @since 3.2.5 Check if post object exists.
|
1521 |
+
*
|
1522 |
+
* @global object $post The post object.
|
1523 |
+
* @global object $wpmem The WP_Members object.
|
1524 |
+
*
|
1525 |
+
* @param string $content
|
1526 |
+
* @return string $content
|
1527 |
+
*/
|
1528 |
+
function do_excerpt( $content ) {
|
1529 |
+
|
1530 |
+
global $post, $more, $wpmem;
|
1531 |
+
|
1532 |
+
if ( is_object( $post ) ) {
|
1533 |
+
|
1534 |
+
$post_id = $post->ID;
|
1535 |
+
$post_type = $post->post_type;
|
1536 |
+
|
1537 |
+
$autoex = ( isset( $wpmem->autoex[ $post->post_type ] ) && 1 == $wpmem->autoex[ $post->post_type ]['enabled'] ) ? $wpmem->autoex[ $post->post_type ] : false;
|
1538 |
+
|
1539 |
+
// Is there already a 'more' link in the content?
|
1540 |
+
$has_more_link = ( stristr( $content, 'class="more-link"' ) ) ? true : false;
|
1541 |
+
|
1542 |
+
// If auto_ex is on.
|
1543 |
+
if ( $autoex ) {
|
1544 |
+
|
1545 |
+
// Build an excerpt if one does not exist.
|
1546 |
+
if ( ! $has_more_link ) {
|
1547 |
+
|
1548 |
+
$is_singular = ( is_singular( $post->post_type ) ) ? true : false;
|
1549 |
+
|
1550 |
+
if ( $is_singular ) {
|
1551 |
+
// If it's a single post, we don't need the 'more' link.
|
1552 |
+
$more_link_text = '';
|
1553 |
+
$more_link = '';
|
1554 |
+
} else {
|
1555 |
+
// The default $more_link_text.
|
1556 |
+
if ( isset( $wpmem->autoex[ $post->post_type ]['text'] ) && '' != $wpmem->autoex[ $post->post_type ]['text'] ) {
|
1557 |
+
$more_link_text = __( $wpmem->autoex[ $post->post_type ]['text'], 'wp-members' );
|
1558 |
+
} else {
|
1559 |
+
$more_link_text = __( '(more…)' );
|
1560 |
+
}
|
1561 |
+
// The default $more_link.
|
1562 |
+
$more_link = ' <a href="'. get_permalink( $post->ID ) . '" class="more-link">' . $more_link_text . '</a>';
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
// Apply the_content_more_link filter if one exists (will match up all 'more' link text).
|
1566 |
+
/** This filter is documented in /wp-includes/post-template.php */
|
1567 |
+
$more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
|
1568 |
+
|
1569 |
+
$defaults = array(
|
1570 |
+
'length' => $autoex['length'],
|
1571 |
+
'more_link' => $more_link,
|
1572 |
+
'blocked_only' => false,
|
1573 |
+
);
|
1574 |
+
/**
|
1575 |
+
* Filter auto excerpt defaults.
|
1576 |
+
*
|
1577 |
+
* @since 3.0.9
|
1578 |
+
* @since 3.1.5 Deprecated add_ellipsis, strip_tags, close_tags, parse_shortcodes, strip_shortcodes.
|
1579 |
+
*
|
1580 |
+
* @param array {
|
1581 |
+
* An array of settings to override the function defaults.
|
1582 |
+
*
|
1583 |
+
* @type int $length The default length of the excerpt.
|
1584 |
+
* @type string $more_link The more link HTML.
|
1585 |
+
* @type boolean $blocked_only Run autoexcerpt only on blocked content. default: false.
|
1586 |
+
* }
|
1587 |
+
* @param string $post->ID The post ID.
|
1588 |
+
* @param string $post->post_type The content's post type.
|
1589 |
+
*/
|
1590 |
+
$args = apply_filters( 'wpmem_auto_excerpt_args', $defaults, $post->ID, $post->post_type );
|
1591 |
+
|
1592 |
+
// Merge settings.
|
1593 |
+
$args = wp_parse_args( $args, $defaults );
|
1594 |
+
|
1595 |
+
// Are we only excerpting blocked content?
|
1596 |
+
if ( $args['blocked_only'] ) {
|
1597 |
+
$post_meta = get_post_meta( $post->ID, '_wpmem_block', true );
|
1598 |
+
if ( 1 == $wpmem->block[ $post->post_type ] ) {
|
1599 |
+
// Post type is blocked, if post meta unblocks it, don't do excerpt.
|
1600 |
+
$do_excerpt = ( "0" == $post_meta ) ? false : true;
|
1601 |
+
} else {
|
1602 |
+
// Post type is unblocked, if post meta blocks it, do excerpt.
|
1603 |
+
$do_excerpt = ( "1" == $post_meta ) ? true : false;
|
1604 |
+
}
|
1605 |
+
} else {
|
1606 |
+
$do_excerpt = true;
|
1607 |
+
}
|
1608 |
+
|
1609 |
+
if ( true === $do_excerpt ) {
|
1610 |
+
$content = ( $args['length'] > 0 ) ? wp_trim_words( $content, $args['length'], $args['more_link'] ) : '';
|
1611 |
+
// Check if the more link was added (note: singular has no more_link):
|
1612 |
+
if ( ! $is_singular && ! strpos( $content, $args['more_link'] ) ) {
|
1613 |
+
$content = $content . $args['more_link'];
|
1614 |
+
}
|
1615 |
+
}
|
1616 |
+
}
|
1617 |
+
}
|
1618 |
+
} else {
|
1619 |
+
$post_id = false;
|
1620 |
+
$post_type = false;
|
1621 |
+
}
|
1622 |
+
|
1623 |
+
/**
|
1624 |
+
* Filter the auto excerpt.
|
1625 |
+
*
|
1626 |
+
* @since 2.8.1
|
1627 |
+
* @since 3.0.9 Added post ID and post type parameters.
|
1628 |
+
* @since 3.2.5 Post ID and post type may be false if there is no post object.
|
1629 |
+
*
|
1630 |
+
* @param string $content The content excerpt.
|
1631 |
+
* @param string $post_id The post ID.
|
1632 |
+
* @param string $post_type The content's post type.
|
1633 |
+
*/
|
1634 |
+
$content = apply_filters( 'wpmem_auto_excerpt', $content, $post_id, $post_type );
|
1635 |
+
|
1636 |
+
// Return the excerpt.
|
1637 |
+
return $content;
|
1638 |
+
}
|
1639 |
+
|
1640 |
+
/**
|
1641 |
+
* Convert form tag.
|
1642 |
+
*
|
1643 |
+
* @todo This is temporary to handle form tag conversion.
|
1644 |
+
*
|
1645 |
+
* @since 3.1.7
|
1646 |
+
* @since 3.2.3 Moved to WP_Members class.
|
1647 |
+
* @since 3.3.0 Removed unnecessary tags.
|
1648 |
+
*
|
1649 |
+
* @param string $tag
|
1650 |
+
* @return string $tag
|
1651 |
+
*/
|
1652 |
+
function convert_tag( $tag ) {
|
1653 |
+
switch ( $tag ) {
|
1654 |
+
case 'new':
|
1655 |
+
return 'register';
|
1656 |
+
break;
|
1657 |
+
case 'edit':
|
1658 |
+
case 'update':
|
1659 |
+
return 'profile';
|
1660 |
+
break;
|
1661 |
+
default:
|
1662 |
+
return $tag;
|
1663 |
+
break;
|
1664 |
+
}
|
1665 |
+
return $tag;
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
/**
|
1669 |
+
* Loads translation files.
|
1670 |
+
*
|
1671 |
+
* @since 3.0.0
|
1672 |
+
* @since 3.2.5 Moved to main object, dropped wpmem_ stem.
|
1673 |
+
*/
|
1674 |
+
function load_textdomain() {
|
1675 |
+
|
1676 |
+
// Plugin textdomain.
|
1677 |
+
$domain = 'wp-members';
|
1678 |
+
|
1679 |
+
// Wordpress locale.
|
1680 |
+
/** This filter is documented in wp-includes/l10n.php */
|
1681 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
1682 |
+
|
1683 |
+
/**
|
1684 |
+
* Filter translation file.
|
1685 |
+
*
|
1686 |
+
* If the translate.wordpress.org language pack is available, it will
|
1687 |
+
* be /wp-content/languages/plugins/wp-members-{locale}.mo by default.
|
1688 |
+
* You can filter this if you want to load a language pack from a
|
1689 |
+
* different location (or different file name).
|
1690 |
+
*
|
1691 |
+
* @since 3.0.0
|
1692 |
+
* @since 3.2.0 Added locale as a parameter.
|
1693 |
+
*
|
1694 |
+
* @param string $file The translation file to load.
|
1695 |
+
* @param string $locale The current locale.
|
1696 |
+
*/
|
1697 |
+
$file = apply_filters( 'wpmem_localization_file', trailingslashit( WP_LANG_DIR ) . 'plugins/' . $domain . '-' . $locale . '.mo', $locale );
|
1698 |
+
|
1699 |
+
$loaded = load_textdomain( $domain, $file );
|
1700 |
+
if ( $loaded ) {
|
1701 |
+
return $loaded;
|
1702 |
+
} else {
|
1703 |
+
/**
|
1704 |
+
* Filter translation directory.
|
1705 |
+
*
|
1706 |
+
* @since 3.0.3
|
1707 |
+
* @since 3.2.0 Added locale as a parameter.
|
1708 |
+
*
|
1709 |
+
* @param string $dir The translation directory.
|
1710 |
+
* @param string $locale The current locale.
|
1711 |
+
*/
|
1712 |
+
$dir = apply_filters( 'wpmem_localization_dir', basename( $this->path ) . '/i18n/languages/', $locale );
|
1713 |
+
load_plugin_textdomain( $domain, FALSE, $dir );
|
1714 |
+
}
|
1715 |
+
return;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
/**
|
1719 |
+
* Load default tos template.
|
1720 |
+
*
|
1721 |
+
* @since 3.2.8
|
1722 |
+
*/
|
1723 |
+
function load_default_tos() {
|
1724 |
+
// Check for custom template or load default.
|
1725 |
+
$custom_template = get_stylesheet_directory() . '/wp-members/templates/tos.php';
|
1726 |
+
if ( file_exists( $custom_template ) ) {
|
1727 |
+
require_once( $custom_template );
|
1728 |
+
} else {
|
1729 |
+
require_once( $this->path . 'templates/tos.php' );
|
1730 |
+
}
|
1731 |
+
}
|
1732 |
+
|
1733 |
+
/**
|
1734 |
+
* Builds defaults for login/out links/buttons.
|
1735 |
+
*
|
1736 |
+
* @since 3.3.5
|
1737 |
+
*
|
1738 |
+
* @param array $args
|
1739 |
+
* @return string $html
|
1740 |
+
*/
|
1741 |
+
function loginout_args( $args = array() ) {
|
1742 |
+
$defaults = array(
|
1743 |
+
'format' => ( isset( $args['format'] ) ) ? $args['format'] : 'link',
|
1744 |
+
'login_redirect_to' => ( isset( $args['login_redirect_to'] ) ) ? $args['login_redirect_to'] : wpmem_current_url(),
|
1745 |
+
'logout_redirect_to' => ( isset( $args['logout_redirect_to'] ) ) ? $args['logout_redirect_to'] : wpmem_current_url(), // @todo - This is not currently active.
|
1746 |
+
'login_text' => ( isset( $args['login_text'] ) ) ? $args['login_text'] : __( 'log in', 'wp-members' ),
|
1747 |
+
'logout_text' => ( isset( $args['logout_text'] ) ) ? $args['logout_text'] : __( 'log out', 'wp-members' ),
|
1748 |
+
'class' => ( isset( $args['class'] ) ) ? $args['class'] : 'wpmem_loginout_link',
|
1749 |
+
'id' => ( isset( $args['id'] ) ) ? $args['id'] : 'wpmem_loginout_link',
|
1750 |
+
);
|
1751 |
+
$args = wp_parse_args( $args, $defaults );
|
1752 |
+
$redirect = ( is_user_logged_in() ) ? $args['logout_redirect_to'] : $args['login_redirect_to'];
|
1753 |
+
$text = ( is_user_logged_in() ) ? $args['logout_text'] : $args['login_text'];
|
1754 |
+
if ( is_user_logged_in() ) {
|
1755 |
+
/** This filter is defined in /includes/api/api.php */
|
1756 |
+
$link = apply_filters( 'wpmem_logout_link', add_query_arg( 'a', 'logout' ) );
|
1757 |
+
} else {
|
1758 |
+
$link = wpmem_login_url( $redirect );
|
1759 |
+
}
|
1760 |
+
|
1761 |
+
if ( 'button' == $args['format'] ) {
|
1762 |
+
$html = '<form action="' . $link . '" id="' . $args['id'] . '" class="' . $args['class'] . '">';
|
1763 |
+
$html.= ( is_user_logged_in() ) ? '<input type="hidden" name="a" value="logout" />' : '';
|
1764 |
+
$html.= '<input type="submit" value="' . $text . '" /></form>';
|
1765 |
+
} else {
|
1766 |
+
$html = sprintf( '<a href="%s" id="%" class="%s">%s</a>', $link, $args['id'], $args['class'], $text );
|
1767 |
+
}
|
1768 |
+
return $html;
|
1769 |
+
}
|
1770 |
+
|
1771 |
+
/**
|
1772 |
+
* Filters the password URL to point to the WP-Members process.
|
1773 |
+
*
|
1774 |
+
* @since 3.3.5
|
1775 |
+
*/
|
1776 |
+
function lost_pwd_url( $lostpwd_url, $redirect ) {
|
1777 |
+
return wpmem_profile_url( 'pwdreset' );
|
1778 |
+
}
|
1779 |
+
|
1780 |
+
/**
|
1781 |
+
* Google recaptcha v3 (invisible) gives more accurate user scores
|
1782 |
+
* if it is loaded on all pages.
|
1783 |
+
*
|
1784 |
+
* @since 3.4.0
|
1785 |
+
*/
|
1786 |
+
function invisible_captcha() {
|
1787 |
+
if ( 4 == $this->captcha && true !== wpmem_is_reg_form_showing() ) {
|
1788 |
+
echo WP_Members_Captcha::show();
|
1789 |
+
}
|
1790 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1791 |
} // End of WP_Members class.
|
@@ -1,310 +1,310 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* A WP_CLI set of subcommands to list and update WP-Members plugin settings.
|
4 |
-
*
|
5 |
-
* @since 3.3.5
|
6 |
-
*/
|
7 |
-
class WP_Members_CLI_Settings {
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Initialize any required elements.
|
11 |
-
*
|
12 |
-
* @since 3.3.5
|
13 |
-
*
|
14 |
-
* @global object $wpmem
|
15 |
-
*/
|
16 |
-
public function __construct() {
|
17 |
-
// WP-Members admin needs to be loaded manually.
|
18 |
-
global $wpmem;
|
19 |
-
if ( ! isset( $wpmem->admin ) ) {
|
20 |
-
$wpmem->load_admin();
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* List the WP-Members content settings.
|
26 |
-
*
|
27 |
-
* @since 3.3.5
|
28 |
-
*/
|
29 |
-
public function content() {
|
30 |
-
$this->list_settings( array( 'content' ), array() );
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* List the WP-Members option settings.
|
35 |
-
*
|
36 |
-
* @since 3.3.5
|
37 |
-
*/
|
38 |
-
public function options() {
|
39 |
-
$this->list_settings( array( 'options' ), array() );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Lists WP-Members settings.
|
44 |
-
*
|
45 |
-
* @since 3.3.5
|
46 |
-
*
|
47 |
-
* @param array $args
|
48 |
-
* @param array $assoc_args
|
49 |
-
*/
|
50 |
-
private function list_settings( $args, $assoc_args ) {
|
51 |
-
|
52 |
-
global $wpmem;
|
53 |
-
|
54 |
-
if ( 'content' == $args[0] ) {
|
55 |
-
$settings = $wpmem->admin->settings( 'content' );
|
56 |
-
} else {
|
57 |
-
$settings = $wpmem->admin->settings( 'options' );
|
58 |
-
}
|
59 |
-
if ( 'content' == $args[0] ) {
|
60 |
-
|
61 |
-
// @todo Add custom post types, and look for admin where all possible post types are assembled.
|
62 |
-
$post_types = array_merge( array( 'post', 'page' ), $wpmem->post_types );
|
63 |
-
|
64 |
-
foreach( $post_types as $post_type ) {
|
65 |
-
foreach ( $settings as $setting => $description ) {
|
66 |
-
if ( 'autoex' != $setting ) {
|
67 |
-
$list[] = array(
|
68 |
-
'Setting' => $setting . ' ' . $post_type,
|
69 |
-
'Description' => $description . ' ' . $post_type,
|
70 |
-
'Value' => $wpmem->{$setting}[ $post_type ],
|
71 |
-
'Option' => ( 0 == $wpmem->{$setting}[ $post_type ] ) ? 'Disabled' : 'Enabled',
|
72 |
-
);
|
73 |
-
} else {
|
74 |
-
$list[] = array(
|
75 |
-
'Setting' => $setting . ' ' . $post_type,
|
76 |
-
'Description' => $description . ' ' . $post_type,
|
77 |
-
'Value' => $wpmem->{$setting}[ $post_type ]['enabled'],
|
78 |
-
'Option' => ( 0 == $wpmem->{$setting}[ $post_type ]['enabled'] ) ? 'Disabled' : 'Enabled',
|
79 |
-
);
|
80 |
-
$list[] = array(
|
81 |
-
'Setting' => '',
|
82 |
-
'Description' => $post_type . ' excerpt word length:',
|
83 |
-
'Value' => $wpmem->{$setting}[ $post_type ]['length'],
|
84 |
-
'Option' => '',
|
85 |
-
);
|
86 |
-
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
$list[] = array( 'Setting' => '', 'Description' => '', 'Value' => '', 'Option' => '' );
|
91 |
-
}
|
92 |
-
|
93 |
-
} else {
|
94 |
-
foreach ( $settings as $setting => $description ) {
|
95 |
-
if ( 'captcha' == $setting ) {
|
96 |
-
$option = WP_Members_Captcha::type( $wpmem->{$setting} );
|
97 |
-
} else {
|
98 |
-
$option = ( 0 == $wpmem->{$setting} ) ? 'Disabled' : 'Enabled';
|
99 |
-
}
|
100 |
-
$list[] = array(
|
101 |
-
'Setting' => $setting,
|
102 |
-
'Description' => $description,
|
103 |
-
'Value' => $wpmem->{$setting},
|
104 |
-
'Option' => $option,
|
105 |
-
);
|
106 |
-
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Description', 'Setting', 'Value', 'Option' ) );
|
111 |
-
$formatter->display_items( $list );
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* List custom post types for WP-Members management.
|
116 |
-
*
|
117 |
-
* @since 3.3.5
|
118 |
-
*/
|
119 |
-
public function post_types() {
|
120 |
-
global $wpmem;
|
121 |
-
$post_types = $wpmem->admin->post_types();
|
122 |
-
foreach ( $post_types as $post_type ) {
|
123 |
-
$enabled = ( array_key_exists( $post_type, $wpmem->post_types ) ) ? "Enabled" : "Disabled";
|
124 |
-
$list[] = array(
|
125 |
-
'Post Type' => $post_type,
|
126 |
-
'Value' => $enabled,
|
127 |
-
);
|
128 |
-
}
|
129 |
-
WP_CLI::line( 'Custom post type settings for WP-Members:' );
|
130 |
-
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Post Type', 'Value' ) );
|
131 |
-
$formatter->display_items( $list );
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Manage post type.
|
136 |
-
*
|
137 |
-
* ## OPTIONS
|
138 |
-
*
|
139 |
-
* [--enable=<post_type>]
|
140 |
-
* : enable the specified post type.
|
141 |
-
*
|
142 |
-
* [--disable=<post_type>]
|
143 |
-
* : disable the specified post type.
|
144 |
-
*
|
145 |
-
* @since 3.3.5
|
146 |
-
*/
|
147 |
-
public function post_type( $args, $assoc_args ) {
|
148 |
-
global $wpmem;
|
149 |
-
if ( isset( $assoc_args['enable'] ) || isset( $assoc_args['disable'] ) ) {
|
150 |
-
$post_types = $wpmem->admin->post_types();
|
151 |
-
if ( ( isset( $assoc_args['enable'] ) && ! array_key_exists( $assoc_args['enable'], $post_types ) ) || ( isset( $assoc_args['disable'] ) && ! array_key_exists( $assoc_args['disable'], $post_types ) ) ) {
|
152 |
-
WP_CLI::error( 'Not an available post type. Try wp mem settings post_types' );
|
153 |
-
}
|
154 |
-
// Handle disable.
|
155 |
-
if ( isset( $assoc_args['disable'] ) ) {
|
156 |
-
unset( $wpmem->post_types[ $assoc_args['disable'] ] );
|
157 |
-
wpmem_update_option( 'wpmembers_settings', 'post_types', $wpmem->post_types );
|
158 |
-
WP_CLI::success( 'Disabled ' . $assoc_args['disable'] . ' post type.' );
|
159 |
-
}
|
160 |
-
if ( isset( $assoc_args['enable'] ) ) {
|
161 |
-
$cpt_obj = get_post_type_object( $assoc_args['enable'] );
|
162 |
-
$new_post_types = array_merge($wpmem->post_types, array( $cpt_obj->name => $cpt_obj->labels->name ) );
|
163 |
-
wpmem_update_option( 'wpmembers_settings', 'post_types', $new_post_types );
|
164 |
-
WP_CLI::success( 'Enabled ' . $assoc_args['enable'] . ' post type.' );
|
165 |
-
}
|
166 |
-
} else {
|
167 |
-
WP_CLI::error( 'Must specify an option: --enable=<post_type> or --disable=<post_type>' );
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Enable a WP-Members setting.
|
173 |
-
*
|
174 |
-
* ## OPTIONS
|
175 |
-
*
|
176 |
-
* <option>
|
177 |
-
* : The WP-Members option setting to enable.
|
178 |
-
*
|
179 |
-
* ## EXAMPLES
|
180 |
-
*
|
181 |
-
* wp mem settings enable mod_reg
|
182 |
-
*/
|
183 |
-
public function enable( $args, $assoc_args ) {
|
184 |
-
global $wpmem;
|
185 |
-
$settings = $wpmem->admin->settings( 'options' );
|
186 |
-
if ( array_key_exists( $args[0], $settings ) && 'captcha' !== $args[0] ) {
|
187 |
-
wpmem_update_option( 'wpmembers_settings', $args[0], 1 );
|
188 |
-
WP_CLI::success( $settings[ $args[0] ] . ' enabled' );
|
189 |
-
}
|
190 |
-
if ( array_key_exists( $args[0], $settings ) && 'captcha' === $args[0] ) {
|
191 |
-
switch( $args[1] ) {
|
192 |
-
case 'rs_captcha':
|
193 |
-
$which = 2;
|
194 |
-
break;
|
195 |
-
case 'recaptcha_v2':
|
196 |
-
$which = 3;
|
197 |
-
break;
|
198 |
-
case 'recaptcha_v3':
|
199 |
-
$which = 4;
|
200 |
-
break;
|
201 |
-
}
|
202 |
-
wpmem_update_option( 'wpmembers_settings', $args[0], $which );
|
203 |
-
WP_CLI::success( $settings[ $args[0] ] . ' ' . $args[1] . ' enabled' );
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Disables a WP-Members setting.
|
209 |
-
*
|
210 |
-
* ## OPTIONS
|
211 |
-
*
|
212 |
-
* <option>
|
213 |
-
* : The WP-Members option setting to disable.
|
214 |
-
*
|
215 |
-
* ## EXAMPLES
|
216 |
-
*
|
217 |
-
* wp mem settings enable mod_reg
|
218 |
-
*/
|
219 |
-
public function disable( $args ) {
|
220 |
-
global $wpmem;
|
221 |
-
$settings = $wpmem->admin->settings( 'options' );
|
222 |
-
if ( array_key_exists( $args[0], $settings ) ) {
|
223 |
-
wpmem_update_option( 'wpmembers_settings', $args[0], 0 );
|
224 |
-
WP_CLI::success( $settings[ $args[0] ] . ' disabled' );
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Set, clear, or list the WP-Members page settings.
|
230 |
-
*
|
231 |
-
* ## OPTIONS
|
232 |
-
*
|
233 |
-
* [<list>]
|
234 |
-
* : Lists all page settings.
|
235 |
-
*
|
236 |
-
* [<clear>]
|
237 |
-
* : Clears page or pages specified.
|
238 |
-
*
|
239 |
-
* [<set>]
|
240 |
-
* : Set a page ID for the user page.
|
241 |
-
*
|
242 |
-
* [--all]
|
243 |
-
* : used with <clear> option, clears all pages.
|
244 |
-
*
|
245 |
-
* [--login[=<ID>]]
|
246 |
-
* : Leave empty (--login) to clear, or set a page ID for the login page.
|
247 |
-
*
|
248 |
-
* [--register[=<ID>]]
|
249 |
-
* : Leave empty (--register) to clear, or set a page ID for the registration page.
|
250 |
-
*
|
251 |
-
* [--profile[=<ID>]]
|
252 |
-
* : Leave empty (--profile) to clear, or set a page ID for the profile page.
|
253 |
-
*
|
254 |
-
* ## EXAMPLES
|
255 |
-
*
|
256 |
-
* wp mem settings pages clear --all
|
257 |
-
* wp mem settings pages clear --register
|
258 |
-
* wp mem settings pages set --login=123
|
259 |
-
* wp mem settings pages list
|
260 |
-
*/
|
261 |
-
public function pages( $args, $assoc_args ) {
|
262 |
-
if ( empty( $args ) ) {
|
263 |
-
WP_CLI::error( 'You must specify clear|set|list', true );
|
264 |
-
}
|
265 |
-
if ( 'clear' == $args[0] ) {
|
266 |
-
if ( empty( $assoc_args ) ) {
|
267 |
-
WP_CLI::error( 'You must specify --all or --login|register|profile', true );
|
268 |
-
}
|
269 |
-
if ( isset( $assoc_args['all'] ) ) {
|
270 |
-
unset( $assoc_args['all'] );
|
271 |
-
$assoc_args = array( 'login'=>'', 'register'=>'', 'profile'=>'' );
|
272 |
-
}
|
273 |
-
foreach ( $assoc_args as $page => $value ) {
|
274 |
-
if ( isset( $assoc_args[ $page ] ) ) {
|
275 |
-
wpmem_update_option( 'wpmembers_settings', 'user_pages/' . $page, '' );
|
276 |
-
WP_CLI::success( ucfirst( $page ) . ' page cleared' );
|
277 |
-
}
|
278 |
-
}
|
279 |
-
return;
|
280 |
-
}
|
281 |
-
if ( 'set' == $args[0] ) {
|
282 |
-
if ( empty( $assoc_args ) ) {
|
283 |
-
WP_CLI::error( 'You must specify which page(s) to set: --login=<ID>, --register=<ID>, --profile=<ID>', true );
|
284 |
-
}
|
285 |
-
foreach ( $assoc_args as $page => $value ) {
|
286 |
-
if ( isset( $assoc_args[ $page ] ) ) {
|
287 |
-
wpmem_update_option( 'wpmembers_settings', 'user_pages/' . $page, $assoc_args[ $page ] );
|
288 |
-
WP_CLI::success( ucfirst( $page ) . ' page set to ID ' . $assoc_args[ $page ] );
|
289 |
-
}
|
290 |
-
}
|
291 |
-
return;
|
292 |
-
}
|
293 |
-
if ( 'list' == $args[0] ) {
|
294 |
-
global $wpmem;
|
295 |
-
$raw_settings = get_option( 'wpmembers_settings' );
|
296 |
-
foreach ( $wpmem->user_pages as $key => $page ) {
|
297 |
-
$list[] = array(
|
298 |
-
'Page' => ucfirst( $key ),
|
299 |
-
'ID' => $raw_settings['user_pages'][ $key ],
|
300 |
-
'URL' => $wpmem->user_pages[ $key ],
|
301 |
-
);
|
302 |
-
}
|
303 |
-
|
304 |
-
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Page', 'ID', 'URL' ) );
|
305 |
-
$formatter->display_items( $list );
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
WP_CLI::add_command( 'mem settings', 'WP_Members_CLI_Settings' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A WP_CLI set of subcommands to list and update WP-Members plugin settings.
|
4 |
+
*
|
5 |
+
* @since 3.3.5
|
6 |
+
*/
|
7 |
+
class WP_Members_CLI_Settings {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Initialize any required elements.
|
11 |
+
*
|
12 |
+
* @since 3.3.5
|
13 |
+
*
|
14 |
+
* @global object $wpmem
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
// WP-Members admin needs to be loaded manually.
|
18 |
+
global $wpmem;
|
19 |
+
if ( ! isset( $wpmem->admin ) ) {
|
20 |
+
$wpmem->load_admin();
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* List the WP-Members content settings.
|
26 |
+
*
|
27 |
+
* @since 3.3.5
|
28 |
+
*/
|
29 |
+
public function content() {
|
30 |
+
$this->list_settings( array( 'content' ), array() );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* List the WP-Members option settings.
|
35 |
+
*
|
36 |
+
* @since 3.3.5
|
37 |
+
*/
|
38 |
+
public function options() {
|
39 |
+
$this->list_settings( array( 'options' ), array() );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Lists WP-Members settings.
|
44 |
+
*
|
45 |
+
* @since 3.3.5
|
46 |
+
*
|
47 |
+
* @param array $args
|
48 |
+
* @param array $assoc_args
|
49 |
+
*/
|
50 |
+
private function list_settings( $args, $assoc_args ) {
|
51 |
+
|
52 |
+
global $wpmem;
|
53 |
+
|
54 |
+
if ( 'content' == $args[0] ) {
|
55 |
+
$settings = $wpmem->admin->settings( 'content' );
|
56 |
+
} else {
|
57 |
+
$settings = $wpmem->admin->settings( 'options' );
|
58 |
+
}
|
59 |
+
if ( 'content' == $args[0] ) {
|
60 |
+
|
61 |
+
// @todo Add custom post types, and look for admin where all possible post types are assembled.
|
62 |
+
$post_types = array_merge( array( 'post', 'page' ), $wpmem->post_types );
|
63 |
+
|
64 |
+
foreach( $post_types as $post_type ) {
|
65 |
+
foreach ( $settings as $setting => $description ) {
|
66 |
+
if ( 'autoex' != $setting ) {
|
67 |
+
$list[] = array(
|
68 |
+
'Setting' => $setting . ' ' . $post_type,
|
69 |
+
'Description' => $description . ' ' . $post_type,
|
70 |
+
'Value' => $wpmem->{$setting}[ $post_type ],
|
71 |
+
'Option' => ( 0 == $wpmem->{$setting}[ $post_type ] ) ? 'Disabled' : 'Enabled',
|
72 |
+
);
|
73 |
+
} else {
|
74 |
+
$list[] = array(
|
75 |
+
'Setting' => $setting . ' ' . $post_type,
|
76 |
+
'Description' => $description . ' ' . $post_type,
|
77 |
+
'Value' => $wpmem->{$setting}[ $post_type ]['enabled'],
|
78 |
+
'Option' => ( 0 == $wpmem->{$setting}[ $post_type ]['enabled'] ) ? 'Disabled' : 'Enabled',
|
79 |
+
);
|
80 |
+
$list[] = array(
|
81 |
+
'Setting' => '',
|
82 |
+
'Description' => $post_type . ' excerpt word length:',
|
83 |
+
'Value' => $wpmem->{$setting}[ $post_type ]['length'],
|
84 |
+
'Option' => '',
|
85 |
+
);
|
86 |
+
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
$list[] = array( 'Setting' => '', 'Description' => '', 'Value' => '', 'Option' => '' );
|
91 |
+
}
|
92 |
+
|
93 |
+
} else {
|
94 |
+
foreach ( $settings as $setting => $description ) {
|
95 |
+
if ( 'captcha' == $setting ) {
|
96 |
+
$option = WP_Members_Captcha::type( $wpmem->{$setting} );
|
97 |
+
} else {
|
98 |
+
$option = ( 0 == $wpmem->{$setting} ) ? 'Disabled' : 'Enabled';
|
99 |
+
}
|
100 |
+
$list[] = array(
|
101 |
+
'Setting' => $setting,
|
102 |
+
'Description' => $description,
|
103 |
+
'Value' => $wpmem->{$setting},
|
104 |
+
'Option' => $option,
|
105 |
+
);
|
106 |
+
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Description', 'Setting', 'Value', 'Option' ) );
|
111 |
+
$formatter->display_items( $list );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* List custom post types for WP-Members management.
|
116 |
+
*
|
117 |
+
* @since 3.3.5
|
118 |
+
*/
|
119 |
+
public function post_types() {
|
120 |
+
global $wpmem;
|
121 |
+
$post_types = $wpmem->admin->post_types();
|
122 |
+
foreach ( $post_types as $post_type ) {
|
123 |
+
$enabled = ( array_key_exists( $post_type, $wpmem->post_types ) ) ? "Enabled" : "Disabled";
|
124 |
+
$list[] = array(
|
125 |
+
'Post Type' => $post_type,
|
126 |
+
'Value' => $enabled,
|
127 |
+
);
|
128 |
+
}
|
129 |
+
WP_CLI::line( 'Custom post type settings for WP-Members:' );
|
130 |
+
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Post Type', 'Value' ) );
|
131 |
+
$formatter->display_items( $list );
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Manage post type.
|
136 |
+
*
|
137 |
+
* ## OPTIONS
|
138 |
+
*
|
139 |
+
* [--enable=<post_type>]
|
140 |
+
* : enable the specified post type.
|
141 |
+
*
|
142 |
+
* [--disable=<post_type>]
|
143 |
+
* : disable the specified post type.
|
144 |
+
*
|
145 |
+
* @since 3.3.5
|
146 |
+
*/
|
147 |
+
public function post_type( $args, $assoc_args ) {
|
148 |
+
global $wpmem;
|
149 |
+
if ( isset( $assoc_args['enable'] ) || isset( $assoc_args['disable'] ) ) {
|
150 |
+
$post_types = $wpmem->admin->post_types();
|
151 |
+
if ( ( isset( $assoc_args['enable'] ) && ! array_key_exists( $assoc_args['enable'], $post_types ) ) || ( isset( $assoc_args['disable'] ) && ! array_key_exists( $assoc_args['disable'], $post_types ) ) ) {
|
152 |
+
WP_CLI::error( 'Not an available post type. Try wp mem settings post_types' );
|
153 |
+
}
|
154 |
+
// Handle disable.
|
155 |
+
if ( isset( $assoc_args['disable'] ) ) {
|
156 |
+
unset( $wpmem->post_types[ $assoc_args['disable'] ] );
|
157 |
+
wpmem_update_option( 'wpmembers_settings', 'post_types', $wpmem->post_types );
|
158 |
+
WP_CLI::success( 'Disabled ' . $assoc_args['disable'] . ' post type.' );
|
159 |
+
}
|
160 |
+
if ( isset( $assoc_args['enable'] ) ) {
|
161 |
+
$cpt_obj = get_post_type_object( $assoc_args['enable'] );
|
162 |
+
$new_post_types = array_merge($wpmem->post_types, array( $cpt_obj->name => $cpt_obj->labels->name ) );
|
163 |
+
wpmem_update_option( 'wpmembers_settings', 'post_types', $new_post_types );
|
164 |
+
WP_CLI::success( 'Enabled ' . $assoc_args['enable'] . ' post type.' );
|
165 |
+
}
|
166 |
+
} else {
|
167 |
+
WP_CLI::error( 'Must specify an option: --enable=<post_type> or --disable=<post_type>' );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Enable a WP-Members setting.
|
173 |
+
*
|
174 |
+
* ## OPTIONS
|
175 |
+
*
|
176 |
+
* <option>
|
177 |
+
* : The WP-Members option setting to enable.
|
178 |
+
*
|
179 |
+
* ## EXAMPLES
|
180 |
+
*
|
181 |
+
* wp mem settings enable mod_reg
|
182 |
+
*/
|
183 |
+
public function enable( $args, $assoc_args ) {
|
184 |
+
global $wpmem;
|
185 |
+
$settings = $wpmem->admin->settings( 'options' );
|
186 |
+
if ( array_key_exists( $args[0], $settings ) && 'captcha' !== $args[0] ) {
|
187 |
+
wpmem_update_option( 'wpmembers_settings', $args[0], 1 );
|
188 |
+
WP_CLI::success( $settings[ $args[0] ] . ' enabled' );
|
189 |
+
}
|
190 |
+
if ( array_key_exists( $args[0], $settings ) && 'captcha' === $args[0] ) {
|
191 |
+
switch( $args[1] ) {
|
192 |
+
case 'rs_captcha':
|
193 |
+
$which = 2;
|
194 |
+
break;
|
195 |
+
case 'recaptcha_v2':
|
196 |
+
$which = 3;
|
197 |
+
break;
|
198 |
+
case 'recaptcha_v3':
|
199 |
+
$which = 4;
|
200 |
+
break;
|
201 |
+
}
|
202 |
+
wpmem_update_option( 'wpmembers_settings', $args[0], $which );
|
203 |
+
WP_CLI::success( $settings[ $args[0] ] . ' ' . $args[1] . ' enabled' );
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Disables a WP-Members setting.
|
209 |
+
*
|
210 |
+
* ## OPTIONS
|
211 |
+
*
|
212 |
+
* <option>
|
213 |
+
* : The WP-Members option setting to disable.
|
214 |
+
*
|
215 |
+
* ## EXAMPLES
|
216 |
+
*
|
217 |
+
* wp mem settings enable mod_reg
|
218 |
+
*/
|
219 |
+
public function disable( $args ) {
|
220 |
+
global $wpmem;
|
221 |
+
$settings = $wpmem->admin->settings( 'options' );
|
222 |
+
if ( array_key_exists( $args[0], $settings ) ) {
|
223 |
+
wpmem_update_option( 'wpmembers_settings', $args[0], 0 );
|
224 |
+
WP_CLI::success( $settings[ $args[0] ] . ' disabled' );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Set, clear, or list the WP-Members page settings.
|
230 |
+
*
|
231 |
+
* ## OPTIONS
|
232 |
+
*
|
233 |
+
* [<list>]
|
234 |
+
* : Lists all page settings.
|
235 |
+
*
|
236 |
+
* [<clear>]
|
237 |
+
* : Clears page or pages specified.
|
238 |
+
*
|
239 |
+
* [<set>]
|
240 |
+
* : Set a page ID for the user page.
|
241 |
+
*
|
242 |
+
* [--all]
|
243 |
+
* : used with <clear> option, clears all pages.
|
244 |
+
*
|
245 |
+
* [--login[=<ID>]]
|
246 |
+
* : Leave empty (--login) to clear, or set a page ID for the login page.
|
247 |
+
*
|
248 |
+
* [--register[=<ID>]]
|
249 |
+
* : Leave empty (--register) to clear, or set a page ID for the registration page.
|
250 |
+
*
|
251 |
+
* [--profile[=<ID>]]
|
252 |
+
* : Leave empty (--profile) to clear, or set a page ID for the profile page.
|
253 |
+
*
|
254 |
+
* ## EXAMPLES
|
255 |
+
*
|
256 |
+
* wp mem settings pages clear --all
|
257 |
+
* wp mem settings pages clear --register
|
258 |
+
* wp mem settings pages set --login=123
|
259 |
+
* wp mem settings pages list
|
260 |
+
*/
|
261 |
+
public function pages( $args, $assoc_args ) {
|
262 |
+
if ( empty( $args ) ) {
|
263 |
+
WP_CLI::error( 'You must specify clear|set|list', true );
|
264 |
+
}
|
265 |
+
if ( 'clear' == $args[0] ) {
|
266 |
+
if ( empty( $assoc_args ) ) {
|
267 |
+
WP_CLI::error( 'You must specify --all or --login|register|profile', true );
|
268 |
+
}
|
269 |
+
if ( isset( $assoc_args['all'] ) ) {
|
270 |
+
unset( $assoc_args['all'] );
|
271 |
+
$assoc_args = array( 'login'=>'', 'register'=>'', 'profile'=>'' );
|
272 |
+
}
|
273 |
+
foreach ( $assoc_args as $page => $value ) {
|
274 |
+
if ( isset( $assoc_args[ $page ] ) ) {
|
275 |
+
wpmem_update_option( 'wpmembers_settings', 'user_pages/' . $page, '' );
|
276 |
+
WP_CLI::success( ucfirst( $page ) . ' page cleared' );
|
277 |
+
}
|
278 |
+
}
|
279 |
+
return;
|
280 |
+
}
|
281 |
+
if ( 'set' == $args[0] ) {
|
282 |
+
if ( empty( $assoc_args ) ) {
|
283 |
+
WP_CLI::error( 'You must specify which page(s) to set: --login=<ID>, --register=<ID>, --profile=<ID>', true );
|
284 |
+
}
|
285 |
+
foreach ( $assoc_args as $page => $value ) {
|
286 |
+
if ( isset( $assoc_args[ $page ] ) ) {
|
287 |
+
wpmem_update_option( 'wpmembers_settings', 'user_pages/' . $page, $assoc_args[ $page ] );
|
288 |
+
WP_CLI::success( ucfirst( $page ) . ' page set to ID ' . $assoc_args[ $page ] );
|
289 |
+
}
|
290 |
+
}
|
291 |
+
return;
|
292 |
+
}
|
293 |
+
if ( 'list' == $args[0] ) {
|
294 |
+
global $wpmem;
|
295 |
+
$raw_settings = get_option( 'wpmembers_settings' );
|
296 |
+
foreach ( $wpmem->user_pages as $key => $page ) {
|
297 |
+
$list[] = array(
|
298 |
+
'Page' => ucfirst( $key ),
|
299 |
+
'ID' => $raw_settings['user_pages'][ $key ],
|
300 |
+
'URL' => $wpmem->user_pages[ $key ],
|
301 |
+
);
|
302 |
+
}
|
303 |
+
|
304 |
+
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'Page', 'ID', 'URL' ) );
|
305 |
+
$formatter->display_items( $list );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
WP_CLI::add_command( 'mem settings', 'WP_Members_CLI_Settings' );
|
@@ -193,16 +193,19 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
193 |
WP_CLI::error( 'User does not exist. Try wp user list' );
|
194 |
}
|
195 |
$all = ( $assoc_args['all'] ) ? true : false;
|
196 |
-
$this->display_user_detail( $user
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
* Handles user detail display.
|
201 |
*
|
202 |
* @since 3.3.5
|
|
|
|
|
|
|
203 |
*/
|
204 |
-
private function display_user_detail( $
|
205 |
-
WP_CLI::line( __( 'User: %s', 'wp-members' ) );
|
206 |
|
207 |
$values = wpmem_user_data( $user_id, $all );
|
208 |
foreach ( $values as $key => $meta ) {
|
@@ -235,6 +238,16 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
235 |
WP_CLI::success( 'User confirmed' );
|
236 |
}
|
237 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
}
|
239 |
}
|
240 |
WP_CLI::add_command( 'mem user', 'WP_Members_CLI_User' );
|
193 |
WP_CLI::error( 'User does not exist. Try wp user list' );
|
194 |
}
|
195 |
$all = ( $assoc_args['all'] ) ? true : false;
|
196 |
+
$this->display_user_detail( $user, $all );
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
* Handles user detail display.
|
201 |
*
|
202 |
* @since 3.3.5
|
203 |
+
*
|
204 |
+
* @param object $user
|
205 |
+
* @param $all
|
206 |
*/
|
207 |
+
private function display_user_detail( $user, $all ) {
|
208 |
+
WP_CLI::line( sprintf( __( 'User: %s', 'wp-members' ), $user->user_login ) );
|
209 |
|
210 |
$values = wpmem_user_data( $user_id, $all );
|
211 |
foreach ( $values as $key => $meta ) {
|
238 |
WP_CLI::success( 'User confirmed' );
|
239 |
}
|
240 |
}
|
241 |
+
|
242 |
+
public function get_role( $args, $assoc_args ) {
|
243 |
+
$all = ( isset( $assoc_args['all'] ) ) ? true : false;
|
244 |
+
$role = wpmem_get_user_role( $assoc_args['id'], $all );
|
245 |
+
if ( is_array( $role ) ) {
|
246 |
+
|
247 |
+
} else {
|
248 |
+
WP_CLI::line( __( 'User role: %s', 'wp-members' ), $role );
|
249 |
+
}
|
250 |
+
}
|
251 |
}
|
252 |
}
|
253 |
WP_CLI::add_command( 'mem user', 'WP_Members_CLI_User' );
|
@@ -8,12 +8,12 @@
|
|
8 |
*
|
9 |
* This file is part of the WP-Members plugin by Chad Butler
|
10 |
* You can find out more about this plugin at https://rocketgeek.com
|
11 |
-
* Copyright (c) 2006-
|
12 |
* WP-Members(tm) is a trademark of butlerblog.com
|
13 |
*
|
14 |
* @package WP-Members
|
15 |
* @author Chad Butler
|
16 |
-
* @copyright 2006-
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
@@ -57,11 +57,11 @@ function wpmem_inc_status() {
|
|
57 |
|
58 |
global $user_login, $wpmem;
|
59 |
|
60 |
-
/** This filter is
|
61 |
$logout = apply_filters( 'wpmem_logout_link', $url . '/?a=logout' );
|
62 |
|
63 |
-
$status = '<p>' . sprintf(
|
64 |
-
. ' | <a href="' . $logout . '">' .
|
65 |
|
66 |
return $status;
|
67 |
}
|
@@ -134,8 +134,8 @@ function wpmem_reg_securify( $content ) {
|
|
134 |
global $wpmem, $wpmem_themsg;
|
135 |
$nonce = wpmem_get( 'reg_nonce', false, 'get' );
|
136 |
if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
|
137 |
-
$content =
|
138 |
-
$content = $content .
|
139 |
}
|
140 |
return $content;
|
141 |
}
|
@@ -233,7 +233,7 @@ if ( ! function_exists( 'wpmem_inc_changepassword' ) ):
|
|
233 |
* Loads the form for changing password.
|
234 |
*
|
235 |
* @since 2.0.0
|
236 |
-
* @since 3.2.0 Now
|
237 |
* @deprecated 3.3.0 Use wpmem_change_password_form() instead.
|
238 |
*
|
239 |
* @global object $wpmem The WP_Members object.
|
@@ -253,7 +253,7 @@ if ( ! function_exists( 'wpmem_inc_resetpassword' ) ):
|
|
253 |
* Loads the form for resetting password.
|
254 |
*
|
255 |
* @since 2.1.0
|
256 |
-
* @since 3.2.0 Now
|
257 |
* @deprecated 3.3.0 Use wpmem_reset_password_form() instead.
|
258 |
*
|
259 |
* @global object $wpmem The WP_Members object.
|
@@ -426,7 +426,7 @@ if ( ! function_exists( 'wpmem_inc_login' ) ):
|
|
426 |
*
|
427 |
* @since 1.8
|
428 |
* @since 3.1.4 Global $wpmem_regchk no longer needed.
|
429 |
-
* @since 3.2.0 Now
|
430 |
* @deprecated 3.3.0 Use wpmem_login_form() instead.
|
431 |
*
|
432 |
* @global object $post The WordPress Post object.
|
@@ -437,8 +437,9 @@ if ( ! function_exists( 'wpmem_inc_login' ) ):
|
|
437 |
* @return string $str The generated html for the login form.
|
438 |
*/
|
439 |
function wpmem_inc_login( $page = "page", $redirect_to = null, $show = 'show' ) {
|
|
|
440 |
global $wpmem;
|
441 |
-
return
|
442 |
}
|
443 |
endif;
|
444 |
|
@@ -449,7 +450,7 @@ if ( ! function_exists( 'wpmem_inc_registration' ) ):
|
|
449 |
* Outputs the form for new user registration and existing user edits.
|
450 |
*
|
451 |
* @since 2.5.1
|
452 |
-
* @since 3.1.7 Now
|
453 |
* @since 3.2.0 Preparing for deprecation, use wpmem_register_form() instead.
|
454 |
* @deprecated 3.3.0 Use wpmem_register_form() instead.
|
455 |
*
|
@@ -459,8 +460,184 @@ if ( ! function_exists( 'wpmem_inc_registration' ) ):
|
|
459 |
* @return string $form The HTML for the entire form as a string.
|
460 |
*/
|
461 |
function wpmem_inc_registration( $tag = 'new', $heading = '', $redirect_to = null ) {
|
|
|
462 |
global $wpmem;
|
463 |
$args = array( 'tag' => $tag, 'heading' => $heading, 'redirect_to' => $redirect_to );
|
464 |
return $wpmem->forms->register_form( $args );
|
465 |
} // End wpmem_inc_registration.
|
466 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
*
|
9 |
* This file is part of the WP-Members plugin by Chad Butler
|
10 |
* You can find out more about this plugin at https://rocketgeek.com
|
11 |
+
* Copyright (c) 2006-2021 Chad Butler
|
12 |
* WP-Members(tm) is a trademark of butlerblog.com
|
13 |
*
|
14 |
* @package WP-Members
|
15 |
* @author Chad Butler
|
16 |
+
* @copyright 2006-2021
|
17 |
*/
|
18 |
|
19 |
// Exit if accessed directly.
|
57 |
|
58 |
global $user_login, $wpmem;
|
59 |
|
60 |
+
/** This filter is defined in /includes/api/api.php */
|
61 |
$logout = apply_filters( 'wpmem_logout_link', $url . '/?a=logout' );
|
62 |
|
63 |
+
$status = '<p>' . sprintf( wpmem_get_text( 'sb_login_status' ), $user_login )
|
64 |
+
. ' | <a href="' . $logout . '">' . wpmem_get_text( 'sb_logout_link' ) . '</a></p>';
|
65 |
|
66 |
return $status;
|
67 |
}
|
134 |
global $wpmem, $wpmem_themsg;
|
135 |
$nonce = wpmem_get( 'reg_nonce', false, 'get' );
|
136 |
if ( $nonce && wp_verify_nonce( $nonce, 'register_redirect' ) ) {
|
137 |
+
$content = wpmem_get_display_message( 'success', $wpmem_themsg );
|
138 |
+
$content = $content . wpmem_login_form();
|
139 |
}
|
140 |
return $content;
|
141 |
}
|
233 |
* Loads the form for changing password.
|
234 |
*
|
235 |
* @since 2.0.0
|
236 |
+
* @since 3.2.0 Now an alias for $wpmem->forms->do_changepassword_form()
|
237 |
* @deprecated 3.3.0 Use wpmem_change_password_form() instead.
|
238 |
*
|
239 |
* @global object $wpmem The WP_Members object.
|
253 |
* Loads the form for resetting password.
|
254 |
*
|
255 |
* @since 2.1.0
|
256 |
+
* @since 3.2.0 Now an alias for $wpmem->forms->do_resetpassword_form()
|
257 |
* @deprecated 3.3.0 Use wpmem_reset_password_form() instead.
|
258 |
*
|
259 |
* @global object $wpmem The WP_Members object.
|
426 |
*
|
427 |
* @since 1.8
|
428 |
* @since 3.1.4 Global $wpmem_regchk no longer needed.
|
429 |
+
* @since 3.2.0 Now an alias for $wpmem->forms->do_login_form().
|
430 |
* @deprecated 3.3.0 Use wpmem_login_form() instead.
|
431 |
*
|
432 |
* @global object $post The WordPress Post object.
|
437 |
* @return string $str The generated html for the login form.
|
438 |
*/
|
439 |
function wpmem_inc_login( $page = "page", $redirect_to = null, $show = 'show' ) {
|
440 |
+
wpmem_write_log( 'wpmem_inc_login() is deprecated as of WP-Members 3.3.0. Use wpmem_login_form() instead.' );
|
441 |
global $wpmem;
|
442 |
+
return wpmem_login_form( 'login', array( 'redirect_to'=>$redirect_to ) ); //$wpmem->forms->do_login_form( $page, $redirect_to, $show );
|
443 |
}
|
444 |
endif;
|
445 |
|
450 |
* Outputs the form for new user registration and existing user edits.
|
451 |
*
|
452 |
* @since 2.5.1
|
453 |
+
* @since 3.1.7 Now an alias for $wpmem->forms->register_form()
|
454 |
* @since 3.2.0 Preparing for deprecation, use wpmem_register_form() instead.
|
455 |
* @deprecated 3.3.0 Use wpmem_register_form() instead.
|
456 |
*
|
460 |
* @return string $form The HTML for the entire form as a string.
|
461 |
*/
|
462 |
function wpmem_inc_registration( $tag = 'new', $heading = '', $redirect_to = null ) {
|
463 |
+
wpmem_write_log( 'wpmem_inc_registration() is deprecated as of WP-Members 3.3.0. Use wpmem_register_form() instead.' );
|
464 |
global $wpmem;
|
465 |
$args = array( 'tag' => $tag, 'heading' => $heading, 'redirect_to' => $redirect_to );
|
466 |
return $wpmem->forms->register_form( $args );
|
467 |
} // End wpmem_inc_registration.
|
468 |
+
endif;
|
469 |
+
|
470 |
+
if ( ! function_exists( 'wpmem_inc_loginfailed' ) ):
|
471 |
+
/**
|
472 |
+
* Login Failed Dialog.
|
473 |
+
*
|
474 |
+
* Returns the login failed error message.
|
475 |
+
*
|
476 |
+
* @since 1.8
|
477 |
+
* @deprecated 3.4.0 Use $wpmem->dialogs->login_failed().
|
478 |
+
*
|
479 |
+
* @global object $wpmem The WP_Members object.
|
480 |
+
* @return string $str The generated html for the login failed message.
|
481 |
+
*/
|
482 |
+
function wpmem_inc_loginfailed() {
|
483 |
+
wpmem_write_log( 'wpmem_inc_loginfailed() is deprecated as of WP-Members 3.4.0. Use $wpmem->dialogs->login_failed() instead.' );
|
484 |
+
global $wpmem;
|
485 |
+
return $wpmem->dialogs->login_failed();
|
486 |
+
}
|
487 |
+
endif;
|
488 |
+
|
489 |
+
|
490 |
+
if ( ! function_exists( 'wpmem_inc_regmessage' ) ):
|
491 |
+
/**
|
492 |
+
* Message Dialog.
|
493 |
+
*
|
494 |
+
* Returns various dialogs and error messages.
|
495 |
+
*
|
496 |
+
* @since 1.8
|
497 |
+
* @since 3.3.0 Changed 'toggles' to 'tags'
|
498 |
+
* @deprecated 3.4.0 Use wpmem_get_display_message() instead.
|
499 |
+
*
|
500 |
+
* @global object $wpmem
|
501 |
+
* @param string $tag Error message tag to look for specific error messages.
|
502 |
+
* @param string $msg A message that has no tag that is passed directly to the function.
|
503 |
+
* @return string $str The final HTML for the message.
|
504 |
+
*/
|
505 |
+
function wpmem_inc_regmessage( $tag, $msg = '' ) {
|
506 |
+
wpmem_write_log( "wpmem_inc_regmessage() is deprecated as of WP-Members 3.4.0. Use wpmem_get_display_message() instead." );
|
507 |
+
global $wpmem;
|
508 |
+
return $wpmem->dialogs->get_message( $tag, $msg );
|
509 |
+
}
|
510 |
+
endif;
|
511 |
+
|
512 |
+
|
513 |
+
if ( ! function_exists( 'wpmem_page_pwd_reset' ) ):
|
514 |
+
/**
|
515 |
+
* Password reset forms.
|
516 |
+
*
|
517 |
+
* This function creates both password reset and forgotten
|
518 |
+
* password forms for page=password shortcode.
|
519 |
+
*
|
520 |
+
* @since 2.7.6
|
521 |
+
* @since 3.2.6 Added nonce validation.
|
522 |
+
* @deprecated 3.4.0 Use $wpmem->shortcodes->render_pwd_reset() instead.
|
523 |
+
*
|
524 |
+
* @global object $wpmem
|
525 |
+
* @param string $wpmem_regchk
|
526 |
+
* @param string $content
|
527 |
+
* @return string $content
|
528 |
+
*/
|
529 |
+
function wpmem_page_pwd_reset( $wpmem_regchk, $content ) {
|
530 |
+
wpmem_write_log( "wpmem_page_pwd_reset() is deprecated as of WP-Members 3.4.0." );
|
531 |
+
global $wpmem;
|
532 |
+
$content = $wpmem->shortcodes->render_pwd_reset( $wpmem_regchk, $content );
|
533 |
+
return $content;
|
534 |
+
|
535 |
+
}
|
536 |
+
endif;
|
537 |
+
|
538 |
+
|
539 |
+
if ( ! function_exists( 'wpmem_page_user_edit' ) ):
|
540 |
+
/**
|
541 |
+
* Creates a user edit page.
|
542 |
+
*
|
543 |
+
* @since 2.7.6
|
544 |
+
* @since 3.3.9 Added $atts
|
545 |
+
* @deprecated 3.4.0 Use $wpmem->shortcodes->render_user_edit() instead.
|
546 |
+
*
|
547 |
+
* @global object $wpmem
|
548 |
+
* @global string $wpmem_a
|
549 |
+
* @global string $wpmem_themsg
|
550 |
+
* @param string $wpmem_regchk
|
551 |
+
* @param string $content
|
552 |
+
* @return string $content
|
553 |
+
*/
|
554 |
+
function wpmem_page_user_edit( $wpmem_regchk, $content, $atts = false ) {
|
555 |
+
wpmem_write_log( "wpmem_page_user_edit() is deprecated as of WP-Members 3.4.0." );
|
556 |
+
global $wpmem, $wpmem_a, $wpmem_themsg;
|
557 |
+
$content = $wpmem->shortcodes->render_user_edit( $wpmem_regchk, $content );
|
558 |
+
return $content;
|
559 |
+
}
|
560 |
+
endif;
|
561 |
+
|
562 |
+
|
563 |
+
/
|