File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Integrations.tar
Base.php 0000644 00000003433 15154035743 0006141 0 ustar 00 <?php
/**
* Base Plugin Integration Class, extend this if implementing a plugin integration class.
*
* @since 2.13.0
*
* @package OMAPI
* @author Gabriel Oliveira and Eduardo Nakatsuka
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Base Plugin Integration class.
*
* @since 2.13.0
*/
abstract class OMAPI_Integrations_Base {
/**
* Holds the class object.
*
* @since 2.13.0
*
* @var static
*/
public static $instance;
/**
* The Base OMAPI Object
*
* @since 2.13.0
*
* @var OMAPI
*/
protected $base;
/**
* The minimum Plugin version required.
*
* @since 2.13.0
*
* @var string
*/
const MINIMUM_VERSION = '0.0.0';
/**
* Build our object.
*
* @since 2.13.0
*/
public function __construct() {
$this->base = OMAPI::get_instance();
static::$instance = $this;
}
/**
* Return the plugin version string.
*
* @since 2.13.0
*
* @return string
*/
abstract public static function version();
/**
* Determines if the passed version string passes the operator compare
* against the currently installed version of plugin.
*
* Defaults to checking if the current plugin version is greater than
* the passed version.
*
* @since 2.13.0
*
* @param string $version The version to check.
* @param string $operator The operator to use for comparison.
*
* @return string
*/
public static function version_compare( $version = '', $operator = '>=' ) {
return version_compare( static::version(), $version, $operator );
}
/**
* Determines if the current WooCommerce version meets the minimum version
* requirement.
*
* @since 2.13.0
*
* @return boolean
*/
public static function is_minimum_version() {
return static::version_compare( static::MINIMUM_VERSION );
}
}
BbPress.php 0000644 00000000776 15154237675 0006646 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Integrations;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to integrate with the bbPress plugin.
*
* @since 4.8.1
*/
class BbPress {
/**
* Returns whether the current page is a bbPress component page.
*
* @since 4.8.1
*
* @return bool Whether the current page is a bbPress component page.
*/
public static function isComponentPage() {
return ! empty( aioseo()->standalone->bbPress->component->templateType );
}
} BuddyPress.php 0000644 00000010740 15154237675 0007362 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Integrations;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class to integrate with the BuddyPress plugin.
*
* @since 4.7.6
*/
class BuddyPress {
/**
* Call the callback given by the first parameter.
*
* @since 4.7.6
*
* @param callable $callback The function to be called.
* @param mixed ...$args Zero or more parameters to be passed to the function
* @return mixed|null The function result or null if the function is not callable.
*/
public static function callFunc( $callback, ...$args ) {
if ( is_callable( $callback ) ) {
return call_user_func( $callback, ...$args );
}
return null;
}
/**
* Returns the BuddyPress email custom post type slug.
*
* @since 4.7.6
*
* @return string The BuddyPress email custom post type slug if found or an empty string.
*/
public static function getEmailCptSlug() {
$slug = '';
if ( aioseo()->helpers->isPluginActive( 'buddypress' ) ) {
$slug = self::callFunc( 'bp_get_email_post_type' );
}
return is_scalar( $slug ) ? strval( $slug ) : '';
}
/**
* Retrieves the BuddyPress component archive page permalink.
*
* @since 4.7.6
*
* @param string $component The BuddyPress component.
* @return string The component archive page permalink.
*/
public static function getComponentArchiveUrl( $component ) {
switch ( $component ) {
case 'activity':
$output = self::callFunc( 'bp_get_activity_directory_permalink' );
break;
case 'member':
$output = self::callFunc( 'bp_get_members_directory_permalink' );
break;
case 'group':
$output = self::callFunc( 'bp_get_groups_directory_url' );
break;
default:
$output = '';
}
return is_scalar( $output ) ? strval( $output ) : '';
}
/**
* Returns the BuddyPress component single page permalink.
*
* @since 4.7.6
*
* @param string $component The BuddyPress component.
* @param mixed $id The component ID.
* @return string The component single page permalink.
*/
public static function getComponentSingleUrl( $component, $id ) {
switch ( $component ) {
case 'activity':
$output = self::callFunc( 'bp_activity_get_permalink', $id );
break;
case 'group':
$output = self::callFunc( 'bp_get_group_url', $id );
break;
case 'member':
$output = self::callFunc( 'bp_core_get_userlink', $id, false, true );
break;
default:
$output = '';
}
return is_scalar( $output ) ? strval( $output ) : '';
}
/**
* Returns the BuddyPress component edit link.
*
* @since 4.7.6
*
* @param string $component The BuddyPress component.
* @param mixed $id The component ID.
* @return string The component edit link.
*/
public static function getComponentEditUrl( $component, $id ) {
switch ( $component ) {
case 'activity':
$output = add_query_arg( [
'page' => 'bp-activity',
'aid' => $id,
'action' => 'edit'
], self::callFunc( 'bp_get_admin_url', 'admin.php' ) );
break;
case 'group':
$output = add_query_arg( [
'page' => 'bp-groups',
'gid' => $id,
'action' => 'edit'
], self::callFunc( 'bp_get_admin_url', 'admin.php' ) );
break;
case 'member':
$output = get_edit_user_link( $id );
break;
default:
$output = '';
}
return is_scalar( $output ) ? strval( $output ) : '';
}
/**
* Returns whether the BuddyPress component is active or not.
*
* @since 4.7.6
*
* @param string $component The BuddyPress component.
* @return bool Whether the BuddyPress component is active.
*/
public static function isComponentActive( $component ) {
static $active = [];
if ( isset( $active[ $component ] ) ) {
return $active[ $component ];
}
switch ( $component ) {
case 'activity':
$active[ $component ] = self::callFunc( 'bp_is_active', 'activity' );
break;
case 'group':
$active[ $component ] = self::callFunc( 'bp_is_active', 'groups' );
break;
case 'member':
$active[ $component ] = self::callFunc( 'bp_is_active', 'members' );
break;
default:
$active[ $component ] = false;
}
return $active[ $component ];
}
/**
* Returns whether the current page is a BuddyPress component page.
*
* @since 4.7.6
*
* @return bool Whether the current page is a BuddyPress component page.
*/
public static function isComponentPage() {
return ! empty( aioseo()->standalone->buddyPress->component->templateType );
}
} Semrush.php 0000644 00000004331 15154237675 0006723 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Api\Integrations;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Integrations\Semrush as SemrushIntegration;
/**
* Route class for the API.
*
* @since 4.0.16
*/
class Semrush {
/**
* Fetches the additional keyphrases.
*
* @since 4.0.16
*
* @param \WP_REST_Request $request The REST Request
* @return \WP_REST_Response The response.
*/
public static function semrushGetKeyphrases( $request ) {
$body = $request->get_json_params();
$keyphrases = SemrushIntegration::getKeyphrases( $body['keyphrase'], $body['database'] );
if ( false === $keyphrases ) {
return new \WP_REST_Response( [
'success' => false,
'message' => 'You may have sent too many requests to Semrush. Please wait a few minutes and try again.'
], 400 );
}
return new \WP_REST_Response( [
'success' => true,
'keyphrases' => $keyphrases
], 200 );
}
/**
* Authenticates with Semrush.
*
* @since 4.0.16
*
* @param \WP_REST_Request $request The REST Request
* @return \WP_REST_Response The response.
*/
public static function semrushAuthenticate( $request ) {
$body = $request->get_json_params();
if ( empty( $body['code'] ) ) {
return new \WP_REST_Response( [
'success' => false,
'message' => 'Missing authorization code.'
], 400 );
}
$success = SemrushIntegration::authenticate( $body['code'] );
if ( ! $success ) {
return new \WP_REST_Response( [
'success' => false,
'message' => 'Authentication failed.'
], 400 );
}
return new \WP_REST_Response( [
'success' => true,
'semrush' => aioseo()->internalOptions->integrations->semrush->all()
], 200 );
}
/**
* Refreshes the API tokens.
*
* @since 4.0.16
*
* @return \WP_REST_Response The response.
*/
public static function semrushRefresh() {
$success = SemrushIntegration::refreshTokens();
if ( ! $success ) {
return new \WP_REST_Response( [
'success' => false,
'message' => 'API tokens could not be refreshed.'
], 400 );
}
return new \WP_REST_Response( [
'success' => true,
'semrush' => aioseo()->internalOptions->integrations->semrush->all()
], 200 );
}
} WpCode.php 0000644 00000001656 15154237675 0006465 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Api\Integrations;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\Plugin\Common\Integrations\WpCode as WpCodeIntegration;
/**
* Route class for the API.
*
* @since 4.3.8
*/
class WpCode {
/**
* Load the WPCode Snippets from the library, if available.
*
* @since 4.3.8
*
* @param \WP_REST_Request $request The REST Request
* @return \WP_REST_Response The response.
*/
public static function getSnippets( $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
return new \WP_REST_Response( [
'success' => true,
'snippets' => WpCodeIntegration::loadWpCodeSnippets(),
'pluginInstalled' => WpCodeIntegration::isPluginInstalled(),
'pluginActive' => WpCodeIntegration::isPluginActive(),
'pluginNeedsUpdate' => WpCodeIntegration::pluginNeedsUpdate()
], 200 );
}
} IntegrationInterface.php 0000644 00000001563 15155074222 0011371 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Integrations;
/**
* Integration.Interface
*
* Integrations must use this interface when registering themselves with blocks,
*/
interface IntegrationInterface {
/**
* The name of the integration.
*
* @return string
*/
public function get_name();
/**
* When called invokes any initialization/setup for the integration.
*/
public function initialize();
/**
* Returns an array of script handles to enqueue in the frontend context.
*
* @return string[]
*/
public function get_script_handles();
/**
* Returns an array of script handles to enqueue in the editor context.
*
* @return string[]
*/
public function get_editor_script_handles();
/**
* An array of key, value pairs of data made available to the block on the client side.
*
* @return array
*/
public function get_script_data();
}
IntegrationRegistry.php 0000644 00000012512 15155074222 0011275 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Integrations;
/**
* Class used for tracking registered integrations with various Block types.
*/
class IntegrationRegistry {
/**
* Integration identifier is used to construct hook names and is given when the integration registry is initialized.
*
* @var string
*/
protected $registry_identifier = '';
/**
* Registered integrations, as `$name => $instance` pairs.
*
* @var IntegrationInterface[]
*/
protected $registered_integrations = [];
/**
* Initializes all registered integrations.
*
* Integration identifier is used to construct hook names and is given when the integration registry is initialized.
*
* @param string $registry_identifier Identifier for this registry.
*/
public function initialize( $registry_identifier = '' ) {
if ( $registry_identifier ) {
$this->registry_identifier = $registry_identifier;
}
if ( empty( $this->registry_identifier ) ) {
_doing_it_wrong( __METHOD__, esc_html__( 'Integration registry requires an identifier.', 'woocommerce' ), '4.6.0' );
return false;
}
/**
* Fires when the IntegrationRegistry is initialized.
*
* Runs before integrations are initialized allowing new integration to be registered for use. This should be
* used as the primary hook for integrations to include their scripts, styles, and other code extending the
* blocks.
*
* @since 4.6.0
*
* @param IntegrationRegistry $this Instance of the IntegrationRegistry class which exposes the IntegrationRegistry::register() method.
*/
do_action( 'woocommerce_blocks_' . $this->registry_identifier . '_registration', $this );
foreach ( $this->get_all_registered() as $registered_integration ) {
$registered_integration->initialize();
}
}
/**
* Registers an integration.
*
* @param IntegrationInterface $integration An instance of IntegrationInterface.
*
* @return boolean True means registered successfully.
*/
public function register( IntegrationInterface $integration ) {
$name = $integration->get_name();
if ( $this->is_registered( $name ) ) {
/* translators: %s: Integration name. */
_doing_it_wrong( __METHOD__, esc_html( sprintf( __( '"%s" is already registered.', 'woocommerce' ), $name ) ), '4.6.0' );
return false;
}
$this->registered_integrations[ $name ] = $integration;
return true;
}
/**
* Checks if an integration is already registered.
*
* @param string $name Integration name.
* @return bool True if the integration is registered, false otherwise.
*/
public function is_registered( $name ) {
return isset( $this->registered_integrations[ $name ] );
}
/**
* Un-register an integration.
*
* @param string|IntegrationInterface $name Integration name, or alternatively a IntegrationInterface instance.
* @return boolean|IntegrationInterface Returns the unregistered integration instance if unregistered successfully.
*/
public function unregister( $name ) {
if ( $name instanceof IntegrationInterface ) {
$name = $name->get_name();
}
if ( ! $this->is_registered( $name ) ) {
/* translators: %s: Integration name. */
_doing_it_wrong( __METHOD__, esc_html( sprintf( __( 'Integration "%s" is not registered.', 'woocommerce' ), $name ) ), '4.6.0' );
return false;
}
$unregistered = $this->registered_integrations[ $name ];
unset( $this->registered_integrations[ $name ] );
return $unregistered;
}
/**
* Retrieves a registered Integration by name.
*
* @param string $name Integration name.
* @return IntegrationInterface|null The registered integration, or null if it is not registered.
*/
public function get_registered( $name ) {
return $this->is_registered( $name ) ? $this->registered_integrations[ $name ] : null;
}
/**
* Retrieves all registered integrations.
*
* @return IntegrationInterface[]
*/
public function get_all_registered() {
return $this->registered_integrations;
}
/**
* Gets an array of all registered integration's script handles for the editor.
*
* @return string[]
*/
public function get_all_registered_editor_script_handles() {
$script_handles = [];
$registered_integrations = $this->get_all_registered();
foreach ( $registered_integrations as $registered_integration ) {
$script_handles = array_merge(
$script_handles,
$registered_integration->get_editor_script_handles()
);
}
return array_unique( array_filter( $script_handles ) );
}
/**
* Gets an array of all registered integration's script handles.
*
* @return string[]
*/
public function get_all_registered_script_handles() {
$script_handles = [];
$registered_integrations = $this->get_all_registered();
foreach ( $registered_integrations as $registered_integration ) {
$script_handles = array_merge(
$script_handles,
$registered_integration->get_script_handles()
);
}
return array_unique( array_filter( $script_handles ) );
}
/**
* Gets an array of all registered integration's script data.
*
* @return array
*/
public function get_all_registered_script_data() {
$script_data = [];
$registered_integrations = $this->get_all_registered();
foreach ( $registered_integrations as $registered_integration ) {
$script_data[ $registered_integration->get_name() . '_data' ] = $registered_integration->get_script_data();
}
return array_filter( $script_data );
}
}
AbstractPaymentMethodType.php 0000644 00000005425 15155423517 0012377 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodTypeInterface;
/**
* AbstractPaymentMethodType class.
*
* @since 2.6.0
*/
abstract class AbstractPaymentMethodType implements PaymentMethodTypeInterface {
/**
* Payment method name defined by payment methods extending this class.
*
* @var string
*/
protected $name = '';
/**
* Settings from the WP options table
*
* @var array
*/
protected $settings = [];
/**
* Get a setting from the settings array if set.
*
* @param string $name Setting name.
* @param mixed $default Value that is returned if the setting does not exist.
* @return mixed
*/
protected function get_setting( $name, $default = '' ) {
return isset( $this->settings[ $name ] ) ? $this->settings[ $name ] : $default;
}
/**
* Returns the name of the payment method.
*/
public function get_name() {
return $this->name;
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return true;
}
/**
* Returns an array of script handles to enqueue for this payment method in
* the frontend context
*
* @return string[]
*/
public function get_payment_method_script_handles() {
return [];
}
/**
* Returns an array of script handles to enqueue for this payment method in
* the admin context
*
* @return string[]
*/
public function get_payment_method_script_handles_for_admin() {
return $this->get_payment_method_script_handles();
}
/**
* Returns an array of supported features.
*
* @return string[]
*/
public function get_supported_features() {
return [ 'products' ];
}
/**
* An array of key, value pairs of data made available to payment methods
* client side.
*
* @return array
*/
public function get_payment_method_data() {
return [];
}
/**
* Returns an array of script handles to enqueue in the frontend context.
*
* Alias of get_payment_method_script_handles. Defined by IntegrationInterface.
*
* @return string[]
*/
public function get_script_handles() {
return $this->get_payment_method_script_handles();
}
/**
* Returns an array of script handles to enqueue in the admin context.
*
* Alias of get_payment_method_script_handles_for_admin. Defined by IntegrationInterface.
*
* @return string[]
*/
public function get_editor_script_handles() {
return $this->get_payment_method_script_handles_for_admin();
}
/**
* An array of key, value pairs of data made available to the block on the client side.
*
* Alias of get_payment_method_data. Defined by IntegrationInterface.
*
* @return array
*/
public function get_script_data() {
return $this->get_payment_method_data();
}
}
BankTransfer.php 0000644 00000003261 15155423517 0007647 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
use Automattic\WooCommerce\Blocks\Assets\Api;
/**
* Bank Transfer (BACS) payment method integration
*
* @since 3.0.0
*/
final class BankTransfer extends AbstractPaymentMethodType {
/**
* Payment method name/id/slug (matches id in WC_Gateway_BACS in core).
*
* @var string
*/
protected $name = 'bacs';
/**
* An instance of the Asset Api
*
* @var Api
*/
private $asset_api;
/**
* Constructor
*
* @param Api $asset_api An instance of Api.
*/
public function __construct( Api $asset_api ) {
$this->asset_api = $asset_api;
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_bacs_settings', [] );
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$this->asset_api->register_script(
'wc-payment-method-bacs',
'build/wc-payment-method-bacs.js'
);
return [ 'wc-payment-method-bacs' ];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
];
}
}
CashOnDelivery.php 0000644 00000004756 15155423517 0010160 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
use Automattic\WooCommerce\Blocks\Assets\Api;
/**
* Cash on Delivery (COD) payment method integration
*
* @since 3.0.0
*/
final class CashOnDelivery extends AbstractPaymentMethodType {
/**
* Payment method name/id/slug (matches id in WC_Gateway_COD in core).
*
* @var string
*/
protected $name = 'cod';
/**
* An instance of the Asset Api
*
* @var Api
*/
private $asset_api;
/**
* Constructor
*
* @param Api $asset_api An instance of Api.
*/
public function __construct( Api $asset_api ) {
$this->asset_api = $asset_api;
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_cod_settings', [] );
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
}
/**
* Return enable_for_virtual option.
*
* @return boolean True if store allows COD payment for orders containing only virtual products.
*/
private function get_enable_for_virtual() {
return filter_var( $this->get_setting( 'enable_for_virtual', false ), FILTER_VALIDATE_BOOLEAN );
}
/**
* Return enable_for_methods option.
*
* @return array Array of shipping methods (string ids) that allow COD. (If empty, all support COD.)
*/
private function get_enable_for_methods() {
$enable_for_methods = $this->get_setting( 'enable_for_methods', [] );
if ( '' === $enable_for_methods ) {
return [];
}
return $enable_for_methods;
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$this->asset_api->register_script(
'wc-payment-method-cod',
'build/wc-payment-method-cod.js'
);
return [ 'wc-payment-method-cod' ];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'enableForVirtual' => $this->get_enable_for_virtual(),
'enableForShippingMethods' => $this->get_enable_for_methods(),
'supports' => $this->get_supported_features(),
];
}
}
Cheque.php 0000644 00000003266 15155423517 0006506 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
use Exception;
use Automattic\WooCommerce\Blocks\Assets\Api;
/**
* Cheque payment method integration
*
* @since 2.6.0
*/
final class Cheque extends AbstractPaymentMethodType {
/**
* Payment method name defined by payment methods extending this class.
*
* @var string
*/
protected $name = 'cheque';
/**
* An instance of the Asset Api
*
* @var Api
*/
private $asset_api;
/**
* Constructor
*
* @param Api $asset_api An instance of Api.
*/
public function __construct( Api $asset_api ) {
$this->asset_api = $asset_api;
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_cheque_settings', [] );
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$this->asset_api->register_script(
'wc-payment-method-cheque',
'build/wc-payment-method-cheque.js'
);
return [ 'wc-payment-method-cheque' ];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
];
}
}
PayPal.php 0000644 00000004614 15155423517 0006460 0 ustar 00 <?php
namespace Automattic\WooCommerce\Blocks\Payments\Integrations;
use WC_Gateway_Paypal;
use Automattic\WooCommerce\Blocks\Assets\Api;
/**
* PayPal Standard payment method integration
*
* @since 2.6.0
*/
final class PayPal extends AbstractPaymentMethodType {
/**
* Payment method name defined by payment methods extending this class.
*
* @var string
*/
protected $name = 'paypal';
/**
* An instance of the Asset Api
*
* @var Api
*/
private $asset_api;
/**
* Constructor
*
* @param Api $asset_api An instance of Api.
*/
public function __construct( Api $asset_api ) {
$this->asset_api = $asset_api;
}
/**
* Initializes the payment method type.
*/
public function initialize() {
$this->settings = get_option( 'woocommerce_paypal_settings', [] );
}
/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
return filter_var( $this->get_setting( 'enabled', false ), FILTER_VALIDATE_BOOLEAN );
}
/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$this->asset_api->register_script(
'wc-payment-method-paypal',
'build/wc-payment-method-paypal.js'
);
return [ 'wc-payment-method-paypal' ];
}
/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
return [
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => $this->get_supported_features(),
];
}
/**
* Returns an array of supported features.
*
* @return string[]
*/
public function get_supported_features() {
$gateway = new WC_Gateway_Paypal();
$features = array_filter( $gateway->supports, array( $gateway, 'supports' ) );
/**
* Filter to control what features are available for each payment gateway.
*
* @since 4.4.0
*
* @example See docs/examples/payment-gateways-features-list.md
*
* @param array $features List of supported features.
* @param string $name Gateway name.
* @return array Updated list of supported features.
*/
return apply_filters( '__experimental_woocommerce_blocks_payment_gateway_features_list', $features, $this->get_name() );
}
}