/**
  * Add add-on meta to order row label for display purposes in
  * order edit screen.
  *
  * @since 1.0
  * @param string $safe_text
  * @param string $text
  * @return string Escaped or unescaped text
  */
 public function append_add_on_fee_meta($safe_text, $text)
 {
     if (SV_WC_Plugin_Compatibility::is_wc_version_lt_2_2() && !empty($this->formatted_names)) {
         foreach ($this->formatted_names as $name => $formatted_name) {
             if ($text == $name) {
                 $safe_text = $formatted_name;
                 unset($this->formatted_names[$name]);
             }
         }
     }
     return $safe_text;
 }
コード例 #2
0
 /**
  * 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 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')) {
         // order admin link to transaction, if supported
         if ($this->supports(self::FEATURE_TRANSACTION_LINK) && SV_WC_Plugin_Compatibility::is_wc_version_lt_2_2()) {
             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, 'maybe_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'));
 }