最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Undefined cache functions in my custom plugin

programmeradmin6浏览0评论

I am making a plugin that make a HTTP call to my API, I want this call be cached an tried using this way:

static function get_info(){
    $cache = wp_cache_get( $username, "action" );
    if(!cache){
        $cache = file_get_contents(...);
        wp_cache_set( $username, $cache, "action", 900 );
    }
    return $cache;
}

When I run this code (this php file are inside my plugin) I am getting

"Fatal error: Uncaught Error: Call to undefined function wp_cache_get()"

I have to maque a require from wp-includes.php cache file? Or maybe I am missing something.

发布评论

评论列表(0)

  1. 暂无评论