jeudi 4 février 2016

Linking Wordpress Admin menu with page content

I have a custom post type that has a custom field attribute with the post ID of various admin pages. IE, edit-page, upload, etc. These hold custom documentation data on how to use these pages.

In another rendered page I loop through both the main menu and the sub menu and want to run a check if I have existing documentation data for that page. The problem is, I can't seem to find any kind of connected data between the post/page/screen id and the menu/submenu.

An example, the $screen object for the posts page is

WP_Screen Object
(
    [action] => 
    [base] => edit
    [columns:WP_Screen:private] => 0
    [id] => edit-post
    [in_admin:protected] => site
    [is_network] => 
    [is_user] => 
    [parent_base] => 
    [parent_file] => 
    [post_type] => post
    [taxonomy] => 
    content…

The array of data from the menu item is

Array (
    [0] => Posts
    [1] => edit_posts
    [2] => edit.php
    [3] =>
    [4] => menu-top menu-icon-post open-if-no-js menu-top-first
    [5] => menu-posts
    [6] => dashicons-admin-post )

How can I query if my currently loops sub-menu has

The ideal end solution would then basically turn this:

Menu Item A 
  Submenu Item A
    - Documentation Post Found
  Submenu Item B
Menu Item B
  Submenu Item A
Menu Item C
    - Documentation Post Found

Into this:

Menu Item A 
  Submenu Item A
    - Documentation Post Found
Menu Item C
    - Documentation Post Found



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire