Changeset 3172497
- Timestamp:
- 10/20/2024 09:47:47 PM (15 months ago)
- Location:
- toggle-hide-show-admin-bar/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (2 diffs)
-
toggle-admin-bar.css (modified) (1 diff)
-
toggle-admin-bar.js (modified) (1 diff)
-
toggle-admin-bar.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
toggle-hide-show-admin-bar/trunk/readme.txt
r3150951 r3172497 37 37 == Changelog == 38 38 39 = 1.1.0 = 40 * Added uninstall.php file to clean up plugin options from the database upon deletion. 41 * Added function to check if admin bar is hidden for the current user. 42 39 43 = 1.0 = 40 44 * Initial release. … … 42 46 == Upgrade Notice == 43 47 48 = 1.1.0 = 49 Added uninstall functionality to remove plugin options from the database and a check to verify if admin bar is hidden for the current user. 50 44 51 = 1.0 = 45 52 Initial release. -
toggle-hide-show-admin-bar/trunk/toggle-admin-bar.css
r3150372 r3172497 1 #t oggleAdminBar {2 position: fixed;3 bottom: 20px;4 padding: 10px;5 background-color: #000000; /* Default background color */6 color: #ffffff; /* Default text color */7 transition: transform.25s;1 #thsabToggleAdminBar { 2 position: fixed; 3 bottom: 20px; 4 padding: 10px; 5 background-color: #000000; /* Default background color */ 6 color: #ffffff; /* Default text color */ 7 transition: transform 0.25s; 8 8 } 9 #t oggleAdminBar input {10 display: none;9 #thsabToggleAdminBar input { 10 display: none; 11 11 } 12 #t oggleAdminBar input + label::before {13 content: 'Hide admin bar';12 #thsabToggleAdminBar input + label::before { 13 content: "Admin bar shown"; 14 14 } 15 #t oggleAdminBar input:checked + label::before {16 content: 'Show admin bar';15 #thsabToggleAdminBar input:checked + label::before { 16 content: "Admin bar hidden"; 17 17 } 18 #t oggleAdminBar label {19 color: inherit; /* Use text color from options */20 font-size: medium;18 #thsabToggleAdminBar label { 19 color: inherit; /* Use text color from options */ 20 font-size: medium; 21 21 } 22 #t oggleAdminBar label i {23 margin-left: 10px; /* Espacio entre los íconos y el texto*/22 #thsabToggleAdminBar label i { 23 margin-left: 10px; /* Gap beetween icon and text */ 24 24 } 25 #t oggleAdminBar label .fa-eye {26 display: none; /* Inicialmente oculto*/25 #thsabToggleAdminBar label .fa-eye { 26 display: inline-block; /* If input is not checked: show normal eye */ 27 27 } 28 #t oggleAdminBar input:checked +label .fa-eye-slash {29 display: none; /* Cuando está marcado, ocultar el ícono del ojo*/28 #thsabToggleAdminBar label .fa-eye-slash { 29 display: none; /* If input is checked: hide normal eye */ 30 30 } 31 #t oggleAdminBar input:checked + label .fa-eye {32 display: inline-block; /* Mostrar el ícono del ojo tachado cuando está marcado*/31 #thsabToggleAdminBar input:checked + label .fa-eye { 32 display: none; /* If input is checked: show slashed eye */ 33 33 } 34 #thsabToggleAdminBar input:checked + label .fa-eye-slash { 35 display: inline-block; /* If input is not checked: hide slashed eye */ 36 } -
toggle-hide-show-admin-bar/trunk/toggle-admin-bar.js
r3150372 r3172497 1 document.addEventListener('DOMContentLoaded', function(){ 2 const adminBar = document.getElementById('wpadminbar'); 3 if(adminBar){ 4 const toggleAdminBarCheckbox = document.querySelector('#toggleAdminBar > input#toggleAdminBarCheckbox'); 5 const toggleAdminBar = document.getElementById('toggleAdminBar'); 1 document.addEventListener("DOMContentLoaded", function () { 2 const adminBar = document.getElementById("wpadminbar"); 3 if (adminBar) { 4 const thsabToggleAdminBarCheckbox = document.querySelector( 5 "#thsabToggleAdminBar > input#thsabToggleAdminBarCheckbox" 6 ); 7 const thsabToggleAdminBar = document.getElementById("thsabToggleAdminBar"); 6 8 7 // Apply settings8 if (tabOptions.position === 'bottom-right') {9 toggleAdminBar.style.left = 'auto';10 toggleAdminBar.style.right = '0';11 toggleAdminBar.style.borderRadius = '10px 0 0 10px';12 } else {13 toggleAdminBar.style.left = '0';14 toggleAdminBar.style.right = 'auto';15 toggleAdminBar.style.borderRadius = '0 10px 10px 0';16 }9 // Apply settings 10 if (tabOptions.position === "bottom-right") { 11 thsabToggleAdminBar.style.left = "auto"; 12 thsabToggleAdminBar.style.right = "0"; 13 thsabToggleAdminBar.style.borderRadius = "10px 0 0 10px"; 14 } else { 15 thsabToggleAdminBar.style.left = "0"; 16 thsabToggleAdminBar.style.right = "auto"; 17 thsabToggleAdminBar.style.borderRadius = "0 10px 10px 0"; 18 } 17 19 18 toggleAdminBar.style.backgroundColor = tabOptions.background_color;19 toggleAdminBar.style.color = tabOptions.text_color;20 thsabToggleAdminBar.style.backgroundColor = tabOptions.background_color; 21 thsabToggleAdminBar.style.color = tabOptions.text_color; 20 22 21 if (tabOptions.behavior === 'hide-partially') {22 toggleAdminBar.style.transform = 'translateX(-80%)';23 toggleAdminBar.addEventListener('mouseenter', function() {24 toggleAdminBar.style.transform = 'translateX(0)';25 });26 toggleAdminBar.addEventListener('mouseleave', function() {27 toggleAdminBar.style.transform = 'translateX(-80%)';28 });29 }23 if (tabOptions.behavior === "hide-partially") { 24 thsabToggleAdminBar.style.transform = "translateX(-80%)"; 25 thsabToggleAdminBar.addEventListener("mouseenter", function () { 26 thsabToggleAdminBar.style.transform = "translateX(0)"; 27 }); 28 thsabToggleAdminBar.addEventListener("mouseleave", function () { 29 thsabToggleAdminBar.style.transform = "translateX(-80%)"; 30 }); 31 } 30 32 31 toggleAdminBarCheckbox.addEventListener('change', function(){32 if(this.checked) {33 adminBar.style.display = 'none';34 document.body.style.marginTop = '0';35 } else {36 adminBar.style.display = 'block';37 document.body.style.marginTop = adminBar.offsetHeight + 'px';38 }39 });40 }33 thsabToggleAdminBarCheckbox.addEventListener("change", function () { 34 if (this.checked) { 35 adminBar.style.display = "none"; 36 document.body.style.marginTop = "0"; 37 } else { 38 adminBar.style.display = "block"; 39 document.body.style.marginTop = adminBar.offsetHeight + "px"; 40 } 41 }); 42 } 41 43 }); -
toggle-hide-show-admin-bar/trunk/toggle-admin-bar.php
r3150372 r3172497 42 42 // Determine initial state based on admin bar visibility 43 43 $admin_bar_visible = is_admin_bar_showing() ? 'show' : 'hide'; 44 45 // HTML for the toggle button with Font Awesome icons46 echo '<div id="toggleAdminBar" class="' . esc_attr($admin_bar_visible) . '">';47 echo '<input type="checkbox" id="toggleAdminBarCheckbox">';48 echo '<label for="toggleAdminBarCheckbox">';49 echo '<i class="fa fa-eye"></i>'; // Icon for showing admin bar50 echo '<i class="fa fa-eye-slash"></i>'; // Icon for hiding admin bar51 echo '</label>';52 echo '</div>';44 ?> 45 <div id="thsabToggleAdminBar" class="' . esc_attr($admin_bar_visible) . '"> 46 <input type="checkbox" id="thsabToggleAdminBarCheckbox"> 47 <label for="thsabToggleAdminBarCheckbox"> 48 <i class="fa fa-eye"></i> 49 <i class="fa fa-eye-slash"></i> 50 </label> 51 </div> 52 <?php 53 53 } 54 54 } … … 80 80 if ( ! current_user_can( 'manage_options' ) ) { 81 81 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'toggle-hide-show-admin-bar' ) ); 82 } 83 84 $user_id = get_current_user_id(); 85 // Get 'show_admin_bar_front' option value from wp_usermeta 86 $show_admin_bar_front = get_user_meta( $user_id, 'show_admin_bar_front', true ); 87 88 // Check if value is false to show a warning 89 if ( $show_admin_bar_front === 'false' ) { 90 ?> 91 <div class="notice notice-warning is-dismissible"> 92 <p>Important! Your profile is not configured to show admin bar in front-end. If you want to enjoy this plugin, <a href="/wp-admin/profile.php">enable this option</a> and comeback to this page.</p> 93 </div> 94 <?php 82 95 } 83 96 ?>
Note: See TracChangeset
for help on using the changeset viewer.