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