Skip to content

Commit

Permalink
fix: 移除 licensor 後不會自動推送套件更新的問題
Browse files Browse the repository at this point in the history
  • Loading branch information
j7-dev committed Jun 29, 2024
1 parent 1abed43 commit aefccc9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
57 changes: 45 additions & 12 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
/**
* Check WooCommerce exist
*/
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
if ( ! in_array(
'woocommerce/woocommerce.php',
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
true
) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';

function require_woocommerce_notice() {
Expand Down Expand Up @@ -78,7 +82,6 @@ function deactivate_woomp() {
* @since 1.0.0
*/
function run_woomp() {

$plugin = new Woomp();
$plugin->run();
}
Expand All @@ -88,13 +91,16 @@ function run_woomp() {
/**
* 指定 WC 結帳頁模板路徑
*
* @param string $template Default template file path.
* @param string $template Default template file path.
* @param string $template_name Template file slug.
* @param string $template_path Template file name.
*
* @return string The new Template file path.
*/
if ( get_option( 'wc_woomp_setting_mode', 1 ) === 'onepage' || get_option( 'wc_woomp_setting_mode', 1 ) === 'twopage' ) {
if ( get_option( 'wc_woomp_setting_mode', 1 ) === 'onepage' || get_option(
'wc_woomp_setting_mode',
1
) === 'twopage' ) {
add_filter( 'wc_get_template', 'intercept_wc_template', 99, 3 );
function intercept_wc_template( $template, $template_name, $template_path ) {
$template_directory = trailingslashit( plugin_dir_path( __FILE__ ) ) . 'woocommerce/';
Expand All @@ -117,10 +123,10 @@ function intercept_wc_template( $template, $template_name, $template_path ) {

require_once RY_WT_PLUGIN_DIR . 'class.ry-wt.main.php';

register_activation_hook( __FILE__, array( 'RY_WT', 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( 'RY_WT', 'plugin_deactivation' ) );
register_activation_hook( __FILE__, [ 'RY_WT', 'plugin_activation' ] );
register_deactivation_hook( __FILE__, [ 'RY_WT', 'plugin_deactivation' ] );

add_action( 'init', array( 'RY_WT', 'init' ), 10 );
add_action( 'init', [ 'RY_WT', 'init' ], 10 );
}

/**
Expand Down Expand Up @@ -152,7 +158,6 @@ function run_paynow_payment() {
* 引入 paynow-shipping
*/
if ( ! defined( 'PAYNOW_SHIPPING_PLUGIN_URL' ) && 'yes' === get_option( 'wc_woomp_setting_paynow_shipping' ) ) {

define( 'PAYNOW_SHIPPING_PLUGIN_URL', plugin_dir_url( __FILE__ ) . 'includes/paynow-shipping/' );
define( 'PAYNOW_SHIPPING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) . 'includes/paynow-shipping/' );
define( 'PAYNOW_SHIPPING_BASENAME', plugin_basename( __FILE__ ) . 'includes/paynow-shipping/' );
Expand Down Expand Up @@ -264,7 +269,6 @@ function deactivate_paynow_einvoice() {
* @since 1.0.0
*/
function run_paynow_einvoice() {

$plugin = new Paynow_Einvoice();
$plugin->run();
}
Expand All @@ -291,7 +295,6 @@ function run_paynow_einvoice() {
* 引入 woomp-paynow-shipping
*/
if ( ! defined( 'WOOMP_PAYNOW_SHIPPING_PLUGIN_URL' ) && 'yes' === get_option( 'wc_woomp_setting_paynow_shipping' ) ) {

define( 'WOOMP_PAYNOW_SHIPPING_PLUGIN_URL', plugin_dir_url( __FILE__ ) . 'includes/woomp-paynow-shipping/' );
define( 'WOOMP_PAYNOW_SHIPPING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) . 'includes/woomp-paynow-shipping/' );
define( 'WOOMP_PAYNOW_SHIPPING_BASENAME', plugin_basename( __FILE__ ) . 'includes/woomp-paynow-shipping/' );
Expand All @@ -303,7 +306,11 @@ function run_paynow_einvoice() {
/**
* 引入支付連
*/
if ( ! in_array( 'PChomePay-Cart-for-WooCommerce/pchomepay.php', WOOMP_ACTIVE_PLUGINS, true ) && ! in_array( 'PChomePay-Cart-for-WooCommerce-master/pchomepay.php', WOOMP_ACTIVE_PLUGINS, true ) ) {
if ( ! in_array(
'PChomePay-Cart-for-WooCommerce/pchomepay.php',
WOOMP_ACTIVE_PLUGINS,
true
) && ! in_array( 'PChomePay-Cart-for-WooCommerce-master/pchomepay.php', WOOMP_ACTIVE_PLUGINS, true ) ) {
require_once WOOMP_PLUGIN_DIR . 'includes/PChomePay-Cart-for-WooCommerce/PChomePay.php';
}

Expand Down Expand Up @@ -339,6 +346,7 @@ function integrate_with_ecpay_ezpay_invoice() {
}
add_filter( 'wc_subscriptions_object_data', 'sync_invoice_data_at_renew_subscription', 100, 4 );
}

\add_action( 'plugins_loaded', 'integrate_with_ecpay_ezpay_invoice' );


Expand All @@ -353,7 +361,6 @@ function integrate_with_ecpay_ezpay_invoice() {
* @return array
*/
function sync_invoice_data_at_renew_subscription( $data, $to_object, $from_object, $copy_type ) {

if ( ! method_exists( $from_object, 'get_meta' ) || ! method_exists( $to_object, 'update_meta_data' ) ) {
return $data;
}
Expand Down Expand Up @@ -385,3 +392,29 @@ function add_payment_description( string $payment_method_id ) {
echo wpautop( wptexturize( $description ) );
}
}


/**
* 套件更新機制
*/
\add_action( 'plugins_loaded', 'woomp_plugin_update_checker', 10 );


function woomp_plugin_update_checker(): void {
try {
$update_checker = YahnisElsts\PluginUpdateChecker\v5\PucFactory::buildUpdateChecker(
'https://github.com/j7-dev/woomp',
WOOMP_PLUGIN_DIR . 'woomp.php',
'woomp'
);
/**
* Type
*
* @var \Puc_v4p4_Vcs_PluginUpdateChecker $update_checker
*/
$update_checker->setBranch( 'master' );
$update_checker->getVcsApi()->enableReleaseAssets();
} catch ( \Throwable $th ) { // phpcs:ignore
// throw $th;
}
}
2 changes: 1 addition & 1 deletion woomp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin Name: 好用版擴充 MorePower Addon for WooCommerce
* Plugin URI: https://morepower.club/morepower-addon/
* Description: WooCommerce 好用版擴充,改善結帳流程與可變商品等區塊,並整合多項金流,讓 WooCommerce 更符合亞洲人使用習慣。
* Version: 3.3.12
* Version: 3.3.13
* Author: MorePower
* Author URI: https://morepower.club
* License: GPL-2.0+
Expand Down

0 comments on commit aefccc9

Please sign in to comment.