| 1 |
<?php |
| 2 |
namespace StoreEngine; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
use StoreEngine\Utils\Helper; |
| 9 |
|
| 10 |
class Miscellaneous { |
| 11 |
public static function init() { |
| 12 |
$self = new self(); |
| 13 |
add_action( 'admin_bar_menu', array( $self, 'add_admin_bar_menu' ), 90 ); |
| 14 |
} |
| 15 |
public function add_admin_bar_menu( $wp_admin_bar ) { |
| 16 |
$dashboard_page_id = (int) Helper::get_settings( 'dashboard_page' ); |
| 17 |
$title = ( current_user_can( 'storeengine_shop_manager' ) ? esc_html__( 'Store Dashboard', 'storeengine' ) : esc_html__( 'Customer Dashboard', 'storeengine' ) ); |
| 18 |
if ( $dashboard_page_id ) { |
| 19 |
$wp_admin_bar->add_node( |
| 20 |
array( |
| 21 |
'id' => 'storeenginedashboard', |
| 22 |
'title' => $title, |
| 23 |
'href' => get_the_permalink( $dashboard_page_id ), |
| 24 |
'parent' => 'site-name', |
| 25 |
) |
| 26 |
); |
| 27 |
} |
| 28 |
|
| 29 |
if ( is_singular( Helper::PRODUCT_POST_TYPE ) && current_user_can( 'storeengine_shop_manager' ) ) { |
| 30 |
$wp_admin_bar->add_menu( |
| 31 |
array( |
| 32 |
'id' => 'storeengineproducts', |
| 33 |
'title' => esc_html__( 'Edit Product', 'storeengine' ), |
| 34 |
'href' => esc_url( admin_url( 'admin.php?page=storeengine-products&id=' . get_the_ID() . '&action=edit' ) ), |
| 35 |
) |
| 36 |
); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|