Adding a table creation and update method.

Bu işleme şunda yer alıyor:
Eric van der Vlist 2011-06-03 18:39:32 +02:00
ebeveyn 86d7e64af5
işleme 68b215972f
2 değiştirilmiş dosya ile 45 ekleme ve 5 silme

Dosyayı Görüntüle

@ -2,9 +2,7 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../wordpress_vdv/wp-content/plugins/owark">
<sourceFolder url="file://$MODULE_DIR$/../wordpress_vdv/wp-content/plugins/owark" isTestSource="false" />
</content>
<content url="file://$MODULE_DIR$/../wordpress/plugins/owark" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>

Dosyayı Görüntüle

@ -18,7 +18,7 @@
/*
Plugin Name: owark
Plugin URI: http://owark.org
Description: Tired of broken links? Archive yours with the Open Web Archive!
Description: Tired of broken links? Archive yours with owark, the Open Web Archive!
Version: 0.1
Author: Eric van der Vlist
Author URI: http://eric.van-der-vlist.com
@ -32,6 +32,7 @@ if (!class_exists("Owark")) {
private $broken_links = array();
private $post_id = -1;
private $post_type = "";
private $version = '0.1';
/**
* Class constructor
@ -43,7 +44,11 @@ if (!class_exists("Owark")) {
*/
function Owark() {
add_action('admin_menu', array($this, 'owark_admin_menu'));
if (is_admin()) {
add_action('admin_menu', array($this, 'owark_admin_menu'));
add_action('plugins_loaded', array($this, 'sanity_checks'));
}
// See http://stackoverflow.com/questions/2210826/need-help-with-wp-rewrite-in-a-wordpress-plugin
// Using a filter instead of an action to create the rewrite rules.
@ -63,6 +68,43 @@ if (!class_exists("Owark")) {
}
/**
* Check we have everything we need...
*
* @package owark
* @since 0.1
*
*
*/
function sanity_checks(){
$installed_ver = get_option( "owark_db_version" );
if ($installed_ver != $this->version) {
global $wpdb;
$table = $wpdb->prefix."owark";
$sql = "CREATE TABLE $table (
id int(10) unsigned NOT NULL AUTO_INCREMENT,
url text NOT NULL,
status varchar(20) NOT NULL DEFAULT 'to-archive',
arc_date datetime,
arc_location text,
PRIMARY KEY(`id`),
KEY `url` (`url`(150)) )";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
update_option( "owark_db_version", $this->version );
}
}
/**
* Admin menus
*
* @package owark
* @since 0.1
*
*
*/
function owark_admin_menu() {
add_management_page(__('The Open Web Archive', 'owark'), __('Web Archive', 'owark'), 'edit_others_posts', 'owark', array($this, 'management_page'));
}