From 13f78b9815a761f5bc5325d7e8bbf2d825bfcbb8 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 8 Jan 2016 19:15:02 +1100 Subject: [PATCH] Add shortcut to admin bar --- assets/css/sportspress.css | 10 +++++ modules/sportspress-admin-bar.php | 65 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 modules/sportspress-admin-bar.php diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index 1b2f5143..968c7598 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -380,6 +380,16 @@ display: none; } +/* Admin Bar */ +#wpadminbar #wp-admin-bar-sportspress>.ab-item:before { + font-family: sportspress, dashicons; +} + +#wpadminbar #wp-admin-bar-sportspress>.ab-item:before { + content: "\f111"; + top: 2px; +} + /* Media Queries */ @media screen and (min-width: 801px) { /* Widget Alignment */ diff --git a/modules/sportspress-admin-bar.php b/modules/sportspress-admin-bar.php new file mode 100644 index 00000000..11124005 --- /dev/null +++ b/modules/sportspress-admin-bar.php @@ -0,0 +1,65 @@ +define_constants(); + + add_action( 'admin_bar_menu', array( $this, 'add_node' ), 40 ); + } + + /** + * Define constants. + */ + private function define_constants() { + if ( !defined( 'SP_ADMIN_BAR_VERSION' ) ) + define( 'SP_ADMIN_BAR_VERSION', '1.9.14' ); + + if ( !defined( 'SP_ADMIN_BAR_URL' ) ) + define( 'SP_ADMIN_BAR_URL', plugin_dir_url( __FILE__ ) ); + + if ( !defined( 'SP_ADMIN_BAR_DIR' ) ) + define( 'SP_ADMIN_BAR_DIR', plugin_dir_path( __FILE__ ) ); + } + + /** + * Add node to admin bar menu. + */ + public function add_node( $wp_admin_bar ) { + if ( is_admin() ) return; + + $args = array( + 'id' => 'sportspress', + 'title' => __( 'SportsPress', 'sportspress' ), + 'href' => add_query_arg( 'page', 'sportspress', admin_url( 'admin.php' ) ), + ); + $wp_admin_bar->add_node( $args ); + } +} + +endif; + +new SportsPress_Admin_Bar();