Skip to content

Commit

Permalink
ingnore build directory
Browse files Browse the repository at this point in the history
update return types

update code sniffer config

update ignore

update comments

update workflow

update comment
  • Loading branch information
vgumonis committed Dec 23, 2024
1 parent 1339741 commit ee1e340
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<rule ref="WordPress">
<exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned"/>
<exclude name="WordPress.Security.NonceVerification"/>
<exclude name="WordPress.WP.EnqueuedResourceParameters.NoExplicitVersion" />
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSameWarning"/>
<exclude name="WordPress.PHP.DevelopmentFunctions"/>
</rule>
Expand All @@ -21,5 +22,6 @@
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>assets/*</exclude-pattern>
<exclude-pattern>index.php</exclude-pattern>
<exclude-pattern>*.asset.php</exclude-pattern>

</ruleset>
89 changes: 73 additions & 16 deletions includes/class-coingate-for-woocommerce-blocks-support.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
<?php
/**
* Class Coingate_For_Woocommerce_Blocks_Support
*
* Provides support for WooCommerce blocks integration with the CoinGate payment gateway.
*
* Extends the AbstractPaymentMethodType to implement specific functionality
* required for handling CoinGate payment methods within WooCommerce Blocks.
*
* @package Coingate_For_Woocommerce
* @subpackage Coingate_For_Woocommerce/includes
* @author CoinGate <[email protected]>
*
* @final
*/

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;

