Plugin Directory

Changeset 451505


Ignore:
Timestamp:
10/16/2011 05:03:36 AM (14 years ago)
Author:
thiudis
Message:

Added references to the author's website.
Changed the code to be object-oriented.
No new functionality in this version.

Location:
custom-menu/trunk
Files:
16 added
2 edited

Legend:

Unmodified
Added
Removed
  • custom-menu/trunk/custom-menu.php

    r428870 r451505  
    22/*
    33Plugin Name: Custom Menu
    4 Plugin URI: http://www.evolonix.com/wordpress/plugins/custom-menu/
     4Plugin URI: http://www.evolonix.com/wordpress/plugins/custom-menu
    55Description: This plugin allows you to display a custom menu that you've created in your theme's "Menus" section in a post or page. Use [menu name="Menu Name"] in your post or page to insert the custom menu. The "name" attribute is required. Since version 1.2, you can now provide a "title" attribute to add a header title to your custom menu (e.g. [menu name="Menu Name" title="My Menu"].)
    6 Version: 1.2
     6Version: 1.3
    77Author: Evolonix
    88Author URI: http://www.evolonix.com
    99License: GPL2
     10Text Domain: custom-menu
    1011*/
    1112?>
     
    2930<?php
    3031
    31 if ( ! function_exists( 'get_custom_menu' ) ) :
     32// Install
     33// NOTE: References shortcode.
     34require_once(plugin_dir_path(__FILE__) . 'class-custom-menu-install.php');
     35register_activation_hook(__FILE__, array('Custom_Menu_Install', 'activate'));
     36register_deactivation_hook(__FILE__, array('Custom_Menu_Install', 'deactivate'));
    3237
    33 function get_custom_menu($atts) {
    34     if ( !isset( $atts['name'] ) )
    35         return;
    36    
    37     // Get menu
    38     $nav_menu = wp_get_nav_menu_object( $atts['name'] );
     38// I18n
     39add_action('init', function() { load_plugin_textdomain('custom-menu', false, basename(dirname(__FILE__)) . '/languages'); });
    3940
    40     if ( !$nav_menu )
    41         return;
    42        
    43     if ( !empty($atts['title']) )
    44         echo '<h3 class="custom-menu-title">' . $atts['title'] . '</h3>';
    45    
    46     wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
    47 }
     41// Admin
     42require_once(plugin_dir_path(__FILE__) . 'class-custom-menu-admin.php');
     43$custom_menu_admin = new Custom_Menu_Admin();
     44add_action('admin_init', array(&$custom_menu_admin, 'init'));
     45add_action('wp_before_admin_bar_render', array(&$custom_menu_admin, 'before_admin_bar_render')); // (optional)
    4846
    49 endif; //get_custom_menu
     47// Front-end (optional)
     48require_once(plugin_dir_path(__FILE__) . 'class-custom-menu.php');
     49$custom_menu = new Custom_Menu();
     50add_action('plugins_loaded', array(&$custom_menu, 'init'));
    5051
    51 add_shortcode( 'menu', 'get_custom_menu' );
     52// Shortcode (optional)
     53require_once(plugin_dir_path(__FILE__) . 'class-custom-menu-shortcode.php');
     54$custom_menu_shortcode = new Custom_Menu_Shortcode();
     55add_shortcode('menu', array(&$custom_menu_shortcode, 'content'));
    5256
    5357?>
  • custom-menu/trunk/readme.txt

    r428870 r451505  
    1616
    17171. Upload `custom-menu` to the `/wp-content/plugins/` directory
    18 2. Activate the plugin through the 'Plugins' menu in WordPress
    19 3. Place `[menu name="Menu Name"]` in your posts or pages wherever you want the menu to display.
    20 4. Optionally, provide a "title" attribute to add a header title to the custom menu.
     181. Activate the plugin through the 'Plugins' menu in WordPress
     191. Place `[menu name="Menu Name"]` in your posts or pages wherever you want the menu to display.
     201. Optionally, provide a "title" attribute to add a header title to the custom menu.
    2121
    2222== Frequently Asked Questions ==
     23
    2324
    2425
     
    2627
    2728
     29
    2830== Changelog ==
    2931
    30 = 1.1 =
    31 * Changed the plugin to use the name="Menu Name" attribute instead of just specifying the name in the brackets.
     32= 1.3 =
     33* Added references to the author's website.
     34* Changed the code to be object-oriented.
    3235
    3336= 1.2 =
     
    3639* You can now provide a "title" attribute to add a header title to your custom menu (e.g. [menu name="Menu Name" title="My Menu"].)
    3740
     41= 1.1 =
     42* Changed the plugin to use the name="Menu Name" attribute instead of just specifying the name in the brackets.
     43
    3844== Upgrade Notice ==
     45
     46= 1.3 =
     47No new functionality in this version.
     48
     49= 1.2 =
     50You should upgrade to version 1.2 so that you can use the "title" attribute and to have it better find and display your menus.
    3951
    4052= 1.1 =
    4153You should upgrade from 1.0 so that it is easier to understand what menu name you are specifying. Before, where you would have specified [menu Menu Name] you now write it like [menu name="Menu Name"]. Much more cleaner and easier to read.
    4254
    43 = 1.2 =
    44 You should upgrade to version 1.2 so that you can use the "title" attribute and to have it better find and display your menus.
    45 
    4655== Arbitrary section ==
    4756
Note: See TracChangeset for help on using the changeset viewer.