Dynamically creating multiple widgets from Mustache templates

How do I register multiple widgets with a single class definition? You don’t. Modern class based Widget API in WP assumes that one class corresponds to one widget. Note that you can still have intermediary subclasses – (extend WP_Widget, then extend it once more) but what you register in the end is still one widget … Read more

wp_ajax handler with multiple class instances

Your McAdmin seems fine – the problem is likely one of two reasons: Another AJAX hook for blubb is terminating the script before McAdmin::get_vehicle You need to add the same hook for wp_ajax_nopriv_blubb – for non-logged in AJAX requests (otherwise it fails silently). If neither is the cause, you need to do a little HTTP … Read more

Accessing a protected property of a post

The foolproof method here to grab a dynamic member variable is to use reflection! Lets say we have this class: class MyClass { private $myProperty = true; } We can use reflection to acquire the class, and the property: $class = new ReflectionClass(“MyClass”); $property = $class->getProperty(“myProperty”); We can then set that property to accessible: $property->setAccessible(true); … Read more

OOP plugin not working

If that’s the entirety of plugin — you never create an object instance of your class. Class itself is merely a definition. Just like functions don’t do anything unless called, definition does nothing unless object of it is created. Thus new My_Custom_Plugin();. Note the if you want to be a good citizen you should allow … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)