implode( "\n", [ 'Out of stock', 'Damaged item', 'Incorrect item', 'Customer request', 'Fulfilment delay', 'Other', ] ), 'patchwork_split_unable_reasons' => implode( "\n", [ 'Out of stock', 'Item discontinued', 'Cannot fulfil at this time', 'Customer request', 'Other', ] ), 'patchwork_split_parent_when_empty' => 'cancel', 'patchwork_split_shipping_mode' => 'keep', 'patchwork_split_restock_unable' => '1', 'patchwork_split_email_on_split' => '0', 'patchwork_split_email_on_unable' => '1', ]; foreach ( $defaults as $key => $value ) { if ( get_option( $key ) === false ) { update_option( $key, $value ); } } // Grant the capability to the roles that manage orders by default if ( get_option( 'patchwork_split_version' ) === false ) { foreach ( [ 'administrator', 'shop_manager' ] as $role_key ) { $role = get_role( $role_key ); if ( $role ) $role->add_cap( self::CAP ); } } update_option( 'patchwork_split_version', PATCHWORK_SPLIT_VERSION ); } /** * Activation hooks don't run on plugin updates, so compare the stored * version on every load and re-run activation when it changes. */ public static function maybe_upgrade(): void { if ( get_option( 'patchwork_split_version' ) !== PATCHWORK_SPLIT_VERSION ) { self::activate(); } } /** * Runs on plugin deactivation. * We don't delete settings here — that's for uninstall. */ public static function deactivate(): void {} }