简单的wordpress插件与一些HTML和JavaScript

时间:2012-03-02 08:02:52

标签: wordpress wordpress-plugin

我有一个html页面,我必须转换为wordpress插件。我的代码是简单的html和javascript

<html>
<head>
    <title>Calculate</title>
    <script language="javascript">
            function addNumbers()
            {
                    var val1 = parseInt(document.getElementById("value1").value);
                    var val2 = parseInt(document.getElementById("value2").value);
                    var ansD = document.getElementById("answer");
                    ansD.value = val1 + val2;
            }
    </script>

</head>
<body>
   <input type="text" id="value1" name="value1" value="1"/>
   <input type="text" id="value2" name="value2" value="2"/>
   <input type="button" name="Sumbit" value="Click here"               
   onclick="javascript:addNumbers()"/>
   <input type="text" id="answer" name="answer" value=""/>
</body>
</html>

我知道基本的插件编写技巧,例如

<?php
/*
Plugin Name: Coding friends hello world
Plugin URI: http://www.codingfriends.com/
Description: Outputs hello world
Version: 0.1
Author: Genux
Author URI: http://www.codingfriends.com   
License: GPL2
*/

function codingfriends_helloworld()
{
//put you form here and javascript here
}

add_action('get_header', 'codingfriends_helloworld');
?> 

提前致谢

1 个答案:

答案 0 :(得分:0)

//put your form here and javascript here

^ this。

另外,在进一步阅读之前,我会仔细阅读WordPress Codex的Plugin Development部分。