data['settings'] = get_option( 'aws_settings' ); add_filter( 'widget_text', 'do_shortcode' ); add_shortcode( 'aws_search_form', array( $this, 'markup' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 ); load_plugin_textdomain( 'aws', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' ); $this->includes(); add_action( 'init', array( $this, 'init' ), 0 ); add_filter( 'wcml_multi_currency_ajax_actions', array( $this, 'add_wpml_ajax_actions' ) ); if ( $this->get_settings('seamless') === 'true' ) { add_filter( 'get_search_form', array( $this, 'markup' ), 999999 ); add_filter( 'get_product_search_form', array( $this, 'markup' ), 999999 ); } } /** * Include required core files used in admin and on the frontend. */ public function includes() { include_once( 'includes/class-aws-helpers.php' ); include_once( 'includes/class-aws-versions.php' ); include_once( 'includes/class-aws-admin.php' ); include_once( 'includes/class-aws-cache.php' ); include_once( 'includes/class-aws-table.php' ); include_once( 'includes/class-aws-markup.php' ); include_once( 'includes/class-aws-search.php' ); include_once( 'includes/class-aws-search-page.php' ); include_once( 'includes/class-aws-order.php' ); include_once( 'includes/class-aws-integrations.php' ); include_once( 'includes/widget.php' ); } /* * Generate search box markup */ public function markup( $args = array() ) { $markup = new AWS_Markup(); return $markup->markup(); } /* * Sort products */ public function order( $products, $order_by ) { $order = new AWS_Order( $products, $order_by ); return $order->result(); } /* * Init plugin classes */ public function init() { $this->cache = AWS_Cache::factory(); } /* * Load assets for search form */ public function load_scripts() { wp_enqueue_style( 'aws-style', AWS_URL . '/assets/css/common.css', array(), AWS_VERSION ); wp_enqueue_script('aws-script', AWS_URL . '/assets/js/common.js', array('jquery'), AWS_VERSION, true); wp_localize_script('aws-script', 'aws_vars', array( 'sale' => __('Sale!', 'aws'), 'sku' => __('SKU', 'aws'), 'showmore' => $this->get_settings('show_more_text') ? AWS_Helpers::translate( 'show_more_text', stripslashes( $this->get_settings('show_more_text') ) ) : __('View all results', 'aws'), 'noresults' => $this->get_settings('not_found_text') ? AWS_Helpers::translate( 'not_found_text', stripslashes( $this->get_settings('not_found_text') ) ) : __('Nothing found', 'aws') )); } /* * Add settings link to plugins */ public function add_action_link( $links, $file ) { $plugin_base = plugin_basename( __FILE__ ); if ( $file == $plugin_base ) { $setting_link = ''.__( 'Settings', 'aws' ).''; array_unshift( $links, $setting_link ); $premium_link = ''.__( 'Get Premium', 'aws' ).''; array_unshift( $links, $premium_link ); } return $links; } /* * Get plugin settings */ public function get_settings( $name ) { $plugin_options = $this->data['settings']; $return_value = isset( $plugin_options[ $name ] ) ? $plugin_options[ $name ] : ''; return $return_value; } /* * Add ajax action to WPML plugin */ function add_wpml_ajax_actions( $actions ){ $actions[] = 'aws_action'; return $actions; } } endif; /** * Returns the main instance of AWS_Main * * @return AWS_Main */ function AWS() { return AWS_Main::instance(); } /* * Check if WooCommerce is active */ if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) { if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) { add_action( 'woocommerce_loaded', 'aws_init' ); } else { add_action( 'admin_notices', 'aws_install_woocommerce_admin_notice' ); } } /* * Check whether the plugin is active by checking the active_plugins list. */ function aws_is_plugin_active( $plugin ) { return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || aws_is_plugin_active_for_network( $plugin ); } /* * Check whether the plugin is active for the entire network */ function aws_is_plugin_active_for_network( $plugin ) { if ( !is_multisite() ) return false; $plugins = get_site_option( 'active_sitewide_plugins' ); if ( isset($plugins[$plugin]) ) return true; return false; } /* * Error notice if WooCommerce plugin is not active */ function aws_install_woocommerce_admin_notice() { ?>