-
Notifications
You must be signed in to change notification settings - Fork 7
/
tinymce.php
59 lines (56 loc) · 1.37 KB
/
tinymce.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
<?php
/*
* @Author: iowen
* @Author URI: https://www.iowen.cn/
* @Date: 2020-03-19 17:36:40
* @LastEditors: iowen
* @LastEditTime: 2022-08-05 23:51:14
* @FilePath: \io-code-highlight\tinymce.php
* @Description:
*/
defined('ABSPATH') || die;
/**
* 添加经典编辑器内容
*
* @return void
*/
function io_code_add_buttons() {
if (get_user_option('rich_editing') == 'true') {
add_filter( 'mce_external_plugins', 'io_code_plugin_tinymce_js' );
add_filter( 'mce_buttons', 'io_code_plugin_register_tinymce_button' );
add_filter( 'mce_css', 'io_code_plugin_mce_css' );
}
}
add_action('admin_init', 'io_code_add_buttons');
/**
* 加载 css
*
* @param mixed $mce_css
* @return string
*/
function io_code_plugin_mce_css( $mce_css ) {
if ( ! empty( $mce_css ) )
$mce_css .= ',';
$mce_css .= IOTHEME_BLOCK_URL . '/assets/css/tinymce-style.css?v=' . IOTHEME_BLOCK_VERSION ;
return $mce_css;
}
/**
* 添加按钮
*
* @param mixed $buttons
* @return array
*/
function io_code_plugin_register_tinymce_button($buttons) {
array_push($buttons, "io_code_high");
return $buttons;
}
/**
* 添加 js
*
* @param mixed $plugin_array
* @return mixed
*/
function io_code_plugin_tinymce_js($plugin_array){
$plugin_array['io_code_button'] = IOTHEME_BLOCK_URL . '/assets/js/tinymce-plugin.js?v=' . IOTHEME_BLOCK_VERSION ;
return $plugin_array;
}