9
9
10
10
use WebberZone \Contextual_Related_Posts \Admin \Activator ;
11
11
use WebberZone \Contextual_Related_Posts \Frontend \Display ;
12
-
13
12
if ( ! defined ( 'WPINC ' ) ) {
14
13
exit ;
15
14
}
16
-
17
15
/**
18
16
* Main plugin class.
19
17
*
@@ -72,15 +70,6 @@ final class Main {
72
70
*/
73
71
public Frontend \Language_Handler $ language ;
74
72
75
- /**
76
- * Pro modules.
77
- *
78
- * @since 3.5.0
79
- *
80
- * @var Pro\Pro|null
81
- */
82
- public ?Pro \Pro $ pro = null ;
83
-
84
73
/**
85
74
* Gets the instance of the class.
86
75
*
@@ -93,7 +82,6 @@ public static function get_instance(): self {
93
82
self ::$ instance = new self ();
94
83
self ::$ instance ->init ();
95
84
}
96
-
97
85
return self ::$ instance ;
98
86
}
99
87
@@ -116,9 +104,7 @@ private function init(): void {
116
104
$ this ->styles = new Frontend \Styles_Handler ();
117
105
$ this ->shortcodes = new Frontend \Shortcodes ();
118
106
$ this ->blocks = new Frontend \Blocks \Blocks ();
119
-
120
107
$ this ->hooks ();
121
-
122
108
if ( is_admin () ) {
123
109
$ this ->admin = new Admin \Admin ();
124
110
if ( is_multisite () ) {
@@ -140,8 +126,12 @@ public function hooks(): void {
140
126
add_filter ( 'the_excerpt_rss ' , array ( $ this , 'content_filter ' ), \crp_get_option ( 'content_filter_priority ' , 10 ) );
141
127
add_filter ( 'the_content_feed ' , array ( $ this , 'content_filter ' ), \crp_get_option ( 'content_filter_priority ' , 10 ) );
142
128
add_action ( 'parse_query ' , array ( $ this , 'parse_query ' ) );
143
-
144
- add_action ( 'activated_plugin ' , array ( $ this , 'activated_plugin ' ), 10 , 2 );
129
+ add_action (
130
+ 'activated_plugin ' ,
131
+ array ( $ this , 'activated_plugin ' ),
132
+ 10 ,
133
+ 2
134
+ );
145
135
add_action ( 'pre_current_active_plugins ' , array ( $ this , 'plugin_deactivated_notice ' ) );
146
136
}
147
137
@@ -160,8 +150,9 @@ public function initiate_plugin(): void {
160
150
* @since 3.5.0
161
151
*/
162
152
public function register_widgets (): void {
163
- register_widget ( '\WebberZone\Contextual_Related_Posts\Frontend\Widgets\Related_Posts_Widget ' );
153
+ register_widget ( '\\ WebberZone \\ Contextual_Related_Posts \\ Frontend \\ Widgets \ \Related_Posts_Widget ' );
164
154
}
155
+
165
156
/**
166
157
* Function to register our new routes from the controller.
167
158
*
@@ -210,25 +201,20 @@ public function activated_plugin( string $plugin, bool $network_wide ): void {
210
201
if ( ! in_array ( $ plugin , array ( 'contextual-related-posts/contextual-related-posts.php ' , 'contextual-related-posts-pro/contextual-related-posts.php ' ), true ) ) {
211
202
return ;
212
203
}
213
-
214
204
Activator::activation_hook ( $ network_wide );
215
-
216
205
$ plugin_to_deactivate = 'contextual-related-posts/contextual-related-posts.php ' ;
217
206
$ deactivated_notice_id = '1 ' ;
218
-
219
207
// If we just activated the free version, deactivate the pro version.
220
208
if ( $ plugin === $ plugin_to_deactivate ) {
221
209
$ plugin_to_deactivate = 'contextual-related-posts-pro/contextual-related-posts.php ' ;
222
210
$ deactivated_notice_id = '2 ' ;
223
211
}
224
-
225
212
if ( is_multisite () && is_network_admin () ) {
226
213
$ active_plugins = (array ) get_site_option ( 'active_sitewide_plugins ' , array () );
227
214
$ active_plugins = array_keys ( $ active_plugins );
228
215
} else {
229
216
$ active_plugins = (array ) get_option ( 'active_plugins ' , array () );
230
217
}
231
-
232
218
foreach ( $ active_plugins as $ plugin_basename ) {
233
219
if ( $ plugin_to_deactivate === $ plugin_basename ) {
234
220
set_transient ( 'crp_deactivated_notice_id ' , $ deactivated_notice_id , 1 * HOUR_IN_SECONDS );
@@ -248,18 +234,19 @@ public function plugin_deactivated_notice(): void {
248
234
if ( ! in_array ( $ deactivated_notice_id , array ( 1 , 2 ), true ) ) {
249
235
return ;
250
236
}
251
-
252
237
$ message = __ ( "Contextual Related Posts and Contextual Related Posts PRO should not be active at the same time. We've automatically deactivated Contextual Related Posts. " , 'contextual-related-posts ' );
253
238
if ( 2 === $ deactivated_notice_id ) {
254
239
$ message = __ ( "Contextual Related Posts and Contextual Related Posts PRO should not be active at the same time. We've automatically deactivated Contextual Related Posts PRO. " , 'contextual-related-posts ' );
255
240
}
256
-
257
241
?>
258
242
<div class="updated" style="border-left: 4px solid #ffba00;">
259
- <p><?php echo esc_html ( $ message ); ?> </p>
243
+ <p>
244
+ <?php
245
+ echo esc_html ( $ message );
246
+ ?>
247
+ </p>
260
248
</div>
261
249
<?php
262
-
263
250
delete_transient ( 'crp_deactivated_notice_id ' );
264
251
}
265
252
}
0 commit comments