PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / _wordpress / ui / element / input / richtextarea.php

richtextarea.php in ShiftController Employee Shift Scheduling 4.9.85, at hc3/_wordpress/ui/element/input/richtextarea.php

97 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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( $this->getAttr('required') ){
65 $htmlId = $this->htmlId();
66 $out .= '
67 <script>
68 var field' . $htmlId . ' = document.getElementById("' . $htmlId . '");
69 var form' . $htmlId . ' = field' . $htmlId . '.closest("form");
70 form' . $htmlId . '.onsubmit = function( event ){
71 var editor = tinyMCE.get( "' . $htmlId . '" );
72 if (null !== editor && false === editor.hidden ){
73 var content = editor.getContent();
74 }
75 else {
76 var content = field' . $htmlId . '.value;
77 }
78
79 if( ! content.length ){
80 alert( "__Required Field__" );
81 event.stopPropagation();
82 return false;
83 }
84 else {
85 return true;
86 }
87 }
88 </script>';
89 }
90
91 if( strlen($this->label) ){
92 $out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() );
93 }
94
95 return $out;
96 }
97 }