예제 #1
0
 function __construct()
 {
     self::$dir = trailingslashit(dirname(__FILE__));
     self::$path = trailingslashit(plugin_dir_path(__FILE__));
     self::$url_path = plugins_url(trailingslashit(basename(self::$dir)));
     self::$settings['permalink_structure'] = get_option('permalink_structure');
     self::$settings['wc_settings_prdctfltr_disable_scripts'] = get_option('wc_settings_prdctfltr_disable_scripts', array());
     self::$settings['wc_settings_prdctfltr_ajax_js'] = get_option('wc_settings_prdctfltr_ajax_js', '');
     self::$settings['wc_settings_prdctfltr_custom_tax'] = get_option('wc_settings_prdctfltr_custom_tax', 'no');
     self::$settings['wc_settings_prdctfltr_enable'] = get_option('wc_settings_prdctfltr_enable', 'yes');
     self::$settings['wc_settings_prdctfltr_default_templates'] = get_option('wc_settings_prdctfltr_default_templates', 'no');
     self::$settings['wc_settings_prdctfltr_force_categories'] = get_option('wc_settings_prdctfltr_force_categories', 'no');
     self::$settings['wc_settings_prdctfltr_instock'] = get_option('wc_settings_prdctfltr_instock', 'no');
     self::$settings['wc_settings_prdctfltr_use_ajax'] = get_option('wc_settings_prdctfltr_use_ajax', 'no');
     self::$settings['wc_settings_prdctfltr_ajax_class'] = get_option('wc_settings_prdctfltr_ajax_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_product_class'] = get_option('wc_settings_prdctfltr_ajax_product_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_columns'] = get_option('wc_settings_prdctfltr_ajax_columns', '4');
     self::$settings['wc_settings_prdctfltr_ajax_rows'] = get_option('wc_settings_prdctfltr_ajax_rows', '4');
     self::$settings['wc_settings_prdctfltr_force_redirects'] = get_option('wc_settings_prdctfltr_force_redirects', 'no');
     self::$settings['wc_settings_prdctfltr_force_emptyshop'] = get_option('wc_settings_prdctfltr_force_emptyshop', 'no');
     self::$settings['wc_settings']['product_taxonomies'] = get_object_taxonomies('product');
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'yes') {
         add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter'), 10, 3);
         add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter'), 10, 3);
     }
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'no' && self::$settings['wc_settings_prdctfltr_default_templates'] == 'yes') {
         add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter_blank'), 10, 3);
         add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter_blank'), 10, 3);
     }
     if (!is_admin() && self::$settings['wc_settings_prdctfltr_force_categories'] == 'no') {
         if (self::$settings['wc_settings_prdctfltr_force_redirects'] !== 'yes' && self::$settings['permalink_structure'] !== '') {
             add_action('template_redirect', array(&$this, 'prdctfltr_redirect'), 999);
         }
         if (self::$settings['wc_settings_prdctfltr_force_emptyshop'] !== 'yes') {
             add_action('template_redirect', array(&$this, 'prdctfltr_redirect_empty_shop'), 998);
         }
     }
     if (self::$settings['wc_settings_prdctfltr_use_ajax'] == 'yes') {
         add_filter('woocommerce_pagination_args', array(&$this, 'prdctfltr_pagination_filter'), 999, 1);
     }
     add_action('init', array(&$this, 'prdctfltr_text_domain'), 1000);
     add_action('wp_enqueue_scripts', array(&$this, 'prdctfltr_scripts'));
     add_filter('pre_get_posts', array(&$this, 'prdctfltr_wc_query'), 999999, 1);
     add_action('prdctfltr_output', array(&$this, 'prdctfltr_get_filter'), 10);
 }
