/** * Set up the class, including it's hooks & filters, when the file is loaded. * * @since 1.0 **/ public static function init() { // Register our custom subscription order type after WC_Post_types::register_post_types() add_action('init', __CLASS__ . '::register_order_types', 6); // Register our custom subscription order statuses before WC_Post_types::register_post_status() add_action('init', __CLASS__ . '::register_post_status', 9); add_action('admin_init', __CLASS__ . '::maybe_activate_woocommerce_subscriptions'); register_deactivation_hook(__FILE__, __CLASS__ . '::deactivate_woocommerce_subscriptions'); // Override the WC default "Add to Cart" text to "Sign Up Now" (in various places/templates) add_filter('woocommerce_order_button_text', __CLASS__ . '::order_button_text'); add_action('woocommerce_subscription_add_to_cart', __CLASS__ . '::subscription_add_to_cart', 30); add_action('wcopc_subscription_add_to_cart', __CLASS__ . '::wcopc_subscription_add_to_cart'); // One Page Checkout compatibility // Ensure a subscription is never in the cart with products add_filter('woocommerce_add_to_cart_validation', __CLASS__ . '::maybe_empty_cart', 10, 3); // Enqueue front-end styles add_filter('woocommerce_enqueue_styles', __CLASS__ . '::enqueue_styles', 10, 1); // Display Subscriptions on a User's account page add_action('woocommerce_before_my_account', __CLASS__ . '::get_my_subscriptions_template'); // Load translation files add_action('plugins_loaded', __CLASS__ . '::load_plugin_textdomain'); // Load dependent files add_action('plugins_loaded', __CLASS__ . '::load_dependant_classes'); // Attach hooks which depend on WooCommerce constants add_action('plugins_loaded', __CLASS__ . '::attach_dependant_hooks'); // WooCommerce 2.0 Notice add_action('admin_notices', __CLASS__ . '::woocommerce_dependancy_notice'); // Staging site or site migration notice add_action('admin_notices', __CLASS__ . '::woocommerce_site_change_notice'); // Add the "Settings | Documentation" links on the Plugins administration screen add_filter('plugin_action_links_' . plugin_basename(__FILE__), __CLASS__ . '::action_links'); add_filter('action_scheduler_queue_runner_batch_size', __CLASS__ . '::action_scheduler_multisite_batch_size'); add_action('in_plugin_update_message-' . plugin_basename(__FILE__), __CLASS__ . '::update_notice', 10, 2); $scheduler_class = apply_filters('woocommerce_subscriptions_scheduler', 'WCS_Action_Scheduler'); self::$cache = WCS_Cache_Manager::get_instance(); self::$scheduler = new $scheduler_class(); }