0 ) { add_action( 'admin_notices', array( $this, 'display_wc_absence_warning' ) ); } return; } spl_autoload_register( array( $this, 'awf_autoloader' ) ); add_action( 'init', array( $this, 'load_textdomain' ) ); add_action( 'widgets_init', array( $this, 'register_widget' ) ); add_action( 'init', array( $this, 'register_shortcode' ) ); self::$excluded_taxonomies = array( 'product_type', 'product_visibility', 'product_shipping_class' ); self::$presets = get_option( 'awf_presets', array() ); if ( !is_array( self::$presets ) ) { self::$presets = array(); } self::$modules = array( 'taxonomy', 'search', 'price', 'stock', 'featured', 'rating', 'onsale', 'ppp' ); // @ToDo 'orderby' if ( is_admin() ) { if ( wp_doing_ajax() && isset( $_REQUEST['awf_front'] ) ) { add_action( 'wp_ajax_awf', array( $this, 'frontend_ajax_controller' ) ); add_action( 'wp_ajax_nopriv_awf', array( $this, 'frontend_ajax_controller' ) ); } else { self::$admin = A_W_F_admin::get_instance(); } } else { self::$front = A_W_F_frontend::get_instance(); self::$front->filters_manager = 'A_W_F_filter_frontend'; } } public static function get_instance() { if ( is_null( self::$instance ) ) { self::$instance = new self(); } return self::$instance; } public static function activate_plugin() { if ( !current_user_can( 'activate_plugins' ) ) { return; } $plugin = ( isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '' ); check_admin_referer( "activate-plugin_{$plugin}" ); if ( empty(get_option( 'awf_presets' )) ) { $presets = array( 1 => array( 'position' => 1, 'filters' => array(), 'associations' => array( 0 => 'shop-pages', ), 'overrides' => array(), ), ); update_option( 'awf_presets', $presets ); update_option( 'awf_preset_1_name', __( 'Default Preset', 'annasta-filters' ) ); } } public static function deactivate_plugin() { if ( !current_user_can( 'activate_plugins' ) ) { return; } require 'class-a-w-f-admin.php'; self::$admin = A_W_F_admin::get_instance(); self::$admin->clear_product_counts_cache(); } public static function uninstall_plugin() { if ( !current_user_can( 'activate_plugins' ) ) { return; } if ( empty(self::$admin) ) { require 'class-a-w-f-admin.php'; self::$admin = A_W_F_admin::get_instance(); } self::$admin->clear_product_counts_cache(); unregister_widget( 'A_W_F_widget' ); $all_options = wp_load_alloptions(); $awf_options = array( 'awf_version', 'awf_premium', 'awf_shortcode_pages', 'awf_force_products_display_on', 'awf_shop_columns', 'awf_redirect_search', 'awf_products_html_wrapper', 'awf_pretty_scrollbars', 'awf_ppp_default', 'awf_include_children_on', 'awf_cat_views_on', 'awf_presets', 'awf_custom_style' ); foreach ( $all_options as $name => $value ) { if ( 0 !== strpos( $name, 'awf_' ) ) { continue; } if ( stristr( $name, 'awf_preset_' ) || stristr( $name, 'awf_filter_' ) || substr( $name, -12 ) === '_pretty_name' || in_array( $name, $awf_options ) ) { delete_option( $name ); } } } public function display_wc_absence_warning() { echo '

', __( 'annasta Woocommerce Product Filters requires WooCommerce plugin to function properly. Please install WooCommerce online shop to use the annasta Woocommerce Product Filters plugin.', 'annasta-filters' ), '

' ; } public function load_textdomain() { load_plugin_textdomain( 'annasta-filters', false, plugin_basename( dirname( A_W_F_PLUGIN_FILE ) ) . '/languages' ); } public function frontend_ajax_controller() { self::$front = A_W_F_frontend::get_instance(); self::$front->ajax_controller(); } public function register_widget() { register_widget( 'A_W_F_widget' ); } function register_shortcode() { add_shortcode( 'annasta_filters', array( $this, 'filters_shortcode' ) ); } public function filters_shortcode( $atts ) { if ( !empty(self::$front) && !empty(self::$presets) ) { $sc_id = 'shortcode-' . self::$sc_id++; $filtered_atts = shortcode_atts( array( 'shortcode_id' => $sc_id, 'preset_id' => '', 'preset_name' => '', ), $atts ); if ( !empty($filtered_atts['preset_name']) ) { foreach ( self::$presets as $id => $data ) { $name = get_option( 'awf_preset_' . $id . '_name', '' ); if ( $name === $filtered_atts['preset_name'] ) { $filtered_atts['preset_id'] = $id; break; } } } $filtered_atts['preset_id'] = (int) $filtered_atts['preset_id']; if ( isset( self::$presets[$filtered_atts['preset_id']] ) ) { return self::$front->display_shortcode( $filtered_atts ); } } return ''; } private function awf_autoloader( $class ) { if ( 0 !== strpos( $class, 'A_W_F_' ) ) { return; } $class = strtolower( $class ); $path = A_W_F_PLUGIN_PATH . 'code/'; $file = 'class-' . str_replace( '_', '-', $class ) . '.php'; $file_path = $path . $file; if ( is_readable( $file_path ) ) { include $file_path; } } private final function __clone() { } // prevent cloning private final function __wakeup() { } // prevent serialization /** Helper Functions */ public static function format_print_r( $print ) { print "
";
            print_r( $print );
            print "
"; //A_W_F::format_print_r( self::$features_by_parent[0] ); //error_log( 'before' . print_r( $filters[$preset_id], true ) ); } } }