diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-09-11 18:43:53 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-09-11 18:43:53 +0200 |
commit | f2c8c10eb5ef7c9bb9707c4787b65f31c8b56292 (patch) | |
tree | c3148b1dbe676b84033ea1daa48a081c4bf16273 /giglogadmin.php | |
parent | aefe55a70d6f6bae7825f3a1a6b61046c8ec2cc3 (diff) | |
download | gigologadmin-f2c8c10eb5ef7c9bb9707c4787b65f31c8b56292.tar.gz gigologadmin-f2c8c10eb5ef7c9bb9707c4787b65f31c8b56292.tar.bz2 gigologadmin-f2c8c10eb5ef7c9bb9707c4787b65f31c8b56292.zip |
Change how we load the plugin.
Since we now have code that should be available, both on the public blog
and in the admin section, we need to be more graular when loading the
various parts of the plugin.
We still try to avoid loading admin-only parts for the public blog, but
allways load the parts that we need in either case. Also avoid running
the db migrations when running unit tests, as the schema is copied over
from the dev environment it just caues problems.
Finally, don't hardcode unit tests to always be in_admin, but rather
determine that for each test.
Diffstat (limited to 'giglogadmin.php')
-rw-r--r-- | giglogadmin.php | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/giglogadmin.php b/giglogadmin.php index c07941f..71d7849 100644 --- a/giglogadmin.php +++ b/giglogadmin.php @@ -28,10 +28,30 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { class GiglogAdmin_Plugin { static public function init(): void { - add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_admin_pages' )); - add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_help_pages' )); + if ( !defined('GIGLOGADMIN_UNIT_TEST') ) { + require_once __DIR__ . '/includes/admin/register_db_tables.php'; + } + + require_once __DIR__ . '/includes/venue.php'; + require_once __DIR__ . '/includes/concert.php'; + require_once __DIR__ . '/includes/view-helpers/select_field.php'; + + if (is_admin()) { + require_once __DIR__ . '/includes/admin/views/giglog_admin_page.php'; + require_once __DIR__ . '/includes/admin/views/giglog_import_gigs.php'; + require_once __DIR__ . '/includes/admin/helpfiles/instrunctions.php'; + require_once __DIR__ . '/includes/admin/helpfiles/instr_reviewers.php'; + require_once __DIR__ . '/includes/admin/helpfiles/instr_photog.php'; + + add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_admin_pages' )); + add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_help_pages' )); - add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' )); + add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' )); + } + else { + require_once __DIR__ . '/includes/admin/views/_concerts_table.php'; + require_once __DIR__ . '/includes/giglog_visitor_display.php'; + } } static function activate(): void { @@ -124,16 +144,6 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { register_activation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'activate' )); register_deactivation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'deactivate' )); - if (is_admin()) { - require_once __DIR__ . '/includes/admin/register_db_tables.php'; - require_once __DIR__ . '/includes/admin/views/giglog_admin_page.php'; - require_once __DIR__ . '/includes/admin/views/giglog_import_gigs.php'; - require_once __DIR__ . '/includes/admin/helpfiles/instrunctions.php'; - require_once __DIR__ . '/includes/admin/helpfiles/instr_reviewers.php'; - require_once __DIR__ . '/includes/admin/helpfiles/instr_photog.php'; - require_once __DIR__ . '/includes/view-helpers/select_field.php'; - - GiglogAdmin_Plugin::init(); - } + GiglogAdmin_Plugin::init(); } ?> |