Submitted By: Adam J Nowak

Code Snippet NameSort by Category CategorySort by Category Submitted BySort by Person   Date

Better Truncator

Actionscript 02/20/12
I was having trouble with my limit string snippet http://code.hyperspatial.com/143/shorten-string-in-php/

It
was not working well with long strings with no spaces, like urls. This php snippet will truncate a long url. So if you want to shorten a url for display use this. View Code

Tags

Better mysqli table creation

PHP 02/20/12
This is the latest of the php table creation scripts. This is a suggested technique on php.net for the oop mysqli classes.

Replace the DB constants with your own values. View Code

Tags ,

Action type callbacks

PHP 02/20/12
I don't even want to start rebuilding the Wordpress hook system, but I needed something similar for a straight PHP site.

This html insert system allows you to fire callback functions in a similar manner to do_action(). The system is not set up to pass arguments at this point.

Just make sure ... View Code

Input action on enter

Javascript 02/17/12
This javascript snippet allows you to run javascript or just submit the form on the enter keypress. View Code

Tags

Improved Shortcode

Wordpress 02/15/12
This in an improved version of http://code.hyperspatial.com/1105/function-as-shortcode/ which allows you to use one function for shortcode callbacks. So instead of writing two functions, one for shortcode (must return printed output) and one to call directly, try this output buffer ... View Code

Tags

SSL check

PHP 02/14/12
This is a quick php snippet to check it the page you are on is secured with an ssl. It basically checks the php server superglobal for https View Code

Tags

BP profile data

Buddypress 02/13/12
These are two functions you can use to get Buddypress xprofile data and change said data. View Code

Tags

WP plugin path constants

Wordpress 02/09/12
These constants allow you to automatically access the server path and the plugin url for your wordpress plugins. Despite the directory name. View Code

Tags ,

Box sizing

CSS 02/01/12
This is a css box sizing trick View Code

Tags

Page Window

Wordpress 02/01/12
This wordpress class allows you to easily run custom loops on your front page in order to add multiple windows, each with the content from a wordpress page.

Just instantiate the class for each window by passing the page id you want. Then display the title, content or excerpt at will. View Code

Roman Conversion

PHP 01/27/12
This script loads a text file and converts each line from roman numerals to arabic numbers. View Code

Parse Hyperlink

PHP 01/27/12
This php regex quickly allows you to parse a hyperlink and add a qualified domain and target blank to the <a> elements View Code

Tags

Get Gravatar

Wordpress 01/05/12
Use this php function to get a Gravatar image. Gravitars are globally recognized avatars. View Code

Sortable Columns

Wordpress 12/19/11
This Wordpress snippet allows you to add sortable columns to your custom post type list on the WP dashboard. Replace bz_league with the name of your custom post type, especially in the actions and filters. View Code

Tags

List directories

PHP 12/16/11
Use this php snippet to list directories in a parent directory. View Code

Update option hook

Wordpress 12/14/11
I always forget about this Wordpress action, so collectifying it. This action fires when the option 'blogdescription' is changed. In this case I am updating the option 'my_copied_description' to mirror the main one. This is handy for custom admin pages where you are changing a global option. View Code

Tags ,