51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
add_action('admin_bar_menu', 'add_toolbar_items', 100);
|
||
|
function add_toolbar_items($admin_bar){
|
||
|
if(substr($_SERVER['REQUEST_URI'],0,9) != "/wp-admin" ){
|
||
|
$admin_bar->add_menu( array(
|
||
|
'id' => 'toggle-help-links',
|
||
|
'title' => '<span class="dashicons dashicons-edit-large" style="font-family:dashicons;"></span> Toggle Aid',
|
||
|
'href' => '#',
|
||
|
'meta' => array(
|
||
|
'title' => __('Toggle Aid'),
|
||
|
'class' => 'toggle-help-links'
|
||
|
),
|
||
|
));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getTooltip($atts){
|
||
|
if ( is_array( $atts ) ) {
|
||
|
foreach ( $atts as $k => $v ) {
|
||
|
if ( 'false' === $v ) {
|
||
|
$atts[ $k ] = false;
|
||
|
}
|
||
|
}
|
||
|
$link = $atts['link'];
|
||
|
$title = $atts['title'];
|
||
|
}
|
||
|
|
||
|
$output = "";
|
||
|
$user = wp_get_current_user();
|
||
|
$allowed_roles = array('administrator','manager');
|
||
|
if( array_intersect($allowed_roles, $user->roles ) ) {
|
||
|
$output = '<div class="tooltip-al-wrapper">
|
||
|
<a href="'.$link.'" target="_blank" title="'.$title.'">
|
||
|
<div class="tooltip-al">
|
||
|
<span class="dashicons dashicons-edit"></span>
|
||
|
</div>
|
||
|
</a>
|
||
|
</div>';
|
||
|
if(!empty($atts['do_short_code'])){
|
||
|
$output = '<div class="tooltip-al-parent">'.$output.'</div>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $output;
|
||
|
|
||
|
}
|
||
|
add_shortcode( 'getTooltip', 'getTooltip' );
|
||
|
|
||
|
|
||
|
?>
|