render_view('support-dashboard-widget.php'); } /** * Render a view * * @param String $view_file The filename of the view to render. * @param Boolean $admin_only Only display the view to users with the manage_options capability. * * @return Boolean True if the user has access to the view. False if not. */ public function render_view(string $view_file, bool $admin_only = true): bool { if ( true === $admin_only && current_user_can('manage_options') || false === $admin_only ) { require self::view_path($view_file); return true; } return false; } /** * Get full file path for a view * * @param String $view_file The view file name. * * @return String The path. */ private function view_path(string $view_file): string { return plugin_dir_path(__FILE__) . self::VIEWS_DIR . $view_file; } /** * Enqueue the 1984 wp-admin scripts */ public function enqueue_admin_scripts() { wp_enqueue_script( '1984-hosting-support-admin', plugins_url( 'js/1984-hosting-support.js', __FILE__ ), array(), HostingSupport1984::HOSTING_SUPPORT_VERSION, true ); wp_enqueue_style( '1984-hosting-support-admin', plugins_url( 'style/1984-hosting-support.css', __FILE__ ), array(), HostingSupport1984::HOSTING_SUPPORT_VERSION, false ); } /** * Check if the user can see the 1984 admin panel * * @return bool [type] [description] */ private function current_user_can_view_admin_panel(): bool { return (true === current_user_can('manage_options')); } } $hosting_support_1984_ui = new HostingSupport1984UI();