自定义Wordpress插件

自定义Wordpress插件

本文介绍了自定义Wordpress插件-如何在帖子编辑器的弹出窗口中插入内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为WordPress创建了自己的插件,但是它并不完全起作用.我的目标是在帖子编辑器"中添加一个附加按钮,该按钮可让您将图像(从计算机上传并在上传后自动修改)插入帖子.

I've created my own plugin for WordPress, but it's not completely functional. My goal is to add an additional button to the Post Editor that allows you to insert an image (that you upload from your computer, and automatically gets modified after upload) into the post.

单击按钮时,将显示我在插件中创建的弹出窗口.我经历了上传过程,然后上传并修改了图像.现在,如何将图片插入帖子中?

When you click on the button, my popup that I created in my plugin shows up. I go through the upload process and the image is uploaded and modified. Now, how do I insert the image into the post?

到目前为止,这是我的代码:

This is my code so far:

function insertHeader(imageURL){
    text = '<div style="text-align:center;"><img src="'+imageURL+'"/></div>';
    tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, text);
}

但是显然它不起作用.我似乎找不到很好的教程来向您展示如何操作.到目前为止,仅通过查看其他插件即可.

But obviously it doesn't work. I can't seem to find a good tutorial that shows you how. I've got this far just by looking at other plugins.

推荐答案

尝试从wp-admin的media-upload.php和upload.php获取想法

try getting idea from the media-upload.php and upload.php of wp-admin

这篇关于自定义Wordpress插件-如何在帖子编辑器的弹出窗口中插入内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 22:24