Completed changed to plugin
Changed function.php to toggle-aid.php to make it a real plugin.
This commit is contained in:
parent
0e04b179c2
commit
db41dabc14
1
output-2023-09-25-17-34.json
Normal file
1
output-2023-09-25-17-34.json
Normal file
File diff suppressed because one or more lines are too long
BIN
toggle-aid/assets/sprite - orig.png
Normal file
BIN
toggle-aid/assets/sprite - orig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
toggle-aid/assets/sprite.png
Normal file
BIN
toggle-aid/assets/sprite.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
29
toggle-aid/css/toggle-aid.css
Normal file
29
toggle-aid/css/toggle-aid.css
Normal file
@ -0,0 +1,29 @@
|
||||
#wp-admin-bar-toggle-help-links a:focus,#wp-admin-bar-toggle-help-links a:active{
|
||||
background-color: unset;
|
||||
}
|
||||
|
||||
.tooltip-al-wrapper{
|
||||
position: absolute;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
background-color: rgba(255, 143, 143,0.7);
|
||||
border-radius: 4px;
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
.tooltip-al-wrapper .tooltip-al{
|
||||
margin:5px;
|
||||
}
|
||||
/*:not(elementor-editor-active);*/
|
||||
.tooltip-al-parent{
|
||||
height:0px;
|
||||
padding:0px !important;
|
||||
margin:0px !important;
|
||||
display:none;
|
||||
}
|
||||
.elementor-editor-active .tooltip-al-parent{
|
||||
height:unset;
|
||||
padding:0px !important;
|
||||
margin:0px !important;
|
||||
display:unset;
|
||||
}
|
51
toggle-aid/includes/toggle-aid.php
Normal file
51
toggle-aid/includes/toggle-aid.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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' );
|
||||
|
||||
|
||||
?>
|
19
toggle-aid/js/toggle-aid.js
Normal file
19
toggle-aid/js/toggle-aid.js
Normal file
@ -0,0 +1,19 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
if($(".toggle-help-links")){
|
||||
// $(".tooltip-al-wrapper:parent").css('display','none');
|
||||
$(".toggle-help-links").click(function(){
|
||||
if($(".tooltip-al-parent").is(":visible")){
|
||||
$(".toggle-help-links").css("background-color","");
|
||||
$(".tooltip-al-parent").css('display','none');
|
||||
}else{
|
||||
$(".tooltip-al-parent").css('display','block');
|
||||
$(".toggle-help-links").css("background-color","#ff8f8f !important");
|
||||
$("#wp-admin-bar-toggle-help-links a:active").css("background-color","#ff8f8f !important");
|
||||
$("#wp-admin-bar-toggle-help-links a:focus").css("background-color","#ff8f8f !important");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
32
toggle-aid/toggle-aid.php
Normal file
32
toggle-aid/toggle-aid.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Toggle Aid
|
||||
Description: All of the important functionality of your site belongs in this.
|
||||
Version: 0.1
|
||||
License: GPL
|
||||
Author: Richard Turner
|
||||
Author URI: yoururl
|
||||
*/
|
||||
|
||||
if ( get_current_user_id() ){
|
||||
include_once 'includes/toggle-aid.php';
|
||||
}
|
||||
|
||||
function ff_enqueue_styles(){
|
||||
//error_log(__LINE__." ".__FUNCTION__);
|
||||
$template_url = get_template_directory_uri();
|
||||
$plugin_url = plugin_dir_url( __FILE__ );
|
||||
|
||||
if ( get_current_user_id() ){
|
||||
wp_register_script('toggle-aid-script', $plugin_url . 'js/toggle-aid.js', array('jquery'), null, true);
|
||||
wp_enqueue_script('toggle-aid-script');
|
||||
wp_register_style( 'toggle-aid-css', $plugin_url.'css/toggle-aid.css', false, NULL, 'all');
|
||||
wp_enqueue_style( 'toggle-aid-css' );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'ff_enqueue_styles' );
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user