From fba834b15df844b196d1ed6b067423c3e9788554 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 18:22:08 +0100 Subject: [PATCH 01/46] add some guidance based on the feedback of users and the suggestion of @akirk --- README.md | 2 +- activitypub.php | 3 +- assets/css/admin.css | 46 ++++++++++++++++++++++++++ includes/class-admin.php | 48 +++++++++++++++------------ includes/class-webfinger.php | 29 +++++++++++++++++ includes/functions.php | 9 +---- includes/help.php | 56 ++++++++++++++++++++++++++++++++ includes/rest/class-nodeinfo.php | 8 ----- templates/admin-header.php | 16 +++++++++ templates/settings.php | 16 ++++----- templates/welcome.php | 23 +++++++++++++ 11 files changed, 208 insertions(+), 48 deletions(-) create mode 100644 assets/css/admin.css create mode 100644 includes/class-webfinger.php create mode 100644 includes/help.php create mode 100644 templates/admin-header.php create mode 100644 templates/welcome.php diff --git a/README.md b/README.md index 6ff1117d..56a6576a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ActivityPub # -**Contributors:** [pfefferle](https://profiles.wordpress.org/pfefferle), [mediaformat](https://profiles.wordpress.org/mediaformat) +**Contributors:** [pfefferle](https://profiles.wordpress.org/pfefferle/), [mediaformat](https://profiles.wordpress.org/mediaformat/) **Donate link:** https://notiz.blog/donate/ **Tags:** OStatus, fediverse, activitypub, activitystream **Requires at least:** 4.7 diff --git a/activitypub.php b/activitypub.php index d802cd7b..58adc9cb 100644 --- a/activitypub.php +++ b/activitypub.php @@ -25,6 +25,7 @@ function init() { require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php'; require_once \dirname( __FILE__ ) . '/includes/class-signature.php'; + require_once \dirname( __FILE__ ) . '/includes/class-webfinger.php'; require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php'; require_once \dirname( __FILE__ ) . '/includes/functions.php'; @@ -107,7 +108,7 @@ function add_rewrite_rules() { \add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' ); } - if ( ! \class_exists( 'Nodeinfo' ) ) { + if ( ! \class_exists( 'Nodeinfo' ) || ! get_option( 'blog_public' ) ) { \add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' ); \add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' ); } diff --git a/assets/css/admin.css b/assets/css/admin.css new file mode 100644 index 00000000..7210a024 --- /dev/null +++ b/assets/css/admin.css @@ -0,0 +1,46 @@ +.activitypub-settings-header { + text-align: center; + margin: 0 0 1rem; + background: #fff; + border-bottom: 1px solid #dcdcde; +} + +.activitypub-settings-title-section { + display: flex; + align-items: center; + justify-content: center; + clear: both; + padding-top: 8px; +} + +.settings_page_activitypub #wpcontent, +.settings_page_activitypub-settings #wpcontent { + padding-left: 0; +} + +.activitypub-settings-tabs-wrapper { + display: -ms-inline-grid; + -ms-grid-columns: 1fr 1fr; + vertical-align: top; + display: inline-grid; + grid-template-columns: 1fr 1fr; +} + +.activitypub-settings-tab.active { + box-shadow: inset 0 -3px #3582c4; + font-weight: 600; +} + +.activitypub-settings-tab { + display: block; + text-decoration: none; + color: inherit; + padding: .5rem 1rem 1rem; + margin: 0 1rem; + transition: box-shadow .5s ease-in-out; +} + +.wp-header-end { + visibility: hidden; + margin: -2px 0 0; +} diff --git a/includes/class-admin.php b/includes/class-admin.php index 9e1eedb8..dd00350a 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -14,21 +14,32 @@ class Admin { \add_action( 'admin_menu', array( '\Activitypub\Admin', 'admin_menu' ) ); \add_action( 'admin_init', array( '\Activitypub\Admin', 'register_settings' ) ); \add_action( 'show_user_profile', array( '\Activitypub\Admin', 'add_fediverse_profile' ) ); + \add_action( 'admin_enqueue_scripts', array( '\Activitypub\Admin', 'admin_style' ) ); } /** * Add admin menu entry */ public static function admin_menu() { - $settings_page = \add_options_page( - 'ActivityPub', + $settings_page = \add_submenu_page( + null, + 'ActivityPub Settings', 'ActivityPub', 'manage_options', - 'activitypub', + 'activitypub-settings', array( '\Activitypub\Admin', 'settings_page' ) ); + $welcome_page = \add_options_page( + 'Welcome', + 'ActivityPub', + 'manage_options', + 'activitypub', + array( '\Activitypub\Admin', 'welcome_page' ) + ); + \add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) ); + \add_action( 'load-' . $welcome_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) ); $followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) ); @@ -42,6 +53,13 @@ class Admin { \load_template( \dirname( __FILE__ ) . '/../templates/settings.php' ); } + /** + * Load welcome page + */ + public static function welcome_page() { + \load_template( \dirname( __FILE__ ) . '/../templates/welcome.php' ); + } + /** * Load user settings page */ @@ -122,23 +140,7 @@ class Admin { } public static function add_settings_help_tab() { - \get_current_screen()->add_help_tab( - array( - 'id' => 'overview', - 'title' => \__( 'Overview', 'activitypub' ), - 'content' => - '

