Plugin default settings hook

I’d use a filter. You can remove this: if (function_exists(‘bf_new_defaults’)) { return bf_new_defaults( $default_settings ); } else { return $default_settings; } and replace it with something like this: return apply_filters(‘bf_filter’, $default_settings) The following is a truncated, proof of concept version of the code so you can see how $default_settings gets altered. add_filter( ‘bf_filter’, function($default_settings) { … Read more

Making an add_filter() call from within an add_filter() call

You can add or remove hooks from inside other hooks if you get the timing right but I don’t understand why you are making this so complex. function set_title($title) { global $wp_query,$post,$address; $address = $wp_query->query_vars[‘address’]; if ($address) { return $address; } } add_filter(‘wp_title’, ‘set_title’); If you need the share the value, use a static variable: … Read more

What hook can I use to modify custom post data before it is displayed on the page?

You can use the_content filter to modify content before it’s output. function my_the_content_filter( $content ) { // maybe limit to archive or single cpt display? if( is_post_type_archive( ‘your-cpt’ ) || is_singular( ‘your-cpt’ ) ){ global $post; $meta = get_post_meta( $post->ID, ‘some-key’, true ); if( false === $meta ){ return $content . ‘some extra content’; } … Read more

What is the action or filter for adding information under the Permalink in Edit Post/Page?

You can try the edit_form_after_title action: add_action( ‘edit_form_after_title’, function(){ echo ‘<hr/><div>My custom HTML</div><hr/>’; }); to add your custom HTML after the permalink: It will inject the HTML between div#titlediv and div#postdivrich: <div id=”post-body-content”> <div id=”titlediv”>…<!– /titlediv –> <hr><div>My custom HTML</div><hr> <div id=”postdivrich” class=”postarea edit-form-section”>…</div> … </div> Tip: when you have question like this, best thing … Read more

How to use add_action for multiple instances of the same class

When you call add_meta_box() you must provide a unique ID as the first parameter. Consider this case: add_meta_box( ‘foobox’, ‘Foo Title’, ‘foo_callback’ ); add_meta_box( ‘foobox’, ‘Bar Title’, ‘bar_callback’ ); You will just get the Bar Title metabox now, because it will overwrite the first one. What you need is a new ID for each box: … Read more

Adding custom Bulk Actions

Unfortunately it’s still not really doable in a clean way. You can see the latest about this here in this trac ticket #16031 I just checked the source and the filter is still basically the same.