33 lines
926 B
PHP
33 lines
926 B
PHP
<?php
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
final class SPP_Shortcode
|
|
{
|
|
public function register_hooks(): void
|
|
{
|
|
add_shortcode('support_provisioning_portal', [$this, 'render']);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $atts
|
|
*/
|
|
public function render(array $atts = []): string
|
|
{
|
|
if (!is_user_logged_in()) {
|
|
return '<p class="spp-login-required">Please sign in to access the provisioning portal.</p>';
|
|
}
|
|
|
|
wp_enqueue_style('spp-portal', SPP_PLUGIN_URL . 'assets/portal.css', [], SPP_VERSION);
|
|
wp_enqueue_script('spp-portal', SPP_PLUGIN_URL . 'assets/portal.js', [], SPP_VERSION, true);
|
|
|
|
return sprintf(
|
|
'<div id="spp-portal-root" class="spp-portal" data-rest-url="%s" data-nonce="%s"></div>',
|
|
esc_url_raw(rest_url('support-provisioning/v1')),
|
|
esc_attr(wp_create_nonce('wp_rest'))
|
|
);
|
|
}
|
|
}
|