\__( 'Settings', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/settings.php', ); if ( $show_welcome_tab ) { $settings_tabs['welcome'] = array( 'label' => \__( 'Welcome', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/welcome.php', ); } $settings_tabs['settings'] = $settings_tab; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ( isset( $_GET['tab'] ) && 'advanced' === $_GET['tab'] ) || $show_advanced_tab ) { $settings_tabs['advanced'] = array( 'label' => \__( 'Advanced', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/advanced-settings.php', ); } // Add blocked actors tab for site-wide blocking. $settings_tabs['blocked-actors'] = array( 'label' => \__( 'Blocked Actors', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/blocked-actors-list.php', ); if ( user_can_activitypub( Actors::BLOG_USER_ID ) ) { $settings_tabs['blog-profile'] = array( 'label' => \__( 'Blog Profile', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/blog-settings.php', ); $settings_tabs['followers'] = array( 'label' => \__( 'Followers', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/followers-list.php', ); if ( '1' === \get_option( 'activitypub_following_ui', '0' ) ) { $settings_tabs['following'] = array( 'label' => \__( 'Following', 'activitypub' ), 'template' => ACTIVITYPUB_PLUGIN_DIR . 'templates/following-list.php', ); } } /** * Filters the tabs displayed in the ActivityPub settings. * * @param array $settings_tabs The tabs to display. */ $settings_tabs = \apply_filters( 'activitypub_admin_settings_tabs', $settings_tabs ); if ( empty( $settings_tabs ) ) { \_doing_it_wrong( __FUNCTION__, 'No settings tabs found. There should be at least one tab to show a settings page.', '7.0.0' ); $settings_tabs['settings'] = $settings_tab; } $tab_keys = \array_keys( $settings_tabs ); $default_tab = \reset( $tab_keys ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $tab = isset( $_GET['tab'] ) ? \sanitize_key( $_GET['tab'] ) : $default_tab; if ( ! isset( $settings_tabs[ $tab ] ) ) { $tab = $default_tab; } switch ( $tab ) { case 'blog-profile': \wp_enqueue_media(); \wp_enqueue_script( 'activitypub-header-image' ); break; case 'settings': \update_option( 'activitypub_checklist_settings_visited', '1' ); break; default: if ( isset( $_GET['help-tab'] ) && 'getting-started' === $_GET['help-tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification \update_option( 'activitypub_checklist_fediverse_intro_visited', '1' ); } elseif ( isset( $_GET['help-tab'] ) && 'editor-blocks' === $_GET['help-tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification \update_option( 'activitypub_checklist_blocks_visited', '1' ); } break; } // Only show tabs if there are more than one. $labels = array(); if ( \count( $settings_tabs ) > 1 ) { $labels = \wp_list_pluck( $settings_tabs, 'label' ); } $args = \array_fill_keys( \array_keys( $labels ), '' ); $args[ $tab ] = 'active'; $args['tabs'] = $labels; \load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/admin-header.php', true, $args ); \load_template( $settings_tabs[ $tab ]['template'] ); } /** * Adds the ActivityPub settings to the Help tab. */ public static function add_settings_help_tab() { // Getting Started / Introduction to the Fediverse. \get_current_screen()->add_help_tab( array( 'id' => 'getting-started', 'title' => \__( 'Getting Started', 'activitypub' ), 'content' => self::get_help_tab_template( 'getting-started' ), ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( 'following' === \sanitize_text_field( \wp_unslash( $_GET['tab'] ?? '' ) ) ) { self::add_following_help_tab(); } // Core Features. \get_current_screen()->add_help_tab( array( 'id' => 'core-features', 'title' => \__( 'Core Features', 'activitypub' ), 'content' => self::get_help_tab_template( 'core-features' ), ) ); // Editor Blocks. \get_current_screen()->add_help_tab( array( 'id' => 'editor-blocks', 'title' => \__( 'Editor Blocks', 'activitypub' ), 'content' => self::get_help_tab_template( 'editor-blocks' ), ) ); // Account Migration. \get_current_screen()->add_help_tab( array( 'id' => 'account-migration', 'title' => \__( 'Account Migration', 'activitypub' ), 'content' => self::get_help_tab_template( 'account-migration' ), ) ); // Show only if templating is enabled. $object_type = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ); if ( 'note' === $object_type ) { // Template Tags. \get_current_screen()->add_help_tab( array( 'id' => 'template-tags', 'title' => \__( 'Template Tags', 'activitypub' ), 'content' => self::get_help_tab_template( 'template-tags' ), ) ); } // Recommended Plugins. if ( ! empty( self::get_recommended_plugins() ) ) { \get_current_screen()->add_help_tab( array( 'id' => 'recommended-plugins', 'title' => \__( 'Recommended Plugins', 'activitypub' ), 'content' => '
' . \esc_html__( 'Enhance your WordPress ActivityPub setup with these hand-picked plugins, each adding unique capabilities for a richer Fediverse experience.', 'activitypub' ) . '
' . self::render_recommended_plugins_list(), ) ); } // Troubleshooting. \get_current_screen()->add_help_tab( array( 'id' => 'troubleshooting', 'title' => \__( 'Troubleshooting', 'activitypub' ), 'content' => self::get_help_tab_template( 'troubleshooting' ), ) ); // Glossary. \get_current_screen()->add_help_tab( array( 'id' => 'glossary', 'title' => \__( 'Glossary', 'activitypub' ), 'content' => self::get_help_tab_template( 'glossary' ), ) ); // Resources. \get_current_screen()->add_help_tab( array( 'id' => 'resources', 'title' => \__( 'Resources', 'activitypub' ), 'content' => self::get_help_tab_template( 'resources' ), ) ); // Enhanced Help Sidebar. \get_current_screen()->set_help_sidebar( '' . \__( 'For more information:', 'activitypub' ) . '
' . "\n" . '' . \esc_html__( 'Get support', 'activitypub' ) . '
' . "\n" . '' . \esc_html__( 'Report an issue', 'activitypub' ) . '
' . "\n" . '' . \esc_html__( 'Documentation', 'activitypub' ) . '
' . "\n" . '' . \esc_html__( 'View latest changes', 'activitypub' ) . '
' ); } /** * Adds the ActivityPub help tab to the users page. */ public static function add_following_help_tab() { \get_current_screen()->add_help_tab( array( 'id' => 'starter-kit', 'title' => \__( 'Starter Kits', 'activitypub' ), 'content' => \sprintf( '%s
' . '%s
', \__( 'Starter Kits', 'activitypub' ), \__( 'Starter kits are curated lists of accounts that help you quickly build your fediverse network. Import a starter kit to automatically follow a collection of interesting accounts in specific topics or communities.', 'activitypub' ), // translators: %s: Importer URL. \wp_kses_post( \sprintf( \__( 'To import a starter kit, go to Tools → Import and look for the “Starter Kit” option.', 'activitypub' ), \admin_url( 'admin.php?import=starter-kit' ) ) ) ), ) ); } /** * Adds the ActivityPub help tab to the users page. */ public static function add_users_help_tab() { \get_current_screen()->add_help_tab( array( 'id' => 'activitypub', 'title' => \__( 'ActivityPub', 'activitypub' ), 'content' => self::get_help_tab_template( 'users' ), // Add to the end of the list. 'priority' => 20, ) ); } /** * Handle 'welcome' query arg. */ public static function handle_welcome_query_arg() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['welcome'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $welcome_checked = empty( \sanitize_text_field( \wp_unslash( $_GET['welcome'] ) ) ) ? 0 : 1; \update_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', $welcome_checked ); \wp_safe_redirect( \admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); exit; } } /** * Handle switching from legacy template mode to automatic object type. * * @since 8.0.0 */ public static function handle_switch_object_type() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $_GET['activitypub_update_object_type'] ) ) { return; } \check_admin_referer( 'activitypub_switch_object_type' ); if ( ! \current_user_can( 'manage_options' ) ) { return; } \update_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE ); \wp_safe_redirect( \admin_url( 'options-general.php?page=activitypub&tab=settings' ) ); exit; } /** * Returns an array of recommended plugins for ActivityPub. */ public static function get_recommended_plugins() { $plugins = array(); if ( ! \is_plugin_active( 'friends/friends.php' ) ) { $plugins['friends'] = array( 'slug' => 'friends', 'author' => 'Alex Kirk', 'author_url' => 'https://profiles.wordpress.org/akirk/', 'icon' => 'https://ps.w.org/friends/assets/icon-256x256.png', 'name' => \__( 'Friends', 'activitypub' ), 'description' => \__( 'Follow people on Mastodon or similar platforms and display their posts on your WordPress, making your site a true Fediverse instance.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=friends&TB_iframe=true' ), ); } if ( ! \is_plugin_active( 'event-bridge-for-activitypub/event-bridge-for-activitypub.php' ) ) { $plugins['event_bridge'] = array( 'slug' => 'event-bridge-for-activitypub', 'author' => 'AndrĂ© Menrath', 'author_url' => 'https://profiles.wordpress.org/andremenrath/', 'icon' => 'https://ps.w.org/event-bridge-for-activitypub/assets/icon-256x256.gif', 'name' => \__( 'Event Bridge for ActivityPub', 'activitypub' ), 'description' => \__( 'Make your events discoverable and federate them across decentralized platforms like Mastodon or Gancio.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=event-bridge-for-activitypub&TB_iframe=true' ), ); } if ( ! \is_plugin_active( 'enable-mastodon-apps/enable-mastodon-apps.php' ) ) { $plugins['enable_mastodon_apps'] = array( 'slug' => 'enable-mastodon-apps', 'author' => 'Alex Kirk', 'author_url' => 'https://profiles.wordpress.org/akirk/', 'icon' => 'https://ps.w.org/enable-mastodon-apps/assets/icon-256x256.png', 'name' => \__( 'Enable Mastodon Apps', 'activitypub' ), 'description' => \__( 'Allow Mastodon apps to interact with your WordPress site, letting you write posts from your favorite app.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=enable-mastodon-apps&TB_iframe=true' ), ); } if ( ! \is_plugin_active( 'hum/hum.php' ) ) { $plugins['hum'] = array( 'slug' => 'hum', 'author' => 'Will Norris', 'author_url' => 'https://profiles.wordpress.org/willnorris/', 'icon' => 'https://s.w.org/plugins/geopattern-icon/hum.svg', 'name' => \__( 'Hum', 'activitypub' ), 'description' => \__( 'A personal URL shortener for WordPress, perfect for sharing short links on the Fediverse.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=hum&TB_iframe=true' ), ); } if ( ! \is_plugin_active( 'webfinger/webfinger.php' ) ) { $plugins['webfinger'] = array( 'slug' => 'webfinger', 'author' => 'Matthias Pfefferle', 'author_url' => 'https://profiles.wordpress.org/pfefferle/', 'icon' => 'https://ps.w.org/webfinger/assets/icon-256x256.png', 'name' => \__( 'WebFinger', 'activitypub' ), 'description' => \__( 'WebFinger protocol support for better discovery and compatibility.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=webfinger&TB_iframe=true' ), ); } if ( ! \is_plugin_active( 'nodeinfo/nodeinfo.php' ) ) { $plugins['nodeinfo'] = array( 'slug' => 'nodeinfo', 'author' => 'Matthias Pfefferle', 'author_url' => 'https://profiles.wordpress.org/pfefferle/', 'icon' => 'https://ps.w.org/nodeinfo/assets/icon-256x256.png', 'name' => \__( 'NodeInfo', 'activitypub' ), 'description' => \__( 'Advanced NodeInfo protocol support for better discovery and compatibility.', 'activitypub' ), 'install_url' => \admin_url( 'plugin-install.php?tab=plugin-information&plugin=nodeinfo&TB_iframe=true' ), ); } return $plugins; } /** * Render recommended plugins as a beautiful, rich showcase for the help tab. */ public static function render_recommended_plugins_list() { $plugins = self::get_recommended_plugins(); \ob_start(); echo '