Take a look at this post for a list of useful “hidden” configuration settings for your WordPress installation.
I found some nice tricks that I’ve applied to my wp-config.php:
// Number of post revision to keep
define('WP_POST_REVISIONS', 3);
// Installation path and template path to reduce database queries
define('WP_HOME', 'http://your_site_url.com');
define('WP_SITEURL', 'http://your_wordpress_directory_url.com');
define('TEMPLATEPATH', '/absolute/path/to/wp-content/themes/active-theme');
define('STYLESHEETPATH', '/absolute/path/to/wp-content/themes/active-theme');
// Security keys to improve cookies encription
define('AUTH_KEY', 'randomKey');
define('SECURE_AUTH_KEY', 'randomKey');
define('LOGGED_IN_KEY', 'randomKey');
define('NONCE_KEY', 'randomKey');
via Digging Into Wordpress.
Tags: WordPress -
This is a simple tip that can help you reduce your style sheet size. Take a look at this CSS portion:
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 1.1em;
font-weight: bold;
font-style: italic;
line-height: 1.5em;
font-variant: uppercase;
All these properties can be condensed into a one row expression using this syntax:
font: fontSize/lineHeight weight style variant family;
See the example below:
font: 1.1em/1.5em bold italic uppercase Arial,Verdana,Helvetica,sans-serif;
Just remember that this syntax will only function if you specify both font-size and font-family.
Tags: CSS, font, style -
A useful XSL template for removing leading zeros
<xsl:template name="removeLeadingZeros">
<xsl:param name="originalString"/>
<xsl:choose>
<xsl:when test="starts-with($originalString,'0')">
<xsl:call-template name="removeLeadingZeros">
<xsl:with-param name="originalString">
<xsl:value-of select="substring-after($originalString,'0' )"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$originalString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Just insert it into your XSL file and use it as usual:
<xsl:call-template name="removeLeadingZeros">
<xsl:with-param name="originalString" select="$myOriginalString"/>
</xsl:call-template>
Tags: XML, XSL, XSL template -
A simple bash script that zips a folder and sets the archive name to the current date.
#!/bin/bash
# Archive name structure: ddMMYYYY_HHmmss.zip
archiveName=`date +%d%m%Y_%H%M%S`.zip
folderName=MyFolder
zip -r $archiveName $folderName
Tags: backup, bash, Linux, script, zip -
A really good tutorial on building custom taxonomies in WordPress 2.8.
Custom taxonomies in WordPress 2.8
Tags: taxonomy, tutorial, WordPress -
Dougal Campbell wrote some interesting notes on permalinks structure and best practices in Wordpress. Worth reading:
Efficient permalink strategies for WordPress – Dougal Campbell’s geek ramblings.
Tags: permalinks, WordPress -
This simple method shows hot to write to text files using Java.
If the file exists it will append the new text to it, otherwise it creates a new file. This is achieved using the FileWriter class and its constructor:
public FileWriter(String fileName, boolean append) throws IOException
Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. JavaDoc.
public void writeToFile(String text, String filePath){
try {
File thisFile = new File(filePath);
BufferedWriter writer = new BufferedWriter(
new FileWriter(filePath, thisFile.exists()));
writer.write( text );
writer.newLine();
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Tags: file, FileWriter, Java, Text -