| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Hooks\Handlers; |
| 4 |
|
| 5 |
class ShortcodeHandler |
| 6 |
{ |
| 7 |
public function fluentSupportPortal($args) |
| 8 |
{ |
| 9 |
if(isset($args['attributes'])) { |
| 10 |
$attributes_value = $args['attributes']; |
| 11 |
$decoded = base64_decode($attributes_value, true); |
| 12 |
if ($decoded !== false && json_decode($decoded) !== null) { |
| 13 |
$args['attributes'] = json_decode($decoded, true); |
| 14 |
} else { |
| 15 |
$args['attributes'] = json_decode($attributes_value, true); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
$args = shortcode_atts( array( |
| 20 |
'show_logout' => 'no', |
| 21 |
'show-signup' => 'true', |
| 22 |
'show-reset-password' => 'true', |
| 23 |
'business_box_id' => $args['business_box_id'] ?? null, |
| 24 |
'attributes' => [], |
| 25 |
), $args ); |
| 26 |
|
| 27 |
if ($args['attributes']) { |
| 28 |
add_filter('fluent_support/customer_portal_vars', function ($vars) use($args) { |
| 29 |
$vars['attributes'] = $args['attributes']; |
| 30 |
return $vars; |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
if($args['show_logout'] == 'yes') { |
| 35 |
add_filter('fluent_support/customer_portal_vars', function ($vars) { |
| 36 |
$vars['show_logout'] = true; |
| 37 |
return $vars; |
| 38 |
}); |
| 39 |
} |
| 40 |
|
| 41 |
if($args['business_box_id']) { |
| 42 |
add_filter('fluent_support/customer_portal_vars', function ($vars) use($args) { |
| 43 |
$vars['mailbox_id'] = wp_strip_all_tags($args['business_box_id']); |
| 44 |
return $vars; |
| 45 |
}); |
| 46 |
} |
| 47 |
|
| 48 |
return (new CustomerPortalHandler)->renderPortal($args); |
| 49 |
} |
| 50 |
} |
| 51 |
|