working on metabox
This commit is contained in:
parent
e218da70d7
commit
c09cff5056
@ -52,6 +52,10 @@ class WhatDidTheySay {
|
||||
}
|
||||
}
|
||||
|
||||
function get_transcripts($post_id) {
|
||||
return get_post_meta($post_id, 'provided_transcripts', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the languages that the approved transcripts for the post are written in.
|
||||
* @param int $post_id The post ID to check for transcripts.
|
||||
|
@ -24,13 +24,12 @@ class WhatDidTheySayAdmin {
|
||||
var $all_languages = array();
|
||||
var $notices = array();
|
||||
|
||||
function WhatDidTheySayAdmin() {
|
||||
function WhatDidTheySayAdmin($what_did_they_say = null) {
|
||||
$this->what_did_they_say = $what_did_they_say;
|
||||
$this->language_file = dirname(__FILE__) . '/../data/lsr-language.txt';
|
||||
}
|
||||
|
||||
function init($what_did_they_say) {
|
||||
$this->what_did_they_say = $what_did_they_say;
|
||||
|
||||
function init() {
|
||||
$this->capabilities = array(
|
||||
'submit_transcriptions' => __('Submit transcriptions to a post', 'what-did-they-say'),
|
||||
'approve_transcriptions' => __('Approve transcriptions to a post', 'what-did-they-say'),
|
||||
@ -241,9 +240,7 @@ class WhatDidTheySayAdmin {
|
||||
|
||||
function manage_admin() {
|
||||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
|
||||
include(dirname(__FILE__) . '/admin.inc');
|
||||
}
|
||||
|
||||
@ -251,8 +248,9 @@ class WhatDidTheySayAdmin {
|
||||
global $post;
|
||||
|
||||
$options = get_option('what-did-they-say-options');
|
||||
|
||||
var_dump($post->ID);
|
||||
$transcripts = $this->what_did_they_say->get_transcripts($post->ID);
|
||||
$nonce = wp_create_nonce('what-did-they-say');
|
||||
include(dirname(__FILE__) . '/meta-box.inc');
|
||||
}
|
||||
}
|
||||
|
||||
|
25
classes/meta-box.inc
Normal file
25
classes/meta-box.inc
Normal file
@ -0,0 +1,25 @@
|
||||
<iuput type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
|
||||
<iuput type="hidden" name="wdts[action]" value="manage_post_transcripts" />
|
||||
<p>
|
||||
<label>
|
||||
Edit transcript for:
|
||||
<select name="wdts[language]" id="wdts-language">
|
||||
<?php foreach ($options['languages'] as $code => $info) { ?>
|
||||
<option value="<?php echo $code ?>" <?php echo $info['default'] ? 'selected="selected"' : '' ?>><?php echo $info['name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<?php foreach (array_keys($options['languages']) as $code) { ?>
|
||||
<textarea class="transcript" id="wdts-transcripts-<?php echo $code ?>" name="wdts[transcripts][<?php echo $code ?>]" style="display: none; width: 100%; height: 200px"><?php echo $transcripts[$code] ?></textarea>
|
||||
<?php } ?>
|
||||
</p>
|
||||
<script type="text/javascript">
|
||||
function switch_transcript() {
|
||||
$$('.transcript').each(function(t) {
|
||||
(t.id == "wdts-transcripts-" + $F('wdts-language')) ? t.show() : t.hide();
|
||||
});
|
||||
}
|
||||
switch_transcript();
|
||||
Event.observe($('wdts-language'), 'change', switch_transcript);
|
||||
</script>
|
@ -103,16 +103,16 @@ class WhatDidTheySayAdminTest extends PHPUnit_Framework_TestCase {
|
||||
$admin->handle_update_capabilities(array(
|
||||
'action' => 'capabilities',
|
||||
'capabilities' => array(
|
||||
'submit_transcription' => 'contributor',
|
||||
'approve_transcription' => 'subscriber',
|
||||
'submit_transcriptions' => 'contributor',
|
||||
'approve_transcriptions' => 'subscriber',
|
||||
'change_languages' => 'reader'
|
||||
)
|
||||
));
|
||||
|
||||
$result = get_option('what-did-they-say-options');
|
||||
$this->assertEquals(array(
|
||||
'submit_transcription' => 'contributor',
|
||||
'approve_transcription' => 'subscriber',
|
||||
'submit_transcriptions' => 'contributor',
|
||||
'approve_transcriptions' => 'subscriber',
|
||||
'change_languages' => 'reader'
|
||||
), $result['capabilities']);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user