diff --git a/classes/WhatDidTheySayAdmin.inc b/classes/WhatDidTheySayAdmin.inc index a09b79d..09e2acb 100644 --- a/classes/WhatDidTheySayAdmin.inc +++ b/classes/WhatDidTheySayAdmin.inc @@ -134,7 +134,10 @@ class WhatDidTheySayAdmin { */ function template_redirect() { 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'); } + if (current_user_can('submit_transcriptions')) { + wp_enqueue_script('scriptaculous-effects'); + wp_enqueue_script('edit-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/edit-transcripts.js', array('scriptaculous-effects'), false, true); + } foreach (get_class_methods($this) as $method) { if (strpos($method, "shortcode_") === 0) { @@ -283,13 +286,13 @@ class WhatDidTheySayAdmin { function user_has_cap($capabilities, $requested_capabilities, $capability_name) { $options = get_option('what-did-they-say-options'); if (is_array($options)) { - $role_cascade = array('administrator', 'editor', 'author', 'contributor', 'subscriber'); + $role_cascade = array('subscriber', 'contributor', 'author', 'editor', 'administrator'); $allowed_roles = array(); - $capture_roles = false; for ($i = 0; $i < count($role_cascade); ++$i) { - if (in_array($role_cascade, $capabilities)) { $capture_roles = true; } - if ($capture_roles) { $allowed_roles[] = $role_cascade[$i]; } + if (isset($capabilities[$role_cascade[$i]])) { + $allowed_roles = array_slice($role_cascade, 0, $i + 1); break; + } } foreach ($requested_capabilities as $requested_capability) { @@ -616,7 +619,7 @@ class WhatDidTheySayAdmin { add_options_page( __('What Did They Say?!?', 'what-did-they-say'), __('What Did They Say?!?', 'what-did-they-say'), - 'manage_options', + 'submit_transcriptions', 'manage-wdts', array(&$this, 'manage_admin') ); @@ -645,6 +648,7 @@ class WhatDidTheySayAdmin { wp_enqueue_style('wdts-admin', plugin_dir_url(dirname(__FILE__)) . 'css/wdts-admin.css'); wp_enqueue_script('scriptaculous-effects'); + wp_enqueue_script('edit-transcript', plugin_dir_url(dirname(__FILE__)) . 'js/edit-transcripts.js', array('scriptaculous-effects'), false, true); } } } @@ -683,6 +687,7 @@ class WhatDidTheySayAdmin { $nonce = wp_create_nonce('what-did-they-say'); include('partials/meta-box.inc'); + include('partials/_editor-script.inc'); } } diff --git a/classes/partials/_editor-script.inc b/classes/partials/_editor-script.inc new file mode 100644 index 0000000..e01c3ac --- /dev/null +++ b/classes/partials/_editor-script.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/classes/partials/_introduction.inc b/classes/partials/_introduction.inc index 52ef42a..9af9116 100644 --- a/classes/partials/_introduction.inc +++ b/classes/partials/_introduction.inc @@ -15,14 +15,16 @@
What Did They Say?!? can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?> - - +
What Did They Say?!? is set to attempt to embed excerpts into your posts automatically.', 'what-did-they-say') ?> @@ -49,14 +51,16 @@ What Did They Say?!? can search your transcripts, too.', 'what-did-they-say') ?> - - + What Did They Say?!? is set to search transcripts when your site is searched.', 'what-did-they-say') ?> diff --git a/classes/partials/meta-box.inc b/classes/partials/meta-box.inc index 28db282..14a9421 100644 --- a/classes/partials/meta-box.inc +++ b/classes/partials/meta-box.inc @@ -56,23 +56,4 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/css/wdts-admin.css b/css/wdts-admin.css index 04f371a..bbe1ead 100644 --- a/css/wdts-admin.css +++ b/css/wdts-admin.css @@ -61,3 +61,7 @@ -moz-border-radius: 2px; -webkit-border-radius: 2px; } + +#wdts-page-introduction label { + display: inline +} \ No newline at end of file diff --git a/js/edit-transcripts.js b/js/edit-transcripts.js index 7a20a30..45093de 100644 --- a/js/edit-transcripts.js +++ b/js/edit-transcripts.js @@ -1,3 +1,5 @@ +var language_selector = $('wdts-language'); + function switch_transcript() { $$('.edit-transcript').each(function(t) { (t.id == "wdts-transcripts-" + $F('wdts-language')) ? t.show() : t.hide(); @@ -28,10 +30,16 @@ var WDTSInjector = Class.create({ }); Event.observe(window, 'load', function() { - [ - [ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ], - [ '#wdts-submit-shorttags button', $('wdts-transcript') ] - ].each(function(info) { + var buttons_to_watch = []; + if ($('wdts-transcript')) { + buttons_to_watch.push([ '#wdts-submit-shorttags button', $('wdts-transcript') ]); + } + + if ($$('select[name=wdts-language]').pop()) { + buttons_to_watch.push([ '#wdts-shorttags button', $("wdts-transcripts-" + $F('wdts-language')) ]); + } + + buttons_to_watch.each(function(info) { $$(info[0]).each(function(b) { b.observe('click', function(e) { Event.stop(e); @@ -179,6 +187,8 @@ $$('.delete-transcript').each(function(b) { }); }); -switch_transcript(); -Event.observe(window, 'load', switch_transcript); -Event.observe(language_selector, 'change', switch_transcript); +if (language_selector) { + switch_transcript(); + Event.observe(window, 'load', switch_transcript); + Event.observe(language_selector, 'change', switch_transcript); +} \ No newline at end of file diff --git a/what-did-they-say.php b/what-did-they-say.php index 9d5c436..8bce213 100644 --- a/what-did-they-say.php +++ b/what-did-they-say.php @@ -211,6 +211,8 @@ function the_media_transcript_queue_editor() { $nonce = wp_create_nonce('what-did-they-say'); + include(dirname(__FILE__) . '/classes/partials/_editor-script.inc'); + ?>