Sticky Menu Installation Fix for WordPress 2.6

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:
  1. # ———————————-
  2. function stickymenu_install() {
  3. # ———————————-
  4. global $wpdb, $version;
  5. if (!current_user_can(“manage_options”)) {
  6.   return;
  7. };
  8. $table_name = $wpdb->prefix . ’stickymenu’;
  9. if ($wpdb->get_var(“show tables like ‘$table_name’”) != $table_name) {
  10.   # Create DB table
  11.   $sql = “CREATE TABLE $table_name (
  12.     id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  13.     pid VARCHAR(55) NOT NULL,
  14.     name VARCHAR(55) NOT NULL,
  15.     link VARCHAR(255) NOT NULL,
  16.     menu VARCHAR(55) NOT NULL,
  17.     class VARCHAR(55) NOT NULL,
  18.     weight int(11) NOT NULL DEFAULT ‘0′,
  19.     disabled TINYINT NOT NULL DEFAULT ‘0′,
  20.     UNIQUE KEY id (id)
  21.     ) TYPE = MYISAM;”;
  22.   require_once(ABSPATH.‘wp-admin/includes/upgrade.php’);
  23.   dbDelta($sql);
  24. } else {
  25.   if ($wpdb->get_var(“show columns from $table_name like ‘class’”) != ‘class’) {
  26.       # This column ‘class’ was added in release 1.4
  27.       $column_name = ‘class’;
  28.       $sql = “ALTER TABLE $table_name ADD $column_name VARCHAR(55) NOT NULL”;
  29.     $wpdb->query($sql);
  30.   require_once(ABSPATH.‘wp-admin/includes/upgrade.php’);
  31.   };
  32.   if ($wpdb->get_var(“show columns from $table_name like ‘pid’”) != ‘pid’) {
  33.     # This column ‘pid’ will be needed in release 1.5
  34.     $column_name = ‘pid’;
  35.     $sql = “ALTER TABLE $table_name ADD $column_name VARCHAR(55) NOT NULL”;
  36.     $wpdb->query($sql);
  37.   require_once(ABSPATH.‘wp-admin/includes/upgrade.php’);
  38.   };
  39. };

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

8 Comments

  1. Neil Foster
    Posted October 27, 2008 at 4:32 pm | Permalink

    Parse error: syntax error, unexpected T_STRING in /home/upsta11/public_html/campbethel/wp-content/plugins/stickymenu/stickymenu.php on line 94

    Somewhere around your line 91 or 92

  2. chris
    Posted November 13, 2008 at 3:23 am | Permalink

    Hi, i get the same error message as Neil :(

    Any suggestions?

    thanks for your help,
    chris

  3. Posted November 13, 2008 at 12:27 pm | Permalink

    I added an alternate file for you to copy from. It is most likely the curly quotes that Wordpress loves to put into everything.

  4. sean
    Posted December 1, 2008 at 11:04 am | Permalink

    Hi,

    I’m currently running WP 2.6.5, and I’ve tried this fix which still isn’t working for me. I click ’save’ and am simply redirected to the Sticky submenu with no menus saved.

  5. Posted December 4, 2008 at 2:18 pm | Permalink

    Hey Sean, Let me have a look at it and see what I can find out. Were you able to fix it?

  6. JaC
    Posted December 8, 2008 at 6:55 am | Permalink

    Hi Dustin

    Similar issue. Fix did not work though I applied it from flat file.

    I am using WP v2.6.2 soon to UG to the just relased to WP v2.6.5

    Best

  7. JaC
    Posted December 8, 2008 at 7:20 am | Permalink

    Hi all

    Resolved.

    It worked after I deactivated and reactivated the plug-in…

    Best

  8. Posted December 8, 2008 at 7:50 am | Permalink

    @JaC - That’s a great point that I forgot to mention. You have to reactivate the plugin because it only creates the database tables when it is installed.

    @sean - Did you try reactivating?

One Trackback

  1. [...] Sticky Menu Installation Fix for WordPress 2.6 [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*