AccountClaimMiddleware.php
3 years ago
AdminColorMiddleware.php
2 years ago
ArchiveModelMiddleware.php
2 months ago
BrandColorMiddleware.php
3 years ago
CheckoutFormModeMiddleware.php
2 months ago
CheckoutRedirectMiddleware.php
3 years ago
ComponentAssetsMiddleware.php
3 years ago
CustomerDashboardLinkRedirectMiddleware.php
1 year ago
CustomerDashboardRedirectMiddleware.php
1 year ago
EditModelMiddleware.php
2 months ago
InvoiceRedirectMiddleware.php
1 year ago
LoginLinkMiddleware.php
1 year ago
LoginMiddleware.php
2 years ago
NonceMiddleware.php
3 years ago
OrderRedirectMiddleware.php
3 years ago
PathRedirectMiddleware.php
3 years ago
PaymentFailureRedirectMiddleware.php
3 years ago
ProductReviewRedirectMiddleware.php
4 months ago
PurchaseRedirectMiddleware.php
3 years ago
SubscriptionRedirectMiddleware.php
3 years ago
UpsellMiddleware.php
2 years ago
WebhooksMiddleware.php
1 month ago
ArchiveModelMiddleware.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Middleware; |
| 4 | |
| 5 | use Closure; |
| 6 | use SureCartCore\Requests\RequestInterface; |
| 7 | use SureCartCore\Responses\RedirectResponse; |
| 8 | |
| 9 | /** |
| 10 | * Middleware for handling model archiving. |
| 11 | */ |
| 12 | class ArchiveModelMiddleware { |
| 13 | /** |
| 14 | * Handle the middleware. |
| 15 | * |
| 16 | * @param RequestInterface $request Request. |
| 17 | * @param Closure $next Next. |
| 18 | * @param string $model_name Model name. |
| 19 | * @return function |
| 20 | */ |
| 21 | public function handle( RequestInterface $request, Closure $next, $model_name ) { |
| 22 | // check nonce. |
| 23 | if ( ! $request->query( 'nonce' ) || ! wp_verify_nonce( $request->query( 'nonce' ), "archive_$model_name" ) ) { |
| 24 | wp_die( __( 'Your session expired - please try again.', 'surecart' ) ); |
| 25 | } |
| 26 | |
| 27 | if ( ! current_user_can( "edit_sc_{$model_name}s" ) ) { |
| 28 | wp_die( __( 'You do not have permission to do this.', 'surecart' ) ); |
| 29 | } |
| 30 | |
| 31 | return $next( $request ); |
| 32 | } |
| 33 | } |
| 34 |