register(); if ( is_admin() ) { ( new Admin\ConnectionTest() )->register(); ( new Admin\HealthNotice() )->register(); ( new Admin\ProUpsell( self::isPro() ) )->register(); } if ( self::isPro() ) { ( new Premium\Pro() )->register(); } } /** * @param array $methods * @return array */ public static function addShippingMethod( array $methods ): array { $methods[ Shipping\Method::ID ] = Shipping\Method::class; return $methods; } /** * The service code saved on the shipping line is for Maple Parcel, not * the store owner. WooCommerce's order screen shows underscored keys * unless they are on this list. * * @param array $keys * @return array */ public static function hideItemMeta( array $keys ): array { $keys[] = Shipping\Method::META_SERVICE; return $keys; } /** * @param array $links * @return array */ public static function actionLinks( array $links ): array { array_unshift( $links, sprintf( '%s', esc_url( admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=' . Shipping\Method::ID ) ), esc_html__( 'Settings', 'maple-parcel' ) ) ); return $links; } /** * Whether this is the paid build. includes/Premium/ ships only in the * premium zip, and the autoloader requires a file only if it is there, so * in the free build this is simply false; nothing is locked behind it. */ public static function isPro(): bool { return class_exists( Premium\Pro::class ); } public static function activate(): void { // Nothing to set up yet: settings are created on first save. } /** * "Requires Plugins: woocommerce" stops activation without WooCommerce, * but WooCommerce can still be deactivated afterwards. */ public static function missingWooCommerceNotice(): void { if ( ! current_user_can( 'activate_plugins' ) ) { return; } printf( '

%s

', esc_html__( 'Maple Parcel needs WooCommerce to be active. Live rates are switched off until it is.', 'maple-parcel' ) ); } }