class-eeb-admin.php
6 years ago
class-eeb-site.php
6 years ago
deprecated.php
6 years ago
integrations.php
6 years ago
template-functions.php
6 years ago
integrations.php
153 lines
| 1 | <?php |
| 2 | // this is an include only WP file |
| 3 | if (!defined('ABSPATH')) { |
| 4 | die; |
| 5 | } |
| 6 | |
| 7 | if ( ! class_exists( 'MO_Admin_Notice' ) && is_admin() ) { |
| 8 | class MO_Admin_Notice { |
| 9 | public function __construct() { |
| 10 | add_action( 'admin_notices', array( $this, 'admin_notice' ) ); |
| 11 | add_action( 'network_admin_notices', array( $this, 'admin_notice' ) ); |
| 12 | add_action( 'admin_init', array( $this, 'dismiss_admin_notice' ) ); |
| 13 | } |
| 14 | public function dismiss_admin_notice() { |
| 15 | if ( ! isset( $_GET['mo-adaction'] ) || $_GET['mo-adaction'] != 'mo_dismiss_adnotice' ) { |
| 16 | return; |
| 17 | } |
| 18 | $url = admin_url(); |
| 19 | update_option( 'mo_dismiss_adnotice', 'true' ); |
| 20 | wp_redirect( $url ); |
| 21 | exit; |
| 22 | } |
| 23 | public function admin_notice() { |
| 24 | global $pagenow; |
| 25 | if($pagenow == 'index.php' || (isset($_GET['page']) && strpos($_GET['page'], EMAIL_ENCODER_BUNDLE_ADMIN_PAGE) !== false)) { |
| 26 | if (get_option('mo_dismiss_adnotice', 'false') == 'true') { |
| 27 | return; |
| 28 | } |
| 29 | if ($this->is_plugin_installed() && $this->is_plugin_active()) { |
| 30 | return; |
| 31 | } |
| 32 | $dismiss_url = esc_url_raw( |
| 33 | add_query_arg( |
| 34 | array( |
| 35 | 'mo-adaction' => 'mo_dismiss_adnotice' |
| 36 | ), |
| 37 | admin_url() |
| 38 | ) |
| 39 | ); |
| 40 | $this->notice_css(); |
| 41 | $install_url = wp_nonce_url( |
| 42 | admin_url('update.php?action=install-plugin&plugin=mailoptin'), |
| 43 | 'install-plugin_mailoptin' |
| 44 | ); |
| 45 | $activate_url = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=mailoptin%2Fmailoptin.php'), 'activate-plugin_mailoptin/mailoptin.php'); |
| 46 | ?> |
| 47 | <div class="mo-admin-notice notice notice-success"> |
| 48 | <div class="mo-notice-first-half"> |
| 49 | <p> |
| 50 | <?php |
| 51 | printf( |
| 52 | __('Free optin form plugin that will %1$sincrease your email list subscribers%2$s and keep them engaged with %1$sautomated and schedule newsletters%2$s.'), |
| 53 | '<span class="mo-stylize"><strong>', '</strong></span>'); |
| 54 | ?> |
| 55 | </p> |
| 56 | <p style="text-decoration: underline;font-size: 12px;">Recommended by Email Encoder plugin</p> |
| 57 | </div> |
| 58 | <div class="mo-notice-other-half"> |
| 59 | <?php if ( ! $this->is_plugin_installed()) : ?> |
| 60 | <a class="button button-primary button-hero" id="mo-install-mailoptin-plugin" href="<?php echo $install_url; ?>"> |
| 61 | <?php _e('Install MailOptin Now for Free!'); ?> |
| 62 | </a> |
| 63 | <?php endif; ?> |
| 64 | <?php if ($this->is_plugin_installed() && ! $this->is_plugin_active()) : ?> |
| 65 | <a class="button button-primary button-hero" id="mo-activate-mailoptin-plugin" href="<?php echo $activate_url; ?>"> |
| 66 | <?php _e('Activate MailOptin Now!'); ?> |
| 67 | </a> |
| 68 | <?php endif; ?> |
| 69 | <div class="mo-notice-learn-more"> |
| 70 | <a target="_blank" href="https://mailoptin.io">Learn more</a> |
| 71 | </div> |
| 72 | </div> |
| 73 | <a href="<?php echo $dismiss_url; ?>"> |
| 74 | <button type="button" class="notice-dismiss"> |
| 75 | <span class="screen-reader-text"><?php _e('Dismiss this notice'); ?>.</span> |
| 76 | </button> |
| 77 | </a> |
| 78 | </div> |
| 79 | <?php |
| 80 | } |
| 81 | } |
| 82 | public function current_admin_url() { |
| 83 | $parts = parse_url( home_url() ); |
| 84 | $uri = $parts['scheme'] . '://' . $parts['host']; |
| 85 | if ( array_key_exists( 'port', $parts ) ) { |
| 86 | $uri .= ':' . $parts['port']; |
| 87 | } |
| 88 | $uri .= add_query_arg( array() ); |
| 89 | return $uri; |
| 90 | } |
| 91 | public function is_plugin_installed() { |
| 92 | $installed_plugins = get_plugins(); |
| 93 | return isset( $installed_plugins['mailoptin/mailoptin.php'] ); |
| 94 | } |
| 95 | public function is_plugin_active() { |
| 96 | return is_plugin_active( 'mailoptin/mailoptin.php' ); |
| 97 | } |
| 98 | public function notice_css() { |
| 99 | ?> |
| 100 | <style type="text/css"> |
| 101 | .mo-admin-notice { |
| 102 | background: #fff; |
| 103 | color: #000; |
| 104 | border-left-color: #46b450; |
| 105 | position: relative; |
| 106 | } |
| 107 | .mo-admin-notice .notice-dismiss:before { |
| 108 | color: #72777c; |
| 109 | } |
| 110 | .mo-admin-notice .mo-stylize { |
| 111 | line-height: 2; |
| 112 | } |
| 113 | .mo-admin-notice .button-primary { |
| 114 | background: #006799; |
| 115 | text-shadow: none; |
| 116 | border: 0; |
| 117 | box-shadow: none; |
| 118 | } |
| 119 | .mo-notice-first-half { |
| 120 | width: 66%; |
| 121 | display: inline-block; |
| 122 | margin: 10px 0; |
| 123 | } |
| 124 | .mo-notice-other-half { |
| 125 | width: 33%; |
| 126 | display: inline-block; |
| 127 | padding: 20px 0; |
| 128 | position: absolute; |
| 129 | text-align: center; |
| 130 | } |
| 131 | .mo-notice-first-half p { |
| 132 | font-size: 14px; |
| 133 | } |
| 134 | .mo-notice-learn-more a { |
| 135 | margin: 10px; |
| 136 | } |
| 137 | .mo-notice-learn-more { |
| 138 | margin-top: 10px; |
| 139 | } |
| 140 | </style> |
| 141 | <?php |
| 142 | } |
| 143 | public static function instance() { |
| 144 | static $instance = null; |
| 145 | if ( is_null( $instance ) ) { |
| 146 | $instance = new self(); |
| 147 | } |
| 148 | return $instance; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | MO_Admin_Notice::instance(); |
| 153 | } |