Open link in a new tab checked by default when adding a new link in visual post editor

Add this function in your theme’s functions.php function my_enqueue($hook) { if (‘post.php’ != $hook ) { return; } wp_enqueue_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/myscript.js’); } add_action(‘admin_enqueue_scripts’, ‘my_enqueue’);` In myscript.js place this code jQuery(document).ready(function(){ jQuery(‘#wp-link-target’).prop(“checked”, true); }) It worked for me.

Filter link to existing content suggestion

Currently there are no ready filters available for this purpose. A ticket has been posted for the request.Lets hope we get one soon. Instead of hardcoding your custom post types its better to create a filter hook and use it Till then you can create your own filter. Open includes/class-wp-editor.php and make folowing changes at … Read more

programatically change href to onclick=window.open

Parsing HTML with regular expressions is not ideal. A better alternative is to use DOMDocument and DOMXpath; This code uses DOMDocument and DOMXpath to parse and modify the HTML without relying on regular expressions. Each link in the content will have the onclick attribute added along with the appropriate window.open() code using the URL pulled … Read more

Link Category Description

OK, with the help of a friend I was able to get this done. I ditched the wp_list_bookmarks and went with a combination of get_terms and get_bookmarks. function blogroll_page( $args = array() ) { if(is_page(‘blogroll’)) { if( $terms = get_terms( ‘link_category’, $args = array(‘exclude’ => 16) ) ) { foreach( $terms as $c ) { … Read more

get_site_url is not returning anything?

The functions that start with “get_” return the value to what’s calling it. So you would do <a href=”https://wordpress.stackexchange.com/questions/11893/<?php echo get_site_url(); ?>”> instead to print out the URL.

Retrieving all Links from a Post?

I’ll answer your question below, but have you looked at using embeds? Look here for more information: http://codex.wordpress.org/Embeds The simplest regex for this would look something like http\:\/\/.*\b Here’s an example of it in action: <?php $file=”test.txt”; $fp = fopen($file, ‘r’); $contents = fread($fp, filesize($file)); $matches = array(); preg_match_all(‘/http\:\/\/.*\b/’, $contents, $matches); print_r($matches); ?> Where the … Read more

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