Support » Plugins » Why wont my variables properly resolve?

  • here is my plugin activation code

    $classified_category_name = 'classified';
    $credit_table_name = 'credits';
    $credit_table_version = 0.1;
    register_activation_hook(__FILE__, 'LBH_Classifieds_Activate');
    function LBH_Classifieds_Activate()
            global $wpdb;
            global $classified_category_name;
            global $credit_table_name;
            global $credit_table_version;
            $table_name = $wpdb->prefix . $credit_table_name;
            return new WP_Error('broke', __('very broken'));
            if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
                    $sql = "CREATE TABLE " . $table_name . " (
                            time bigint(11) DEFAULT 0 NOT NULL,
                            amount tinyint(3) DEFAULT 0 NOT NULL,
                            username varchar(50) NOT NULL,
                            UNIQUE KEY username (username)
                    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
            add_option('lbh_db_version', $credit_table_version);

    but the global variables are empty.

    Also, is there any way to print any information from within a plugin? I’ve tried returning a WP_Error, throwing a WP_Error, and all I can ever get is a big yellow box, mostly empty, with “Plugin could not be activated because it triggered a fatal error.”


Viewing 1 replies (of 1 total)
  • Did you find a solution? I’m finding a lot of plugins are erroring because global $wpdb is not returning anything. Performing a dumpvar shows $wpdb = NULL. And I can’t call any of the classes associated with $wpdb either such as $wpdb->get_value().

Viewing 1 replies (of 1 total)
  • The topic ‘Why wont my variables properly resolve?’ is closed to new replies.