PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.54
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.54
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.54, at public/admin/class-noticemanager.php

79 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 /**
18 * Class constructor, adds the necessary hooks.
19 */
20 public function __construct() {
21 add_action( 'admin_notices', array( $this, 'leadin_action_required_notice' ) );
22 }
23
24 /**
25 * Render the disconnected banner.
26 */
27 private function leadin_render_disconnected_banner() {
28 ?>
29 <div id="leadin-disconnected-banner" class="leadin-banner notice notice-warning is-dismissible">
30 <p>
31 <img src="<?php echo esc_attr( LEADIN_ASSETS_PATH . '/images/sprocket.svg' ); ?>" height="16" style="margin-bottom: -3px" />
32 &nbsp;
33 <?php
34 echo sprintf(
35 esc_html( __( 'The HubSpot plugin is not connected right now To use HubSpot tools on your WordPress site, %1$sconnect the plugin now%2$s', 'leadin' ) ),
36 '<a class="leadin-banner__link" href="admin.php?page=leadin&bannerClick=true">',
37 '</a>'
38 );
39 ?>
40 </p>
41 </div>
42 <?php
43 }
44
45 /**
46 * Find what notice (if any) needs to be rendered
47 */
48 public function leadin_action_required_notice() {
49 $current_screen = get_current_screen();
50 if ( User::is_admin() ) {
51 if ( self::should_show_disconnected_notice() ) {
52 $this->leadin_render_disconnected_banner();
53 } elseif ( self::should_show_review_notice() ) {
54 $review_banner = new ReviewBanner();
55 $review_banner->leadin_render_review_banner();
56 }
57 }
58 }
59
60 /**
61 * Find if disconnected notice should be shown
62 */
63 public function should_show_disconnected_notice() {
64 $current_screen = get_current_screen();
65 return ! Connection::is_connected() && 'leadin' !== $current_screen->parent_base;
66 }
67
68 /**
69 * Find if review notice should be shown
70 */
71 public function should_show_review_notice() {
72 $current_screen = get_current_screen();
73 $is_dashboard = 'index' === $current_screen->parent_base;
74 $is_not_skipped = empty( User_Metadata::get_skip_review() );
75 return $is_dashboard && Connection::is_connected() && $is_not_skipped;
76 }
77
78 }
79