|
|
Fixing a broken dashboard in Wordpress 2.5 |
| by Neil Middleton 10:20 pm Thursday, 10 April 2008. |
Since upgrading to Wordpress 2.5 last week (which, incidentally, is excellent), my administrator dashboard has been somewhat broken returning the error:
Fatal error: Unsupported operand types in /path/to/blog/wp-admin/index.php(101) : runtime-created function on line 1
Well, I’ve been looking at this tonight and sussed the problem. Let’s take a look at line 101 (ignore the word wrap):
$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev,
$curr', 'return $prev+count($curr);' ) );
Now, from what I can tell, this line is figuring out how many widgets to show, and thus figure out the HTML etc required to do so. However, in PHP, array_reduce() will return NULL if nowt is found, and an initial value argument is not passed in. Passing in an initial value fixes this (0 being that default):
$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev,
$curr', 'return $prev+count($curr);' ), 0 );
Stick that in your code, and all should be running smoothly.
Comments (0)|
|
ColdFusion Code highlighting with GeSHI |
| by Neil Middleton 11:24 pm Monday, 21 January 2008. |
If like me, you are a ColdFusion developer using Wordpress as their blogging engine, you might have a need to occaisionally put code samples into your blog posts. With tools like Ray Camden’s BlogCFC and ASFusion’s Mango, this is very easy as they have been designed to do this from the start. However, in Wordpress you need to do some fiddling first.
Ultimately there are a few code highlighters out there that you can use, and I have chosen to use CodeViewer, which lets me upload files of code that then get converted into a nice highlighted form. From here I have a variety of options of things like allowing you guys to download that code in it’s raw form. The highlighting is done via another plugin called GeSHI, the Generic Syntax Highlighter. This is a long term open source project designed to create a PHP based syntax highlighter that can be used from a number of other applications (such as Wordpress) and supports a vast range of languages such as AS3, T-SQL, ColdFusion and others.
However, after saying all this, the currently bundled CFML parser does not contain any of the new CF8 syntax, and has only a limited number of attributes listed. Therefore, I have sat down and updated the language file to include all CF8 tags, functions and attributes, which means that should you be using GeSHI, you should have no real problems with any of the new CF8 syntax.
To download the file, click here. I have also sent off the file to the GeSHI admins in the hope that they can include it in a future release. If you can see any problems, and need some help, please don’t hesitate to contact me.
Download CF8 GeSHI Language File
Comments (0)|
|
Blog fixed! |
| by Niklas Richardson 11:51 am Thursday, 5 May 2005. |
So the blog broke when we moved server!
But now it’s back, so be prepared for Prismix posts again!
Comments (0)|
|
Blog Comment Security Code Implemented |
| by Niklas Richardson 2:00 pm Thursday, 3 March 2005. |
So I’ve just implemented the SCODE anti-comment-spam plugin for MovableType.
To get the correct libraries, use the ppm install app which comes with ActivePerl and the following commands:
ppm> rep add UWinnipeg http://theoryx5.uwinnipeg.ca/ppms/ ppm> search GD ppm> install GD
You can skip the search GD command, but it’s good to check that it’s found.
Then follow the rest of the installation notes that come with SCODE.
I also found this blog entry useful, however a bit cryptic!!
Enjoy!
Comments (0)|
|
MTCodeBeautifier and MovableType |
| by Niklas Richardson 4:23 pm Monday, 23 August 2004. |
I didn’t realise that setting up MTCodeBeautifier would be SO hard. Well, in fact it was! It was a flipping nightmare! In any case, I now have it working, and we can now output lovely ColdFusion code:
<cfscript> myvar = "Hello World!"; </cfscript>
These are the steps that I took:
I installed the following:
The installation of these is straight forward and if you follow the instructions on the MTCodeBeautifier website for using MTMacro instead of Textile 2 then I’ve found it works a treat. You also need to add the following CSS to your stylesheet for it to look nice.
.linecomment { color: #FF8000; }
.blockcomment { color: #FF8000; }
.prepro { color: #0000BB; }
.select {}
.quote { color: #DD0000; }
.category1 { color: #007700; }
.category2 { color: #0000BB; }
.category3 { color: #0000BB; }
/* To make Word-wrap work */
pre
{
border: 1px solid #888;
background: #FFF;
padding: 5px;
overflow: auto;
width: 95%;
max-height: 450px;
margin: 0px auto;
}
I then just wrap the following around my code snippets to get code colouring:
<code language="coldfusion"> <cfscript> myvar = "Hello World!"; </cfscript> </code>
It also supports other language colouring like ActionScript, PHP and Perl.
However, be sure to turn off “Text Formatting” when you create your posts otherwise it will look REALLY ugly, and make sure you format your own posts using HTML.
Comments (0)