Linked Questions

0
votes
0answers
24 views

Best practice for instantiating classes with OOP Wordpress

I'm trying to wrap my head around using Wordpress the OOP way, and I'm a bit confused about how to properly instantiate a series of classes I've created for my theme. I've read tons of questions and ...
1
vote
2answers
32 views

Most efficient way to use classes to create admin pages using Settings API

I've built a class which creates admin pages with the Settings API. I'm trying to optimize it to run only where I need it. Most of the examples and tutorials I've seen say to instantiate it from the ...
0
votes
2answers
73 views

using filter and hook inside class

I'm going deep with oop to create wordpress plugins. I've found an interesting article about the hooks and how to use them inside a class. After reading I have some doubt: is correct to use the hooks ...
0
votes
0answers
22 views

When developing WordPress plugin, is it a good idea to create my class object by hooking to existing class constructor?

I want to create my object when another object is made. Is it a good idea to create my object by hooking to existing class constructor? for example if the main class is class WordPress_Class { /** ...
1
vote
1answer
83 views

Plugin. Html code in Template

perhaps i am blind or something but i searched alot, here and also wordpress codex and similar. In example i wrote a plugin that reads something from database and print someting. But how can i archive ...
0
votes
1answer
283 views

OOP development and hooks

I'm currently working on writing my first OOP Plugin for Wordpress. To help out a little bit with structure I looked for, and found, a boiler plate that sets up the basics for me. In Main.php there'...
1
vote
1answer
98 views

Update menu when saving settings

I have a settings page for my plugin in which the user can toggle a custom post type on or off. When the plugin is initialized I then check this setting to see if the custom content type should be ...
1
vote
0answers
121 views

Instantiating classes in constructor vs in a method [duplicate]

I'm writing a plugin, and for the most part I'm following the plugin boilerplate with the addition of autoloading and namespacing. When running the main class, where you include methods to run in the ...
1
vote
1answer
882 views

Where to add hooks in a class

In the code below, shouldn't the hooks under the bottom two functions be placed inside the constructor? class The_Class { private static $instance = null; public static function ...
1
vote
2answers
64 views

Will simple function names in a class structure conflict with other plugins?

I implement a class structure in my plugin, for example: class Ethans_Plugin { public function __construct() { add_filter( 'admin_init', array( $this, 'admin' ), 10, 1 ); ...
37
votes
1answer
10k views

Testing hooks callback

I'm developing a plugin using TDD and one thing that i completely fail to test are... hooks. I mean OK, i can test hook callback, but how could I test if a hook actually trigger (both custom hooks ...
0
votes
1answer
105 views

Plugin: Hooking up classes that have their own hooks

Was wondering if there is a "best" approach to hooking up classes that has their own hooks, still making sure that those hooks haven't run before the class got a chance to declare it's own said hooks. ...
13
votes
3answers
15k views

PHP error with shortcode handler from a class

Currently i am using the following generic flow for adding the shortcode for a plugin. class MyPlugin { private $myvar; function baztag_func() { print $this->myvar; ...
0
votes
1answer
156 views

remove_action: Initial attempt failed while a later attempt worked

I hope this is the right place to post this - if not, please just simply direct me to the right place! I recently came across a plugin that, among other things, added a meta entry to the header. I ...
0
votes
0answers
2k views

calling a function from a class in your template

ok, so I have created a plugin in Wordpress. I want to be able to use some values I have created in a function within my template but I just don't seem to be able to get it to work. I have created my ...

15 30 50 per page