├── .gitignore ├── screenshot-1.png ├── readme.txt ├── readme.md └── duplicate-menu.php /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | -------------------------------------------------------------------------------- /screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopher/duplicate-menu/HEAD/screenshot-1.png -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Duplicate Menu === 2 | Contributors: jchristopher 3 | Donate link: http://mondaybynoon.com/donate/ 4 | Tags: menu, duplicate, copy, clone 5 | Requires at least: 3.4.2 6 | Tested up to: 5.3 7 | Stable tag: 0.2.2 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | Easily duplicate your WordPress menus with one click. 12 | 13 | == Description == 14 | 15 | Some WordPress installs use very elaborate navigation systems powered by core Menus. They're a fantastic feature that can often make or break a theme. Menus aren't very portable out of the box, however. If you're looking to make a change to a Menu you're pretty much working live without a quick way to revert back to an old version. That's where Duplicate Menu comes in. 16 | 17 | Duplicate Menu will allow you to create a second (or third, or fourth, etc.) copy of an existing Menu to do with what you will. It generates the clone on a programmatic level and recreates all necessary relationships to ensure the structure is retained as well. 18 | 19 | Find out more information in my [explanatory article on Duplicate Menu](https://mondaybynoon.com/wordpress-plugin-duplicate-menu/) 20 | 21 | == Installation == 22 | 23 | 1. Download the plugin and extract the files 24 | 1. Upload `duplicate-menu` to your `~/wp-content/plugins/` directory 25 | 1. Activate the plugin through the 'Plugins' menu in WordPress 26 | 27 | == Screenshots == 28 | 29 | 1. Easily create a carbon copy of an existing Menu 30 | 31 | == Changelog == 32 | 33 | = 0.2.2 = 34 | * Fixes Deprecation Warning 35 | 36 | = 0.2.1 = 37 | * Change capability to `edit_theme_options` 38 | * Added some inline documentation 39 | * Fixed link in readme 40 | * Updated screenshot 41 | 42 | = 0.2 = 43 | * Added `duplicate_menu_item` action, allowing devs to bolt on custom functionality 44 | 45 | = 0.1.1 = 46 | * Removed anonymous function call to support PHP <5.3 installs 47 | * Added link to GitHub, please contribute! 48 | 49 | = 0.1 = 50 | * Initial release 51 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | This is a WordPress plugin. [Official download available on wordpress.org](https://wordpress.org/plugins/duplicate-menu/). 2 | 3 | # Duplicate Menu 4 | 5 | Easily duplicate your WordPress menus with one click 6 | 7 | ## Description 8 | 9 | Some WordPress installs use very elaborate navigation systems powered by core Menus. They're a fantastic feature that can often make or break a theme. Menus aren't very portable out of the box, however. If you're looking to make a change to a Menu you're pretty much working live without a quick way to revert back to an old version. That's where Duplicate Menu comes in. 10 | 11 | Duplicate Menu will allow you to create a second (or third, or fourth, etc.) copy of an existing Menu to do with what you will. It generates the clone on a programmatic level and recreates all necessary relationships to ensure the structure is retained as well. 12 | 13 | Find out more information in my [explanatory article on Duplicate Menu](http://mondaybynoon.com/wordpress-plugin-duplicate-menu/) 14 | 15 | ## Installation 16 | 17 | 1. Download the plugin and extract the files 18 | 1. Upload `duplicate-menu` to your `~/wp-content/plugins/` directory 19 | 1. Activate the plugin through the 'Plugins' menu in WordPress 20 | 21 | ## Usage 22 | 23 | After activation, navigate to Appearance > Duplicate Menu to create a copy of an existing Menu 24 | 25 | ![Easily create a carbon copy of an existing Menu](https://mondaybynoon.com/wp-content/uploads/2017/10/screenshot-1.png) 26 | 27 | ### Changelog 28 | 29 | #### 0.2.2 30 | - Fixes Deprecation Warning 31 | 32 | #### 0.2.1 33 | - Change capability to edit_theme_options 34 | - Added some inline documentation 35 | - Fixed link in readme 36 | - Updated screenshot 37 | 38 | #### 0.2 39 | - Added duplicate_menu_item action, allowing devs to bolt on custom functionality 40 | 41 | #### 0.1.1 42 | - Removed anonymous function call to support PHP <5.3 installs 43 | - Added link to GitHub, please contribute! 44 | 45 | #### 0.1 46 | - Initial release 47 | -------------------------------------------------------------------------------- /duplicate-menu.php: -------------------------------------------------------------------------------- 1 | $menu_item->db_id, 79 | 'menu-item-object-id' => $menu_item->object_id, 80 | 'menu-item-object' => $menu_item->object, 81 | 'menu-item-position' => $i, 82 | 'menu-item-type' => $menu_item->type, 83 | 'menu-item-title' => $menu_item->title, 84 | 'menu-item-url' => $menu_item->url, 85 | 'menu-item-description' => $menu_item->description, 86 | 'menu-item-attr-title' => $menu_item->attr_title, 87 | 'menu-item-target' => $menu_item->target, 88 | 'menu-item-classes' => implode( ' ', $menu_item->classes ), 89 | 'menu-item-xfn' => $menu_item->xfn, 90 | 'menu-item-status' => $menu_item->post_status 91 | ); 92 | 93 | $parent_id = wp_update_nav_menu_item( $new_id, 0, $args ); 94 | 95 | $rel[$menu_item->db_id] = $parent_id; 96 | 97 | // did it have a parent? if so, we need to update with the NEW ID 98 | if ( $menu_item->menu_item_parent ) { 99 | $args['menu-item-parent-id'] = $rel[$menu_item->menu_item_parent]; 100 | $parent_id = wp_update_nav_menu_item( $new_id, $parent_id, $args ); 101 | } 102 | 103 | // allow developers to run any custom functionality they'd like 104 | do_action( 'duplicate_menu_item', $menu_item, $args ); 105 | 106 | $i++; 107 | } 108 | 109 | return $new_id; 110 | } 111 | 112 | /* 113 | * Output the options screen 114 | */ 115 | function options_screen() { 116 | $nav_menus = wp_get_nav_menus(); 117 | ?> 118 |
119 |

120 |

121 | 122 | 123 | duplicate( $source, $destination ); 130 | ?> 131 | 132 |

133 | 134 | . 135 | 136 | . 137 | 138 |

139 | 140 | 141 | 142 | 143 | 144 |

145 | 146 |
147 | 148 | 149 | 150 | 153 | 164 |
151 | 152 | 154 | 161 | 162 | 163 |
165 |

166 | 167 |

168 |
169 | 170 |
171 |