我有oneplugin文件testplugin.php..它包含变量$ abc;
// main plugin.php
if(!is_admin()){
new Funtion_Button();
}
class Function_Button
{
if(is_single() || is_page() || is_home() ){
global $post;
global $wpdb;
$query_images_args = array(
'post_type' => 'attachment' , 'post_mime_type' =>'image','post_status' => 'published', 'posts_per_page' => -1,'numberposts' => 1
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image) {
$images[]= wp_get_attachment_url( $image->ID );
}
$abc[]=0;
$abc= $abc.http_build_query($images);
$_SESSION['arrayImg']=$abc;
);
}
///接收文件
include ('testplugin.php');
session_start();
$array1[]=$abc;
现在这个$ abc来自主插件页面
但是我收到了这个错误
致命错误:在第98行的C:\ wamp \ www \ wordpress \ wp-content \ plugins \ testplugin.php中调用未定义的函数is_admin()
在98行,我有 if(!is_admin()){
答案 0 :(得分:1)
使用会话:
//在testplugin.php上
session_start();
$_SESSION['varname'] = $var_value;
//在另一个档案
session_start();
$var_value = $_SESSION['varname'];
使用cookies:
//在testplugin.php上
$_COOKIE['varname'] = $var_value;
//第2页
$var_value = $_COOKIE['varname'];