本文整理汇总了PHP中NewsletterSubscription类的典型用法代码示例。如果您正苦于以下问题:PHP NewsletterSubscription类的具体用法?PHP NewsletterSubscription怎么用?PHP NewsletterSubscription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NewsletterSubscription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instance
/**
* @return NewsletterSubscription
*/
static function instance()
{
if (self::$instance == null) {
self::$instance = new NewsletterSubscription();
}
return self::$instance;
}
示例2: 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');
}
}
}
示例3: 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;
}
}
示例4: actionUnsuscribe
public function actionUnsuscribe($token)
{
$entry = unserialize(base64_decode($token));
if (!($model = NewsletterSubscription::model()->findByAttributes(array('id' => (int) $entry['id'], 'email' => $entry['email'])))) {
throw new CHttpException(403);
} else {
$model->delete();
}
$this->render('unsuscribe');
}
示例5: 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);
}
}
}
}
}
}
示例6: 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')) {
require_once '../../../../wp-load.php';
}
$user = NewsletterSubscription::instance()->check_user();
if ($user == null) {
die('No subscriber found.');
}
NewsletterSubscription::instance()->show_message('profile', $user);
示例7: 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
}
?>
示例8: get_option
for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
if (empty($options_lists['list_' . $i])) {
continue;
}
$lists['' . $i] = '(' . $i . ') ' . $options_lists['list_' . $i];
}
if ($controls->is_action('resend')) {
$user = NewsletterUsers::instance()->get_user($controls->button_data);
$opts = get_option('newsletter');
NewsletterSubscription::instance()->mail($user->email, $newsletter->replace($opts['confirmation_subject'], $user), $newsletter->replace($opts['confirmation_message'], $user));
$controls->messages = 'Activation email resent to ' . $user->email;
}
if ($controls->is_action('resend_welcome')) {
$user = NewsletterUsers::instance()->get_user($controls->button_data);
$opts = get_option('newsletter');
NewsletterSubscription::instance()->mail($user->email, $newsletter->replace($opts['confirmed_subject'], $user), $newsletter->replace($opts['confirmed_message'], $user));
$controls->messages = 'Welcome email resent.';
}
if ($controls->is_action('remove')) {
$wpdb->query($wpdb->prepare("delete from " . NEWSLETTER_USERS_TABLE . " where id=%d", $controls->button_data));
unset($controls->data['subscriber_id']);
}
// We build the query condition
$where = "where 1=1";
$query_args = array();
$text = trim($controls->data['search_text']);
if ($text != '') {
$query_args[] = '%' . $text . '%';
$query_args[] = '%' . $text . '%';
$query_args[] = '%' . $text . '%';
$where .= " and (email like %s or name like %s or surname like %s)";
示例9: widget
function widget($args, $instance)
{
global $newsletter;
extract($args);
echo $before_widget;
// Filters are used for WPML
if (!empty($instance['title'])) {
$title = apply_filters('widget_title', $instance['title'], $instance);
echo $before_title . $title . $after_title;
}
$buffer = apply_filters('widget_text', $instance['text'], $instance);
$options = get_option('newsletter');
$options_profile = get_option('newsletter_profile');
if (stripos($instance['text'], '<form') === false) {
$form = NewsletterSubscription::instance()->get_form_javascript();
$form .= '<div class="newsletter newsletter-widget">';
$form .= NewsletterWidget::get_widget_form();
$form .= '</div>';
// Canot user directly the replace, since the form is different on the widget...
if (strpos($buffer, '{subscription_form}') !== false) {
$buffer = str_replace('{subscription_form}', $form, $buffer);
} else {
if (strpos($buffer, '{subscription_form_') !== false) {
// TODO: Optimize with a method to replace only the custom forms
$buffer = $newsletter->replace($buffer);
} else {
$buffer .= $form;
}
}
} else {
$buffer = str_ireplace('<form', '<form method="post" action="' . esc_attr(plugins_url('newsletter/do/subscribe.php')) . '" onsubmit="return newsletter_check(this)"', $buffer);
$buffer = str_ireplace('</form>', '<input type="hidden" name="nr" value="widget"/></form>', $buffer);
}
// That replace all the remaining tags
$buffer = $newsletter->replace($buffer);
echo $buffer;
echo $after_widget;
}
示例10: unset
global $logger;
unset($_SESSION['bookingDetails']);
$logger->LogInfo(__FILE__);
$logger->LogDebug("Script is starting ...");
$errorMessage = "";
$successMessage = "";
if (sizeof($_POST) > 0) {
$logger->LogInfo("Processing newsletter subscription ...");
$systemConfiguration->assertReferer();
if (isset($_POST['email'])) {
$emailAddress = trim($_POST['email']);
$logger->LogDebug("Email address for newsletter was specified.");
$logger->LogDebug($emailAddress);
$subscription = NewsletterSubscription::fetchFromDbForEmail($emailAddress);
if ($subscription == null) {
$subscription = new NewsletterSubscription();
}
$subscription->email = $emailAddress;
$subscription->isActive = true;
$logger->LogDebug("Saving subscription ...");
if ($subscription->save()) {
$logger->LogDebug("Saving is successful.");
$successMessage = HOME_BOX_BOTTOM_LEFT_SUCCESS;
} else {
$logger->LogError("Saving FAILED!");
$logger->LogError($subscription->errors);
$errorMessage = BOOKING_DETAILS_EMAIL_INVALID;
}
}
}
$logger->LogDebug("Starting HTML ...");
示例11: array
<?php
// TODO: Uncomment
include "access.php";
include_once "../includes/SystemConfiguration.class.php";
global $systemConfiguration;
global $logger;
$id = 0;
$errors = array();
$logger->LogInfo("Attempting to deactivate newsletter subscription ...");
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$id = intval($_GET['id']);
if (!NewsletterSubscription::deactivate($id)) {
$logger->LogError("Error deactivating newsletter subscription.");
foreach (NewsletterSubscription::$staticErrors as $error) {
$logger->LogError($error);
$errors[] = $error;
}
} else {
header("Location: newsletter_subscriptions_list.php");
}
} else {
$errors[] = "Invalid request: Newsletter Subscription id was not set";
$logger->LogError("Newsletter Subscription id is not set.");
}
include "header.php";
?>
</td>
</tr>
示例12: 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();
?>
示例13: 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();
?>
示例14: isValid
public function isValid()
{
$this->errors = array();
if (!preg_match(Client::$EMAIL_REGEX, $this->email)) {
$this->setError(BOOKING_DETAILS_EMAIL_INVALID);
} else {
$sub = NewsletterSubscription::fetchFromDbForEmail($this->email);
if ($sub != null && $sub->id != $this->id) {
$this->setError("Subscription with email: " . $this->email . " already exists");
}
}
return sizeof($this->errors) == 0;
}
示例15: hook_subscription_user_register
function hook_subscription_user_register($wp_user_id)
{
global $wpdb;
// If the integration is disabled...
if ($this->options['subscribe'] == 0) {
return;
}
// If not forced and the user didn't choose the newsletter...
if ($this->options['subscribe'] != 1) {
if (!isset($_REQUEST['newsletter'])) {
return;
}
}
$this->logger->info('Adding a registered WordPress user (' . $wp_user_id . ')');
$wp_user = $wpdb->get_row($wpdb->prepare("select * from {$wpdb->users} where id=%d limit 1", $wp_user_id));
if (empty($wp_user)) {
$this->logger->error('User not found?!');
return;
}
// Yes, some registration procedures allow empty email
if (!$this->is_email($wp_user->user_email)) {
return;
}
$_REQUEST['ne'] = $wp_user->user_email;
$_REQUEST['nr'] = 'registration';
// Upon registration there is no last name and first name, sorry.
// $status is determined by the opt in
$user = NewsletterSubscription::instance()->subscribe(null, $this->options['confirmation'] == 1);
// Now we associate it with wp
$this->set_user_wp_user_id($user->id, $wp_user_id);
}