summaryrefslogtreecommitdiffstats
path: root/giglogadmin.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-02-21 13:45:21 +0100
committerHarald Eilertsen <haraldei@anduin.net>2021-02-21 13:45:21 +0100
commit1c0bbd401d6376214c88edf2a639398235fab14f (patch)
treeeccc42f9e9ddacf7c2b6579ff3ce359e0c35245f /giglogadmin.php
parent156b39bbe979b3b7f533e51a670e908247cb241c (diff)
downloadgigologadmin-1c0bbd401d6376214c88edf2a639398235fab14f.tar.gz
gigologadmin-1c0bbd401d6376214c88edf2a639398235fab14f.tar.bz2
gigologadmin-1c0bbd401d6376214c88edf2a639398235fab14f.zip
Move menu filter into plugin class.
Diffstat (limited to 'giglogadmin.php')
-rw-r--r--giglogadmin.php35
1 files changed, 18 insertions, 17 deletions
diff --git a/giglogadmin.php b/giglogadmin.php
index 003c1fa..88d040a 100644
--- a/giglogadmin.php
+++ b/giglogadmin.php
@@ -17,23 +17,6 @@
* License URI: https://www.gnu.org/licenses/agpl-3.0.txthttps://www.gnu.org/licenses/agpl-3.0.txt
*/
-/*
- * Show menus based on whether user is logged in or not.
- *
- * Giglog admin pages should only be visible for logged in users/can eventually
- * be customized by role if needed
- */
-function my_wp_nav_menu_args( $args = '' ) {
- if ( is_user_logged_in() ) {
- $args['menu'] = 'Loggedusers';
- } else {
- $args['menu'] = 'Notloggedusers';
- }
-
- return $args;
-}
-
-add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
@@ -51,6 +34,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
add_shortcode('giglog_upload', 'giglogadmin_upload_files');
add_shortcode('giglog_photog', 'giglogadmin_photographers');
+ add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' ));
}
static function activate() {
@@ -59,6 +43,23 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
static function deactivate() {
}
+
+ /*
+ * Show menus based on whether user is logged in or not.
+ *
+ * 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 = '' ) {
+ if ( is_user_logged_in() ) {
+ $args['menu'] = 'Loggedusers';
+ } else {
+ $args['menu'] = 'Notloggedusers';
+ }
+
+ return $args;
+ }
+
}
register_activation_hook( __FILE__, array( 'GiglogAdmin_Plugin', 'activate' ));