constants(); self::$instance->loadTextdomain(); if ( !self::$instance->checkRequirements() ) { return; } self::$instance->systemHooks(); self::$instance->autoload(); self::$instance->setup = new \DgoraWcas\Setup(); self::$instance->setup->init(); self::$instance->settings = new \DgoraWcas\Settings(); self::$instance->hooks(); new \DgoraWcas\Integrations\Plugins\PluginsCompatibility(); self::$instance->multilingual = new \DgoraWcas\Multilingual(); self::$instance->nativeSearch = new \DgoraWcas\Engines\WordPressNative\Search(); // @TODO Temporary always use native WordPress DetailsBox engine. // Replace with details.php and shortinit in future releases new \DgoraWcas\Engines\WordPressNative\DetailsBox(); self::$instance->personalization = new \DgoraWcas\Personalization(); new \DgoraWcas\Scripts(); $embeddingViaMenu = new \DgoraWcas\EmbeddingViaMenu(); $embeddingViaMenu->init(); self::$instance->themeCompatibility = new \DgoraWcas\Integrations\Themes\ThemesCompatibility(); self::$instance->brands = new \DgoraWcas\Integrations\Brands(); self::$instance->brands->init(); \DgoraWcas\Shortcode::register(); if ( is_admin() ) { \DgoraWcas\Admin\Install::maybeInstall(); new \DgoraWcas\Admin\AdminMenu(); new \DgoraWcas\Admin\Promo\FeedbackNotice(); new \DgoraWcas\Admin\Promo\Upgrade(); new \DgoraWcas\Admin\Troubleshooting(); } if ( is_admin() || wp_doing_cron() ) { $analytics = new \DgoraWcas\Analytics\Analytics(); $analytics->init(); } new \DgoraWcas\Integrations\Solver(); global $wp_version ; if ( version_compare( $wp_version, '5.9' ) >= 0 ) { $blocks = new \DgoraWcas\Blocks(); $blocks->init(); } } self::$instance->tnow = time(); return self::$instance; } /** * Constructor Function */ private function __construct() { self::$instance = $this; } /** * Uninstall, Activate, Deactivate hooks * * @return void */ private function systemHooks() { register_deactivation_hook( __FILE__, function () { } ); } /** * Check requirements * * @return bool */ private function checkRequirements() { if ( version_compare( PHP_VERSION, '7.0' ) < 0 ) { add_action( 'admin_notices', array( $this, 'adminNoticeReqPhp70' ) ); return false; } if ( !class_exists( 'WooCommerce' ) || !class_exists( 'WC_AJAX' ) ) { add_action( 'admin_notices', array( $this, 'adminNoticeNoWoocommerce' ) ); return false; } if ( !file_exists( DGWT_WCAS_DIR . 'vendor/autoload.php' ) ) { add_action( 'admin_notices', array( $this, 'adminNoticeNoVendor' ) ); return false; } return true; } /** * Notice: Minimum required PHP version is 7.0 * * @return void */ public function adminNoticeReqPhp70() { if ( defined( 'DISABLE_NAG_NOTICES' ) && DISABLE_NAG_NOTICES ) { return; } ?>

' . DGWT_WCAS_NAME . '', PHP_VERSION ); ?>

' . DGWT_WCAS_FULL_NAME . '', 'WooCommerce' ); ?>

' . DGWT_WCAS_FULL_NAME . '' ); ?>

