本文整理汇总了PHP中NewsletterSubscription::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP NewsletterSubscription::instance方法的具体用法?PHP NewsletterSubscription::instance怎么用?PHP NewsletterSubscription::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NewsletterSubscription
的用法示例。
在下文中一共展示了NewsletterSubscription::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade
function upgrade()
{
parent::upgrade();
if ($this->old_version < '1.0.2') {
// Locked content configuration migration
$old_options = Newsletter::instance()->get_options();
if (isset($old_options['lock_message']) || isset($old_options['lock_ids']) || isset($old_options['lock_url'])) {
$this->options['ids'] = $old_options['lock_ids'];
$this->options['url'] = $old_options['lock_url'];
$this->options['message'] = $old_options['lock_message'];
$this->options['enabled'] = 1;
$this->save_options($this->options);
unset($old_options['lock_ids']);
unset($old_options['lock_url']);
unset($old_options['lock_message']);
Newsletter::instance()->save_options($old_options);
}
$old_options = NewsletterSubscription::instance()->get_options('lock');
if (!empty($old_options)) {
$this->options['ids'] = $old_options['ids'];
$this->options['url'] = $old_options['url'];
$this->options['message'] = $old_options['message'];
$this->options['enabled'] = 1;
$this->save_options($this->options);
NewsletterSubscription::instance()->delete_options('lock');
}
}
}
示例2: hook_wp_loaded
function hook_wp_loaded()
{
global $newsletter, $wpdb;
switch ($newsletter->action) {
case 'v':
// TODO: Change to Newsletter::instance()->get:email(), not urgent
$email = $this->get_email((int) $_GET['id']);
if (empty($email)) {
die('Email not found');
}
if ($email->private == 1) {
die('Email not found');
}
$user = NewsletterSubscription::instance()->get_user_from_request();
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
die;
}
echo $newsletter->replace($email->message, $user, $email->id);
die;
}
}
示例3: instance
/**
* @return NewsletterSubscription
*/
static function instance()
{
if (self::$instance == null) {
self::$instance = new NewsletterSubscription();
}
return self::$instance;
}
示例4: hook_init
function hook_init()
{
add_shortcode('newsletter_profile', array($this, 'shortcode_profile'));
add_shortcode('newsletter_subscription', array($this, 'shortcode_subscription'));
add_shortcode('newsletter_field', array($this, 'shortcode_field'));
$action = isset($_REQUEST['na']) ? $_REQUEST['na'] : '';
if (empty($action) || is_admin()) {
return;
}
if ($action == 's') {
$user = $this->subscribe();
if ($user->status == 'E') {
$this->show_message('error', $user->id);
}
if ($user->status == 'C') {
$this->show_message('confirmation', $user->id);
}
if ($user->status == 'S') {
$this->show_message('confirmed', $user->id);
}
} else {
if ($action == 'c') {
$user = NewsletterSubscription::instance()->confirm();
$this->show_message('confirmed', $user);
} else {
if ($action == 'u') {
$user = $this->get_user_from_request();
if ($user == null) {
die('No subscriber found.');
}
$this->show_message('unsubscription', $user->id);
} else {
if ($action == 'uc') {
$user = $this->unsubscribe();
if ($user->status == 'E') {
$this->show_message('error', $user->id);
} else {
$this->show_message('unsubscribed', $user);
}
} else {
if ($action == 'p' || $action == 'pe') {
$user = $this->get_user_from_request();
if ($user == null) {
die('No subscriber found.');
}
$this->show_message('profile', $user);
}
}
}
}
}
}
示例5:
<div class="notice">
<a href="<?php
echo $_SERVER['REQUEST_URI'] . '&dismiss=rate';
?>
" class="dismiss">×</a>
<p>
We never asked before and we're curious: <a href="http://wordpress.org/extend/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
(few seconds required - account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
</p>
</div>
<?php
}
?>
<?php
if (NEWSLETTER_DEBUG || !isset($dismissed['newsletter-page']) && empty(NewsletterSubscription::instance()->options['url'])) {
?>
<div class="notice">
<a href="<?php
echo $_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page';
?>
" class="dismiss">×</a>
<p>
You should create a blog page to show the subscription form and the subscription messages. Go to the
<a href="?page=newsletter_subscription_options">subscription panel</a> to
configure it.
</p>
</div>
<?php
}
?>
示例6: header
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
require_once '../../../../wp-load.php';
}
if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
$user = NewsletterSubscription::instance()->unsubscribe();
if ($user->status == 'E') {
NewsletterSubscription::instance()->show_message('unsubscription_error', $user);
} else {
NewsletterSubscription::instance()->show_message('unsubscribed', $user);
}
} else {
$url = plugins_url('newsletter') . '/do/unsubscribe.php?';
foreach ($_REQUEST as $name => $value) {
$url .= urlencode($name) . '=' . urlencode($value) . '&';
}
$url .= '&ts=' . time();
?>
<!DOCTYPE html>
<html>
<head>
<script>
location.href = location.href + "&ts=<?php
echo time();
?>
示例7: time
if (!isset($module->options['antibot'])) {
$module->options['antibot'] = 0;
}
if ($module->options['antibot'] == 0 || $module->options['antibot'] == 1 && isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
$user = NewsletterSubscription::instance()->subscribe();
if ($user->status == 'E') {
NewsletterSubscription::instance()->show_message('error', $user->id);
}
if ($user->status == 'C') {
NewsletterSubscription::instance()->show_message('confirmed', $user->id);
}
if ($user->status == 'A') {
NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
}
if ($user->status == 'S') {
NewsletterSubscription::instance()->show_message('confirmation', $user->id);
}
} else {
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="document.getElementById('form').action = '?ts=<?php
echo time();
?>
';document.getElementById('form').submit()">
<form id="form" action="<?php
echo plugins_url('newsletter');
?>
示例8: grab
function grab()
{
global $wpdb, $current_user, $newsletter;
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
return;
}
for ($i = 0; $i < $this->rules_max; $i++) {
if (!isset($this->options['rule_' . $i . '_enabled'])) {
continue;
}
if ($this->options['rule_' . $i . '_enabled'] != 1) {
continue;
}
$field = trim($this->options['rule_' . $i . '_check_field']);
if (empty($field) || !isset($_POST[$field])) {
continue;
}
$value = $this->options['rule_' . $i . '_check_value'];
//if (!empty($value) && $value != $_POST[$field])
// continue;
add_option($this->prefix . '_data', array(), null, 'no');
$data = array();
$data['ip'] = $_SERVER['REMOTE_ADDR'];
$data['time'] = time();
if (isset($this->options['rule_' . $i . '_auto'])) {
foreach ($_POST as $key => $value) {
if (!NewsletterModule::is_email($value)) {
continue;
}
$_REQUEST['ne'] = $value;
$user = NewsletterSubscription::instance()->subscribe();
$data['email'] = $value;
update_option($this->prefix . '_data', $data);
return;
}
} else {
if (is_user_logged_in()) {
get_currentuserinfo();
}
$email = sanitize_email($_POST[$this->options['rule_' . $i . '_email_field']]);
if (empty($email) && is_user_logged_in()) {
$email = $current_user->user_email;
}
$check = sanitize_text_field($_POST[$this->options['rule_' . $i . '_check_field']]);
if (!Newsletter::is_email($email)) {
continue;
}
$_REQUEST['ne'] = $email;
$user = NewsletterSubscription::instance()->subscribe();
$data['email'] = $email;
update_option($this->prefix . '_data', $data);
if (!empty($current_user->user_email) && $check === 'No, I can remember') {
$wpdb->query($wpdb->prepare("update " . NEWSLETTER_USERS_TABLE . " set status='U', email=%s", $current_user->user_email));
} else {
if (!empty($current_user->user_email) && $check === 'Yes, I want Updates') {
$wpdb->query($wpdb->prepare("update " . NEWSLETTER_USERS_TABLE . " set status='C', email=%s", $current_user->user_email));
}
}
}
}
}
示例9: wp_nonce_url
?>
<div class="newsletter-notice">
I never asked before and I'm curious: <a href="http://wordpress.org/extend/plugins/newsletter/" target="_blank">would you rate this plugin</a>?
(few seconds required). (account on WordPress.org required, every blog owner should have one...). <strong>Really appreciated, The Newsletter Team</strong>.
<div class="newsletter-dismiss"><a href="<?php
echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=rate');
?>
">Dismiss</a></div>
<div style="clear: both"></div>
</div>
<?php
}
?>
<?php
if (isset($dismissed['newsletter-page']) && $dismissed['newsletter-page'] != 1 && empty(NewsletterSubscription::instance()->options['url'])) {
?>
<div class="newsletter-notice">
Create a page with your blog style to show the subscription form and the subscription messages. Go to the
<a href="?page=newsletter_subscription_options">subscription panel</a> to
configure it.
<div class="newsletter-dismiss"><a href="<?php
echo wp_nonce_url($_SERVER['REQUEST_URI'] . '&dismiss=newsletter-page');
?>
">Dismiss</a></div>
<div style="clear: both"></div>
</div>
<?php
}
?>
示例10: htmlspecialchars
</div>
<div id="tabs-5">
<p>This panel shows the form HTML code generated by Newsletter if you want to copy it as starting point for a custom form.</p>
<h3>Standard form code</h3>
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php
echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form());
?>
</textarea>
<h3>Widget form code</h3>
<textarea readonly style="width: 100%; height: 500px; font-family: monospace"><?php
echo htmlspecialchars(NewsletterSubscription::instance()->get_subscription_form());
?>
</textarea>
</div>
<div id="tabs-6">
<table class="form-table">
<tr>
<th>Subscription form style</th>
<td>
<?php
$controls->select('style', $module->get_styles());
?>
</td>
示例11: header
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
require_once '../../../../wp-load.php';
}
if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
$user = NewsletterSubscription::instance()->confirm();
if ($user->status == 'E') {
NewsletterSubscription::instance()->show_message('error', $user->id);
} else {
NewsletterSubscription::instance()->show_message('confirmed', $user);
}
} else {
$url = plugins_url('newsletter') . '/do/confirm.php?';
foreach ($_REQUEST as $name => $value) {
$url .= urlencode($name) . '=' . urlencode($value) . '&';
}
$url .= '&ts=' . time();
?>
<!DOCTYPE html>
<html>
<head>
<script>
location.href = location.href + "&ts=<?php
echo time();
?>
示例12: header
<?php
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
// Patch to avoid "na" parameter to disturb the call
unset($_REQUEST['na']);
unset($_POST['na']);
unset($_GET['na']);
if (!defined('ABSPATH')) {
include '../../../../wp-load.php';
}
$user = NewsletterSubscription::instance()->check_user();
if ($user == null || $user->status != 'C') {
echo 'Subscriber not found, sorry.';
die;
}
$options_main = get_option('newsletter_main', array());
setcookie('newsletter', $user->id . '-' . $user->token, time() + 60 * 60 * 24 * 365, '/');
header('Location: ' . $options_main['lock_url']);
die;
示例13: array
if (empty($nl_user->wp_user_id)) {
$module->logger->info('Linked');
$module->set_user_wp_user_id($nl_user->id, $wp_user->id);
continue;
}
}
$module->logger->info('New subscriber created');
// Create a new subscriber
$nl_user = array();
$nl_user['email'] = $module->normalize_email($wp_user->user_email);
$nl_user['name'] = $wp_user->user_login;
$nl_user['status'] = $controls->data['align_wp_users_status'];
$nl_user['wp_user_id'] = $wp_user->id;
$nl_user['referrer'] = 'wordpress';
// Adds the force subscription preferences
$preferences = NewsletterSubscription::instance()->options['preferences'];
if (is_array($preferences)) {
foreach ($preferences as $p) {
$nl_user['list_' . $p] = 1;
}
}
$module->save_user($nl_user);
$count++;
}
$controls->messages = count($wp_users) . ' ' . __('WordPress users processed', 'newsletter-users') . '. ';
$controls->messages .= $count . ' ' . __('subscriptions added', 'newsletter-users') . '.';
}
if ($controls->is_action('bounces')) {
$lines = explode("\n", $controls->data['bounced_emails']);
$total = 0;
$marked = 0;
示例14: replace
/**
* Replace any kind of newsletter placeholder in a text.
*/
function replace($text, $user = null, $email_id = null, $referrer = null)
{
global $wpdb;
$this->logger->debug('Replace start');
if (is_array($user)) {
$user = $this->get_user($user['id']);
}
$email = null;
if (is_numeric($email_id)) {
$email = $this->get_email($email_id);
}
$text = apply_filters('newsletter_replace', $text, $user, $email);
//$text = str_replace('{home_url}', get_option('home'), $text);
//$text = str_replace('{blog_url}', get_option('home'), $text);
$text = $this->replace_url($text, 'BLOG_URL', get_option('home'));
$text = $this->replace_url($text, 'HOME_URL', get_option('home'));
$text = str_replace('{blog_title}', get_option('blogname'), $text);
$text = str_replace('{blog_description}', get_option('blogdescription'), $text);
$text = $this->replace_date($text);
if ($user != null) {
$options_profile = get_option('newsletter_profile');
$text = str_replace('{email}', $user->email, $text);
if (empty($user->name)) {
$text = str_replace(' {name}', '', $text);
$text = str_replace('{name}', '', $text);
} else {
$text = str_replace('{name}', $user->name, $text);
}
switch ($user->sex) {
case 'm':
$text = str_replace('{title}', $options_profile['title_male'], $text);
break;
case 'f':
$text = str_replace('{title}', $options_profile['title_female'], $text);
break;
case 'n':
$text = str_replace('{title}', $options_profile['title_none'], $text);
break;
default:
$text = str_replace('{title}', '', $text);
}
$text = str_replace('{surname}', $user->surname, $text);
$text = str_replace('{last_name}', $user->surname, $text);
$full_name = trim($user->name . ' ' . $user->surname);
if (empty($full_name)) {
$text = str_replace(' {full_name}', '', $text);
$text = str_replace('{full_name}', '', $text);
} else {
$text = str_replace('{full_name}', $full_name, $text);
}
$text = str_replace('{token}', $user->token, $text);
$text = str_replace('%7Btoken%7D', $user->token, $text);
$text = str_replace('{id}', $user->id, $text);
$text = str_replace('%7Bid%7D', $user->id, $text);
$text = str_replace('{ip}', $user->ip, $text);
$text = str_replace('{key}', $user->id . '-' . $user->token, $text);
$text = str_replace('%7Bkey%7D', $user->id . '-' . $user->token, $text);
if (strpos($text, '{profile_form}') !== false) {
$text = str_replace('{profile_form}', NewsletterSubscription::instance()->get_profile_form($user), $text);
}
for ($i = 1; $i < NEWSLETTER_PROFILE_MAX; $i++) {
$p = 'profile_' . $i;
$text = str_replace('{profile_' . $i . '}', $user->{$p}, $text);
}
// $profile = $wpdb->get_results("select name,value from " . $wpdb->prefix . "newsletter_profiles where newsletter_id=" . $user->id);
// foreach ($profile as $field) {
// $text = str_ireplace('{np_' . $field->name . '}', htmlspecialchars($field->value), $text);
// }
//
// $text = preg_replace('/\\{np_.+\}/i', '', $text);
$base = empty($this->options_main['url']) ? get_option('home') : $this->options_main['url'];
$id_token = '&ni=' . $user->id . '&nt=' . $user->token;
$nk = $user->id . '-' . $user->token;
$options_subscription = NewsletterSubscription::instance()->options;
if (!empty($options_subscription['action_url'])) {
$home_url = home_url();
//$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', self::add_qs(plugins_url('do.php', __FILE__), 'a=c' . $id_token));
$text = $this->replace_url($text, 'SUBSCRIPTION_CONFIRM_URL', $home_url . '?na=c&nk=' . $nk);
$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', $home_url . '?na=uc&nk=' . $nk);
//$text = $this->replace_url($text, 'UNSUBSCRIPTION_CONFIRM_URL', NEWSLETTER_URL . '/do/unsubscribe.php?nk=' . $nk);
$text = $this->replace_url($text, 'UNSUBSCRIPTION_URL', $home_url . '?na=u&nk=' . $nk);
$text = $this->replace_url($text, 'CHANGE_URL', plugins_url('newsletter/do/change.php'));
// Obsolete.
$text = $this->replace_url($text, 'FOLLOWUP_SUBSCRIPTION_URL', self::add_qs($base, 'nm=fs' . $id_token));
$text = $this->replace_url($text, 'FOLLOWUP_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=fu' . $id_token));
$text = $this->replace_url($text, 'FEED_SUBSCRIPTION_URL', self::add_qs($base, 'nm=es' . $id_token));
$text = $this->replace_url($text, 'FEED_UNSUBSCRIPTION_URL', self::add_qs($base, 'nm=eu' . $id_token));
if (empty($options_profile['profile_url'])) {
$text = $this->replace_url($text, 'PROFILE_URL', $home_url . '?na=p&nk=' . $nk);
} else {
$text = $this->replace_url($text, 'PROFILE_URL', self::add_qs($options_profile['profile_url'], 'ni=' . $user->id . '&nt=' . $user->token));
}
//$text = $this->replace_url($text, 'UNLOCK_URL', self::add_qs($this->options_main['lock_url'], 'nm=m' . $id_token));
$text = $this->replace_url($text, 'UNLOCK_URL', $home_url . '?na=ul&nk=' . $nk);
if (!empty($email_id)) {
$text = $this->replace_url($text, 'EMAIL_URL', $home_url . '?na=v&id=' . $email_id . '&nk=' . $nk);
}
//.........这里部分代码省略.........
示例15: header
<?php
/**
* This is a generic viewer for sent emails. It is not binded to one shot emails, it can display even the emails from
* updates or feed by mail module.
*/
header('Content-Type: text/html;charset=UTF-8');
header('X-Robots-Tag: noindex,nofollow,noarchive');
header('Cache-Control: no-cache,no-store,private');
include '../../../../wp-load.php';
// TODO: Change to Newsletter::instance()->get:email(), not urgent
$email = Newsletter::instance()->get_email((int) $_GET['id']);
if (empty($email)) {
die('Email not found');
}
$user = NewsletterSubscription::instance()->get_user_from_request();
if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/view.php')) {
include WP_CONTENT_DIR . '/extensions/newsletter/view.php';
die;
}
echo $newsletter->replace($email->message, $user, $email->id);