' . \__( 'ActivityPub is a decentralized social networking protocol based on the ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended standard published by the W3C Social Web Working Group. It provides a client to server API for creating, updating and deleting content, as well as a federated server to server API for delivering notifications and subscribing to content.', 'activitypub' ) . '

', - ) - ); - - \get_current_screen()->set_help_sidebar( - '

' . \__( 'For more information:', 'activitypub' ) . '

' . - '

' . \__( 'Test Suite', 'activitypub' ) . '

' . - '

' . \__( 'W3C Spec', 'activitypub' ) . '

' . - '

' . \__( 'Give us feedback', 'activitypub' ) . '

' . - '
' . - '

' . \__( 'Donate', 'activitypub' ) . '

' - ); + require_once \dirname( __FILE__ ) . '/help.php'; } public static function add_followers_list_help_tab() { @@ -147,8 +149,12 @@ class Admin { public static function add_fediverse_profile( $user ) { ?> -

+

ID ); } + + public static function admin_style() { + wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '../assets/css/admin.css' ); + } } diff --git a/includes/class-webfinger.php b/includes/class-webfinger.php new file mode 100644 index 00000000..659470e5 --- /dev/null +++ b/includes/class-webfinger.php @@ -0,0 +1,29 @@ +user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST ); + } +} diff --git a/includes/functions.php b/includes/functions.php index 3c33664d..89942563 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -95,14 +95,7 @@ function safe_remote_get( $url, $user_id ) { * @return string The user-resource */ function get_webfinger_resource( $user_id ) { - // use WebFinger plugin if installed - if ( \function_exists( '\get_webfinger_resource' ) ) { - return \get_webfinger_resource( $user_id, false ); - } - - $user = \get_user_by( 'id', $user_id ); - - return $user->user_login . '@' . \wp_parse_url( \home_url(), \PHP_URL_HOST ); + return \Activitypub\Webfinger::get_resource( $user_id ); } /** diff --git a/includes/help.php b/includes/help.php new file mode 100644 index 00000000..632b1899 --- /dev/null +++ b/includes/help.php @@ -0,0 +1,56 @@ +add_help_tab( + array( + 'id' => 'fediverse', + 'title' => \__( 'Fediverse', 'activitypub' ), + 'content' => + '

' . \__( 'What is the Fediverse?', 'activitypub' ) . '

' . + '

' . \__( 'The Fediverse is a new word made of two words: "federation" + "universe"', 'activitypub' ) . '

' . + '

' . \__( 'It is a federated social network running on free open software on a myriad of computers across the globe. Many independent servers are interconnected and allow people to interact with one another. There\'s no one central site: you choose a server to register. This ensures some decentralization and sovereignty of data. Fediverse (also called Fedi) has no built-in advertisements, no tricky algorithms, no one big corporation dictating the rules. Instead we have small cozy communities of like-minded people. Welcome!', 'activitypub' ) . '

' . + '

' . \__( 'For more informations please visit fediverse.party', 'activitypub' ) . '

', + ) +); + +\get_current_screen()->add_help_tab( + array( + 'id' => 'activitypub', + 'title' => \__( 'ActivityPub', 'activitypub' ), + 'content' => + '

' . \__( 'What is ActivityPub?', 'activitypub' ) . '

' . + '

' . \__( 'ActivityPub is a decentralized social networking protocol based on the ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended standard published by the W3C Social Web Working Group. It provides a client to server API for creating, updating and deleting content, as well as a federated server to server API for delivering notifications and subscribing to content.', 'activitypub' ) . '

', + ) +); + +\get_current_screen()->add_help_tab( + array( + 'id' => 'webfinger', + 'title' => \__( 'WebFinger', 'activitypub' ), + 'content' => + '

' . \__( 'What is WebFinger?', 'activitypub' ) . '

' . + '

' . \__( 'WebFinger is used to discover information about people or other entities on the Internet that are identified by a URI using standard Hypertext Transfer Protocol (HTTP) methods over a secure transport. A WebFinger resource returns a JavaScript Object Notation (JSON) object describing the entity that is queried. The JSON object is referred to as the JSON Resource Descriptor (JRD).', 'activitypub' ) . '

' . + '

' . \__( 'For a person, the type of information that might be discoverable via WebFinger includes a personal profile address, identity service, telephone number, or preferred avatar. For other entities on the Internet, a WebFinger resource might return JRDs containing link relations that enable a client to discover, for example, that a printer can print in color on A4 paper, the physical location of a server, or other static information.', 'activitypub' ) . '

' . + '

' . \__( 'On Mastodon [and other Plattforms], user profiles can be hosted either locally on the same website as yours, or remotely on a completely different website. The same username may be used on a different domain. Therefore, a Mastodon user\'s full mention consists of both the username and the domain, in the form @username@domain. In practical terms, @user@example.com is not the same as @user@example.org. If the domain is not included, Mastodon will try to find a local user named @username. However, in order to deliver to someone over ActivityPub, the @username@domain mention is not enough – mentions must be translated to an HTTPS URI first, so that the remote actor\'s inbox and outbox can be found. (This paragraph is copied from the Mastodon Documentation)', 'activitypub' ) . '