'Version', ), 'plugin' ); $this->define( 'DGWT_WCAS_NAME', 'FiboSearch' ); $this->define( 'DGWT_WCAS_FULL_NAME', 'FiboSearch - AJAX Search for WooCommerce' ); $this->define( 'DGWT_WCAS_VERSION', $v['Version'] ); $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_GET_PRICES_ACTION', 'dgwt_wcas_get_prices' ); $this->define( 'DGWT_WCAS_WC_AJAX_ENDPOINT', true ); } /** * Define constant if not already set * * @param string $name * @param string|bool $value * * @return void */ private function define( $name, $value ) { if ( !defined( $name ) ) { define( $name, $value ); } } /** * PSR-4 autoload * * @return void */ public function autoload() { require_once DGWT_WCAS_DIR . 'vendor/autoload.php'; require_once DGWT_WCAS_DIR . 'widget.php'; } /** * Actions and filters * * @return void */ private function hooks() { add_action( 'admin_init', array( $this, 'adminScripts' ), 8 ); } /** * Enqueue admin sripts * * @return void */ public function adminScripts() { $min = ( SCRIPT_DEBUG ? '' : '.min' ); // Register CSS wp_register_style( 'dgwt-wcas-admin-style', DGWT_WCAS_URL . 'assets/css/admin-style.css', array(), DGWT_WCAS_VERSION ); // Register front styles for block editor wp_register_style( 'dgwt-wcas-style', apply_filters( 'dgwt/wcas/scripts/css_style_url', DGWT_WCAS_URL . 'assets/css/style' . $min . '.css' ), array(), DGWT_WCAS_VERSION ); // Register JS wp_register_script( 'dgwt-wcas-admin-js', DGWT_WCAS_URL . 'assets/js/admin' . $min . '.js', array( 'jquery', 'wp-url' ), DGWT_WCAS_VERSION ); if ( \DgoraWcas\Helpers::isSettingsPage() ) { $localize = array( 'adminurl' => admin_url( 'admin-ajax.php' ), 'labels' => \DgoraWcas\Helpers::getLabels(), 'adminLabels' => array( 'preview' => __( 'No interaction! This is only a preview.', 'ajax-search-for-woocommerce' ), ), 'nonces' => array( 'build_index' => wp_create_nonce( 'dgwt_wcas_build_index' ), 'stop_build_index' => wp_create_nonce( 'dgwt_wcas_stop_build_index' ), 'build_index_heartbeat' => wp_create_nonce( 'dgwt_wcas_build_index_heartbeat' ), 'advanced_options_switch' => wp_create_nonce( 'dgwt_wcas_advanced_options_switch' ), ), 'images' => array( 'admin_preloader_url' => DGWT_WCAS_URL . 'assets/img/preloader.gif', ), ); $localize = apply_filters( 'dgwt/wcas/scripts/admin/localize', $localize ); wp_localize_script( 'dgwt-wcas-admin-js', 'dgwt_wcas', $localize ); // Enqueue CSS wp_enqueue_style( 'dgwt-wcas-admin-style' ); if ( !dgoraAsfwFs()->is_activation_mode() ) { add_thickbox(); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'dgwt-wcas-admin-js' ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'dgwt-wcas-admin-popper-js', DGWT_WCAS_URL . 'assets/js/popper.min.js', array( 'jquery' ), DGWT_WCAS_VERSION ); wp_enqueue_script( 'dgwt-wcas-admin-tooltip-js', DGWT_WCAS_URL . 'assets/js/tooltip.min.js', array( 'jquery' ), DGWT_WCAS_VERSION ); wp_enqueue_style( 'dgwt-wcas-style', apply_filters( 'dgwt/wcas/scripts/css_style_url', DGWT_WCAS_URL . 'assets/css/style' . $min . '.css' ), array(), DGWT_WCAS_VERSION ); } } if ( \DgoraWcas\Helpers::isCheckoutPage() ) { wp_enqueue_style( 'dgwt-wcas-admin-style' ); } if ( \DgoraWcas\Helpers::isDebugPage() ) { wp_enqueue_style( 'dgwt-wcas-admin-style' ); } } /** * Register text domain * * @return void */ private function loadTextdomain() { $lang_dir = dirname( plugin_basename( DGWT_WCAS_FILE ) ) . '/languages/'; load_plugin_textdomain( 'ajax-search-for-woocommerce', false, $lang_dir ); } /** * @see \DgoraWcas\Search */ public function searchPosts( $phrase, $args = array() ) { if ( is_null( $this->search ) ) { $this->search = new \DgoraWcas\Search(); } return $this->search->searchPosts( $phrase, $args ); } } // Init the plugin function DGWT_WCAS() { return DGWT_WC_Ajax_Search::getInstance(); } add_action( 'plugins_loaded', 'DGWT_WCAS', 15 ); }