我有一个插件文件testplugin.php.它包含变量$abc;
主要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来自主插件页
但是我得到这个错误
致命错误:调用未定义函数is_admin()在C:'wamp'www'wordpress'wp-content'plugins'testplugin.php第98行
在第98行我有 if(!is_admin()){
Using session:
在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'];