很抱歉,如果之前有人问过这个问题,我想创建我自己的插件,您可以在管理面板中输入信息,这些信息会显示在您的页面上。到目前为止,我已经创建了一个新的管理菜单的形式,但它没有发送信息到我的网站。请帮我一把。
<?php
/*
Plugin Name: newsSlider-Plugin
*/
print_r($_SESSION);
add_action("admin_menu", "addMenu");
function addMenu()
{
add_menu_page("News slider", "News slider", 5, "subMenu", "changeTextFunction");
add_submenu_page("subMenu", "change style", "change style", 5, "changeStyle",
"changeStyleFunction");
}
function changeTextFunction()
{
echo "Write down the news you want to be displayed in the fields";
echo \'
<form method="post" action="">
News field 1<input type="text" name="newsSlide1">
News field 2<input type="text" name="newsSlide2">
<input type="submit" name="submit" value="Submit">
</form>\';
echo $_SESSION["favcolor"];
}
function changeStyleFunction()
{
echo "subsmenu hellooo";
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$newsSliderInput1= test_input($_POST["newsSlide1"]);
session_start();
$_SESSION["favcolor"] = "yellow";
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
add_action("the_content", "displayNewsSlider");
function displayNewsSlider()
{
echo $newsSliderInput1;
echo "hi";
echo $_SESSION["favcolor"];
}
?>