' . + '

' . \__( 'For more informations please visit webfinger.net', 'activitypub' ) . '

', + ) +); + +\get_current_screen()->add_help_tab( + array( + 'id' => 'nodeinfo', + 'title' => \__( 'NodeInfo', 'activitypub' ), + 'content' => + '

' . \__( 'What is NodeInfo?', 'activitypub' ) . '

' . + '

' . \__( 'NodeInfo is an effort to create a standardized way of exposing metadata about a server running one of the distributed social networks. The two key goals are being able to get better insights into the user base of distributed social networking and the ability to build tools that allow users to choose the best fitting software and server for their needs.', 'activitypub' ) . '

' . + '

' . \__( 'For more informations please visit nodeinfo.diaspora.software', 'activitypub' ) . '

', + ) +); + +\get_current_screen()->set_help_sidebar( + '

' . \__( 'For more information:', 'activitypub' ) . '

' . + '

' . \__( 'Test Suite', 'activitypub' ) . '

' . + '

' . \__( 'W3C Spec', 'activitypub' ) . '

' . + '

' . \__( 'Give us feedback', 'activitypub' ) . '

' . + '
' . + '

' . \__( 'Donate', 'activitypub' ) . '

' +); diff --git a/includes/rest/class-nodeinfo.php b/includes/rest/class-nodeinfo.php index d4b394fa..e2ae5b40 100644 --- a/includes/rest/class-nodeinfo.php +++ b/includes/rest/class-nodeinfo.php @@ -95,10 +95,6 @@ class Nodeinfo { 'outbound' => array(), ); - $nodeinfo['metadata'] = array( - 'email' => \get_option( 'admin_email' ), - ); - return new \WP_REST_Response( $nodeinfo, 200 ); } @@ -140,10 +136,6 @@ class Nodeinfo { 'outbound' => array(), ); - $nodeinfo['metadata'] = array( - 'email' => \get_option( 'admin_email' ), - ); - return new \WP_REST_Response( $nodeinfo, 200 ); } diff --git a/templates/admin-header.php b/templates/admin-header.php new file mode 100644 index 00000000..68d5e279 --- /dev/null +++ b/templates/admin-header.php @@ -0,0 +1,16 @@ +
+
+

