本文整理汇总了PHP中Redux_Functions::setCookie方法的典型用法代码示例。如果您正苦于以下问题:PHP Redux_Functions::setCookie方法的具体用法?PHP Redux_Functions::setCookie怎么用?PHP Redux_Functions::setCookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redux_Functions
的用法示例。
在下文中一共展示了Redux_Functions::setCookie方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_notice_json
private function get_notice_json()
{
// filesystem object
$filesystem = $this->parent->filesystem;
// get notice data from server
//$data = $filesystem->execute('get_contents', $this->server_file);// 'http://www.reduxframework.com/' . 'wp-content/uploads/redux/redux_notice.json');
$data = wp_remote_get($this->server_file, array('sslverify' => false));
$data = $data['body'];
// if some data exists
if ($data != '' || !empty($data)) {
// if local notice file exists
if (file_exists($this->notice_json)) {
// get cached data
$cache_data = $filesystem->execute('get_contents', $this->notice_json);
// if local and server data are same, then return
if (strcmp($data, $cache_data) == 0) {
// set new cookie for interval value
Redux_Functions::setCookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
// bail out
return;
}
}
// set server data
$params = array('content' => $data);
// write local notice file with new data
$filesystem->execute('put_contents', $this->notice_json, $params);
// set cookie for three day expiry
setcookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
// set unique key for dismiss meta key
update_option($this->cookie_id, time());
}
}
示例2: get_notice_json
private function get_notice_json()
{
// get notice data from server
$data = @wp_remote_get($this->server_file, array('sslverify' => false));
if (isset($data) && !empty($data) && !is_wp_error($data) && $data['response']['code'] == 200) {
$data = $data['body'];
// if some data exists
if ($data != '' || !empty($data)) {
if (!empty($this->notice_data)) {
if (strcmp($data, $this->notice_data) == 0) {
// set new cookie for interval value
Redux_Functions::setCookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
// bail out
return;
}
}
update_option('r_notice_data', $data);
$this->notice_data = $data;
// set cookie for three day expiry
setcookie($this->cookie_id, time(), time() + 86400 * $this->interval, '/');
// set unique key for dismiss meta key
update_option($this->cookie_id, time());
}
}
}