\get_rest_url( null, ACTIVITYPUB_REST_NAMESPACE . '/admin/stats/' . Actors::BLOG_USER_ID ), 'userStatsUrl' => \get_rest_url( null, ACTIVITYPUB_REST_NAMESPACE . '/admin/stats/' ), ) ); \wp_enqueue_style( 'activitypub-dashboard-stats', \plugins_url( 'build/dashboard-stats/style-index.css', ACTIVITYPUB_PLUGIN_FILE ), array( 'wp-components' ), $asset['version'] ); // Add inline script to initialize the widget. \wp_add_inline_script( 'activitypub-dashboard-stats', 'wp.domReady( function() { if ( activitypub && activitypub.dashboardStats ) { activitypub.dashboardStats.initialize( "activitypub-stats-widget-root" ); } } );' ); } /** * Check if the current user can see the stats widget. * * @return bool True if user has access. */ private static function user_can_see_stats() { $has_user_access = user_can_activitypub( \get_current_user_id() ) && ! is_user_type_disabled( 'user' ); $has_blog_access = ! is_user_type_disabled( 'blog' ) && \current_user_can( 'manage_options' ); return $has_user_access || $has_blog_access; } /** * Render the ActivityPub.blog news feed widget. */ public static function render_news_widget() { echo '
'; } /** * Render the ActivityPub Author profile widget. */ public static function render_author_profile_widget() { $user = Actors::get_by_id( \get_current_user_id() ); ?>
'; } }