Skip to content

Instantly share code, notes, and snippets.

@AlphaGit
Created March 13, 2013 04:09
Show Gist options
  • Save AlphaGit/5149321 to your computer and use it in GitHub Desktop.
Save AlphaGit/5149321 to your computer and use it in GitHub Desktop.
Adding a custom property, modifying the Nav_Waker_Menu_Edit for Wordpress. (Code extract from https://github.com/AlphaGit/alphasmanifesto/blob/master/custom_menu_setup.php)
<?php
// modify the displayed dom for editing menu items so that they provide the new value
add_action( 'wp_edit_nav_menu_walker', 'alphasmanifesto_edit_nav_menu_walker' );
function alphasmanifesto_edit_nav_menu_walker($walker) {
return "AlphasManifestoNavMenuEditWalker";
}
class AlphasManifestoNavMenuEditWalker extends Walker_Nav_Menu {
//...
function start_el(&$output, $item, $depth, $args) {
//...
// after the last field, before the submitbox code
?>
<p class="field-image-url description description-wide">
<label for="edit-menu-item-image-url-<?php echo $item_id; ?>">
<?php _e( 'Image URL' ); ?><br />
<input type="text" id="edit-menu-item-image-url-<?php echo $item_id ?>" class="widefat code edit-menu-item-image-url" name="menu-item-image-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr($item->image_url); ?>" /?
</label>
</p>
<?php
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment