class-admin-bar.php
1 week ago
class-aioseo-sitemaps.php
1 week ago
class-css-load-optimizer.php
1 week ago
class-foogallery-template-loader.php
1 week ago
class-public.php
1 week ago
class-rank-math-seo-sitemaps.php
1 week ago
class-shortcodes.php
1 week ago
class-yoast-seo-sitemaps.php
1 week ago
index.php
1 week 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 |