| 1 |
<?php |
| 2 |
|
| 3 |
namespace Booktics\Shortcode; |
| 4 |
|
| 5 |
/** |
| 6 |
* Customer shortcode class |
| 7 |
*/ |
| 8 |
class Customer_Shortcode { |
| 9 |
/** |
| 10 |
* Constructor for customer shortcode |
| 11 |
* |
| 12 |
* @return void |
| 13 |
*/ |
| 14 |
public function __construct() { |
| 15 |
add_shortcode( 'booktics_customer_panel', array( $this, 'render_customer_panel' ) ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Render customer panel |
| 20 |
* |
| 21 |
* @param array $attributes |
| 22 |
* |
| 23 |
* @return string |
| 24 |
*/ |
| 25 |
public function render_customer_panel( $attributes ) { |
| 26 |
|
| 27 |
wp_enqueue_style( 'booktics-vendor' ); |
| 28 |
wp_enqueue_style( 'booktics-frontend' ); |
| 29 |
|
| 30 |
wp_enqueue_script( 'booktics-packages' ); |
| 31 |
wp_enqueue_script( 'booktics-frontend-scripts' ); |
| 32 |
|
| 33 |
// Check if user is logged in |
| 34 |
if ( ! is_user_logged_in() ) { |
| 35 |
$login_url = wp_login_url( get_permalink() ); |
| 36 |
return '<div class="booktics-login-required"> |
| 37 |
<h3>Customer Portal Access</h3> |
| 38 |
<p>Please login to access your booking history.</p> |
| 39 |
<a href="' . esc_url( $login_url ) . '" class="booktics-login-btn">Login</a> |
| 40 |
</div>'; |
| 41 |
} |
| 42 |
|
| 43 |
// Return container for React app |
| 44 |
return '<div id="booktics-customer-dashboard" |
| 45 |
data-user-id="' . get_current_user_id() . '"> |
| 46 |
</div>'; |
| 47 |
} |
| 48 |
} |