PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / public / class-admin-bar.php
foogallery / includes / public Last commit date
class-admin-bar.php 4 weeks ago class-aioseo-sitemaps.php 4 weeks ago class-css-load-optimizer.php 4 weeks ago class-foogallery-template-loader.php 4 weeks ago class-public.php 4 weeks ago class-rank-math-seo-sitemaps.php 4 weeks ago class-shortcodes.php 4 weeks ago class-yoast-seo-sitemaps.php 4 weeks ago index.php 4 weeks ago
class-admin-bar.php
56 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * FooGallery_AdminBar Class
9 * allows for really easy gallery editing from the front-end (when logged in)
10 * Date: 30/08/2015
11 */
12
13 if ( !class_exists( 'FooGallery_AdminBar' ) ) {
14
15 class FooGallery_AdminBar {
16
17 function __construct() {
18 // adds the edit galleries menu to the admin bar
19 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 101 ); // 101 determines the position
20 }
21
22 public function admin_bar_menu($wp_admin_bar) {
23 global $wp_the_query;
24
25 if ( !is_admin() ) {
26 $current_object = $wp_the_query->get_queried_object();
27
28 if ( empty( $current_object ) )
29 return;
30
31 if ( ! empty( $current_object->post_type )
32 && current_user_can( 'edit_post', $current_object->ID ) ) {
33
34 $gallery_posts = foogallery_get_galleries_attached_to_post( $current_object->ID );
35
36 if ( !empty( $gallery_posts ) ) {
37 $wp_admin_bar->add_menu(array(
38 'id' => 'foogallery',
39 'title' => __( 'Edit Galleries', 'foogallery' )
40 ));
41
42 foreach ( $gallery_posts as $gallery ) {
43 $wp_admin_bar->add_menu( array(
44 'parent' => 'foogallery',
45 'id' => $gallery->ID,
46 'title' => esc_html( $gallery->post_title ),
47 'href' => get_edit_post_link( $gallery->ID ),
48 ) );
49 }
50 }
51 }
52 }
53 }
54 }
55 }
56