Tag Info

Hot answers tagged

4

The best way to solve this is to simplify your code. Right now, ScriptQueuer::QueueCss() is just a static method, and it is getting its data too late. You could use an immutable object instead and then just register one of its methods as callback. Example: class Enqueuer { private $stylesheets; public function __construct( ArrayObject ...


3

The name of the current hook is always current_filter(). Despite its name, this function returns the name of actions too. Usage example: Move the textarea in a comment form. The current priority is: key( $GLOBALS['wp_filter'][ $hook ] ).


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


1

Makes no difference. Despite the fact add_action doesn't actually check if the callback is indeed callable (i.e. is a valid function/class/method), PHP will first "load" function and class definitions before executing inline code, hence why you can do something like: wpse_185390_function(); // Perfectly fine, even though the function is defined "afterwards" ...


1

The publish_{post-type} action is triggered only when the post change from any post status (not published) to published; for example, if the post is already published and you edit it, the publish_{post-type} action is not triggered. I think you need to hook your function to save_post_{post_type} action, which is triggered every time a post is saved, not ...


1

The main component you are probably missing is dropping your customizations in an install.php file in the wp-content directory. If you look at the /wp-admin/includes/upgrade.php you will be able to see exactly how it is included and the installation functions you can override. I am not sure if that will be good enough to catch the hook you want to use but ...



Only top voted, non community-wiki answers of a minimum length are eligible