I did a shortcode based on MediaWiki links and an old plugin for my own needs and I think it may be useful to share; and since this plugin is already similar and to not create another plugin for the same I suggest an additional alternative approach, between the same shortcode:
function internal_link($atts, $content = null) {
extract(shortcode_atts(array(
"name" => ''
), $atts));
if ( empty($name)) {
if ($page = get_page_by_title(html_entity_decode($content,ENT_QUOTES)) && get_the_title() == $content) {
return '<strong>'.$content.'</strong>';
} elseif ($page = get_page_by_title(html_entity_decode($content,ENT_QUOTES))) {
return '<a>ID).'">'.do_shortcode($content).'</a>';
} else {
if ( is_user_logged_in() ) {
return '<a href="'.get_option('siteurl').'/wp-admin/page-new.php?post_title='.urlencode($content).'" title="Not">'.do_shortcode($content).'</a>';
} else {
return do_shortcode($content);
}
}
} elseif ( !empty($name)) {
if ($page = get_page_by_title(html_entity_decode($name,ENT_QUOTES)) && get_the_title() == $name) {
return '<strong>'.$content.'</strong>';
} elseif ($page = get_page_by_title(html_entity_decode($name,ENT_QUOTES))) {
return '<a>ID).'">'.do_shortcode($content).'</a>';
} else {
if ( is_user_logged_in() ) {
return '<a href="'.get_option('siteurl').'/wp-admin/page-new.php?post_title='.urlencode($name).'" title="Not">'.do_shortcode($content).'</a>';
} else {
return do_shortcode($content);
}
}
}
}add_shortcode("link", "internal_link");
The attributes names and specific code are referential, but the main features are that it allows to link a page based on the content of the markup link, regardless if is written as a slug or not because a function "sanitizes" it. If one don't want to use the content as the link, can add the page name in the same way to an attribute. And, to maintain a wiki feel, if the page don't exist it shows a link with a different CSS class that links to the edit page to create an article with that name (note that the code for it change sightly for WP 3.0). The link don't show if an user if not logged.
It should be noted that this implementation is dependent of what custom type is called (pages by default), so an attribute should be added for that. And perhaps another if one want to link to taxonomies or users.
The default of these features should be managed by an UI.