add nl2br support

This commit is contained in:
John Bintz 2009-09-30 21:50:16 -04:00
parent e45a2b0e2e
commit 12ad221d29
2 changed files with 21 additions and 4 deletions

View File

@ -20,7 +20,8 @@ class WhatDidTheySayAdmin {
'load_default_styles' => true, 'load_default_styles' => true,
'automatic_embedding' => true, 'automatic_embedding' => true,
'search_integration' => true, 'search_integration' => true,
'excerpt_distance' => 30 'excerpt_distance' => 30,
'use_nl2br' => false
); );
var $capabilities = array(); var $capabilities = array();
@ -228,7 +229,10 @@ class WhatDidTheySayAdmin {
* @return string The processed transcription text. * @return string The processed transcription text.
*/ */
function the_media_transcript($transcript, $content = "") { function the_media_transcript($transcript, $content = "") {
return array($transcript, '<div class="transcript">' . do_shortcode($transcript) . '</div>'); $content = do_shortcode($transcript);
$options = get_option('what-did-they-say-options');
if ($options['use_nl2br']) { $content = nl2br($content); }
return array($transcript, '<div class="transcript">' . $content . '</div>');
} }
/** /**
@ -499,6 +503,7 @@ class WhatDidTheySayAdmin {
$options = get_option('what-did-they-say-options'); $options = get_option('what-did-they-say-options');
$options['load_default_styles'] = isset($info['default_styles']); $options['load_default_styles'] = isset($info['default_styles']);
$options['use_nl2br'] = isset($info['use_nl2br']);
$options['excerpt_distance'] = !empty($info['excerpt_distance']) ? $info['excerpt_distance'] : 30; $options['excerpt_distance'] = !empty($info['excerpt_distance']) ? $info['excerpt_distance'] : 30;
update_option('what-did-they-say-options', $options); update_option('what-did-they-say-options', $options);

View File

@ -13,15 +13,27 @@
</label> </label>
<label> <label>
<?php _e('Include default CSS styles for transcripts:', 'what-did-they-say') ?>
<input type="checkbox" <input type="checkbox"
name="wdts[default_styles]" name="wdts[default_styles]"
value="yes" value="yes"
<?php echo ($options['load_default_styles'] ? 'checked="checked"' : '') ?> /> <?php echo ($options['load_default_styles'] ? 'checked="checked"' : '') ?> />
<?php _e('Include default CSS styles for transcripts', 'what-did-they-say') ?>
</label>
<label>
<input type="checkbox"
name="wdts[use_nl2br]"
value="yes"
<?php echo ($options['use_nl2br'] ? 'checked="checked"' : '') ?> />
<?php _e('Turn transcript line breaks into HTML new lines (nl2br())', 'what-did-they-say') ?>
</label> </label>
<input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" /> <input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" />
</form> </form>
<h3><?php _e('Transcript Line Breaks', 'what-did-they-say') ?></h3>
<p><?php _e('If you\'re using short codes or HTML to construct your transcripts, you don\'t need to enable transcript line breaks.', 'what-did-they-say') ?></p>
<h3><?php _e('Default CSS Selectors Information', 'what-did-they-say') ?></h3> <h3><?php _e('Default CSS Selectors Information', 'what-did-they-say') ?></h3>
<p><?php _e('By default, the following CSS selectors are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p> <p><?php _e('By default, the following CSS selectors are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p>