[theme-reviewers] add_theme_page()

Rahul Bansal rahul.bansal at rtcamp.com
Tue Jan 25 13:31:44 UTC 2011


@WPTRT

Is this kind of "submenu" is acceptable?
https://img.skitch.com/20110125-8g997iqaysqnuaipbryqj3bq1k.png



--
Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/



On Tue, Jan 25, 2011 at 2:03 PM, Philip M. Hofer (Frumph) <philip at frumph.net
> wrote:

>  hey sounds like a good plan, get some theme-review & associates approved
> tutorials goin, like best-practices sorta thing
>
>
>
> ----- Original Message -----
> *From:* Rahul Bansal <rahul.bansal at rtcamp.com>
> *To:* theme-reviewers at lists.wordpress.org
> *Sent:* Tuesday, January 25, 2011 12:22 AM
> *Subject:* Re: [theme-reviewers] add_theme_page()
>
> Yup, that works for me, added to actual page
>
> Cool. If I come across more, I will add it there via comments section.
> If you find them good enough for all of us, you can add them to the main
> post.  :-)
>
> --
> Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
> Skype: rahul286 | Twitter: @rahul286 | Web: http://rtcamp.com/
>
>
>
> On Tue, Jan 25, 2011 at 1:49 PM, Philip M. Hofer (Frumph) <
> philip at frumph.net> wrote:
>
>>  Yup, that works for me, added to actual page
>>
>>
>>
>>  ----- Original Message -----
>> *From:* Rahul Bansal <rahul286 at gmail.com>
>> *To:* theme-reviewers at lists.wordpress.org
>>   *Sent:* Tuesday, January 25, 2011 12:14 AM
>> *Subject:* Re: [theme-reviewers] add_theme_page()
>>
>>  If you have any links that you would like added to the
>>> make.wordpress.org/themes site, sure pass em over
>>
>> Cool. Added it here - http://make.wordpress.org/themes/about/resources/ via
>> comment form.
>> Daniel really made everything so simple!
>>
>>
>> --
>> Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
>> Mobile: +91-9860501882 | Web: http://rtcamp.com/
>>
>>
>>
>> On Tue, Jan 25, 2011 at 1:39 PM, Philip M. Hofer (Frumph) <
>> philip at frumph.net> wrote:
>>
>>>  If you have any links that you would like added to the
>>> make.wordpress.org/themes site, sure pass em over
>>>
>>> i'll see who'se handling those pages and talk to them about it
>>>
>>>
>>>
>>>  ----- Original Message -----
>>> *From:* Rahul Bansal <rahul286 at gmail.com>
>>>  *To:* theme-reviewers at lists.wordpress.org
>>>   *Sent:* Monday, January 24, 2011 11:49 PM
>>> *Subject:* Re: [theme-reviewers] add_theme_page()
>>>
>>> Really good - added to our internal wiki. We all will be surely using
>>> this way only going ahead! :-)
>>>
>>> @WPTRT
>>> Just a suggestion - if such tutorials can be collected somewhere for easy
>>> reference and then everytime you recommends something, you may share a link
>>> to alternative (and better) solution that is acceptable.
>>> I know this will be extra work for you so a page on codex may be devoted
>>> for this where dev may find quick-help.
>>>
>>> --
>>> Rahul Bansal | Founder & CEO | rtCamp Solutions Pvt. Ltd.
>>> Mobile: +91-9860501882 | Web: http://rtcamp.com/
>>>
>>>
>>>
>>> On Tue, Jan 25, 2011 at 8:11 AM, Amy <sabreuse at gmail.com> wrote:
>>>
>>>>  Fantastic tutorial, Daniel - definitely one that I'll be coming back
>>>> to.
>>>>
>>>>
>>>> On Jan 24, 2011, at 9:07 PM, Josh Stauffer <joshstauffer at gmail.com>
>>>> wrote:
>>>>
>>>>    And a tweet from me.
>>>>
>>>> Josh
>>>>
>>>>
>>>> On Mon, Jan 24, 2011 at 7:38 PM, Edward Caissie <<edward.caissie at gmail.com>
>>>> edward.caissie at gmail.com> wrote:
>>>>
>>>>> Added a Tweet, too ...
>>>>>
>>>>>
>>>>> On Mon, Jan 24, 2011 at 6:55 PM, Emil Uzelac < <emil at themeid.com>
>>>>> emil at themeid.com> wrote:
>>>>>
>>>>>> Good job, tweeted as well :)
>>>>>>
>>>>>>
>>>>>> *Emil Uzelac* | ThemeID | T: 224-444-0006 | Twitter: @EmilUzelac<http://twitter.com/emiluzelac>| E:
>>>>>> emil at themeid.com | http://themeid.com
>>>>>> *Make everything as simple as possible, but not simpler.* - Albert
>>>>>> Einstein
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jan 24, 2011 at 5:49 PM, Chip Bennett <<chip at chipbennett.net>
>>>>>> chip at chipbennett.net> wrote:
>>>>>>
>>>>>>> *jaw drops*
>>>>>>>
>>>>>>> Now *that* is an awesome tutorial! Well done, Daniel!
>>>>>>>
>>>>>>> (Tweeted)
>>>>>>>
>>>>>>> Chip
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Jan 24, 2011 at 5:34 PM, Daniel Tara <<contact at onedesigns.com>
>>>>>>> contact at onedesigns.com> wrote:
>>>>>>>
>>>>>>>>  I wrapped this into and article. Hope it helps you and all
>>>>>>>> developers in need out there:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> <http://www.onedesigns.com/tutorials/separate-multiple-theme-options-pages-using-tabs>
>>>>>>>> http://www.onedesigns.com/tutorials/separate-multiple-theme-options-pages-using-tabs
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> *From:* <theme-reviewers-bounces at lists.wordpress.org>
>>>>>>>> theme-reviewers-bounces at lists.wordpress.org [mailto:<theme-reviewers-bounces at lists.wordpress.org>
>>>>>>>> theme-reviewers-bounces at lists.wordpress.org] *On Behalf Of *Sayontan
>>>>>>>> Sinha
>>>>>>>> *Sent:* Monday, January 24, 2011 11:24 PM
>>>>>>>>
>>>>>>>> *To:* <theme-reviewers at lists.wordpress.org>
>>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>> *Subject:* Re: [theme-reviewers] add_theme_page()
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> That would be a relief. Let me give it a try.
>>>>>>>>
>>>>>>>> On Mon, Jan 24, 2011 at 1:12 PM, Daniel Tara <<contact at onedesigns.com>
>>>>>>>> contact at onedesigns.com> wrote:
>>>>>>>>
>>>>>>>> Creating tabs is as easy as this:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> function sayontan_admin_tabs( $current = 'general' ) {
>>>>>>>>
>>>>>>>>                 $tabs = array( 'general' => 'General', 'layput' =>
>>>>>>>> 'Layout', 'advanced' => 'Advanced' );
>>>>>>>>
>>>>>>>>                 $links = array();
>>>>>>>>
>>>>>>>>                 foreach( $tabs as $tab => $name ) :
>>>>>>>>
>>>>>>>>                                 if ( $current == $tab ) :
>>>>>>>>
>>>>>>>>                                                 $links[] = "<a
>>>>>>>> class='nav-tab nav-tab-active'
>>>>>>>> href='?page=sayontan_options&tab=$tab'>$name</a>";
>>>>>>>>
>>>>>>>>                                 else :
>>>>>>>>
>>>>>>>>                                                 $links[] = "<a
>>>>>>>> class='nav-tab' href='?page=sayontan_options&tab=$tab'>$name</a>";
>>>>>>>>
>>>>>>>>                                 endif;
>>>>>>>>
>>>>>>>>                 endforeach;
>>>>>>>>
>>>>>>>>                 foreach ( $links as $link )
>>>>>>>>
>>>>>>>>                                 echo $link;
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> if ( isset ( $_GET['tab'] ) ) :
>>>>>>>>
>>>>>>>>                 $tab = $_GET['tab'];
>>>>>>>>
>>>>>>>> else:
>>>>>>>>
>>>>>>>>                 $tab = 'general';
>>>>>>>>
>>>>>>>> endif;
>>>>>>>>
>>>>>>>> switch ( $tab ) :
>>>>>>>>
>>>>>>>>                 case 'general' :
>>>>>>>>
>>>>>>>>                 // Whatever
>>>>>>>>
>>>>>>>>                 break;
>>>>>>>>
>>>>>>>>                 ...
>>>>>>>>
>>>>>>>> endswitch;
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> *From:* <theme-reviewers-bounces at lists.wordpress.org>
>>>>>>>> theme-reviewers-bounces at lists.wordpress.org [mailto:<theme-reviewers-bounces at lists.wordpress.org>
>>>>>>>> theme-reviewers-bounces at lists.wordpress.org] *On Behalf Of *Sayontan
>>>>>>>> Sinha
>>>>>>>> *Sent:* Monday, January 24, 2011 10:47 PM
>>>>>>>> *To:* <theme-reviewers at lists.wordpress.org>
>>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>>
>>>>>>>>
>>>>>>>> *Subject:* Re: [theme-reviewers] add_theme_page()
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Ideally, it would still have just one Theme Options page under
>>>>>>>>
>>>>>>>>
>>>>>>>> appearance, and then use tabs or something else on its own page to
>>>>>>>> separate the options out.
>>>>>>>>
>>>>>>>>
>>>>>>>> This is much easier said than done. I have been working towards
>>>>>>>> getting tabs in place on one page (multiple calls to add_theme_page makes
>>>>>>>> things look quite ugly), but there are simply too many limitations with the
>>>>>>>> whole API to make this work effectively. Let me try to explain.
>>>>>>>>
>>>>>>>> *The Scenario:*
>>>>>>>> My theme has several options. Putting them all on one page causes a
>>>>>>>> lot of issues, like sluggishness of the back-end and interference with
>>>>>>>> PHP-Suhosin protection settings (though Suhosin can be tweaked). I
>>>>>>>> originally had a 2-level tab system, with horizontal tabs at the top for
>>>>>>>> different sections of settings, then vertical tabs within each section (that
>>>>>>>> is similar to the kind of settings that the other folks are talking about).
>>>>>>>> The tabs were all handled by JQuery. This works fine with a small number of
>>>>>>>> options, but with a large number of options, the sluggishness shows up in
>>>>>>>> the back-end. That was when I removed the horizontal tabs at the top level
>>>>>>>> and used add_menu_page and add_submenu_page.
>>>>>>>>
>>>>>>>> But with the recent enforcements of new rules and recommendations, I
>>>>>>>> have had to do some major rework. I first rewrote the options framework to
>>>>>>>> use the Settings API, but still with add_menu_page and add_submenu_page. Now
>>>>>>>> I am rewriting again to get rid of the additional menu and roll it back to
>>>>>>>> how the look was earlier, but with a difference: the entire set of options
>>>>>>>> will not be loaded into browser memory in JQuery tabs. Instead, I will try
>>>>>>>> to fetch each page as it is clicked, like the Theme Installation page in WP.
>>>>>>>>
>>>>>>>> *My attempts:*
>>>>>>>>
>>>>>>>>    1. I first simply created one options page, then included a set
>>>>>>>>    of links at the top.
>>>>>>>>    *Issue:* Getting the links to behave as belonging within WP.
>>>>>>>>    E.g. If your admin panel is at <http://host.com/wp-admin>
>>>>>>>>    http://host.com/wp-admin, your theme options page could be at
>>>>>>>>    <http://host.com/wp-admin/themes.php?page=my-options>
>>>>>>>>    http://host.com/wp-admin/themes.php?page=my-options. The tabs,
>>>>>>>>    however cannot be given links through the admin panel. In other words, to
>>>>>>>>    get a URL such as
>>>>>>>>    <http://host.com/wp-admin/themes.php?page=my-sub-options-1>
>>>>>>>>    http://host.com/wp-admin/themes.php?page=my-sub-options-1, I
>>>>>>>>    HAVE to use add_theme_page. If I don't use add_theme_page, the page isn't
>>>>>>>>    added to the whitelist and will not show up. I cannot use other URLs,
>>>>>>>>    because then I will have something like this:
>>>>>>>>    <http://host.com/wp-content/themes/my-theme/my-sub-options-1.php>
>>>>>>>>    http://host.com/wp-content/themes/my-theme/my-sub-options-1.php,
>>>>>>>>    which is just not done.
>>>>>>>>    2. To get around the above, I decided to bundle AJAX with the
>>>>>>>>    options page. So I have one options page accessible through
>>>>>>>>    <http://host.com/wp-admin/themes.php?page=my-options>
>>>>>>>>    http://host.com/wp-admin/themes.php?page=my-options. In there I
>>>>>>>>    have 5 links, each of which invokes AJAX to load the specific options page,
>>>>>>>>    while staying in
>>>>>>>>    <http://host.com/wp-admin/themes.php?page=my-options>
>>>>>>>>    http://host.com/wp-admin/themes.php?page=my-options. This way I
>>>>>>>>    only need to whitelist the main page.
>>>>>>>>    *Issue:* Getting settings_fields() to generate _wp_http_referer
>>>>>>>>    different from admin-ajax.php. This is causing options.php to return
>>>>>>>>    admin-ajax.php?updated=true, which is not what I want. This is where I am
>>>>>>>>    stuck right now, but hopefully I will get over the hurdle soon.
>>>>>>>>
>>>>>>>> I am looking forward to completing this exercise, so that other
>>>>>>>> developers can learn from my (rather harsh) experience here.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Sayontan.
>>>>>>>>
>>>>>>>> On Mon, Jan 24, 2011 at 11:08 AM, Otto < <otto at ottodestruct.com>
>>>>>>>> otto at ottodestruct.com> wrote:
>>>>>>>>
>>>>>>>> On Mon, Jan 24, 2011 at 1:03 PM, Rahul Bansal <<rahul286 at gmail.com>
>>>>>>>> rahul286 at gmail.com> wrote:
>>>>>>>> > What if theme offers so many options that it need to contains 4-5
>>>>>>>> subpages?
>>>>>>>>
>>>>>>>> Ideally, it would still have just one Theme Options page under
>>>>>>>> appearance, and then use tabs or something else on its own page to
>>>>>>>> separate the options out.
>>>>>>>>
>>>>>>>> Realistically, I'd say a theme with that many options is too complex
>>>>>>>> to begin with. Themes should be about the look of the site, not
>>>>>>>> crazy
>>>>>>>> functionality. Break the functionality parts out into plugins that
>>>>>>>> go
>>>>>>>> along with the theme or something like that.
>>>>>>>>
>>>>>>>> -Otto
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> theme-reviewers mailing list
>>>>>>>> <theme-reviewers at lists.wordpress.org>
>>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>>  <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Sayontan Sinha
>>>>>>>> <http://mynethome.net/>http://mynethome.net |
>>>>>>>> <http://mynethome.net/blog>http://mynethome.net/blog
>>>>>>>> --
>>>>>>>> Beating Australia in Cricket is like killing a celebrity. The death
>>>>>>>> gets more coverage than the crime.
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> theme-reviewers mailing list
>>>>>>>> <theme-reviewers at lists.wordpress.org>
>>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>>  <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Sayontan Sinha
>>>>>>>> <http://mynethome.net/>http://mynethome.net |
>>>>>>>> <http://mynethome.net/blog>http://mynethome.net/blog
>>>>>>>> --
>>>>>>>> Beating Australia in Cricket is like killing a celebrity. The death
>>>>>>>> gets more coverage than the crime.
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> theme-reviewers mailing list
>>>>>>>> <theme-reviewers at lists.wordpress.org>
>>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>>  <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> theme-reviewers mailing list
>>>>>>> <theme-reviewers at lists.wordpress.org>
>>>>>>> theme-reviewers at lists.wordpress.org
>>>>>>>  <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> theme-reviewers mailing list
>>>>>> <theme-reviewers at lists.wordpress.org>
>>>>>> theme-reviewers at lists.wordpress.org
>>>>>> <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> theme-reviewers mailing list
>>>>> <theme-reviewers at lists.wordpress.org>
>>>>> theme-reviewers at lists.wordpress.org
>>>>> <http://lists.wordpress.org/mailman/listinfo/theme-reviewers>
>>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>>
>>>>>
>>>>  _______________________________________________
>>>> theme-reviewers mailing list
>>>> theme-reviewers at lists.wordpress.org
>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>
>>>>
>>>> _______________________________________________
>>>> theme-reviewers mailing list
>>>> theme-reviewers at lists.wordpress.org
>>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>>
>>>>
>>>  ------------------------------
>>>
>>> _______________________________________________
>>> theme-reviewers mailing list
>>> theme-reviewers at lists.wordpress.org
>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>
>>>
>>> _______________________________________________
>>> theme-reviewers mailing list
>>> theme-reviewers at lists.wordpress.org
>>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>>
>>>
>>  ------------------------------
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>>
>  ------------------------------
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110125/f5b7dcaf/attachment-0001.htm>


More information about the theme-reviewers mailing list