michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
340 stars 71 forks source link

Page title and submenu to be different #156

Closed ghost closed 10 years ago

ghost commented 10 years ago

Is there a way to call the page title and sub menu different titles?

For instance I want to call the page title "custom theme settings", but want to name the sub menu I have created just "theme settings".

Here is how I have the page title which takes from the sub menu

    '$this->addSubMenuItems(   
        array(
            'title' => 'Custom Theme Settings',        // page title
            'page_slug' => 'feedsy-options',    // page slug
        )        
    );'
michaeluno commented 10 years ago

Currently it is not possible with one menu item. I'll add this to my todo list.

Which one do you like?

$this->addSubMenuItems(
    array(
        'title'         => __( 'My Menu Title', 'my-text-domain' ),
        'page_title'    => __( 'My Page Title', 'my-text-domain' ),
        'page_slug'     => 'apf_read_me',
    )
);

or

$this->addSubMenuItems(
    array(
        'title'         => __( 'My Page Title', 'my-text-domain' ),
        'menu_title'    => __( 'My Menu Title', 'my-text-domain' ),
        'page_slug'     => 'apf_read_me',
    )
);

Meanwhile, I can suggest a workaround. Create two menu items and make one hidden and the other a link to the page with a different title.

As an example, to change the menu title Read Me of the demo plugin to About, you can do something like this. Passing false to the show_in_menu argument will hide the menu item from the sidebar and the href argument will insert a menu item that just serves as a link.

            array(
                'title'                 => __( 'Read Me', 'admin-page-framework-demo' ),
                'page_slug'             => 'apf_read_me',
                'screen_icon'           => 'page',
                'show_in_menu'          => false, // hide it
            ),     
            array(
                'title'                 => __( 'About', 'admin-page-framework-demo' ),
                'href'                  => add_query_arg( array( 'page' => 'apf_read_me' ), admin_url( 'edit.php?post_type=apf_posts' ) ), 
            ),

The tricky part is add_query_arg( array( 'page' => 'apf_read_me' ), admin_url( 'edit.php?post_type=apf_posts' ) ) and you need to know the base url name and the query string of the page.

michaeluno commented 10 years ago

Now this is possible in the 3.3.0b branch. Download.

Example

        $this->addSubMenuItems(     
            array(
                'title'                 => __( 'Read Me', 'admin-page-framework-demo' ),    // the page title
                'menu_title'            => __( 'About', 'admin-page-framework' ),           // (optional) to make it different from the page title.
                'page_slug'             => 'apf_read_me',
            )
        );
ghost commented 10 years ago

That is awesome Michael. I will try this later today when I am woken up completely.
I am making out a starter theme with the embed method of the framework. Once it is completed where can I upload it to so that others have a starting base?

michaeluno commented 10 years ago

Once it is completed where can I upload it to so that others have a starting base?

I don't know. Maybe wordpress.org or github? Looking forward to it!

ghost commented 10 years ago

I have downloaded the latest and will try out the menu name and page title name today. Till then I think it is safe to close out this feature request. As for the starter theme with the framework embedded, your 100% correct. I will simply upload it to my own Git repo and make a PR to your readme.md and place a link where others that might like to use the theme as a starting point to use the framework once you approve it of course. Does that sound like a good idea?

Are there any commercial themes or plugins out there using the APF already? It would be great to see them listed.

michaeluno commented 10 years ago

Till then I think it is safe to close out this feature request.

Issue topics labelled Beta Stage is not stable so you may encounter some bugs.

Does that sound like a good idea?

To list anybody's product in readme of Admin Page Framework is something that should be avoided because if the number of users increases and there are more people wanting to list their products, it is not going to be maintainable. Rather I would prefer to have a product listing web site with the review system for Admin Page Framework so that anybody can submit their own work including custom field types.

Though, I can place a link to your repository or the web site of the product from my web site. So let me know when it's done.

Are there any commercial themes or plugins out there using the APF already? It would be great to see them listed.

Not that I know of.