ActivityPub

+
+ + +
+
diff --git a/templates/settings.php b/templates/settings.php index 5a4ba9dc..6e8d9805 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,12 +1,14 @@ -
-

+ 'active', 'welcome' => '' ) ); ?> -

+
+

+ +

-

+

@@ -104,7 +106,7 @@ -

+

@@ -127,8 +129,4 @@
- -

- donation?', 'activitypub' ); ?> -

diff --git a/templates/welcome.php b/templates/welcome.php new file mode 100644 index 00000000..ffff3e20 --- /dev/null +++ b/templates/welcome.php @@ -0,0 +1,23 @@ + '', 'welcome' => 'active' ) ); ?> + +
+

+ +

+

+ %s or the URL %s. Users, that can not access this settings page, will find their username on the Edit Profile page.', + 'activitypub' + ), + \Activitypub\get_webfinger_resource( wp_get_current_user()->ID ), + \get_author_posts_url( wp_get_current_user()->ID ), + \admin_url( 'profile.php#fediverse' ) + ); + ?> +

+

Site Health to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ), admin_url( '/wp-admin/site-health.php' ) ); ?>

+
+

Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress, thus making your own WordPress a Mastodon instance of its own.', 'activitypub' ); ?>

+
From 0a1e5c13f35cc6f736b67585b47d1864c48a56dc Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 18:24:14 +0100 Subject: [PATCH 02/46] fix phpcs issue --- includes/class-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index dd00350a..8637f1ea 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -155,6 +155,6 @@ class Admin { } public static function admin_style() { - wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '../assets/css/admin.css' ); + wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '../assets/css/admin.css', array(), '1.0.0' ); } } From a280680e5d386b991f041840403d7430093543a5 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:30:40 +0100 Subject: [PATCH 03/46] Update templates/welcome.php Co-authored-by: Alex Kirk --- templates/welcome.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/welcome.php b/templates/welcome.php index ffff3e20..8ed5e164 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -8,7 +8,7 @@ %s or the URL %s. Users, that can not access this settings page, will find their username on the Edit Profile page.', + 'People can follow you by using the username %s or the URL %s. Users who can not access this settings page will find their username on the Edit Profile page.', 'activitypub' ), \Activitypub\get_webfinger_resource( wp_get_current_user()->ID ), From 9de398df4eec73485057c360d3f87a21dae6dd8f Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:33:37 +0100 Subject: [PATCH 04/46] remove misleading part --- templates/welcome.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/welcome.php b/templates/welcome.php index 8ed5e164..172e3e5e 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -19,5 +19,5 @@

Site Health to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ), admin_url( '/wp-admin/site-health.php' ) ); ?>


-

Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress, thus making your own WordPress a Mastodon instance of its own.', 'activitypub' ); ?>

+

Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress.', 'activitypub' ); ?>

From 7f346baf691d15f63a3897febc08c37d70fde673 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:37:18 +0100 Subject: [PATCH 05/46] remove spec and test links and replace them with support and bug links --- includes/help.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/help.php b/includes/help.php index 632b1899..16ffbeab 100644 --- a/includes/help.php +++ b/includes/help.php @@ -48,9 +48,8 @@ \get_current_screen()->set_help_sidebar( '

' . \__( 'For more information:', 'activitypub' ) . '

' . - '

' . \__( 'Test Suite', 'activitypub' ) . '

' . - '

' . \__( 'W3C Spec', 'activitypub' ) . '

' . - '

' . \__( 'Give us feedback', 'activitypub' ) . '

' . + '

' . \__( 'Get support', 'activitypub' ) . '

' . + '

' . \__( 'Report an issue', 'activitypub' ) . '

' . '
' . '

' . \__( 'Donate', 'activitypub' ) . '

' ); From 113a3bd4d27906c566f473cc71fc16ebcc30c1a0 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:45:46 +0100 Subject: [PATCH 06/46] normalize check --- activitypub.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activitypub.php b/activitypub.php index 58adc9cb..d2139d1b 100644 --- a/activitypub.php +++ b/activitypub.php @@ -108,7 +108,7 @@ function add_rewrite_rules() { \add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' ); } - if ( ! \class_exists( 'Nodeinfo' ) || ! get_option( 'blog_public' ) ) { + if ( ! \class_exists( 'Nodeinfo' ) || ! (bool) \get_option( 'blog_public', 1 ) ) { \add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' ); \add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' ); } From 2f8579cfe1939ae9cd5578a5e7888ef0492303c4 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:49:05 +0100 Subject: [PATCH 07/46] use ActivityPub instead of Fediverse to be consistent --- includes/class-admin.php | 2 +- templates/welcome.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index 8637f1ea..aa475804 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -149,7 +149,7 @@ class Admin { public static function add_fediverse_profile( $user ) { ?> -

+

ID ); } diff --git a/templates/welcome.php b/templates/welcome.php index 172e3e5e..d2c38915 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -13,7 +13,7 @@ ), \Activitypub\get_webfinger_resource( wp_get_current_user()->ID ), \get_author_posts_url( wp_get_current_user()->ID ), - \admin_url( 'profile.php#fediverse' ) + \admin_url( 'profile.php#activitypub' ) ); ?>

