@hizzlewp/store-ui
v1.3.5
Published
This package displays data provided by the `@hizzlewp/store` package.
Downloads
210
Readme
Store UI
This package displays data provided by the @hizzlewp/store package.
Installation
npm install @hizzlewp/store-ui
composer require hizzlewp/storeUsage
use Hizzle\Store\UI\CollectionProvider;
class MyClass {
private static $hook_suffix;
public function __construct() {
add_action( 'admin_menu', [ __CLASS__, 'add_admin_menu' ] );
add_action( 'admin_enqueue_scripts', [ __CLASS__, 'enqueue_scripts' ] );
}
public static function add_admin_menu() {
self::$hook_suffix = add_menu_page(
'My Plugin',
'My Plugin',
'manage_options',
'my-plugin',
[ __CLASS__, 'render_admin_page' ]
);
}
public static function render_admin_page() {
// Check permission.
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'hizzlewp' ) );
}
// Render the page.
echo '<div id="hizzlewp-store-ui"></div>';
}
public static function enqueue_scripts() {
if ( self::$hook_suffix !== get_current_screen()->id ) {
return;
}
wp_enqueue_script( 'hizzlewp-store-ui' );
wp_localize_script( 'hizzlewp-store-ui', 'hizzlewpStoreUi', [
'namespace' => 'noptin',
'collection' => 'subscribers',
] );
}
}