Blog

Recent Blog Posts

Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed or Subscribe to Email update. You will find all kinds of things about technology here!

PHP: Remove File Extension

While writing a script to list the file in a specified folder on the server I wanted to remove file extension from the file name before I link it. Here is the php code that will remove the file extension.

< ? php
if(!function_exists("RemoveExtension"))
{
function RemoveExtension($strName)
{
$ext = strrchr($strName, '.');
if($ext !== false) {
$strName = substr($strName, 0, -strlen($ext));
}
return $strName;
}
}
? >

If you enjoyed this post, make sure you subscribe to my RSS feed!


Loading custom Javascript Libraries in Wordpress Themes with wp_enqueue_script()

Since reading Nick’s entry on Loading Javascript Libraries in Wordpress Plugins, I have decided to use the same techniques to get my custom Theme to load JavaScript using wp_enqueue_script().

There is two reasons why I wanted to load my custom JavaScript libraries:

  1. Default jQuery library included with the latest version of WordPress is not up-to-date
  2. My custom code does not work with the default version included with this release WordPress

As this is a custom theme I have a functions.php where I have defined all my custom functions. So to load the custom JavaScript.

< ? php
function my_add_js_libs() {
//Add the jquery framework to the header
//wp_enqueue_script('jquery'); // default jquery is not up-to-date
//wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false );
wp_enqueue_script('my_jquery', $src = '/wp-content/themes/[mythemename]/js/jquery-1.2.1.pack.js’, $deps = array(), $ver = ‘1.2.1′ );
wp_enqueue_script(’my_core_js’, $src = ‘/wp-content/themes/[mythemename]/js/core.js’, $deps = array(’my_jquery’));
}
? >

then make a call to the function in the header.php just before the wp_head();

< ? php
my_add_js_libs();
wp_head();
? >

This should now load the custom JavaScript Libraries required for your themes in the sequence that WordPress decides.

If you enjoyed this post, make sure you subscribe to my RSS feed!


Feedback Form