Skip to content

Commit

Permalink
update menu bar backend (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-eastgate authored Feb 6, 2023
1 parent ce75869 commit 83d9e65
Showing 1 changed file with 53 additions and 55 deletions.
108 changes: 53 additions & 55 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,60 +335,58 @@ function update_status_close_action_button_option()
}
});

if ( ! is_admin() ) {
add_action('admin_bar_menu', function ( $wp_admin_bar ) {
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) ){
$toolBarConfig = [
[
'id' => 'onoffice',
'title' => __('onOffice', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice'),
'meta' => [ 'class' => 'onoffice' ]
],
[
'id' => 'onoffice-clear-cache',
'title' => __('Clear onOffice cache', 'onoffice-for-wp-websites'),
'href' => admin_url('onoffice-clear-cache'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'onoffice-clear-cache' ]
],
[
'id' => 'addresses',
'title' => __('Addresses', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-addresses'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'addresses' ]
],
[
'id' => 'estates',
'title' => __('Estates', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-estates'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'estates' ]
],
[
'id' => 'forms',
'title' => __('Forms', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-forms'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'forms' ]
],
[
'id' => 'settings',
'title' => __('Settings', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-settings'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'settings' ]
]
];

foreach ( $toolBarConfig as $e ) {
$wp_admin_bar->add_node($e);
}
};
}, 500);
}
add_action('admin_bar_menu', function ( $wp_admin_bar ) {
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator');
if( array_intersect($allowed_roles, $user->roles ) ){
$toolBarConfig = [
[
'id' => 'onoffice',
'title' => __('onOffice', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice'),
'meta' => [ 'class' => 'onoffice' ]
],
[
'id' => 'onoffice-clear-cache',
'title' => __('Clear onOffice cache', 'onoffice-for-wp-websites'),
'href' => admin_url('onoffice-clear-cache'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'onoffice-clear-cache' ]
],
[
'id' => 'addresses',
'title' => __('Addresses', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-addresses'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'addresses' ]
],
[
'id' => 'estates',
'title' => __('Estates', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-estates'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'estates' ]
],
[
'id' => 'forms',
'title' => __('Forms', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-forms'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'forms' ]
],
[
'id' => 'settings',
'title' => __('Settings', 'onoffice-for-wp-websites'),
'href' => admin_url('admin.php?page=onoffice-settings'),
'parent' => 'onoffice',
'meta' => [ 'class' => 'settings' ]
]
];

foreach ( $toolBarConfig as $e ) {
$wp_admin_bar->add_node($e);
}
};
}, 500);

return $pDI;

0 comments on commit 83d9e65

Please sign in to comment.