Changeset 3447932
- Timestamp:
- 01/27/2026 01:49:33 PM (2 months ago)
- Location:
- shipi
- Files:
-
- 15 added
- 2 edited
-
tags/1.3.1 (added)
-
tags/1.3.1/assets (added)
-
tags/1.3.1/assets/css (added)
-
tags/1.3.1/assets/css/admin.css (added)
-
tags/1.3.1/assets/img (added)
-
tags/1.3.1/assets/img/shipi-20px.png (added)
-
tags/1.3.1/assets/img/shipi_100px.png (added)
-
tags/1.3.1/assets/js (added)
-
tags/1.3.1/assets/js/admin.js (added)
-
tags/1.3.1/includes (added)
-
tags/1.3.1/includes/rest-api.php (added)
-
tags/1.3.1/includes/shipping-class.php (added)
-
tags/1.3.1/index.php (added)
-
tags/1.3.1/readme.txt (added)
-
tags/1.3.1/shipi.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/shipi.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shipi/trunk/readme.txt
r3409924 r3447932 3 3 Tags: WooCommerce shipping, shipping label, shipping rates, DHL, FedEx, UPS, carrier integration, live rates, WooCommerce 4 4 Requires at least: 4.0.1 5 Tested up to: 6.8 6 Stable tag: 1.3.0 7 Requires PHP: 5.6 5 Tested up to: 6.9 6 Stable tag: 1.3.1 7 Requires PHP: 5.6 8 Network: true 8 9 License: GPLv3 or later 9 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 76 77 Yes. Shipi automatically tracks shipment progress and updates WooCommerce order status accordingly. 77 78 79 = Does Shipi support WordPress Multisite? = 80 Yes! Shipi is fully compatible with WordPress Multisite networks. You can network-activate the plugin or activate it on individual sites. Each site in your network can have its own Shipi account connection and configuration. Settings, integration keys, and shipping data are stored separately for each site. 81 78 82 == Third-Party Services == 79 83 … … 96 100 97 101 == Changelog == 102 103 = 1.3.1 = 104 * Added WordPress Multisite support 105 * Improved WooCommerce detection for multisite networks 106 * Added activation/deactivation hooks 107 * Added automatic initialization for new sites in network-activated scenarios 98 108 99 109 = 1.3.0 = -
shipi/trunk/shipi.php
r3409924 r3447932 3 3 * Plugin Name: Shipi 4 4 * Description: 15+ Shipping carriers in one package. 5 * Version: 1.3. 05 * Version: 1.3.1 6 6 * Author: Shipi 7 7 * Author URI: https://myshipi.com/ … … 30 30 ); 31 31 32 // Helper function to check if WooCommerce is active (multisite-aware) 33 function shipi_is_woocommerce_active() { 34 // Check if WooCommerce class exists (most reliable method) 35 if ( class_exists( 'WooCommerce' ) ) { 36 return true; 37 } 38 39 // Load plugin.php if needed for is_plugin_active function 40 if ( ! function_exists( 'is_plugin_active' ) ) { 41 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 42 } 43 44 // Check if plugin is active (multisite-aware function) 45 if ( function_exists( 'is_plugin_active' ) ) { 46 if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 47 return true; 48 } 49 } 50 51 // Fallback: Check active plugins (site-specific) 52 $active_plugins = get_option( 'active_plugins', array() ); 53 if ( in_array( 'woocommerce/woocommerce.php', $active_plugins ) ) { 54 return true; 55 } 56 57 // Check network-active plugins in multisite 58 if ( is_multisite() ) { 59 $network_active_plugins = get_site_option( 'active_sitewide_plugins', array() ); 60 if ( isset( $network_active_plugins['woocommerce/woocommerce.php'] ) ) { 61 return true; 62 } 63 } 64 65 return false; 66 } 67 32 68 // check is woocommerce is installed already. 33 if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) )) ) {69 if ( shipi_is_woocommerce_active() ) { 34 70 if( !class_exists('shipi_Parent') ){ 35 71 Class shipi_Parent { … … 1048 1084 new shipi_Parent(); 1049 1085 } 1086 1087 /** 1088 * Activation hook for single-site activation 1089 * Note: For network activation, this runs for each site individually 1090 */ 1091 function shipi_activate( $network_wide = false ) { 1092 // If network activation, we'll handle each site separately via wp_initialize_site 1093 if ( $network_wide && is_multisite() ) { 1094 // For network activation, just flush rewrite rules network-wide 1095 // Individual site initialization happens in shipi_new_site_init 1096 return; 1097 } 1098 1099 // For single-site activation, check WooCommerce 1100 if ( ! shipi_is_woocommerce_active() ) { 1101 deactivate_plugins( plugin_basename( __FILE__ ) ); 1102 wp_die( 1103 esc_html__( 'Shipi requires WooCommerce to be installed and active. Please install and activate WooCommerce first.', 'shipi' ), 1104 esc_html__( 'Plugin Activation Error', 'shipi' ), 1105 array( 'back_link' => true ) 1106 ); 1107 } 1108 1109 // Clear any transients 1110 delete_transient( 'shipi_nonce_temp' ); 1111 1112 // Flush rewrite rules for REST API 1113 flush_rewrite_rules(); 1114 } 1115 1116 /** 1117 * Deactivation hook 1118 */ 1119 function shipi_deactivate() { 1120 // Clear transients on deactivation 1121 delete_transient( 'shipi_nonce_temp' ); 1122 1123 // Flush rewrite rules 1124 flush_rewrite_rules(); 1125 } 1126 1127 /** 1128 * Initialize plugin on new site creation (for network-activated plugins) 1129 */ 1130 function shipi_new_site_init( $site ) { 1131 if ( ! function_exists( 'is_plugin_active_for_network' ) ) { 1132 require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); 1133 } 1134 1135 // Only initialize if plugin is network-activated 1136 if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { 1137 switch_to_blog( $site->blog_id ); 1138 1139 // Check if WooCommerce is active on this site 1140 if ( shipi_is_woocommerce_active() ) { 1141 // Plugin will auto-initialize when WooCommerce is detected 1142 // No additional setup needed as the main class handles initialization 1143 } 1144 1145 restore_current_blog(); 1146 } 1147 } 1148 1149 // Register activation hook 1150 register_activation_hook( __FILE__, 'shipi_activate' ); 1151 1152 // Register deactivation hook 1153 register_deactivation_hook( __FILE__, 'shipi_deactivate' ); 1154 1155 // Hook into new site creation for network-activated plugins 1156 if ( is_multisite() ) { 1157 add_action( 'wp_initialize_site', 'shipi_new_site_init', 10, 1 ); 1158 }
Note: See TracChangeset
for help on using the changeset viewer.