Advertisement
jrf_nl

Live Blogging plugin bugfix

Mar 8th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. function live_blogging_get_entry($entry)
  2. {
  3.     $style = get_option('liveblogging_style');
  4.     $style = preg_replace(
  5.         '/\$DATE/',
  6.         get_the_time(get_option('liveblogging_date_style'), $entry),
  7.         $style
  8.     );
  9.     // Remove content hooks
  10.     $unhooks = get_option('liveblogging_unhooks');
  11.     if (!empty($unhooks))
  12.     {
  13.         foreach ($unhooks as $unhook)
  14.         {
  15.         $unhook = explode( ',' , $unhook, 2 );
  16.         $unhook = array_map( 'trim', $unhook );
  17.         $count = count( $unhook );
  18.         switch( $count ) {
  19.             case 2:
  20.                 if ( method_exists( $GLOBALS[$unhook[0]], $unhook[1]))
  21.                 {
  22.                     remove_filter('the_content', array($GLOBALS[$unhook[0]], $unhook[1]));
  23.                 }
  24.                 break;
  25.  
  26.             case 1:
  27.             default:
  28.                 if ( function_exists($unhook[0]))
  29.                 {
  30.                     remove_filter('the_content', $unhook[0]);
  31.                 }
  32.                 break;
  33.         }
  34.         }
  35.     }
  36.     $style = preg_replace(
  37.         '/\$CONTENT/',
  38.         apply_filters('the_content', $entry->post_content),
  39.         $style);
  40.     // Add content back in hooks
  41.     if (!empty($unhooks))
  42.     {
  43.         foreach ($unhooks as $unhook)
  44.         {
  45.         $unhook = explode( ',' , $unhook, 2 );
  46.         $unhook = array_map( 'trim', $unhook );
  47.         $count = count( $unhook );
  48.         switch( $count ) {
  49.             case 2:
  50.                 if ( method_exists( $GLOBALS[$unhook[0]], $unhook[1]))
  51.                 {
  52.                     add_filter('the_content', array($GLOBALS[$unhook[0]], $unhook[1]));
  53.                 }
  54.                 break;
  55.  
  56.             case 1:
  57.             default:
  58.                 if ( function_exists($unhook[0]))
  59.                 {
  60.                     add_filter('the_content', $unhook[0]);
  61.                 }
  62.                 break;
  63.         }
  64.     }
  65.     }
  66.     $user = get_userdata($entry->post_author);
  67.     $style = preg_replace(
  68.         '/\$AUTHOR/',
  69.         apply_filters('the_author', $user->display_name),
  70.         $style
  71.     );
  72.     return $style;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement