Plugin Directory

Changeset 2755017


Ignore:
Timestamp:
07/12/2022 11:40:38 AM (3 years ago)
Author:
marioshtika
Message:

Release version 1.0.1

Location:
horizontal-footer-sitemap-widget
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • horizontal-footer-sitemap-widget/trunk/horizontal-footer-sitemap-widget.php

    r992371 r2755017  
    44Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
    55Description: A simple widget which uses the menu of your selection to show them horizontaly as a Horizontal Footer Sitemap
    6 Version: 1.0
     6Version: 1.0.1
    77Author: Mario Shtika
    88Author URI: http://mario.shtika.info
     
    1010*/
    1111
    12      
     12
    1313/* Start Adding Functions Below this Line */
    1414
    1515// Creating the widget
    16 class horizontal_footer_sitemap_widget extends WP_Widget {
     16class horizontal_footer_sitemap_widget extends WP_Widget
     17{
     18    function __construct()
     19    {
     20        parent::__construct(
     21            // Base ID of your widget
     22            'horizontal_footer_sitemap_widget',
     23            // Widget name will appear in UI
     24            __('Horizontal Footer Sitemap', 'horizontal_footer_sitemap_widget'),
     25            // Widget description
     26            array('description' => __('Add a custom menu to your side bar and show it horizontaly as a Horizontal Footer Sitemap', 'horizontal_footer_sitemap_widget'),)
     27        );
    1728
    18     function __construct() {
    19         parent::__construct(
    20             // Base ID of your widget
    21             'horizontal_footer_sitemap_widget',
    22             // Widget name will appear in UI
    23             __('Horizontal Footer Sitemap', 'horizontal_footer_sitemap_widget'),
    24             // Widget description
    25             array('description' => __('Add a custom menu to your side bar and show it horizontaly as a Horizontal Footer Sitemap', 'horizontal_footer_sitemap_widget'),)
    26         );
    27        
    28         // Register style sheet.
    29         add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) );
    30     }
     29        // Register style sheet.
     30        add_action('wp_enqueue_scripts', array($this, 'register_plugin_styles'));
     31    }
    3132
    32     // Widget Frontend
    33     public function widget($args, $instance) {
    34         // Get menu
    35         $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
    36        
    37         if ( !$nav_menu ) {
    38             return;
    39         }
     33    // Widget Frontend
     34    public function widget($args, $instance)
     35    {
     36        // Get menu
     37        $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
    4038
    41         echo '<div id="footer_sitemap_widget">';
    42         echo $args['before_widget'];
     39        if (!$nav_menu) {
     40            return;
     41        }
    4342
    44         wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
     43        echo '<div id="footer_sitemap_widget">';
     44        echo $args['before_widget'];
    4545
    46         echo $args['after_widget'];
    47         echo '</div>';
    48     }
    49    
    50     public function register_plugin_styles() {
    51         wp_register_style('horizontal_footer_sitemap_widget', plugins_url('/css/widget.css', __FILE__));
    52                
    53         wp_enqueue_style('horizontal_footer_sitemap_widget');
    54     }
    55    
    56     // Widget Backend
    57     public function form($instance) {
    58         $nav_menu = isset($instance['nav_menu']) ? $instance['nav_menu'] : '';
    59        
    60         // Get menus
    61         $menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );
    62        
    63         // If no menus exists, direct the user to go and create some.
    64         if ( !$menus ) {
    65             echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
    66             return;
    67         }
    68         ?>
    69        
    70         <?php // Widget admin form ?>
    71         <p>
    72             <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
    73             <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
    74                 <option value="0"><?php _e( '&mdash; Select &mdash;' ) ?></option>
    75                 <?php
    76                     foreach ( $menus as $menu ) {
    77                         echo '<option value="' . $menu->term_id . '"'
    78                             . selected( $nav_menu, $menu->term_id, false )
    79                             . '>'. esc_html( $menu->name ) . '</option>';
    80                     }
    81                 ?>
    82             </select>
    83         </p>
    84         <?php
    85     }
     46        wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu));
    8647
    87     // Updating widget replacing old instances with new
    88     public function update($new_instance, $old_instance) {
    89         $instance = array();
    90         if (!empty($new_instance['nav_menu'])) {
    91             $instance['nav_menu'] = (int) $new_instance['nav_menu'];
    92         }
    93         return $instance;       
    94     }
     48        echo $args['after_widget'];
     49        echo '</div>';
     50    }
    9551
     52    public function register_plugin_styles()
     53    {
     54        wp_register_style('horizontal_footer_sitemap_widget', plugins_url('/css/widget.css', __FILE__));
     55
     56        wp_enqueue_style('horizontal_footer_sitemap_widget');
     57    }
     58
     59    // Widget Backend
     60    public function form($instance)
     61    {
     62        $nav_menu = isset($instance['nav_menu']) ? $instance['nav_menu'] : '';
     63
     64        // Get menus
     65        $menus = wp_get_nav_menus(array('orderby' => 'name'));
     66
     67        // If no menus exists, direct the user to go and create some.
     68        if (!$menus) {
     69            echo '<p>' . sprintf(__('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php')) . '</p>';
     70            return;
     71        }
     72        ?>
     73        <p>
     74            <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
     75            <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
     76                <option value="0"><?php _e('&mdash; Select &mdash;') ?></option>
     77                <?php
     78                foreach ($menus as $menu) {
     79                    echo '<option value="' . $menu->term_id . '"'
     80                        . selected($nav_menu, $menu->term_id, false)
     81                        . '>' . esc_html($menu->name) . '</option>';
     82                }
     83                ?>
     84            </select>
     85        </p>
     86        <?php
     87    }
     88
     89    // Updating widget replacing old instances with new
     90    public function update($new_instance, $old_instance)
     91    {
     92        $instance = array();
     93        if (!empty($new_instance['nav_menu'])) {
     94            $instance['nav_menu'] = (int) $new_instance['nav_menu'];
     95        }
     96        return $instance;
     97    }
    9698}
    9799
    98100// Class horizontal_footer_sitemap_widget ends here
    99101// Register and load the widget
    100 function horizontal_footer_sitemap_widget_load_widget() {
    101     register_widget('horizontal_footer_sitemap_widget');
     102function horizontal_footer_sitemap_widget_load_widget()
     103{
     104    register_widget('horizontal_footer_sitemap_widget');
    102105}
    103106
  • horizontal-footer-sitemap-widget/trunk/readme.txt

    r992371 r2755017  
    33Tags: horizontal menu, footer html sitemap
    44Requires at least: 4.0
    5 Tested up to: 4.0
    6 Stable tag: 1.0
     5Tested up to: 6.0
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.