Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.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
Wordpress 寄存器\激活\未调用挂钩可调用函数_Wordpress - Fatal编程技术网

Wordpress 寄存器\激活\未调用挂钩可调用函数

Wordpress 寄存器\激活\未调用挂钩可调用函数,wordpress,Wordpress,我试图调用一个可调用函数,当插件被激活时,该函数将写入一个文件 这是我的密码 register_activation_hook( __FILE__, 'ordero_create'); function ordero_create(){ $file = plugin_dir_path( __FILE__ ) . '/errors.txt'; $open = fopen( $file, "a" ); 使用上述代码,插件已成功激活,但未调用ordero_create()函数 当我将寄存器\u

我试图调用一个可调用函数,当插件被激活时,该函数将写入一个文件

这是我的密码

register_activation_hook( __FILE__, 'ordero_create');

function ordero_create(){

$file = plugin_dir_path( __FILE__ ) . '/errors.txt'; 
$open = fopen( $file, "a" );
使用上述代码,插件已成功激活,但未调用ordero_create()函数

当我将寄存器\u激活\u钩子更改为这样时

register_activation_hook( __FILE__, ordero_create());
插件已成功激活,并且正在调用ordero_create()函数。但也有类似的警告

The plugin generated 230 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
我确信在
?>
之后或
之前没有空格或新行。最后,问题解决了

之前我有两个文件index.php,其中包含标准wordpress插件初始化,调用另一个包含主代码的php文件

    <?php
/*
Plugin Name: tes
Plugin URI: xxx
Description: xxx
Version: 1.0.1
Author: xxx
Author URI: xxx
License: 
    Copyright 2020 xxx


Logs:
v1.0
- Release first version.
*/
include_once('tes.php');
?>

然后在tes.php上

<?php
register_activation_hook( __FILE__, 'ordero_tb_create');



function ordero_tb_create(){

$file = plugin_dir_path( __FILE__ ) . '/errors.txt'; 
$open = fopen( $file, "a" ); 
}
?>

在我将这两个文件合并成一个文件后,它的工作方式应该是这样的

最后,它被解决了

之前我有两个文件index.php,其中包含标准wordpress插件初始化,调用另一个包含主代码的php文件

    <?php
/*
Plugin Name: tes
Plugin URI: xxx
Description: xxx
Version: 1.0.1
Author: xxx
Author URI: xxx
License: 
    Copyright 2020 xxx


Logs:
v1.0
- Release first version.
*/
include_once('tes.php');
?>

然后在tes.php上

<?php
register_activation_hook( __FILE__, 'ordero_tb_create');



function ordero_tb_create(){

$file = plugin_dir_path( __FILE__ ) . '/errors.txt'; 
$open = fopen( $file, "a" ); 
}
?>


当我把这两个文件合并成一个文件后,它的工作应该是这样的

你能提供整个函数体吗?你能提供整个函数体吗?