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 / Classes / AdminNotices.php
wp-user-avatar / src / Classes Last commit date
Installer 3 years ago AdminNotices.php 2 months ago AjaxHandler.php 1 year ago Autologin.php 9 months ago BlockRegistrations.php 10 months ago BuddyPressBbPress.php 3 years ago DisableConcurrentLogins.php 2 years ago EditUserProfile.php 5 months ago ExtensionManager.php 1 month ago FileUploader.php 3 months ago FormPreviewHandler.php 5 months ago FormRepository.php 1 year ago FormShortcodeDefaults.php 1 month ago GDPR.php 3 years ago Geolocation.php 3 years ago GlobalSiteAccess.php 3 years ago ImageUploader.php 1 year ago LoginAuth.php 1 year ago Miscellaneous.php 3 years ago ModifyRedirectDefaultLinks.php 4 hours ago PPRESS_Session.php 1 year ago PROFILEPRESS_sql.php 1 year ago PasswordReset.php 1 year ago ProfileUrlRewrite.php 4 years ago RegistrationAuth.php 1 week ago SendEmail.php 3 years ago ShortcodeThemeFactory.php 5 years ago UserAvatar.php 1 year ago UserSignupLocationListingPage.php 3 years ago UsernameEmailRestrictLogin.php 4 years ago WPProfileFieldParserTrait.php 1 year ago WelcomeEmailAfterSignup.php 1 year ago default-email-template.php 1 year ago index.php 3 years ago
AdminNotices.php
324 lines
1 <?php
2
3 namespace ProfilePress\Core\Classes;
4
5 use ProfilePress\Core\Membership\PaymentMethods\AbstractPaymentMethod;
6 use ProfilePress\Core\Membership\PaymentMethods\Stripe\Helpers;
7 use ProfilePressVendor\PAnD;
8
9 class AdminNotices
10 {
11 public function __construct()
12 {
13 add_action('admin_init', function () {
14
15 if (ppress_is_admin_page()) {
16 remove_all_actions('admin_notices');
17 }
18
19 add_action('admin_notices', [$this, 'admin_notices_bucket']);
20
21 add_filter('removable_query_args', [$this, 'removable_query_args']);
22 });
23
24 if (class_exists('\ProfilePressVendor\PAnD')) {
25 // persist admin notice dismissal initialization
26 add_action('admin_init', array('ProfilePressVendor\PAnD', 'init'));
27 add_action('wp_ajax_dismiss_admin_notice', ['ProfilePressVendor\PAnD', 'dismiss_admin_notice']);
28 }
29 add_action('admin_init', array($this, 'act_on_request'));
30
31 add_filter('admin_body_class', [$this, 'add_admin_body_class']);
32 }
33
34 public function add_admin_body_class($classes)
35 {
36 $current_screen = get_current_screen();
37
38 if (empty ($current_screen)) return $classes;
39
40 if (false !== strpos($current_screen->id, 'ppress-')) {
41 // Leave space on both sides so other plugins do not conflict.
42 $classes .= ' ppress-admin ';
43 }
44
45 global $wp_version;
46
47 if (version_compare($wp_version, '6.9.4', '>')) {
48 $classes .= ' ppressWP7higher';
49 }
50
51 return $classes;
52 }
53
54 public function admin_notices_bucket()
55 {
56 do_action('ppress_admin_notices');
57
58 $this->test_mode_notice();
59
60 $this->seo_friendly_permalink_not_set();
61
62 $this->connect_enabled_stripe_method();
63
64 $this->registration_disabled_notice();
65
66 $this->create_plugin_pages();
67
68 $this->review_plugin_notice();
69
70 $this->addons_promo_notices();
71 }
72
73 public function act_on_request()
74 {
75 if ( ! empty($_GET['ppress_admin_action'])) {
76
77 if ($_GET['ppress_admin_action'] == 'dismiss_leave_review_forever') {
78 update_option('ppress_dismiss_leave_review_forever', true);
79 }
80
81 wp_safe_redirect(esc_url_raw(remove_query_arg('ppress_admin_action')));
82 exit;
83 }
84 }
85
86 public function test_mode_notice()
87 {
88 if (apply_filters('ppress_show_test_mode_notice', true) && ppress_is_test_mode() && current_user_can('manage_options')) {
89 $link = add_query_arg(
90 ['view' => 'payments', 'section' => 'payment-methods'],
91 PPRESS_SETTINGS_SETTING_PAGE
92 );
93
94 $notice = sprintf(__('<strong>Important:</strong> No real payment is being processed because ProfilePress is in test mode. Go to <a href="%s">Payment method settings</a> to disable test mode.', 'wp-user-avatar'), $link);
95 ?>
96 <div class="notice notice-warning">
97 <p><?php echo $notice; ?></p>
98 </div>
99 <?php
100 }
101 }
102
103 /**
104 * Display one-time admin notice to review plugin at least 7 days after installation
105 */
106 public function review_plugin_notice()
107 {
108 if ( ! current_user_can('manage_options')) return;
109
110 if ( ! PAnD::is_admin_notice_active('ppress-review-plugin-notice-forever')) return;
111
112 if (get_option('ppress_dismiss_leave_review_forever', false)) return;
113
114 $install_date = get_option('ppress_install_date', '');
115
116 if (empty($install_date)) return;
117
118 $diff = round((time() - strtotime($install_date)) / 24 / 60 / 60);
119
120 if ($diff < 7) return;
121
122 $review_url = 'https://wordpress.org/support/plugin/wp-user-avatar/reviews/?filter=5#new-post';
123
124 $dismiss_url = esc_url(add_query_arg('ppress_admin_action', 'dismiss_leave_review_forever'));
125
126 $notice = sprintf(
127 __('Hey, I noticed you have been using ProfilePress for at least 7 days now - that\'s awesome! Could you please do us a BIG favor and give it a %1$s5-star rating on WordPress?%2$s This will help us spread the word and boost our motivation - thanks!', 'wp-user-avatar'),
128 '<a href="' . $review_url . '" target="_blank">',
129 '</a>'
130 );
131 $label = __('Sure! I\'d love to give a review', 'wp-user-avatar');
132
133 $dismiss_label = __('Dismiss Forever', 'wp-user-avatar');
134
135 $notice .= "<div style=\"margin:10px 0 0;\"><a href=\"$review_url\" target='_blank' class=\"button-primary\">$label</a></div>";
136 $notice .= "<div style=\"margin:10px 0 0;\"><a href=\"$dismiss_url\">$dismiss_label</a></div>";
137
138 echo '<div data-dismissible="ppress-review-plugin-notice-forever" class="update-nag notice notice-warning is-dismissible">';
139 echo "<p>$notice</p>";
140 echo '</div>';
141 }
142
143 public function seo_friendly_permalink_not_set()
144 {
145 if ( ! PAnD::is_admin_notice_active('ppress_seo_friendly_permalink_not_set-2')) return;
146
147 if (is_admin() && current_user_can('administrator') && ! get_option('permalink_structure')) {
148
149 $change_permalink_button = sprintf(
150 '<a class="button" href="%s">%s</a>',
151 admin_url('options-permalink.php'),
152 __('Change Permalink Structure', 'wp-user-avatar')
153 );
154
155 $notice = sprintf(
156 __("Your site permalink structure is currently set to <code>Plain</code>. This setting is not compatible with ProfilePress. Change your permalink structure to any other setting to avoid issues. We recommend <code>Post name</code>.</p><p>%s", 'wp-user-avatar'),
157 $change_permalink_button
158 );
159
160 echo '<div data-dismissible="ppress_seo_friendly_permalink_not_set-2" class="update-nag notice notice-warning is-dismissible">';
161 echo "<p>$notice</p>";
162 echo '</div>';
163 }
164 }
165
166 public function addons_promo_notices()
167 {
168 $notices = [
169 'learndash' => [
170 'message' => esc_html__('Did you know that you can sell access to LearnDash courses and groups and enroll users after registration?', 'wp-user-avatar'),
171 'url' => 'https://profilepress.com/article/setting-up-learndash-addon/',
172 'condition' => class_exists('\SFWD_LMS')
173 ],
174 'sensei' => [
175 'message' => esc_html__('Did you know that you can sell access to Sensei LMS courses and groups and enroll users after registration?', 'wp-user-avatar'),
176 'url' => 'https://profilepress.com/article/setting-up-sensei-lms-addon/',
177 'condition' => function_exists('Sensei')
178 ]
179 ];
180
181 foreach ($notices as $notice_id => $notice) {
182
183 if (true === $notice['condition']) {
184
185 $notice_pand_key = sprintf('ppress_addons_promo_%s_notice-forever', $notice_id);
186
187 $url = $notice['url'] . '?utm_source=wp_dashboard&utm_medium=addons-promo&utm_campaign=admin-notice';
188
189 if (PAnD::is_admin_notice_active($notice_pand_key)) {
190
191 echo '<div data-dismissible="' . $notice_pand_key . '" class="notice notice-info is-dismissible">';
192 printf(
193 '<p>%s <a target="_blank" href="%s">%s</a></p>',
194 $notice['message'], $url, esc_html__('Learn more', 'wp-user-avatar'));
195 echo '</div>';
196 }
197 }
198 }
199 }
200
201 public function create_plugin_pages()
202 {
203 if ( ! PAnD::is_admin_notice_active('ppress-create-plugin-pages-notice-forever')) {
204 return;
205 }
206
207 $create_page_url = esc_url(add_query_arg([
208 'ppress_create_pages' => 'true',
209 'ppress_nonce' => wp_create_nonce('ppress_create_pages')
210 ]));
211
212 $class = 'notice notice-info is-dismissible';
213 $message = __('ProfilePress needs to create several pages (Checkout, Order Confirmation, User Profile, My Account, Registration, Login, Member Directory) to function correctly.', 'wp-user-avatar');
214 $buttons = sprintf(
215 '<a href="%s" class="button button-primary">%s</a> <a href="#" class="button-secondary dismiss-this">%s</a>',
216 $create_page_url, esc_html__('Create Pages', 'wp-user-avatar'), esc_html__('No Thanks', 'wp-user-avatar')
217 );
218
219 printf('<div data-dismissible="ppress-create-plugin-pages-notice-forever" class="%1$s"><p>%2$s</p><p>%3$s</p></div>', esc_attr($class), esc_html($message), $buttons);
220 }
221
222 public function connect_enabled_stripe_method()
223 {
224 if ( ! PAnD::is_admin_notice_active('ppress-connect-enabled-stripe-method-7')) {
225 return;
226 }
227
228 if (
229 ppress_get_payment_method_setting('stripe_enabled') != 'true' ||
230 ! empty(Helpers::get_secret_key())
231 ) {
232 return;
233 }
234
235 $class = 'notice notice-info is-dismissible';
236
237 $message = $this->stripe_connect_notice_html(
238 esc_html__('You enabled Stripe payment method in ProfilePress but did not connect your Stripe account. Connect now to start accepting payments instantly.', 'wp-user-avatar')
239 );
240
241 printf('<div data-dismissible="ppress-connect-enabled-stripe-method-7" class="%1$s">%2$s</div>', esc_attr($class), $message);
242 }
243
244 /**
245 * Notice when user registration is disabled.
246 */
247 function registration_disabled_notice()
248 {
249 if ( ! current_user_can('manage_options')) return;
250
251 if (get_option('users_can_register') || apply_filters('ppress_remove_registration_disabled_notice', false)) {
252 return;
253 }
254
255 if ( ! class_exists('\ProfilePressVendor\PAnD')) return;
256
257 if ( ! PAnD::is_admin_notice_active('pp-registration-disabled-notice-forever')) {
258 return;
259 }
260
261 $url = is_multisite() ? network_admin_url('settings.php') : admin_url('options-general.php');
262
263 ?>
264 <div data-dismissible="pp-registration-disabled-notice-forever" id="message" class="updated notice is-dismissible">
265 <p>
266 <?php printf(__('User registration currently disabled. To enable, Go to <a href="%1$s">Settings -> General</a>, and under Membership, check "Anyone can register"', 'wp-user-avatar'), $url); ?>
267 . </p>
268 </div>
269 <?php
270 }
271
272 public function removable_query_args($args = [])
273 {
274 $args[] = 'settings-updated';
275 $args[] = 'rule-updated';
276 $args[] = 'settings-added';
277 $args[] = 'field-edited';
278 $args[] = 'field-added';
279 $args[] = 'updated-contact-info';
280 $args[] = 'form-added';
281 $args[] = 'form-edited';
282 $args[] = 'user-profile-added';
283 $args[] = 'user-profile-edited';
284 $args[] = 'melange-edited';
285 $args[] = 'melange-added';
286 $args[] = 'license';
287
288 return $args;
289 }
290
291 private function stripe_connect_notice_html($message)
292 {
293 ob_start();
294 ?>
295
296 <p>
297 <?php echo $message; ?>
298 </p>
299
300 <p>
301 <?php echo Helpers::get_connect_button(AbstractPaymentMethod::get_payment_method_admin_page_url('stripe')); ?>
302
303 <a href="https://profilepress.com/article/setting-up-stripe/" target="_blank" rel="noopener noreferrer" class="button button-secondary" style="margin-left: 5px;">
304 <?php esc_html_e('Learn More', 'wp-user-avatar'); ?>
305 </a>
306 </p>
307
308 <?php
309
310 return ob_get_clean();
311 }
312
313 public static function get_instance()
314 {
315 static $instance = null;
316
317 if (is_null($instance)) {
318 $instance = new self();
319 }
320
321 return $instance;
322 }
323 }
324