88namespace WebberZone \Better_Search ;
99
1010use WebberZone \Better_Search \Admin \Activator ;
11+
1112if ( ! defined ( 'WPINC ' ) ) {
1213 exit ;
1314}
15+
1416/**
1517 * Main plugin class.
1618 *
@@ -117,6 +119,7 @@ public static function get_instance() {
117119 self ::$ instance = new self ();
118120 self ::$ instance ->init ();
119121 }
122+
120123 return self ::$ instance ;
121124 }
122125
@@ -142,10 +145,19 @@ private function init() {
142145 $ this ->display = new Frontend \Display ();
143146 $ this ->live_search = new Frontend \Live_Search ();
144147 $ this ->template_handler = new Frontend \Template_Handler ();
148+
145149 $ this ->hooks ();
150+
146151 if ( ! function_exists ( 'bsearch_freemius ' ) ) {
147152 require_once __DIR__ . '/load-freemius.php ' ;
148153 }
154+
155+ if ( bsearch_freemius ()->is__premium_only () ) {
156+ if ( bsearch_freemius ()->can_use_premium_code () ) {
157+ $ this ->pro = new Pro \Pro ();
158+ }
159+ }
160+
149161 if ( is_admin () ) {
150162 $ this ->admin = new Admin \Admin ();
151163 if ( is_multisite () ) {
@@ -182,8 +194,8 @@ public function initiate_plugin() {
182194 * @since 3.3.0
183195 */
184196 public function register_widgets () {
185- register_widget ( '\\ WebberZone \\ Better_Search \\ Frontend \\ Widgets \ \Search_Box ' );
186- register_widget ( '\\ WebberZone \\ Better_Search \\ Frontend \\ Widgets \ \Search_Heatmap ' );
197+ register_widget ( '\WebberZone\Better_Search\Frontend\Widgets\Search_Box ' );
198+ register_widget ( '\WebberZone\Better_Search\Frontend\Widgets\Search_Heatmap ' );
187199 }
188200
189201 /**
@@ -199,20 +211,25 @@ public function activated_plugin( $plugin, $network_wide ) {
199211 if ( ! in_array ( $ plugin , array ( 'better-search/better-search.php ' , 'better-search-pro/better-search.php ' ), true ) ) {
200212 return ;
201213 }
214+
202215 Activator::activation_hook ( $ network_wide );
216+
203217 $ plugin_to_deactivate = 'better-search/better-search.php ' ;
204218 $ deactivated_notice_id = '1 ' ;
219+
205220 // If we just activated the free version, deactivate the pro version.
206221 if ( $ plugin === $ plugin_to_deactivate ) {
207222 $ plugin_to_deactivate = 'better-search-pro/better-search.php ' ;
208223 $ deactivated_notice_id = '2 ' ;
209224 }
225+
210226 if ( is_multisite () && is_network_admin () ) {
211227 $ active_plugins = (array ) get_site_option ( 'active_sitewide_plugins ' , array () );
212228 $ active_plugins = array_keys ( $ active_plugins );
213229 } else {
214230 $ active_plugins = (array ) get_option ( 'active_plugins ' , array () );
215231 }
232+
216233 foreach ( $ active_plugins as $ plugin_basename ) {
217234 if ( $ plugin_to_deactivate === $ plugin_basename ) {
218235 set_transient ( 'bsearch_deactivated_notice_id ' , $ deactivated_notice_id , 1 * HOUR_IN_SECONDS );
@@ -232,10 +249,12 @@ public function plugin_deactivated_notice() {
232249 if ( ! in_array ( $ deactivated_notice_id , array ( 1 , 2 ), true ) ) {
233250 return ;
234251 }
252+
235253 $ message = __ ( "Better Search and Better Search Pro should not be active at the same time. We've automatically deactivated Better Search. " , 'better-search ' );
236254 if ( 2 === $ deactivated_notice_id ) {
237255 $ message = __ ( "Better Search and Better Search Pro should not be active at the same time. We've automatically deactivated Better Search Pro. " , 'better-search ' );
238256 }
257+
239258 ?>
240259 <div class="updated" style="border-left: 4px solid #ffba00;">
241260 <p>
@@ -245,6 +264,7 @@ public function plugin_deactivated_notice() {
245264 </p>
246265 </div>
247266 <?php
267+
248268 delete_transient ( 'bsearch_deactivated_notice_id ' );
249269 }
250270
@@ -260,37 +280,12 @@ public static function pro_upgrade_banner( $donate = true ) {
260280 ?>
261281 <div id="pro-upgrade-banner">
262282 <div class="inside">
263- <p><a href="https://webberzone.com/plugins/better-search/pro/" target="_blank"><img src="
264- <?php
265- echo esc_url ( BETTER_SEARCH_PLUGIN_URL . 'includes/admin/images/better-search-pro-banner.png ' );
266- ?>
267- " alt="
268- <?php
269- esc_html_e ( 'Better Search Pro - Coming soon. Sign up to find out more ' , 'better-search ' );
270- ?>
271- " width="300" height="300" style="max-width: 100%;" /></a></p>
272-
273- <?php
274- if ( $ donate ) {
275- ?>
276-
277- <p style="text-align:center;">
278- <?php
279- esc_html_e ( 'OR ' );
280- ?>
281- </p>
282- <p><a href="https://wzn.io/donate-bs" target="_blank"><img src="
283- <?php
284- echo esc_url ( BETTER_SEARCH_PLUGIN_URL . 'includes/admin/images/support.webp ' );
285- ?>
286- " alt="
287- <?php
288- esc_html_e ( 'Support the development - Send us a donation today. ' , 'better-search ' );
289- ?>
290- " width="300" height="169" style="max-width: 100%;" /></a></p>
291- <?php
292- }
293- ?>
283+ <p><a href="https://webberzone.com/plugins/better-search/pro/" target="_blank"><img src="<?php echo esc_url ( BETTER_SEARCH_PLUGIN_URL . 'includes/admin/images/better-search-pro-banner.png ' ); ?> " alt="<?php esc_html_e ( 'Better Search Pro - Coming soon. Sign up to find out more ' , 'better-search ' ); ?> " width="300" height="300" style="max-width: 100%;" /></a></p>
284+
285+ <?php if ( $ donate ) : ?>
286+ <p style="text-align:center;"><?php esc_html_e ( 'OR ' ); ?> </p>
287+ <p><a href="https://wzn.io/donate-bs" target="_blank"><img src="<?php echo esc_url ( BETTER_SEARCH_PLUGIN_URL . 'includes/admin/images/support.webp ' ); ?> " alt="<?php esc_html_e ( 'Support the development - Send us a donation today. ' , 'better-search ' ); ?> " width="300" height="169" style="max-width: 100%;" /></a></p>
288+ <?php endif ; ?>
294289 </div>
295290 </div>
296291 <?php
0 commit comments