Advertisement
Guest User

incsub_wiki-functions.php

a guest
Jun 1st, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.69 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * The wiki plugin replaces certain functions using a filter.
  5.  * This function removes/replaces those filters with the original code.
  6.  *
  7.  * @uses $wiki
  8.  */
  9. function restore_original_functions() {
  10.   global $wiki;
  11.  
  12.   if ( has_filter( 'comments_open', array($wiki, 'comments_open') ) ) {    
  13.     add_filter( 'comments_open', 'comments_open_restored', 15, 1 );
  14.   }
  15.  
  16. }
  17.  
  18.  
  19. /**
  20.  * Restores the original comments_open() which is overridden in the wiki plugin.
  21.  * Function below is the original in Wordpress version 1.5.0 with a change to the last line.
  22.  * Original last line: return apply_filters( 'comments_open', $open, $post_id );
  23.  *
  24.  * @uses $post
  25.  *
  26.  * @param int $post_id An optional post ID to check instead of the current post.
  27.  * @return bool True if the comments are open
  28.  */
  29. function comments_open_restored( $post_id = null ) {
  30.  
  31.   $_post = get_post($post_id);
  32.   $open = ( 'open' == $_post->comment_status );
  33.   return apply_filters( 'comments_open_restored', $open, $post_id );
  34.  
  35. }
  36.  
  37.  
  38. /**
  39.  * Replacement for the $wiki->tabs() function used by the wiki plugin.
  40.  * Takes the tabs value produced by $wiki->tabs() and strips out the
  41.  * 'discussion', 'advanced', and 'create new' items.
  42.  *
  43.  * @uses $post, $incsub_tab_check, $wp_query, $wiki;
  44.  *
  45.  * @return string HTML code to display post/wiki tabs
  46.  */
  47. function tabs() {
  48.   global $post, $incsub_tab_check, $wp_query, $wiki;
  49.  
  50.   $wtabs = $wiki->tabs();
  51.  
  52.   $array = explode('</li>', $wtabs);
  53.  
  54.   unset($array[1]); // discussion tab
  55.   unset($array[4]); // advanced
  56.   unset($array[5]); // create new
  57.  
  58.   $array = array_values($array);
  59.  
  60.   $newtabs = implode('</li>', $array);
  61.  
  62.   return $newtabs;
  63.  
  64. }
  65.  
  66.  
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement