Plugin Directory

Changeset 2932444


Ignore:
Timestamp:
06/29/2023 09:23:08 PM (3 years ago)
Author:
smanimania
Message:

Optimization of the plugin code and structure

Location:
developress-sticky-footer-bar/trunk
Files:
4 added
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • developress-sticky-footer-bar/trunk/css/css-frontend.css

    r2932443 r2932444  
    122122font-size: 10px;
    123123}
    124 
  • developress-sticky-footer-bar/trunk/developress_sticky_footer_bar.php

    r2931635 r2932444  
    1010 *
    1111 * @link              developress.it/roberto_paolucci
    12  * @since             2.0.9
     12 * @since             2.1.0
    1313 * @package           Developress_sticky_footer_bar
    1414 *
     
    1717 * Plugin URI:        developress.it/plugin/developress_sticky_footer_bar
    1818 * Description:       Plugin per la gestione di una footer bar
    19  * Version:           2.0.9
     19 * Version:            2.1.0
    2020 * Author:            Roberto Paolucci - DeveloPress.it
    2121 * Author URI:        developress.it/roberto_paolucci
     
    2525 * Domain Path:       /languages
    2626 */
    27 
    28 
    2927
    3028// Funzione per creare la pagina delle opzioni
     
    5755    ?>
    5856
    59 
    60 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    61 
    6257    <div class="wrap">
    6358        <h1>StickyBar Settings</h1>
    6459       
    65 <!-- info box - start -->
    66        
    67 <style>
    68 .link-info-box {
    69       display: inline-block;
    70       background-color: #fff;
    71       padding: 5px 20px 7px 20px;
    72       color: #02a1f0;
    73       font-weight: 700;
    74       border-radius: 5px;
    75       margin-right: 5px;
    76       margin-bottom: 10px;
    77       border: 1px solid #02a1f0;
    78     }
    79 
    80     .link-info-box i {
    81       margin-left: 5px;
    82     }
    83 
    84     @media (min-width: 768px) {
    85       .link-info-box {
    86         width: 50%;
    87       }
    88     }
    89 
    90     @media (min-width: 1024px) {
    91       .link-info-box {
    92         width: 25%;
    93       }
    94     }
    95 
    96         .link-info-box a{
    97         text-decoration:none;
    98     }
    99 
    100  
    101     .row-avatar {
    102       display: flex;
    103       align-items: flex-start;
    104     }
    105    
    106     .column {
    107       padding: 10px;
    108     }
    109    
    110     img {
    111       max-width: 100%;
    112       height: auto;
    113       margin-right: 10px;
    114     }
    115    
    116     .column p {
    117       margin: 0;
    118     }
    119 
    120     .thankyou-rightside {
    121         background-color:#ffffff !important;
    122     }
    123     .icon-headset-developress {
    124         color:#009704;
    125     }   
    126    
    127     .icon-tab-big {
    128         color:#009704;
    129         font-size:21px;
    130         margin-right:20px;
    131     }   
    132 </style>       
    133        
     60<!-- info box - start -->       
    13461<div style="margin-top:30px; margin-bottom:30px;">
    13562
     
    15986    <!-- CTAs - end -->
    16087
    161 
    162    
    16388</div>
    16489<!-- info box - end -->
    16590       
    166         <form method="post" action="options.php">
    167            
    168 <!-- tab - start -->
    169 
    170   <style>
    171     /* Stili delle tab */
    172     .tab {
    173       display: none;
    174     }
    175 
    176     /* Stili dei link delle tab */
    177     .tab-label {
    178       background-color: #f1f1f1;
    179       padding: 8px 16px;
    180       cursor: pointer;
    181       border: none;
    182       outline: none;
    183       font-weight: bold;
    184       text-decoration:none;     
    185     }
    186 
    187     /* Stili della tab attiva */
    188     .tab-label.active {
    189       background-color: #fff;
    190       background-color:#fff;   
    191       text-decoration:none;
    192     }
    193 
    194     /* Stili delle tabelle */
    195     .tab-content {
    196       display: none;
    197       padding: 16px;
    198       background-color:#fff;
    199       margin-top:6px;
    200      
    201        
    202     }
    203 
    204     /* Stili della tab attiva */
    205     .tab-content.active {
    206       display: block;
    207        
    208     }
    209      
    210   </style>
    211 
     91<form method="post" action="options.php">
    21292  <a href="#" class="tab-label" onclick="openTab(event, 'tab1')"><i class="fas fa-toggle-on"></i> Active Bar</a>
    21393  <a href="#" class="tab-label" onclick="openTab(event, 'tab2')"><i class="fas fa-paint-brush"></i> Style</a>
     
    468348    </table>
    469349  </div>
    470            
    471   <script>
    472     function openTab(evt, tabName) {
    473       evt.preventDefault();
    474 
    475       // Nasconde tutti i contenuti delle tab
    476       var tabContent = document.getElementsByClassName("tab-content");
    477       for (var i = 0; i < tabContent.length; i++) {
    478         tabContent[i].style.display = "none";
    479       }
    480 
    481       // Rimuove la classe "active" da tutti i link delle tab
    482       var tabLabels = document.getElementsByClassName("tab-label");
    483       for (var i = 0; i < tabLabels.length; i++) {
    484         tabLabels[i].className = tabLabels[i].className.replace(" active", "");
    485       }
    486 
    487       // Mostra il contenuto della tab selezionata e aggiunge la classe "active" al link della tab corrispondente
    488       document.getElementById(tabName).style.display = "block";
    489       evt.currentTarget.className += " active";
    490     }
    491 
    492     // Apre la Tab 1 di default al caricamento della pagina
    493     document.getElementById("tab1").style.display = "block";
    494     document.getElementsByClassName("tab-label")[0].className += " active";
    495   </script>
     350
    496351   
    497352<!-- tab - end -->
     
    535390add_action('admin_init', 'registra_opzioni_tema');
    536391
     392
     393
    537394// Funzione per mostrare i valori delle opzioni nel footer
    538395function mostra_valori_opzioni_footer() {
     
    545402    $menu_select = get_option('menu_select');
    546403
    547 
    548    
    549    
    550404// start bar html
    551405
     
    555409      $hyde_bar = "none";
    556410  }
    557   ?>
    558 
    559 
    560 
    561 <?php
     411 
     412
    562413$menu_locations = get_nav_menu_locations(); // Ottiene tutte le posizioni dei menu
    563414$menu_id = $menu_locations['stikybar']; // Ottiene l'ID del menu nella posizione 'stikybar'
     
    576427?>
    577428
    578 
    579429<div style="margin-top:5%"></div>
    580 
    581430  <div class="footer-developress" style="display:<?php echo $hyde_bar; ?>;background-color:<?php echo $background_bar; ?>;">
    582431    <div class="footer-item sidebar-icon-menu" style="cursor:pointer" onclick="openNav()">
    583432        <i style="color: <?php echo $font_color;?>" class="fas fa-bars footer-icon"></i>
    584433        <span style="color: <?php echo $font_color;?>" class="footer-label ">Menu</span>
    585 
    586434    </div>   
    587435
     
    637485                    echo '<div class="side-item-box ' . $menu_item->classes[0] . '">';
    638486                    echo '<a class="link-item-bar" href="' . $menu_item->url . '">';
    639                    
    640                     echo '<i style="color: ' . $font_color . ';" class="fas fa-' . $menu_item->classes[0] . ' footer-icon"></i>'; // Utilizza la classe CSS assegnata come classe per l'icona
    641                    
    642 
    643                    
     487                    echo '<i style="color: ' . $font_color . ';" class="fas fa-' . $menu_item->classes[0] . ' footer-icon"></i>'; // Utilizza la classe CSS assegnata come classe per l'icona   
    644488                    echo '<span class="footer-label" style="margin-left:20px;color: ' . $font_color . ';">' . $menu_item->title . '</span>'; // Utilizza il titolo della voce di menu come label
    645                     echo "<div class='linea-div-menu'></div>";
    646                    
    647 
    648                    
     489                    echo "<div class='linea-div-menu'></div>";
    649490                    echo '</a>';
    650                    
    651491                    echo '</div>';
    652492                }
     
    660500    }
    661501    ?>
    662 
    663502</div>
    664503
     
    666505
    667506// end bar html
    668 
    669507
    670508}
     
    673511add_action('wp_footer', 'mostra_valori_opzioni_footer');
    674512
    675 // Funzione per mostrare la lista delle voci di menu scelto
    676 function mostra_voci_menu() {
    677     $menu_select = get_option('menu_select');
    678 
    679     if (!empty($menu_select)) {
    680         $menu_object = wp_get_nav_menu_object($menu_select);
    681 
    682         if ($menu_object) {
    683             $menu_items = wp_get_nav_menu_items($menu_object->term_id);
    684 
    685             if (!empty($menu_items)) {
    686                 echo '<table>';
    687                 echo '<tr><th>Menu Item</th></tr>';
    688 
    689                 foreach ($menu_items as $menu_item) {
    690                     echo '<tr><td>' . $menu_item->title . '</td></tr>';
    691                 }
    692 
    693                 echo '</table>';
    694             }
    695         }
    696     }
    697 }
    698 
    699513
    700514// Funzione per inserire i codici CSS nel tag <head>
    701 function css_head_developress() {
     515function css_js_head_front_developress() {
    702516    $custom_css = get_option('custom_css');
    703517    if (!empty($custom_css)) {
     
    705519        echo '<style type="text/css">' . $custom_css . '</style>';
    706520    }
    707     ?>
    708 
    709     <?php
     521 
    710522    $plugin_url = plugin_dir_url( __FILE__ );
    711523    $visibility = get_option('visibility');
     
    727539      wp_enqueue_style( 'plugin-style', $plugin_url . 'css/only_phone_tablet.css' );
    728540      break;
    729 
    730 
    731541      default:
    732542      echo "";
    733543      break;
    734544  }
    735 
    736 
    737 
    738545  ?>       
    739546
    740   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    741   <link rel="stylesheet" href="<?php echo $plugin_url;?>css/main.css">
    742 
    743 
    744 
    745 
    746   <script>
    747     function openNav() {
    748       document.getElementById("mySidenav").style.width = "250px";
    749   }
    750 
    751   function closeNav() {
    752       document.getElementById("mySidenav").style.width = "0";
    753   }
    754 </script>
    755 
     547 
     548 
    756549
    757550<?php
    758 
    759 }
    760 add_action('wp_head', 'css_head_developress', 100);
    761 
    762 
    763 
    764 
    765 // Funzione per inserire i codici JS nel tag <head>
    766 function js_head_developress() {
    767 
    768 
    769     ?>
    770 
    771 
    772 
    773 
    774    
    775     <script>
    776         function openNav() {
    777           document.getElementById("mySidenav").style.width = "250px";
    778       }
    779 
    780       function closeNav() {
    781           document.getElementById("mySidenav").style.width = "0";
    782       }
    783   </script>
    784 
    785 
    786   <?php
    787 
    788 
    789 }
    790 add_action('wp_head', 'js_head_developress', 100);
     551}
     552add_action('wp_head', 'css_js_head_front_developress', 100);
     553
    791554
    792555// Link to settings page from plugins screen
     
    799562}
    800563
    801 ?>
    802 
     564
     565// Gestione CSS e JS
     566
     567function developress_enqueue_scripts_js_frontend() {
     568    wp_enqueue_script( 'js_frontend_developress', plugin_dir_url( __FILE__ ) . 'js/js-frontend.js', array(), '1.0', true );
     569}
     570add_action( 'wp_enqueue_scripts', 'developress_enqueue_scripts_js_frontend' );
     571
     572function developress_enqueue_scripts_js_backend() {
     573    wp_enqueue_script( 'js_frontend_developress', plugin_dir_url( __FILE__ ) . 'js/js-backend.js', array(), '1.0', true );
     574}
     575add_action( 'admin_enqueue_scripts', 'developress_enqueue_scripts_js_backend' );
     576
     577function developress_enqueue_scripts_css_backend() {
     578    wp_enqueue_style( 'css_frontend_developress', plugin_dir_url( __FILE__ ) . 'css/css-backend.css', array(), '1.0' );
     579}
     580add_action( 'admin_enqueue_scripts', 'developress_enqueue_scripts_css_backend' );
     581
     582function developress_enqueue_scripts_css_frontend() {
     583    wp_enqueue_style( 'css_frontend_developress', plugin_dir_url( __FILE__ ) . 'css/css-frontend.css', array(), '1.0' );
     584}
     585add_action( 'wp_enqueue_scripts', 'developress_enqueue_scripts_css_frontend' );
     586
     587
     588function developress_enqueue_fontawasome_css_frontend() {
     589    wp_enqueue_style( 'font_awesome_css', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css', array(), '5.15.3' );
     590}
     591add_action( 'wp_enqueue_scripts', 'developress_enqueue_fontawasome_css_frontend' );
     592
     593function developress_enqueue_fontawasome_css_backend() {
     594    wp_enqueue_style( 'font_awesome_css', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css', array(), '5.15.3' );
     595}
     596add_action( 'admin_enqueue_scripts', 'developress_enqueue_fontawasome_css_backend' );
     597
     598?>
Note: See TracChangeset for help on using the changeset viewer.