/** * Initializes the plugin * * @since 1.0.0 * @return \WC_Order_Status_Manager */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); add_action('init', array($this, 'init')); // Make sure email template files are searched for in our plugin add_filter('woocommerce_locate_template', array($this, 'locate_template'), 20, 3); add_filter('woocommerce_locate_core_template', array($this, 'locate_template'), 20, 3); }
/** * Construct and initialize the main plugin class */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // register importers add_action('admin_init', array($this, 'admin_init')); // add the menu itme add_action('admin_menu', array($this, 'admin_menu')); add_action('admin_print_styles', array($this, 'admin_scripts')); }
/** * Initializes the plugin * * @since 1.0 */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // Hook for order status when payment is complete add_filter('woocommerce_payment_complete_order_status', array($this, 'handle_payment_complete_order_status'), 10, 2); // admin if (is_admin() && !defined('DOING_AJAX')) { // add general settings add_filter('woocommerce_general_settings', array($this, 'add_global_settings')); } }
/** * Initilize the plugin * * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, array('dependencies' => array('SimpleXML', 'dom'))); // Load the gateway add_action('sv_wc_framework_plugins_loaded', array($this, 'load_classes')); // add the 'my account' cc vault if on the My Account page add_action('woocommerce_after_my_account', array($this, 'account_cc')); // process our mini checkout form on the Pay Page for 3D Secure transactions add_action('wp_ajax_wc-realex-checkout', array($this, 'process_checkout')); add_action('wp_ajax_nopriv_wc-realex-checkout', array($this, 'process_checkout')); }
/** * Initializes the plugin * * @since 1.0.0 * @return \WC_Product_Reviews_Pro */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // Admin if (is_admin() && !defined('DOING_AJAX')) { // delay standard install so we can use get_comments() remove_action('wp_loaded', array($this, 'do_install')); add_action('admin_init', array($this, 'do_install')); } // Include required files $this->includes(); add_action('wp_update_comment_count', array($this, 'clear_transients')); add_filter('pre_option_woocommerce_enable_review_rating', array($this, 'filter_enable_review_rating')); // Points and Rewards compatability - ensure only allowed contibutions are counted towards earned review points add_filter('wc_points_rewards_review_post_comments_args', array($this, 'points_rewards_review_get_comments_args'), 10, 2); add_filter('wc_points_rewards_review_approve_comments_args', array($this, 'points_rewards_review_get_comments_args'), 10, 2); // Points and Rewards compatability - ensure points are only added for allowed contribution types add_filter('wc_points_rewards_pro_post_add_product_review_points', array($this, 'points_rewards_review_add_product_review_points'), 10, 2); add_filter('wc_points_rewards_pro_approve_add_product_review_points', array($this, 'points_rewards_review_add_product_review_points'), 10, 2); }
/** * Setup main plugin class * * @since 3.0 * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // load includes after WC is loaded add_action('sv_wc_framework_plugins_loaded', array($this, 'includes'), 11); // Subscriptions support if ($this->is_plugin_active('woocommerce-subscriptions.php')) { if (SV_WC_Plugin_Compatibility::is_wc_subscriptions_version_gte_2_0()) { // don't copy over FreshBooks invoice meta from the original order to the subscription (subscription objects should not have an invoice) add_filter('wcs_subscription_meta', array($this, 'subscriptions_remove_subscription_order_meta'), 10, 3); // don't copy over FreshBooks invoice meta to subscription object during upgrade from 1.5.x to 2.0 add_filter('wcs_upgrade_subscription_meta_to_copy', array($this, 'subscriptions_remove_subscription_order_meta_during_upgrade')); // don't copy over FreshBooks invoice meta from the subscription to the renewal order add_filter('wcs_renewal_order_meta', array($this, 'subscriptions_remove_renewal_order_meta')); } else { // remove the invoice data from new renewal orders for subscription renewals so a new invoice is created for each renewal order add_filter('woocommerce_subscriptions_renewal_order_meta_query', array($this, 'subscriptions_remove_renewal_order_meta_1_5'), 10, 4); } } // maybe disable API logging if ('on' !== get_option('wc_freshbooks_debug_mode')) { remove_action('wc_' . $this->get_id() . '_api_request_performed', array($this, 'log_api_request'), 10); } }
/** * Setup main plugin class * * @since 1.0 * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // include required files $this->includes(); add_action('init', array($this, 'include_template_functions'), 25); // generate voucher pdf, attach to emails, handle downloads add_filter('woocommerce_email_classes', array($this, 'add_email_classes')); }
/** * Plugin constructor * * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // set the custom order number on the new order. we hook into woocommerce_checkout_update_order_meta for orders which are created // from the frontend, and we hook into woocommerce_process_shop_order_meta for admin-created orders. // Note we use these actions rather than the more generic wp_insert_post action because we want to // run after the order meta (including totals) are set so we can detect whether this is a free order add_action('woocommerce_checkout_update_order_meta', array($this, 'set_sequential_order_number'), 10, 2); add_action('woocommerce_process_shop_order_meta', array($this, 'set_sequential_order_number'), 15, 2); add_action('woocommerce_before_resend_order_emails', array($this, 'set_sequential_order_number'), 10, 1); // return our custom order number for display add_filter('woocommerce_order_number', array($this, 'get_order_number'), 10, 2); // order tracking page search by order number add_filter('woocommerce_shortcode_order_tracking_order_id', array($this, 'find_order_by_order_number')); // WC Subscriptions support: prevent unnecessary order meta from polluting parent renewal orders, and set order number for subscription orders add_filter('woocommerce_subscriptions_renewal_order_meta_query', array($this, 'subscriptions_remove_renewal_order_meta'), 10, 4); add_action('woocommerce_subscriptions_renewal_order_created', array($this, 'subscriptions_set_sequential_order_number'), 9, 4); if (is_admin()) { // keep the admin order search/order working properly add_filter('request', array($this, 'woocommerce_custom_shop_order_orderby'), 20); add_filter('woocommerce_shop_order_search_fields', array($this, 'custom_search_fields')); // sort by underlying _order_number on the Pre-Orders table add_filter('wc_pre_orders_edit_pre_orders_request', array($this, 'custom_orderby')); add_filter('wc_pre_orders_search_fields', array($this, 'custom_search_fields')); // inject our admin options add_filter('woocommerce_general_settings', array($this, 'admin_settings')); add_action('woocommerce_settings_start', array($this, 'admin_settings_js')); // roll my own Settings field error check, which isn't beautiful, but is important add_filter('pre_update_option_woocommerce_order_number_start', array($this, 'validate_order_number_start_setting'), 10, 2); // pre WC 2.1 add_filter('wp_redirect', array($this, 'add_settings_error_msg'), 10, 2); // add support for the CSV export plugin add_filter('woocommerce_export_csv_extra_columns', array($this, 'export_csv_extra_columns')); add_action('woocommerce_settings_start', array($this, 'add_settings_errors')); } }
/** * Setup main plugin class * * @since 3.0 * @return \WC_Customer_Order_CSV_Export */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // required files $this->includes(); // Set orders as not-exported when created add_action('wp_insert_post', array($this, 'mark_order_not_exported'), 10, 2); // Admin if (is_admin()) { // handle single order CSV export download from order action button add_action('wp_ajax_wc_customer_order_csv_export_export_order', array($this, 'process_ajax_export_order')); if (!defined('DOING_AJAX')) { $this->admin_includes(); } } // clear schduled events on deactivation register_deactivation_hook($this->get_file(), array($this->cron, 'clear_scheduled_export')); }
/** * Initializes the plugin * * @since 2.0 */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN, array('dependencies' => array('dom', 'SimpleXML', 'xmlwriter'))); // include required files add_action('sv_wc_framework_plugins_loaded', array($this, 'includes')); // admin if (is_admin() && !defined('DOING_AJAX')) { // tweak the CSS for the order notes so super-long Amazon transaction IDs fit properly add_action('admin_print_styles', array($this, 'render_embedded_styles'), 1); } // process the redirect from Amazon after a customer confirms their payment add_action('wp', array($this, 'process_redirect')); }
/** * Initializes the plugin * * @since 2.0 */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN, array('dependencies' => array('curl', 'dom', 'hash', 'openssl', 'SimpleXML', 'xmlwriter'))); // include required files add_action('sv_wc_framework_plugins_loaded', array($this, 'includes')); // add the 'My Cards' on the 'My Account' page add_action('woocommerce_after_my_account', array($this, 'render_my_cards')); // load templates, called just before the woocommerce template functions are included add_action('init', array($this, 'include_template_functions'), 25); // admin if (is_admin() && !defined('DOING_AJAX')) { // show braintree customer ID field on edit user pages add_action('show_user_profile', array($this, 'render_braintree_customer_id_meta_field')); add_action('edit_user_profile', array($this, 'render_braintree_customer_id_meta_field')); // save braintree customer ID field add_action('personal_options_update', array($this, 'save_braintree_customer_id_meta_field')); add_action('edit_user_profile_update', array($this, 'save_braintree_customer_id_meta_field')); } }
/** * Initializes the plugin * * @since 1.0 * @return \WC_Admin_Custom_Order_Fields */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // include required files $this->includes(); // display any publicly-visible custom order data in the frontend/emails add_action('woocommerce_order_details_after_order_table', array($this, 'add_order_details_after_order_table')); add_action('woocommerce_email_after_order_table', array($this, 'add_order_details_after_order_table')); // custom ajax handler for AJAX search add_action('wp_ajax_wc_admin_custom_order_fields_json_search_field', array($this, 'add_json_search_field')); // save default field values when order is created add_action('wp_insert_post', array($this, 'save_default_field_values'), 10, 2); }
/** * Setup main plugin class * * @since 1.0 * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); $this->includes(); add_action('init', array($this, 'init')); add_action('init', array($this, 'include_template_functions'), 25); add_filter('woocommerce_product_tabs', array($this, 'setup_tabs'), 98); // allow the use of shortcodes within the tab content add_filter('woocommerce_tab_manager_tab_panel_content', 'do_shortcode'); }
/** * Initializes the plugin * * @since 1.0 * @return \WC_Checkout_Add_Ons */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // Initialize add_action('init', array($this, 'includes')); // custom ajax handler for AJAX search add_action('wp_ajax_wc_checkout_add_ons_json_search_field', array($this, 'add_json_search_field')); // add checkout add-ons value column header to order items table add_action('woocommerce_admin_order_item_headers', array($this, 'add_order_item_headers')); // add checkout add-ons value column to order items table add_action('woocommerce_admin_order_item_values', array($this, 'add_order_item_values'), 10, 3); // save checkout add-ons value add_action('woocommerce_process_shop_order_meta', array($this, 'process_shop_order_meta'), 10, 2); // save checkout add-ons value via ajax add_action('wp_ajax_wc_checkout_add_ons_save_order_items', array($this, 'save_order_item_values_ajax')); }
/** * Initialize the plugin * * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN, array('dependencies' => array('simplexml', 'dom'))); // Load the gateway add_action('sv_wc_framework_plugins_loaded', array($this, 'load_classes')); }
/** * Initializes the plugin * * @since 1.0.0 * @return \WC_Memberships */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // Include required files add_action('sv_wc_framework_plugins_loaded', array($this, 'includes')); add_action('init', array($this, 'init')); // Make sure template files are searched for in our plugin add_filter('woocommerce_locate_template', array($this, 'locate_template'), 20, 3); add_filter('woocommerce_locate_core_template', array($this, 'locate_template'), 20, 3); add_action('woocommerce_order_status_completed', array($this, 'grant_membership_access'), 11); add_action('woocommerce_order_status_processing', array($this, 'grant_membership_access'), 11); // Lifecycle add_action('admin_init', array($this, 'maybe_activate')); register_deactivation_hook(__FILE__, array($this, 'deactivate')); }
/** * Initializes the plugin * * @since 1.0.0 * @return \WC_social_login */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION); // Initialize add_action('init', array($this, 'init')); // Register widgets add_action('widgets_init', array($this, 'register_widgets')); }
/** * Initialize the plugin * * Optional args: * * + `require_ssl` - boolean true if this plugin requires SSL for proper functioning, false otherwise. Defaults to false * + `gateways` - array associative array of gateway id to gateway class name. A single plugin might support more than one gateway, ie credit card, echeck. Note that the credit card gateway must always be the first one listed. * + `currencies` - array of currency codes this gateway is allowed for, defaults to all * + `supports` - array named features that this gateway supports, including 'tokenization', 'transaction_link', 'customer_id' * * @since 1.0 * @see SV_WC_Plugin::__construct() * @param string $id plugin id * @param string $version plugin version number * @param string $text_domain the plugin text domain * @param array $args plugin arguments */ public function __construct($id, $version, $text_domain, $args) { parent::__construct($id, $version, $text_domain, $args); // optional parameters: the supported gateways if (isset($args['gateways'])) { foreach ($args['gateways'] as $gateway_id => $gateway_class_name) { $this->add_gateway($gateway_id, $gateway_class_name); } } if (isset($args['currencies'])) { $this->currencies = $args['currencies']; } if (isset($args['supports'])) { $this->supports = $args['supports']; } if (isset($args['require_ssl'])) { $this->require_ssl = $args['require_ssl']; } if (!is_admin() && $this->supports(self::FEATURE_TOKENIZATION)) { // Handle any actions from the My Payment Methods section add_action('wp', array($this, 'handle_my_payment_methods_actions')); // Add the 'Manage My Payment Methods' on the 'My Account' page for the gateway add_action('woocommerce_after_my_account', array($this, 'add_my_payment_methods')); } // Admin if (is_admin() && !defined('DOING_AJAX')) { // show/persist customer id field on edit user pages, if supported if ($this->supports(self::FEATURE_CUSTOMER_ID)) { // show the customer ID add_action('show_user_profile', array($this, 'add_customer_id_meta_field')); add_action('edit_user_profile', array($this, 'add_customer_id_meta_field')); // save the customer ID add_action('personal_options_update', array($this, 'save_customer_id_meta_field')); add_action('edit_user_profile_update', array($this, 'save_customer_id_meta_field')); } // order admin link to transaction, if supported if ($this->supports(self::FEATURE_TRANSACTION_LINK)) { add_action('woocommerce_order_actions_start', array($this, 'order_meta_box_transaction_link')); } } if ($this->supports(self::FEATURE_CAPTURE_CHARGE)) { if (is_admin() && !defined('DOING_AJAX')) { // capture charge order action add_filter('woocommerce_order_actions', array($this, 'maybe_add_capture_charge_order_action')); add_action('woocommerce_order_action_wc_' . $this->get_id() . '_capture_charge', array($this, 'maybe_capture_charge')); // bulk capture charge order action add_action('admin_footer-edit.php', array($this, 'add_capture_charge_bulk_order_action')); add_action('load-edit.php', array($this, 'process_capture_charge_bulk_order_action')); } } // Add classes to WC Payment Methods add_filter('woocommerce_payment_gateways', array($this, 'load_gateways')); }
/** * Initializes the plugin * * @since 1.0 * @return \WC_social_login */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // autoload classes spl_autoload_register(array($this, 'autoload')); // Initialize $this->init(); }
/** * Setup main plugin class * * @since 1.0 * @return \WC_Twilio_SMS */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // Load classes $this->includes(); // Add opt-in checkbox to checkout add_action('woocommerce_after_checkout_billing_form', array($this, 'add_opt_in_checkbox')); // Process opt-in checkbox after order is processed add_action('woocommerce_checkout_update_order_meta', array($this, 'process_opt_in_checkbox')); // Add order status hooks, at priority 11 as order status manager adds // custom statuses at 10 add_action('init', array($this, 'add_order_status_hooks'), 11); }
/** * Construct and initialize the main plugin class * * @see SV_WC_Plugin::__construct() */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, self::TEXT_DOMAIN); // include required files $this->includes(); add_action('woocommerce_init', array($this, 'woocommerce_init')); add_action('sv_wc_framework_plugins_loaded', array($this, 'init')); }
/** * Construct and initialize the main plugin class */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION, array('dependencies' => array('mbstring'))); // Initialize add_action('init', array($this, 'includes')); }
/** * Initialize the plugin * * Optional args: * * + `require_ssl` - boolean true if this plugin requires SSL for proper functioning, false otherwise. Defaults to false * + `gateways` - array associative array of gateway id to gateway class name. A single plugin might support more than one gateway, ie credit card, echeck. Note that the credit card gateway must always be the first one listed. * + `currencies` - array of currency codes this gateway is allowed for, defaults to all * + `supports` - array named features that this gateway supports, including 'tokenization', 'transaction_link', 'customer_id', 'capture_charge' * * @since 1.0.0 * @see SV_WC_Plugin::__construct() * @param string $id plugin id * @param string $version plugin version number * @param array $args plugin arguments */ public function __construct($id, $version, $args) { parent::__construct($id, $version, $args); // optional parameters: the supported gateways if (isset($args['gateways'])) { foreach ($args['gateways'] as $gateway_id => $gateway_class_name) { $this->add_gateway($gateway_id, $gateway_class_name); } } if (isset($args['currencies'])) { $this->currencies = $args['currencies']; } if (isset($args['supports'])) { $this->supports = $args['supports']; } if (isset($args['require_ssl'])) { $this->require_ssl = $args['require_ssl']; } // My Payment Methods feature if (!is_admin() && $this->supports(self::FEATURE_MY_PAYMENT_METHODS)) { add_action('wp', array($this, 'maybe_init_my_payment_methods')); } // Admin if (is_admin() && !is_ajax()) { if ($this->supports(self::FEATURE_CAPTURE_CHARGE)) { // capture charge order action add_filter('woocommerce_order_actions', array($this, 'maybe_add_capture_charge_order_action')); add_action('woocommerce_order_action_wc_' . $this->get_id() . '_capture_charge', array($this, 'maybe_capture_charge')); // bulk capture charge order action add_action('admin_footer-edit.php', array($this, 'maybe_add_capture_charge_bulk_order_action')); add_action('load-edit.php', array($this, 'process_capture_charge_bulk_order_action')); } if ($this->is_subscriptions_active()) { // filter the payment gateway table on the checkout settings screen to indicate if a gateway can support Subscriptions but requires tokenization to be enabled add_action('admin_print_styles-woocommerce_page_wc-settings', array($this, 'subscriptions_add_renewal_support_status_inline_style')); add_filter('woocommerce_payment_gateways_renewal_support_status_html', array($this, 'subscriptions_maybe_edit_renewal_support_status'), 10, 2); } } // Add classes to WC Payment Methods add_filter('woocommerce_payment_gateways', array($this, 'load_gateways')); }
/** * Setup main plugin class * * @since 3.0 * @return \WC_Customer_Order_CSV_Export */ public function __construct() { parent::__construct(self::PLUGIN_ID, self::VERSION); // required files $this->includes(); // Set orders as not-exported when created add_action('wp_insert_post', array($this, 'mark_order_not_exported'), 10, 2); // Admin if (is_admin()) { // handle single order CSV export download from order action button add_action('wp_ajax_wc_customer_order_csv_export_export_order', array($this, 'process_ajax_export_order')); if (!is_ajax()) { $this->admin_includes(); } } // Subscriptions support if ($this->is_plugin_active('woocommerce-subscriptions.php')) { if (SV_WC_Plugin_Compatibility::is_wc_subscriptions_version_gte_2_0()) { // Prevent that new subscription renewal orders from being automatically marked as 'exported' add_filter('wcs_subscription_meta', array($this, 'subscriptions_remove_subscription_order_meta'), 10, 3); add_filter('wcs_upgrade_subscription_meta_to_copy', array($this, 'subscriptions_remove_subscription_order_meta_during_upgrade')); add_filter('wcs_renewal_order_meta', array($this, 'subscriptions_remove_renewal_order_meta')); } } // clear scheduled events on deactivation register_deactivation_hook($this->get_file(), array($this->get_cron_instance(), 'clear_scheduled_export')); }