99
1010use WebberZone \Contextual_Related_Posts \Admin \Activator ;
1111use WebberZone \Contextual_Related_Posts \Frontend \Display ;
12-
1312if ( ! defined ( 'WPINC ' ) ) {
1413 exit ;
1514}
16-
1715/**
1816 * Main plugin class.
1917 *
@@ -72,15 +70,6 @@ final class Main {
7270 */
7371 public Frontend \Language_Handler $ language ;
7472
75- /**
76- * Pro modules.
77- *
78- * @since 3.5.0
79- *
80- * @var Pro\Pro|null
81- */
82- public ?Pro \Pro $ pro = null ;
83-
8473 /**
8574 * Gets the instance of the class.
8675 *
@@ -93,7 +82,6 @@ public static function get_instance(): self {
9382 self ::$ instance = new self ();
9483 self ::$ instance ->init ();
9584 }
96-
9785 return self ::$ instance ;
9886 }
9987
@@ -116,9 +104,7 @@ private function init(): void {
116104 $ this ->styles = new Frontend \Styles_Handler ();
117105 $ this ->shortcodes = new Frontend \Shortcodes ();
118106 $ this ->blocks = new Frontend \Blocks \Blocks ();
119-
120107 $ this ->hooks ();
121-
122108 if ( is_admin () ) {
123109 $ this ->admin = new Admin \Admin ();
124110 if ( is_multisite () ) {
@@ -140,8 +126,12 @@ public function hooks(): void {
140126 add_filter ( 'the_excerpt_rss ' , array ( $ this , 'content_filter ' ), \crp_get_option ( 'content_filter_priority ' , 10 ) );
141127 add_filter ( 'the_content_feed ' , array ( $ this , 'content_filter ' ), \crp_get_option ( 'content_filter_priority ' , 10 ) );
142128 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+ );
145135 add_action ( 'pre_current_active_plugins ' , array ( $ this , 'plugin_deactivated_notice ' ) );
146136 }
147137
@@ -160,8 +150,9 @@ public function initiate_plugin(): void {
160150 * @since 3.5.0
161151 */
162152 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 ' );
164154 }
155+
165156 /**
166157 * Function to register our new routes from the controller.
167158 *
@@ -210,25 +201,20 @@ public function activated_plugin( string $plugin, bool $network_wide ): void {
210201 if ( ! in_array ( $ plugin , array ( 'contextual-related-posts/contextual-related-posts.php ' , 'contextual-related-posts-pro/contextual-related-posts.php ' ), true ) ) {
211202 return ;
212203 }
213-
214204 Activator::activation_hook ( $ network_wide );
215-
216205 $ plugin_to_deactivate = 'contextual-related-posts/contextual-related-posts.php ' ;
217206 $ deactivated_notice_id = '1 ' ;
218-
219207 // If we just activated the free version, deactivate the pro version.
220208 if ( $ plugin === $ plugin_to_deactivate ) {
221209 $ plugin_to_deactivate = 'contextual-related-posts-pro/contextual-related-posts.php ' ;
222210 $ deactivated_notice_id = '2 ' ;
223211 }
224-
225212 if ( is_multisite () && is_network_admin () ) {
226213 $ active_plugins = (array ) get_site_option ( 'active_sitewide_plugins ' , array () );
227214 $ active_plugins = array_keys ( $ active_plugins );
228215 } else {
229216 $ active_plugins = (array ) get_option ( 'active_plugins ' , array () );
230217 }
231-
232218 foreach ( $ active_plugins as $ plugin_basename ) {
233219 if ( $ plugin_to_deactivate === $ plugin_basename ) {
234220 set_transient ( 'crp_deactivated_notice_id ' , $ deactivated_notice_id , 1 * HOUR_IN_SECONDS );
@@ -248,18 +234,19 @@ public function plugin_deactivated_notice(): void {
248234 if ( ! in_array ( $ deactivated_notice_id , array ( 1 , 2 ), true ) ) {
249235 return ;
250236 }
251-
252237 $ 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 ' );
253238 if ( 2 === $ deactivated_notice_id ) {
254239 $ 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 ' );
255240 }
256-
257241 ?>
258242 <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>
260248 </div>
261249 <?php
262-
263250 delete_transient ( 'crp_deactivated_notice_id ' );
264251 }
265252}
0 commit comments