From 30919b1f7b02110834fb3ac6414913da01ad3bf7 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:50:56 +0100 Subject: [PATCH 08/46] be more descriptive --- includes/class-webfinger.php | 2 +- includes/functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-webfinger.php b/includes/class-webfinger.php index 659470e5..a0ec5427 100644 --- a/includes/class-webfinger.php +++ b/includes/class-webfinger.php @@ -16,7 +16,7 @@ class Webfinger { * * @return string The user-resource */ - public static function get_resource( $user_id ) { + public static function get_user_resource( $user_id ) { // use WebFinger plugin if installed if ( \function_exists( '\get_webfinger_resource' ) ) { return \get_webfinger_resource( $user_id, false ); diff --git a/includes/functions.php b/includes/functions.php index 89942563..93ec0c1c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -95,7 +95,7 @@ function safe_remote_get( $url, $user_id ) { * @return string The user-resource */ function get_webfinger_resource( $user_id ) { - return \Activitypub\Webfinger::get_resource( $user_id ); + return \Activitypub\Webfinger::get_user_resource( $user_id ); } /** From aa4f6bce69b348f693185e0707278cac8a07b679 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 15 Nov 2022 20:53:27 +0100 Subject: [PATCH 09/46] try to test against PHP 8.2 --- .github/workflows/phpunit.yml | 6 +++--- .gitignore | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 3ffaab22..0756e1f4 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,5 +1,5 @@ name: Unit Testing -on: +on: push: pull_request: jobs: @@ -15,7 +15,7 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10 strategy: matrix: - php-versions: ['5.6', '7.2', '7.3', '7.4', '8.0', '8.1'] + php-versions: ['5.6', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout uses: actions/checkout@v2 @@ -24,7 +24,7 @@ jobs: with: php-version: ${{ matrix.php-versions }} coverage: none - tools: composer, phpunit-polyfills + tools: composer, phpunit-polyfills extensions: mysql - name: Install Composer dependencies for PHP uses: "ramsey/composer-install@v1" diff --git a/.gitignore b/.gitignore index 6012ccb8..22c23348 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock .DS_Store .idea/ .php_cs.cache +.vscode/settings.json From 6232bddcd746003c546f43e9cf092756ff268932 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Sat, 19 Nov 2022 13:15:21 +0100 Subject: [PATCH 10/46] load only an activitypub settings pages --- includes/class-admin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index aa475804..bc7bcd95 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -154,7 +154,9 @@ class Admin { \Activitypub\get_identifier_settings( $user->ID ); } - public static function admin_style() { - wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '../assets/css/admin.css', array(), '1.0.0' ); + public static function admin_style( $hook_suffix ) { + if ( false !== strpos( $hook_suffix, 'activitypub' ) ) { + wp_enqueue_style( 'admin-styles', plugin_dir_url( __FILE__ ) . '../assets/css/admin.css', array(), '1.0.0' ); + } } } From 6e660d5f9b1473e97e37aa274e03dc9af9ee00b0 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Sat, 19 Nov 2022 13:26:00 +0100 Subject: [PATCH 11/46] hide template patterns --- assets/css/admin.css | 6 ++++++ templates/settings.php | 25 ++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 7210a024..df1082cf 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -44,3 +44,9 @@ visibility: hidden; margin: -2px 0 0; } + +summary { + cursor: pointer; + text-decoration: underline; + color: #2271b1; +} diff --git a/templates/settings.php b/templates/settings.php index 6e8d9805..ae43d6cb 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -33,18 +33,21 @@

-

-
    -
  • %title% -
  • -
  • %content% -
  • -
  • %excerpt% -
  • -
  • %permalink% -
  • -
  • %shortlink% - ', '' ); ?>
  • -
  • %hashtags% -
  • -
- ', '' ); ?> -
+
+ +
+
    +
  • %title% -
  • +
  • %content% -
  • +
  • %excerpt% -
  • +
  • %permalink% -
  • +
  • %shortlink% - ', '' ); ?>
  • +
  • %hashtags% -
  • +
+
+

+

', '' ); ?>

From 7d9107870bd8385e4ca5c07edaf6735084cab89a Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Sat, 19 Nov 2022 13:32:06 +0100 Subject: [PATCH 12/46] fix workflows --- .github/workflows/deploy.yml | 2 +- .github/workflows/update-assets.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5aa90f7a..2e179973 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@master - name: WordPress Plugin Deploy - uses: 10up/action-wordpress-plugin-deploy@master + uses: 10up/action-wordpress-plugin-deploy@stable env: SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} diff --git a/.github/workflows/update-assets.yml b/.github/workflows/update-assets.yml index 06a7c718..2a9955a0 100644 --- a/.github/workflows/update-assets.yml +++ b/.github/workflows/update-assets.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@master - name: WordPress.org plugin asset/readme update - uses: 10up/action-wordpress-plugin-asset-update@master + uses: 10up/action-wordpress-plugin-asset-update@stable env: SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} SVN_USERNAME: ${{ secrets.SVN_USERNAME }} From e4edd52ddb5bae7bd177744946fa65a94aa306de Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Sat, 19 Nov 2022 21:28:39 +0100 Subject: [PATCH 13/46] add info to check site health on errors --- templates/settings.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/settings.php b/templates/settings.php index ae43d6cb..2b275601 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,6 +1,10 @@ 'active', 'welcome' => '' ) ); ?>
+
+

