Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Menus and Submenus #5487

Closed
Kpudlo opened this issue Sep 30, 2019 · 4 comments · Fixed by #5497
Closed

Admin Menus and Submenus #5487

Kpudlo opened this issue Sep 30, 2019 · 4 comments · Fixed by #5497

Comments

@Kpudlo
Copy link

Kpudlo commented Sep 30, 2019

Describe the bug
I've been working on seeing about creating an admin menu with submenu items through pods and noticed a couple of features that could be bugs, but I'm also not sure if they are working as intended.

Error 1. If I assign a Pods CPT to a Pods Settings Page that is set to show on the main admin menu (no parent), it overrides any options on that Pods Settings Page and displays just the CPT.

Error 2. If I assign a Pods CPT to a Pods Settings Page that is set to a submenu of another Pods Settings Page it does nothing.

I know that I can add a submenu page using add_submenu_page, which would solve these issues, but wasn't sure if this was working as intended.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Pods Settings Page, in my case called Organization.
    1. Add a new custom field (can be anything)
    2. Change Menu Location to Make a new menu item below Settings
  2. Create a second Pods Settings Page, in my case called 'Company'.
    1. Change Menu Location to Add a submenu item to another menu
    2. Change Custom Menu Location to pods-settings-organization
  3. Create a new Pods CPT, called Brand
  4. Set the Companies CPT's Parent Menu ID to pods-settings-organization and observe the first error
  5. Set the Companies CPT Parent Menu ID to pods-settings-company and observe the second error

Expected behavior
I would expect that in the case of Error 1., the Brand CPT would be added as a submenu page of the Organization Pods Settings Page.

With the CPT overwriting the Pods Settings Page, I would expect in the case of Error 2., the Brand CPT should overwrite Company Pods Settings Page

Screenshots
image
Looking at the Organization Pods Settings Page with the Brand CPT Parent Menu ID set to pods-settings-organization

image
Looking at the Company Pods Settings Page with the Brand CPT Parent Menu ID set to pods-settings-company

Pods Version

Please provide the version of Pods you are running:
2.7.15

WordPress Environment

wp-core

version: 5.2.3
site_language: en_US
user_language: en_US
permalink: /blog/%year%/%monthnum%/%day%/%postname%/
https_status: true
user_registration: false
default_comment_status: open
multisite: true
user_count: 3
site_count: 2
network_count: 1
dotorg_communication: true

wp-active-theme

name: Hello Elementor
version: 2.2.1
author: Elementor Team
author_website: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dash
parent_theme: none
theme_features: menus, post-thumbnails, automatic-feed-links, title-tag, html5, custom-logo, editor-style, woocommerce, wc-product-gallery-zoom, wc-product-gallery-lightbox, wc-product-gallery-slider, widgets
theme_path: /path/to/site/wp-content/themes/hello-elementor

wp-themes (3)

Twenty Nineteen: version: 1.4, author: the WordPress team
Twenty Seventeen: version: 2.2, author: the WordPress team
Twenty Sixteen: version: 2.0, author: the WordPress team

wp-plugins-active (6)

Advanced Custom Fields PRO: version: 5.8.0, author: Elliot Condon (latest version: 5.8.4)
Central Color Palette: version: 1.13.11, author: Daniel Schneider
Distributor: version: 1.5.0, author: 10up Inc.
Elementor: version: 2.7.3, author: Elementor.com
Pods - Custom Content Types and Fields: version: 2.7.15, author: Pods Framework Team
QuadMenu: version: 1.9.0, author: Mega Menu (latest version: 1.9.3)

wp-plugins-inactive (15)

Elementor Pro: version: 2.6.5, author: Elementor.com (latest version: 2.7.1)
Gravity Forms: version: 2.4.9, author: rocketgenius
Gravity Forms User Registration Add-On: version: 4.1, author: rocketgenius
HT Mega - Absolute Addons for Elementor Page Builder: version: 1.2.3, author: HasThemes
Jetpack by WordPress.com: version: 7.7.2, author: Automattic
Site Kit by Google: version: 1.0.0-beta.1.0.6, author: Google
Stream: version: 3.4.1, author: XWP (latest version: 3.4.2)
Stream to Slack: version: 0.0.1, author: SMILE
User Switching: version: 1.5.2, author: John Blackbourn & contributors

wp-media

image_editor: WP_Image_Editor_GD
imagick_module_version: Not available
imagemagick_version: Not available
gd_version: 2.2.5
ghostscript_version: not available

wp-server

server_architecture: Linux 4.15.0-64-generic x86_64
httpd_software: nginx/1.14.0
php_version: 7.2.19-0ubuntu0.18.04.2 64bit
php_sapi: fpm-fcgi
max_input_variables: 4000
time_limit: 30
memory_limit: 256M
max_input_time: 60
upload_max_size: 400M
php_post_max_size: 400M
curl_version: 7.58.0 OpenSSL/1.1.1
suhosin: false
imagick_availability: false
htaccess_extra_rules: true

