Action hook ‘wp’ firing twice… why?

It can happen if one of the files you include in the theme is returning 404 Not Found error. Like, if you’re linking to a .js or .css or an image which does not exist on that location. Use the Inspector in your browser to see if you get any 404 errors, anywhere. Fix them … Read more

Using add_filter() in Widgets

<?php /** * Display the actual Widget * * @param Array $args * @param Array $instance */ public function widget($args, $instance){ … $wcss = apply_filters( ‘my-filter-name’, $wcss ); … } ?> To create your own filter hook just use the function “apply_filters” then as you mentioned add a function in your constructor i.e. function __constructor() … Read more

Which to use to execute code during the saving of a plugin settings page?

If you’re using Settings API, then you should use a sanitize callback: register_setting( $option_group, $option_name, $sanitize_callback ); The myth is that the $sanitize_callback actually is a filter for your options when it’s saved in the database. This is the place where you can do something with your custom code. This is the sample code: register_setting( … Read more