• In my attempts to learn plugin development I have been going through the “class based” sample here:

    http://www.yaconiello.com/blog/how-to-write-wordpress-plugin/

    One thing I don’t understand is, why are the WP_Plugin_Template and WP_Plugin_Template_Settings classes instantiated at all? They have no member variables, so it seems the instances have no practical value and the class functions may as well all be static. Are there situations where they might have variables?

    Also the call to do_settings_fields() in templates/settings.php seems to be a mistake. It doesn’t do anything and is missing the required second argument.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m assuming they are just example empty class frameworks that you are expected to elaborate on based on your specific needs, or that you do so by extending the base class. Since the point is how to make a class based plugin and not how to make a functional class that does something useful, the extra properties may have been thought to just confuse the issue, except in your case where the lack of properties was confusing 🙂

    You’re right about the settings fields. Typically, one shouldn’t even be calling that function, all the fields can be done at once with do_settings_sections(). Sigh. Such is the nature of information on the Internet. Everything must be viewed with a critical eye, all data is suspect, even the Codex, and even this post! You will eventually recognize authors whose information you trust and always go to them when possible.

    Thread Starter Rod Roark

    (@sunsetsystems)

    Thanks bcworkz, that’s about what I figured. If anyone has other simple examples of object oriented plugins I’d love to look at those also.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Oddities about the class based plugin tutorial’ is closed to new replies.