imageup.php,main.php · 小六/UEditor-KityFormula for wordpress - Gitee.com

/**

* Plugin Name: UEditor-KityFormula

* Plugin URI: http://www.yangshengliang.com

* Description: 百度开源富文本编辑器UEditor-KityFormula for wordpress!此插件最早由taoqili开发,SamLiu改进,两位作者均不再发布更新版本,大山在其基础上更新到1.4.3版本,bmqy沿用更新至1.4.3.3。jinaYang在前几位的基础上,添加了百度数学公式插件kityformula,使之进一步完善。

* Version: 2.0.1

* Author: 大山, SamLiu, taoqili, bmqy, jinaYang

* Author URI: http://www.yangshengliang.com

*/

@include_once( dirname( __FILE__ ) . "/ueditor.class.php" );

if ( class_exists( "UEditor" ) ) {

$ueditor_lang = 'en';

if( stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'zh-cn') !== false){

$ueditor_lang = 'zh-cn';

}

$ue = new UEditor("postdivrich",array(

//此处可以配置编辑器的所有配置项,配置方法同editor_config.js

"toolbars"=>array(

array('fullscreen', 'source', '|', 'undo', 'redo', '|',

'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall'),

array('customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',

'insertcode', '|',

'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',

'indent', 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',

'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',

'template', 'background'),

array('link', 'unlink', 'anchor', '|',

'simpleupload', 'insertimage', 'scrawl', 'insertvideo', 'music', 'attachment', 'pagebreak', '|',

'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',

'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|', 'searchreplace', 'drafts', 'help','kityformula')

)

,'lang'=>$ueditor_lang

,"focus"=>true

,"textarea"=>"content"

,"zIndex"=>1

,"initialFrameHeight"=>320 //初始化编辑器高度,默认320

,"wordCount"=>false //是否开启字数统计

,"autoHeightEnabled"=>false // 是否自动长高,默认true

//是否可以拉伸长高,默认true(当开启时,自动长高失效)

,"scaleEnabled"=>true

//浮动时工具栏距离浏览器顶部的高度,用于某些具有固定头部的页面

,"topOffset"=>32

,"minFrameHeight"=>320 //编辑器拖动时最小高度,默认220

,"initialStyle"=>'p{font-size:14px;line-height:1.8;}'//编辑器层级的基数,可以用来改变字体等

,"catchRemoteImageEnable"=>false //设置是否抓取远程图片

));

register_activation_hook( __FILE__, array( &$ue, 'ue_closeDefaultEditor' ) );

register_deactivation_hook( __FILE__, array( &$ue, 'ue_openDefaultEditor' ) );

add_action("wp_head",array(&$ue,'ue_importSyntaxHighlighter'));

add_action("wp_footer",array(&$ue,'ue_syntaxHighlighter'));

add_action("admin_head",array(&$ue,'ue_importUEditorResource'));

add_action('edit_form_advanced', array(&$ue, 'ue_renderUEditor'));

add_action('edit_page_form', array(&$ue, 'ue_renderUEditor'));

add_action( 'plugins_unload', array(&$ue, 'ue_openDefaultEditor'));

add_filter('the_editor', 'enable_ueditor');

}

function enable_ueditor($editor_box){

if( strpos($editor_box, 'wp-content-editor-container') > 0 ){

$js=<<

var ueditor_container = document.getElementById('postdivrich');

var editor_content = document.getElementById('content');

var ueditor_content_container = document.createElement('script');

var wp_ueditor_content = editor_content.defaultValue;

ueditor_container.appendChild(ueditor_content_container);

ueditor_content_container.setAttribute('id', 'postdivrich');

ueditor_content_container.setAttribute('class', 'postarea');

ueditor_content_container.setAttribute('type', 'text/plain');

ueditor_container.removeAttribute('id');

ueditor_container.removeAttribute('class');

var mce_container = document.getElementById("wp-content-wrap");

mce_container.parentNode.removeChild(mce_container);

js_enable_ueditor;

return $editor_box.$js;

}

return $editor_box;

}

function UEditorAjaxGetHandler(){

include_once( dirname( __FILE__ ) . "/ueditor/php/imageManager.php" );

exit;

}

add_action( 'wp_ajax_ueditor_get', 'UEditorAjaxGetHandler' );

// Should return an array in the style of array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename )

function ueditor_mime_types($mime_types ){

$types = array(

'apk' => 'application/android binary'

);

return array_merge($types, $mime_types);

}

add_filter( 'mime_types', 'ueditor_mime_types' );

function UEditorAjaxPostHandler(){

switch($_REQUEST['method']){

case 'imageUp':

include_once( dirname( __FILE__ ) . "/ueditor/php/imageUp.php" );

break;

case 'scrawlUp':

include_once( dirname( __FILE__ ) . "/ueditor/php/scrawlUp.php" );

break;

case 'fileUp':

include_once( dirname( __FILE__ ) . "/ueditor/php/fileUp.php" );

break;

case 'getRemoteImage':

include_once( dirname( __FILE__ ) . "/ueditor/php/getRemoteImage.php" );

break;

case 'wordImage':

include_once( dirname( __FILE__ ) . "/ueditor/php/wordImage.php" );

break;

case 'onekey':

include_once( dirname( __FILE__ ) . "/ueditor/php/onekeyUp.php" );

break;

default:

break;

}

exit;

}

add_action( 'wp_ajax_ueditor_post', 'UEditorAjaxPostHandler' );

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值