[theme-reviewers] add_theme_page()

Sayontan Sinha sayontan at gmail.com
Mon Jan 24 21:10:25 UTC 2011


Phil,
I have skinned the cat several ways here, only to hit dead ends. The easy
solution is obviously to load the whole set of options in memory and split
it out into tabs using JQuery, but as I said, there are overheads if your
pages are heavy.

It is likely that I have missed an easier approach than what I am
attempting, but I think it is more probable that the API falls short here.
After all, most themes today use a custom built option maintenance
mechanism, and I am pretty sure very few people if any have attempted large
theme options pages with the Settings API. The Settings API works fine if I
leave in add_menu_page and add_submenu_page (I was going to submit it that
way), but the combination with AJAX is what makes it tough to implement.
Again, it is possible that I missed a trick here.

Sayontan.

On Mon, Jan 24, 2011 at 12:52 PM, Philip M. Hofer (Frumph) <
philip at frumph.net> wrote:

>  I have no idea what code your using to try to accomplish what you're
> doing, but i'm thinking that there are better methods for implementation
> that are being overlooked.
>
>
> ----- Original Message -----
> *From:* Sayontan Sinha <sayontan at gmail.com>
> *To:* theme-reviewers at lists.wordpress.org
> *Sent:* Monday, January 24, 2011 12:46 PM
> *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, your theme options
>    page could be at 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, 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, 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. 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. 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> wrote:
>
>> On Mon, Jan 24, 2011 at 1:03 PM, Rahul Bansal <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
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>
>
>
> --
> Sayontan Sinha
> http://mynethome.net | 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
> 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
>
>


-- 
Sayontan Sinha
http://mynethome.net | http://mynethome.net/blog
--
Beating Australia in Cricket is like killing a celebrity. The death gets
more coverage than the crime.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20110124/0e3a6208/attachment-0001.htm>


More information about the theme-reviewers mailing list