예제 #2
0
 function __construct()
 {
     global $prdctfltr_global;
     self::$dir = trailingslashit(dirname(__FILE__));
     self::$path = trailingslashit(plugin_dir_path(__FILE__));
     self::$url_path = plugins_url(trailingslashit(basename(self::$dir)));
     self::$settings['permalink_structure'] = get_option('permalink_structure');
     self::$settings['wc_settings_prdctfltr_disable_scripts'] = get_option('wc_settings_prdctfltr_disable_scripts', array());
     self::$settings['wc_settings_prdctfltr_ajax_js'] = get_option('wc_settings_prdctfltr_ajax_js', '');
     self::$settings['wc_settings_prdctfltr_custom_tax'] = get_option('wc_settings_prdctfltr_custom_tax', 'no');
     self::$settings['wc_settings_prdctfltr_enable'] = get_option('wc_settings_prdctfltr_enable', 'yes');
     self::$settings['wc_settings_prdctfltr_enable_overrides'] = get_option('wc_settings_prdctfltr_enable_overrides', array('orderby', 'result-count'));
     foreach (self::$settings['wc_settings_prdctfltr_enable_overrides'] as $k => $v) {
         self::$settings['wc_settings_prdctfltr_enable_overrides'][$k] = 'loop/' . $v . '.php';
     }
     self::$settings['wc_settings_prdctfltr_enable_action'] = get_option('wc_settings_prdctfltr_enable_action', '');
     self::$settings['wc_settings_prdctfltr_default_templates'] = get_option('wc_settings_prdctfltr_default_templates', 'no');
     self::$settings['wc_settings_prdctfltr_force_categories'] = get_option('wc_settings_prdctfltr_force_categories', 'no');
     self::$settings['wc_settings_prdctfltr_instock'] = get_option('wc_settings_prdctfltr_instock', 'no');
     self::$settings['wc_settings_prdctfltr_use_ajax'] = get_option('wc_settings_prdctfltr_use_ajax', 'no');
     self::$settings['wc_settings_prdctfltr_ajax_class'] = get_option('wc_settings_prdctfltr_ajax_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_category_class'] = get_option('wc_settings_prdctfltr_ajax_category_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_product_class'] = get_option('wc_settings_prdctfltr_ajax_product_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_pagination_class'] = get_option('wc_settings_prdctfltr_ajax_pagination_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_count_class'] = get_option('wc_settings_prdctfltr_ajax_count_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_orderby_class'] = get_option('wc_settings_prdctfltr_ajax_orderby_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_columns'] = get_option('wc_settings_prdctfltr_ajax_columns', '4');
     self::$settings['wc_settings_prdctfltr_ajax_rows'] = get_option('wc_settings_prdctfltr_ajax_rows', '4');
     self::$settings['wc_settings_prdctfltr_force_redirects'] = get_option('wc_settings_prdctfltr_force_redirects', 'no');
     self::$settings['wc_settings_prdctfltr_force_emptyshop'] = get_option('wc_settings_prdctfltr_force_emptyshop', 'no');
     self::$settings['wc_settings_prdctfltr_force_search'] = get_option('wc_settings_prdctfltr_force_search', 'no');
     self::$settings['wc_settings_prdctfltr_use_analytics'] = get_option('wc_settings_prdctfltr_use_analytics', 'no');
     self::$settings['wc_settings_prdctfltr_shop_page_override'] = get_option('wc_settings_prdctfltr_shop_page_override', '');
     self::$settings['wc_settings_prdctfltr_clearall'] = get_option('wc_settings_prdctfltr_clearall', 'all');
     self::$settings['wc_settings_prdctfltr_showon_product_cat'] = get_option('wc_settings_prdctfltr_showon_product_cat', array());
     self::$settings['wc_settings_prdctfltr_hideempty'] = get_option('wc_settings_prdctfltr_hideempty', 'no') == 'yes' ? 1 : 0;
     self::$settings['wc_settings_prdctfltr_pagination_type'] = get_option('wc_settings_prdctfltr_pagination_type', 'default');
     self::$settings['wc_settings_prdctfltr_remove_single_redirect'] = get_option('wc_settings_prdctfltr_remove_single_redirect', 'yes');
     self::$settings['wc_settings_prdctfltr_product_animation'] = get_option('wc_settings_prdctfltr_product_animation', 'default');
     self::$settings['wc_settings_prdctfltr_filtering_mode'] = get_option('wc_settings_prdctfltr_filtering_mode', 'simple');
     self::$settings['wc_settings_prdctfltr_after_ajax_scroll'] = get_option('wc_settings_prdctfltr_after_ajax_scroll', 'products');
     self::$settings['wc_settings']['product_taxonomies'] = get_object_taxonomies('product');
     add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter'), 10, 3);
     add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter'), 10, 3);
     if (in_array(self::$settings['wc_settings_prdctfltr_enable'], array('no', 'action')) && self::$settings['wc_settings_prdctfltr_default_templates'] == 'yes') {
         add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter_blank'), 10, 3);
         add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter_blank'), 10, 3);
     }
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'action' && self::$settings['wc_settings_prdctfltr_enable_action'] !== '') {
         $curr_action = explode(':', self::$settings['wc_settings_prdctfltr_enable_action']);
         if (isset($curr_action[1])) {
             $curr_action[1] = floatval($curr_action[1]);
         } else {
             $curr_action[1] = 10;
         }
         add_filter($curr_action[0], array(&$this, 'prdctfltr_get_filter'), $curr_action[1]);
     }
     add_filter('body_class', array($this, 'add_body_class'));
     if (self::$settings['wc_settings_prdctfltr_use_ajax'] == 'yes') {
         add_filter('woocommerce_pagination_args', array(&$this, 'prdctfltr_pagination_filter'), 999, 1);
     }
     add_action('init', array(&$this, 'prdctfltr_text_domain'), 1000);
     add_action('wp_enqueue_scripts', array(&$this, 'prdctfltr_scripts'));
     add_action('wp_footer', array(&$this, 'localize_scripts'));
     add_filter('pre_get_posts', array(&$this, 'prdctfltr_wc_query'), 999999, 1);
     add_filter('parse_tax_query', array(&$this, 'prdctfltr_wc_tax'), 999999, 1);
     add_action('prdctfltr_filter_after', array(&$this, 'prdctfltr_add_css'));
     if (self::$settings['wc_settings_prdctfltr_filtering_mode'] == 'indepth' && self::$settings['permalink_structure'] !== '') {
         add_filter('redirect_canonical', array(&$this, 'redirect_double_taxonomy'), 999, 2);
     }
     if (!is_admin()) {
         add_filter('woocommerce_shortcode_products_query', 'WC_Prdctfltr::add_wc_shortcode_filter', 999999);
         if (self::$settings['permalink_structure'] !== '') {
             if (self::$settings['wc_settings_prdctfltr_force_redirects'] !== 'yes' && self::$settings['permalink_structure'] !== '') {
                 add_action('template_redirect', array(&$this, 'prdctfltr_redirect'), 999);
             }
             if (self::$settings['wc_settings_prdctfltr_force_emptyshop'] !== 'yes') {
                 add_action('template_redirect', array(&$this, 'prdctfltr_redirect_empty_shop'), 998);
             }
         }
     }
     if (self::$settings['wc_settings_prdctfltr_remove_single_redirect'] == 'yes') {
         add_filter('woocommerce_redirect_single_search_result', array(&$this, 'remove_single_redirect'), 999);
     }
     if (self::$settings['wc_settings_prdctfltr_use_analytics'] == 'yes') {
         add_action('wp_ajax_nopriv_prdctfltr_analytics', array(&$this, 'prdctfltr_analytics'));
         add_action('wp_ajax_prdctfltr_analytics', array(&$this, 'prdctfltr_analytics'));
     }
     add_action('prdctfltr_output', array(&$this, 'prdctfltr_get_filter'), 10);
     register_activation_hook(__FILE__, array(&$this, 'activate'));
     //add_action( 'wp_footer', array( &$this, 'debug' ) );
 }
