Web Site Design Blog

Tag: Programming
June 4, 2012

I recently added the Facebook comments and Addthis plugins to my site. One of the issues that occurred was a duplicate ‘Like’ button when the comments plugin loaded. After a quick look at the comments plugin code, I saw that the Facebook javascript SDK was being loaded in the footer.

add_action('wp_footer', 'fbmlsetup', 100);

My first instinct was to move this to the ‘wp_head’ hook, then I realized that wouldn’t be good because it would place the <div> and script inside the <head> element of the page. My experience told me this code is supposed to live right after the <body> tag. Apparently there is no such hook built into WordPress, but to create one in your theme is simple and painless.

In your theme’s functions.php add the following function named ‘after_body’:

function after_body(){
	do_action('after_body');
}

In your theme’s header.php call the ‘after_body’ function right after the <body> tag:

<body>
<?php after_body(); ?>

Now just a little hack to the plugin code, I commented out the ‘wp_footer’ hook and replaced it with the ‘after_body’ hook.

// moving this to head to avoid conflict with addThis buttons ... 
// add_action('wp_footer', 'fbmlsetup', 100);
add_action('after_body', 'fbmlsetup', 100);

This resolved the issue and helped me understand how simple it is to create a custom action hook in WordPress.

May 7, 2011

We now have a demo up featuring a video player developed by Ross Sabes.

Video Player

This player utilizes a full featured custom back-end video database management tool.

Web Video Player Admin

Each video title can support multiple files in a variety of formats (FLV, MP4, Ogg, WebM, etc…) and settings for maximum compatibility and performance across the widest possible array of devices. The player can be customized to detect the users bandwidth and play the most suitable Flash format available. If the visitor is using an iPad, iPhone or iPod the player is programmed to use the compatible MP4 format with both high and low bandwidth options if available.

Video Edit Screen

Videos can be assigned to multiple pages by the administrator.

Select Pages for the Video to Appear On

Select pages for the video to appear on.

Videos can also be tagged for search engines and other custom functionality.Tag videos for addtitional functionality

Visit the front-end here
For a demo of the back-end contact us.

This program was developed using:
MooTools
MediaBox
and MooFlow

August 29, 2010

Here is a simple little regex tester I made: regular-expression-lab

August 13, 2010

There are 2 ways a website can be developed: either as static web pages or as dynamic (database driven) web pages. Let’s discuss both varieties:

Static Web Pages
All web pages are displayed using HTML code. Static web pages are essentially a series of linked HTML documents. To make a change to a static website one must edit the HTML code directly on each page. While this may work for a simple web site that has 3 or 4 pages, it quickly becomes inefficient as your web site grows in depth and complexity.

Database SymbolDynamic, Database Driven Web Pages
Database driven websites are fast becoming the standard for website development. The content on a dynamic website is maintained in a database. When a visitor requests information for a page, product, article or photo, that request is processed and returned by a database.

Web Site Maintenance
Typically the information in the database is maintained through a secure administrator log-in area. A well designed administrator log-in area makes it easy for anyone to update the website content without having to learn HTML or sophisticated website design software.

Content Management Area

If you are interested in developing a dynamic, database driven website, have static web pages that need to be converted or want help with an existing dynamic website please contact us for a free consultation. We will be happy to discuss the various benefits and options available to you.

You can also use the comments form below for additional discussion and questions.

April 22, 2010

When I am working on a website I have a local development version that I program and test locally. When an update is implemented, it is tested locally before it is copied to the live server. WordPress sites are treated no differently. Here is how you can make the wp-config.php portable to work in your live and local environment. Simply replace the variables below with the actual information for your web site and you will be have a wp-config.php that can happily thrive in both environments.

I defined an additional constant ‘LIVE’ that I can refer to elsewhere in my code to determine if I am on the live server or not.

wp-config.php


if($_SERVER[‘HTTP_HOST’]==’livedomain.com’ || $_SERVER[‘HTTP_HOST’]==’www.livedomain.com’){

define(‘DB_NAME’, ‘db_name_live’); // The name of the database
define(‘DB_USER’, ‘mysql_username_live’); // Your MySQL username
define(‘DB_PASSWORD’, ‘mysql_password_live’); // …and password
define(‘DB_HOST’, ‘localhost’); // db host
define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);
define(‘AUTH_KEY’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);
define(‘LIVE’, true);

}else{

define(‘DB_NAME’, ‘name_of_db_local’); // The name of the database
define(‘DB_USER’, ‘mysql_username_local’); // Your MySQL username
define(‘DB_PASSWORD’, ‘mysql_password_local’); // …and password
define(‘DB_HOST’, ‘localhost’); // db host
define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);
define(‘AUTH_KEY’, ‘put your unique phrase here’);
define(‘SECURE_AUTH_KEY’, ‘put your unique phrase here’);
define(‘LOGGED_IN_KEY’, ‘put your unique phrase here’);
define(‘LIVE’, false);

}

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-content/languages.
// For example, install de.mo to wp-content/languages and set WPLANG to ‘de’
// to enable German language support.
define (‘WPLANG’, ”);

/* That’s all, stop editing! Happy blogging. */

if ( !defined(‘ABSPATH’) )
define(‘ABSPATH’, dirname(__FILE__) . ‘/’);
require_once(ABSPATH . ‘wp-settings.php’);
?>

MySQL Queries

Another thing to be conscious of when moving between a live and local server environment with WordPress are couple of records in the wp_options table of the database. The siteurl and liveurl records will be different in your local environment and live environment. If you copy your database from one to the other, just run the appropriate query below (with the liveurl and localurl variables changed to your actual data) depending on if you are copying from local to live or live to local.

Live to Local Query

Run query on local database.

UPDATE wp_options SET option_value=’http://localurl.com’ WHERE option_name=’siteurl’ ;

UPDATE wp_options SET option_value=’http://localurl.com’ WHERE option_name=’home’

Local to Live Query

Run query on live database.

UPDATE wp_options SET option_value=’http://liveurl.com‘ WHERE option_name=’siteurl’ ;

UPDATE wp_options SET option_value=’http://liveurl.com’ WHERE option_name=’home’

If you have any questions or suggestions, your comments are welcome below.

September 10, 2009

This example uses the php class developed by Mark Sandborn (now hosted at code.google.com here). I made a couple slight modifications to the class. Using Marks’ class I created this form to serve as a starting point for you to present your user with various UPS shipping options and their associated costs to integrate into your own shopping cart.

download my sourcecode for the form
Rates and Service Selection XML Tool Developers Guide from UPS

Happy coding!

March 12, 2009

I made a random flickr image loader using phpFlickr.

It loads a random image from based on the search term entered in the text box. Search terms are saved in a database and reused randomly on each refresh.