How to check if a hook is hooked or not?

Sure, that’s called has_action, which is an alias of has_filter. Usage: if ( has_action(‘hook_name’) ) { throw new \Exception(‘You cannot hook to a protected action.’); } else { do_action(‘hook_name’); } These two functions access the global array $wp_filter that stores all of the filters / actions

How to hook into unregistering a widget instance?

Yes, this can be done. Ultimately, adding and removing a widget to/from a sidebar means updating an option in the database with a call like this: update_option( ‘sidebars_widgets’, array( … ) ) If you look at the code of update_option you see that there is a filter called just before the actual update. So if … Read more

Is there a way to add another row to the tinyMCE kitchen sink toggle?

Yes! Use the mce_buttons_2 filter to add buttons to the second row. Use the mce_buttons_3 filter to add buttons to the third row. Here’s an example of what I use: function mytheme_mce_buttons_row_3($buttons) { $buttons[] = ‘fontselect’; $buttons[] = ‘fontsizeselect’; $buttons[] = ‘code’; $buttons[] = ‘sup’; $buttons[] = ‘sub’; $buttons[] = ‘backcolor’; $buttons[] = ‘separator’; $buttons[] … Read more

Modify links when inserted by WYSIWYG editor

The HTML for the inserted internal links are generated by Javascript, so I’m not aware of any easy way to change it. The HTML generation is controlled from the wpLink.htmlUpdate method (HTML mode) and the wpLink.mceUpdate method (TinyMCE mode), in the /wp-includes/js/wplink.js file. Here are some ideas: Add a query parameter to the inserted links: … Read more

Insert Custom HTML After Shortcode

I wonder if you could override the [rev_slider] with this kind of wrapper: add_shortcode( ‘rev_slider’, function( $atts = array(), $content=”” ) { $html=””; // Your custom banner HTML $banner=”<div id=”bannerHTML”><!– banner HTML goes here –></div>”; // Append your banner HTML to the revslider’s output if( function_exists( ‘rev_slider_shortcode’ ) ) $html = rev_slider_shortcode( $atts, $content ) … Read more

Advanced Custom Fields and Yoast SEO keyword analysis [closed]

Looking at the filter: $post_content = apply_filters( ‘wpseo_pre_analysis_post_content’, $post->post_content, $post ); it would be a matter of adding your fields content to string being analyzed. You have to do the get_field() part right, this is untested: add_filter( ‘wpseo_pre_analysis_post_content’, ‘filter_yoasts_wpse_119879’, 10, 2 ); function filter_yoasts_wpse_119879( $content, $post ) { $fields = get_field( ‘name’, $post->ID ); return … Read more

Valid characters for actions, hooks and filters

When you “hook”/add_action/*_filter(‘whatever’); a callback function to do_action(‘whatever’);, then you basically add the function (or object-method) name to the global $wp_filters-array. Doing so, you add the function/method name to an array that is built like the following $wp_filter[ $tag ][ $priority ][ $idx ] // $tag = action/filter name // $priority = 3rd argument / … Read more