/** * Constructor for the class */ function __construct() { // register existing modules $this->modules = array('quick-view' => array('load_on' => 'woocommerce_before_shop_loop_item', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-quick-view.php'), 'class' => 'Cherry_WC_Quick_View', 'ajax' => array('action' => 'cherry_wc_quick_view', 'callback' => 'ajax_callback')), 'video-tab' => array('load_on' => 'init', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-product-video-tab.php'), 'class' => 'Cherry_WC_Package_Product_Video', 'ajax' => false), 'yith-addons' => array('load_on' => 'after_setup_theme', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-yith-addons.php'), 'class' => 'Cherry_WC_YITH_Addons', 'ajax' => false), 'account-dropdown' => array('load_on' => 'after_setup_theme', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-account-dropdown.php'), 'class' => 'Cherry_WC_Account_Dropdown', 'ajax' => false), 'cart-dropdown' => array('load_on' => 'after_setup_theme', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-cart-dropdown.php'), 'class' => 'Cherry_WC_Cart_Dropdown', 'ajax' => false), 'product-gallery' => array('load_on' => 'woocommerce_before_single_product', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-single-product-gallery.php'), 'class' => 'Cherry_WC_Single_Product_Gallery', 'ajax' => false), 'product-sharing' => array('load_on' => 'woocommerce_before_single_product', 'file' => cherry_wc_package()->plugin_dir('modules/class-cherry-wc-product-sharing.php'), 'class' => 'Cherry_WC_Product_Sharing', 'ajax' => false)); $this->add_ajax_handlers(); $this->load_modules(); }
} /** * Returns the instance. * * @since 1.0.0 * @return object */ public static function get_instance() { // If the single instance hasn't been set, set it now. if (null == self::$instance) { self::$instance = new self(); } return self::$instance; } } /** * Get base plugin class instance * * @since 1.0.0 * @return object */ function cherry_wc_package() { return Cherry_Woocommerce_Package::get_instance(); } /** * Create plugin instance */ cherry_wc_package(); }
/** * Load WooCommerce specific dynamic CSS * * @since 1.0.0 * @return void */ public function add_dynamic_styles() { include cherry_wc_package()->plugin_dir('public/assets/css/dynamic-style.css'); }
/** * Register new static by name * * @since 1.0.0 * @param string $filename static filname to register. * @return void */ public function register_static($filename = null) { if (!$filename) { return; } $static_file = apply_filters('cherry_wc_static_' . $filename, $filename); if (defined('CHILD_DIR')) { $child_dir = CHILD_DIR; } else { $child_dir = get_stylesheet_directory(); } $static_file_path = preg_replace('#/+#', '/', trailingslashit($child_dir) . $static_file); // If file found in child theme - include it and break function. if (file_exists($static_file_path)) { require_once $static_file_path; return; } // If file was not found in child theme - search it in parent. if (defined('PARENT_DIR')) { $parent_dir = PARENT_DIR; } else { $parent_dir = get_template_directory(); } $static_file_path = preg_replace('#/+#', '/', trailingslashit($parent_dir) . $static_file); if (file_exists($static_file_path)) { require_once $static_file_path; return; } require_once cherry_wc_package()->plugin_dir('init/statics/' . $static_file); }
/** * Prepare template data to replace * * @since 1.0.0 * @param array $atts output attributes. * @return object */ public function setup_template_data($atts) { require_once cherry_wc_package()->plugin_dir('public/includes/class-cherry-wc-template-callbacks.php'); $callbacks = new Cherry_WC_Template_Callbacks($atts); $data = array('cat_image' => array($callbacks, 'get_cat_image'), 'cat_name' => array($callbacks, 'get_cat_name'), 'cat_desc' => array($callbacks, 'get_cat_desc'), 'cat_count' => array($callbacks, 'get_cat_count'), 'cat_url' => array($callbacks, 'get_cat_url')); $this->macros_data = apply_filters('cherry_woocommerce_data_callbacks', $data, $atts); return $callbacks; }