示例#1
0
function papercite_ajax_callback()
{
    require_once dirname(__FILE__) . "/papercite_db.php";
    print json_encode(papercite_install(true));
    die;
}
示例#2
0
                // Remove all entries (change in PHP class names)
                $wpdb->query("TRUNCATE TABLE {$papercite_table_name}");
                $wpdb->query("TRUNCATE TABLE {$papercite_table_name_url}");
            }
        }
        require ABSPATH . 'wp-admin/includes/upgrade.php';
        $sql = "CREATE TABLE {$papercite_table_name} (\n             urlid INT UNSIGNED NOT NULL,  \n             bibtexid VARCHAR(200) CHARSET ASCII NOT NULL,\n             entrytype VARCHAR(80) CHARSET ASCII NOT NULL,\n             year SMALLINT,\n             data TEXT NOT NULL,\n             PRIMARY KEY id (urlid, bibtexid),\n             INDEX year (year),\n             INDEX entrytype (entrytype)\n          ) DEFAULT CHARACTER SET {$wpdb->charset}";
        ob_start();
        $wpdb->show_errors(true);
        dbDelta($sql, true);
        $output = ob_get_contents();
        ob_end_clean();
        if ($wpdb->last_result !== FALSE) {
            $sql = "CREATE TABLE {$papercite_table_name_url} (\n                 urlid INT UNSIGNED NOT NULL AUTO_INCREMENT,  \n                 url VARCHAR(300) CHARSET ASCII NOT NULL,\n                 ts BIGINT UNSIGNED NOT NULL,\n                 PRIMARY KEY id (urlid),\n                 UNIQUE KEY url (url)\n              ) DEFAULT CHARACTER SET {$wpdb->charset}";
            ob_start();
            $wpdb->show_errors(true);
            dbDelta($sql, true);
            $output = ob_get_contents();
            ob_end_clean();
        }
        if ($wpdb->last_result !== FALSE) {
            // Set the current version
            update_option("papercite_db_version", $papercite_db_version);
            add_action('admin_notices', 'papercite_msg_upgraded');
        }
        return array($wpdb->last_result !== FALSE, $output);
    }
    return true;
}
papercite_install();