Sticky Menu Installation Fix for WordPress 2.6

Posted on

If you have recently tried to install the Sticky Menu plugin you will have noticed that it does not create a table in the database as it should. Here is the fix, for anyone who is interested. Just open the stickymenu.php file and replace the entire stickymenu_install() function with the one below.

==
[php num=86]

———————————-

function stickymenu_install() {

———————————-

global $wpdb, $version;
if (!current_user_can(“manage_options”)) {
return;
};
$table_name = $wpdb→prefix . ‘stickymenu’;
if ($wpdb→get_var(“show tables like ‘$table_name’“) != $table_name) {

Create DB table

$sql = “ CREATE TABLE $tablename (
id int(11) UNSIGNED NOT NULL AUTO
INCREMENT ,
pid VARCHAR NOT NULL ,
name VARCHAR NOT NULL ,
link VARCHAR NOT NULL ,
menu VARCHAR NOT NULL ,
class VARCHAR NOT NULL ,
weight int(11) NOT NULL DEFAULT ‘0′,
disabled TINYINT NOT NULL DEFAULT ‘0′,
UNIQUE KEY id (id)
) TYPE = MYISAM ;“;
require_once( ABSPATH .‘wp-admin/includes/upgrade.php’);
dbDelta($sql);
} else {
if ($wpdb→get_var(“show columns from $table_name like ‘class’“) != ‘class’) {

This column ‘class’ was added in release 1.4

$column_name = ‘class’;
$sql = “ ALTER TABLE $table_name ADD $column_name VARCHAR NOT NULL “;
$wpdb→query($sql);
require_once( ABSPATH .‘wp-admin/includes/upgrade.php’);
};
if ($wpdb→get_var(“show columns from $table_name like ‘pid’“) != ‘pid’) {

This column ‘pid’ will be needed in release 1.5

$column_name = ‘pid’;
$sql = “ ALTER TABLE $table_name ADD $column_name VARCHAR NOT NULL “;
$wpdb→query($sql);
require_once( ABSPATH .‘wp-admin/includes/upgrade.php’);
};

}; [/php]

UPDATE : Because of the way Wordpress handles quotes you can’t just copy and paste this code. You will have to change the quotes from their curly counterparts back to the straight quotes, or copy the code from the file below.

stickymenu-fixphp