Plugin Directory

Changeset 1011880


Ignore:
Timestamp:
10/22/2014 03:46:17 AM (11 years ago)
Author:
Faison
Message:

Uploading Version 2.0.0

Location:
navception
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • navception/trunk/navception.js

    r733229 r1011880  
    1 jQuery(document).ready( function() {
     1jQuery( document ).ready(function() {
    22
    33    var check_for_limbo = function( list_id ) {
    4         if( ! jQuery( this ).is( ':checked' ) ) {
     4        var target = jQuery( this );
     5
     6        if ( ! target.is( ':checked' ) ) {
    57            return;
    68        }
    7 
    8         var target = jQuery(this);
    9 
    10         var handle_response = function( response, status ) {
    11             if( status != "success" || ! response.success ) { return; }
    12 
    13             if( response.causes_limbo ) {
    14                 jQuery('#' + response.checkbox_ul + ' [value=' + response.menu_id + ']' ).prop('checked', false);
    15                 alert( 'Adding that menu would cause an infinite loop, I unchecked it for you :D' );
    16             }
    17         };
    189
    1910        var data = {
    2011            'action': 'check_for_limbo',
    2112            'navception_original_menu': navception.current_menu,
    22             'navception_new_menu' : jQuery( this ).val(),
    23             'navception_checkbox_ul' : jQuery( this ).closest( 'ul' ).prop( 'id' )
     13            'navception_new_menu': target.val(),
     14            'navception_checkbox_ul': target.closest( 'ul' ).prop( 'id' )
     15        };
     16
     17        var handle_response = function( response, status ) {
     18            if ( 'success' != status || ! response.success ) {
     19                return;
     20            }
     21
     22            if ( response.causes_limbo ) {
     23                jQuery( '#' + response.checkbox_ul + ' [value=' + response.menu_id + ']' ).prop( 'checked', false );
     24                alert( 'Adding that menu would cause an infinite loop, I unchecked it for you :D' );
     25            }
    2426        };
    2527
     
    2729    }
    2830
    29     jQuery('#nav_menuchecklist-pop input[type=checkbox], #nav_menuchecklist input[type=checkbox]').on( 'change.navception', check_for_limbo );
    30 
    31 
    32     jQuery('#nav_menu-search-checklist').bind("DOMNodeInserted",function(){
    33         var childs = jQuery(this).find( 'input[type=checkbox]' );
    34         if( childs.length > 0 ) {
    35             var child = childs[ childs.length - 1 ];
    36             jQuery( child ).on( 'change.navception', check_for_limbo );
    37         }
    38     });
    39 } );
     31    jQuery( '#taxonomy-nav_menu' ).on( 'change.navception', 'input[type=checkbox]', check_for_limbo );
     32});
  • navception/trunk/navception.php

    r868145 r1011880  
    11<?php
    2     /*
    3      * Plugin Name: Navception
    4      * Plugin URI: http://faisonz.com/wordpress-plugins/navception/
    5      * Description: Embed WordPress Menus inside of other WordPress Menus!
    6      * Author: Faison Zutavern
    7      * Author URI: http://faisonz.com
    8      * Version: 1.0.0
    9      */
    10 
    11     require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );
    12 
    13     class Navception {
    14 
    15         private $hook;
    16         private $new_menu_id = false;
    17 
    18         function __construct() {
    19             $this->register_hooks();
    20 
    21         }
    22 
    23         function register_hooks() {
    24             add_action( 'admin_init', array( $this, 'add_nav_box' ) );
    25 
    26             add_filter( 'nav_menu_css_class', array( $this, 'navception_class' ), 10, 3 );
    27             add_filter( 'nav_menu_item_id', array( $this, 'navception_id' ), 10, 3 );
    28 
    29             add_filter( 'walker_nav_menu_start_el', array( $this, 'navception' ), 10, 4 );
    30 
    31             add_action( 'wp_ajax_check_for_limbo', array( $this, 'check_for_limbo_ajax' ) );
    32             add_action( 'wp_update_nav_menu_item', array( $this, 'check_for_limbo'), 10, 3);
    33 
    34             add_action('admin_enqueue_scripts', array( $this, 'pw_load_scripts' ) );
    35 
    36             add_action( 'wp_create_nav_menu', array( $this, 'detect_new_menu' ) );
    37         }
    38 
    39         function add_nav_box() {
    40             $tax = get_taxonomy( 'nav_menu' );
    41             $tax = apply_filters( 'nav_menu_meta_box_object', $tax );
    42             if ( $tax ) {
    43                 $id = $tax->name;
    44                 add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
    45             }
    46         }
    47 
    48         function navception_class( $classes, $item, $args = null ) {
    49             if( $item->object != 'nav_menu' ) {
    50                 return $classes;
    51             }
    52 
    53             $items = wp_get_nav_menu_items( $item->object_id );
    54 
    55             if( count( $items ) == 0 ) {
    56                 return $classes;
    57             }
    58 
    59             _wp_menu_item_classes_by_context( $items );
    60             $first_item = $items[ 0 ];
    61 
    62             $navcepted_classes = empty( $first_item->classes ) ? array() : (array) $first_item->classes;
    63             $navcepted_classes[] = 'menu-item-' . $first_item->ID;
    64             $classes = array_merge( $classes, $navcepted_classes );
    65 
    66             $classes = apply_filters( 'nav_menu_css_class', array_filter( $classes ), $first_item, $args );
    67 
    68             return $classes;
    69         }
    70 
    71         function navception_id( $menu_item_id, $item, $args ) {
    72             if( $item->object != 'nav_menu' ) {
    73                 return $menu_item_id;
    74             }
    75 
    76             $items = wp_get_nav_menu_items( $item->object_id );
    77 
    78             if( count( $items ) == 0 ) {
    79                 return $menu_item_id;
    80             }
    81 
    82             $first_item = $items[ 0 ];
    83 
    84             $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $first_item->ID, $first_item, $args );
    85 
    86             return $id;
    87 
    88         }
    89 
    90         /*
    91          *
    92          *
    93          *
    94          *  Tap into walker_nav_menu_start_el
    95          *  params: $item_output, $item, $depth, $args
    96          */
    97         function navception( $item_output, $item, $depth, $args ) {
    98             if( $item->object != 'nav_menu' ) {
    99                 return $item_output;
    100             }
    101 
    102             //  Gotta find this out based on the item included
    103             $navception_menu_id = $item->object_id;
    104             //  if there's a max depth (or -1), do the math to find out how many depths are left.
    105             $num = $args->depth;
    106             if( $num > 0 ) {
    107                 $num -= $depth;
    108             }
    109 
    110             $navcepted_menu = wp_nav_menu( array(
    111                 'menu' => $navception_menu_id,
    112                 'container' => false,
    113                 'fallbak_cb' => false,
    114                 'items_wrap' => '%3$s',
    115                 'depth' => $num,
    116                 'echo' => false
    117             ) );
    118 
    119             $nav_ = explode( '>', $navcepted_menu );
    120             array_shift( $nav_ );
    121             $navcepted_menu = implode( '>', $nav_ );
    122 
    123             $nav_ = explode( '</li', $navcepted_menu );
    124             array_pop( $nav_ );
    125             $navcepted_menu = implode( '</li', $nav_ );
    126 
    127             return $navcepted_menu;
    128 
    129         }
    130 
    131         function check_for_limbo( $menu_id, $menu_item_db_id, $args ) {
    132             if( isset( $args['menu-item-object'] ) && $args['menu-item-object'] == 'nav_menu' ) {
    133                 $original_menu = $menu_id;
    134                 $navception_menu = (int) $args['menu-item-object-id'];
    135 
    136                 if( $this->causes_limbo( $original_menu, $navception_menu ) ) {
    137                     $this->removed_menus[] = $args['menu-item-title'];
    138                     add_action( 'admin_notices', array( $this, 'warn_of_limbo' ) );
    139                     wp_delete_post( $menu_item_db_id, true );
    140 
    141                 }
    142             }
    143         }
    144 
    145         function check_for_limbo_ajax() {
    146             $original_menu = isset( $_POST['navception_original_menu'] ) ? $_POST['navception_original_menu'] : false;
    147             $navcepted_menu = isset( $_POST['navception_new_menu'] ) ? $_POST['navception_new_menu'] : false;
    148             $checkbox_ul = isset( $_POST['navception_checkbox_ul'] ) ? $_POST['navception_checkbox_ul'] : false;
    149             if( ! ( is_numeric( $original_menu ) && is_numeric( $navcepted_menu ) && $checkbox_ul ) ) {
    150                 wp_send_json( array(
    151                     'success' => false
    152                 ) );
    153             }
    154 
    155             $original_menu = (int) $original_menu;
    156             $navcepted_menu = (int) $navcepted_menu;
    157 
    158             if( $this->causes_limbo( $original_menu, $navcepted_menu ) ) {
    159                 wp_send_json( array(
    160                     'success' => true,
    161                     'causes_limbo' => true,
    162                     'checkbox_ul' => $checkbox_ul,
    163                     'menu_id' => $navcepted_menu
    164                 ) );
    165             }
    166 
    167             wp_send_json( array(
    168                 'success' => true,
    169                 'causes_limbo' => false
    170             ) );
    171         }
    172 
    173         function causes_limbo( $original_menu, $navcepted_menu ) {
    174 
    175             if( ! is_array( $original_menu ) ) {
    176                 $original_menu = array( $original_menu );
    177             }
    178 
    179             if( in_array( $navcepted_menu, $original_menu ) ) {
    180                 return true;
    181             }
    182             $original_menu[] = $navcepted_menu;
    183 
    184 
    185             $navcepted_items = wp_get_nav_menu_items( $navcepted_menu );
    186 
    187             foreach( $navcepted_items as $navcepted_item ) {
    188                 if( $navcepted_item->object != 'nav_menu' ) {
     2/*
     3 * Plugin Name: Navception
     4 * Plugin URI: http://faisonz.com/wordpress-plugins/navception/
     5 * Description: Embed WordPress Menus inside of other WordPress Menus!
     6 * Author: Faison Zutavern
     7 * Author URI: http://faisonz.com
     8 * Version: 2.0.0
     9 */
     10
     11/**
     12 * The Navception Plugin Class
     13 *
     14 * @since 1.0.0
     15 *
     16 * @package Navception
     17 */
     18class Navception {
     19
     20    /**
     21     * The Navception Instance.
     22     *
     23     * @since 2.0.0
     24     * @var object
     25     */
     26    private static $instance;
     27
     28    /**
     29     * The current version of Navception.
     30     *
     31     * @since 2.0.0
     32     * @var int
     33     */
     34    const version = '2.0.0';
     35
     36    /**
     37     * The ID of a newly created Menu, if detected.
     38     *
     39     * @since 1.0.0
     40     * @var int
     41     */
     42    private $new_menu_id = 0;
     43
     44    /**
     45     * Function for retreiving the main Navception plugin instance.
     46     *
     47     * @since 2.0.0
     48     *
     49     * @return Navception The main Navception plugin instance.
     50     */
     51    public static function instance() {
     52        if ( ! isset( self::$instance ) || ! self::$instance instanceof Navception ) {
     53            self::$instance = new Navception;
     54            self::$instance->register_hooks();
     55        }
     56
     57        return self::$instance;
     58    }
     59
     60    /**
     61     * Dummy constructor to keep the Navception Singleton from loading more than once.
     62     *
     63     * @since 1.0.0
     64     */
     65    public function __construct() { /* Nothing going on here, move along. */ }
     66
     67    /**
     68     * Hook up Navception functions to needed Filters and Actions.
     69     *
     70     * @since 1.0.0
     71     */
     72    private function register_hooks() {
     73        add_filter( 'wp_get_nav_menu_items', array( $this, 'navception' ), 10, 3 );
     74
     75        if ( ! is_admin() ) {
     76            return;
     77        }
     78
     79        add_action( 'admin_init',              array( $this, 'add_nav_box' ) );
     80        add_action( 'wp_ajax_check_for_limbo', array( $this, 'check_for_limbo_ajax' ) );
     81        add_action( 'wp_update_nav_menu_item', array( $this, 'check_for_limbo'), 10, 3);
     82        add_action( 'admin_enqueue_scripts',   array( $this, 'enqueue_scripts' ) );
     83        add_action( 'wp_create_nav_menu',      array( $this, 'detect_new_menu' ) );
     84    }
     85
     86    /**
     87     * Replace Nav Menu Menu Items with Menus.
     88     *
     89     * @since 1.0.0
     90     *
     91     * @param array  $items An array of menu item post objects.
     92     * @param object $menu  The menu object.
     93     * @param array  $args  An array of arguments used to retrieve menu item objects.
     94     *
     95     * @return array Array of menu items with possible Navception applied.
     96     */
     97    public function navception( $items, $menu, $args ) {
     98        // Don't navcpetion in the admin
     99        if ( is_admin() ) {
     100            return $items;
     101        }
     102
     103        if ( empty( $args['navception_suffix_prefix'] ) ) {
     104            $args['navception_suffix_prefix'] = '-navception';
     105        }
     106
     107        $filtered_items            = array();
     108        $nav_id_suffix             = 1;
     109        $nav_suffix_prefix         = $args['navception_suffix_prefix'];
     110        $nav_parent_suffix         = empty( $args['navception_parent_suffix'] ) ? '' : $args['navception_parent_suffix'];
     111        $previous_menu_item_parent = empty( $args['navception_previous_menu_item_parent'] ) ? 0 : $args['navception_previous_menu_item_parent'];
     112
     113        foreach ( $items as $item ) {
     114            if ( 'nav_menu' != $item->object ) {
     115                $filtered_items[] = $item;
     116                continue;
     117            }
     118
     119            $navception_suffix                = sprintf( '%s%d', $nav_suffix_prefix, $nav_id_suffix );
     120            $args['navception_parent_suffix'] = $navception_suffix;
     121            $args['navception_suffix_prefix'] = $navception_suffix . '-';
     122
     123            // Setup the previous menu item parent to use in the next navcepted menu.
     124            if ( ! empty( $item->menu_item_parent ) ) {
     125                $args['navception_previous_menu_item_parent'] = $item->menu_item_parent . $nav_parent_suffix;
     126            } else {
     127                $args['navception_previous_menu_item_parent'] = $previous_menu_item_parent;
     128            }
     129
     130            $navception_items = wp_get_nav_menu_items( $item->object_id, $args );
     131
     132            // If the nav menu item is an empty menu, just remove it.
     133            if ( empty( $navception_items ) ) {
     134                continue;
     135            }
     136
     137            // Add a suffix to each Navcepted Menu's menu items' ids, parents, orders, etc.
     138            foreach ( $navception_items as &$navception_item ) {
     139                if ( false !== strpos( $navception_item->ID, '-navception' ) ) {
     140                    $filtered_items[] = $navception_item;
    189141                    continue;
    190142                }
    191143
    192                 if( in_array( $navcepted_item->object_id, $original_menu ) ) {
    193                     return true;
     144                $navception_item->ID         .= $navception_suffix;
     145                $navception_item->db_id      .= $navception_suffix;
     146                $navception_item->menu_order .= $navception_suffix;
     147
     148                if ( empty( $navception_item->menu_item_parent ) ) {
     149                    if ( empty( $item->menu_item_parent ) ) {
     150                        $navception_item->menu_item_parent = $previous_menu_item_parent;
     151                    } else {
     152                        $navception_item->menu_item_parent = $item->menu_item_parent . $nav_parent_suffix;
     153                    }
     154                } else if ( $item->menu_item_parent != $navception_item->menu_item_parent ) {
     155                    $navception_item->menu_item_parent .= $navception_suffix;
    194156                }
    195                
    196                 if( $this->causes_limbo( $original_menu, $navcepted_item->object_id ) ) {
    197                     return true;
    198                 }
    199             }
    200 
    201             return false;
    202         }
    203 
    204 
    205 
    206         function pw_load_scripts( $hook ) {
    207             if( $hook != 'nav-menus.php' ) {
    208                 return;
    209             }
    210 
    211             $current_menu_id = false;
    212             if( $this->new_menu_id ) {
    213                 $current_menu_id = $this->new_menu_id;
    214             } else if( isset( $_REQUEST['menu'] ) ) {
    215                 $current_menu_id = (int) $_REQUEST['menu'];
    216             } else if( get_user_option( 'nav_menu_recently_edited' ) ) {
    217                 $current_menu_id = (int) get_user_option( 'nav_menu_recently_edited' );
    218             }
    219 
    220             if( $current_menu_id ) {
    221 
    222                 wp_enqueue_script(
    223                     'navception',
    224                     plugins_url( '/navception.js', __FILE__ ),
    225                     array('jquery')
    226                 );
    227 
    228                 wp_localize_script(
    229                     'navception',
    230                     'navception',
    231                     array(
    232                         'current_menu' => $current_menu_id
    233                     )
    234                 );
    235             }
    236         }
    237 
    238         function detect_new_menu( $menu_id ) {
    239             $this->new_menu_id = $menu_id;
    240         }
    241 
    242         function warn_of_limbo() {
    243             ?>
    244                 <div id='message' class='error'>
    245                     <p><strong>Navception Warning:</strong> Adding that Menu would cause an infinite loop! I removed it for you :D</p>
    246                 </div>
    247             <?php
    248         }
    249 
    250     }
    251    
    252     new Navception();
     157
     158                $filtered_items[] = $navception_item;
     159            }
     160
     161            $nav_id_suffix += 1;
     162        }
     163
     164        return $filtered_items;
     165    }
     166
     167    /**
     168     * Adds the Navigation Menus Meta Box to the Edit Menus Screen.
     169     *
     170     * @since 1.0.0
     171     */
     172    public function add_nav_box() {
     173        $nav_menu_tax = get_taxonomy( 'nav_menu' );
     174        /**
     175         * Filter whether the Nav Menu menu items meta box will be added.
     176         *
     177         * If a falsey value is returned instead of an object, the menu items
     178         * meta box for Nav Menus will not be added.
     179         *
     180         * @since 2.0.0
     181         *
     182         * @param object $nav_menu_tax The Nav Menu object to add a menu items meta box for.
     183         */
     184        $nav_menu_tax = apply_filters( 'navception_nav_menu_meta_box_object', $nav_menu_tax );
     185
     186        if ( ! $nav_menu_tax ) {
     187            return;
     188        }
     189
     190        $id = $nav_menu_tax->name;
     191        add_meta_box( "add-{$id}", $nav_menu_tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $nav_menu_tax );
     192    }
     193
     194    /**
     195     * Checks if adding a Nav Menu Menu Item to a menu causes an infinite loop, via AJAX.
     196     *
     197     * @since 1.0.0
     198     */
     199    public function check_for_limbo_ajax() {
     200        $original_menu  = isset( $_POST['navception_original_menu'] ) ? $_POST['navception_original_menu'] : false;
     201        $navcepted_menu = isset( $_POST['navception_new_menu'] ) ? $_POST['navception_new_menu'] : false;
     202        $checkbox_ul    = isset( $_POST['navception_checkbox_ul'] ) ? $_POST['navception_checkbox_ul'] : false;
     203
     204        if ( ! ( is_numeric( $original_menu ) && is_numeric( $navcepted_menu ) && $checkbox_ul ) ) {
     205            wp_send_json( array(
     206                'success' => false
     207            ) );
     208        }
     209
     210        $original_menu  = (int) $original_menu;
     211        $navcepted_menu = (int) $navcepted_menu;
     212
     213        if ( $this->causes_limbo( $original_menu, $navcepted_menu ) ) {
     214            wp_send_json( array(
     215                'success'      => true,
     216                'causes_limbo' => true,
     217                'checkbox_ul'  => $checkbox_ul,
     218                'menu_id'      => $navcepted_menu,
     219            ) );
     220        }
     221
     222        wp_send_json( array(
     223            'success'      => true,
     224            'causes_limbo' => false,
     225        ) );
     226    }
     227
     228    /**
     229     * Checks if adding a Nav Menu Menu Item to a menu causes an infinite loop, via not AJAX.
     230     *
     231     * Since this function runs after the Nav Menu Menu Item is added to a menu, this function
     232     * also removes the Nav Menu Menu Item if an infinite loop is caused.
     233     *
     234     * @since 1.0.0
     235     *
     236     * @param int   $menu_id         ID of the updated menu.
     237     * @param int   $menu_item_db_id ID of the updated menu item.
     238     * @param array $args            An array of arguments used to update a menu item.
     239     */
     240    public function check_for_limbo( $menu_id, $menu_item_db_id, $args ) {
     241        if ( empty( $args['menu-item-object'] ) || 'nav_menu' != $args['menu-item-object'] ) {
     242            return;
     243        }
     244
     245        $original_menu   = absint( $menu_id );
     246        $navception_menu = absint( $args['menu-item-object-id'] );
     247
     248        if ( ! $this->causes_limbo( $original_menu, $navception_menu ) ) {
     249            return;
     250        }
     251
     252        $this->removed_menus[] = $args['menu-item-title'];
     253        add_action( 'admin_notices', array( $this, 'warn_of_limbo' ) );
     254        wp_delete_post( $menu_item_db_id, true );
     255    }
     256
     257    /**
     258     * Warn the user that an infinite loop would have been created.
     259     *
     260     * This is specifically used when an infinite loop is created when saving
     261     * without AJAX.
     262     *
     263     * @since 1.0.0
     264     */
     265    public function warn_of_limbo() {
     266        ?>
     267            <div id='message' class='error'>
     268                <p><strong>Navception Warning:</strong> Adding that Menu would cause an infinite loop! I removed it for you :D</p>
     269            </div>
     270        <?php
     271    }
     272
     273    /**
     274     * Checks if adding a Nav Menu Menu Item to a menu causes an infinite loop, via AJAX.
     275     *
     276     * @since 1.0.0
     277     *
     278     * @param int|array $original_menu  A menu ID or array of menu IDs to check the $navcepted_menu against.
     279     * @param int       $navcepted_menu The menu ID to check against $original_menu for infinite loops.
     280     *
     281     * @return bool True if adding $navcepted_menu to $original_menu causes an infinite loop, otherwise false.
     282     */
     283    private function causes_limbo( $original_menu, $navcepted_menu ) {
     284
     285        if ( ! is_array( $original_menu ) ) {
     286            $original_menu = array( $original_menu );
     287        }
     288
     289        if ( in_array( $navcepted_menu, $original_menu ) ) {
     290            return true;
     291        }
     292
     293        $original_menu[] = $navcepted_menu;
     294        $navcepted_items = wp_get_nav_menu_items( $navcepted_menu );
     295
     296        foreach ( $navcepted_items as $navcepted_item ) {
     297            if ( 'nav_menu' != $navcepted_item->object ) {
     298                continue;
     299            }
     300
     301            if ( in_array( $navcepted_item->object_id, $original_menu ) ) {
     302                return true;
     303            }
     304           
     305            if ( $this->causes_limbo( $original_menu, $navcepted_item->object_id ) ) {
     306                return true;
     307            }
     308        }
     309
     310        return false;
     311    }
     312
     313    /**
     314     * Enqueues the navception.js if editing a menu.
     315     *
     316     * @since 1.0.0
     317     *
     318     * @param string $hook The current admin page.
     319     */
     320    public function enqueue_scripts( $hook ) {
     321        if( 'nav-menus.php' != $hook ) {
     322            return;
     323        }
     324
     325        $current_menu_id = false;
     326        if ( $this->new_menu_id ) {
     327            $current_menu_id = $this->new_menu_id;
     328        } else if ( isset( $_REQUEST['menu'] ) ) {
     329            $current_menu_id = (int) $_REQUEST['menu'];
     330        } else if ( get_user_option( 'nav_menu_recently_edited' ) ) {
     331            $current_menu_id = (int) get_user_option( 'nav_menu_recently_edited' );
     332        }
     333
     334        if ( empty( $current_menu_id ) ) {
     335            return;
     336        }
     337
     338        wp_enqueue_script(
     339            'navception',
     340            plugins_url( '/navception.js', __FILE__ ),
     341            array(
     342                'jquery',
     343            ),
     344            self::version
     345        );
     346
     347        wp_localize_script(
     348            'navception',
     349            'navception',
     350            array(
     351                'current_menu' => $current_menu_id,
     352            )
     353        );
     354    }
     355
     356    /**
     357     * Stores the ID of the newly created menu for use in enqueue_scripts().
     358     *
     359     * The normal ways of getting a menu's ID doesn't seem to work when a new menu is
     360     * created, so this is the work around from version 1.0.0.
     361     *
     362     * @since 1.0.0
     363     *
     364     * @param int $menu_id ID of the new menu.
     365     */
     366    public function detect_new_menu( $menu_id ) {
     367        $this->new_menu_id = $menu_id;
     368    }
     369}
     370
     371Navception::instance();
  • navception/trunk/readme.txt

    r894903 r1011880  
    55Author URI: http://faisonz.com
    66Requires at least: 3.5
    7 Tested up to: 3.9
    8 Stable tag: 1.0.0
     7Tested up to: 4.0
     8Stable tag: 2.0.0
    99License: GPL2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6464== Changelog ==
    6565
     66= 2.0.0 =
     67* Rewrote the main Navception code to run on the 'wp_get_nav_menu_items' filter, which is easier to code and allows any custom Nav Menu Walker to do its thing. I believe this also makes Navception work with Nav Menu Roles.
     68* Rewriting the main Navception code also fixes a bug where the 'menu-item-has-children' class wouldn't be added to menu items in a navcepted menu (Thanks to Emma for reporting :D)
     69* Removed the need to include wp-admin/includes/nav-menu.php by replacing the use of the 'nav_menu_meta_box_object' filter with a custom 'navception_nav_menu_meta_box_object' filter.
     70* Updated the Admin JavaScript to work more efficiently.
     71* Refactored to follow coding standards better.
     72* Documented all the functions, fields, and filters.
     73* Switched the Navception class to a singleton to avoid registering hooks multiple times.
     74
    6675= 1.0.0 =
    6776* Initial Release.
     
    6978== Upgrade Notice ==
    7079
     80= 2.0.0 =
     81Navception has been refactored to work better and more efficient. This update "shouldn't" cause any issue, but since it's a big update, you should test this before updating on any production environments. Good news though, this should play nice with Custom Nav Walkers. And by that I mean I don't step on your toes.
     82
    7183= 1.0.0 =
    7284If you have a version less than 1.0.0, something went really, really wrong. Upgrade now, because I have no idea what will happen if you don't!
Note: See TracChangeset for help on using the changeset viewer.