Changeset 3399343
- Timestamp:
- 11/20/2025 03:34:59 AM (5 months ago)
- Location:
- maaly-pay
- Files:
-
- 4 added
- 1 edited
-
assets/js/blocks.asset.php (added)
-
assets/js/blocks.js (added)
-
trunk/assets/js/blocks.asset.php (added)
-
trunk/assets/js/blocks.js (added)
-
trunk/includes/class-maaly-pay-gateway-blocks.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
maaly-pay/trunk/includes/class-maaly-pay-gateway-blocks.php
r3399333 r3399343 7 7 * Class for handling Maaly Pay Gateway payment block checkout support. 8 8 */ 9 final class WC_MaalyGateway_Blocks extends AbstractPaymentMethodType { 9 final class WC_MaalyGateway_Blocks extends AbstractPaymentMethodType 10 { 10 11 11 12 /** … … 26 27 * Initializes the Maaly Gateway block. 27 28 */ 28 public function initialize() { 29 public function initialize() 30 { 29 31 // Load settings for your gateway (if applicable) 30 $this->settings = get_option( 'maaly_pay_settings', array());32 $this->settings = get_option('maaly_pay_settings', array()); 31 33 32 $gateways = WC()->payment_gateways->payment_gateways();34 $gateways = WC()->payment_gateways->payment_gateways(); 33 35 // Instantiate your main payment gateway class 34 $this->gateway = $gateways($this->name); 36 $this->gateway = $gateways($this->name); 35 37 } 36 38 … … 40 42 * @return bool True if the payment method is active, false otherwise. 41 43 */ 42 public function is_active() { 44 public function is_active() 45 { 43 46 return $this->gateway->is_available(); // Or check a specific setting 44 47 } … … 49 52 * @return array The script handles for the payment method. 50 53 */ 51 public function get_payment_method_script_handles() { 54 public function get_payment_method_script_handles() 55 { 56 // wp_register_script( 57 // 'wc-maaly-pay-blocks', 58 // // plugins_url( 'assets/js/maaly-pay.js', __FILE__ ), // Path to your frontend script 59 // MAALY_PAY_PLUGIN_URL . 'assets/js/maaly-pay.js', 60 // ['wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'], 61 // '1.1.1', 62 // true 63 // ); 64 65 // if (function_exists('wp_set_script_translations')) { 66 // wp_set_script_translations('wc-maaly-pay-blocks'); 67 // } 68 69 // return ['wc-maaly-pay-blocks']; 70 71 $script_path = '/assets/js/blocks.js'; 72 $script_asset_path = trailingslashit(MAALY_PAY_PLUGIN_DIR) . 'assets/js/blocks.asset.php'; 73 $script_asset = file_exists($script_asset_path) 74 ? require($script_asset_path) 75 : array( 76 'dependencies' => array(), 77 'version' => '1.2.0' 78 ); 79 $script_url = MAALY_PAY_PLUGIN_DIR . $script_path; 80 52 81 wp_register_script( 53 82 'wc-maaly-pay-blocks', 54 // plugins_url( 'assets/js/maaly-pay.js', __FILE__ ), // Path to your frontend script 55 MAALY_PAY_PLUGIN_URL . 'assets/js/maaly-pay.js', 56 [ 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n' ], 57 '1.1.0', 83 $script_url, 84 $script_asset['dependencies'], 85 $script_asset['version'], 58 86 true 59 87 ); 60 88 61 if ( function_exists( 'wp_set_script_translations' )) {62 wp_set_script_translations( 'wc-maaly-pay-blocks');89 if (function_exists('wp_set_script_translations')) { 90 wp_set_script_translations('wc-maaly-pay-blocks', 'woocommerce-gateway-maaly', trailingslashit(MAALY_PAY_PLUGIN_DIR) . 'languages/'); 63 91 } 64 92 65 return [ 'wc-maaly-pay-blocks'];93 return ['wc-maaly-pay-blocks']; 66 94 } 67 95 … … 71 99 * @return array The data for the payment method. 72 100 */ 73 public function get_payment_method_data() { 101 public function get_payment_method_data() 102 { 74 103 return [ 75 'title' => $this->gateway->title,104 'title' => $this->gateway->title, 76 105 'description' => $this->gateway->description, 77 'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ])106 'supports' => array_filter($this->gateway->supports, [$this->gateway, 'supports']) 78 107 // Add any other data needed by your frontend script 79 108 ];
Note: See TracChangeset
for help on using the changeset viewer.