Giter Site home page Giter Site logo

Comments (7)

michaeluno avatar michaeluno commented on August 16, 2024

Hi,

Use the show_in_menu custom post type argument. For an existing admin page root menu created with Admin Page Framework, pass the admin page class name as it serves as the menu slug.

I've uploaded example plugins.

  • to add a custom post type submenu item to an existent admin page root menu (see)
  • to add a custom post type submenu item to an existent custom post type root menu (see)

from admin-page-framework.

champsupertramp avatar champsupertramp commented on August 16, 2024

Hi @michaeluno Thanks for your attention.

I tried the following code snippet but unfortunately, the submenu don't reigster. The post type is created and the root menu is there. It's just the submenu doesn't appear in the parent menu.

class APFDemo_CPTSubmenu_AdminPage extends AdminPageFramework {

    public function setUp() {

        $this->setRootMenuPage( 'CPT Demo - CPT Submenu','dashicons-welcome-widgets-menus', 100 );
        $this->addSubMenuItems(
            array(
                'title'        => 'Main',
                'page_slug'    => 'apf_demo_cpt_submenu_main',
                'order'        => 10,
            )
        );

    }

    /**
     * @callback do_{page slug}
     */
    public function do_apf_demo_cpt_submenu_main() {
        echo "<p>Hello.</p>";
    }

}


class APFDemo_CPTSubmenu_PostType_A extends AdminPageFramework_PostType {

    public function setUp() {
        $this->setArguments(
            array(
                'labels'                => array(
                    'name'                  => 'CPT Submenu A',
                    'menu_name'             => 'CPT Submenu A',
                ),
                'show_ui'               => true,
                'show_in_menu'          => 'APFDemo_CPTSubmenu_AdminPage',
                'submenu_order_manage'  => 20,
            )
        );
    }

}

new APFDemo_CPTSubmenu_AdminPage;

new APFDemo_CPTSubmenu_PostType_A('cpt_newtest', null, __FILE__);

from admin-page-framework.

michaeluno avatar michaeluno commented on August 16, 2024

In your code, extendsAdminPageFramework { will code an error. Try the examples shown on Gist linked in my previous reply. They can be downloaded as a zip file and run as a plugin. Install them on your test site with the Admin Page Framework - Loader plugin activated.

from admin-page-framework.

champsupertramp avatar champsupertramp commented on August 16, 2024

Hi @michaeluno

It's a typo with my example but it's already set as extends AdminPageFramework in the plugin that i'm working on. I'm also able to create root pages, section and fields.

Regards,

from admin-page-framework.

michaeluno avatar michaeluno commented on August 16, 2024

Try the example plugins on a test site which only activates the Admin Page Framework - Loader plugin, NOT on your development plugin in order to eliminate any possible factors which cause problems.

The steps you need to take is:

  1. Create a test site with no plugins and with the default theme.
  2. Install and activate the Admin Page Framework - Loader plugin.
  3. Install and activate the example plugin.

And see what happens. If it doesn't give you a desired result, post screenshots.

from admin-page-framework.

champsupertramp avatar champsupertramp commented on August 16, 2024

Hi @michaeluno

Good news! I'm able to make it work now within the development plugin. It was an issue with my class calls.
I've changed it from 'show_in_menu' => 'Admin_Settings',
to 'show_in_menu' => '\The_Subscription\Admin_Settings',

Thank you very much for your guidance!

Regards,

from admin-page-framework.

michaeluno avatar michaeluno commented on August 16, 2024

Okay, great.

from admin-page-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.