本文整理汇总了PHP中NewsletterModule::get_token方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsletterModule::get_token方法的具体用法?PHP NewsletterModule::get_token怎么用?PHP NewsletterModule::get_token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsletterModule
的用法示例。
在下文中一共展示了NewsletterModule::get_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($module)
{
$this->module = $module;
if (defined('NEWSLETTER_LOG_LEVEL')) {
$this->level = NEWSLETTER_LOG_LEVEL;
} else {
$this->level = get_option('newsletter_log_level', self::ERROR);
}
$secret = get_option('newsletter_logger_secret');
if (strlen($secret) < 8) {
$secret = NewsletterModule::get_token(8);
update_option('newsletter_logger_secret', $secret);
}
if (!wp_mkdir_p(NEWSLETTER_LOG_DIR)) {
$this->level = self::NONE;
}
$this->file = NEWSLETTER_LOG_DIR . '/' . $module . '-' . $secret . '.txt';
}
示例2: save_user
/**
* NEVER CHANGE THIS METHOD SIGNATURE, USER BY THIRD PARTY PLUGINS.
*
* Saves a new user on the database. Return false if the email (that must be unique) is already
* there. For a new users set the token and creation time if not passed.
*
* @param array|object $user
*/
function save_user($user, $return_format = OBJECT)
{
if (is_object($user)) {
$user = (array) $user;
}
if (empty($user['id'])) {
$existing = $this->get_user($user['email']);
if ($existing != null) {
return false;
}
if (empty($user['token'])) {
$user['token'] = NewsletterModule::get_token();
}
//if (empty($user['created'])) $user['created'] = time();
// Database default
//if (empty($user['status'])) $user['status'] = 'S';
}
// Due to the unique index on email field, this can fail.
return $this->store->save(NEWSLETTER_USERS_TABLE, $user, $return_format);
}