modified: README.md
This commit is contained in:
32
support-provisioning-portal/includes/class-spp-shortcode.php
Normal file
32
support-provisioning-portal/includes/class-spp-shortcode.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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'))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user