PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / RegisterActivation / Base.php
wp-user-avatar / src / RegisterActivation Last commit date
Base.php 9 months ago CreateDBTables.php 1 year ago index.php 5 years ago
Base.php
289 lines
1 <?php
2
3 namespace ProfilePress\Core\RegisterActivation;
4
5 use ProfilePress\Core\Classes\FormRepository as FR;
6 use ProfilePress\Core\Membership\DigitalProducts\UploadHandler;
7
8 class Base
9 {
10 public static function run_install($networkwide = false)
11 {
12 if (is_multisite() && $networkwide) {
13
14 $site_ids = get_sites(['fields' => 'ids', 'number' => 0]);
15
16 foreach ($site_ids as $site_id) {
17 switch_to_blog($site_id);
18 self::pp_install();
19 restore_current_blog();
20 }
21 } else {
22 self::pp_install();
23 }
24
25 flush_rewrite_rules();
26 }
27
28 /**
29 * Run plugin install / activation action when new blog is created in multisite setup.
30 *
31 * @param int $blog_id
32 */
33 public static function multisite_new_blog_install($blog_id)
34 {
35 if ( ! function_exists('is_plugin_active_for_network')) {
36 require_once ABSPATH . 'wp-admin/includes/plugin.php';
37 }
38
39 if (is_plugin_active_for_network('wp-user-avatar/wp-user-avatar.php')) {
40 switch_to_blog($blog_id);
41 self::pp_install();
42 restore_current_blog();
43 }
44 }
45
46 /**
47 * Perform plugin activation / installation.
48 */
49 public static function pp_install()
50 {
51 // set flag for those migrating from wp user avatar
52 if ( ! get_option('ppress_plugin_activated') && '1' == get_option('wp_user_avatar_default_avatar_updated')) {
53 add_option('ppress_is_from_wp_user_avatar', 'true');
54 }
55
56 if ( ! current_user_can('activate_plugins') || get_option('ppress_plugin_activated') == 'true') return;
57
58 CreateDBTables::make();
59
60 UploadHandler::get_instance()->create_protection_files(true);
61
62 self::default_settings();
63 self::create_default_forms();
64 self::clear_wpengine_cache();
65
66 add_option('ppress_install_date', current_time('mysql'));
67 add_option('ppress_plugin_activated', 'true');
68 add_option('ppress_new_v4_install', 'true');
69
70 flush_rewrite_rules();
71 }
72
73 public static function create_default_forms()
74 {
75 FR::add_form(
76 esc_html__('Default Registration', 'wp-user-avatar'),
77 FR::REGISTRATION_TYPE,
78 'Tulip',
79 FR::DRAG_DROP_BUILDER_TYPE
80 );
81
82 FR::add_form(
83 esc_html__('Default Login', 'wp-user-avatar'),
84 FR::LOGIN_TYPE,
85 'Tulip',
86 FR::DRAG_DROP_BUILDER_TYPE
87 );
88
89 FR::add_form(
90 esc_html__('Default Password Reset', 'wp-user-avatar'),
91 FR::PASSWORD_RESET_TYPE,
92 'Tulip',
93 FR::DRAG_DROP_BUILDER_TYPE
94 );
95
96 FR::add_form(
97 esc_html__('Default Edit Profile', 'wp-user-avatar'),
98 FR::EDIT_PROFILE_TYPE,
99 'Tulip',
100 FR::DRAG_DROP_BUILDER_TYPE
101 );
102
103 FR::add_form(
104 esc_html__('Default User Profile', 'wp-user-avatar'),
105 FR::USER_PROFILE_TYPE,
106 'DefaultTemplate',
107 FR::DRAG_DROP_BUILDER_TYPE
108 );
109
110 FR::add_form(
111 esc_html__('Default Member Directory', 'wp-user-avatar'),
112 FR::MEMBERS_DIRECTORY_TYPE,
113 'DefaultTemplate',
114 FR::DRAG_DROP_BUILDER_TYPE
115 );
116
117 FR::add_form(
118 esc_html__('Lucid Tab Widget', 'wp-user-avatar'),
119 FR::MELANGE_TYPE,
120 'Lucid',
121 FR::SHORTCODE_BUILDER_TYPE
122 );
123 }
124
125 public static function default_settings()
126 {
127 $settings = [
128 'login_username_email_restrict' => 'both',
129 'myac_edit_account_endpoint' => 'edit-profile',
130 'myac_change_password_endpoint' => 'change-password',
131 'set_user_profile_slug' => 'profile',
132 'set_login_redirect' => 'dashboard',
133 'global_site_access' => 'everyone',
134 'global_restricted_access_message' => '<p>' . esc_html__('You are unauthorized to view this page.', 'wp-user-avatar') . '</p>',
135
136 'admin_email_addresses' => ppress_admin_email(),
137 'email_sender_name' => ppress_site_title(),
138 'email_sender_email' => 'wordpress@' . ppress_site_url_without_scheme(),
139 'email_content_type' => 'text/html',
140 'email_template_type' => 'default',
141
142 'password_reset_email_enabled' => 'on',
143 'password_reset_email_subject' => sprintf(__('[%s] Password Reset'), ppress_site_title()),
144 'password_reset_email_content' => ppress_password_reset_content_default(),
145
146 'new_user_admin_email_email_enabled' => 'on',
147 'new_user_admin_email_email_subject' => sprintf(__('[%s] New User Registration'), ppress_site_title()),
148 'new_user_admin_email_email_content' => ppress_new_user_admin_notification_message_default(),
149 ];
150
151 foreach ($settings as $key => $value) {
152 ppress_update_settings($key, $value);
153 }
154
155 self::membership_default_settings();
156 }
157
158 public static function membership_default_settings()
159 {
160 $settings = [
161 // Business info
162 'business_name' => ppress_site_title(),
163 'business_country' => 'US',
164 // Payment settings
165 //'payment_currency' => 'USD', excluded so onboarding checklist can ask user to set currency
166 'currency_position' => 'left',
167 'currency_decimal_separator' => '.',
168 'currency_thousand_separator' => ',',
169 'currency_decimal_number' => '2',
170 'terms_agreement_label' => sprintf(__('I have read and agree to the website %s', 'wp-user-avatar'), '[terms]'),
171 ];
172
173 foreach ($settings as $key => $value) {
174 ppress_update_settings($key, $value);
175 }
176 }
177
178 public static function create_pages()
179 {
180 $pages = [
181 'set_login_url' => [
182 'post_title' => esc_html__('Log In', 'wp-user-avatar'),
183 'post_content' => sprintf('<!-- wp:shortcode -->[profilepress-login id="%s"]<!-- /wp:shortcode -->', FR::get_form_first_id(FR::LOGIN_TYPE)),
184 ],
185 'set_registration_url' => [
186 'post_title' => esc_html__('Sign Up', 'wp-user-avatar'),
187 'post_content' => sprintf('<!-- wp:shortcode -->[profilepress-registration id="%s"]<!-- /wp:shortcode -->', FR::get_form_first_id(FR::REGISTRATION_TYPE)),
188 ],
189 'set_lost_password_url' => [
190 'post_title' => esc_html__('Reset Password', 'wp-user-avatar'),
191 'post_content' => sprintf('<!-- wp:shortcode -->[profilepress-password-reset id="%s"]<!-- /wp:shortcode -->', FR::get_form_first_id(FR::PASSWORD_RESET_TYPE)),
192 ],
193 'edit_user_profile_url' => [
194 'post_title' => esc_html__('My Account', 'wp-user-avatar'),
195 'post_content' => '<!-- wp:shortcode -->[profilepress-my-account]<!-- /wp:shortcode -->',
196 'post_name' => 'account'
197 ],
198 'set_user_profile_shortcode' => [
199 'post_title' => esc_html__('My Profile', 'wp-user-avatar'),
200 'post_content' => sprintf('<!-- wp:shortcode -->[profilepress-user-profile id="%s"]<!-- /wp:shortcode -->', FR::get_form_first_id(FR::USER_PROFILE_TYPE))
201 ],
202 'member_directory' => [
203 'post_title' => esc_html__('Member Directory', 'wp-user-avatar'),
204 'post_content' => sprintf('<!-- wp:shortcode -->[profilepress-member-directory id="%s"]<!-- /wp:shortcode -->', FR::get_form_first_id(FR::MEMBERS_DIRECTORY_TYPE))
205 ]
206 ];
207
208 foreach ($pages as $key => $page) {
209
210 $insert = wp_insert_post(
211 array_merge(
212 ['post_status' => 'publish', 'post_type' => 'page'],
213 $page
214 ),
215 true
216 );
217
218 if ($insert && ! is_wp_error($insert)) {
219 ppress_update_settings($key, $insert);
220 }
221 }
222
223 self::create_membership_pages();
224 }
225
226 public static function create_membership_pages()
227 {
228 $pages = [
229 'checkout_page_id' => [
230 'post_title' => esc_html__('Checkout', 'wp-user-avatar'),
231 'post_content' => '<!-- wp:shortcode -->[profilepress-checkout]<!-- /wp:shortcode -->'
232 ],
233 'payment_success_page_id' => [
234 'post_title' => esc_html__('Order Confirmation', 'wp-user-avatar'),
235 'post_content' => sprintf(
236 '<!-- wp:paragraph --><p>%s</p><!-- /wp:paragraph --><!-- wp:shortcode -->[profilepress-receipt]<!-- /wp:shortcode -->',
237 esc_html__('Thank you for your order!', 'wp-user-avatar')
238 )
239 ],
240 'payment_failure_page_id' => [
241 'post_title' => esc_html__('Order Failed', 'wp-user-avatar'),
242 'post_content' => sprintf(
243 '<!-- wp:paragraph --><p>%s</p><!-- /wp:paragraph -->',
244 esc_html__('Your transaction failed, please try again or contact support.', 'wp-user-avatar')
245 )
246 ]
247 ];
248
249 foreach ($pages as $key => $page) {
250
251 $page_id = ppress_settings_by_key($key, '');
252 $page_status = get_post_status($page_id);
253
254 if (empty($page_id) || 'publish' !== $page_status) {
255
256 $insert = wp_insert_post(
257 array_merge(
258 ['post_status' => 'publish', 'post_type' => 'page'],
259 $page
260 ),
261 true
262 );
263
264 if ($insert && ! is_wp_error($insert)) {
265 ppress_update_settings($key, $insert);
266 }
267 }
268 }
269 }
270
271 public static function clear_wpengine_cache()
272 {
273 if ( ! class_exists('\WpeCommon')) {
274 return;
275 }
276
277 if (method_exists('\WpeCommon', 'purge_memcached')) {
278 \WpeCommon::purge_memcached();
279 }
280
281 if (method_exists('\WpeCommon', 'clear_maxcdn_cache')) {
282 \WpeCommon::clear_maxcdn_cache();
283 }
284
285 if (method_exists('\WpeCommon', 'purge_varnish_cache')) {
286 \WpeCommon::purge_varnish_cache();
287 }
288 }
289 }