Site Health to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ), admin_url( '/wp-admin/site-health.php' ) ); ?>

+
+

From 39df4226623edd6d8549614659d990eeb6515691 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 21 Nov 2022 08:27:22 +0100 Subject: [PATCH 14/46] remove headline --- templates/settings.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/settings.php b/templates/settings.php index 2b275601..ebe7d629 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -5,8 +5,6 @@

Site Health to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ), admin_url( '/wp-admin/site-health.php' ) ); ?>

-

-

From 19117323f9aaacffb1dd1e18ea6e7aba7f6c4aed Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Tue, 22 Nov 2022 00:05:17 +0100 Subject: [PATCH 15/46] Added some debug data --- includes/class-health-check.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/includes/class-health-check.php b/includes/class-health-check.php index 12f8d710..cb0e1300 100644 --- a/includes/class-health-check.php +++ b/includes/class-health-check.php @@ -15,6 +15,7 @@ class Health_Check { */ public static function init() { \add_filter( 'site_status_tests', array( '\Activitypub\Health_Check', 'add_tests' ) ); + \add_filter( 'debug_information', array( '\Activitypub\Health_Check', 'debug_information' ) ); } public static function add_tests( $tests ) { @@ -287,4 +288,30 @@ class Health_Check { return $link; } + + /** + * Static function for generating site debug data when required. + * + * @param array $info The debug information to be added to the core information page. + * @return array The filtered informations + */ + public static function debug_information( $info ) { + $info['activitypub'] = array( + 'label' => __( 'ActivityPub' ), + 'fields' => array( + 'webfinger' => array( + 'label' => __( 'WebFinger', 'activitypub' ), + 'value' => \Activitypub\Webfinger::get_user_resource( wp_get_current_user()->ID ), + 'private' => true, + ), + 'author_url' => array( + 'label' => __( 'Author URL', 'activitypub' ), + 'value' => get_author_posts_url( wp_get_current_user()->ID ), + 'private' => true, + ), + ), + ); + + return $info; + } } From 603199c9e8ff18db8436d5f068709e9d262e9229 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 2 Dec 2022 18:23:56 +0100 Subject: [PATCH 16/46] add recommended plugins --- activitypub.php | 3 + assets/css/activitypub-admin.css | 140 +++++++++++++++++++++++++++++++ assets/css/admin.css | 52 ------------ assets/js/activitypub-admin.js | 14 ++++ includes/class-admin.php | 7 +- includes/class-debug.php | 3 + templates/welcome.php | 68 +++++++++++++-- 7 files changed, 226 insertions(+), 61 deletions(-) create mode 100644 assets/css/activitypub-admin.css delete mode 100644 assets/css/admin.css create mode 100644 assets/js/activitypub-admin.js diff --git a/activitypub.php b/activitypub.php index d2139d1b..58d978a3 100644 --- a/activitypub.php +++ b/activitypub.php @@ -22,6 +22,9 @@ function init() { \defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' ); \defined( 'ACTIVITYPUB_ALLOWED_HTML' ) || \define( 'ACTIVITYPUB_ALLOWED_HTML', '

-

', '' ); ?>

+

Let me know if you miss a template pattern.', 'activitypub' ), 'default' ); ?>

@@ -117,7 +116,7 @@

- +

@@ -162,7 +161,7 @@

Disallowed Comment Keys" list.', 'activitypub' ), \esc_attr( \admin_url( 'options-discussion.php#disallowed_keys' ) ) diff --git a/templates/welcome.php b/templates/welcome.php index 28987f92..75387fdb 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -36,7 +36,7 @@ \sprintf( // translators: \__( 'If you have problems using this plugin, please check the Site Health to ensure that your site is compatible and/or use the "Help" tab (in the top right of the settings pages).', 'activitypub' ), - \esc_url_raw( admin_url( '/wp-admin/site-health.php' ) ) + \esc_url_raw( admin_url( 'site-health.php' ) ) ), 'default' ); From 59117ba953dceb2225c971272b1779200fe5bd9d Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 5 Dec 2022 20:26:37 +0100 Subject: [PATCH 31/46] nicer info header --- assets/css/activitypub-admin.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/css/activitypub-admin.css b/assets/css/activitypub-admin.css index 695a5f00..946bf133 100644 --- a/assets/css/activitypub-admin.css +++ b/assets/css/activitypub-admin.css @@ -1,3 +1,8 @@ +.settings_page_activitypub-settings .notice-info { + max-width: 800px; + margin: 0 auto; +} + .activitypub-settings-header { text-align: center; margin: 0 0 1rem; From 0cbc1037acb9e1be4909a351476f6d259d439712 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 5 Dec 2022 20:26:49 +0100 Subject: [PATCH 32/46] better escaping --- templates/settings.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/settings.php b/templates/settings.php index 5f8fddbf..51e45204 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -128,15 +128,13 @@

', - '', + echo \wp_kses( \sprintf( - '%s', + // translators: + \__( 'A list of HTML elements, you want to whitelist for your activities. Leave list empty to support all HTML elements. Default: %s', 'activitypub' ), \esc_html( ACTIVITYPUB_ALLOWED_HTML ) - ) + ), + 'default' ); ?>

From 03704fb74e2b85e75327fdfede3a82338c52870c Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 5 Dec 2022 20:27:04 +0100 Subject: [PATCH 33/46] use install thickbox --- includes/class-admin.php | 4 ++++ templates/welcome.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/class-admin.php b/includes/class-admin.php index 5e6e4744..7f4ca7fd 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -57,6 +57,10 @@ class Admin { * Load welcome page */ public static function welcome_page() { + wp_enqueue_script( 'plugin-install' ); + add_thickbox(); + wp_enqueue_script( 'updates' ); + \load_template( \dirname( __FILE__ ) . '/../templates/welcome.php' ); } diff --git a/templates/welcome.php b/templates/welcome.php index 75387fdb..8f824139 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -58,7 +58,7 @@

-

+

-
+

From 6d6975a2c9299911bbdd4334cae413a11ef7e5b0 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Mon, 5 Dec 2022 21:05:58 +0100 Subject: [PATCH 38/46] Update templates/welcome.php Co-authored-by: Alex Kirk --- templates/welcome.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/welcome.php b/templates/welcome.php index 5168639a..cc52323d 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -58,7 +58,7 @@

-

+

-