Am I using the right hook for removing quicktags on the admin TinyMCE?

After checking out the code, the best way to do this would be to use the wp_editor_settings filter in /wp-includes/class-wp-editor.php. When you call wp_editor() it internally makes a call to _WP_Editors::editor($content, $editor_id, $settings);. This function first passes the $settings array through parse_settings() which uses that filter. add_filter( ‘wp_editor_settings’, ‘remove_editor_quicktags’, 10, 2 ); function remove_editor_quicktags( $settings, … Read more

add class to internal links in content

i didn’t want to use js, i wanted a php solution, plus i also manipulate all internal links into anchor links. in the end, you have to decide for yourself, what would be the best way for you, php or js. this goes into functions.php inside the current theme folder. add_filter(‘the_content’, ‘crawl_content’); function crawl_content( $text … Read more

WordPress 3.5+ upload tool filter

The library parameter is actually responsible of what you see in the library frame and not what you can upload. It accepts : image,audio,video,file or any other mime type for example to show only pdf’s : library: { type: ‘application/pdf’ }, Now to actually limit the upload to a file type you need to add … Read more

How to exclude/filter a tag from get_the_tag_list()

function mytheme_filter_tags( $term_links ) { $result = array(); $exclude_tags = array( ‘some tag’, ‘another tag’, ‘third tag’ ); foreach ( $term_links as $link ) { foreach ( $exclude_tags as $tag ) { if ( stripos( $link, $tag ) !== false ) continue 2; } $result[] = $link; } return $result; } add_filter( “term_links-post_tag”, ‘mytheme_filter_tags’, 100, … Read more

Using hooks to place content in theme dynamically

If you’re the parent theme Developer, you can add the hook in your parent themes file and then use it in a custom function in your child theme. 1. Add Hook To Parent Themes File <?php do_action( ‘after_wp_footer’ ); ?> 2. Create Function For New Hook in Parent Theme function create_after_footer_hook() { do_action(‘after_wp_footer’); } 3. … Read more

Change default settings used by gallery shortcode

The shortcode_atts_{$shortcode} filter allows default parameters to be modified for shortcodes. To modify the shortcode, we’ll use the shortcode_atts_gallery filter. Here is an example that changes the defaults for the columns and link parameters in the shortcode. Note that if the user specifies values for these parameters, those values will be used; we’re just changing … Read more