diff --git a/classes/WDTSTranscript.php b/classes/WDTSTranscript.php
index 73cd2e8..f6a5987 100644
--- a/classes/WDTSTranscript.php
+++ b/classes/WDTSTranscript.php
@@ -39,6 +39,10 @@ class WDTSTranscriptManager {
$transcript_info['user_id'] = $user->ID;
unset($transcript_info['key']);
+ foreach (array_keys($transcript_info) as $key) {
+ if (strpos($key, "_") === 0) { unset($transcript_info[$key]); }
+ }
+
if (($transcripts = $this->_get_transcripts_metadata()) !== false) {
$max_key = 0;
foreach ($transcripts as $transcript) {
diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php
index 9226b1b..f029cc8 100644
--- a/classes/WhatDidTheySayAdmin.php
+++ b/classes/WhatDidTheySayAdmin.php
@@ -16,7 +16,8 @@ class WhatDidTheySayAdmin {
'submit_transcriptions' => 'administrator',
'approve_transcriptions' => 'administrator',
'change_languages' => 'administrator'
- )
+ ),
+ 'load_default_styles' => true
);
var $capabilities = array();
@@ -45,11 +46,15 @@ class WhatDidTheySayAdmin {
'change_languages' => __('Change the available languages', 'what-did-they-say')
);
+ $options = get_option('what-did-they-say-options');
+ if (!is_array($options)) {
+ $options = $this->default_options;
+ update_option('what-did-they-say-options', $options);
+ }
+
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('admin_notices', array(&$this, 'admin_notices'));
- wp_enqueue_script('prototype');
-
add_filter('user_has_cap', array(&$this, 'user_has_cap'), 5, 3);
add_filter('the_media_transcript', array(&$this, 'the_media_transcript'));
add_filter('the_language_name', array(&$this, 'the_language_name'));
@@ -63,18 +68,71 @@ class WhatDidTheySayAdmin {
if ($this->is_ajax) { exit(0); }
}
- }
- }
-
- $this->read_language_file();
-
- if (current_user_can('submit_transcriptions')) {
- wp_enqueue_script('scriptaculous-effects');
+ }
}
}
function template_redirect() {
- wp_enqueue_script('toggle-transcript', plugin_dir_url(dirname(__FILE__)) . 'toggle-transcript.js', array('prototype'), false, true);
+ wp_enqueue_script('toggle-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/toggle-transcript.js', array('prototype'), false, true);
+ if (current_user_can('submit_transcriptions')) { wp_enqueue_script('scriptaculous-effects'); }
+
+ foreach (get_class_methods($this) as $method) {
+ if (strpos($method, "shortcode_") === 0) {
+ $shortcode_name = str_replace("_", "-", str_replace("shortcode_", "", $method));
+ add_shortcode($shortcode_name, array(&$this, $method));
+ }
+ }
+
+ add_filter('filter_shortcode_dialog', array(&$this, 'filter_shortcode_dialog'), 10, 4);
+ add_filter('filter_shortcode_scene_action', array(&$this, 'filter_shortcode_scene_action'), 10, 2);
+ add_filter('filter_shortcode_scene_heading', array(&$this, 'filter_shortcode_scene_heading'), 10, 2);
+
+ $options = get_option('what-did-they-say-options');
+ if (!empty($options['load_default_styles'])) {
+ wp_enqueue_style('wdts-defaults', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-defaults.css');
+ }
+ }
+
+ function shortcode_dialog($atts, $speech) {
+ extract(shortcode_atts(array(
+ 'name' => 'Nobody',
+ 'direction' => ''
+ ), $atts));
+
+ list($content) = apply_filters('filter_shortcode_dialog', "", $name, $direction, $speech);
+ return $content;
+ }
+
+ function filter_shortcode_dialog($content, $name, $direction, $speech) {
+ $content = '
' . $name . '';
+ if (!empty($direction)) {
+ $content .= ' ' . $direction . '';
+ }
+ $content .= ' ' . $speech . '
';
+
+ return array($content, $name, $direction, $speech);
+ }
+
+ function shortcode_scene_action($atts, $description) {
+ extract(shortcode_atts(array(), $atts));
+
+ list($content) = apply_filters('filter_shortcode_scene_action', "", $description);
+ return $content;
+ }
+
+ function filter_shortcode_scene_action($content, $description) {
+ return array('' . $description . '
', $description);
+ }
+
+ function shortcode_scene_heading($atts, $description) {
+ extract(shortcode_atts(array(), $atts));
+
+ list($content) = apply_filters('filter_shortcode_scene_heading', "", $description);
+ return $content;
+ }
+
+ function filter_shortcode_scene_heading($content, $description) {
+ return array('' . $description . '
', $description);
}
/**
@@ -83,7 +141,7 @@ class WhatDidTheySayAdmin {
* @return string The processed transcription text.
*/
function the_media_transcript($transcript) {
- return '' . $transcript . '
';
+ return '' . do_shortcode($transcript) . '
';
}
/**
@@ -180,8 +238,6 @@ class WhatDidTheySayAdmin {
function handle_update_manage_post_transcripts($info) {
$updated = false;
if (current_user_can('approve_transcriptions')) {
- $options = get_option('what-did-they-say-options');
-
$approved_transcript_manager = new WDTSApprovedTranscript($info['post_id']);
foreach ($info['transcripts'] as $language => $transcript) {
@@ -245,6 +301,19 @@ class WhatDidTheySayAdmin {
header('HTTP/1.1 401 Unauthorized');
}
+ function handle_update_default_styles($info) {
+ $updated = false;
+ if (current_user_can('edit_themes')) {
+ $options = get_option('what-did-they-say-options');
+
+ $options['load_default_styles'] = isset($info['default_styles']);
+
+ update_option('what-did-they-say-options', $options);
+ $updated = __('Default styles option updated.', 'what-did-they-say');
+ }
+ return $updated;
+ }
+
/**
* Handle updates to languages.
* @param array $info The part of the $_POST array for What Did They Say?!?
@@ -391,15 +460,21 @@ class WhatDidTheySayAdmin {
/**
* Handle admin_menu action.
*/
- function admin_menu() {
- if (current_user_can('edit_users')) {
+ function admin_menu() {
+ global $plugin_page;
+
+ if (current_user_can('submit_transcriptions')) {
add_options_page(
- __('What Did They Say?!? Settings', 'what-did-they-say'),
+ __('What Did They Say?!?', 'what-did-they-say'),
__('What Did They Say?!?', 'what-did-they-say'),
'manage_options',
'manage-wdts',
array(&$this, 'manage_admin')
);
+
+ if ($plugin_page == "manage-wdts") { $this->read_language_file(); }
+
+ wp_enqueue_script('scriptaculous-effects');
}
if (current_user_can('approve_transcriptions')) {
@@ -411,6 +486,8 @@ class WhatDidTheySayAdmin {
'normal',
'low'
);
+
+ wp_enqueue_script('scriptaculous-effects');
}
}
diff --git a/classes/admin.inc b/classes/admin.inc
index 5c78487..e8d3ba0 100644
--- a/classes/admin.inc
+++ b/classes/admin.inc
@@ -1,5 +1,39 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [scene-heading]Ext. The Old Man\'s House[/scene-heading] becomes:', 'what-did-they-say') ?>
+
+
+
+
+
+
+ [scene-action]John is walking down to the car parked in the driveway.[/scene-action] becomes:', 'what-did-they-say') ?>
+
+
+
+
+
+
+ [dialog name="John" direction="(towards the house)"]Hey, where are the keys?[/dialog] becomes:', 'what-did-they-say') ?>
+
+
+
-
-
+
+
+
+
+
+
+ - .transcript: The container for the transcript', 'what-did-they-say') ?>
+ - .dialog: Character dialog', 'what-did-they-say') ?>
+ - .name: The character\'s name', 'what-did-they-say') ?>
+ - .direction: The direction the characters is speaking in/from (off-stage, to another character)', 'what-did-they-say') ?>
+ - .scene-heading: A scene heading', 'what-did-they-say') ?>
+ - .scene-action: Action within a scene', 'what-did-they-say') ?>
+
+
+
-
-
- |
- |
- |
- |
-
- $info) {
- $default = isset($info['default']);
- $name = $info['name'];
- ?>
+
+
+
+
+
+
+ |
+ |
+ |
+ |
+
+ $info) {
+ $default = isset($info['default']);
+ $name = $info['name'];
+ ?>
+
+
+
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
-
-
-
-
- |
-
-
- |
-
+ | |
+
- |
-
-
|
-
-
- |
-
-
- |
-
-
+
+
+
diff --git a/classes/meta-box.inc b/classes/meta-box.inc
index 32c0e81..2ba3fc5 100644
--- a/classes/meta-box.inc
+++ b/classes/meta-box.inc
@@ -43,8 +43,12 @@
-
-
+
+
@@ -61,6 +65,6 @@
};
var s = document.createElement('script');
- s.src = '';
+ s.src = '';
document.getElementsByTagName('head')[0].appendChild(s);
\ No newline at end of file
diff --git a/css/wdts-defaults.css b/css/wdts-defaults.css
new file mode 100644
index 0000000..1cc6891
--- /dev/null
+++ b/css/wdts-defaults.css
@@ -0,0 +1,37 @@
+div.transcript {
+ border: solid #333 1px;
+ padding: 10px;
+ margin: 10px;
+ background-color: #e7e7e7
+}
+
+div.transcript div, div.transcript span {
+ font-family: 'Courier New'
+}
+
+div.transcript > div {
+ margin-bottom: 10px
+}
+
+div.transcript div.scene-heading {
+ text-transform: uppercase;
+ text-align: center;
+ font-weight: bold;
+ margin-bottom: 10px
+}
+
+div.transcript div.dialog {
+ text-align: center
+}
+
+div.transcript div.dialog span {
+ display: block
+}
+
+div.transcript div.dialog span.name {
+ text-transform: uppercase
+}
+
+div.transcript div.dialog span.speech {
+ margin: 10px 20px 0
+}
\ No newline at end of file
diff --git a/edit-transcripts.js b/js/edit-transcripts.js
similarity index 100%
rename from edit-transcripts.js
rename to js/edit-transcripts.js
diff --git a/toggle-transcript.js b/js/toggle-transcript.js
similarity index 100%
rename from toggle-transcript.js
rename to js/toggle-transcript.js
diff --git a/what-did-they-say.php b/what-did-they-say.php
index 7af5100..1f7bd53 100644
--- a/what-did-they-say.php
+++ b/what-did-they-say.php
@@ -176,7 +176,7 @@ function the_media_transcript_queue_editor() {
${"${var_name}_transcript_manager"} = new $class_name($post->ID);
${"${var_name}_transcripts"} = ${"${var_name}_transcript_manager"}->get_transcripts();
}
-
+
$nonce = wp_create_nonce('what-did-they-say');
?>
@@ -184,7 +184,7 @@ function the_media_transcript_queue_editor() {