-
Notifications
You must be signed in to change notification settings - Fork 32
/
sponsors.php
212 lines (187 loc) · 5.85 KB
/
sponsors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
// Avoid direct calls to this file.
if ( ! defined( 'ABSPATH' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* Plugin sponsors.
*
* @version 3.6.8
*/
class PluginSponsor {
/* Recommend plugins.
*
* @since 3.6.8
*/
protected static $sponsors = array(
'mailoptin' => 'mailoptin/mailoptin.php',
);
/**
* PluginSponsor constructor.
*
* @since 3.6.8
*/
public function __construct() {
// admin notices.
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
add_action( 'network_admin_notices', array( $this, 'admin_notice' ) );
add_action( 'admin_init', array( $this, 'dismiss_admin_notice' ) );
}
/**
* Dismiss admin notice.
*
* @since 3.6.8
* @access public
*
* @return void
*/
public function dismiss_admin_notice() {
if ( ! isset( $_GET['mo-adaction'] ) || $_GET['mo-adaction'] != 'mo_dismiss_adnotice' ) {
return;
}
$url = admin_url();
update_option( 'mo_dismiss_adnotice', 'true' );
wp_redirect( $url );
exit;
}
/**
* Add admin notices.
*
* @since 3.6.8
* @access public
*
* @return void
*/
public function admin_notice() {
if ( get_option( 'mo_dismiss_adnotice', 'false' ) == 'true' ) {
return;
}
if ( $this->is_plugin_installed( 'mailoptin' ) && $this->is_plugin_active( 'mailoptin' ) ) {
return;
}
$dismiss_url = esc_url_raw(
add_query_arg(
array(
'mo-adaction' => 'mo_dismiss_adnotice',
),
admin_url()
)
);
$this->notice_css();
$install_url = wp_nonce_url(
admin_url( 'update.php?action=install-plugin&plugin=mailoptin' ),
'install-plugin_mailoptin'
);
$activate_url = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=mailoptin%2Fmailoptin.php' ),
'activate-plugin_mailoptin/mailoptin.php' );
?>
<div class="mo-admin-notice notice notice-success">
<div class="mo-notice-first-half">
<p>
<?php
printf(
__( '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.' ),
'<span class="mo-stylize"><strong>', '</strong></span>' );
?>
</p>
<p style="text-decoration: underline;font-size: 12px;">Recommended by Dynamic Featured Image plugin</p>
</div>
<div class="mo-notice-other-half">
<?php if ( ! $this->is_plugin_installed( 'mailoptin' ) ) : ?>
<a class="button button-primary button-hero" id="mo-install-mailoptin-plugin"
href="<?php echo $install_url; ?>">
<?php _e( 'Install MailOptin Now for Free!' ); ?>
</a>
<?php endif; ?>
<?php if ( $this->is_plugin_installed( 'mailoptin' ) && ! $this->is_plugin_active( 'mailoptin' ) ) : ?>
<a class="button button-primary button-hero" id="mo-activate-mailoptin-plugin"
href="<?php echo $activate_url; ?>">
<?php _e( 'Activate MailOptin Now!' ); ?>
</a>
<?php endif; ?>
<div class="mo-notice-learn-more">
<a target="_blank" href="https://mailoptin.io">Learn more</a>
</div>
</div>
<a href="<?php echo $dismiss_url; ?>">
<button type="button" class="notice-dismiss">
<span class="screen-reader-text"><?php _e( 'Dismiss this notice' ); ?>.</span>
</button>
</a>
</div>
<?php
}
/**
* Check if plugin is installed.
*
* @param $key
*
* @return bool
*/
protected function is_plugin_installed( $key ) {
$installed_plugins = get_plugins();
return isset( $installed_plugins[ self::$sponsors[ $key ] ] );
}
/**
* Check if plugin is active.
*
* @param $key
*
* @return bool
*/
protected function is_plugin_active( $key ) {
return is_plugin_active( self::$sponsors[ $key ] );
}
/**
* Styles for notice.
*
* @return void
*/
protected function notice_css() {
?>
<style type="text/css">
.mo-admin-notice {
background: #fff;
color: #000;
border-left-color: #46b450;
position: relative;
}
.mo-admin-notice .notice-dismiss:before {
color: #72777c;
}
.mo-admin-notice .mo-stylize {
line-height: 2;
}
.mo-admin-notice .button-primary {
background: #006799;
text-shadow: none;
border: 0;
box-shadow: none;
}
.mo-notice-first-half {
width: 66%;
display: inline-block;
margin: 10px 0;
}
.mo-notice-other-half {
width: 33%;
display: inline-block;
padding: 20px 0;
position: absolute;
text-align: center;
}
.mo-notice-first-half p {
font-size: 14px;
}
.mo-notice-learn-more a {
margin: 10px;
}
.mo-notice-learn-more {
margin-top: 10px;
}
</style>
<?php
}
}