Some customisations for the Wiki plugin

At the moment, the wiki plugin makes things look very wiki'ish. Would be great to have some more control over things like the tabs so we can create a wiki featured site, without the wiki-styling and nomenclature.

For one example, see my tweak here to remove the "discussion" tab and display the comments beneath the article (like a standard blog post).

Would be great to have a show/hide tab setting and then some code we can insert into the template to link to the various features instead (e.g. Edit post).

  • Carl

    Thanks for the support Vaughan. I've been playing with this a little more and have some further thoughts:

    * Show/hide various tabs in the admin settings page.

    * Add a template type function to $wiki->showComments(); so we can display the comments wherever we want in our template.

    * Put the various links into an array variable of the $wiki class. You can use something like this code and run it when the Wiki class is initialised. It will populate an array with the available wiki links and is based on the existing $wiki->tabs(); function:

     * Replacement for the $wiki->tabs() function used by the wiki plugin.
     * This function is similar except that it returns an array of tabs rather
     * than formatted HTML code. The idea is that this array can then be split
     * and styled however you like in the template.
     * @uses $post, $incsub_tab_check, $wp_query, $wiki;
     * @return array
    function tabsarray() {
    	global $post, $incsub_tab_check, $wp_query, $wiki;
    	$incsub_tab_check = 1;
    	$classes['page'] = array('incsub_wiki_link_page');
    	$classes['discussion'] = array('incsub_wiki_link_discussion');
    	$classes['history'] = array('incsub_wiki_link_history');
    	$classes['edit'] = array('incsub_wiki_link_edit');
    	$classes['advanced_edit'] = array('incsub_wiki_link_advanced_edit');
    	$classes['create'] = array('incsub_wiki_link_create');
      // Set the tab to "current" based on the "action" parameter in the querystring
    	if (!isset($_REQUEST['action'])) {
    		$classes['page'][] = 'current';
    	if (isset($_REQUEST['action'])) {
    		switch ($_REQUEST['action']) {
    			case 'page':
    				$classes['page'][] = 'current';
    			case 'discussion':
    				$classes['discussion'][] = 'current';
    			case 'restore':
    			case 'diff':
    			case 'history':
    				$classes['history'][] = 'current';
    			case 'edit':
    				if (isset($_REQUEST['eaction']) && $_REQUEST['eaction'] == 'create')
    				$classes['create'][] = 'current';
    				$classes['edit'][] = 'current';
    	$seperator = (preg_match('/\?/i', get_permalink()) > 0)? '&' : '?';
    	$post_type_object = get_post_type_object( get_query_var('post_type') );
      // Set elements of the tabs array
    	$tabs['page']['classes']  = join( ' ', $classes['page'] );
    	$tabs['page']['url']      = get_permalink();
    	$tabs['page']['text']     = __('Page', $wiki->translation_domain);
    	if (comments_open()) {
      	$tabs['discussion']['classes']  = join( ' ', $classes['discussion'] );
      	$tabs['discussion']['url']      = get_permalink().$seperator.'action=discussion';
      	$tabs['discussion']['text']     = __('Discussion', $wiki->translation_domain);
    	$tabs['history']['classes']  = join( ' ', $classes['history'] );
    	$tabs['history']['url']      = get_permalink().$seperator.'action=history';
    	$tabs['history']['text']     = __('History', $wiki->translation_domain);
    	$tabs['history']['classes']  = join( ' ', $classes['history'] );
    	$tabs['history']['url']      = get_permalink().$seperator.'action=history';
    	$tabs['history']['text']     = __('History', $wiki->translation_domain);
    	if ($post && current_user_can($post_type_object->cap->edit_post, $post->ID)) {
      	$tabs['edit']['classes']  = join( ' ', $classes['edit'] );
      	$tabs['edit']['url']      = get_permalink().$seperator.'action=edit';
      	$tabs['edit']['text']     = __('Edit', $wiki->translation_domain);
        if (is_user_logged_in()) {
        	$tabs['advanced']['classes']  = join( ' ', $classes['advanced_edit'] );
        	$tabs['advanced']['url']      = get_edit_post_link();
        	$tabs['advanced']['text']     = __('Advanced', $wiki->translation_domain);
      	$tabs['create']['classes']  = join( ' ', $classes['create'] );
      	$tabs['create']['url']      = get_permalink().$seperator.'action=edit&eaction=create';
      	$tabs['create']['text']     = __('Create new', $wiki->translation_domain);
    	$incsub_tab_check = 0;
    	return $tabs;

    Now you can add one more function to get the individual wiki link you require:

     * Provides the HTML code for a specific link based on the
     * wiki plugin features. If the tab doesn't exist (e.g. because
     * of permissions), then nothing is returned.
     * @uses $wiki;
     * @param string $tabname A required string representing the name of the tab to return.
     * @return string HTML code to display post/wiki tabs
    function wikilink( $tabname ) {
      global $wiki;
      if( array_key_exists( $tabname, $wiki->tabs) ) {
        return $wiki->tabs;
      } else {
        return NULL;

    Finally, in the template, you can now specify more exactly where you want each link to appear. For example, if I want to have an "Edit" link at the end of the article, then in my template I could include $wiki->wikilink('edit'); somewhere after the echo $wiki->decider(...); call.

    That should do for now! :slight_smile:


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.