From 127df329b6c6a8f632d30aba9128cab92d62edbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 19 Oct 2024 13:06:01 +0200 Subject: [PATCH] improved settings page layout --- assets/css/activitypub-event-bridge-admin.css | 52 +++++++++++++++++++ .../activitypub-event-extensions-admin.css | 6 --- includes/plugins/class-event-plugin.php | 12 +++++ templates/admin-header.php | 33 ++++++++++++ templates/settings.php | 27 +++++----- templates/status.php | 23 ++++++-- 6 files changed, 130 insertions(+), 23 deletions(-) create mode 100644 assets/css/activitypub-event-bridge-admin.css delete mode 100644 assets/css/activitypub-event-extensions-admin.css create mode 100644 templates/admin-header.php diff --git a/assets/css/activitypub-event-bridge-admin.css b/assets/css/activitypub-event-bridge-admin.css new file mode 100644 index 0000000..a3575c3 --- /dev/null +++ b/assets/css/activitypub-event-bridge-admin.css @@ -0,0 +1,52 @@ +.activitypub-event-bridge-settings-page .box { + border: 1px solid #c3c4c7; + background-color: #fff; + padding: 1em 1.5em; + margin-bottom: 1.5em; +} + +.activitypub-event-bridge-settings { + max-width: 800px; + margin: 0 auto; +} + +.activitypub-event-bridge-settings-header { + text-align: center; + margin: 0 0 1rem; + background: #fff; + border-bottom: 1px solid #dcdcde; +} + +.activitypub-event-bridge-settings-title-section { + display: flex; + align-items: center; + justify-content: center; + clear: both; + padding-top: 8px; +} + +.activitypub-event-bridge-settings-tabs-wrapper { + display: -ms-inline-grid; + -ms-grid-columns: auto auto auto auto; + vertical-align: top; + display: inline-grid; + grid-template-columns: auto auto auto auto; +} + +.activitypub-event-bridge-settings-tab.active { + box-shadow: inset 0 -3px #3582c4; + font-weight: 600; +} + +.activitypub-event-bridge-settings-tab { + display: block; + text-decoration: none; + color: inherit; + padding: .5rem 1rem 1rem; + margin: 0 1rem; + transition: box-shadow .5s ease-in-out; +} + +.activitypub-event-bridge-settings .box h3 { + font-size: 1.1rem!important; +} \ No newline at end of file diff --git a/assets/css/activitypub-event-extensions-admin.css b/assets/css/activitypub-event-extensions-admin.css deleted file mode 100644 index c59d1a1..0000000 --- a/assets/css/activitypub-event-extensions-admin.css +++ /dev/null @@ -1,6 +0,0 @@ -.activitypub-event-bridge-settings-page .box { - border: 1px solid #c3c4c7; - background-color: #fff; - padding: 1em 1.5em; - margin-bottom: 1.5em; -} diff --git a/includes/plugins/class-event-plugin.php b/includes/plugins/class-event-plugin.php index f70cfa0..7374794 100644 --- a/includes/plugins/class-event-plugin.php +++ b/includes/plugins/class-event-plugin.php @@ -53,6 +53,18 @@ abstract class Event_Plugin { return ''; } + /** + * Get the plugins name from the main plugin-file's top-level-file-comment. + */ + final public static function get_plugin_name(): string { + $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . static::get_plugin_file() ); + if ( isset( $plugin_data['Name'] ) ) { + return $plugin_data['Name']; + } else { + return ''; + } + } + /** * Detects whether the current screen is a admin page of the event plugin. */ diff --git a/templates/admin-header.php b/templates/admin-header.php new file mode 100644 index 0000000..1890558 --- /dev/null +++ b/templates/admin-header.php @@ -0,0 +1,33 @@ + '', + 'settings' => '', + ) +); +?> + +
+
+

+
+ + +
+
diff --git a/templates/settings.php b/templates/settings.php index 8eb382e..58f1bed 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -13,6 +13,14 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore +\load_template( + __DIR__ . '/admin-header.php', + true, + array( + 'settings' => 'active', + ) +); + use Activitypub\Activity\Extended_Object\Event; if ( ! isset( $args ) || ! array_key_exists( 'event_terms', $args ) ) { @@ -31,19 +39,12 @@ $selected_default_event_category = \get_option( 'activitypub_event_bridge_defaul $current_category_mapping = \get_option( 'activitypub_event_bridge_event_category_mappings', array() ); ?> -
-
-

-
-
-
- -
+
-

+

@@ -59,11 +60,9 @@ $current_category_mapping = \get_option( 'activitypub_event_bridge_event_
-
- -
-

+ +

@@ -96,8 +95,8 @@ $current_category_mapping = \get_option( 'activitypub_event_bridge_event_
+
-
diff --git a/templates/status.php b/templates/status.php index 75bb595..36d8b74 100644 --- a/templates/status.php +++ b/templates/status.php @@ -5,11 +5,28 @@ * @package ActivityPub_Event_Bridge */ +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + +use ActivityPub_Event_Bridge\Setup; + +\load_template( + __DIR__ . '/admin-header.php', + true, + array( + 'status' => 'active', + ) +); + +$active_event_plugins = Setup::get_instance()->get_active_event_plugins(); + ?> -
+
-

-

This is so cool!

+

+ +

get_plugin_name() ); ?>

+