start preparing for admin interface

This commit is contained in:
John Bintz 2009-08-12 19:51:23 -04:00
parent 4cdd2985ac
commit 2b91ce8125
3 changed files with 112 additions and 0 deletions

View File

@ -6,12 +6,34 @@
* other posts as necessary.
*/
class WhatDidTheySay {
var $version = "0.1";
function WhatDidTheySay() {
global $wpdb;
$this->table = $wpdb->prefix . "provided_transcripts";
}
function install() {
global $wpdb;
if (get_option('what-did-they-say-version') !== $this->version) {
$sql = "CREATE TABLE %s (
id int NOT NULL AUTO_INCREMENT,
post_id int NOT NULL,
user_id int NOT NULL,
language char(10) NOT NULL,
transcript mediumtext,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
update_option('what-did-they-say-version', $version);
}
}
/**
* Save a transcript to a post.
* @param int $post_id The post to attach the transcript to.

View File

@ -0,0 +1,57 @@
<?php
class WhatDidTheySayAdmin {
function WhatDidTheySayAdmin() {
}
function init($what_did_they_say) {
$this->what_did_they_say = $what_did_they_say;
add_action('admin_menu', array(&$this, 'admin_menu'));
if (isset($_POST['wdts'])) {
if (isset($_POST['wdts']['_nonce'])) {
if (wp_verify_nonce('what-did-they-say', $_POST['wdts']['_nonce'])) {
$this->handle_update($_POST['wdts']);
}
}
}
}
function admin_menu() {
add_submenu_page(
'edit-comments.php',
__('Manage Transcriptions', 'what-did-they-say'),
__('Transcripts', 'what-did-they-say'),
'edit_posts',
'manage-transcriptions-wdts',
array(&$this, 'manage_transcriptions_admin')
);
if (current_user_can('edit_posts')) {
add_meta_box(
'manage-transcriptions',
__('Manage Transcriptions', 'what-did-they-say'),
array(&$this, 'manage_transcriptions_meta_box'),
'post',
'normal',
'low'
);
}
}
function manage_transcriptions_admin() {
}
function manage_transcriptions_meta_box() {
}
function handle_update($info) {
}
}
?>

View File

@ -0,0 +1,33 @@
<?php
/*
Plugin Name: What Did They Say?!?
Plugin URI: http://www.coswellproductions.com/wordpress/wordpress-plugins/
Description: Manage and display text transcriptions of comics, videos, or other media.
Version: 0.1
Author: johncoswell
Author URI: http://www.coswellproductions.com/wordpress/
Copyright 2009 John Bintx (email : john@coswellproductions.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
$what_did_they_say =& new WhatDidTheySay();
$what_did_they_say_admin =& new WhatDidTheySayAdmin(&$what_did_they_say);
add_action('init', array(&$what_did_they_say_admin, 'init'));
register_activation_hook(__FILE__, array(&$what_did_they_say, 'install'));
?>