| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Element_Input_RichTextarea extends HC3_Ui_Element_Input_Textarea |
| 3 |
{ |
| 4 |
protected $el = 'input'; |
| 5 |
protected $uiType = 'input/text'; |
| 6 |
protected $bold = FALSE; |
| 7 |
|
| 8 |
public function bold( $set = TRUE ) |
| 9 |
{ |
| 10 |
$this->bold = $set; |
| 11 |
return $this; |
| 12 |
} |
| 13 |
|
| 14 |
public function render() |
| 15 |
{ |
| 16 |
if( ! is_admin() ){ |
| 17 |
return parent::render(); |
| 18 |
} |
| 19 |
|
| 20 |
if( ! function_exists('get_current_screen') ){ |
| 21 |
require_once( ABSPATH . 'wp-admin/includes/screen.php' ); |
| 22 |
} |
| 23 |
|
| 24 |
$wpEditorSettings = array(); |
| 25 |
$wpEditorSettings['textarea_name'] = $this->htmlName(); |
| 26 |
|
| 27 |
$rows = $this->getAttr('rows'); |
| 28 |
if( $rows ){ |
| 29 |
$wpEditorSettings['textarea_rows'] = $rows; |
| 30 |
} |
| 31 |
|
| 32 |
// stupid wp, it outputs it right away |
| 33 |
ob_start(); |
| 34 |
|
| 35 |
$editorId = $this->htmlId(); |
| 36 |
wp_editor( |
| 37 |
$this->value, |
| 38 |
$editorId, |
| 39 |
$wpEditorSettings |
| 40 |
); |
| 41 |
|
| 42 |
if( 0 ) |
| 43 |
{ |
| 44 |
$more_js = <<<EOT |
| 45 |
<script type="text/javascript"> |
| 46 |
var str = nts_tinyMCEPreInit.replace(/nts_wp_editor/gi, '$editor_id'); |
| 47 |
var ajax_tinymce_init = JSON.parse(str); |
| 48 |
|
| 49 |
tinymce.init( ajax_tinymce_init.mceInit['$editor_id'] ); |
| 50 |
</script> |
| 51 |
EOT; |
| 52 |
|
| 53 |
// _WP_Editors::enqueue_scripts(); |
| 54 |
// print_footer_scripts(); |
| 55 |
// _WP_Editors::editor_js(); |
| 56 |
echo $more_js; |
| 57 |
} |
| 58 |
|
| 59 |
_WP_Editors::enqueue_scripts(); |
| 60 |
_WP_Editors::editor_js(); |
| 61 |
|
| 62 |
$out = ob_get_clean(); |
| 63 |
|
| 64 |
if( strlen($this->label) ){ |
| 65 |
$out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() ); |
| 66 |
} |
| 67 |
|
| 68 |
return $out; |
| 69 |
} |
| 70 |
} |