Changeset 2755017
- Timestamp:
- 07/12/2022 11:40:38 AM (3 years ago)
- 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 4 4 Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates 5 5 Description: A simple widget which uses the menu of your selection to show them horizontaly as a Horizontal Footer Sitemap 6 Version: 1.0 6 Version: 1.0.1 7 7 Author: Mario Shtika 8 8 Author URI: http://mario.shtika.info … … 10 10 */ 11 11 12 12 13 13 /* Start Adding Functions Below this Line */ 14 14 15 15 // Creating the widget 16 class horizontal_footer_sitemap_widget extends WP_Widget { 16 class 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 ); 17 28 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 } 31 32 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; 40 38 41 echo '<div id="footer_sitemap_widget">'; 42 echo $args['before_widget']; 39 if (!$nav_menu) { 40 return; 41 } 43 42 44 wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) ); 43 echo '<div id="footer_sitemap_widget">'; 44 echo $args['before_widget']; 45 45 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( '— Select —' ) ?></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)); 86 47 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 } 95 51 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('— Select —') ?></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 } 96 98 } 97 99 98 100 // Class horizontal_footer_sitemap_widget ends here 99 101 // Register and load the widget 100 function horizontal_footer_sitemap_widget_load_widget() { 101 register_widget('horizontal_footer_sitemap_widget'); 102 function horizontal_footer_sitemap_widget_load_widget() 103 { 104 register_widget('horizontal_footer_sitemap_widget'); 102 105 } 103 106 -
horizontal-footer-sitemap-widget/trunk/readme.txt
r992371 r2755017 3 3 Tags: horizontal menu, footer html sitemap 4 4 Requires at least: 4.0 5 Tested up to: 4.06 Stable tag: 1.0 5 Tested up to: 6.0 6 Stable tag: 1.0.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.