This repository has been archived by the owner on Jun 22, 2018. It is now read-only.
forked from mukhortov/HESH-WordPress-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html-editor-syntax-highlighter.php
61 lines (47 loc) · 1.86 KB
/
html-editor-syntax-highlighter.php
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
53
54
55
56
57
58
59
60
61
<?php
/**
*
* @since 1.7.1
* @package HESH_plugin
*
* Plugin Name: HTML Editor Syntax Highlighter
* Plugin URI: http://wordpress.org/extend/plugins/html-editor-syntax-highlighter/
* Description: Adds syntax highlighting in the WordPress post HTML/text editor using Codemirror.js
* Text Domain: html-editor-syntax-highlighter
* Author: Petr Mukhortov
* Author URI: http://mukhortov.com/
* Author: James Bradford
* Author URI: http://arniebradfo.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* GitHub Branch: master
* GitHub Plugin URI: https://github.com/mukhortov/HESH-WordPress-Plugin
* Version: 1.7.1
* Requires at least: 4.0.11
* Tested up to: 4.5.2
* Stable tag: 1.7.1
**/
if ( preg_match( '#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'] ) ) {
die('You are not allowed to call this page directly.');
}
define( 'HESH_LIBS', plugins_url( '/lib/', __FILE__ ) );
class wp_html_editor_syntax {
public function __construct () {
add_action( 'admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts' ) );
}
// Enqueues scripts and styles for hesh.js
public function admin_enqueue_scripts () {
if ( !post_type_supports( get_post_type(), 'editor' ) ) return;
$ver = get_plugin_data( __FILE__ )['Version'];
wp_enqueue_style( 'codemirror', HESH_LIBS.'codemirror.min.css', false, $ver );
wp_enqueue_style( 'heshcss', HESH_LIBS.'hesh.min.css', false, $ver );
wp_register_script( 'codemirror', HESH_LIBS.'codemirror.min.js', false, $ver, true );
wp_enqueue_script( 'codemirror' );
wp_register_script( 'heshjs', HESH_LIBS.'hesh.min.js', array('codemirror'), $ver, true );
wp_enqueue_script( 'heshjs' );
}
}
if (is_admin()) {
$hesh = new wp_html_editor_syntax();
}
?>