Archive for the ‘Wordpress’ Category

AdSense on WordPress blog

Wednesday, November 12th, 2008

I was looking to add some ads under the right-hand menu and found the following. I’ve since created a file called google.inc in my site’s document root and then added the following near the end of wp-content/themes/default/sidebar.php:

                                </ul>
                                </li>
                        <?php } ?>
 
                        <?php include( ABSPATH . 'google.inc'); ?>
 
                        <?php endif; ?>
                </ul>
        </div>

I’ll need to look into a plugin so that I don’t need to hack this each time I upgrade WordPress versions.

wp-syntax

Saturday, June 14th, 2008

I’ve tried a few WordPress plugins to properly format shell output and the best I’ve found so far is wp-syntax. I simply use lang=”" as using lang=”bash” doesn’t work for me since I use a hash (#) to represent the shell prompt. Anyway, I noticed a problem where using a pipe (|) doesn’t display correctly and looking at the page’s HTML source the pipe seems to get replaced with <PIPE>. Obviously, the browser doesn’t render that and no pipe is displayed. Looking through wp-content/plugins/wp-syntax, I noticed str_replace in geshi/geshi.php that seems to replace | with <PIPE>. I guess it should get replaced again at a later stage but something seems broken. I’ve since changed this code in geshi/geshi.php from:

$result = str_replace(array('<semi>', '<pipe>'), array(';', '~'), $result);
$aTransSpecchar = array(
  '&' => '&amp;',
  '"' => '&quot;',
  '<' => '&lt;',
  '>' => '&gt;',
 
  //This fix is related to SF#1923020, but has to be applied
  //regardless of actually highlighting symbols.
 
  //Circumvent a bug with symbol highlighting
  //This is required as ; would produce undesirable side-effects if it
  //was not to be processed as an entity.
  ';' => '<semi>', // Force ; to be processed as entity
  '~' => '<pipe>' // Force | to be processed as entity
  );                      // ENT_COMPAT set

To:

$result = str_replace(array('<semi>', '<pipe>'), array(';', '~'), $result);
$aTransSpecchar = array(
  '&' => '&amp;',
  '"' => '&quot;',
  '<' => '&lt;',
  '>' => '&gt;'
 
  //This fix is related to SF#1923020, but has to be applied
  //regardless of actually highlighting symbols.
 
  //Circumvent a bug with symbol highlighting
  //This is required as ; would produce undesirable side-effects if it
  //was not to be processed as an entity.
  //';' => '<semi>', // Force ; to be processed as entity
  //'~' => '<pipe>' // Force | to be processed as entity
  );                      // ENT_COMPAT set

This seems to that fix the immediate problem, while probably breaking something else (as per the comments).