| 1 |
<?php |
| 2 |
|
| 3 |
namespace StoreEngine\Shortcode; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
use StoreEngine\Utils\Helper; |
| 10 |
use StoreEngine\Utils\Template; |
| 11 |
use WP_Error; |
| 12 |
|
| 13 |
class OrderDownloads { |
| 14 |
|
| 15 |
public function __construct() { |
| 16 |
add_shortcode( 'storeengine_order_downloads', [ $this, 'render' ] ); |
| 17 |
} |
| 18 |
|
| 19 |
public function render() { |
| 20 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 21 |
$order_hash = isset( $_GET['order_hash'] ) ? sanitize_text_field( wp_unslash( $_GET['order_hash'] ) ) : ''; |
| 22 |
$order = Helper::get_order_by_key( $order_hash ); |
| 23 |
$order = $order instanceof WP_Error ? false : $order; |
| 24 |
|
| 25 |
if ( ! $order ) { |
| 26 |
return ''; |
| 27 |
} |
| 28 |
|
| 29 |
ob_start(); |
| 30 |
Template::get_template( 'shortcode/order-downloads.php', [ |
| 31 |
'downloadable_permissions' => apply_filters( 'storeengine/order/downloadable_permissions', $order->get_downloadable_permissions(), $order ), |
| 32 |
] ); |
| 33 |
|
| 34 |
return ob_get_clean(); |
| 35 |
} |
| 36 |
} |
| 37 |
|