예제 #3
0
파일: prdctfltr.php 프로젝트: hikaram/wee
 function __construct()
 {
     self::$dir = trailingslashit(dirname(__FILE__));
     self::$path = trailingslashit(plugin_dir_path(__FILE__));
     self::$url_path = plugins_url(trailingslashit(basename(self::$dir)));
     self::$settings['permalink_structure'] = get_option('permalink_structure');
     self::$settings['wc_settings_prdctfltr_disable_scripts'] = get_option('wc_settings_prdctfltr_disable_scripts', array());
     self::$settings['wc_settings_prdctfltr_ajax_js'] = get_option('wc_settings_prdctfltr_ajax_js', '');
     self::$settings['wc_settings_prdctfltr_custom_tax'] = get_option('wc_settings_prdctfltr_custom_tax', 'no');
     self::$settings['wc_settings_prdctfltr_enable'] = get_option('wc_settings_prdctfltr_enable', 'yes');
     self::$settings['wc_settings_prdctfltr_enable_overrides'] = get_option('wc_settings_prdctfltr_enable_overrides', array('orderby', 'result-count'));
     foreach (self::$settings['wc_settings_prdctfltr_enable_overrides'] as $k => $v) {
         self::$settings['wc_settings_prdctfltr_enable_overrides'][$k] = 'loop/' . $v . '.php';
     }
     self::$settings['wc_settings_prdctfltr_enable_action'] = get_option('wc_settings_prdctfltr_enable_action', '');
     self::$settings['wc_settings_prdctfltr_default_templates'] = get_option('wc_settings_prdctfltr_default_templates', 'no');
     self::$settings['wc_settings_prdctfltr_force_categories'] = get_option('wc_settings_prdctfltr_force_categories', 'no');
     self::$settings['wc_settings_prdctfltr_instock'] = get_option('wc_settings_prdctfltr_instock', 'no');
     self::$settings['wc_settings_prdctfltr_use_ajax'] = get_option('wc_settings_prdctfltr_use_ajax', 'no');
     self::$settings['wc_settings_prdctfltr_ajax_class'] = get_option('wc_settings_prdctfltr_ajax_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_category_class'] = get_option('wc_settings_prdctfltr_ajax_category_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_product_class'] = get_option('wc_settings_prdctfltr_ajax_product_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_pagination_class'] = get_option('wc_settings_prdctfltr_ajax_pagination_class', '');
     self::$settings['wc_settings_prdctfltr_ajax_columns'] = get_option('wc_settings_prdctfltr_ajax_columns', '4');
     self::$settings['wc_settings_prdctfltr_ajax_rows'] = get_option('wc_settings_prdctfltr_ajax_rows', '4');
     self::$settings['wc_settings_prdctfltr_force_redirects'] = get_option('wc_settings_prdctfltr_force_redirects', 'no');
     self::$settings['wc_settings_prdctfltr_force_emptyshop'] = get_option('wc_settings_prdctfltr_force_emptyshop', 'no');
     self::$settings['wc_settings_prdctfltr_use_analytics'] = get_option('wc_settings_prdctfltr_use_analytics', 'no');
     self::$settings['wc_settings_prdctfltr_shop_page_override'] = get_option('wc_settings_prdctfltr_shop_page_override', '');
     self::$settings['wc_settings']['product_taxonomies'] = get_object_taxonomies('product');
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'yes') {
         add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter'), 10, 3);
         add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter'), 10, 3);
     }
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'no' && self::$settings['wc_settings_prdctfltr_default_templates'] == 'yes') {
         add_filter('woocommerce_locate_template', array(&$this, 'prdctrfltr_add_loop_filter_blank'), 10, 3);
         add_filter('wc_get_template_part', array(&$this, 'prdctrfltr_add_filter_blank'), 10, 3);
     }
     if (self::$settings['wc_settings_prdctfltr_enable'] == 'action' && self::$settings['wc_settings_prdctfltr_enable_action'] !== '') {
         $curr_action = explode(':', self::$settings['wc_settings_prdctfltr_enable_action']);
         if (isset($curr_action[1])) {
             $curr_action[1] = floatval($curr_action[1]);
         } else {
             $curr_action[1] = 10;
         }
         add_filter($curr_action[0], array(&$this, 'prdctfltr_get_filter'), $curr_action[1]);
     }
     if (!is_admin() && self::$settings['wc_settings_prdctfltr_force_categories'] == 'no') {
         if (self::$settings['wc_settings_prdctfltr_force_redirects'] !== 'yes' && self::$settings['permalink_structure'] !== '') {
             add_action('template_redirect', array(&$this, 'prdctfltr_redirect'), 999);
         }
         if (self::$settings['wc_settings_prdctfltr_force_emptyshop'] !== 'yes') {
             add_action('template_redirect', array(&$this, 'prdctfltr_redirect_empty_shop'), 998);
         }
     }
     if (self::$settings['wc_settings_prdctfltr_use_ajax'] == 'yes') {
         add_filter('woocommerce_pagination_args', array(&$this, 'prdctfltr_pagination_filter'), 999, 1);
     }
     add_action('init', array(&$this, 'prdctfltr_text_domain'), 1000);
     add_action('wp_enqueue_scripts', array(&$this, 'prdctfltr_scripts'));
     add_filter('pre_get_posts', array(&$this, 'prdctfltr_wc_query'), 999999, 1);
     add_action('prdctfltr_filter_after', array(&$this, 'prdctfltr_add_css'));
     add_action('wp', array(&$this, 'prdctfltr_init'));
     if (self::$settings['wc_settings_prdctfltr_use_analytics'] == 'yes') {
         add_action('wp_ajax_nopriv_prdctfltr_analytics', array(&$this, 'prdctfltr_analytics'));
         add_action('wp_ajax_prdctfltr_analytics', array(&$this, 'prdctfltr_analytics'));
     }
     add_action('prdctfltr_output', array(&$this, 'prdctfltr_get_filter'), 10);
 }