Advertisement
Guest User

Busted add wp_nav_menu_items

a guest
May 7th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. add_action('admin_init', 'register_ballot_options' ); //place our ballot parameters into wp_options
  3. function register_ballot_options(){
  4. register_setting( 'ballot_group', 'ballots');
  5. }
  6.  
  7. add_action( 'admin_menu', 'ballots_admin' ); //Creates menu pages for ballot options entry
  8. function ballots_admin() {
  9. add_menu_page( 'User Ballots', 'User Ballots', 'administrator', __FILE__, 'add_ballot');
  10. }
  11.  
  12. add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
  13. function add_loginout_link( $items, $args ) {
  14. var_dump($args);
  15. wp_die("args from wp_nav_menu_items hook");
  16. if (is_user_logged_in() && $args->theme_location == 'primary') {
  17. $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
  18. } elseif (!is_user_logged_in() && $args->theme_location == 'primary') {
  19. $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
  20. }
  21. return $items;
  22. }
  23.  
  24. add_shortcode('do_ballots', 'do_ballots');
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement