Dynamically adding filters

I think you are on the right track, but that last part is messy. You are using the bw_add_markup_class function for two different purposes : to return the classes that you want to add to list the context of the filters that you want to call If I understand well want you are trying to … Read more

Use has_filter on comment_post

You’re adding the action on comment_form_before_fields in comment_form_logged_in_after. The latter is called only when the user is logged in, and the former is only called when the user is not logged in. You can add WordPress actions and filters at any time after WordPress is initialized. If you’re adding the action in a plugin, add … Read more

save_post not triggered when a post is updated

A var_dump() in save_post action doesn’t display any information on the screen. Well, it does only when you are on “Add new” screen. This is due the different sequence of actions that follow when creating a new post or when editing it. When you click on “publish” or “update” button, there is a request, the … Read more

add_action not working within widget() of WP_Wdiget

Not really following how the functions relate to each other and where (so what variables are available, how), but you might try something like: add_action(‘before_test_action’, array($this, ‘widget_test_func’)); public function widget_test_func( $instance) { $boolean = (isset($instance[‘boolean’])) ? $instance[‘boolean’] : ”; if ($boolean == ‘on’) { echo ‘within widget test func’; } }

Admin: how to make a custom list filter button send GET queryvars

Thanks to @cybmeta I was able to solve my issue. Below I post all the relevant code. Keep in mind it refers to a ‘distributor’ custom post type that uses 4 custom taxonomies (‘italy’,’france’,’spain’,’world’). // add columns function add_distributor_columns($table_columns){ $area_column = array(‘area’ => ‘Area’); $macroarea_column = array(‘macroarea’ => ‘Macroarea’); // put them on the right … Read more

Insert Content Before div#main from the functions.php File

The markup surrounding the content is not specified by WordPress, so there is no hook for that. But you can declare your own hook there. In your template file, write … <?php do_action( ‘before_content_container’ ); ?> <div class=”main”> <?php the_content(); ?> </div> <?php do_action( ‘after_content_container’ ); ?> … and then you can register a callback … Read more

Include HTML (Bootstrap Modal Box) with a plugin into my header

You only need the_content filter to add the modal, but bootstrap.js is needed to make it work. add_action(‘wp_enqueue_scripts’, array($this, ‘enqueue_bootstrap’); public function enqueue_bootstrap(){ wp_register_script( ‘bootstrap’, plugins_url( ‘your-plugin/assets/js/bootstrap.min.js’ ) ); wp_enqueue_script( ‘bootstrap’ ); } EDIT: You need to add $content argument to your function. As the codex says Note that the filter function must return the … Read more