Changeset 728325
- Timestamp:
- 06/19/2013 11:07:35 AM (13 years ago)
- Location:
- codepress-menu
- Files:
-
- 11 added
- 2 edited
- 2 copied
-
tags/2.3 (added)
-
tags/2.3/class-codepress-menu-walker.php (added)
-
tags/2.3/codepress-menu.php (copied) (copied from codepress-menu/trunk/codepress-menu.php) (4 diffs)
-
tags/2.3/css (added)
-
tags/2.3/css/codepress-menu.css (added)
-
tags/2.3/js (added)
-
tags/2.3/js/codepress-menu.js (added)
-
tags/2.3/readme.txt (copied) (copied from codepress-menu/trunk/readme.txt) (6 diffs)
-
trunk/class-codepress-menu-walker.php (added)
-
trunk/codepress-menu.php (modified) (4 diffs)
-
trunk/css (added)
-
trunk/css/codepress-menu.css (added)
-
trunk/js (added)
-
trunk/js/codepress-menu.js (added)
-
trunk/readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
codepress-menu/tags/2.3/codepress-menu.php
r682297 r728325 3 3 Plugin Name: Codepress Menu 4 4 Plugin URI: http://wordpress.org/extend/plugins/codepress-menu/ 5 Version: 2. 2.26 Description: A more flexible take on displaying a WordPress menu in your theme5 Version: 2.3 6 Description: Extensions for WordPress nav-menu's 7 7 Author: Codepress 8 8 License: GPLv2 … … 24 24 */ 25 25 26 class Codepress_Walker_Nav_Menu extends Walker_Nav_Menu { 26 define( 'CODEPRESS_MENU_URL', plugin_dir_url( __FILE__ ) ); 27 define( 'CODEPRESS_MENU_DIR', plugin_dir_path( __FILE__ ) ); 27 28 28 /** 29 * Indents any object as long as it has a unique id and that of its parent. 30 * 31 * @since 2.1 32 */ 33 protected function indent( array $items, $root, $parent, $id ) { 34 $indent = array(); 35 36 foreach( $items as $k => $item ) { 37 if ( $item->$parent == $root ) { 38 unset( $items[$k] ); 39 40 $item->children = $this->indent( $items, $item->$id, $parent, $id ); 41 $indent[] = $item; 42 } 43 } 44 45 return $indent; 46 } 47 48 /** 49 * Only return a level from a indented list of items. 50 * 51 * @since 2.0 52 */ 53 protected function level( $items, $level, $reached = 1, $currentBranch = false) { 54 55 foreach ( $items as $item ) { 56 57 // check for current or ancestor 58 if ( $item->current || $item->current_item_ancestor || $currentBranch ) { 59 60 // catch top level 61 if ( $level == 1 && $reached == 1 ) 62 return array( $item ); 63 64 // catch all other levels 65 if ( $reached + 1 == $level && ! empty( $item->children ) ) 66 return $item->children; 67 68 if ( ! empty( $item->children ) ) 69 return $this->level( $item->children, $level, $reached + 1, true ); 70 } 71 } 72 73 return array(); 74 } 75 76 /** 77 * Unset children exceeding max depth. 78 * 79 * @since 1.0 80 */ 81 protected function depth( $items, $depth, $level = 1 ) { 82 83 foreach( $items as $k => $item ) { 84 // unset the children, or go a level deeper 85 if ( $depth == $level ) 86 unset( $items[$k]->children ); 87 elseif ( ! empty( $item->children ) ) 88 $items[$k]->children = $this->depth( $item->children, $depth, $level + 1 ); 89 } 90 91 return $items; 92 } 93 94 /** 95 * Adds classes to the first and last item of each level. 96 * 97 * @since 2.1 98 */ 99 protected function mark_first_and_last( array $items ) { 100 $i = 0; 101 102 foreach( $items as $item ) { 103 if ( $i == 0 ) 104 $item->classes[] = 'first'; 105 106 $i++; 107 108 if ( $i == count( $items ) ) 109 $item->classes[] = 'last'; 110 111 if ( ! empty( $item->children ) ) 112 $item->children = $this->mark_first_and_last( $item->children ); 113 } 114 115 return $items; 116 } 117 118 /** 119 * Sanitize classes by removing some of them and renaming others. 120 * 121 * @since 2.1.1 122 */ 123 protected function sanitize_classes( $items, $args ) { 124 125 foreach( $items as $k => $item ) { 126 // always allow custom assigned classes 127 $filtered = (array) get_post_meta( $item->ID, '_menu_item_classes', true ); 128 $allowed = array(); 129 130 if ( $args->classes == 'minimal' || $args->classes == 'simple' ) { 131 $allowed = array( 132 'current-menu-item' => 'current', 133 'current-menu-parent' => 'current-parent', 134 'current-menu-ancestor' => 'current-ancestor', 135 ); 136 } 137 138 if ( $args->classes == 'sanitize' ) { 139 $allowed = array( 140 'current-menu-item', 141 'current-menu-parent', 142 'current-menu-ancestor', 143 ); 144 } 145 146 if ( $args->classes == 'simple' || $args->classes == 'sanitize' ) 147 $allowed = array_merge( $allowed, array( 'first', 'last' ) ); 148 149 $allowed = apply_filters( 'codepress_menu_filter_classes', $allowed, $item, $args ); 150 151 // check for class that is allowed, but needs transformation 152 foreach ( $item->classes as $class ) { 153 if ( array_key_exists( $class, $allowed ) ) 154 $filtered[] = $allowed[$class]; 155 elseif ( in_array( $class, $allowed ) ) 156 $filtered[] = $class; 157 } 158 159 $items[$k]->classes = array_filter( $filtered );; 160 } 161 162 return $items; 163 } 164 165 /** 166 * Walkers have a walk method, makes sense. 167 * 168 * @since 2.1 169 */ 170 public function walk( $items, $depth, $args ) { 171 $items = $this->indent( $items, 0, $this->db_fields['parent'], $this->db_fields['id'] ); 172 173 if ( $args->level ) 174 $items = $this->level( $items, $args->level ); 175 176 $items = $this->depth( $items, $depth ); 177 178 if ( $args->classes ) { 179 $items = $this->mark_first_and_last( $items ); 180 $items = $this->sanitize_classes( $items, $args ); 181 } 182 183 $items = apply_filters( 'codepress_menu_filter', $items ); 184 185 return $this->get_menu( $items, $args ); 186 } 187 188 /** 189 * Get the menu string. 190 * 191 * @return string 192 * @since 1.0 193 */ 194 public function get_menu( $items, $args, $level = 1 ) { 195 $output = ''; 196 197 if ( $level > 1) 198 $this->start_lvl( $output, 0, $args ); 199 200 foreach( $items as $item ) { 201 $this->start_el( $output, $item, 0, $args ); 202 203 if ( ! empty( $item->children ) ) 204 $output .= $this->get_menu( $item->children, $args, $level + 1); 205 206 $this->end_el( $output, $item, 0, $args ); 207 } 208 209 if ( $level > 1 ) 210 $this->end_lvl( $output, 0, $args ); 211 212 return $output; 213 } 214 } 29 require CODEPRESS_MENU_DIR . '/class-codepress-menu-walker.php'; 215 30 216 31 /** 217 * Init Codepress Menu .32 * Init Codepress Menu 218 33 * 219 34 * @uses apply_filters() To ignore certain theme_locations. … … 244 59 245 60 $defaults = array( 246 'level' => 0, 247 'classes' => false, 248 'walker' => new Codepress_Walker_Nav_Menu, 61 'level' => 0, 62 'walker' => new Codepress_Menu_Walker, 249 63 ); 250 64 251 65 foreach( $defaults as $option => $default ) { 252 if ( empty( $args[ $option] ) )253 $args[ $option] = $default;66 if ( empty( $args[ $option ] ) ) 67 $args[ $option ] = $default; 254 68 } 255 69 … … 257 71 } 258 72 add_filter( 'wp_nav_menu_args', 'codepress_menu_init' ); 73 74 /** 75 * Enqueue styles and scripts for nav-menus page 76 * 77 * @since 2.3 78 */ 79 function codepress_menu_admin_scripts() { 80 global $pagenow; 81 82 if ( 'nav-menus.php' != $pagenow ) 83 return; 84 85 wp_enqueue_script( 'codepress-menu-backend', CODEPRESS_MENU_URL . '/js/codepress-menu.js' ); 86 wp_enqueue_style( 'codepress-menu-backend', CODEPRESS_MENU_URL . '/css/codepress-menu.css' ); 87 } 88 add_action( 'admin_print_scripts', 'codepress_menu_admin_scripts' ); 89 90 /** 91 * Show or hide the menu-item delete link 92 * 93 * @since 2.3 94 */ 95 function codepress_menu_manage_nav_menus_columns( $columns ) { 96 $columns['codepress-menu-simple-delete'] = __( 'Remove' ); 97 98 return $columns; 99 } 100 add_filter( 'manage_nav-menus_columns', 'codepress_menu_manage_nav_menus_columns', 15 ); -
codepress-menu/tags/2.3/readme.txt
r682419 r728325 3 3 Tags: wordpress, menu, submenu, walker, navigation, nav, php, code, wp_nav_menu 4 4 Requires at least: 3.1 5 Tested up to: 3. 4.26 Stable tag: 2. 2.25 Tested up to: 3.5 6 Stable tag: 2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Allows you to display a sub-menu, it's depth from there on and gives you goodcontrol over the menu-item classes.10 Allows you to display a sub-menu, it's depth from there on and gives you control over the menu-item classes. 11 11 12 12 == Description == 13 13 14 Uses the native [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu) but adds some flexibility. 14 Uses the native [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu). Add parameters to the wp_nav_menu() to enable functionality. 15 Also, ships with one-click delete menu-items in the WordPress admin. Turned off or on using the screen-options. Sweet. 15 16 16 No configuration required, just adds runtime parameters that can be used to tweak your menu. 17 **Examples** 17 18 18 19 This will get the first sub-menu from the active branch and 2 levels beyond (menu + sub-menu + sub-menu): … … 24 25 ` 25 26 26 Show the wholecurrent branch only:27 Show the current branch only: 27 28 ` 28 29 wp_nav_menu( array( … … 31 32 ` 32 33 33 Aimed on simple use on various use cases:34 Aimed on simple use in various use cases: 34 35 ` 35 36 // display first level in the header … … 45 46 ` 46 47 47 Another feature is it's controll over the css classes that are assigned. You might be faced with a html template of 48 which you cannot or do not want to change the css. 49 50 Use the filter 'codepress_menu_filter_classes' to define your own class filter. 51 52 There are also a few pre-configured variants: 53 54 * *sanitize* Keep only a few WordPress classes (li.current-menu-item, li.current-menu-parent, li.current-menu-ancestor) and add li.first and li.last. 55 * *simple* Use even more simple classes (li.current, li.current-parent, li.current-ancestor) and add li.first and li.last. 56 * *minimal* Same as simple, but without list.first and li.last because you target modern browsers only or use something like selectivizr 57 * *false* Do nothing (default) 48 Another feature is it's control over the css classes that are given to a menu-item. You might be faced with css selectors 49 which you cannot change. The 'codepress_menu_filter_classes' filter can be used in your functions.php to set the class property: 58 50 59 51 ` 60 wp_nav_menu( array( 61 'classes' => 'sanitize' 62 )); 52 /** 53 * Change the classes of a menu item 54 * 55 * @param array $classes List current classes 56 * @param object $item Current menu item 57 * @param array $items Current list of items (per level) 58 * @param integer $k Key of the current item in $items 59 */ 60 function codepress_menu_item_classes( $classes, $item, $items, $k ) { 61 // mark the first item 62 if ( reset( $items ) == $items[ $k ] ) 63 $classes[] = 'first'; 64 65 // mark the last item 66 if ( end( $items ) == $items[ $k ] ) 67 $classes[] = 'last'; 68 69 // map the WordPress default 'current-menu-item' class to 'active' 70 if ( in_array( 'current-menu-item', $classes ) ) 71 $classes[] = 'active'; 72 73 return $classes; 74 } 75 add_filter( 'codepress_menu_item_classes', 'codepress_menu_item_classes', 10, 4 ); 63 76 ` 77 78 **Simple Menu Delete** 79 80 It ships with one-click delete menu-items within WordPress. 81 This functionality was integrated from our Simple Menu Delete plugin and enhanced a bit: 82 83 * Turned off or on using the screen-options. 84 * Display is more in line with WordPress's way of delete-links. 85 * Works exactly the same now as the nested delete-link which is a click further inside the menu item. 86 87 88 == Frequently Asked Questions == 89 90 = Something is broken? Have an idea? = 91 92 Great! Tell us, we'd love to help out. 64 93 65 94 66 95 == Upgrade Notice == 96 97 = 2.3 = 98 We have decided that current way of changing of classes is not in line with how WordPress works. We still offer the possibility to influence the 99 classes, but the focus is on using giving you the tools to do what you want 'codepress_menu_item_classes'. See the examples for some intended usage. 67 100 68 101 = 2.2 = … … 75 108 == Installation == 76 109 77 Search for `codepress menu` as described in the [Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) or 110 Search for `codepress menu` as described in the [Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) 111 112 or 78 113 79 114 1. Upload codepress-menu to the `/wp-content/plugins/` directory … … 84 119 85 120 == Changelog == 121 122 = 2.3 = 123 124 * A more WordPress-like implementation of the menu-item class control. 125 * Added a one-click delete for menu-items in wp-admin (can be turned off or on via screen options). 126 * Minor code cleanup, adhering WordPress standards... even more! 86 127 87 128 = 2.2.2 = -
codepress-menu/trunk/codepress-menu.php
r682297 r728325 3 3 Plugin Name: Codepress Menu 4 4 Plugin URI: http://wordpress.org/extend/plugins/codepress-menu/ 5 Version: 2. 2.26 Description: A more flexible take on displaying a WordPress menu in your theme5 Version: 2.3 6 Description: Extensions for WordPress nav-menu's 7 7 Author: Codepress 8 8 License: GPLv2 … … 24 24 */ 25 25 26 class Codepress_Walker_Nav_Menu extends Walker_Nav_Menu { 26 define( 'CODEPRESS_MENU_URL', plugin_dir_url( __FILE__ ) ); 27 define( 'CODEPRESS_MENU_DIR', plugin_dir_path( __FILE__ ) ); 27 28 28 /** 29 * Indents any object as long as it has a unique id and that of its parent. 30 * 31 * @since 2.1 32 */ 33 protected function indent( array $items, $root, $parent, $id ) { 34 $indent = array(); 35 36 foreach( $items as $k => $item ) { 37 if ( $item->$parent == $root ) { 38 unset( $items[$k] ); 39 40 $item->children = $this->indent( $items, $item->$id, $parent, $id ); 41 $indent[] = $item; 42 } 43 } 44 45 return $indent; 46 } 47 48 /** 49 * Only return a level from a indented list of items. 50 * 51 * @since 2.0 52 */ 53 protected function level( $items, $level, $reached = 1, $currentBranch = false) { 54 55 foreach ( $items as $item ) { 56 57 // check for current or ancestor 58 if ( $item->current || $item->current_item_ancestor || $currentBranch ) { 59 60 // catch top level 61 if ( $level == 1 && $reached == 1 ) 62 return array( $item ); 63 64 // catch all other levels 65 if ( $reached + 1 == $level && ! empty( $item->children ) ) 66 return $item->children; 67 68 if ( ! empty( $item->children ) ) 69 return $this->level( $item->children, $level, $reached + 1, true ); 70 } 71 } 72 73 return array(); 74 } 75 76 /** 77 * Unset children exceeding max depth. 78 * 79 * @since 1.0 80 */ 81 protected function depth( $items, $depth, $level = 1 ) { 82 83 foreach( $items as $k => $item ) { 84 // unset the children, or go a level deeper 85 if ( $depth == $level ) 86 unset( $items[$k]->children ); 87 elseif ( ! empty( $item->children ) ) 88 $items[$k]->children = $this->depth( $item->children, $depth, $level + 1 ); 89 } 90 91 return $items; 92 } 93 94 /** 95 * Adds classes to the first and last item of each level. 96 * 97 * @since 2.1 98 */ 99 protected function mark_first_and_last( array $items ) { 100 $i = 0; 101 102 foreach( $items as $item ) { 103 if ( $i == 0 ) 104 $item->classes[] = 'first'; 105 106 $i++; 107 108 if ( $i == count( $items ) ) 109 $item->classes[] = 'last'; 110 111 if ( ! empty( $item->children ) ) 112 $item->children = $this->mark_first_and_last( $item->children ); 113 } 114 115 return $items; 116 } 117 118 /** 119 * Sanitize classes by removing some of them and renaming others. 120 * 121 * @since 2.1.1 122 */ 123 protected function sanitize_classes( $items, $args ) { 124 125 foreach( $items as $k => $item ) { 126 // always allow custom assigned classes 127 $filtered = (array) get_post_meta( $item->ID, '_menu_item_classes', true ); 128 $allowed = array(); 129 130 if ( $args->classes == 'minimal' || $args->classes == 'simple' ) { 131 $allowed = array( 132 'current-menu-item' => 'current', 133 'current-menu-parent' => 'current-parent', 134 'current-menu-ancestor' => 'current-ancestor', 135 ); 136 } 137 138 if ( $args->classes == 'sanitize' ) { 139 $allowed = array( 140 'current-menu-item', 141 'current-menu-parent', 142 'current-menu-ancestor', 143 ); 144 } 145 146 if ( $args->classes == 'simple' || $args->classes == 'sanitize' ) 147 $allowed = array_merge( $allowed, array( 'first', 'last' ) ); 148 149 $allowed = apply_filters( 'codepress_menu_filter_classes', $allowed, $item, $args ); 150 151 // check for class that is allowed, but needs transformation 152 foreach ( $item->classes as $class ) { 153 if ( array_key_exists( $class, $allowed ) ) 154 $filtered[] = $allowed[$class]; 155 elseif ( in_array( $class, $allowed ) ) 156 $filtered[] = $class; 157 } 158 159 $items[$k]->classes = array_filter( $filtered );; 160 } 161 162 return $items; 163 } 164 165 /** 166 * Walkers have a walk method, makes sense. 167 * 168 * @since 2.1 169 */ 170 public function walk( $items, $depth, $args ) { 171 $items = $this->indent( $items, 0, $this->db_fields['parent'], $this->db_fields['id'] ); 172 173 if ( $args->level ) 174 $items = $this->level( $items, $args->level ); 175 176 $items = $this->depth( $items, $depth ); 177 178 if ( $args->classes ) { 179 $items = $this->mark_first_and_last( $items ); 180 $items = $this->sanitize_classes( $items, $args ); 181 } 182 183 $items = apply_filters( 'codepress_menu_filter', $items ); 184 185 return $this->get_menu( $items, $args ); 186 } 187 188 /** 189 * Get the menu string. 190 * 191 * @return string 192 * @since 1.0 193 */ 194 public function get_menu( $items, $args, $level = 1 ) { 195 $output = ''; 196 197 if ( $level > 1) 198 $this->start_lvl( $output, 0, $args ); 199 200 foreach( $items as $item ) { 201 $this->start_el( $output, $item, 0, $args ); 202 203 if ( ! empty( $item->children ) ) 204 $output .= $this->get_menu( $item->children, $args, $level + 1); 205 206 $this->end_el( $output, $item, 0, $args ); 207 } 208 209 if ( $level > 1 ) 210 $this->end_lvl( $output, 0, $args ); 211 212 return $output; 213 } 214 } 29 require CODEPRESS_MENU_DIR . '/class-codepress-menu-walker.php'; 215 30 216 31 /** 217 * Init Codepress Menu .32 * Init Codepress Menu 218 33 * 219 34 * @uses apply_filters() To ignore certain theme_locations. … … 244 59 245 60 $defaults = array( 246 'level' => 0, 247 'classes' => false, 248 'walker' => new Codepress_Walker_Nav_Menu, 61 'level' => 0, 62 'walker' => new Codepress_Menu_Walker, 249 63 ); 250 64 251 65 foreach( $defaults as $option => $default ) { 252 if ( empty( $args[ $option] ) )253 $args[ $option] = $default;66 if ( empty( $args[ $option ] ) ) 67 $args[ $option ] = $default; 254 68 } 255 69 … … 257 71 } 258 72 add_filter( 'wp_nav_menu_args', 'codepress_menu_init' ); 73 74 /** 75 * Enqueue styles and scripts for nav-menus page 76 * 77 * @since 2.3 78 */ 79 function codepress_menu_admin_scripts() { 80 global $pagenow; 81 82 if ( 'nav-menus.php' != $pagenow ) 83 return; 84 85 wp_enqueue_script( 'codepress-menu-backend', CODEPRESS_MENU_URL . '/js/codepress-menu.js' ); 86 wp_enqueue_style( 'codepress-menu-backend', CODEPRESS_MENU_URL . '/css/codepress-menu.css' ); 87 } 88 add_action( 'admin_print_scripts', 'codepress_menu_admin_scripts' ); 89 90 /** 91 * Show or hide the menu-item delete link 92 * 93 * @since 2.3 94 */ 95 function codepress_menu_manage_nav_menus_columns( $columns ) { 96 $columns['codepress-menu-simple-delete'] = __( 'Remove' ); 97 98 return $columns; 99 } 100 add_filter( 'manage_nav-menus_columns', 'codepress_menu_manage_nav_menus_columns', 15 ); -
codepress-menu/trunk/readme.txt
r682419 r728325 3 3 Tags: wordpress, menu, submenu, walker, navigation, nav, php, code, wp_nav_menu 4 4 Requires at least: 3.1 5 Tested up to: 3. 4.26 Stable tag: 2. 2.25 Tested up to: 3.5 6 Stable tag: 2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Allows you to display a sub-menu, it's depth from there on and gives you goodcontrol over the menu-item classes.10 Allows you to display a sub-menu, it's depth from there on and gives you control over the menu-item classes. 11 11 12 12 == Description == 13 13 14 Uses the native [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu) but adds some flexibility. 14 Uses the native [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu). Add parameters to the wp_nav_menu() to enable functionality. 15 Also, ships with one-click delete menu-items in the WordPress admin. Turned off or on using the screen-options. Sweet. 15 16 16 No configuration required, just adds runtime parameters that can be used to tweak your menu. 17 **Examples** 17 18 18 19 This will get the first sub-menu from the active branch and 2 levels beyond (menu + sub-menu + sub-menu): … … 24 25 ` 25 26 26 Show the wholecurrent branch only:27 Show the current branch only: 27 28 ` 28 29 wp_nav_menu( array( … … 31 32 ` 32 33 33 Aimed on simple use on various use cases:34 Aimed on simple use in various use cases: 34 35 ` 35 36 // display first level in the header … … 45 46 ` 46 47 47 Another feature is it's controll over the css classes that are assigned. You might be faced with a html template of 48 which you cannot or do not want to change the css. 49 50 Use the filter 'codepress_menu_filter_classes' to define your own class filter. 51 52 There are also a few pre-configured variants: 53 54 * *sanitize* Keep only a few WordPress classes (li.current-menu-item, li.current-menu-parent, li.current-menu-ancestor) and add li.first and li.last. 55 * *simple* Use even more simple classes (li.current, li.current-parent, li.current-ancestor) and add li.first and li.last. 56 * *minimal* Same as simple, but without list.first and li.last because you target modern browsers only or use something like selectivizr 57 * *false* Do nothing (default) 48 Another feature is it's control over the css classes that are given to a menu-item. You might be faced with css selectors 49 which you cannot change. The 'codepress_menu_filter_classes' filter can be used in your functions.php to set the class property: 58 50 59 51 ` 60 wp_nav_menu( array( 61 'classes' => 'sanitize' 62 )); 52 /** 53 * Change the classes of a menu item 54 * 55 * @param array $classes List current classes 56 * @param object $item Current menu item 57 * @param array $items Current list of items (per level) 58 * @param integer $k Key of the current item in $items 59 */ 60 function codepress_menu_item_classes( $classes, $item, $items, $k ) { 61 // mark the first item 62 if ( reset( $items ) == $items[ $k ] ) 63 $classes[] = 'first'; 64 65 // mark the last item 66 if ( end( $items ) == $items[ $k ] ) 67 $classes[] = 'last'; 68 69 // map the WordPress default 'current-menu-item' class to 'active' 70 if ( in_array( 'current-menu-item', $classes ) ) 71 $classes[] = 'active'; 72 73 return $classes; 74 } 75 add_filter( 'codepress_menu_item_classes', 'codepress_menu_item_classes', 10, 4 ); 63 76 ` 77 78 **Simple Menu Delete** 79 80 It ships with one-click delete menu-items within WordPress. 81 This functionality was integrated from our Simple Menu Delete plugin and enhanced a bit: 82 83 * Turned off or on using the screen-options. 84 * Display is more in line with WordPress's way of delete-links. 85 * Works exactly the same now as the nested delete-link which is a click further inside the menu item. 86 87 88 == Frequently Asked Questions == 89 90 = Something is broken? Have an idea? = 91 92 Great! Tell us, we'd love to help out. 64 93 65 94 66 95 == Upgrade Notice == 96 97 = 2.3 = 98 We have decided that current way of changing of classes is not in line with how WordPress works. We still offer the possibility to influence the 99 classes, but the focus is on using giving you the tools to do what you want 'codepress_menu_item_classes'. See the examples for some intended usage. 67 100 68 101 = 2.2 = … … 75 108 == Installation == 76 109 77 Search for `codepress menu` as described in the [Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) or 110 Search for `codepress menu` as described in the [Codex](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) 111 112 or 78 113 79 114 1. Upload codepress-menu to the `/wp-content/plugins/` directory … … 84 119 85 120 == Changelog == 121 122 = 2.3 = 123 124 * A more WordPress-like implementation of the menu-item class control. 125 * Added a one-click delete for menu-items in wp-admin (can be turned off or on via screen options). 126 * Minor code cleanup, adhering WordPress standards... even more! 86 127 87 128 = 2.2.2 =
Note: See TracChangeset
for help on using the changeset viewer.