PATCHWORK_LOCATIONS_FS_ID, 'slug' => 'patchwork-locations', 'type' => 'plugin', 'public_key' => PATCHWORK_LOCATIONS_FS_KEY, 'is_premium' => false, 'has_addons' => false, 'has_paid_plans' => false, 'is_org_compliant' => true, 'menu' => [ 'slug' => 'patchwork-locations', 'parent' => [ 'slug' => 'patchwork', ], 'account' => false, 'contact' => false, 'support' => false, 'pricing' => false, 'addons' => false, ], 'is_live' => true, ] ); } return $patchwork_locations_fs; } patchwork_locations_fs(); patchwork_locations_fs()->add_action( 'after_uninstall', 'patchwork_locations_uninstall' ); do_action( 'patchwork_locations_fs_loaded' ); } /** * Runs when the plugin is deleted (through Freemius, so it can record the uninstall). Removes settings only. Locations, * the stock at each location and each order's location are kept on purpose, so * reinstalling picks up where you left off; WooCommerce's own stock is never changed. */ function patchwork_locations_uninstall() { foreach ( ['patchwork_locations_default', 'patchwork_locations_checkout', 'patchwork_locations_checkout_label'] as $option ) { delete_option( $option ); } } // ─── Patchwork Core (shared dashboard; the newest copy across plugins loads) ─ require_once PATCHWORK_LOCATIONS_DIR . 'lib/patchwork-core/bootstrap.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-locations.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-stock.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-orders.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-checkout.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-product-admin.php'; require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-split-bridge.php'; // The post type is needed even before WooCommerce is checked (e.g. on activation). \Patchwork\Locations\Locations::init(); add_action( 'plugins_loaded', function () { if ( !class_exists( 'WooCommerce' ) ) { add_action( 'admin_notices', function () { echo '

'; echo esc_html__( 'Patchwork Locations requires WooCommerce to be installed and active.', 'patchwork-locations' ); echo '

'; } ); return; } require_once PATCHWORK_LOCATIONS_DIR . 'includes/class-module.php'; // extends a core class, so load after the core \Patchwork\Core\Core::instance()->register( new \Patchwork\Locations\Module() ); \Patchwork\Locations\Stock::init(); \Patchwork\Locations\Orders::init(); \Patchwork\Locations\Checkout::init(); \Patchwork\Locations\Product_Admin::init(); \Patchwork\Locations\Split_Bridge::init(); } ); register_activation_hook( __FILE__, function () { \Patchwork\Locations\Locations::register_post_type(); flush_rewrite_rules( false ); } );