Making menu link open in new tab?

You can do that with jQuery. We can open this link in new tab/window by adding target=”_blank” attribute dynamically on link which has URL https://www.example.com. Here is the example function for that. function wpse_my_custom_script() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $( “ul#adminmenu a[href$=’https://www.example.com’]” ).attr( ‘target’, ‘_blank’ ); }); </script> <?php } add_action( ‘admin_head’, ‘wpse_my_custom_script’ … Read more

Trying to count the total number of paragraphs inside a blog article

I’m pretty sure that is_singular() is going to return false when you are inside the WP loop, since there are more than one posts being looped through. Try is_single() or just look at the post object and examine the post_type attribute. add_filter( ‘the_content’, ‘_some_func’, 15 ); function _some_func( $content ) { if( __check_paragraph_count_blog( $content ) … Read more

How to enqueue a theme style-sheet to my admin settings page?

The admin_enqueue_scripts hook has a $hook_suffix parameter for the current admin page. This parameter will return something like toplevel_page_yourpagename where the toplevel_page will be your page level and yourpagename is what you find on the ?page=yourpagename url. Use that to check if the current page is your plugin’s settings page and then load the scripts. … Read more