From d0e63fc8596751845d05deedbb66218b5cbbf41f Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Wed, 17 Jul 2024 16:17:54 +0200 Subject: [PATCH 01/10] added settings page sceleton --- includes/admin/class-settings-page.php | 110 +++++++++++++++++++++++++ includes/class-settings.php | 0 includes/class-setup.php | 5 +- templates/admin-header.php | 21 +++++ templates/settings-extractor.php | 13 +++ templates/settings-general.php | 13 +++ 6 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 includes/admin/class-settings-page.php delete mode 100644 includes/class-settings.php create mode 100644 templates/admin-header.php create mode 100644 templates/settings-extractor.php create mode 100644 templates/settings-general.php diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php new file mode 100644 index 0000000..27abc1c --- /dev/null +++ b/includes/admin/class-settings-page.php @@ -0,0 +1,110 @@ + {name => '' + active => true|false} + } + */ + + // todo generate this somehow + // maybe with filters, similar as with the settings + $submenu_options = array( + 'general' => array( + 'name' => 'General', + 'active' => false + ), + 'events_manager' => array( + 'name' => 'Events Manager', + 'active' => false, + ), + 'gatherpress' => array( + 'name' => 'Gatherpress', + 'active' => false, + ), + 'the_events_calendar' => array( + 'name' => 'The Events Calendar', + 'active' => false, + ), + 'vsel' => array( + 'name' => 'VS Event', + 'active' => false, + ), + ); + + $submenu_options[$tab]['active'] = true; + + + + switch ( $tab ) { + case 'general': + \load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings-general.php' , true, $submenu_options ); + break; + default: + \load_template( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_DIR . 'templates/settings-extractor.php', true, $submenu_options ); + break; + } + + } + +} diff --git a/includes/class-settings.php b/includes/class-settings.php deleted file mode 100644 index e69de29..0000000 diff --git a/includes/class-setup.php b/includes/class-setup.php index cf2f799..f1715a8 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -13,7 +13,7 @@ namespace Activitypub_Event_Extensions; use Activitypub_Event_Extensions\Admin\Event_Plugin_Admin_Notices; use Activitypub_Event_Extensions\Admin\General_Admin_Notices; - +use Activitypub_Event_Extensions\Admin\Settings_Page; // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore @@ -141,6 +141,9 @@ class Setup { return; } + add_action( 'admin_menu', array( Settings_Page::static, 'admin_menu' ) ); + add_filter( 'plugin_action_links_Activitypub_Event_Extensions', array( Settings_Page::static, 'settings_links' ) ); + add_filter( 'activitypub_transformer', array( $this, 'register_activitypub_event_transformer' ), 10, 3 ); } diff --git a/templates/admin-header.php b/templates/admin-header.php new file mode 100644 index 0000000..53cb250 --- /dev/null +++ b/templates/admin-header.php @@ -0,0 +1,21 @@ + +
+
+

+
+ + +
+
diff --git a/templates/settings-extractor.php b/templates/settings-extractor.php new file mode 100644 index 0000000..ac089a5 --- /dev/null +++ b/templates/settings-extractor.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/templates/settings-general.php b/templates/settings-general.php new file mode 100644 index 0000000..ac089a5 --- /dev/null +++ b/templates/settings-general.php @@ -0,0 +1,13 @@ + \ No newline at end of file From 098b1f578b35825e35d3848da7ac0500c816c0da Mon Sep 17 00:00:00 2001 From: ruru4143 Date: Thu, 18 Jul 2024 16:23:34 +0200 Subject: [PATCH 02/10] settings: moved slug into const var --- includes/admin/class-settings-page.php | 1 + templates/admin-header.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index 27abc1c..9ad568e 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -36,6 +36,7 @@ class Settings_Page { */ const static = 'Activitypub_Event_Extensions\Admin\Settings_Page'; + const settings_slug = 'activitypub-events'; /** * Warning if the plugin is Active and the ActivityPub plugin is not. diff --git a/templates/admin-header.php b/templates/admin-header.php index 53cb250..a201095 100644 --- a/templates/admin-header.php +++ b/templates/admin-header.php @@ -3,14 +3,14 @@ currently reusing activitypub classes which is kinda nice, because it has a cons -->
-

+

-