| 1 |
<?php |
| 2 |
namespace SureCartBlocks\Controllers; |
| 3 |
|
| 4 |
use SureCart\Models\Component; |
| 5 |
use SureCart\Models\Customer; |
| 6 |
use SureCart\Models\User; |
| 7 |
|
| 8 |
/** |
| 9 |
* Payment method block controller class. |
| 10 |
*/ |
| 11 |
class UserController extends BaseController { |
| 12 |
/** |
| 13 |
* List all payment methods. |
| 14 |
* |
| 15 |
* @param array $attributes Block attributes. |
| 16 |
* @param string $content Block content. |
| 17 |
* |
| 18 |
* @return function |
| 19 |
*/ |
| 20 |
public function show( $attributes, $content ) { |
| 21 |
$user = wp_get_current_user(); |
| 22 |
if ( ! $user ) { |
| 23 |
return ''; |
| 24 |
} |
| 25 |
$data = get_userdata( $user->ID ); |
| 26 |
|
| 27 |
return wp_kses_post( |
| 28 |
Component::tag( 'sc-wordpress-user' ) |
| 29 |
->id( 'wordpress-user-edit' ) |
| 30 |
->with( |
| 31 |
[ |
| 32 |
'heading' => $attributes['title'] ?? __( 'Account Details', 'surecart' ), |
| 33 |
'user' => [ |
| 34 |
'display_name' => $user->display_name, |
| 35 |
'email' => $user->user_email, |
| 36 |
'first_name' => $data->user_firstname, |
| 37 |
'last_name' => $data->user_lastname, |
| 38 |
], |
| 39 |
] |
| 40 |
)->render() |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Show a view to add a payment method. |
| 46 |
* |
| 47 |
* @return function |
| 48 |
*/ |
| 49 |
public function edit() { |
| 50 |
$user = wp_get_current_user(); |
| 51 |
if ( ! $user ) { |
| 52 |
return ''; |
| 53 |
} |
| 54 |
$data = get_userdata( $user->ID ); |
| 55 |
$back = add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 56 |
ob_start(); ?> |
| 57 |
|
| 58 |
<sc-spacing style="--spacing: var(--sc-spacing-large)"> |
| 59 |
<sc-breadcrumbs> |
| 60 |
<sc-breadcrumb href="<?php echo esc_url( $back ); ?>"> |
| 61 |
<?php esc_html_e( 'Dashboard', 'surecart' ); ?> |
| 62 |
</sc-breadcrumb> |
| 63 |
<sc-breadcrumb> |
| 64 |
<?php esc_html_e( 'Account Details', 'surecart' ); ?> |
| 65 |
</sc-breadcrumb> |
| 66 |
</sc-breadcrumbs> |
| 67 |
|
| 68 |
<?php |
| 69 |
echo wp_kses_post( |
| 70 |
Component::tag( 'sc-wordpress-user-edit' ) |
| 71 |
->id( 'wordpress-user-edit' ) |
| 72 |
->with( |
| 73 |
[ |
| 74 |
'heading' => $attributes['title'] ?? __( 'Update Account Details', 'surecart' ), |
| 75 |
'user' => [ |
| 76 |
'id' => $user->ID, |
| 77 |
'display_name' => $user->display_name, |
| 78 |
'email' => $user->user_email, |
| 79 |
'first_name' => $data->user_firstname, |
| 80 |
'last_name' => $data->user_lastname, |
| 81 |
], |
| 82 |
'successUrl' => esc_url_raw( $back ), |
| 83 |
] |
| 84 |
)->render() |
| 85 |
); |
| 86 |
|
| 87 |
?> |
| 88 |
|
| 89 |
<?php |
| 90 |
echo wp_kses_post( |
| 91 |
Component::tag( 'sc-wordpress-password-edit' ) |
| 92 |
->id( 'wordpress-password-edit' ) |
| 93 |
->with( |
| 94 |
[ |
| 95 |
'heading' => $attributes['title'] ?? __( 'Update Password', 'surecart' ), |
| 96 |
'user' => [ |
| 97 |
'id' => $user->ID, |
| 98 |
'display_name' => $user->display_name, |
| 99 |
'email' => $user->user_email, |
| 100 |
'first_name' => $data->user_firstname, |
| 101 |
'last_name' => $data->user_lastname, |
| 102 |
], |
| 103 |
'successUrl' => esc_url_raw( $back ), |
| 104 |
] |
| 105 |
)->render() |
| 106 |
); |
| 107 |
|
| 108 |
?> |
| 109 |
</sc-spacing> |
| 110 |
|
| 111 |
<?php |
| 112 |
return ob_get_clean(); |
| 113 |
} |
| 114 |
} |
| 115 |
|