Changeset 68b2159


Ignore:
Timestamp:
03/06/2011 18:39:32 (8 years ago)
Author:
Eric van der Vlist <vdv@dyomedea.com>
Branches:
master
Children:
77850f0
Parents:
86d7e64
git-author:
Eric van der Vlist <vdv@dyomedea.com> (03/06/2011 18:39:32)
git-committer:
Eric van der Vlist <vdv@dyomedea.com> (03/06/2011 18:39:32)
Message:

Adding a table creation and update method.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • owark/owark.iml

    r86d7e64 r68b2159  
    33  <component name="NewModuleRootManager" inherit-compiler-output="true"> 
    44    <exclude-output /> 
    5     <content url="file://$MODULE_DIR$/../wordpress_vdv/wp-content/plugins/owark"> 
    6       <sourceFolder url="file://$MODULE_DIR$/../wordpress_vdv/wp-content/plugins/owark" isTestSource="false" /> 
    7     </content> 
     5    <content url="file://$MODULE_DIR$/../wordpress/plugins/owark" /> 
    86    <orderEntry type="inheritedJdk" /> 
    97    <orderEntry type="sourceFolder" forTests="false" /> 
  • wordpress/plugins/owark/owark.php

    r86d7e64 r68b2159  
    1919Plugin Name: owark 
    2020Plugin URI: http://owark.org 
    21 Description: Tired of broken links? Archive yours with the Open Web Archive! 
     21Description: Tired of broken links? Archive yours with owark, the Open Web Archive! 
    2222Version: 0.1 
    2323Author: Eric van der Vlist 
     
    3333        private $post_id = -1; 
    3434        private $post_type = ""; 
     35        private $version = '0.1'; 
    3536         
    3637        /** 
     
    4445                function Owark() { 
    4546 
    46             add_action('admin_menu', array($this, 'owark_admin_menu')); 
     47 
     48            if (is_admin()) { 
     49                add_action('admin_menu', array($this, 'owark_admin_menu')); 
     50                add_action('plugins_loaded', array($this, 'sanity_checks')); 
     51            } 
    4752 
    4853            // See http://stackoverflow.com/questions/2210826/need-help-with-wp-rewrite-in-a-wordpress-plugin 
     
    6469                } 
    6570 
     71        /** 
     72         * Check we have everything we need... 
     73         * 
     74         * @package owark 
     75         * @since 0.1 
     76         * 
     77         * 
     78         */ 
     79        function sanity_checks(){ 
     80            $installed_ver = get_option( "owark_db_version" ); 
     81            if ($installed_ver != $this->version) { 
     82                global $wpdb; 
     83                $table = $wpdb->prefix."owark"; 
     84                $sql = "CREATE TABLE $table ( 
     85                    id int(10) unsigned NOT NULL AUTO_INCREMENT, 
     86                    url text NOT NULL, 
     87                    status varchar(20) NOT NULL DEFAULT 'to-archive', 
     88                    arc_date datetime, 
     89                    arc_location text, 
     90                    PRIMARY KEY(`id`), 
     91                    KEY `url` (`url`(150)) )"; 
     92                require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
     93                dbDelta($sql); 
     94 
     95                update_option( "owark_db_version", $this->version ); 
     96 
     97            } 
     98        } 
     99 
     100        /** 
     101         * Admin menus 
     102         * 
     103         * @package owark 
     104         * @since 0.1 
     105         * 
     106         * 
     107         */ 
    66108        function owark_admin_menu() { 
    67109            add_management_page(__('The Open Web Archive', 'owark'), __('Web Archive', 'owark'), 'edit_others_posts', 'owark', array($this, 'management_page')); 
Note: See TracChangeset for help on using the changeset viewer.