Here’s a foundation for writing a WordPress plugin, based on version 3.2. This would go in the main my-plugin-name.php file. Continue reading
-
Recent Posts
Recent Comments
Archives
Categories
Meta
Here’s a foundation for writing a WordPress plugin, based on version 3.2. This would go in the main my-plugin-name.php file. Continue reading
If you want to display the shortcode literally in a post (like so: [shortcode]), just use double brackets like this: “[[shortcode]]”. You can also use the html entities [ for “[" and ] for "]” (which you’ll need to use if your shortcode doesn’t exist and therefore doesn’t run through the parser).
One of the biggest pains about developing on a local server setup like WAMP is that the root filepaths are different when you go live. To get around this I always set up a virtual host so that my development url can be something like, http://myapplication.localhost/. It’s really easy to set up. Continue reading
Use temporary tables when your sql queries are starting to do gymnastics. The following would go in your model:
(function(){
var functionName = function(){
this.init();
};
functionName.prototype = {
init : function() {
this.setFunction();
},
setFunction : function() {
// do stuff here
}
};
new functionName();
})();
Here’s a handy little snippet to automatically put the cursor in the first input field on the page. You can override it by adding a class of “nofocus” to any element and/or list the elements in the array. Nice for login pages.
if( !$(':input:visible:enabled:first').hasClass('nofocus') &&
$.inArray( $(':input:visible:enabled:first').attr('id'),
['element_to_exclude', 'another_element_to_exclude']
) == -1
){
$(':input:visible:enabled:first').focus();
}
Here’s a little snippet for generating an excerpt without breaking up a word:
function excerpt($string='', $maxChar=50, $uri='#') {
$length = strlen($string);
if ($length < $maxChar) {
return $string;
}
$trimmedString = substr($string, 0, $maxChar);
$choppedString = substr($trimmedString, 0, strrpos($trimmedString, strrchr($trimmedString, ' ')));
$newString = $choppedString . ' <a href="' . $uri . '">more</a>';
return $newString;
}