Initial implementation of the Woo Alipay - Barcode Pay Extension for WooCommerce. Adds a new payment gateway for Alipay barcode payments, including frontend and backend support, WooCommerce Blocks integration, REST API enhancements, and plugin setup files. Requires Woo Alipay and WooCommerce plugins.
35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
<?php
|
|
/*
|
|
* Plugin Name: Woo Alipay - Barcode Pay Extension
|
|
* Plugin URI: https://woocn.com/
|
|
* Description: 独立启用 Woo Alipay 的“条码支付(当面条码)”网关。需要先安装并启用 Woo Alipay 与 WooCommerce。
|
|
* Version: 0.1.0
|
|
* Author: WooCN.com
|
|
* Author URI: https://woocn.com/
|
|
* Requires Plugins: woocommerce, woo-alipay
|
|
* Text Domain: woo-alipay-barcode
|
|
* Domain Path: /languages
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
|
|
|
// 加载扩展引导(注册网关和 REST UI 支持)
|
|
require_once plugin_dir_path( __FILE__ ) . 'bootstrap.php';
|
|
|
|
// 激活时将网关设为启用(可选)
|
|
register_activation_hook( __FILE__, function () {
|
|
if ( current_user_can( 'manage_woocommerce' ) ) {
|
|
$option_key = 'woocommerce_alipay_barcode_settings';
|
|
$settings = get_option( $option_key, array() );
|
|
$settings['enabled'] = isset( $settings['enabled'] ) ? $settings['enabled'] : 'no'; // 默认不强制开启
|
|
update_option( $option_key, $settings );
|
|
wp_cache_flush();
|
|
}
|
|
} );
|
|
|
|
// 设置页快捷入口
|
|
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function( $links ) {
|
|
$url = admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=alipay_barcode' );
|
|
$links[] = '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Settings', 'woo-alipay-barcode' ) . '</a>';
|
|
return $links;
|
|
} );
|