wordpress - 如何自定义添加媒体按钮,单击wordpress中的按钮后在弹出窗口中弹出我的自定义html
问题描述
我有下面的代码。我需要一个按钮,例如在管理员的编辑页面中添加媒体,单击时会显示一个弹出窗口并显示我的自定义 html,其中包含一个表单。
我在下面尝试过,但我得到了不必要的东西,比如上传文件选项卡、媒体库选项卡等,我不需要所有这些,但我只需要单击按钮上的自定义表单。
索引.php
function add_cp_media_button() {
echo '<a href="#" id="cp-forms-btn" class="button">cp Forms</a>';
}
function include_cp_media_button_js_file() {
wp_enqueue_script('media_button', plugins_url( '/js/cp.js', __FILE__ ), array('jquery'), '1.0', true);
}
add_action('wp_enqueue_media', 'include_cp_media_button_js_file');
cp.js
jQuery(function($) {
$(document).ready(function(){
$('#cp-forms-btn').click(open_media_window);
});
function open_media_window() {
//I want to display the form with select drop down with my names populated in the dropdown, after selecting the item, I need to insert the text to the editor.
}
});
有人可以帮我吗
解决方案
推荐阅读
- python - 我正在尝试制作一个简单的出租车费用估算器代码
- javascript - 表格单元格条件格式
- git - API 管理 GIT 流程
- java - 调用 cloudant db 服务,报错 javax.net.ssl.SSLException: Received fatal alert: protocol_version
- python - 无法不打印循环的停止值
- winapi - Windows,如何直接渲染到视频扫描输出内存?
- mysql - 如果同名计为 1,则组中的 sql 计数
- kubernetes - 去模板(掌舵,kubernetes)
- python - 如何使用 Pandas 找到两个不同日期时间之间的最小值?
- python - 从不立即加载元素的表中抓取数据