WordPress.org

Ready to get started?Download WordPress

Forums

Table ceated on activation, but no prefix.. ! (1 post)

  1. JibsouX
    Member
    Posted 10 months ago #

    1 : the table is created but no prefix : Linkificator_plugin but not wp_Linkificator_plugin
    2 : LINK_deactivate doen't work..

    if you have an idea ?
    thanks a lot

    // DEFINE WP_LINK_TABLE = LINKIFICATOR_PLUGIN
    define("WP_LINK_TABLE", $wpdb->prefix . "Linkificator_plugin");
    
    // CALLBACK FUNCTION ACTIVATION & CREATION TABLE
    function LINK_activation()
    {
        global $wpdb;
    
        if($wpdb->get_var("show tables like '". WP_LINK_TABLE . "'") != WP_LINK_TABLE)
        {
            $wpdb->query(
                "CREATE TABLE IF NOT EXISTS '". WP_LINK_TABLE . "</code> (
                  'id' int(20) NOT NULL auto_increment,
                  'link' text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
                  PRIMARY KEY  ('id') )
                ");
            $sSql = "INSERT INTO '". WP_LINK_TABLE . "' ('link')";
            $sSql = $sSql . "VALUES ('Les liens morts apparaitront ici.');";
            $wpdb->query($sSql);
        }
    }
    
    // CALLBACK DESACTIVATE & DELETING TABLE
    function LINK_deactivate() {
        global $wpdb;
        $wpdb->query("DROP TABLE IF EXISTS '". WP_LINK_TABLE . "' ");
    }
    
    // REGISTRE HOOKS
    register_activation_hook(__FILE__, 'LINK_activation');
    register_deactivation_hook( __FILE__, 'LINK_deactivate' );
    register_uninstall_hook( __FILE__, 'LINK_deactivate' );

Reply

You must log in to post.

About this Topic