wp-database

extension: mysqli
server_version: 5.7.27-0ubuntu0.18.04.1
client_version: mysqlnd 5.0.12-dev - 20150407 - $Id: 3591daad22de08524295e1bd073aceeff11e6579 $

wp-constants

WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /path/to/site/wp-content
WP_PLUGIN_DIR: /path/to/site/wp-content/plugins
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: false
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined

wp-filesystem

wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable

pods

pods-server-software: nginx/1.14.0
pods-user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
pods-session-save-path: /var/lib/php/sessions
pods-session-save-path-exists: Yes
pods-session-save-path-writable: Yes
pods-session-max-lifetime: 1440
pods-opcode-cache-apc: Yes
pods-opcode-cache-memcached: No
pods-opcode-cache-opcache: Yes
pods-opcode-cache-redis: No
pods-object-cache-apc: Yes
pods-object-cache-apcu: Yes
pods-object-cache-memcache: No
pods-object-cache-memcached: No
pods-object-cache-redis: No
pods-memory-current-usage: 27.560M
pods-memory-current-usage-real: 2.000M
pods-network-wide: Yes
pods-install-location: /path/to/site/wp-content/plugins/pods/
pods-developer: No
pods-tableless-mode: No
pods-light-mode: No
pods-strict: No
pods-allow-deprecated: Yes
pods-api-cache: Yes

`

Pods Package Export (helpful!)

{"meta":{"version":"2.7.15","build":1569857386},"pods":{"3030":{"id":3030,"name":"sm_brand","label":"Brands","description":"","type":"post_type","storage":"meta","object":"","alias":"","fields":[],"show_in_menu":"1","_elementor_controls_usage":[],"label_singular":"Brand","public":"1","show_ui":"1","supports_title":"1","supports_editor":"1","publicly_queryable":"1","exclude_from_search":"0","capability_type":"post","capability_type_custom":"regular_brand","capability_type_extra":"1","has_archive":"0","hierarchical":"0","rewrite":"1","rewrite_with_front":"1","rewrite_feeds":"0","rewrite_pages":"1","query_var":"1","can_export":"1","default_status":"draft","supports_author":"0","supports_thumbnail":"0","supports_excerpt":"0","supports_trackbacks":"0","supports_custom_fields":"0","supports_comments":"0","supports_revisions":"0","supports_page_attributes":"0","supports_post_formats":"0","built_in_taxonomies_category":"0","built_in_taxonomies_elementor_library_category":"0","built_in_taxonomies_elementor_library_type":"0","built_in_taxonomies_link_category":"0","built_in_taxonomies_post_tag":"0","menu_position":"0","show_in_nav_menus":"1","show_in_admin_bar":"1","pfat_enable":"0","pfat_run_outside_loop":"0","pfat_append_single":"append","pfat_filter_single":"the_content","pfat_append_archive":"append","pfat_filter_archive":"the_content","rest_enable":"0","read_all":"0","write_all":"0","menu_location_custom":"pods-settings-company"},"3078":{"id":3078,"name":"company","label":"Company","description":"","type":"settings","storage":"none","object":"","alias":"","fields":[],"show_in_menu":1,"_elementor_controls_usage":[],"menu_name":"Company","menu_location":"submenu","ui_style":"post_type","menu_location_custom":"pods-settings-organization","menu_position":"0"},"3076":{"id":3076,"name":"organization","label":"Organization","description":"","type":"settings","storage":"none","object":"","alias":"","fields":{"test-field":{"id":3077,"name":"test-field","label":"Test Field","description":"","help":"","class":"","type":"boolean","weight":0,"pick_object":"","pick_val":"","sister_id":"","_elementor_controls_usage":[],"required":"0","pick_post_status":["publish"],"boolean_format_type":"checkbox","boolean_yes_label":"Yes","boolean_no_label":"No","admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"unique":"0"}},"show_in_menu":1,"_elementor_controls_usage":[],"menu_name":"Organization","menu_location":"top","ui_style":"settings","menu_position":"30"}}}

Possible Workaround
Use the add_submenu_page function

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label Type: Bug to this issue, with a confidence of 0.78. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@JoryHogeveen
Copy link
Member

Hello @Kpudlo

Found the issue and this appears to be a limitation in WordPress core.
See https://codex.wordpress.org/Function_Reference/register_post_type#show_in_menu

I'll check the action priority, it's currently set to 99 so there must be a reason for that.

@Kpudlo
Copy link
Author

Kpudlo commented Oct 17, 2019

Hi @JoryHogeveen

I changed the priority from 9 to 99 on one of my installs and confirmed that it will work once that is done. Thank you for your assistance!

@JoryHogeveen
Copy link
Member

Thanks for letting me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants