From a0a4edb72b0b2a02711b9bf1c260e49a749c914b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Tue, 22 Oct 2024 16:18:29 +0200 Subject: [PATCH] improve admin welcome page --- activitypub-event-bridge.php | 4 +- assets/css/activitypub-event-bridge-admin.css | 17 +- assets/img/activitypub.svg | 288 ++++++++++++++++++ assets/img/fediverse.svg | 17 ++ assets/img/mastodon.svg | 10 + assets/img/mobilizon.svg | 1 + .../admin/class-general-admin-notices.php | 18 ++ includes/admin/class-health-check.php | 10 +- includes/admin/class-settings-page.php | 2 +- templates/welcome.php | 158 +++++++++- 10 files changed, 506 insertions(+), 19 deletions(-) create mode 100644 assets/img/activitypub.svg create mode 100644 assets/img/fediverse.svg create mode 100644 assets/img/mastodon.svg create mode 100644 assets/img/mobilizon.svg diff --git a/activitypub-event-bridge.php b/activitypub-event-bridge.php index 9a7ca6b..357123d 100644 --- a/activitypub-event-bridge.php +++ b/activitypub-event-bridge.php @@ -3,7 +3,7 @@ * Plugin Name: ActivityPub Event Bridge * Description: Integrating popular event plugins with the ActivityPub plugin. * Plugin URI: https://event-federation.eu/ - * Version: 0.1.1 + * Version: 0.1.1.5 * Author: André Menrath * Author URI: https://graz.social/@linos * Text Domain: activitypub-event-bridge @@ -11,7 +11,7 @@ * License URI: https://www.gnu.org/licenses/agpl-3.0.de.html * Requires PHP: 8.1 * - * Requires at least ActivityPub plugin with version >= 3.2.2. ActivityPub plugin tested up to: 3.2.2. + * Requires at least ActivityPub plugin with version >= 3.2.2. ActivityPub plugin tested up to: 3.3.3. * * @package ActivityPub_Event_Bridge * @license AGPL-3.0-or-later diff --git a/assets/css/activitypub-event-bridge-admin.css b/assets/css/activitypub-event-bridge-admin.css index 8455b96..18bcf24 100644 --- a/assets/css/activitypub-event-bridge-admin.css +++ b/assets/css/activitypub-event-bridge-admin.css @@ -1,3 +1,7 @@ +.settings_page_activitypub-event-bridge #wpcontent { + padding-left: 0; +} + .activitypub-event-bridge-settings-page .box { border: 1px solid #c3c4c7; background-color: #fff; @@ -6,8 +10,7 @@ } .activitypub-event-bridge-settings-page .box ul.activitypub-event-bridge-list { - list-style-type: disc; - margin-left: 1.4rem; + margin-left: 0.6em; } .activitypub-event-bridge-settings-page .box pre { @@ -62,7 +65,8 @@ } .activitypub-event-bridge-settings .box h3 { - font-size: 1.1rem!important; + font-size: 1.15em; + margin-bottom: 0em; } #activitypub_event_bridge_initially_activated { @@ -155,3 +159,10 @@ outline: 2px solid #2271b1; background-color: #f6f7f7; } + +.activitypub-event-bridge-settings-inline-icon { + width: 1.5em; + height: 1.5em; + vertical-align: middle; + margin: 0 0.3em; +} diff --git a/assets/img/activitypub.svg b/assets/img/activitypub.svg new file mode 100644 index 0000000..f56d428 --- /dev/null +++ b/assets/img/activitypub.svg @@ -0,0 +1,288 @@ + + + + + ActivityPub logo + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + ActivityPub logo + + 2017-04-15 + + + Robert Martinez + + + + + ActivityPub + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/img/fediverse.svg b/assets/img/fediverse.svg new file mode 100644 index 0000000..a789df2 --- /dev/null +++ b/assets/img/fediverse.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/assets/img/mastodon.svg b/assets/img/mastodon.svg new file mode 100644 index 0000000..0f8baeb --- /dev/null +++ b/assets/img/mastodon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/img/mobilizon.svg b/assets/img/mobilizon.svg new file mode 100644 index 0000000..8b5d57e --- /dev/null +++ b/assets/img/mobilizon.svg @@ -0,0 +1 @@ + diff --git a/includes/admin/class-general-admin-notices.php b/includes/admin/class-general-admin-notices.php index 43cb4f3..7ab1f2b 100644 --- a/includes/admin/class-general-admin-notices.php +++ b/includes/admin/class-general-admin-notices.php @@ -98,6 +98,24 @@ class General_Admin_Notices { ); } + /** + * Warning to fix status issues first. + * + * @return string + */ + public static function get_admin_notice_status_not_ok(): string { + return sprintf( + /* translators: 1: An URL to the list of supported event plugins. */ + _x( + 'The Plugin ActivityPub Event Bridge is of no use, because you do not have installed and activated a supported Event Plugin. +
For a list of supported Event Plugins see here.', + 'admin notice', + 'activitypub-event-bridge' + ), + esc_html( self::ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL ) + ); + } + /** * Warning if the plugin is Active and the ActivityPub plugin is not. * diff --git a/includes/admin/class-health-check.php b/includes/admin/class-health-check.php index 1f44905..5fa3f9a 100644 --- a/includes/admin/class-health-check.php +++ b/includes/admin/class-health-check.php @@ -107,12 +107,16 @@ class Health_Check { /** * Retrieves the most recently published event posts of a certain event post type. * - * @param string $event_post_type The post type of the events. - * @param int $number_of_posts The maximum number of events to return. + * @param ?string $event_post_type The post type of the events. + * @param ?int $number_of_posts The maximum number of events to return. * * @return WP_Post[]|false Array of event posts, or false if none are found. */ - public static function get_most_recent_event_posts( $event_post_type, $number_of_posts = 5 ) { + public static function get_most_recent_event_posts( $event_post_type = null, $number_of_posts = 5 ) { + if ( ! $event_post_type ) { + $event_post_type = Setup::get_instance()->get_active_event_plugins()[0]->get_post_type(); + } + $args = array( 'numberposts' => $number_of_posts, 'category' => 0, diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index 9694d98..df6143b 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -37,7 +37,7 @@ class Settings_Page { public static function admin_menu(): void { \add_options_page( 'Activitypub Event Extension', - __( 'ActivityPub Events', 'activitypub-event-bridge' ), + __( 'ActivityPub Event Bridge', 'activitypub-event-bridge' ), 'manage_options', self::SETTINGS_SLUG, array( self::STATIC, 'settings_page' ) diff --git a/templates/welcome.php b/templates/welcome.php index e1def8e..1a87055 100644 --- a/templates/welcome.php +++ b/templates/welcome.php @@ -21,6 +21,17 @@ use ActivityPub_Event_Bridge\Admin\Health_Check; ); $active_event_plugins = Setup::get_instance()->get_active_event_plugins(); +$activitypub_event_bridge_status_ok = true; + +$example_event_post = Health_Check::get_most_recent_event_posts(); + +if ( empty( $example_event_post ) ) { + $example_event_post = 'https://yoursite.com/events/event-name'; + $example_event_post_is_dummy = true; +} else { + $example_event_post = \get_permalink( $example_event_post[0]); + $example_event_post_is_dummy = false; +} global $wp_filesystem; WP_Filesystem(); @@ -31,21 +42,64 @@ WP_Filesystem();

- +
@@ -59,21 +113,105 @@ WP_Filesystem();

-

+

' . \esc_html__( 'Please fix the status issues above first.', 'activitypub-event-bridge' ) . '

'; + } + ?> +

-

+

+

+ +

+ +

+ +

+ +

+ +

+