How do you get specific tags from the_content?

Using preg_match_all() you can create a regex pattern to find and extract tags (and their content). With WordPress’s post_content hook, you can find and list all the H1’s within current posts content with something like: add_action(‘the_content’, function ($content){ // look for <h1> tags and text therein, anticipate class/id name $findH1s = preg_match_all(‘/<h1 ?.*>(.*)<\/h1>/i’, $content, $h1s); … Read more

Replacing a deprecated filter ‘woocommerce_get_price’ with ‘woocommerce_product_get_price’

It’s hard to find because the hook name is generated dynamically. All the get_ functions in the WooCommerce product class, like $product->get_price(), use the get_prop() method under the hood. This is part of the WC_Data class that WC_Product extends. At the end of get_prop() the filters are applied like this: apply_filters( $this->get_hook_prefix() . $key, $value, … Read more

Override has_post_thumbnail function

Yes, there is a way to do that… Let’s take a look at has_post_thumbnail function itself: function has_post_thumbnail( $post = null ) { return (bool) get_post_thumbnail_id( $post ); } As you can see, all it really does is getting post thumbnail ID and checking if it exists. But there are no filters in here. Let’s … Read more

How can I output all apply_filters and do_action?

apply_filters and do_action are NOT stored in $wp_filter, ONLY add_filter and add_action are stored in $wp_filter When you call apply_filters or do_action, core WordPress loops through all of the registered filters or actions (added by add_filter and add_action), looking for any matching ones, and then executes the associated function. The only difference being actions which … Read more

Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?

This filter only accepts strings for mime types. It also already has support for webm, mp4, mpeg, ogv, and ogg. I think you can remove everything except the line for SVGs. A word of warning, WordPress doesn’t support SVG upload by default because it’s a security concern. Be careful about enabling this. At the least, … Read more

Gutenberg Block – Post Featured Image Filter Hook

From the documentation: Prepend and append to the panel contents: var el = wp.element.createElement; function wrapPostFeaturedImage( OriginalComponent ) { return function( props ) { return ( el( wp.element.Fragment, {}, ‘Prepend above’, el( OriginalComponent, props ), ‘Append below’ ) ); } } wp.hooks.addFilter( ‘editor.PostFeaturedImage’, ‘my-plugin/wrap-post-featured-image’, wrapPostFeaturedImage ); So did you intentionally not using wp.element.Fragment? You may … Read more

Add a div of content within the_content after a certain block

Yes, add_filter() is what you’re looking for, but to identify a specific block, you want the render_block hook. <?php add_filter(‘render_block’, function($block_content, $block) { // Only for Core Code blocks if(‘core/code’ === $block[‘blockName’]) { // Add your custom HTML after the block $block_content = $block_content . ‘<div>Test addition</div>’; } // Always return the content return $block_content; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)