summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--giglogadmin.php38
-rw-r--r--includes/giglog_visitor_display.php11
-rw-r--r--tests/bootstrap.php2
3 files changed, 28 insertions, 23 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();
}
?>
diff --git a/includes/giglog_visitor_display.php b/includes/giglog_visitor_display.php
index 8177cb8..567bf41 100644
--- a/includes/giglog_visitor_display.php
+++ b/includes/giglog_visitor_display.php
@@ -1,13 +1,8 @@
<?php declare(strict_types=1);
-function display_giglog()
+function display_giglog() : string
{
- require_once __DIR__ . '/admin/views/_concerts_table.php';
- require_once __DIR__ . '/view-helpers/select_field.php';
- require_once __DIR__ . '/venue.php';
- require_once __DIR__ . '/concert.php';
- $c = new GiglogAdmin_ConcertsTable();
- $html = $c->render();
- return ($html);
+ $c = new GiglogAdmin_ConcertsTable();
+ return $c->render();
}
add_shortcode('getconcerts', 'display_giglog');
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index c999ba1..798322a 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -30,7 +30,7 @@ require_once $_tests_dir . '/includes/functions.php';
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
- define('WP_ADMIN', true); // We're always in admin
+ define('GIGLOGADMIN_UNIT_TEST', true);
require dirname( dirname( __FILE__ ) ) . '/giglogadmin.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );