constants(); self::$instance->load_textdomain(); if ( !self::$instance->check_requirements() ) { return; } self::$instance->autoload(); $setup = new \DgoraWcas\Setup; $setup->init(); self::$instance->settings = new \DgoraWcas\Settings; $engine = self::$instance->engine = self::$instance->settings->get_opt('search_engine', 'native'); self::$instance->hooks(); self::$instance->multilingual = new \DgoraWcas\Multilingual; // Search engine switch($engine){ case 'native': new \DgoraWcas\Engines\WordPressNative\Search; new \DgoraWcas\Engines\WordPressNative\DetailsBox; break; } new \DgoraWcas\Personalization; new \DgoraWcas\Scripts; new \DgoraWcas\Integrations\WpTao; \DgoraWcas\Shortcode::register(); if(is_admin()) { \DgoraWcas\Admin\Install::maybe_install(); new \DgoraWcas\Admin\AdminMenu; new \DgoraWcas\Admin\Promo\FeedbackNotice; } self::$instance->backwardCompatibility = new \DgoraWcas\BackwardCompatibility; } self::$instance->tnow = time(); return self::$instance; } /** * Constructor Function */ private function __construct() { self::$instance = $this; } /** * Check requirements */ private function check_requirements() { if ( version_compare( PHP_VERSION, '5.5.0' ) < 0 ) { if(version_compare( PHP_VERSION, '5.3.0' ) < 0){ add_action( 'admin_notices', array( $this, 'admin_notice_req_php_53' ) ); return false; }else{ add_action( 'admin_notices', array( $this, 'admin_notice_req_php_55' ) ); } } if ( !class_exists('WooCommerce') || !class_exists('WC_AJAX')) { add_action( 'admin_notices', array( $this, 'admin_notice_no_woocommerce' ) ); return false; } return true; } /** * Notice: PHP version less than 5.3 * @return void */ public function admin_notice_req_php_53() { ?>

AJAX Search for WooCommerce: You need PHP version at least 5.3 to run this plugin. You are currently using PHP version ', 'ajax-search-for-woocommerce'); echo PHP_VERSION . '.'; ?>

id) || ($screen->id !== 'dashboard' && $screen->id !== 'plugins')){ return; } if(!empty($_GET['dgwt-wcas-php55-notice']) && $_GET['dgwt-wcas-php55-notice'] === 'dismiss'){ set_transient('dgwt-wcas-php55-notice-dismiss', '1', (60*60*24*7)); } if(!get_transient('dgwt-wcas-php55-notice-dismiss')) { ?>

AJAX Search for WooCommerce:
Your PHP version %s will not longer supported in the next plugin releases.", 'ajax-search-for-woocommerce'), PHP_VERSION); _e(' You have to update your PHP version to least 5.5 (recommended 7.2 or greater).', 'ajax-search-for-woocommerce'); echo '
'; _e("If you cannot upgrade your PHP version yourself, you can send an email to your host.", 'ajax-search-for-woocommerce'); echo '

'; echo '' . __('If you do not upgrade the php version, the next plugin release will not work!', 'ajax-search-for-woocommerce') . ''; echo '
'; echo '
'; echo '' . __('Remind me again in week.', 'ajax-search-for-woocommerce') . ''; ?>

AJAX Search for WooCommerce is enabled but not effective. It requires %s in order to work.', 'ajax-search-for-woocommerce' ), 'WooCommerce'); ?>

define( 'DGWT_WCAS_VERSION', $plugin_data['Version'] ); $this->define( 'DGWT_WCAS_NAME', 'AJAX Search for WooCommerce' ); $this->define( 'DGWT_WCAS_FILE', __FILE__ ); $this->define( 'DGWT_WCAS_DIR', plugin_dir_path( __FILE__ ) ); $this->define( 'DGWT_WCAS_URL', plugin_dir_url( __FILE__ ) ); $this->define( 'DGWT_WCAS_SETTINGS_KEY', 'dgwt_wcas_settings' ); $this->define( 'DGWT_WCAS_SEARCH_ACTION', 'dgwt_wcas_ajax_search' ); $this->define( 'DGWT_WCAS_RESULT_DETAILS_ACTION', 'dgwt_wcas_result_details' ); $this->define( 'DGWT_WCAS_WOO_PRODUCT_POST_TYPE', 'product' ); $this->define( 'DGWT_WCAS_WOO_PRODUCT_CATEGORY', 'product_cat' ); $this->define( 'DGWT_WCAS_WOO_PRODUCT_TAG', 'product_tag' ); $this->define( 'DGWT_WCAS_WC_AJAX_ENDPOINT', true ); $this->define( 'DGWT_WCAS_DEBUG', false ); } /** * Define constant if not already set * @param string $name * @param string|bool $value */ private function define( $name, $value ) { if ( !defined( $name ) ) { define( $name, $value ); } } /** * PSR-4 autoload */ public function autoload() { if(file_exists(DGWT_WCAS_DIR . 'vendor/autoload.php')){ require_once DGWT_WCAS_DIR . 'vendor/autoload.php'; } require_once DGWT_WCAS_DIR . 'widget.php'; // @TODO Storefront integrations. Create tis as a option //require_once DGWT_WCAS_DIR . 'includes/Integrations/Storefront.php'; } /** * Actions and filters */ private function hooks() { add_action( 'admin_init', array( $this, 'admin_scripts' ), 8 ); } /* * Enqueue admin sripts */ public function admin_scripts() { // Register CSS wp_register_style( 'dgwt-wcas-admin-style', DGWT_WCAS_URL . 'assets/css/admin-style.css', array(), DGWT_WCAS_VERSION ); // Register JS $min = !DGWT_WCAS_DEBUG ? '.min' : ''; wp_register_script( 'dgwt-wcas-admin-js', DGWT_WCAS_URL . 'assets/js/admin' . $min . '.js', array( 'jquery' ), DGWT_WCAS_VERSION ); if ( \DgoraWcas\Helpers::isSettingsPage() ) { // Enqueue CSS wp_enqueue_style( array( 'dgwt-wcas-admin-style', 'wp-color-picker' ) ); wp_enqueue_script( 'dgwt-wcas-admin-js' ); wp_enqueue_script( 'wp-color-picker' ); } } /* * Register text domain */ private function load_textdomain() { $lang_dir = dirname( plugin_basename( DGWT_WCAS_FILE ) ) . '/languages/'; load_plugin_textdomain( 'ajax-search-for-woocommerce', false, $lang_dir ); } } } // Init the plugin function DGWT_WCAS() { return DGWT_WC_Ajax_Search::get_instance(); } add_action( 'plugins_loaded', 'DGWT_WCAS' );