Autoloader not finding classes from my plugin

Given the first PHP code snippet you posted, I don’t see that you’re using the class yet, which explains why you’re not seeing your classes in the autoload error log that you’re debugging with. Note that use will not trigger PHP’s autoloader. use My_Plugin\Includes; You need to actually instantiate a class, check that it exists, … Read more

Static vs Dynamic methods in WordPress

This question is about the famous debate on using Dynamic methods over static methods in classes. According to my research the widely acknowledged idea is to limit the use of static methods as much as we can. If you need to store something it’d need to be a static member variable, which is problematic. Just … Read more

Trying to get property of non-object

If you look at the documentation for get_term_by(), you’ll see that it: Will return false if $taxonomy does not exist or $term was not found. You need to account for this possibility in your code by checking the value of $term. You’ll also note from the documentation that get_term_by() does not return a WP_Error, so … Read more

UML diagrams of WordPress

I don´t know any sequence diagram for WordPress but if you decide to built them yourself (which would be appreciated 🙂 ) you may get some inspiration from these sequence diagrams created for Drupal

Load classes using spl_autoload_register

Right, to answer my own stupidity. spl_autoload_register is called when you instantiate a class. Moving new water(); from file water.php to file test.php solves the problem. The test.php should then look like this: <?php /* Plugin Name: test Plugin URI: test Description: Version: 1.0 Author: test Author URI: test */ class test_main { public function … Read more

problem with implementing widget via the_content()

Its extremely difficult to remove a filter that’s added as part of an object. You have get the reference to the original object and pass that as part of the function to remove. Luckily the filter was added at an unusual priority, so you will probably be safe removing all filters at priority 100: remove_all_filters( … Read more

Will WordPress become completely OOP?

I can say with about 99.9999% certainty that WordPress will never become completely OOP in future version, not the least of which is that the topic has come up time and again on the wp-hackers list and the core team members has expressed no interest in doing so. As I look at my personal experience … Read more

What is an example of the Single Responsibility Principle?

Check out the Solid description. Unless you ask for something more specific, it will be hard to help more. Single responsibility is the concept of a Class doing one specific thing (responsibility) and not trying to do more than it should, which is also referred to as High Cohesion. Classes dont often start out with … Read more