' .
__('CZL Express requires WooCommerce to be installed and active', 'woocommerce-czlexpress') .
'
';
});
return false;
}
if (version_compare(WC_VERSION, '6.0.0', '<')) {
add_action('admin_notices', function() {
echo '' .
__('CZL Express requires WooCommerce 6.0.0 or higher', 'woocommerce-czlexpress') .
'
';
});
return false;
}
return true;
}
// 初始化插件
function woo_czl_express_init() {
if (wc_czlexpress_check_environment()) {
require_once WOO_CZL_EXPRESS_PATH . 'includes/class-woo-czl-express.php';
WooCzlExpress::instance();
}
}
add_action('plugins_loaded', 'woo_czl_express_init');
add_action('woocommerce_order_status_processing', function($order_id) {
$czl_order = new CZL_Order();
$czl_order->create_shipment($order_id);
});
// 在插件停用时清理定时任务
register_deactivation_hook(__FILE__, 'wc_czlexpress_deactivate');
function wc_czlexpress_deactivate() {
$timestamp = wp_next_scheduled('czl_update_tracking_cron');
if ($timestamp) {
wp_unschedule_event($timestamp, 'czl_update_tracking_cron');
}
}