Theme Options? What happened?

Hey @ned,

Our plugin that we use at Lumen added a few additional “Theme Option” tabs under “Appearance” in the admin area. I just noticed in the change log for 3.7.0 that it looks like the Global, mPDF, eBook, and Web Options have been given their own classes that extend “\Pressbooks\Options”? Would this have effected the way the “Theme Options” area works? Is there a way 3rd party plugins can hook into something to add more Theme options, and if not, is this something that you’d be open to having?



Also, I’m getting an error on the Theme Option page under the mPDF Options Tab that reads:

Notice: Undefined index: mpdf_fontsize in /sites/wordpress/wp-content/plugins/pressbooks/includes/modules/themeoptions/class-pb-mpdfoptions.php on line 318

Any thoughts on that?

Hi Bryan,

In short: yes, there is a way third-party plugins can hook in to add theme options. Still needs a bit more work. I will be in touch this coming week to get you some more info.

Happy New Year!

P.S. Re: the undefined index error, that’s probably a situation where we should be calling isset before trying to access an option array key. As per this thread, the mPDF exporter hasn’t been updated much of late.

@ned, fixed the error I was getting. Changes are in this PR. :slight_smile:

1 Like

Okay, so there’s an issue for this:

I am regrouping post-vacation but would like to return to work on this, @Bryan, and I would love to collaborate with you on it as it seems to be of mutual interest. Let’s be in touch tomorrow? Also related:

1 Like

@ned, just got our plugin working with the changes that were made to theme options. But yeah, probably some things could be made better. Let me know how I might be able to help with this.

Here’s the commit where I made our plugin work:

Thanks for this, Bryan—super helpful! I am working in an open PR ( and will probably ask for some help & testing from you as I wrap it up. Will keep you posted.

Okay. That PR is pretty much ready to go, I think. Some sample code for you to look at:

  1. A demo of adding a custom theme options tab (you’ve already done this in a slightly different way, but there might be some more helpful info in here):
  2. A demo of adding a custom option to a core tab:

Preliminary testing seems to be going nicely. I’m having to rebuild some of our old theme options. So far, so good though. I’ll let you know if I run into any issues.

Will you be creating any documentation for others to reference on how to add/edit theme options beyond the examples you linked to above? They are clear to me, but I can imagine it being difficult to follow for others down the road.

Yes, definitely. In fact it’s on my to-do list to write a dev blog post for about this very topic.

1 Like

Works great! I was able to throw away hundreds of lines of terrible sad code with your work on this. Thanks Ned!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.