johnpbloch / wordpress

A fork of WordPress with Composer support added. Branches, tags, and trunk synced from upstream every 15 minutes.
https://packagist.org/packages/johnpbloch/wordpress
602 stars 102 forks source link

add_submenu_page not working with johnpbloch/wordpress on Bedrock #16

Closed eshimischi closed 8 years ago

eshimischi commented 8 years ago

Hello. Very strange to say but i made my custom post type Release for Discography and tried to sort out things with add_submenu_page to add an Option submenu with no luck.

add_action( 'admin_menu', array( $this, 'add_settings_menu' ) );
function add_settings_menu() {
  add_submenu_page( 'edit.php?post_type=release', 'Options', 'Options', 'edit_plugins', 'label-options', array( $this, 'options_form' ) );
}
shot1

It works fine with official Wordpress. Tried to reinstall Bedrock and composer->johnpbloch/wordpress with no luck again.

Any ideas?

johnpbloch commented 8 years ago

@eshimischi What version of WordPress was this happening on? And does the problem still happen with this repo with all other plugins turned off and the default theme active?

eshimischi commented 8 years ago

@johnpbloch 4.4.1. Yes i checked the Decibel premium theme also Decibel it has some plugins that add the submenus to custom type menus, i can't see it also, but when we avoid Bedrock and use repo without it, it works.

eshimischi commented 8 years ago

@johnpbloch Just made a test: Install Bedrock, compose install (wordpress 4.4.1) There are no any plugins, Twenty Fifteen theme activated Add a code to functions.php

$args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => false, 'rewrite' => array( 'slug' => 'release' ), 'capability_type' => 'post', 'has_archive' => false, 'hierarchical' => false, 'menu_position' => 5, 'taxonomies' => array(), 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), 'exclude_from_search' => false, 'menu_icon' => 'dashicons-media-audio' ); register_post_type( 'release', $args );

add_action('admin_menu', 'wpdocs_register_my_custom_submenu_page'); function wpdocs_register_my_custom_submenu_page() {add_submenu_page( 'edit.php?post_type=release', 'Settings', 'Settings', 'edit_plugins', 'label-settings', 'options_form' );}

And the result is the same!

screen shot 2016-02-03 at 01 45 26
johnpbloch commented 8 years ago

@eshimischi This is just a hunch, but can you try changing the required capability from edit_plugins to manage_options? I'm not positive Bedrock does this by default, but I know a lot of people that use composer to manage their sites completely shut off file modification, which automatically removes the edit_plugins capability from all users.

If that doesn't work, I'll try to reproduce the issue and see if I can figure it out.

eshimischi commented 8 years ago

@johnpbloch you just decided my problem, yes indeed manage_options works and now i can see the Settings submenu. Didn't see any tips about changing edit_plugins before so thanks again for your time!

PS: i just found it! Support

johnpbloch commented 8 years ago

I'm glad it was something simple (although terribly obscure), and not an actual bug in the WP or Bedrock codebase. Thanks for getting in touch with your question!