/**
* Class Coingate_For_Woocommerce_Blocks_Support
*
* Provides support for WooCommerce blocks integration with the CoinGate payment gateway.
*
* Extends the AbstractPaymentMethodType to implement specific functionality
* required for handling CoinGate payment methods within WooCommerce Blocks.
*
* @package Coingate_For_Woocommerce
* @subpackage Coingate_For_Woocommerce/includes
* @author CoinGate <[email protected]>
*
* @final
*/
final class Coingate_For_Woocommerce_Blocks_Support extends AbstractPaymentMethodType {

/**
* Payment gateway settings.
*
* @var array
*/
private $gateway;
protected $name = 'coingate'; // payment gateway id

public function initialize() {
$this->settings = get_option( "woocommerce_coingate_settings", array() );
}
/**
* Payment method name.
*
* @var string
*/
protected $name = 'coingate';

public function is_active() {
return ! empty( $this->settings[ 'enabled' ] ) && 'yes' === $this->settings[ 'enabled' ];
/**
* Init
*/
public function initialize(): void {
$this->settings = get_option( 'woocommerce_coingate_settings', array() );
}

public function get_payment_method_script_handles() {
/**
* Payment method enabled.
*
* @return bool
*/
public function is_active(): bool {
return ! empty( $this->settings['enabled'] ) && 'yes' === $this->settings['enabled'];
}

/**
* Script to use
*
* @return array
*/
public function get_payment_method_script_handles(): array {
wp_register_script(
'wc-coingate-blocks-integration',
plugin_dir_url( __DIR__ ) . 'build/index.js',
Expand All @@ -24,20 +77,24 @@ public function get_payment_method_script_handles() {
'wp-element',
'wp-html-entities',
),
null,
false,
true
);

return array( 'wc-coingate-blocks-integration' );
}

public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
// TODO CAN ADD ICON pvz coingate
// 'icon' => plugin_dir_url( __DIR__ ) . 'assets/icon.png',
/**
* Payment method data
*
* @return array
*/
public function get_payment_method_data(): array {
return array(
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
// 'icon' => plugin_dir_url( __DIR__ ) . 'assets/icon.png',
// 'supports' => array_filter( $this->gateway->supports, [ $this->gateway, 'supports' ] ),
];
);
}
}
}
10 changes: 5 additions & 5 deletions includes/class-coingate-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Coingate_For_Woocommerce {
*
* @since 1.0.0
* @access protected
* @var Coingate_For_Woocommerce_Loader $loader Maintains and registers all hooks for the plugin.
* @var Coingate_For_Woocommerce_Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;

Expand Down Expand Up @@ -163,7 +163,7 @@ private function define_public_hooks() {

$this->loader->add_filter( 'woocommerce_payment_gateways', $plugin_public, 'register_payment_gateway' );

$this->loader->add_action( 'woocommerce_blocks_loaded', $plugin_public, 'woocommerce_gateway_coingate_block_support');
$this->loader->add_action( 'woocommerce_blocks_loaded', $plugin_public, 'woocommerce_gateway_coingate_block_support' );
}

/**
Expand All @@ -179,8 +179,8 @@ public function run() {
* The name of the plugin used to uniquely identify it within the context of
* WordPress and to define internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
* @since 1.0.0
*/
public function get_plugin_name() {
return $this->plugin_name;
Expand All @@ -189,8 +189,8 @@ public function get_plugin_name() {
/**
* The reference to the class that orchestrates the hooks with the plugin.
*
* @since 1.0.0
* @return Coingate_For_Woocommerce_Loader Orchestrates the hooks of the plugin.
* @since 1.0.0
*/
public function get_loader() {
return $this->loader;
Expand All @@ -199,8 +199,8 @@ public function get_loader() {
/**
* Retrieve the version number of the plugin.
*
* @since 1.0.0
* @return string The version number of the plugin.
* @since 1.0.0
*/
public function get_version() {
return $this->version;
Expand Down
113 changes: 55 additions & 58 deletions public/class-coingate-for-woocommerce-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,72 +19,69 @@
* @subpackage Coingate_For_Woocommerce/public
* @author CoinGate <[email protected]>
*/
class Coingate_For_Woocommerce_Public
{
class Coingate_For_Woocommerce_Public {

/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;

/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;

/**
* Initialize the class and set its properties.
*
* @param string $plugin_name The name of the plugin.
* @param string $version The version of this plugin.
* @since 1.0.0
*/
public function __construct($plugin_name, $version)
{
/**
* Initialize the class and set its properties.
*
* @param string $plugin_name The name of the plugin.
* @param string $version The version of this plugin.
*
* @since 1.0.0
*/
public function __construct( $plugin_name, $version ) {

$this->plugin_name = $plugin_name;
$this->version = $version;
$this->plugin_name = $plugin_name;
$this->version = $version;

}
}

/**
* Register payment gateway.
*
* @param array $methods Payment gateway methods.
* @return array
*/
public function register_payment_gateway(array $methods)
{
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-coingate-for-woocommerce-payment-gateway.php';
/**
* Register payment gateway.
*
* @param array $methods Payment gateway methods.
*
* @return array
*/
public function register_payment_gateway( array $methods ) {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-coingate-for-woocommerce-payment-gateway.php';

if (!isset($methods['Coingate_Payment_Gateway'])) {
$methods['Coingate_Payment_Gateway'] = new Coingate_For_Woocommerce_Payment_Gateway();
}
if ( ! isset( $methods['Coingate_Payment_Gateway'] ) ) {
$methods['Coingate_Payment_Gateway'] = new Coingate_For_Woocommerce_Payment_Gateway();
}

return $methods;
}
return $methods;
}

/**
* Enable Block support
*
*/
public function woocommerce_gateway_coingate_block_support()
{
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-coingate-for-woocommerce-blocks-support.php';
/**
* Enable Block support
*/
public function woocommerce_gateway_coingate_block_support() {
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-coingate-for-woocommerce-blocks-support.php';

add_action(
'woocommerce_blocks_payment_method_type_registration',
function (\Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) {
$payment_method_registry->register(new Coingate_For_Woocommerce_Blocks_Support);
}
);
}
add_action(
'woocommerce_blocks_payment_method_type_registration',
function ( \Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register( new Coingate_For_Woocommerce_Blocks_Support() );
}
);
}
}

0 comments on commit ee1e340

Please sign in to comment.