Add function after the_content

The main issue in your code is caused by the call to zss_social_buttons() in your filter function: // In zss_insert_share_buttons(): $social_share_buttons = zss_social_buttons(); // NULL $content .= $social_share_buttons; And the problem there is that zss_social_buttons() is echoing the sharing links/buttons instead of returning them, so they’re not actually added to the $content variable. Instead, they’re … Read more

plugin dev – minimum base css specificity?

There’s no standard. CSS specificity in themes varies wildly, and I’m convinced many theme authors are not even aware of the concept given some of the CSS I’ve seen. If something is very important to the appearance of your plugin, then high specificity may be desirable, but in many cases if you’re just styling divs … Read more

Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all

You’re only registering the shortcode on activation. add_shortcode() is not persistent, and since shortcodes are parsed on output, the shortcode needs to be registered on every request. So you need to move add_shortcode() outside of the activation hook: function install_myplugin() { // … } function uninstall_myplugin() { // … } function myplugin_shortcode_reference() { // … … Read more

flush_rewrite_rules() not working with update_option_{$option}

flush_rewrite_rules() should be called very early within the WordPress initialization. The reason is that the entpoints cannot be changed afterwards. A solution could look like this: function updateMySlugOption($old_value, $value, $option) { if( $old_value != $value ) { set_transient(‘update_slugs’, 1); } } add_action( ‘update_option_mySlug’, ‘updateMySlugOption’, 10, 3); function update_slugs() { if( get_transient(‘update_slugs’) ) { flush_rewrite_rules(); delete_transient(‘update_slugs’); … Read more

WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title

I don’t know if it’s the Gutenberg editor or if it’s the hook publish_post The hook itself works, and if you used the old WordPress post editor, then the issue in question would not happen. So you can say that it’s the Gutenberg/block editor. why it’s not returning the meta and featured image Because Gutenberg … Read more