PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / admin / class-noticemanager.php

class-noticemanager.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at public/admin/class-noticemanager.php

78 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadin\admin;
4
5 use Leadin\data\User;
6 use Leadin\admin\Connection;
7 use Leadin\data\User_Metadata;
8 use Leadin\admin\AdminConstants;
9 use Leadin\admin\ReviewBanner;
10
11 /**
12 * Class responsible for rendering the admin notices.
13 */
14 class NoticeManager {
15
16 /**
17 * Class constructor, adds the necessary hooks.
18 */
19 public function __construct() {
20 add_action( 'admin_notices', array( $this, 'leadin_action_required_notice' ) );
21 }
22
23 /**
24 * Render the disconnected banner.
25 */
26 private function leadin_render_disconnected_banner() {
27 ?>
28 <div id="leadin-disconnected-banner" class="leadin-banner notice notice-warning is-dismissible">
29 <p>
30 <img src="<?php echo esc_attr( LEADIN_ASSETS_PATH . '/images/sprocket.svg' ); ?>" height="16" style="margin-bottom: -3px" />
31 &nbsp;
32 <?php
33 echo sprintf(
34 esc_html( __( 'The HubSpot plugin isn’t connected right now. To use HubSpot tools on your WordPress site, %1$sconnect the plugin now%2$s.', 'leadin' ) ),
35 '<a class="leadin-banner__link" href="admin.php?page=leadin&bannerClick=true">',
36 '</a>'
37 );
38 ?>
39 </p>
40 </div>
41 <?php
42 }
43
44 /**
45 * Find what notice (if any) needs to be rendered
46 */
47 public function leadin_action_required_notice() {
48 $current_screen = get_current_screen();
49 if ( User::is_admin() ) {
50 if ( self::should_show_disconnected_notice() ) {
51 $this->leadin_render_disconnected_banner();
52 } elseif ( self::should_show_review_notice() ) {
53 $review_banner = new ReviewBanner();
54 $review_banner->leadin_render_review_banner();
55 }
56 }
57 }
58
59 /**
60 * Find if disconnected notice should be shown
61 */
62 public function should_show_disconnected_notice() {
63 $current_screen = get_current_screen();
64 return ! Connection::is_connected() && 'leadin' !== $current_screen->parent_base;
65 }
66
67 /**
68 * Find if review notice should be shown
69 */
70 public function should_show_review_notice() {
71 $current_screen = get_current_screen();
72 $is_dashboard = 'index' === $current_screen->parent_base;
73 $is_not_skipped = empty( User_Metadata::get_skip_review() );
74 return $is_dashboard && Connection::is_connected() && $is_not_skipped;
75 }
76
77 }
78