class-admin-bar.php
7 months ago
class-aioseo-sitemaps.php
7 months ago
class-css-load-optimizer.php
7 months ago
class-foogallery-template-loader.php
7 months ago
class-public.php
7 months ago
class-rank-math-seo-sitemaps.php
7 months ago
class-shortcodes.php
7 months ago
class-yoast-seo-sitemaps.php
7 months ago
index.php
11 years ago
class-admin-bar.php
50 lines
| 1 | <?php |
| 2 | /** |
| 3 | * FooGallery_AdminBar Class |
| 4 | * allows for really easy gallery editing from the front-end (when logged in) |
| 5 | * Date: 30/08/2015 |
| 6 | */ |
| 7 | |
| 8 | if ( !class_exists( 'FooGallery_AdminBar' ) ) { |
| 9 | |
| 10 | class FooGallery_AdminBar { |
| 11 | |
| 12 | function __construct() { |
| 13 | // adds the edit galleries menu to the admin bar |
| 14 | add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 101 ); // 101 determines the position |
| 15 | } |
| 16 | |
| 17 | public function admin_bar_menu($wp_admin_bar) { |
| 18 | global $wp_the_query; |
| 19 | |
| 20 | if ( !is_admin() ) { |
| 21 | $current_object = $wp_the_query->get_queried_object(); |
| 22 | |
| 23 | if ( empty( $current_object ) ) |
| 24 | return; |
| 25 | |
| 26 | if ( ! empty( $current_object->post_type ) |
| 27 | && current_user_can( 'edit_post', $current_object->ID ) ) { |
| 28 | |
| 29 | $gallery_posts = foogallery_get_galleries_attached_to_post( $current_object->ID ); |
| 30 | |
| 31 | if ( !empty( $gallery_posts ) ) { |
| 32 | $wp_admin_bar->add_menu(array( |
| 33 | 'id' => 'foogallery', |
| 34 | 'title' => __( 'Edit Galleries', 'foogallery' ) |
| 35 | )); |
| 36 | |
| 37 | foreach ( $gallery_posts as $gallery ) { |
| 38 | $wp_admin_bar->add_menu( array( |
| 39 | 'parent' => 'foogallery', |
| 40 | 'id' => $gallery->ID, |
| 41 | 'title' => esc_html( $gallery->post_title ), |
| 42 | 'href' => get_edit_post_link( $gallery->ID ), |
| 43 | ) ); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |