[Plugin: WordPress Wiki] Code tweak for linking to non-yet-written pages
-
Did a small mod so that pages that have yet to be written get linked in a way that is visually different from normal wiki links (Like the red links used in Wikipedia).
For pages that don’t exist they now are linked with a [+] trailing the “hot” word. Example can be seen on this page here.
To implement, just edit the plugin and change the wiki_callback_func function by replacing it with this below I only the if/else right down the bottom.
/**
* Call back function for regex
* @param <type> $m
* @return <type> link
*/
function wiki_callback_func($m) {
global $post;$splited = explode(“|”, $m[2]);
if (count($splited) == 2) {
$link_text = trim($splited[1]);
$link_slug = trim($splited[0]);
} else {
$link_slug = $link_text = $m[2];
}$link = get_permalink_by_title($link_slug);
if (!$link) {
// If there is no post with that titleif ($post->post_type == “page”) {
$link = get_bloginfo(“wpurl”) . “/wp-admin/page-new.php” ;
} else {
$link = get_bloginfo(“wpurl”) . “/wp-admin/post-new.php” ;
}return $link_text . ‘<small>[+]</small>‘; // link to create a page or post
} else {return ‘‘ . $link_text . ‘‘; // normal wiki link
}}
- The topic ‘[Plugin: WordPress Wiki] Code tweak for linking to non-yet-written pages’ is closed to new replies.