本文整理匯總了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());
}
}
}