Changeset 365690
- Timestamp:
- 03/28/2011 09:00:51 AM (15 years ago)
- Location:
- simple-portfolio/trunk
- Files:
-
- 3 edited
-
extends/xml.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
simple-portfolio.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
simple-portfolio/trunk/extends/xml.php
r355286 r365690 126 126 <menus> 127 127 <?php 128 $menus = wp_get_nav_menus();129 $menu_items = wp_get_nav_menu_items($menus[0]);130 foreach ($menu_items as $menu_item): ?>131 <menu url="<?php echo hide_server_url($menu_item->url); ?>">132 <title><![CDATA[<?php echo $menu_item->title; ?>]]></title>133 <description><![CDATA[<?php echo $menu_item->description; ?>]]></description>134 </menu>135 <?php endforeach;?>128 $menus = wp_get_nav_menus(); 129 $menu_items = wp_get_nav_menu_items($menus[0]); 130 131 $nav = new NavigationMenus( $menu_items ); 132 $nav->hideServerUrls(get_site_url()); 133 $menus_recursive = $nav->getRecursiveXml(); 134 echo $menus_recursive; 135 ?> 136 136 </menus> 137 137 <pages> … … 195 195 </wordpress> 196 196 197 <?php 198 class NavigationMenus { 199 200 var $collection; 201 202 function __construct( $collection ) { 203 $this->collection = $collection; 204 } 205 206 /** 207 * Get a recursive xml formatted menu structure 208 */ 209 public function getRecursiveXml() { 210 $recursiveMenus = $this->getRecursiveMenus(); 211 212 $output = ""; 213 214 foreach ($recursiveMenus as $item) { 215 $output .= $this->getXMLformattedMenu( $item ); 216 } 217 218 return $output; 219 } 220 221 private function getXMLformattedMenu( $item ) { 222 $output = ""; 223 $output .= "<menu url=\"{$item['menu']->url}\">\n"; 224 $output .= " <title><![CDATA[{$item['menu']->title}]]></title>\n"; 225 $output .= " <description><![CDATA[{$item['menu']->description}]]></description>\n"; 226 $output .= " <menus>"; 227 228 foreach ($item['menus'] as $childItem) { 229 $output .= $this->getXMLformattedMenu( $childItem ); 230 } 231 232 $output .= " </menus>"; 233 $output .= "</menu>\n"; 234 235 return $output; 236 } 237 238 /** 239 * Get the recursive menus at object level 240 */ 241 public function getRecursiveMenus() { 242 // parse top level items 243 $toplevel = array(); 244 foreach ($this->collection as $item) { 245 if ($item->menu_item_parent == 0) 246 array_push( $toplevel, $this->getMenu($item)); 247 } 248 249 // loop over toplevel and apply children 250 foreach ($toplevel as &$item) { 251 $this->addChildren( $item ); 252 } 253 254 return $toplevel; 255 } 256 257 /** 258 * Hide the base server url.. 259 * for example: site is http://www.site.nl/page/2 260 * then all menus url will be replaced with page/2 261 */ 262 public function hideServerUrls( $siteurl ) { 263 foreach ($this->collection as &$collectionItem) { 264 $path = $collectionItem->url; 265 266 if (substr($path, 0, strlen($siteurl)) == $siteurl) { 267 $trimmed = substr($path, strlen($siteurl)); 268 while (substr($trimmed,0,1) == '/') $trimmed = substr($trimmed,1); 269 while (substr($trimmed, strlen($trimmed)-1) == '/') $trimmed = substr($trimmed, 0, strlen($trimmed)-1); 270 $path = $trimmed; 271 } 272 273 $collectionItem->url = $path; 274 } 275 } 276 277 private function addChildren( &$item ) { 278 foreach ($this->collection as $collectionItem) { 279 if ($collectionItem->menu_item_parent == $item["menu"]->ID) { 280 $added = $this->getMenu($collectionItem); 281 $this->addChildren( $added ); 282 array_push($item["menus"], $added); 283 } 284 } 285 } 286 287 private function getMenu( $item ) { 288 return array("menu" => $item, "menus" => array()); 289 } 290 } 291 ?> -
simple-portfolio/trunk/readme.txt
r355494 r365690 6 6 Requires at least: 2.8 7 7 Tested up to: 3.1 8 Stable tag: 1. 68 Stable tag: 1.7 9 9 10 10 Simple Portfolio allows you to easily manage your portfolio. You can append snippets, youtube and media from the built-in Media Library to projects. … … 83 83 == Changelog == 84 84 85 = 1.7 = 86 The xml format is slightly changed. When navigating to site/slug.xml the menus are now recursive instead of listed under each other. 87 85 88 = 1.6 = 86 89 -
simple-portfolio/trunk/simple-portfolio.php
r355510 r365690 4 4 Plugin URI: http://projects.inlet.nl/simple-portfolio-wordpress3/ 5 5 Description: Manage your portfolio projects easily and use them everywhere you like. This plugin is very simple to use, it doesn't bother you with a complex user interface. Add project specific information, for example what your role was and the team you've worked in, etc. Add any media you like: YouTube, code snippets or any media from your wordpress built-in Media Library. Wonder how it works? Watch the <a href="http://www.inlet.nl">screencast</a>. 6 Version: 1. 66 Version: 1.7 7 7 Author: Patrick Brouwer (Inlet) 8 8 Author URI: http://www.inlet.nl
Note: See TracChangeset
for help on using the changeset viewer.