Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress插件开发_Php_Wordpress - Fatal编程技术网

Php Wordpress插件开发

Php Wordpress插件开发,php,wordpress,Php,Wordpress,我正在使用这个网站帮助我锻炼如何制作一个保存选项的插件。 这是我的代码,但它似乎不起作用。有人能给我指一下正确的方向吗 <?php /* * Plugin Name: test * Plugin URI: www.test.com * Version: 1.0 * Author: J Davies * Author URI: test.com * Description: Random Test */ function say_test(){ $greeting

我正在使用这个网站帮助我锻炼如何制作一个保存选项的插件。 这是我的代码,但它似乎不起作用。有人能给我指一下正确的方向吗

<?php 
/*
 * Plugin Name: test
 * Plugin URI: www.test.com
 * Version: 1.0
 * Author: J Davies
 * Author URI: test.com
 * Description: Random Test
 */

function say_test(){
    $greeting = get_option('test_greeting');
    print "Say ".$greeting;
}

function set_test_options(){
    add_option('test_greeting','test','test');
}

function unset_test_options(){
    delete_option('test_greeting');
}

register_activation_hook(__FILE__,'set_test_options');
register_deactivation_hook(__FILE__,'unset_test_options');
?>


我在这里看到的唯一奇怪的事情是,
add\u option()
应该只接受两个或四个参数(第三个参数为空)。设置第三个参数会导致Wordpress运行其
\u deprecated\u argument()
函数,如果处于调试模式,则会触发错误。

我发现了问题,我需要将每个函数包装为if(function\u exists())。 谢谢