map( invoke( $method ) ) ->getOrElse( $default ); } /** * @param string $wcClass * * @return mixed|object|null */ private static function getFromContainer( $wcClass ) { try { $object = \wc_get_container()->get( $wcClass ); } catch ( \Exception $e ) { return null; } return $object; } /** * Checks if the current screen is an admin screen for WooCommerce HPOS * * @param string|null $action * @return bool */ private static function isOrderAdminScreen( $action ) { return is_admin() && Obj::prop( 'page', $_GET ) === self::WC_ORDERS && Obj::prop( 'action', $_GET ) === $action; } /** * Checks if the current screen is an admin screen for WooCommerce New Order with the HPOS. * * @return bool */ public static function isOrderCreateAdminScreen() { return self::isOrderAdminScreen( 'new' ); } /** * Checks if the current screen is an admin screen for list of WooCommerce orders with the HPOS. * * @return bool */ public static function isOrderListAdminScreen() { return self::isOrderAdminScreen( null ); } /** * Checks if the current screen is an admin screen for WooCommerce Edit Order with the HPOS. * * @return bool */ public static function isOrderEditAdminScreen() { return self::isOrderAdminScreen( 'edit' ) && isset( $_GET['id'] ); } }