Synchronize custom post type tags with WordPress default post type tags

register_taxonomy_for_object_type() will do what you want as long as the taxonomy and object (post_type) are already registered elsewhere. Very useful when dealing with a plugin’s CPTs you need to add a taxonomy to. add_action( ‘init’, ‘add_tag_tax_to_posts’); function add_tag_tax_to_posts(){ register_taxonomy_for_object_type( ‘SLUG_OF_PLUGIN_TAG_TAX_HERE’, ‘post’ ); } Or to do the reverse, and add the default tags (post_tag) to … Read more

How do I add a javascript file to all admin pages via a plugin?

The Plugin Developer Handbook recommends using plugins_url() to create the URL to the JS file. Try using that function inside your script loader, and using a different handle for the script depending on the context (like prefixing the admin script name with “admin-“) to avoid conflicting script registration. Alternatively, you can register the script just … Read more

How do you output enqueued scripts to an admin page?

To display registered scripts information in posts/pages, we’ll use a shortcode. For admin registered scripts, we’ll use admin_footer action hook. Put this code into your plugin: if(!is_admin) { function fpwScripts($atts) { global $wp_scripts; $out=”<h2>Registered Scripts</h2>”; foreach($wp_scripts->registered as $key => $value) { $out .= “<h3>{$value->handle}</h3>”; $out .= “source = {$value->src}<br>”; $out .= “dependencies = array(<br>”; foreach($value->deps … Read more

how to use preg_replace for wordpress video?

So you’re using the default WordPress video shortcode in the editor, right? If so, there’s no need to filter the whole content, especially that markup for the video would be already rendered and is quite complicated: <div style=”width: 960px;” class=”wp-video”><!–[if lt IE 9]> <script>document.createElement(‘video’);</script><![endif]–> <video class=”wp-video-shortcode” id=”video-160186-1″ width=”960″ height=”600″ preload=”metadata” controls=”controls”> <source type=”video/mp4″ src=”https://wordpress.stackexchange.com/questions/300917/YOUR_VIDEO_URL” /> … Read more