-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisable_html_editor.php
More file actions
52 lines (45 loc) · 1.55 KB
/
disable_html_editor.php
File metadata and controls
52 lines (45 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
Plugin Name: Disable HTML Editor
Description: Disable HTML Editor At the Page Level
Version: 1.1
Author: Dmitry Yakovlev
Author URI: http://dimayakovlev.ru/
*/
# get correct id for plugin
$thisfile=basename(__FILE__, ".php");
i18n_merge($thisfile) || i18n_merge($thisfile, 'en_US');
# register plugin
register_plugin(
$thisfile,
i18n_r($thisfile.'/TITLE'),
'1.1',
i18n_r($thisfile.'/AUTHOR'),
'http://dimayakovlev.ru/',
i18n_r($thisfile.'/DESCRIPTION'),
'',
''
);
add_action('edit-extras', 'plugin_disable_html_editor', array($thisfile));
add_action('changedata-save', 'plugin_disable_html_editor_save');
function plugin_disable_html_editor($thisfile) {
global $data_edit, $HTMLEDITOR;
$checked = '';
if(isset($data_edit) && (string)$data_edit->noHTMLEditor) {
$HTMLEDITOR = '';
$checked = ' checked';
}
echo '<p id="'.$thisfile.'" class="inline clearfix"><input type="checkbox" name="post-noHTMLEditor" style="width: auto" value="1"'.$checked.'> <label for="post-noHTMLEditor">'.i18n_r($thisfile.'/LABEL').'</label></p>';
add_action('footer', 'plugin_disable_html_js', array($thisfile));
}
function plugin_disable_html_js($id) {
echo '<script type="text/javascript">jQuery(document).ready(function() { $("#'.$id.'").insertAfter($("#metadata_window")); })</script>';
}
function plugin_disable_html_editor_save() {
global $xml;
if (isset($_POST['post-noHTMLEditor'])) {
$xml->addChild('noHTMLEditor')->addCData('1');
} else {
$xml->addChild('noHTMLEditor');
}
}