我想从我正在编写的插件中调用一些函数。我通过wordpress页面上的一个快捷码调用插件代码。首先,我只是想弹出一个“警报”窗口,比如说,如果我成功连接到数据库。最终,插件将显示一个接一个的下拉列表,后面的下拉列表将根据前面的选择填充。感谢您的帮助!我的插件中的代码如下:
<?php
/*
Plugin Name: Custom program graphs
Plugin URI: localhost/test/
Description: Creates graphs
Version: 0.1.0
Author: My Cars
*/
require_once("dbcontroller.php"); # Instantiate DB Controlling - WORKS WELL functions
function vc_connect_to_database()
{
$db_handle = new DBController();
$connection = $db_handle->connectDB();
if (!$connection)
{
return \'<h6>\' . "Unable to connect to database." . \'</h6>\';
}
# WORKS WELL IN THE CONDITION ABOVE THIS
else
{
# FAILS HERE!! HOW CAN I CALL A FUNCTION LIKE alert FROM HERE?
return window.alert("Connected to the database successfully.");
}
}
add_shortcode(\'connect_database\', \'vc_connect_to_database\');