Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use Link as Menu item ?
#6
I had cobbled together a quick plugin to play with the $menuitems variable. This plugin turns the linst items into an array, then adds entries into the array. Consider it a starting point for anyone who wants to write a "custom menu link" plugin.
Code:
<?php
/*
Plugin Name: Menu Modify
Description: Modifies the Menu
Version: 0.1
Author: Rob Antonishen
Author URI: http://ffaat.pointclark.net
*/

# get correct id for plugin
$thisfile=basename(__FILE__, ".php");

# register plugin
register_plugin(
    $thisfile,
    'Menu Modify',    
    '0.1',        
    'Rob Antonishen',
    'http://ffaat.pointclark.net',
    'Modifies the menu',
    'theme',
    'menu_show'  
);

# activate filter
add_filter('menuitems','menu_filter');


function menu_show() {}

function menu_filter($menuitems) {
  preg_match_all("/<li(.*)?>(.*?)<\/li>/",$menuitems,$menuarray);
  #insert at start
  #array_splice($menuarray[0],0,0,'<li><a href="http://something.com" title="New Menu Item">New Item</a></li>');
  #insert at end
  array_splice($menuarray[0],count($menuarray[0]),0,'<li><a href="http://www.google.com" title="Google">Google</a></li>');
  $menuitems = implode($menuarray[0]);
  return $menuitems;
}
?>

-Rob A>
Reply


Messages In This Thread
Use Link as Menu item ? - by freekers - 2010-12-01, 03:08:05
Use Link as Menu item ? - by ccagle8 - 2010-12-01, 05:25:39
Use Link as Menu item ? - by freekers - 2010-12-01, 20:51:27
Use Link as Menu item ? - by Zegnåt - 2010-12-04, 22:22:00
Use Link as Menu item ? - by georgewiel - 2011-01-09, 07:00:38
Use Link as Menu item ? - by RobA - 2011-01-11, 06:16:37
Use Link as Menu item ? - by ajackson - 2011-11-17, 21:07:51
Use Link as Menu item ? - by mvlcek - 2011-11-17, 21:31:24
Use Link as Menu item ? - by ajackson - 2011-11-25, 20:22:48



Users browsing this thread: 1 Guest(s)