Plugin Directory

Changeset 3172497


Ignore:
Timestamp:
10/20/2024 09:47:47 PM (15 months ago)
Author:
jorgedelcampo
Message:

-- new version 1.1.0

Location:
toggle-hide-show-admin-bar/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • toggle-hide-show-admin-bar/trunk/readme.txt

    r3150951 r3172497  
    3737== Changelog ==
    3838
     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
    3943= 1.0 =
    4044* Initial release.
     
    4246== Upgrade Notice ==
    4347
     48= 1.1.0 =
     49Added uninstall functionality to remove plugin options from the database and a check to verify if admin bar is hidden for the current user.
     50
    4451= 1.0 =
    4552Initial release.
  • toggle-hide-show-admin-bar/trunk/toggle-admin-bar.css

    r3150372 r3172497  
    1 #toggleAdminBar {
    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;
    88}
    9 #toggleAdminBar input {
    10     display: none;
     9#thsabToggleAdminBar input {
     10  display: none;
    1111}
    12 #toggleAdminBar input + label::before {
    13     content: 'Hide admin bar';
     12#thsabToggleAdminBar input + label::before {
     13  content: "Admin bar shown";
    1414}
    15 #toggleAdminBar input:checked + label::before {
    16     content: 'Show admin bar';
     15#thsabToggleAdminBar input:checked + label::before {
     16  content: "Admin bar hidden";
    1717}
    18 #toggleAdminBar 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;
    2121}
    22 #toggleAdminBar 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 */
    2424}
    25 #toggleAdminBar 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 */
    2727}
    28 #toggleAdminBar 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 */
    3030}
    31 #toggleAdminBar 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 */
    3333}
     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');
     1document.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");
    68
    7         // Apply settings
    8         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    }
    1719
    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;
    2022
    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    }
    3032
    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  }
    4143});
  • toggle-hide-show-admin-bar/trunk/toggle-admin-bar.php

    r3150372 r3172497  
    4242        // Determine initial state based on admin bar visibility
    4343        $admin_bar_visible = is_admin_bar_showing() ? 'show' : 'hide';
    44 
    45         // HTML for the toggle button with Font Awesome icons
    46         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 bar
    50         echo '<i class="fa fa-eye-slash"></i>'; // Icon for hiding admin bar
    51         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
    5353    }
    5454}
     
    8080    if ( ! current_user_can( 'manage_options' ) ) {
    8181        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
    8295    }
    8396    ?>
Note: See TracChangeset for help on using the changeset viewer.