summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-02-21 14:34:14 +0100
committerHarald Eilertsen <haraldei@anduin.net>2021-02-21 14:34:14 +0100
commitd7f1eccafc8013b20a5f23e5b5c97df458ea6081 (patch)
tree6a098665a2715d818133d4132888294ecfe3e525
parenta176f66a860634b0975eee6894f075fe21e65cdf (diff)
downloadgigologadmin-d7f1eccafc8013b20a5f23e5b5c97df458ea6081.tar.gz
gigologadmin-d7f1eccafc8013b20a5f23e5b5c97df458ea6081.tar.bz2
gigologadmin-d7f1eccafc8013b20a5f23e5b5c97df458ea6081.zip
Add top level menu to WordPress admin menu.
Currently nothing useful on the page, but a placeholder for a more useful page later, and possibly submenus for other functionality. The menu is placed right below the 'Media' menu for now, and is available to anyone with the 'upload_files' capability. Both of these may be adjusted later if there's a better location or other capabilities fit better.
-rw-r--r--giglogadmin.php17
-rw-r--r--includes/admin/views/giglog_admin_page.php26
2 files changed, 43 insertions, 0 deletions
diff --git a/giglogadmin.php b/giglogadmin.php
index 1157d73..091cdcf 100644
--- a/giglogadmin.php
+++ b/giglogadmin.php
@@ -24,6 +24,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
require_once __DIR__ . '/includes/public/shortcodes/giglog_display_unprocessed.php';
require_once __DIR__ . '/includes/public/shortcodes/giglog_photographers.php';
require_once __DIR__ . '/includes/public/shortcodes/giglog_process_files.php';
+ require_once __DIR__ . '/includes/admin/views/giglog_admin_page.php';
class GiglogAdmin_Plugin
{
@@ -34,6 +35,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
add_shortcode('giglog_upload', 'giglogadmin_upload_files');
add_shortcode('giglog_photog', 'giglogadmin_photographers');
+ add_action( 'admin_menu', array( 'GiglogAdmin_Plugin', 'add_admin_pages' ));
add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' ));
}
@@ -44,6 +46,21 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) {
static function deactivate() {
}
+ /**
+ * Adds the 'Giglog' top level menu to the left side WordPress admin
+ * menu. Other subpages will come later.
+ */
+ static function add_admin_pages() {
+ add_menu_page(
+ "Giglog", // Page title
+ "Giglog", // Menu title
+ "upload_files", // Will show for users with this capability
+ "giglog", // menu slug
+ array( 'GiglogAdmin_AdminPage', 'render_html' ), // callable
+ 'dashicons-tickets-alt', // Icon url
+ 11); // Position, just below 'Media'
+ }
+
/*
* Show menus based on whether user is logged in or not.
*
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
new file mode 100644
index 0000000..45a9f3f
--- /dev/null
+++ b/includes/admin/views/giglog_admin_page.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Copyright (C) 2021 Harald Eilertsen, Andrea Chirulescu
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
+ class GiglogAdmin_AdminPage {
+ static function render_html() {
+ echo '<div class="wrap"><h1>Hi there admin!</h1></div>';
+ }
+ }
+}
+?>