在我的插件中,当我调用选择页面时,页面是空白的

时间:2013-07-29 作者:user33913

我有问题:在我的插件目录中,我有两个文件:

  • gen.php
  • open.php
当我从gen.phpopen.php 我在中使用selectopen.php

$myrows = $wpdb->get_results("SELECT * FROM wp_ogloszenia_kupione");
无法打开我的文件我使用:

$fp = fopen(trim(trim($id)),"wb");

fwrite($fp,$content);
fwrite($fp, pack("CCC",0xef,0xbb,0xbf));
fopen(trim(trim($id)),"r");
fclose($fp);
//End 4
//5 - Otwarcie pliku



if (file_exists(trim($id))) {
    header(\'Content-Description: File Transfer\');
    header(\'Content-Type: application/octet-stream\');
    header(\'Content-Disposition: attachment; filename=\'.basename(trim($id)));
    header(\'Content-Transfer-Encoding: binary\');
    header(\'Expires: 0\');
    header(\'Cache-Control: must-revalidate\');
    header(\'Pragma: public\');
    header(\'Content-Length: \' . filesize(trim($id)));
    ob_clean();
    flush();
    readfile(trim($id));
    exit;
} 
但当我删除时,选择一切都很好。

那么,为什么select会造成这种混乱呢?

1 个回复
SO网友:M-R

您无法加载使$wpdb和其他WordPress函数在上下文中可用的文件。您可以包含一些php文件来模拟WordPress上下文

include_once(\'../../../wp-config.php\');
include_once(\'../../../wp-load.php\');
include_once(\'../../../wp-includes/wp-db.php\');

$data = $wpdb->get_results("SELECT * FROM " . $table_prefix . "posts");
var_dump($data);

结束