diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
commit | 7d17f220e52d683f849a1854278a9bd47af17dd2 (patch) | |
tree | 3fed3ff2c6ab28c397a929a02e56d238ca40ed6d /giglogadmin.php | |
parent | ee9bef751805ac3f3c9572d1620f2221092b3094 (diff) | |
parent | 30f12e61317d9b181efb46382a4db98d73f65954 (diff) | |
download | gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.gz gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.bz2 gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.zip |
Merge branch 'psalm' into dev
This brings another tool in to help us keep the code in order - Psalm.
(I thought the name was fitting! :)
This will do fairly simple static analysis of the code, and report
problems and suggest fixes. It can help fix some issues itself, but
please double check that it does the right thing.
More info: https://psalm.dev
This merge also brings in fixes that was suggested by Paslm. Mostly this
is typa annotations for functions, but also some bugfixes discovered by
the tool.
Diffstat (limited to 'giglogadmin.php')
-rw-r--r-- | giglogadmin.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/giglogadmin.php b/giglogadmin.php index 0e8b399..c8ae9b0 100644 --- a/giglogadmin.php +++ b/giglogadmin.php @@ -36,7 +36,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { class GiglogAdmin_Plugin { - static public function init() { + static public function init(): void { add_shortcode('giglog_cities', 'giglogadmin_getfilters'); add_shortcode('giglog_bands', 'giglogadmin_getconcerts'); add_shortcode('giglog_unprocessed', 'giglogadmin_display_unprocessed'); @@ -49,18 +49,20 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' )); } - static function activate() { + static function activate(): void { require_once __DIR__ . '/includes/admin/register_db_tables.php'; } - static function deactivate() { + static function deactivate(): void { } /** * Adds the 'Giglog' top level menu to the left side WordPress admin * menu. Other subpages will come later. + * + * @return void */ - static function add_admin_pages() { + static function add_admin_pages(): void { $top = add_menu_page( "Giglog admin", // Page title "Giglog", // Menu title @@ -80,13 +82,17 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { "giglog_import", // menu slug array( 'GiglogAdmin_ImportGigsPage', 'render_html' )); // callable - add_action( 'load-' . $import_hook, array( 'GiglogAdmin_ImportGigsPage', 'submit_form' ) ); + if ($import_hook !== false) { + add_action( + 'load-' . $import_hook, + array( 'GiglogAdmin_ImportGigsPage', 'submit_form' ) ); + } wp_register_style( 'css_style', plugins_url( '/includes/css/main.css', __FILE__ ) ); wp_enqueue_style('css_style'); } - static function add_help_pages() { + static function add_help_pages(): void { add_menu_page( "Help for ET users", // Page title "Help for ET users", // Menu title @@ -119,7 +125,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { * Giglog admin pages should only be visible for logged in users/can eventually * be customized by role if needed */ - static function nav_menu_args( $args = '' ) { + static function nav_menu_args( array $args = [] ) : array { if ( is_user_logged_in() ) { $args['menu'] = 'Loggedusers'; } else { |