deleted plugin Subscribe2 version 10.36

This commit is contained in:
KawaiiPunk 2021-09-30 15:02:30 +00:00 committed by Gitium
parent 30f6692a58
commit 373ebbb254
64 changed files with 0 additions and 15072 deletions

View File

@ -1,14 +0,0 @@
config.codekit
.idea
.codekit-cache
/vendor/
node_modules
zip
.DS_Store
nbproject
debug.log
npm-debug.log
.netbeans.xml
.vscode
build/*
!build/index.js

View File

@ -1,143 +0,0 @@
<?php
if ( ! function_exists( 'add_action' ) ) {
exit();
}
global $current_user;
// was anything POSTed?
if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-write_subscribers' . S2VERSION ) ) {
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
}
$subject = html_entity_decode( stripslashes( wp_kses( $this->substitute( $_POST['subject'] ), '' ) ), ENT_QUOTES );
$body = wpautop( $this->substitute( stripslashes( $_POST['content'] ) ), true );
if ( '' !== $current_user->display_name || '' !== $current_user->user_email ) {
$this->myname = html_entity_decode( $current_user->display_name, ENT_QUOTES );
$this->myemail = $current_user->user_email;
}
if ( isset( $_POST['send'] ) ) {
if ( 'confirmed' === $_POST['what'] ) {
$recipients = $this->get_public();
} elseif ( 'unconfirmed' === $_POST['what'] ) {
$recipients = $this->get_public( 0 );
} elseif ( 'public' === $_POST['what'] ) {
$confirmed = $this->get_public();
$unconfirmed = $this->get_public( 0 );
$recipients = array_merge( (array) $confirmed, (array) $unconfirmed );
} elseif ( is_numeric( $_POST['what'] ) ) {
$category = intval( $_POST['what'] );
$recipients = $this->get_registered( "cats=$category" );
} elseif ( 'all_users' === $_POST['what'] ) {
$recipients = $this->get_all_registered();
} elseif ( 'all' === $_POST['what'] ) {
$confirmed = $this->get_public();
$unconfirmed = $this->get_public( 0 );
$registered = $this->get_all_registered();
$recipients = array_merge( (array) $confirmed, (array) $unconfirmed, (array) $registered );
} else {
$recipients = $this->get_registered();
}
} elseif ( isset( $_POST['preview'] ) ) {
global $user_email;
$recipients[] = $user_email;
}
$uploads = array();
if ( ! empty( $_FILES ) ) {
foreach ( $_FILES['file']['name'] as $key => $value ) {
if ( 0 === $_FILES['file']['error'][ $key ] ) {
$file = array(
'name' => $_FILES['file']['name'][ $key ],
'type' => $_FILES['file']['type'][ $key ],
'tmp_name' => $_FILES['file']['tmp_name'][ $key ],
'error' => $_FILES['file']['error'][ $key ],
'size' => $_FILES['file']['size'][ $key ],
);
$uploads[] = wp_handle_upload(
$file,
array(
'test_form' => false,
)
);
}
}
}
$attachments = array();
if ( ! empty( $uploads ) ) {
foreach ( $uploads as $upload ) {
if ( ! isset( $upload['error'] ) ) {
$attachments[] = $upload['file'];
} else {
$upload_error = $upload['error'];
}
}
}
if ( empty( $body ) ) {
$error_message = __( 'Your email was empty', 'subscribe2' );
$success = false;
} elseif ( isset( $upload_error ) ) {
$error_message = $upload_error;
$success = false;
} else {
$success = $this->mail( $recipients, $subject, $body, 'html', $attachments );
$error_message = __( 'Check your settings and check with your hosting provider', 'subscribe2' );
}
if ( $success ) {
if ( isset( $_POST['preview'] ) ) {
$message = '<p class="s2_message">' . __( 'Preview message sent!', 'subscribe2' ) . '</p>';
} elseif ( isset( $_POST['send'] ) ) {
$message = '<p class="s2_message">' . __( 'Message sent!', 'subscribe2' ) . '</p>';
}
} else {
global $phpmailer;
$message = '<p class="s2_error">' . __( 'Message failed!', 'subscribe2' ) . '</p>' . $error_message . $phpmailer->ErrorInfo;
}
echo '<div id="message" class="updated"><strong><p>' . wp_kses_post( $message ) . '</p></strong></div>' . "\r\n";
}
// show our form
echo '<div class="wrap">';
echo '<h1>' . esc_html__( 'Send an email to subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
echo '<form method="post" enctype="multipart/form-data">' . "\r\n";
wp_nonce_field( 'subscribe2-write_subscribers' . S2VERSION );
if ( isset( $_POST['subject'] ) ) {
$subject = stripslashes( esc_html( $_POST['subject'] ) );
} else {
$subject = __( 'A message from', 'subscribe2' ) . ' ' . html_entity_decode( get_option( 'blogname' ), ENT_QUOTES );
}
if ( ! isset( $_POST['content'] ) ) {
$body = '';
}
echo '<p>' . esc_html__( 'Subject', 'subscribe2' ) . ': <input type="text" size="69" name="subject" value="' . esc_attr( $subject ) . '" /> <br><br>';
echo '<textarea rows="12" cols="75" name="content">' . esc_textarea( $body ) . '</textarea>';
echo "<br><div id=\"upload_files\"><input type=\"file\" name=\"file[]\"></div>\r\n";
echo '<input type="button" class="button-secondary" name="addmore" value="' . esc_attr( __( 'Add More Files', 'subscribe2' ) ) . "\" onClick=\"add_file_upload();\" />\r\n";
echo "<br><br>\r\n";
echo esc_html__( 'Recipients:', 'subscribe2' ) . ' ';
$this->display_subscriber_dropdown( apply_filters( 's2_subscriber_dropdown_default', 'registered' ), false );
echo '<input type="hidden" name="s2_admin" value="mail" />';
echo '<p class="submit"><input type="submit" class="button-secondary" name="preview" value="' . esc_attr( __( 'Preview', 'subscribe2' ) ) . '" />&nbsp;<input type="submit" class="button-primary" name="send" value="' . esc_attr( __( 'Send', 'subscribe2' ) ) . '" /></p>';
echo '</form></div>' . "\r\n";
echo '<div style="clear: both;"><p>&nbsp;</p></div>';
?>
<script type="text/javascript">
//<![CDATA[
function add_file_upload() {
var div = document.getElementById( 'upload_files' );
var field = div.getElementsByTagName( 'input' )[0];
div.appendChild( document.createElement( 'br' ) );
div.appendChild( field.cloneNode( false ) );
}
//]]>
</script>
<?php
require ABSPATH . 'wp-admin/admin-footer.php';
// just to be sure
die;

View File

@ -1,529 +0,0 @@
<?php
if ( ! function_exists( 'add_action' ) ) {
exit();
}
global $wpdb, $current_tab;
// was anything POSTed?
if ( isset( $_POST['s2_admin'] ) ) {
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-options_subscribers' . S2VERSION ) ) {
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
}
if ( isset( $_POST['reset'] ) ) {
require_once S2PATH . 'classes/class-s2-upgrade.php';
global $s2_upgrade;
$s2_upgrade = new S2_Upgrade();
$s2_upgrade->reset();
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Options reset!', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['preview'] ) ) {
global $user_email, $post;
$this->preview_email = true;
if ( 'never' === $this->subscribe2_options['email_freq'] ) {
$preview_posts = get_posts( 'numberposts=1' );
$preview_post = $preview_posts[0];
$this->publish( $preview_post, $user_email );
} else {
do_action( 's2_digest_preview', $user_email );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Preview message(s) sent to logged in user', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['resend'] ) ) {
$stickies = get_option( 'sticky_posts' );
if ( ! empty( $this->subscribe2_options['last_s2cron'] ) || ( 'yes' === $this->subscribe2_options['stickies'] && ! empty( $stickies ) ) ) {
do_action( 's2_digest_resend', 'resend' );
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Attempt made to resend the Digest Notification email', 'subscribe2' ) . '</strong></p></div>';
} else {
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'The Digest Notification email contained no post information. No email was sent', 'subscribe2' ) . '</strong></p></div>';
}
} elseif ( isset( $_POST['submit'] ) ) {
foreach ( $_POST as $key => $value ) {
if ( in_array( $key, array( 'bcclimit', 's2page', 's2_unsub_page' ), true ) ) {
// numerical inputs fixed for old option names
if ( is_numeric( $_POST[ $key ] ) && $_POST[ $key ] >= 0 ) {
$this->subscribe2_options[ $key ] = (int) $_POST[ $key ];
}
} elseif ( in_array( $key, array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'reg_override' ), true ) ) {
// check box entries
( isset( $_POST[ $key ] ) && '1' === $_POST[ $key ] ) ? $this->subscribe2_options[ $key ] = '1' : $this->subscribe2_options[ $key ] = '0';
} elseif ( 'appearance_tab' === $key ) {
$options = array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'js_ip_updater', 's2_unsub_page' );
foreach ( $options as $option ) {
if ( ! isset( $_POST[ $option ] ) ) {
$this->subscribe2_options[ $option ] = '0';
}
}
} elseif ( in_array( $key, array( 'notification_subject', 'mailtext', 'confirm_subject', 'confirm_email', 'remind_subject', 'remind_email' ), true ) && ! empty( $_POST[ $key ] ) ) {
// email subject and body templates
$this->subscribe2_options[ $key ] = trim( $_POST[ $key ] );
} elseif ( in_array( $key, array( 'compulsory', 'exclude', 'format' ), true ) ) {
sort( $_POST[ $key ] );
$newvalue = implode( ',', $_POST[ $key ] );
if ( 'format' === $key ) {
$this->subscribe2_options['exclude_formats'] = $newvalue;
} else {
$this->subscribe2_options[ $key ] = $newvalue;
}
} elseif ( 'registered_users_tab' === $key ) {
$options = array( 'compulsory', 'exclude', 'format', 'reg_override' );
foreach ( $options as $option ) {
if ( ! isset( $_POST[ $option ] ) ) {
if ( 'format' === $option ) {
$this->subscribe2_options['exclude_formats'] = '';
} else {
$this->subscribe2_options[ $option ] = '';
}
}
}
} elseif ( 'email_freq' === $key ) {
// send per-post or digest emails
$email_freq = $_POST['email_freq'];
$scheduled_time = wp_next_scheduled( 's2_digest_cron' );
$timestamp_offset = get_option( 'gmt_offset' ) * 60 * 60;
$crondate = ( isset( $_POST['crondate'] ) ) ? $_POST['crondate'] : 0;
$crontime = ( isset( $_POST['crondate'] ) ) ? $_POST['crontime'] : 0;
if ( $email_freq !== $this->subscribe2_options['email_freq'] || date_i18n( get_option( 'date_format' ), $scheduled_time + $timestamp_offset ) !== $crondate || gmdate( 'G', $scheduled_time + $timestamp_offset ) !== $crontime ) {
$this->subscribe2_options['email_freq'] = $email_freq;
wp_clear_scheduled_hook( 's2_digest_cron' );
$scheds = (array) wp_get_schedules();
$interval = ( isset( $scheds[ $email_freq ]['interval'] ) ) ? (int) $scheds[ $email_freq ]['interval'] : 0;
if ( 0 === $interval ) {
// if we are on per-post emails remove last_cron entry
unset( $this->subscribe2_options['last_s2cron'] );
} else {
// if we are using digest schedule the event and prime last_cron as now
$time = time() + $interval;
$srttimestamp = strtotime( $crondate ) + ( $crontime * 60 * 60 );
if ( false === $srttimestamp || 0 === $srttimestamp ) {
$srttimestamp = time();
}
$timestamp = $srttimestamp - $timestamp_offset;
while ( $timestamp < time() ) {
// if we are trying to set the time in the past increment it forward
// by the interval period until it is in the future
$timestamp += $interval;
}
wp_schedule_event( $timestamp, $email_freq, 's2_digest_cron' );
}
}
} else {
if ( isset( $this->subscribe2_options[ $key ] ) ) {
if ( 'sender' === $key && $this->subscribe2_options[ $key ] !== $_POST[ $key ] ) {
$this->subscribe2_options['dismiss_sender_warning'] = '0';
}
$this->subscribe2_options[ $key ] = $_POST[ $key ];
}
}
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Options saved!', 'subscribe2' ) . '</strong></p></div>';
update_option( 'subscribe2_options', $this->subscribe2_options );
}
}
// send error message if no WordPress page exists
$page_id = $wpdb->get_var( "SELECT ID FROM `{$wpdb->prefix}posts` WHERE post_type='page' AND post_status='publish' LIMIT 1" );
if ( empty( $page_id ) ) {
echo '<div id="page_message" class="error"><p class="s2_error"><strong>' . esc_html__( 'You must create a WordPress page for this plugin to work correctly.', 'subscribe2' ) . '</strong></p></div>';
}
// display error message for GDPR
if ( defined( 'S2GDPR' ) && true === S2GDPR ) {
if ( 'yes' === $this->subscribe2_options['autosub'] || 'yes' === $this->subscribe2_options['wpregdef'] || 'yes' === $this->subscribe2_options['autosub_def'] || 'yes' === $this->subscribe2_options['comment_def'] ) {
echo '<div id="gdpr_message" class="error"><p class="s2_error"><strong>' . esc_html__( 'Your Settings may breach GDPR', 'subscribe2' ) . '</strong></p></div>';
}
}
if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
$disallowed_keywords = array( '{TITLE}', '{TITLETEXT}', '{PERMALINK}', '{PERMAURL}', '{DATE}', '{TIME}', '{LINK}', '{ACTION}', '{REFERENCELINKS}' );
} else {
$disallowed_keywords = array( '{POSTTIME}', '{TABLE}', '{TABLELINKS}', '{COUNT}', '{LINK}', '{ACTION}' );
}
$disallowed = false;
foreach ( $disallowed_keywords as $disallowed_keyword ) {
if ( false !== strstr( $this->subscribe2_options['mailtext'], $disallowed_keyword ) ) {
$disallowed[] = $disallowed_keyword;
}
}
$template_link = '<a href="' . admin_url( 'admin.php?page=s2_settings&tab=templates' ) . '">' . __( 'Modify your template', 'subscribe2' ) . '</a>';
if ( false !== $disallowed ) {
$disallowed_keywords = __( 'Your chosen email type (per-post or digest) does not support the following keywords:', 'subscribe2' );
echo '<div id="keyword_message" class="error"><p class="s2_error"><strong>' . esc_html( $disallowed_keywords ) . '</strong><br>' . esc_html( implode( ', ', $disallowed ) ) . '<br>' . wp_kses_post( $template_link ) . '</p></div>';
}
// send error message if sender email address is off-domain
if ( 'blogname' === $this->subscribe2_options['sender'] ) {
$sender = get_bloginfo( 'admin_email' );
} else {
$user = $this->get_userdata( $this->subscribe2_options['sender'] );
$sender = $user->user_email;
}
list( $user, $sender_domain ) = explode( '@', $sender, 2 );
$dismis_sender_worning = '';
if(isset($this->subscribe2_options['dismiss_sender_warning'])) {
$dismis_sender_worning = $this->subscribe2_options['dismiss_sender_warning'];
}
if ( ! stristr( esc_html( $_SERVER['SERVER_NAME'] ), $sender_domain ) && 'author' !== $this->subscribe2_options['sender'] && '0' === (isset($this->subscribe2_options['dismiss_sender_warning']) ? $this->subscribe2_options['dismiss_sender_warning'] : '0') ) {
// Translators: Warning message
echo wp_kses_post( '<div id="sender_message" class="error notice is-dismissible"><p class="s2_error"><strong>' . sprintf( __( 'You appear to be sending notifications from %1$s, which has a different domain name than your blog server %2$s. This may result in failed emails.', 'subscribe2' ), $sender, $_SERVER['SERVER_NAME'] ) . '</strong></p></div>' );
}
// detect or define which tab we are in
$current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'email';
// show our form
echo '<div class="wrap">';
echo '<h1>' . esc_html__( 'Settings', 'subscribe2' ) . '</h1>' . "\r\n";
$s2tabs = array(
'email' => __( 'Email Settings', 'subscribe2' ),
'templates' => __( 'Templates', 'subscribe2' ),
'registered' => __( 'Registered Users', 'subscribe2' ),
'appearance' => __( 'Appearance', 'subscribe2' ),
'misc' => __( 'Miscellaneous', 'subscribe2' ),
);
echo '<h2 class="nav-tab-wrapper">';
foreach ( $s2tabs as $tab_key => $tab_caption ) {
$active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . esc_attr( $active ) . '" href="?page=s2_settings&amp;tab=' . esc_html( $tab_key ) . '">' . esc_html( $tab_caption ) . '</a>';
}
echo '</h2>';
echo '<form method="post">' . "\r\n";
wp_nonce_field( 'subscribe2-options_subscribers' . S2VERSION );
echo '<input type="hidden" name="s2_admin" value="options" />' . "\r\n";
echo '<input type="hidden" id="jsbcclimit" value="' . esc_attr( $this->subscribe2_options['bcclimit'] ) . '" />';
switch ( $current_tab ) {
case 'email':
// settings for outgoing emails
echo '<div class="s2_admin" id="s2_notification_settings">' . "\r\n";
echo '<p>' . "\r\n";
echo wp_kses_post( 'Restrict the number of <strong>recipients per email</strong> to (0 for unlimited)', 'subscribe2' ) . ': ';
echo '<span id="s2bcclimit_1"><span id="s2bcclimit" style="background-color: #FFFBCC">' . esc_html( $this->subscribe2_options['bcclimit'] ) . '</span> ';
echo '<a href="#" onclick="s2Show(\'bcclimit\'); return false;">' . esc_html__( 'Edit', 'subscribe2' ) . '</a></span>' . "\r\n";
echo '<span id="s2bcclimit_2">' . "\r\n";
echo '<input type="text" name="bcclimit" value="' . esc_attr( $this->subscribe2_options['bcclimit'] ) . '" size="3" />' . "\r\n";
echo '<a href="#" onclick="s2Update(\'bcclimit\'); return false;">' . esc_html__( 'Update', 'subscribe2' ) . '</a>' . "\r\n";
echo '<a href="#" onclick="s2Revert(\'bcclimit\'); return false;">' . esc_html__( 'Revert', 'subscribe2' ) . '</a></span>' . "\n";
echo '<br><br>' . esc_html__( 'Send Admins notifications for new', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="admin_email" value="subs"' . checked( $this->subscribe2_options['admin_email'], 'subs', false ) . ' />' . "\r\n";
echo esc_html__( 'Subscriptions', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="admin_email" value="unsubs"' . checked( $this->subscribe2_options['admin_email'], 'unsubs', false ) . ' />' . "\r\n";
echo esc_html__( 'Unsubscriptions', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="admin_email" value="both"' . checked( $this->subscribe2_options['admin_email'], 'both', false ) . ' />' . "\r\n";
echo esc_html__( 'Both', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="admin_email" value="none"' . checked( $this->subscribe2_options['admin_email'], 'none', false ) . ' />' . "\r\n";
echo esc_html__( 'Neither', 'subscribe2' ) . '</label><br><br>' . "\r\n";
echo esc_html__( 'Include theme CSS stylesheet in HTML notifications', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="stylesheet" value="yes"' . checked( $this->subscribe2_options['stylesheet'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="stylesheet" value="no"' . checked( $this->subscribe2_options['stylesheet'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
echo esc_html__( 'Send Emails for Pages', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="pages" value="yes"' . checked( $this->subscribe2_options['pages'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="pages" value="no"' . checked( $this->subscribe2_options['pages'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
$s2_post_types = apply_filters( 's2_post_types', array() );
if ( ! empty( $s2_post_types ) ) {
if ( ! empty( $s2_post_types ) ) {
echo esc_html__( 'Subscribe2 will send email notifications for the following custom post types', 'subscribe2' ) . ': ';
echo '<strong>' . esc_html( implode( ', ', $s2_post_types ) ) . '</strong><br><br>' . "\r\n";
}
}
echo esc_html__( 'Send Emails for Password Protected Posts', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="password" value="yes"' . checked( $this->subscribe2_options['password'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="password" value="no"' . checked( $this->subscribe2_options['password'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
echo esc_html__( 'Send Emails for Private Posts', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="private" value="yes"' . checked( $this->subscribe2_options['private'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="private" value="no"' . checked( $this->subscribe2_options['private'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
echo esc_html__( 'Include Sticky Posts at the top of all Digest Notifications', 'subscribe2' ) . ': ';
echo '<label><input type="radio" name="stickies" value="yes"' . checked( $this->subscribe2_options['stickies'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="stickies" value="no"' . checked( $this->subscribe2_options['stickies'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
}
echo esc_html__( 'Send Email From', 'subscribe2' ) . ': ';
echo '<label>' . "\r\n";
$this->admin_dropdown( true );
echo '</label><br><br>' . "\r\n";
if ( function_exists( 'wp_schedule_event' ) ) {
echo esc_html__( 'Send Emails', 'subscribe2' ) . ': <br>' . "\r\n";
$this->display_digest_choices();
}
if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
echo '<p>' . esc_html__( 'For digest notifications, date order for posts is', 'subscribe2' ) . ': ' . "\r\n";
echo '<label><input type="radio" name="cron_order" value="desc"' . checked( $this->subscribe2_options['cron_order'], 'desc', false ) . ' /> ';
echo esc_html__( 'Descending', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="cron_order" value="asc"' . checked( $this->subscribe2_options['cron_order'], 'asc', false ) . ' /> ';
echo esc_html__( 'Ascending', 'subscribe2' ) . '</label></p>' . "\r\n";
}
echo esc_html__( 'Add Tracking Parameters to the Permalink', 'subscribe2' ) . ': ';
echo '<input type="text" name="tracking" value="' . esc_attr( $this->subscribe2_options['tracking'] ) . '" size="50" /> ';
echo '<br>' . esc_html__( 'eg. utm_source=subscribe2&amp;utm_medium=email&amp;utm_campaign=postnotify&amp;utm_id={ID}&amp;utm_title={TITLE}', 'subscribe2' ) . "\r\n";
echo '</p>' . "\r\n";
echo '</div>' . "\r\n";
break;
case 'templates':
// email templates
echo '<div class="s2_admin" id="s2_templates">' . "\r\n";
echo '<p>' . "\r\n";
echo '<table style="width: 100%; border-collapse: separate; border-spacing: 5px; *border-collapse: expression(\'separate\', cellSpacing = \'5px\');" class="editform">' . "\r\n";
echo '<tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
echo esc_html__( 'Notification email (must not be empty)', 'subscribe2' ) . ':<br>' . "\r\n";
echo esc_html__( 'Subject Line', 'subscribe2' ) . ': ';
echo '<input type="text" name="notification_subject" value="' . esc_attr( $this->subscribe2_options['notification_subject'] ) . '" size="45" />';
echo '<br>' . "\r\n";
echo '<textarea rows="9" cols="60" name="mailtext" style="width:95%;">' . esc_textarea( stripslashes( $this->subscribe2_options['mailtext'] ) ) . '</textarea>' . "\r\n";
echo '</td><td style="vertical-align: top;" rowspan="3">';
echo '<p class="submit"><input type="submit" class="button-secondary" name="preview" value="' . esc_html__( 'Send Email Preview', 'subscribe2' ) . '" /></p>' . "\r\n";
echo '<h3>' . esc_html__( 'Message substitutions', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<dl>';
echo '<dt><b><em style="color: red">' . esc_html__( 'IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED', 'subscribe2' ) . '</em></b></dt><dd></dd>' . "\r\n";
echo '<dt><b>{BLOGNAME}</b></dt><dd>' . esc_html( get_option( 'blogname' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{BLOGLINK}</b></dt><dd>' . esc_html( get_option( 'home' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TITLE}</b></dt><dd>' . wp_kses_post( __( "the post's title<br>(<i>for per-post emails only</i>)", 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TITLETEXT}</b></dt><dd>' . wp_kses_post( __( "the post's unformatted title <br>(<i>for per-post emails only</i>)", 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{POST}</b></dt><dd>' . wp_kses_post( __( "the excerpt or the entire post<br>(<i>based on the subscriber's preferences</i>)", 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{POSTTIME}</b></dt><dd>' . wp_kses_post( __( 'the excerpt of the post and the time it was posted<br>(<i>for digest emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TABLE}</b></dt><dd>' . wp_kses_post( __( 'a list of post titles<br>(<i>for digest emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TABLELINKS}</b></dt><dd>' . wp_kses_post( __( 'a list of post titles followed by links to the articles<br>(<i>for digest emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{REFERENCELINKS}</b></dt><dd>' . wp_kses_post( __( 'a reference style list of links at the end of the email with corresponding numbers in the content<br>(<i>for the full content plain text per-post email only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{PERMALINK}</b></dt><dd>' . wp_kses_post( __( "the post's permalink<br>(<i>for per-post emails only</i>)", 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TINYLINK}</b></dt><dd>' . esc_html__( "the post's permalink after conversion by TinyURL", 'subscribe2' ) . '</dd>' . "\r\n";
echo '<dt><b>{PERMAURL}</b></dt><dd>' . wp_kses_post( __( "the post's unformatted permalink<br>(<i>for per-post emails only</i>)", 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{DATE}</b></dt><dd>' . wp_kses_post( __( 'the date the post was made<br>(<i>for per-post emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{TIME}</b></dt><dd>' . wp_kses_post( __( 'the time the post was made<br>(<i>for per-post emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{MYNAME}</b></dt><dd>' . esc_html__( "the admin or post author's name", 'subscribe2' ) . '</dd>' . "\r\n";
echo '<dt><b>{EMAIL}</b></dt><dd>' . esc_html__( "the admin or post author's email", 'subscribe2' ) . ' </dd>' . "\r\n";
echo '<dt><b>{AUTHORNAME}</b></dt><dd>' . esc_html__( "the post author's name", 'subscribe2' ) . '</dd>' . "\r\n";
echo '<dt><b>{LINK}</b></dt><dd>' . wp_kses_post( __( 'the generated link to confirm a request<br>(<i>only used in the confirmation email template</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
if ( 1 === $this->subscribe2_options['bcclimit'] ) {
echo '<dt><b>{UNSUBLINK}</b></dt><dd>' . wp_kses_post( __( 'a generated unsubscribe link<br>(<i>only used in the email notification template</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
}
echo '<dt><b>{ACTION}</b></dt><dd>' . wp_kses_post( __( 'Action performed by LINK in confirmation email<br>(<i>only used in the confirmation email template</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
echo '<dt><b>{CATS}</b></dt><dd>' . esc_html__( "the post's assigned categories", 'subscribe2' ) . '</dd>' . "\r\n";
echo '<dt><b>{TAGS}</b></dt><dd>' . esc_html__( "the post's assigned Tags", 'subscribe2' ) . '</dd>' . "\r\n";
echo '<dt><b>{COUNT}</b></dt><dd>' . wp_kses_post( __( 'the number of posts included in the digest email<br>(<i>for digest emails only</i>)', 'subscribe2' ) ) . '</dd>' . "\r\n";
if ( current_theme_supports( 'post-thumbnails' ) ) {
echo '<dt><b>{IMAGE}</b></dt><dd>' . esc_html__( "the post's featured image", 'subscribe2' ) . '</dd>' . "\r\n";
}
echo '</dl></td></tr><tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
echo esc_html__( 'Subscribe / Unsubscribe confirmation email', 'subscribe2' ) . ':<br>' . "\r\n";
echo esc_html__( 'Subject Line', 'subscribe2' ) . ': ';
echo '<input type="text" name="confirm_subject" value="' . esc_attr( $this->subscribe2_options['confirm_subject'] ) . '" size="45" /><br>' . "\r\n";
echo '<textarea rows="9" cols="60" name="confirm_email" style="width:95%;">' . esc_textarea( stripslashes( $this->subscribe2_options['confirm_email'] ) ) . '</textarea>' . "\r\n";
echo '</td></tr><tr><td style="vertical-align: top; height: 350px; min-height: 350px;">';
echo esc_html__( 'Reminder email to Unconfirmed Subscribers', 'subscribe2' ) . ':<br>' . "\r\n";
echo esc_html__( 'Subject Line', 'subscribe2' ) . ': ';
echo '<input type="text" name="remind_subject" value="' . esc_attr( $this->subscribe2_options['remind_subject'] ) . '" size="45" /><br>' . "\r\n";
echo '<textarea rows="9" cols="60" name="remind_email" style="width:95%;">' . esc_textarea( stripslashes( $this->subscribe2_options['remind_email'] ) ) . '</textarea><br><br>' . "\r\n";
echo '</td></tr></table>' . "\r\n";
echo '</div>' . "\r\n";
break;
case 'registered':
// Access function to allow display for form elements
require_once S2PATH . 'classes/class-s2-forms.php';
$s2_forms = new s2_forms();
// compulsory categories
echo '<div class="s2_admin" id="s2_compulsory_categories">' . "\r\n";
echo '<input type="hidden" name="registered_users_tab" value="options" />' . "\r\n";
echo '<h3>' . esc_html__( 'Compulsory Categories', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>' . "\r\n";
echo '<strong><em style="color: red">' . esc_html__( 'Compulsory categories will be checked by default for Registered Subscribers', 'subscribe2' ) . '</em></strong><br>' . "\r\n";
echo '</p>';
$s2_forms->display_category_form( explode( ',', $this->subscribe2_options['compulsory'] ), 1, array(), 'compulsory' );
echo "</div>\r\n";
// excluded categories
echo '<div class="s2_admin" id="s2_excluded_categories">' . "\r\n";
echo '<h3>' . esc_html__( 'Excluded Categories', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>';
echo '<strong><em style="color: red">' . esc_html__( 'Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2' ) . '</em></strong><br>' . "\r\n";
echo '</p>';
$s2_forms->display_category_form( explode( ',', $this->subscribe2_options['exclude'] ), 1, array(), 'exclude' );
echo '<p style="text-align: center;"><label><input type="checkbox" name="reg_override" value="1"' . checked( $this->subscribe2_options['reg_override'], '1', false ) . ' /> ';
echo esc_html__( 'Allow registered users to subscribe to excluded categories?', 'subscribe2' ) . '</label></p>' . "\r\n";
echo '</div>' . "\r\n";
// excluded post formats
$formats = get_theme_support( 'post-formats' );
if ( false !== $formats ) {
// excluded formats
echo '<div class="s2_admin" id="s2_excluded_formats">' . "\r\n";
echo '<h3>' . esc_html__( 'Excluded Formats', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>';
echo '<strong><em style="color: red">' . esc_html__( 'Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2' ) . '</em></strong><br>' . "\r\n";
echo '</p>';
$this->display_format_form( $formats, explode( ',', $this->subscribe2_options['exclude_formats'] ) );
echo '</div>' . "\r\n";
}
//Auto Subscription for new registrations
echo '<div class="s2_admin" id="s2_autosubscribe_settings">' . "\r\n";
echo '<h3>' . esc_html__( 'Auto-Subscribe', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>' . "\r\n";
echo esc_html__( 'Subscribe new users registering with your blog', 'subscribe2' ) . ':<br>' . "\r\n";
if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['autosub'] ) || ( false === S2GDPR ) ) ) {
echo '<label><input type="radio" name="autosub" value="yes"' . checked( $this->subscribe2_options['autosub'], 'yes', false ) . ' /> ';
echo esc_html__( 'Automatically', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
}
echo '<label><input type="radio" name="autosub" value="wpreg"' . checked( $this->subscribe2_options['autosub'], 'wpreg', false ) . ' /> ';
echo esc_html__( 'Display option on Registration Form', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="autosub" value="no"' . checked( $this->subscribe2_options['autosub'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
echo esc_html__( 'Auto-subscribe includes any excluded categories', 'subscribe2' ) . ':<br>' . "\r\n";
echo '<label><input type="radio" name="newreg_override" value="yes"' . checked( $this->subscribe2_options['newreg_override'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="newreg_override" value="no"' . checked( $this->subscribe2_options['newreg_override'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['wpregdef'] ) || ( false === S2GDPR ) ) ) {
echo esc_html__( 'Registration Form option is checked by default', 'subscribe2' ) . ':<br>' . "\r\n";
echo '<label><input type="radio" name="wpregdef" value="yes"' . checked( $this->subscribe2_options['wpregdef'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="wpregdef" value="no"' . checked( $this->subscribe2_options['wpregdef'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
}
echo esc_html__( 'Auto-subscribe users to receive email as', 'subscribe2' ) . ': <br>' . "\r\n";
echo '<label><input type="radio" name="autoformat" value="html"' . checked( $this->subscribe2_options['autoformat'], 'html', false ) . ' /> ';
echo esc_html__( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="autoformat" value="html_excerpt"' . checked( $this->subscribe2_options['autoformat'], 'html_excerpt', false ) . ' /> ';
echo esc_html__( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="autoformat" value="post"' . checked( $this->subscribe2_options['autoformat'], 'post', false ) . ' /> ';
echo esc_html__( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="autoformat" value="excerpt"' . checked( $this->subscribe2_options['autoformat'], 'excerpt', false ) . ' /> ';
echo esc_html__( 'Plain Text - Excerpt', 'subscribe2' ) . '</label><br><br>';
echo esc_html__( 'Registered Users have the option to auto-subscribe to new categories', 'subscribe2' ) . ': <br>' . "\r\n";
echo '<label><input type="radio" name="show_autosub" value="yes"' . checked( $this->subscribe2_options['show_autosub'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="show_autosub" value="no"' . checked( $this->subscribe2_options['show_autosub'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="show_autosub" value="exclude"' . checked( $this->subscribe2_options['show_autosub'], 'exclude', false ) . ' /> ';
echo esc_html__( 'New categories are immediately excluded', 'subscribe2' ) . '</label><br><br>';
if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['autosub_def'] ) || ( false === S2GDPR ) ) ) {
echo esc_html__( 'Option for Registered Users to auto-subscribe to new categories is checked by default', 'subscribe2' ) . ': <br>' . "\r\n";
echo '<label><input type="radio" name="autosub_def" value="yes"' . checked( $this->subscribe2_options['autosub_def'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="autosub_def" value="no"' . checked( $this->subscribe2_options['autosub_def'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>';
}
// Hide these options if using Jetpack Comments
if ( ! class_exists( 'Jetpack_Comments' ) ) {
echo esc_html__( 'Display checkbox to allow subscriptions from the comment form', 'subscribe2' ) . ': <br>' . "\r\n";
echo '<label><input type="radio" name="comment_subs" value="before"' . checked( $this->subscribe2_options['comment_subs'], 'before', false ) . ' /> ';
echo esc_html__( 'Before the Comment Submit button', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="comment_subs" value="after"' . checked( $this->subscribe2_options['comment_subs'], 'after', false ) . ' /> ';
echo esc_html__( 'After the Comment Submit button', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="comment_subs" value="no"' . checked( $this->subscribe2_options['comment_subs'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>';
if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['comment_def'] ) || ( false === S2GDPR ) ) ) {
echo esc_html__( 'Comment form checkbox is checked by default', 'subscribe2' ) . ': <br>' . "\r\n";
echo '<label><input type="radio" name="comment_def" value="yes"' . checked( $this->subscribe2_options['comment_def'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="comment_def" value="no"' . checked( $this->subscribe2_options['comment_def'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label><br><br>' . "\r\n";
}
}
echo esc_html__( 'Show one-click subscription on profile page', 'subscribe2' ) . ':<br>' . "\r\n";
echo '<label><input type="radio" name="one_click_profile" value="yes"' . checked( $this->subscribe2_options['one_click_profile'], 'yes', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="one_click_profile" value="no"' . checked( $this->subscribe2_options['one_click_profile'], 'no', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label>' . "\r\n";
echo '</p></div>' . "\r\n";
break;
case 'appearance':
// Appearance options
echo '<div class="s2_admin" id="s2_appearance_settings">' . "\r\n";
echo '<input type="hidden" name="appearance_tab" value="options" />' . "\r\n";
echo '<p>' . "\r\n";
// WordPress page ID where subscribe2 token is used
echo esc_html__( 'Set default Subscribe2 page as', 'subscribe2' ) . ': ';
$this->pages_dropdown( $this->subscribe2_options['s2page'] );
echo "</br></br>";
echo esc_html__( 'Set Subscribe2 unsubscribe page', 'subscribe2' ) . ': ';
$this->pages_dropdown( isset($this->subscribe2_options['s2_unsub_page']) ? $this->subscribe2_options['s2_unsub_page'] : 0 , 's2_unsub_page');
// show link to WordPress page in meta
echo '<br><br><label><input type="checkbox" name="show_meta" value="1"' . checked( $this->subscribe2_options['show_meta'], '1', false ) . ' /> ';
echo esc_html__( 'Show a link to your subscription page in "meta"?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// show QuickTag button
echo '<label><input type="checkbox" name="show_button" value="1"' . checked( $this->subscribe2_options['show_button'], '1', false ) . ' /> ';
echo esc_html__( 'Show the Subscribe2 button on the Write toolbar?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// enable popup style form
echo '<label><input type="checkbox" name="ajax" value="1"' . checked( $this->subscribe2_options['ajax'], '1', false ) . ' /> ';
echo esc_html__( 'Enable popup style subscription form?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// show Widget
echo '<label><input type="checkbox" name="widget" value="1"' . checked( $this->subscribe2_options['widget'], '1', false ) . ' /> ';
echo esc_html__( 'Enable Subscribe2 Widget?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// show Counter Widget
echo '<label><input type="checkbox" name="counterwidget" value="1"' . checked( $this->subscribe2_options['counterwidget'], '1', false ) . ' /> ';
echo esc_html__( 'Enable Subscribe2 Counter Widget?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// s2_meta checked by default
echo '<label><input type="checkbox" name="s2meta_default" value="1"' . checked( $this->subscribe2_options['s2meta_default'], '1', false ) . ' /> ';
echo esc_html__( 'Disable email notifications is checked by default on authoring pages?', 'subscribe2' ) . '</label><br><br>' . "\r\n";
// Subscription form for Registered Users on Frontend
echo '<label><input type="checkbox" name="js_ip_updater" value="1"' . checked( $this->subscribe2_options['js_ip_updater'], '1', false ) . ' /> ';
echo esc_html__( 'Use javascript to update IP address in Subscribe2 HTML form data? (useful if caching is enabled)', 'subscribe2' ) . '</label>' . "\r\n";
echo '</p>';
echo '</div>' . "\r\n";
break;
case 'misc':
//barred domains
echo '<div class="s2_admin" id="s2_barred_domains">' . "\r\n";
echo '<h3>' . esc_html__( 'Barred Domains', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>' . "\r\n";
echo esc_html__( 'Enter domains to bar for public subscriptions, wildcards (*) and exceptions (!) are allowed', 'subscribe2' ) . '<br>' . "\r\n";
echo esc_html__( 'Use a new line for each entry and omit the "@" symbol, for example !email.com, hotmail.com, yahoo.*', 'subscribe2' );
echo "\r\n" . '<br><textarea style="width: 98%;" rows="4" cols="60" name="barred">' . esc_textarea( $this->subscribe2_options['barred'] ) . '</textarea>';
echo '</p>';
echo '<h3>' . esc_html__( 'Links', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<a href="https://wordpress.org/plugins/subscribe2/">' . esc_html__( 'Plugin Site', 'subscribe2' ) . '</a><br>';
echo '<a href="https://wordpress.org/support/plugin/subscribe2">' . esc_html__( 'Plugin Forum', 'subscribe2' ) . '</a><br>';
echo '<a href="https://getwemail.io/subscribe2/">' . esc_html__( 'Plugin Blog', 'subscribe2' ) . '</a><br>';
echo '</div>' . "\r\n";
break;
}
// submit
echo '<p class="submit" style="text-align: center"><input type="submit" class="button-primary" name="submit" value="' . esc_attr( __( 'Submit', 'subscribe2' ) ) . '" /></p>';
if ( 'misc' === $current_tab ) {
// reset
echo '<h3>' . esc_html__( 'Reset to Default Settings', 'subscribe2' ) . '</h3>' . "\r\n";
echo '<p>' . esc_html__( 'Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers.', 'subscribe2' ) . '</p>' . "\r\n";
echo '<p class="submit" style="text-align: center">';
echo '<input type="submit" class="button" id="deletepost" name="reset" value="' . esc_attr( __( 'RESET', 'subscribe2' ) ) . '" /></p>';
}
echo '</form></div>' . "\r\n";
require ABSPATH . 'wp-admin/admin-footer.php';
// just to be sure
die;

View File

@ -1,338 +0,0 @@
<?php
if ( ! function_exists( 'add_action' ) ) {
exit();
}
global $subscribers, $what, $current_tab;
// detect or define which tab we are in
$current_tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'public';
// Access function to allow display for form elements
require_once S2PATH . 'classes/class-s2-forms.php';
$s2_forms = new s2_forms();
// Instantiate and prepare our table data - this also runs the bulk actions
if ( ! class_exists( 'WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
if ( ! class_exists( 'Subscribe2_List_Table' ) ) {
require_once S2PATH . 'classes/class-s2-list-table.php';
$s2_list_table = new S2_List_Table();
}
// was anything POSTed ?
if ( isset( $_POST['s2_admin'] ) ) {
$s2_request_category = '';
if (isset($_REQUEST['category']) && $_REQUEST['category']) {
$s2_request_category = $_REQUEST['category'];
}
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $s2_list_table->_args['plural'] ) ) {
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
}
if ( ! empty( $_POST['addresses'] ) ) {
$reg_sub_error = '';
$pub_sub_error = '';
$unsub_error = '';
$email_error = '';
$message = '';
foreach ( preg_split( '/[\s,]+/', $_POST['addresses'] ) as $email ) {
$clean_email = $this->sanitize_email( $email );
if ( false === $this->validate_email( $clean_email ) ) {
( '' === $email_error ) ? $email_error = "$email" : $email_error .= ", $email";
continue;
} else {
if ( isset( $_POST['subscribe'] ) ) {
if ( false !== $this->is_public( $clean_email ) ) {
( '' === $pub_sub_error ) ? $pub_sub_error = "$clean_email" : $pub_sub_error .= ", $clean_email";
continue;
}
if ( $this->is_registered( $clean_email ) ) {
( '' === $reg_sub_error ) ? $reg_sub_error = "$clean_email" : $reg_sub_error .= ", $clean_email";
continue;
}
$this->add( $clean_email, true );
$message = __( 'Address(es) subscribed!', 'subscribe2' );
} elseif ( isset( $_POST['unsubscribe'] ) ) {
if ( false === $this->is_public( $clean_email ) || $this->is_registered( $clean_email ) ) {
( '' === $unsub_error ) ? $unsub_error = "$clean_email" : $unsub_error .= ", $clean_email";
continue;
}
$this->delete( $clean_email );
$message = __( 'Address(es) unsubscribed!', 'subscribe2' );
}
}
}
if ( '' !== $reg_sub_error ) {
echo '<div id="message" class="error"><p><strong>' . esc_html__( 'Some emails were not processed, the following are already Registered Subscribers', 'subscribe2' ) . ':<br>' . esc_html( $reg_sub_error ) . '</strong></p></div>';
}
if ( '' !== $pub_sub_error ) {
echo '<div id="message" class="error"><p><strong>' . esc_html__( 'Some emails were not processed, the following are already Public Subscribers', 'subscribe2' ) . ':<br>' . esc_html( $pub_sub_error ) . '</strong></p></div>';
}
if ( '' !== $unsub_error ) {
echo '<div id="message" class="error"><p><strong>' . esc_html__( 'Some emails were not processed, the following were not in the database', 'subscribe2' ) . ':<br> ' . esc_html( $unsub_error ) . '</strong></p></div>';
}
if ( '' !== $email_error ) {
echo '<div id="message" class="error"><p><strong>' . esc_html__( 'Some emails were not processed, the following were invalid email addresses', 'subscribe2' ) . ':<br> ' . esc_html( $email_error ) . '</strong></p></div>';
}
if ( '' !== $message ) {
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $message ) . '</strong></p></div>';
}
$_POST['what'] = 'confirmed';
} elseif ( isset( $_POST['remind'] ) ) {
$this->remind( $_POST['reminderemails'] );
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Reminder Email(s) Sent!', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['sub_categories'] ) && 'subscribe' === $_POST['manage'] ) {
if ( isset( $_REQUEST['subscriber'] ) ) {
$this->subscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $s2_request_category );
} else {
$this->subscribe_registered_users( $_POST['exportcsv'], $s2_request_category );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Subscribed!', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['sub_categories'] ) && 'unsubscribe' === $_POST['manage'] ) {
if ( isset( $_REQUEST['subscriber'] ) ) {
$this->unsubscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $s2_request_category );
} else {
$this->unsubscribe_registered_users( $_POST['exportcsv'], $s2_request_category );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['sub_format'] ) ) {
if ( isset( $_REQUEST['subscriber'] ) ) {
$this->format_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['format'] );
} else {
$this->format_change( $_POST['exportcsv'], $_POST['format'] );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Format updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
} elseif ( isset( $_POST['sub_digest'] ) ) {
if ( isset( $_REQUEST['subscriber'] ) ) {
$this->digest_change( implode( ",\r\n", $_REQUEST['subscriber'] ), $_POST['sub_category'] );
} else {
$this->digest_change( $_POST['exportcsv'], $_POST['sub_category'] );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Digest Subscription updated for Selected Registered Users!', 'subscribe2' ) . '</strong></p></div>';
}
}
if ( 'registered' === $current_tab ) {
// Get Registered Subscribers
$registered = $this->get_registered( 'return=emailid' );
$all_users = $this->get_all_registered( 'emailid' );
// safety check for our arrays
if ( '' === $registered ) {
$registered = array();
}
if ( '' === $all_users ) {
$all_users = array();
}
} else {
//Get Public Subscribers
$confirmed = $this->get_public();
$unconfirmed = $this->get_public( 0 );
// safety check for our arrays
if ( '' === $confirmed ) {
$confirmed = array();
}
if ( '' === $unconfirmed ) {
$unconfirmed = array();
}
}
$reminderform = false;
if ( isset( $_REQUEST['what'] ) ) {
if ( 'public' === $_REQUEST['what'] ) {
$what = 'public';
$subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
} elseif ( 'confirmed' === $_REQUEST['what'] ) {
$what = 'confirmed';
$subscribers = $confirmed;
} elseif ( 'unconfirmed' === $_REQUEST['what'] ) {
$what = 'unconfirmed';
$subscribers = $unconfirmed;
if ( ! empty( $subscribers ) ) {
$reminderemails = implode( ',', $subscribers );
$reminderform = true;
}
} elseif ( is_numeric( $_REQUEST['what'] ) ) {
$what = intval( $_REQUEST['what'] );
$subscribers = $this->get_registered( "cats=$what&return=emailid" );
} elseif ( 'registered' === $_REQUEST['what'] ) {
$what = 'registered';
$subscribers = $registered;
} elseif ( 'all_users' === $_REQUEST['what'] ) {
$what = 'all_users';
$subscribers = $all_users;
}
} else {
if ( 'public' === $current_tab ) {
$what = 'public';
$subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
} else {
$what = 'all_users';
$subscribers = $all_users;
}
}
if ( ! empty( $_POST['s'] ) ) {
if ( 'registered' === $current_tab ) {
foreach ( $subscribers as $subscriber ) {
if ( is_numeric( stripos( $subscriber['user_email'], $_POST['s'] ) ) ) {
$result[] = $subscriber;
}
}
} else {
foreach ( $subscribers as $subscriber ) {
if ( is_numeric( stripos( $subscriber, $_POST['s'] ) ) ) {
$result[] = $subscriber;
}
}
}
$subscribers = $result;
}
$s2_list_table->prepare_items();
// show our form
echo '<div class="wrap">';
echo '<h1>' . esc_html__( 'Subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
$s2tabs = array(
'public' => __( 'Public Subscribers', 'subscribe2' ),
'registered' => __( 'Registered Subscribers', 'subscribe2' ),
);
echo '<h2 class="nav-tab-wrapper">';
foreach ( $s2tabs as $tab_key => $tab_caption ) {
$active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
echo '<a class="nav-tab ' . esc_attr( $active ) . '" href="' . esc_url( '?page=s2_tools&amp;tab=' . $tab_key ) . '">' . esc_html( $tab_caption ) . '</a>';
}
echo '</h2>';
echo '<form method="post">' . "\r\n";
echo '<input type="hidden" name="s2_admin" />' . "\r\n";
switch ( $current_tab ) {
case 'public':
echo '<input type="hidden" id="s2_location" name="s2_location" value="public" />' . "\r\n";
echo '<div class="s2_admin" id="s2_add_subscribers">' . "\r\n";
echo '<h2>' . esc_html__( 'Add/Remove Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
echo '<p>' . esc_html__( 'Enter addresses, one per line or comma-separated', 'subscribe2' ) . '<br>' . "\r\n";
echo '<textarea rows="2" cols="80" name="addresses"></textarea></p>' . "\r\n";
echo '<input type="hidden" name="s2_admin" />' . "\r\n";
echo '<p class="submit" style="border-top: none;"><input type="submit" class="button-primary" name="subscribe" value="' . esc_attr( __( 'Subscribe', 'subscribe2' ) ) . '" />';
echo '&nbsp;<input type="submit" class="button-primary" name="unsubscribe" value="' . esc_attr( __( 'Unsubscribe', 'subscribe2' ) ) . '" /></p>' . "\r\n";
echo '</div>' . "\r\n";
// subscriber lists
echo '<div class="s2_admin" id="s2_current_subscribers">' . "\r\n";
echo '<h2>' . esc_html__( 'Current Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
echo '<br>';
$cats = $this->all_cats();
$cat_ids = array();
foreach ( $cats as $category ) {
$cat_ids[] = $category->term_id;
}
$exclude = array_merge( array( 'all', 'all_users', 'registered' ), $cat_ids );
break;
case 'registered':
echo '<input type="hidden" id="s2_location" name="s2_location" value="registered" />' . "\r\n";
echo '<div class="s2_admin" id="s2_add_subscribers">' . "\r\n";
echo '<h2>' . esc_html__( 'Add/Remove Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
echo '<p class="submit" style="border-top: none;"><a class="button-primary" href="' . esc_url( admin_url( 'user-new.php' ) ) . '">' . esc_html__( 'Add Registered User', 'subscribe2' ) . '</a></p>' . "\r\n";
echo "</div>\r\n";
// subscriber lists
echo '<div class="s2_admin" id="s2_current_subscribers">' . "\r\n";
echo '<h2>' . esc_html__( 'Current Subscribers', 'subscribe2' ) . '</h2>' . "\r\n";
echo '<br>';
$exclude = array( 'all', 'public', 'confirmed', 'unconfirmed' );
break;
}
// show the selected subscribers
echo '<table style="width: 100%; border-collapse: separate; border-spacing: 0px; *border-collapse: expression("separate", cellSpacing = "0px");"><tr>';
echo '<td style="width: 50%; text-align: left;">';
$this->display_subscriber_dropdown( $what, __( 'Filter', 'subscribe2' ), $exclude );
echo '</td>' . "\r\n";
if ( $reminderform ) {
echo '<td style="width: 25%; text-align: right;"><input type="hidden" name="reminderemails" value="' . esc_attr( $reminderemails ) . '" />' . "\r\n";
echo '<input type="submit" class="button-secondary" name="remind" value="' . esc_attr( __( 'Send Reminder Email', 'subscribe2' ) ) . '" /></td>' . "\r\n";
} else {
echo '<td style="width: 25%;"></td>';
}
if ( ! empty( $subscribers ) ) {
if ( 'public' === $current_tab ) {
$exportcsv = implode( ",\r\n", $subscribers );
} else {
$exportcsv = '';
foreach ( $subscribers as $subscriber ) {
( '' === $exportcsv ) ? $exportcsv = $subscriber['user_email'] : $exportcsv .= ",\r\n" . $subscriber['user_email'];
}
}
echo '<td style="width: 25%; text-align: right;"><input type="hidden" name="exportcsv" value="' . esc_attr( $exportcsv ) . '" />' . "\r\n";
echo '<input type="submit" class="button-secondary" name="csv" value="' . esc_attr( __( 'Save Emails to CSV File', 'subscribe2' ) ) . '" /></td>' . "\r\n";
} else {
echo '<td style="width: 25%;"></td>';
}
echo '</tr></table>';
// output our subscriber table
$s2_list_table->search_box( __( 'Search', 'subscribe2' ), 'search_id' );
$s2_list_table->display();
echo '</div>' . "\r\n";
// show bulk management form if filtered in some Registered Users
if ( 'registered' === $current_tab ) {
echo '<div class="s2_admin" id="s2_bulk_manage">' . "\r\n";
echo '<h2>' . esc_html__( 'Bulk Management', 'subscribe2' ) . '</h2>' . "\r\n";
if ( 'never' === $this->subscribe2_options['email_freq'] ) {
$categories = array();
if ( isset( $_POST['category'] ) ) {
$categories = $_POST['category'];
}
$manage = '';
if ( isset( $_POST['manage'] ) ) {
$manage = $_POST['manage'];
}
$format = '';
if ( isset( $_POST['format'] ) ) {
$format = $_POST['format'];
}
echo esc_html__( 'Preferences for Registered Users selected above can be changed using this section.', 'subscribe2' ) . '<br>' . "\r\n";
echo '<strong><em style="color: red">' . esc_html__( 'Consider User Privacy as changes cannot be undone', 'subscribe2' ) . '</em></strong><br>' . "\r\n";
echo '<br>' . esc_html__( 'Action to perform', 'subscribe2' ) . ':' . "\r\n";
echo '<label><input type="radio" name="manage" value="subscribe"' . checked( $manage, 'subscribe', false ) . ' /> ' . esc_html__( 'Subscribe', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
echo '<label><input type="radio" name="manage" value="unsubscribe"' . checked( $manage, 'unsubscribe', false ) . ' /> ' . esc_html__( 'Unsubscribe', 'subscribe2' ) . '</label><br><br>' . "\r\n";
if ( '1' === $this->subscribe2_options['reg_override'] ) {
$s2_forms->display_category_form( $categories, 1 );
} else {
$s2_forms->display_category_form( $categories, 0 );
}
echo '<p class="submit"><button class="button-primary" name="sub_categories" onclick="return bmCheck();">' . esc_html__( 'Bulk Update Categories', 'subscribe2' ) . '</button></p>';
echo '<br>' . esc_html__( 'Send email as', 'subscribe2' ) . ':' . "\r\n";
echo '<label><input type="radio" name="format" value="html"' . checked( $format, 'html', false ) . ' /> ' . esc_html__( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
echo '<label><input type="radio" name="format" value="html_excerpt"' . checked( $format, 'html_excerpt', false ) . ' /> ' . esc_html__( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
echo '<label><input type="radio" name="format" value="post"' . checked( $format, 'post', false ) . ' /> ' . esc_html__( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
echo '<label><input type="radio" name="format" value="excerpt"' . checked( $format, 'excerpt', false ) . '/> ' . esc_html__( 'Plain Text - Excerpt', 'subscribe2' ) . '</label>' . "\r\n";
echo '<p class="submit"><button class="button-primary" name="sub_format" onclick="return bmCheck();">' . esc_html__( 'Bulk Update Format', 'subscribe2' ) . '</button></p>';
} else {
$sub_cats = '';
if ( isset( $_POST['sub_category'] ) ) {
$sub_cats = $_POST['sub_category'];
}
echo esc_html__( 'Preferences for Registered Users selected above can be changed using this section.', 'subscribe2' ) . "<br>\r\n";
echo '<strong><em style="color: red">' . esc_html__( 'Consider User Privacy as changes cannot be undone.', 'subscribe2' ) . '</em></strong><br>' . "\r\n";
echo '<br>' . esc_html__( 'Subscribe Selected Users to receive a periodic digest notification', 'subscribe2' ) . ':' . "\r\n";
echo '<label><input type="radio" name="sub_category" value="digest"' . checked( $sub_cats, 'digest', false ) . ' /> ';
echo esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;' . "\r\n";
echo '<label><input type="radio" name="sub_category" value="-1"' . checked( $sub_cats, '-1', false ) . ' /> ';
echo esc_html__( 'No', 'subscribe2' ) . '</label>';
echo '<p class="submit"><button class="button-primary" name="sub_digest" onclick="return bmCheck();">' . esc_html__( 'Bulk Update Digest Subscription', 'subscribe2' ) . '</button></p>';
}
echo '</div>' . "\r\n";
}
echo '</form></div>' . "\r\n";
require ABSPATH . 'wp-admin/admin-footer.php';
// just to be sure
die;

View File

@ -1,47 +0,0 @@
<?php
if ( ! function_exists( 'add_action' ) ) {
exit();
}
require_once S2PATH . 'classes/class-s2-forms.php';
$s2_forms = new S2_Forms();
$s2_forms->init();
// was anything POSTed?
if ( isset( $_POST['s2_admin'] ) && 'user' === $_POST['s2_admin'] ) {
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'subscribe2-user_subscribers' . S2VERSION ) ) {
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
}
do_action( 's2_subscription_submit' );
}
// show our form
echo '<div class="wrap">';
global $user_ID;
$userid = $s2_forms->get_userid();
$user = get_userdata( $userid );
if ( $userid === $user_ID ) {
echo '<h1>' . esc_html__( 'Your Notification Settings', 'subscribe2' ) . "</h1>\r\n";
} else {
echo '<h1>' . esc_html__( 'Notification Settings for user:', 'subscribe2' ) . ' <span style="color: red;">' . esc_html( $user->display_name ) . '</span></h1>' . "\r\n";
}
echo '<form method="post">';
wp_nonce_field( 'subscribe2-user_subscribers' . S2VERSION );
echo '<p>';
do_action( 's2_subscription_form', $userid );
// submit
echo '<p class="submit"><input type="submit" class="button-primary" name="submit" value="' . esc_attr( __( 'Update Preferences', 'subscribe2' ) ) . ' &raquo;" /></p>';
echo '</form>' . "\r\n";
echo '</div>' . "\r\n";
require ABSPATH . 'wp-admin/admin-footer.php';
// just to be sure
die;

File diff suppressed because it is too large Load Diff

View File

@ -1,183 +0,0 @@
<?php
if ( ! class_exists( 'MO_Admin_Notice' ) ) {
class MO_Admin_Notice {
public function __construct() {
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
add_action( 'network_admin_notices', array( $this, 'admin_notice' ) );
add_action( 'admin_init', array( $this, 'dismiss_admin_notice' ) );
}
public function dismiss_admin_notice() {
if ( ! isset( $_GET['mo-adaction'] ) || 'mo_dismiss_adnotice' !== $_GET['mo-adaction'] ) {
return;
}
$url = admin_url();
update_option( 'mo_dismiss_adnotice', 'true' );
wp_safe_redirect( $url );
exit;
}
public function admin_notice() {
global $pagenow;
if ( 'index.php' === $pagenow || ( isset( $_GET['page'] ) && false !== strpos( $_GET['page'], 's2_' ) ) ) {
if ( get_option( 'mo_dismiss_adnotice', 'false' ) === 'true' ) {
return;
}
if ( $this->is_plugin_installed() && $this->is_plugin_active() ) {
return;
}
$dismiss_url = esc_url_raw(
add_query_arg(
array(
'mo-adaction' => 'mo_dismiss_adnotice',
),
admin_url()
)
);
$this->notice_css();
$install_url = wp_nonce_url(
admin_url( 'plugin-install.php?s=wemail&tab=search&type=term' ),
'install-plugin_mailoptin'
);
$activate_url = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wemail%2Fwemail.php' ), 'activate-plugin_wemail/wemail.php' );
?>
<div class="mo-admin-notice notice notice-success">
<div class="mo-notice-first-half">
<p>
<?php
printf(
// Translators: Mail Optin admin notice
__( 'Free email newsletter plugin that will %1$sincrease your email list subscribers%2$s and keep them engaged with %1$sautomated and schedule newsletters%2$s.', 'subscribe2' ),
'<span class="mo-stylize"><strong>',
'</strong></span>'
);
?>
</p>
<p style="text-decoration: underline;font-size: 12px;">Recommended by Subscribe2 plugin</p>
</div>
<div class="mo-notice-other-half">
<?php if ( ! $this->is_plugin_installed() ) : ?>
<a class="button button-primary button-hero" id="mo-install-mailoptin-plugin" href="<?php echo $install_url; ?>">
<?php _e( 'Install weMail Now for Free!', 'subscribe2' ); ?>
</a>
<?php endif; ?>
<?php if ( $this->is_plugin_installed() && ! $this->is_plugin_active() ) : ?>
<a class="button button-primary button-hero" id="mo-activate-mailoptin-plugin" href="<?php echo $activate_url; ?>">
<?php _e( 'Activate weMail Now!', 'subscribe2' ); ?>
</a>
<?php endif; ?>
<div class="mo-notice-learn-more">
<a target="_blank" href="https://getwemail.io">Learn more</a>
</div>
</div>
<a href="<?php echo $dismiss_url; ?>">
<button type="button" class="notice-dismiss">
<span class="screen-reader-text"><?php _e( 'Dismiss this notice', 'subscribe2' ); ?>.</span>
</button>
</a>
</div>
<?php
}
}
public function current_admin_url() {
$parts = wp_parse_url( home_url() );
$uri = $parts['scheme'] . '://' . $parts['host'];
if ( array_key_exists( 'port', $parts ) ) {
$uri .= ':' . $parts['port'];
}
$uri .= add_query_arg( array() );
return $uri;
}
public function is_plugin_installed() {
$installed_plugins = get_plugins();
return isset( $installed_plugins['wemail/wemail.php'] );
}
public function is_plugin_active() {
return is_plugin_active( 'wemail/wemail.php' );
}
public function notice_css() {
?>
<style type="text/css">
.mo-admin-notice {
background: #fff;
color: #000;
border-left-color: #46b450;
position: relative;
}
.mo-admin-notice .notice-dismiss:before {
color: #72777c;
}
.mo-admin-notice .mo-stylize {
line-height: 2;
}
.mo-admin-notice .button-primary {
background: #006799;
text-shadow: none;
border: 0;
box-shadow: none;
}
.mo-notice-first-half {
width: 66%;
display: inline-block;
margin: 10px 0;
}
.mo-notice-other-half {
width: 33%;
display: inline-block;
padding: 20px 0;
position: absolute;
text-align: center;
}
.mo-notice-first-half p {
font-size: 14px;
}
.mo-notice-learn-more a {
margin: 10px;
}
.mo-notice-learn-more {
margin-top: 10px;
}
</style>
<?php
}
public static function instance() {
static $instance = null;
if ( is_null( $instance ) ) {
$instance = new self();
}
return $instance;
}
}
MO_Admin_Notice::instance();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,174 +0,0 @@
<?php
class S2_Ajax {
/**
* Constructor
*/
public function __construct() {
// maybe use dev scripts
$this->script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
if ( is_admin() ) {
add_action( 'wp_ajax_nopriv_subscribe2_form', array( &$this, 's2_ajax_form_handler' ) );
add_action( 'wp_ajax_nopriv_subscribe2_submit', array( &$this, 's2_ajax_submit_handler' ) );
add_filter( 's2_ajax_form', array( &$this, 's2_ajax_form_class' ), 1 );
add_filter( 'safe_style_css', array( &$this, 's2_safe_css' ) );
global $s2_frontend;
require_once S2PATH . 'classes/class-s2-core.php';
require_once S2PATH . 'classes/class-s2-frontend.php';
$s2_frontend = new S2_Frontend();
$s2_frontend->subscribe2_options = get_option( 'subscribe2_options' );
} else {
// add actions for ajax form if enabled
add_action( 'wp_enqueue_scripts', array( &$this, 'add_ajax' ) );
}
}
/**
* Add jQuery code and CSS to front pages for ajax form
*/
public function add_ajax() {
// enqueue the jQuery script we need and let WordPress handle the dependencies
wp_enqueue_script( 'jquery-ui-dialog' );
$css = apply_filters( 's2_jqueryui_css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/ui-darkness/jquery-ui.css' );
if ( is_ssl() ) {
$css = str_replace( 'http:', 'https:', $css );
}
wp_register_style( 'jquery-ui-style', $css, array(), '1.11.4' );
wp_enqueue_style( 'jquery-ui-style' );
wp_register_script( 's2-ajax', S2URL . 'include/s2-ajax' . $this->script_debug . '.js', array(), '1.3', true );
$translation_array = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'title' => __( 'Subscribe to this blog', 'subscribe2' ),
'nonce' => wp_create_nonce( 's2_ajax_form_nonce' ),
);
wp_localize_script( 's2-ajax', 's2AjaxScriptStrings', $translation_array );
wp_enqueue_script( 's2-ajax' );
}
/**
* Ajax form handler
*/
public function s2_ajax_form_handler() {
require_once ABSPATH . '/wp-includes/shortcodes.php';
$response = str_replace( ':', '&', $_POST['data'] );
$response = str_replace( '-', '=', $response );
wp_parse_str( $response, $atts );
global $s2_frontend;
$content = $s2_frontend->widget_shortcode( $atts );
$content = apply_filters( 's2_ajax_form', $content );
$allowed_tags = array(
'form' => array(
'action' => true,
'id' => true,
'method' => true,
'name' => true,
),
'span' => array(
'style' => true,
),
'label' => array(
'for' => true,
),
'input' => array(
'id' => true,
'name' => true,
'onblur' => true,
'onfocus' => true,
'size' => true,
'type' => true,
'value' => true,
),
'p' => true,
'br' => true,
);
echo wp_kses( $content, $allowed_tags );
exit();
}
/**
* Ajax submit handler
*/
public function s2_ajax_submit_handler() {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 's2_ajax_form_nonce' ) ) {
echo '<p>' . esc_html__( 'There was an error validating your request. Please try again later.', 'subscribe2' ) . '</p>';
wp_die();
}
$data = $_POST['data'];
if ( ( isset( $data['firstname'] ) && '' !== $data['firstname'] ) || ( isset( $data['lastname'] ) && '' !== $data['lastname'] ) || ( isset( $data['uri'] ) && 'http://' !== $data['uri'] ) ) {
// looks like some invisible-to-user fields were changed; falsely report success
echo '<p>' . esc_html__( 'A confirmation message is on its way!', 'subscribe2' ) . '</p>';
wp_die();
}
global $s2_frontend, $wpdb;
$s2_frontend->email = $s2_frontend->sanitize_email( $data['email'] );
$s2_frontend->ip = $data['ip'];
if ( false === $s2_frontend->validate_email( $s2_frontend->email ) ) {
echo '<p>' . esc_html__( 'Sorry, but that does not look like an email address to me.', 'subscribe2' ) . '</p>';
} elseif ( $s2_frontend->is_barred( $s2_frontend->email ) ) {
echo '<p>' . esc_html__( 'Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2' ) . '</p>';
} else {
if ( is_int( $s2_frontend->lockout ) && $s2_frontend->lockout > 0 ) {
$date = gmdate( 'H:i:s.u', $s2_frontend->lockout );
$ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
if ( in_array( $s2_frontend->ip, $ips, true ) ) {
echo '<p>' . esc_html__( 'Slow down, you move too fast.', 'subscribe2' ) . '</p>';
}
}
$check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $s2_frontend->email ) );
if ( null !== $check ) {
// Translators: Link to login page
printf( wp_kses_post( __( 'To manage your subscription options please <a href="%1$s">login.</a>', 'subscribe2' ) ), esc_url( get_option( 'siteurl' ) . '/wp-login.php' ) );
}
if ( 'subscribe' === $data['button'] ) {
if ( '1' !== $s2_frontend->is_public( $s2_frontend->email ) ) {
// the user is unknown or inactive
$s2_frontend->add( $s2_frontend->email );
$status = $s2_frontend->send_confirm( 'add' );
if ( $status ) {
echo '<p>' . esc_html__( 'A confirmation message is on its way!', 'subscribe2' ) . '</p>';
} else {
echo '<p>' . esc_html__( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
}
} else {
// they're already subscribed
echo '<p>' . esc_html__( 'That email address is already subscribed.', 'subscribe2' ) . '</p>';
}
} elseif ( 'unsubscribe' === $data['button'] ) {
if ( false === $s2_frontend->is_public( $s2_frontend->email ) ) {
echo '<p>' . esc_html__( 'That email address is not subscribed.', 'subscribe2' ) . '</p>';
} else {
$status = $s2_frontend->send_confirm( 'del' );
if ( $status ) {
echo '<p>' . esc_html__( 'A confirmation message is on its way!', 'subscribe2' ) . '</p>';
} else {
echo '<p>' . esc_html__( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
}
}
}
}
wp_die();
}
/**
* Filter to add ajax id to form
*/
public function s2_ajax_form_class( $content ) {
$content = str_replace( '<form', '<form id="s2ajaxform"', $content );
$content = str_replace( 'wp-login.php"', 'wp-login.php" style="text-decoration: underline;"', $content );
return $content;
}
/**
* Add display attribute to safe CSS
*/
public function s2_safe_css( $style_attributes ) {
$style_attributes[] = 'display';
return $style_attributes;
}
}

View File

@ -1,211 +0,0 @@
<?php
class S2_Block_Editor {
/**
* Constructor
*/
public function __construct() {
// maybe use dev scripts
$this->script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
add_action( 'init', array( &$this, 'register_s2_meta' ) );
add_action( 'rest_api_init', array( $this, 'register_preview_endpoint' ) );
add_action( 'rest_api_init', array( $this, 'register_resend_endpoint' ) );
add_action( 'rest_api_init', array( $this, 'register_settings_endpoint' ) );
if ( is_admin() ) {
add_action( 'enqueue_block_editor_assets', array( &$this, 'gutenberg_block_editor_assets' ), 6 );
add_action( 'enqueue_block_editor_assets', array( &$this, 'gutenberg_i18n' ), 6 );
}
}
/**
* Register _s2mail meta data for Block Editor
*/
public function register_s2_meta() {
register_meta(
'post',
'_s2mail',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
'auth_callback' => function() {
return current_user_can( 'edit_posts' );
},
)
);
}
/**
* Register REST endpoints for preview email
*/
public function register_preview_endpoint() {
register_rest_route(
's2/v1',
'/preview/(?P<id>[0-9]+)',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'preview' ),
'args' => array(
'id' => array(
'validate_callback' => function( $param ) {
return is_numeric( $param );
},
),
),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
)
);
}
/**
* Register REST endpoints for resending emails
*/
public function register_resend_endpoint() {
register_rest_route(
's2/v1',
'/resend/(?P<id>[0-9]+)',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'resend' ),
'args' => array(
'id' => array(
'validate_callback' => function( $param ) {
return is_numeric( $param );
},
),
),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
)
);
}
/**
* Register REST endpoints for surfacing settings
*/
public function register_settings_endpoint() {
register_rest_route(
's2/v1',
'/settings/(?P<setting>[a-z0-9_]+)',
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'setting' ),
'args' => array(
'id' => array(
'validate_callback' => function( $param ) {
return preg_match( '/^[a-z0-9_]+$/', $param ) > 0;
},
),
),
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
)
);
}
/**
* Function to trigger Preview email on REST API request
*/
public function preview( $data ) {
global $mysubscribe2;
$post = get_post( intval( $data['id'] ) );
$current_user = wp_get_current_user();
if ( 0 === $current_user->ID ) {
return false;
}
if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
$mysubscribe2->subscribe2_cron( $current_user->user_email );
} else {
$mysubscribe2->publish( $post, $current_user->user_email );
}
return true;
}
/**
* Function to trigger resending of email on REST API request
*/
public function resend( $data ) {
global $mysubscribe2;
$post = get_post( intval( $data['id'] ) );
$current_user = wp_get_current_user();
if ( 0 === $current_user->ID ) {
return false;
}
$mysubscribe2->publish( $post );
return true;
}
/**
* Function to return value for passed setting
*/
public function setting( $data ) {
global $mysubscribe2;
if ( array_key_exists( $data['setting'], $mysubscribe2->subscribe2_options ) ) {
return $mysubscribe2->subscribe2_options[ $data['setting'] ];
}
return false;
}
/**
* Enqueue Block Editor assets
*/
public function gutenberg_block_editor_assets() {
wp_enqueue_script(
'subscribe2-shortcode',
S2URL . 'gutenberg/shortcode' . $this->script_debug . '.js',
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
'1.1',
true
);
register_block_type(
'subscribe2-html/shortcode',
array(
'editor_script' => 'subscribe2-shortcode',
)
);
wp_enqueue_script(
'subscribe2-sidebar',
S2URL . 'gutenberg/sidebar' . $this->script_debug . '.js',
array( 'wp-plugins', 'wp-element', 'wp-i18n', 'wp-edit-post', 'wp-components', 'wp-data', 'wp-compose', 'wp-api-fetch' ),
'1.1',
true
);
}
/**
* Handle translation of Block Editor assets
*/
public function gutenberg_i18n() {
$translations = get_translations_for_domain( 'subscribe2' );
$locale_data = array(
'' => array(
'domain' => 'subscribe2',
'lang' => get_user_locale(),
'plural_forms' => 'nplurals=2; plural=n != 1;',
),
);
foreach ( $translations->entries as $msgid => $entry ) {
$locale_data[ $msgid ] = $entry->translations;
}
wp_add_inline_script(
'wp-i18n',
'wp.i18n.setLocaleData( ' . wp_json_encode( $locale_data ) . ', "subscribe2" );'
);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,119 +0,0 @@
<?php
class S2_Counter_Widget extends WP_Widget {
/**
* Declares the S2_Counter_widget class.
*/
public function __construct() {
$widget_options = array(
'classname' => 's2_counter',
'description' => esc_html__( 'Subscriber Counter widget for Subscribe2', 'subscribe2' ),
'customize_selective_refresh' => true,
);
$control_options = array(
'width' => 250,
'height' => 500,
);
parent::__construct( 's2_counter', esc_html__( 'Subscribe2 Counter', 'subscribe2' ), $widget_options, $control_options );
}
/**
* Displays the Widget
*/
public function widget( $args, $instance ) {
$title = empty( $instance['title'] ) ? 'Subscriber Count' : $instance['title'];
$s2w_bg = empty( $instance['s2w_bg'] ) ? '#e3dacf' : $instance['s2w_bg'];
$s2w_fg = empty( $instance['s2w_fg'] ) ? '#345797' : $instance['s2w_fg'];
$s2w_width = empty( $instance['s2w_width'] ) ? '82' : $instance['s2w_width'];
$s2w_height = empty( $instance['s2w_height'] ) ? '16' : $instance['s2w_height'];
$s2w_font = empty( $instance['s2w_font'] ) ? '11' : $instance['s2w_font'];
echo wp_kses_post( $args['before_widget'] );
if ( ! empty( $title ) ) {
echo wp_kses_post( $args['before_title'] ) . esc_html( $title ) . wp_kses_post( $args['after_title'] );
}
global $mysubscribe2;
$registered = $mysubscribe2->get_registered();
$confirmed = $mysubscribe2->get_public();
$count = ( count( $registered ) + count( $confirmed ) );
echo wp_kses_post( '<ul><div style="text-align:center; background-color:' . $s2w_bg . '; color:' . $s2w_fg . '; width:' . $s2w_width . 'px; height:' . $s2w_height . 'px; font:' . $s2w_font . 'pt Verdana, Arial, Helvetica, sans-serif; vertical-align:middle; padding:3px; border:1px solid #444;">' );
echo esc_html( $count );
echo '</div></ul>';
echo wp_kses_post( $args['after_widget'] );
}
/**
* Saves the widgets settings.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = wp_strip_all_tags( stripslashes( $new_instance['title'] ) );
$instance['s2w_bg'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_bg'] ) );
$instance['s2w_fg'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_fg'] ) );
$instance['s2w_width'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_width'] ) );
$instance['s2w_height'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_height'] ) );
$instance['s2w_font'] = wp_strip_all_tags( stripslashes( $new_instance['s2w_font'] ) );
return $instance;
}
/**
* Creates the edit form for the widget.
*/
public function form( $instance ) {
// set some defaults
$options = get_option( 'widget_s2counter' );
if ( false === $options ) {
$defaults = array(
'title' => 'Subscriber Count',
's2w_bg' => '#e3dacf',
's2w_fg' => '#345797',
's2w_width' => '82',
's2w_height' => '16',
's2w_font' => '11',
);
} else {
$defaults = array(
'title' => $options['title'],
's2w_bg' => $options['s2w_bg'],
's2w_fg' => $options['s2w_fg'],
's2w_width' => $options['s2w_width'],
's2w_height' => $options['s2w_height'],
's2w_font' => $options['s2w_font'],
);
delete_option( 'widget_s2counter' );
}
$instance = wp_parse_args( (array) $instance, $defaults );
// Be sure you format your options to be valid HTML attributes.
$s2w_title = htmlspecialchars( $instance['title'], ENT_QUOTES );
$s2w_bg = htmlspecialchars( $instance['s2w_bg'], ENT_QUOTES );
$s2w_fg = htmlspecialchars( $instance['s2w_fg'], ENT_QUOTES );
$s2w_width = htmlspecialchars( $instance['s2w_width'], ENT_QUOTES );
$s2w_height = htmlspecialchars( $instance['s2w_height'], ENT_QUOTES );
$s2w_font = htmlspecialchars( $instance['s2w_font'], ENT_QUOTES );
echo '<div>' . "\r\n";
echo '<fieldset><legend><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Widget Title', 'subscribe2' ) . '</label></legend>' . "\r\n";
echo '<input type="text" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" value="' . esc_attr( $s2w_title ) . '" />' . "\r\n";
echo '</fieldset>' . "\r\n";
echo '<fieldset>' . "\r\n";
echo '<legend>' . esc_html__( 'Color Scheme', 'subscribe2' ) . '</legend>' . "\r\n";
echo '<label>' . "\r\n";
echo '<input type="text" name="' . esc_attr( $this->get_field_name( 's2w_bg' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_bg' ) ) . '" maxlength="6" value="' . esc_attr( $s2w_bg ) . '" class="colorpickerField" style="width:60px;" /> ' . esc_html__( 'Body', 'subscribe2' ) . '</label><br>' . "\r\n";
echo '<label>' . "\r\n";
echo '<input type="text" name="' . esc_attr( $this->get_field_name( 's2w_fg' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_fg' ) ) . '" maxlength="6" value="' . esc_attr( $s2w_fg ) . '" class="colorpickerField" style="width:60px;" /> ' . esc_html__( 'Text', 'subscribe2' ) . '</label><br>' . "\r\n";
echo '<div class="s2_colorpicker" id ="' . esc_attr( $this->get_field_id( 's2_colorpicker' ) ) . '"></div>';
echo '</fieldset>';
echo '<fieldset>' . "\r\n";
echo '<legend>' . esc_html__( 'Width, Height and Font Size', 'subscribe2' ) . '</legend>' . "\r\n";
echo '<table style="border:0; padding:0; margin:0 0 12px 0; border-collapse:collapse;" align="center">' . "\r\n";
echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_width' ) ) . '">' . esc_html__( 'Width', 'subscribe2' ) . '</label></td>' . "\r\n";
echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_width' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_width' ) ) . '" value="' . esc_attr( $s2w_width ) . '" /></td></tr>' . "\r\n";
echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_height' ) ) . '">' . esc_html__( 'Height', 'subscribe2' ) . '</label></td>' . "\r\n";
echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_height' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_height' ) ) . '" value="' . esc_attr( $s2w_height ) . '" /></td></tr>' . "\r\n";
echo '<tr><td><label for="' . esc_attr( $this->get_field_id( 's2w_font' ) ) . '">' . esc_html__( 'Font', 'subscribe2' ) . '</label></td>' . "\r\n";
echo '<td><input type="text" name="' . esc_attr( $this->get_field_name( 's2w_font' ) ) . '" id="' . esc_attr( $this->get_field_id( 's2w_font' ) ) . '" value="' . esc_attr( $s2w_font ) . '" /></td></tr>' . "\r\n";
echo '</table></fieldset></div>' . "\r\n";
}
}// end S2_Counter_widget class

View File

@ -1,198 +0,0 @@
<?php
class S2_Form_Widget extends WP_Widget {
// Display the widgets instance in the REST API
public $show_instance_in_rest = true;
/**
* Declares the Subscribe2 widget class.
*/
public function __construct() {
$widget_ops = array(
'classname' => 's2_form_widget',
'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ),
'customize_selective_refresh' => true,
'show_instance_in_rest' => true,
);
// add_filter( 'widget_text', 'shortcode_unautop' );
// add_filter( 'widget_text', 'do_shortcode' );
$control_ops = array(
'width' => 250,
'height' => 300,
);
parent::__construct( 's2_form_widget', esc_html__( 'Subscribe2 Widget', 'subscribe2' ), $widget_ops, $control_ops );
}
/**
* Displays the Widget
*/
public function widget( $args, $instance ) {
$title = empty( $instance['title'] ) ? __( 'Subscribe2', 'subscribe2' ) : $instance['title'];
$div = empty( $instance['div'] ) ? 'search' : $instance['div'];
$widgetprecontent = empty( $instance['widgetprecontent'] ) ? '' : $instance['widgetprecontent'];
$widgetpostcontent = empty( $instance['widgetpostcontent'] ) ? '' : $instance['widgetpostcontent'];
$textbox_size = empty( $instance['size'] ) ? 20 : $instance['size'];
$hidebutton = empty( $instance['hidebutton'] ) ? 'none' : $instance['hidebutton'];
$postto = empty( $instance['postto'] ) ? '' : $instance['postto'];
$js = empty( $instance['js'] ) ? '' : $instance['js'];
$noantispam = empty( $instance['noantispam'] ) ? '' : $instance['noantispam'];
$nowrap = empty( $instance['nowrap'] ) ? '' : $instance['nowrap'];
$hide = '';
if ( 'subscribe' === $hidebutton || 'unsubscribe' === $hidebutton ) {
$hide = ' hide="' . $hidebutton . '"';
} elseif ( 'link' === $hidebutton ) {
$hide = ' link="' . __( '(Un)Subscribe to Posts', 'subscribe2' ) . '"';
}
$postid = '';
if ( ! empty( $postto ) ) {
$postid = ' id="' . $postto . '"';
}
$size = ' size="' . $textbox_size . '"';
$nojs = '';
if ( $js ) {
$nojs = ' nojs="true"';
}
if ( $noantispam ) {
$noantispam = ' noantispam="true"';
}
if ( $nowrap ) {
$nowrap = ' wrap="false"';
}
$shortcode = '[subscribe2' . $hide . $postid . $size . $nojs . $noantispam . $nowrap . ' widget="true"]';
echo wp_kses_post( $args['before_widget'] );
if ( ! empty( $title ) ) {
echo wp_kses_post( $args['before_title'] ) . esc_attr( $title ) . wp_kses_post( $args['after_title'] );
}
echo '<div class="' . esc_attr( $div ) . '">';
if ( ! empty( $widgetprecontent ) ) {
echo wp_kses_post( $widgetprecontent );
}
echo do_shortcode( $shortcode );
if ( ! empty( $widgetpostcontent ) ) {
echo wp_kses_post( $widgetpostcontent );
}
echo '</div>';
echo wp_kses_post( $args['after_widget'] );
}
/**
* Saves the widgets settings.
*/
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = wp_strip_all_tags( stripslashes( $new_instance['title'] ) );
$instance['div'] = wp_strip_all_tags( stripslashes( $new_instance['div'] ) );
$instance['widgetprecontent'] = stripslashes( $new_instance['widgetprecontent'] );
$instance['widgetpostcontent'] = stripslashes( $new_instance['widgetpostcontent'] );
$instance['size'] = intval( stripslashes( $new_instance['size'] ) );
$instance['hidebutton'] = wp_strip_all_tags( stripslashes( $new_instance['hidebutton'] ) );
$instance['postto'] = stripslashes( $new_instance['postto'] );
$instance['js'] = stripslashes( $new_instance['js'] );
$instance['noantispam'] = stripslashes( $new_instance['noantispam'] );
$instance['nowrap'] = stripslashes( $new_instance['nowrap'] );
return $instance;
}
/**
* Creates the edit form for the widget.
*/
public function form( $instance ) {
// set some defaults, getting any old options first
$options = get_option( 'widget_subscribe2widget' );
if ( false === $options ) {
$defaults = array(
'title' => 'Subscribe2',
'div' => 'search',
'widgetprecontent' => '',
'widgetpostcontent' => '',
'size' => 20,
'hidebutton' => 'none',
'postto' => '',
'js' => '',
'noantispam' => '',
'nowrap' => '',
);
} else {
$defaults = array(
'title' => $options['title'],
'div' => $options['div'],
'widgetprecontent' => $options['widgetprecontent'],
'widgetpostcontent' => $options['widgetpostcontent'],
'size' => $options['size'],
'hidebutton' => $options['hidebutton'],
'postto' => $options['postto'],
'js' => $options['js'],
'noantispam' => $options['noantispam'],
'nowrap' => $options['nowrap'],
);
delete_option( 'widget_subscribe2widget' );
}
// code to obtain old settings too
$instance = wp_parse_args( (array) $instance, $defaults );
$title = htmlspecialchars( $instance['title'], ENT_QUOTES );
$div = htmlspecialchars( $instance['div'], ENT_QUOTES );
$widgetprecontent = htmlspecialchars( $instance['widgetprecontent'], ENT_QUOTES );
$widgetpostcontent = htmlspecialchars( $instance['widgetpostcontent'], ENT_QUOTES );
$size = htmlspecialchars( $instance['size'], ENT_QUOTES );
$hidebutton = htmlspecialchars( $instance['hidebutton'], ENT_QUOTES );
$postto = htmlspecialchars( $instance['postto'], ENT_QUOTES );
$js = htmlspecialchars( $instance['js'], ENT_QUOTES );
$noantispam = htmlspecialchars( $instance['noantispam'], ENT_QUOTES );
$nowrap = htmlspecialchars( $instance['nowrap'], ENT_QUOTES );
global $wpdb, $mysubscribe2;
$sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type='page' AND post_status='publish'";
echo '<div>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Title', 'subscribe2' ) . ':' . "\r\n";
echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $title ) . '" /></label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'div' ) ) . '">' . esc_html__( 'Div class name', 'subscribe2' ) . ':' . "\r\n";
echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'div' ) ) . '" name="' . esc_attr( $this->get_field_name( 'div' ) ) . '" type="text" value="' . esc_attr( $div ) . '" /></label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '">' . esc_html__( 'Pre-Content', 'subscribe2' ) . ':' . "\r\n";
echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetprecontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetprecontent' ) ) . '" rows="2" cols="25">' . esc_attr( $widgetprecontent ) . '</textarea></label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '">' . esc_html__( 'Post-Content', 'subscribe2' ) . ':' . "\r\n";
echo '<textarea class="widefat" id="' . esc_attr( $this->get_field_id( 'widgetpostcontent' ) ) . '" name="' . esc_attr( $this->get_field_name( 'widgetpostcontent' ) ) . '" rows="2" cols="25">' . esc_attr( $widgetpostcontent ) . '</textarea></label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'size' ) ) . '">' . esc_html__( 'Text Box Size', 'subscribe2' ) . ':' . "\r\n";
echo '<input class="widefat" id="' . esc_attr( $this->get_field_id( 'size' ) ) . '" name="' . esc_attr( $this->get_field_name( 'size' ) ) . '" type="text" value="' . esc_attr( $size ) . '" /></label></p>' . "\r\n";
echo '<p>' . esc_html__( 'Display options', 'subscribe2' ) . ':<br>' . "\r\n";
echo '<label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'complete" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="none"' . checked( 'none', $hidebutton, false ) . '/> ' . esc_html__( 'Show complete form', 'subscribe2' ) . '</label>' . "\r\n";
echo '<br><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'subscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="subscribe"' . checked( 'subscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Subscribe button', 'subscribe2' ) . '</label>' . "\r\n";
echo '<br><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'unsubscribe" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="unsubscribe"' . checked( 'unsubscribe', $hidebutton, false ) . '/> ' . esc_html__( 'Hide Unsubscribe button', 'subscribe2' ) . '</label>' . "\r\n";
if ( '1' === $mysubscribe2->subscribe2_options['ajax'] ) {
echo '<br><label for="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax"><input id="' . esc_attr( $this->get_field_id( 'hidebutton' ) ) . 'ajax" name="' . esc_attr( $this->get_field_name( 'hidebutton' ) ) . '" type="radio" value="link"' . checked( 'link', $hidebutton, false ) . '/> ' . esc_html__( 'Show as link', 'subscribe2' ) . '</label>' . "\r\n";
}
echo '</p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'postto' ) ) . '">' . esc_html__( 'Post form content to page', 'subscribe2' ) . ':' . "\r\n";
echo '<select class="widefat" id="' . esc_attr( $this->get_field_id( 'postto' ) ) . '" name="' . esc_attr( $this->get_field_name( 'postto' ) ) . '">' . "\r\n";
echo '<option value="' . esc_attr( $mysubscribe2->subscribe2_options['s2page'] ) . '">' . esc_html__( 'Use Subscribe2 Default', 'subscribe2' ) . '</option>' . "\r\n";
echo '<option value="home"';
if ( 'home' === $postto ) {
echo ' selected="selected"';
}
echo '>' . esc_html__( 'Use Home Page', 'subscribe2' ) . '</option>' . "\r\n";
echo '<option value="self"';
if ( 'self' === $postto ) {
echo ' selected="selected"';
}
echo '>' . esc_html__( 'Use Referring Page', 'subscribe2' ) . '</option>' . "\r\n";
$mysubscribe2->pages_dropdown( $postto );
echo '</select></label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'js' ) ) . '">' . esc_html__( 'Disable JavaScript', 'subscribe2' ) . ':' . "\r\n";
echo '<input id="' . esc_attr( $this->get_field_id( 'js' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'js' ) ) . '" value="true" type="checkbox"' . checked( 'true', $js, false ) . '/>';
echo '</label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'noantispam' ) ) . '">' . esc_html__( 'Disable Anti-spam measures', 'subscribe2' ) . ':' . "\r\n";
echo '<input id="' . esc_attr( $this->get_field_id( 'noantispam' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'noantispam' ) ) . '" value="true" type="checkbox"' . checked( 'true', $noantispam, false ) . '/>';
echo '</label></p>' . "\r\n";
echo '<p><label for="' . esc_attr( $this->get_field_id( 'nowrap' ) ) . '">' . esc_html__( 'Disable wrapping of form buttons', 'subscribe2' ) . ':' . "\r\n";
echo '<input id="' . esc_attr( $this->get_field_id( 'nowrap' ) ) . '" name ="' . esc_attr( $this->get_field_name( 'nowrap' ) ) . '" value="true" type="checkbox"' . checked( 'true', $nowrap, false ) . '/>';
echo '</label></p>' . "\r\n";
echo '</div>' . "\r\n";
}
} // End S2_Form_widget class

View File

@ -1,428 +0,0 @@
<?php
class S2_Forms {
/**
* Functions to Display content of Your Subscriptions page and process any input
*/
public function init() {
add_action( 's2_subscription_submit', array( &$this, 's2_your_subscription_submit' ) );
add_action( 's2_subscription_form', array( &$this, 's2_your_subscription_form' ), 10, 2 );
}
/**
* Return appropriate user ID if user can edit other users subscriptions
*/
public function get_userid() {
if ( isset( $_GET['id'] ) ) {
if ( ! current_user_can( apply_filters( 's2_capability', 'manage_options', 'manage' ) ) ) {
die( '<p>' . esc_html__( 'Permission error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
}
if ( is_multisite() ) {
if ( ! is_user_member_of_blog( $_GET['id'], get_current_blog_id() ) ) {
die( '<p>' . esc_html__( 'Permission error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
} else {
$userid = (int) $_GET['id'];
}
} else {
$userid = (int) $_GET['id'];
}
} else {
global $user_ID;
return $user_ID;
}
return $userid;
}
/**
* Display the form to allow Regsitered users to amend their subscription
*/
public function s2_your_subscription_form( $userid ) {
if ( ! is_int( $userid ) ) {
return false;
}
global $mysubscribe2;
echo '<input type="hidden" name="s2_admin" value="user" />';
if ( 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
echo esc_html__( 'Receive email as', 'subscribe2' ) . ': &nbsp;&nbsp;';
echo '<label><input type="radio" name="s2_format" value="html"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'html', false ) . ' />';
echo ' ' . esc_html__( 'HTML - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="s2_format" value="html_excerpt"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'html_excerpt', false ) . ' />';
echo ' ' . esc_html__( 'HTML - Excerpt', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="s2_format" value="post"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'post', false ) . ' />';
echo ' ' . esc_html__( 'Plain Text - Full', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="s2_format" value="excerpt"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true ), 'excerpt', false ) . ' />';
echo ' ' . esc_html__( 'Plain Text - Excerpt', 'subscribe2' ) . '</label><br><br>' . "\r\n";
if ( 'yes' === $mysubscribe2->subscribe2_options['show_autosub'] ) {
echo esc_html__( 'Automatically subscribe me to newly created categories', 'subscribe2' ) . ': &nbsp;&nbsp;';
echo '<label><input type="radio" name="new_category" value="yes"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), true ), 'yes', false ) . ' />';
echo ' ' . esc_html__( 'Yes', 'subscribe2' ) . '</label>&nbsp;&nbsp;';
echo '<label><input type="radio" name="new_category" value="no"' . checked( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), true ), 'no', false ) . ' />';
echo ' ' . esc_html__( 'No', 'subscribe2' ) . '</label>';
echo '</p>';
}
if ( 'yes' === $mysubscribe2->subscribe2_options['one_click_profile'] ) {
// One-click subscribe and unsubscribe buttons
echo '<h2>' . esc_html__( 'One Click Subscription / Unsubscription', 'subscribe2' ) . "</h2>\r\n";
echo '<p class="submit"><input type="submit" class="button-primary" name="subscribe" value="' . esc_html__( 'Subscribe to All', 'subscribe2' ) . '" />&nbsp;&nbsp;';
echo '<input type="submit" class="button-primary" name="unsubscribe" value="' . esc_html__( 'Unsubscribe from All', 'subscribe2' ) . '" /></p>';
}
// subscribed categories
if ( $mysubscribe2->s2_mu ) {
global $blog_id;
$subscribed = get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
// if we are subscribed to the current blog display an "unsubscribe" link
if ( ! empty( $subscribed ) ) {
$unsubscribe_link = esc_url( add_query_arg( 's2mu_unsubscribe', $blog_id ) );
echo '<p><a href="' . esc_url( $unsubscribe_link ) . '" class="button">' . esc_html__( 'Unsubscribe me from this blog', 'subscribe2' ) . '</a></p>';
} else {
// else we show a "subscribe" link
$subscribe_link = esc_url( add_query_arg( 's2mu_subscribe', $blog_id ) );
echo '<p><a href="' . esc_url( $subscribe_link ) . '" class="button">' . esc_html__( 'Subscribe to all categories', 'subscribe2' ) . '</a></p>';
}
echo '<h2>' . esc_html__( 'Subscribed Categories on', 'subscribe2' ) . ' ' . esc_html( get_option( 'blogname' ) ) . ' </h2>' . "\r\n";
} else {
echo '<h2>' . esc_html__( 'Subscribed Categories', 'subscribe2' ) . '</h2>' . "\r\n";
}
('' === $mysubscribe2->subscribe2_options['compulsory']) ? $compulsory = array() : $compulsory = explode( ',', $mysubscribe2->subscribe2_options['compulsory'] );
$this->display_category_form( explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ), $mysubscribe2->subscribe2_options['reg_override'], $compulsory );
} else {
// we're doing daily digests, so just show
// subscribe / unnsubscribe
echo esc_html__( 'Receive periodic summaries of new posts?', 'subscribe2' ) . ': &nbsp;&nbsp;';
echo '<label>';
echo '<input type="radio" name="category" value="digest"';
if ( get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ) {
echo ' checked="checked"';
}
echo ' /> ' . esc_html__( 'Yes', 'subscribe2' ) . '</label> <label><input type="radio" name="category" value="-1" ';
if ( ! get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) ) {
echo ' checked="checked"';
}
echo ' /> ' . esc_html__( 'No', 'subscribe2' );
echo '</label></p>';
}
if ( count( $this->get_authors() ) > 1 && 'never' === $mysubscribe2->subscribe2_options['email_freq'] ) {
echo '<div class="s2_admin" id="s2_authors">' . "\r\n";
echo '<h2>' . esc_html__( 'Do not send notifications for post made by these authors', 'subscribe2' ) . '</h2>' . "\r\n";
$this->display_author_form( explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), true ) ) );
echo '</div>' . "\r\n";
}
// list of subscribed blogs on WordPress mu
if ( $mysubscribe2->s2_mu && ! isset( $_GET['email'] ) ) {
global $blog_id, $s2class_multisite;
$s2blog_id = $blog_id;
$current_user = wp_get_current_user();
$blogs = $s2class_multisite->get_mu_blog_list();
$blogs_subscribed = array();
$blogs_notsubscribed = array();
foreach ( $blogs as $blog ) {
// switch to blog
switch_to_blog( $blog['blog_id'] );
// check that the Subscribe2 plugin is active on the current blog
$current_plugins = get_option( 'active_plugins' );
if ( ! is_array( $current_plugins ) ) {
$current_plugins = (array) $current_plugins;
}
if ( ! in_array( S2DIR . 'subscribe2.php', $current_plugins, true ) ) {
continue;
}
// check if we're subscribed to the blog
$subscribed = get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
$blogname = get_option( 'blogname' );
if ( strlen( $blogname ) > 30 ) {
$blog['blogname'] = wp_html_excerpt( $blogname, 30 ) . '..';
} else {
$blog['blogname'] = $blogname;
}
$blog['description'] = get_option( 'blogdescription' );
$blog['blogurl'] = get_option( 'home' );
$blog['subscribe_page'] = get_option( 'home' ) . '/wp-admin/admin.php?page=s2';
$key = strtolower( $blog['blogname'] . '-' . $blog['blog_id'] );
if ( ! empty( $subscribed ) ) {
$blogs_subscribed[ $key ] = $blog;
} else {
$blogs_notsubscribed[ $key ] = $blog;
}
restore_current_blog();
}
echo '<div class="s2_admin" id="s2_mu_sites">' . "\r\n";
if ( ! empty( $blogs_subscribed ) ) {
ksort( $blogs_subscribed );
echo '<h2>' . esc_html__( 'Subscribed Blogs', 'subscribe2' ) . '</h2>' . "\r\n";
echo '<ul class="s2_blogs">' . "\r\n";
foreach ( $blogs_subscribed as $blog ) {
echo '<li><span class="name"><a href="' . esc_url( $blog['blogurl'] ) . '" title="' . esc_attr( $blog['description'] ) . '">' . esc_html( $blog['blogname'] ) . '</a></span>' . "\r\n";
if ( $s2blog_id === $blog['blog_id'] ) {
echo '<span class="buttons">' . esc_html__( 'Viewing Settings Now', 'subscribe2' ) . '</span>' . "\r\n";
} else {
echo '<span class="buttons">';
if ( is_user_member_of_blog( $current_user->id, $blog['blog_id'] ) ) {
echo '<a href="' . esc_url( $blog['subscribe_page'] ) . '">' . esc_html__( 'View Settings', 'subscribe2' ) . '</a>' . "\r\n";
}
echo '<a href="' . esc_url( add_query_arg( 's2mu_unsubscribe', $blog['blog_id'] ) ) . '">' . esc_html__( 'Unsubscribe', 'subscribe2' ) . '</a></span>' . "\r\n";
}
echo '<div class="additional_info">' . esc_html( $blog['description'] ) . '</div>' . "\r\n";
echo '</li>';
}
echo '</ul>' . "\r\n";
}
if ( ! empty( $blogs_notsubscribed ) ) {
ksort( $blogs_notsubscribed );
echo '<h2>' . esc_html__( 'Subscribe to new blogs', 'subscribe2' ) . "</h2>\r\n";
echo '<ul class="s2_blogs">';
foreach ( $blogs_notsubscribed as $blog ) {
echo '<li><span class="name"><a href="' . esc_url( $blog['blogurl'] ) . '" title="' . esc_attr( $blog['description'] ) . '">' . esc_html( $blog['blogname'] ) . '</a></span>' . "\r\n";
if ( $s2blog_id === $blog['blog_id'] ) {
echo '<span class="buttons">' . esc_html__( 'Viewing Settings Now', 'subscribe2' ) . '</span>' . "\r\n";
} else {
echo '<span class="buttons">';
if ( is_user_member_of_blog( $current_user->id, $blog['blog_id'] ) ) {
echo '<a href="' . esc_url( $blog['subscribe_page'] ) . '">' . esc_html__( 'View Settings', 'subscribe2' ) . '</a>' . "\r\n";
}
echo '<a href="' . esc_url( add_query_arg( 's2mu_subscribe', $blog['blog_id'] ) ) . '">' . esc_html__( 'Subscribe', 'subscribe2' ) . '</a></span>' . "\r\n";
}
echo '<div class="additional_info">' . esc_html( $blog['description'] ) . '</div>' . "\r\n";
echo '</li>';
}
echo '</ul>' . "\r\n";
}
echo '</div>' . "\r\n";
}
}
/**
* Process input from the form that allows Regsitered users to amend their subscription
*/
public function s2_your_subscription_submit() {
global $mysubscribe2, $user_ID;
$userid = $this->get_userid();
if ( isset( $_POST['submit'] ) ) {
if ( isset( $_POST['s2_format'] ) ) {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), $_POST['s2_format'] );
} else {
// value has not been set so use default
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_format' ), 'excerpt' );
}
if ( isset( $_POST['new_category'] ) ) {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), $_POST['new_category'] );
} else {
// value has not been passed so use Settings defaults
if ( 'yes' === $mysubscribe2->subscribe2_options['show_autosub'] && 'yes' === $mysubscribe2->subscribe2_options['autosub_def'] ) {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), 'yes' );
} else {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), 'no' );
}
}
$cats = ( isset( $_POST['category'] ) ) ? $_POST['category'] : '';
if ( empty( $cats ) || '-1' === $cats ) {
$oldcats = explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) );
if ( $oldcats ) {
foreach ( $oldcats as $cat ) {
delete_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat );
}
}
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
} elseif ( 'digest' === $cats ) {
$all_cats = $mysubscribe2->all_cats( false, 'ID' );
foreach ( $all_cats as $cat ) {
( '' === $catids ) ? $catids = "$cat->term_id" : $catids .= ",$cat->term_id";
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
}
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $catids );
} else {
if ( ! is_array( $cats ) ) {
$cats = (array) $_POST['category'];
}
sort( $cats );
$old_cats = explode( ',', get_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true ) );
$remove = array_diff( $old_cats, $cats );
$new = array_diff( $cats, $old_cats );
if ( ! empty( $remove ) ) {
// remove subscription to these cat IDs
foreach ( $remove as $id ) {
delete_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id );
}
}
if ( ! empty( $new ) ) {
// add subscription to these cat IDs
foreach ( $new as $id ) {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id, $id );
}
}
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $cats ) );
}
$authors = ( isset( $_POST['author'] ) ) ? $_POST['author'] : '';
if ( is_array( $authors ) ) {
$authors = implode( ',', $authors );
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), $authors );
} elseif ( empty( $authors ) ) {
update_user_meta( $userid, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
}
} elseif ( isset( $_POST['subscribe'] ) ) {
$mysubscribe2->one_click_handler( $userid, 'subscribe' );
} elseif ( isset( $_POST['unsubscribe'] ) ) {
$mysubscribe2->one_click_handler( $userid, 'unsubscribe' );
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Subscription preferences updated.', 'subscribe2' ) . '</strong></p></div>' . "\r\n";
}
/**
* Display a table of categories with checkboxes
* Optionally pre-select those categories specified
*/
public function display_category_form( $selected = array(), $override = 1, $compulsory = array(), $name = 'category' ) {
global $wpdb, $mysubscribe2;
if ( 0 === $override ) {
$all_cats = $mysubscribe2->all_cats( true );
} else {
$all_cats = $mysubscribe2->all_cats( false );
}
$half = ( count( $all_cats ) / 2 );
$i = 0;
$j = 0;
echo '<table style="width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression(\'separate\', cellSpacing = \'2px\');" class="editform">' . "\r\n";
echo '<tr><td style="text-align: left;" colspan="2">' . "\r\n";
echo '<label><input type="checkbox" name="checkall" value="checkall_' . esc_attr( $name ) . '" /> ' . esc_html__( 'Select / Unselect All', 'subscribe2' ) . '</label>' . "\r\n";
echo '</td></tr>' . "\r\n";
echo '<tr style="vertical-align: top;"><td style="width: 50%; text-align: left;">' . "\r\n";
foreach ( $all_cats as $cat ) {
if ( $i >= $half && 0 === $j ) {
echo '</td><td style="width: 50%; text-align: left;">' . "\r\n";
$j++;
}
$cat_name = '';
$parents = array_reverse( get_ancestors( $cat->term_id, $cat->taxonomy ) );
if ( $parents ) {
foreach ( $parents as $parent ) {
$parent = get_term( $parent, $cat->taxonomy );
$cat_name .= $parent->name . ' &raquo; ';
}
}
$cat_name .= $cat->name;
if ( 0 === $j ) {
echo '<label><input class="checkall_' . esc_attr( $name ) . '" type="checkbox" name="' . esc_attr( $name ) . '[]" value="' . esc_attr( $cat->term_id ) . '"';
if ( in_array( (string) $cat->term_id, $selected, true ) || in_array( (string) $cat->term_id, $compulsory, true ) ) {
echo ' checked="checked"';
}
if ( in_array( (string) $cat->term_id, $compulsory, true ) && 'category' === $name ) {
echo ' DISABLED';
}
echo ' /> <abbr title="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat_name ) . '</abbr></label><br>' . "\r\n";
} else {
echo '<label><input class="checkall_' . esc_attr( $name ) . '" type="checkbox" name="' . esc_attr( $name ) . '[]" value="' . esc_attr( $cat->term_id ) . '"';
if ( in_array( (string) $cat->term_id, $selected, true ) || in_array( (string) $cat->term_id, $compulsory, true ) ) {
echo ' checked="checked"';
}
if ( in_array( (string) $cat->term_id, $compulsory, true ) && 'category' === $name ) {
echo ' DISABLED';
}
echo ' /> <abbr title="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat_name ) . '</abbr></label><br>' . "\r\n";
}
$i++;
}
if ( ! empty( $compulsory ) ) {
foreach ( $compulsory as $cat ) {
echo '<input type="hidden" name="' . esc_attr( $name ) . '[]" value="' . esc_attr( $cat ) . '">' . "\r\n";
}
}
echo '</td></tr>' . "\r\n";
echo '</table>' . "\r\n";
}
/**
* Display a table of authors with checkboxes
* Optionally pre-select those authors specified
*/
public function display_author_form( $selected = array() ) {
$all_authors = $this->get_authors();
$half = ( count( $all_authors ) / 2 );
$i = 0;
$j = 0;
echo '<table style="width: 100%; border-collapse: separate; border-spacing: 2px; *border-collapse: expression(\'separate\', cellSpacing = \'2px\');" class="editform">' . "\r\n";
echo '<tr><td style="text-align: left;" colspan="2">' . "\r\n";
echo '<label><input type="checkbox" name="checkall" value="checkall_author" /> ' . esc_html__( 'Select / Unselect All', 'subscribe2' ) . '</label>' . "\r\n";
echo '</td></tr>' . "\r\n";
echo '<tr style="vertical-align: top;"><td style="width: 50%; test-align: left;">' . "\r\n";
foreach ( $all_authors as $author ) {
if ( $i >= $half && 0 === $j ) {
echo '</td><td style="width: 50%; text-align: left;">' . "\r\n";
$j++;
}
if ( 0 === $j ) {
echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . esc_attr( $author->ID ) . '"';
if ( in_array( $author->ID, $selected, true ) ) {
echo ' checked="checked"';
}
echo ' /> ' . esc_html( $author->display_name ) . '</label><br>' . "\r\n";
} else {
echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . esc_attr( $author->ID ) . '"';
if ( in_array( $author->ID, $selected, true ) ) {
echo ' checked="checked"';
}
echo ' /> ' . esc_html( $author->display_name ) . '</label><br>' . "\r\n";
$i++;
}
}
echo '</td></tr>' . "\r\n";
echo '</table>' . "\r\n";
}
/**
* Collect an array of all author level users and above
*/
public function get_authors() {
if ( '' === $this->all_authors ) {
$role = array(
'fields' => array( 'ID', 'display_name' ),
'role' => 'administrator',
);
$administrators = get_users( $role );
$role = array(
'fields' => array( 'ID', 'display_name' ),
'role' => 'editor',
);
$editors = get_users( $role );
$role = array(
'fields' => array( 'ID', 'display_name' ),
'role' => 'author',
);
$authors = get_users( $role );
$this->all_authors = array_merge( $administrators, $editors, $authors );
}
return apply_filters( 's2_authors', $this->all_authors );
}
/**
* Define some variables
*/
private $all_authors = '';
}

View File

@ -1,356 +0,0 @@
<?php
class S2_Frontend extends S2_Core {
/**
* Load all our strings
*/
public function load_strings() {
// Translators: Link to login page
$this->please_log_in = '<p class="s2_message">' . sprintf( __( 'To manage your subscription options please <a href="%1$s">login</a>.', 'subscribe2' ), get_option( 'siteurl' ) . '/wp-login.php' ) . '</p>';
$profile = apply_filters( 's2_profile_link', get_option( 'siteurl' ) . '/wp-admin/admin.php?page=s2' );
// Translators: Link to Profile page
$this->profile = '<p class="s2_message">' . sprintf( __( 'You may manage your subscription options from your <a href="%1$s">profile</a>.', 'subscribe2' ), $profile ) . '</p>';
if ( true === $this->s2_mu ) {
global $blog_id;
$user_ID = get_current_user_id();
if ( ! is_user_member_of_blog( $user_ID, $blog_id ) ) {
// if we are on multisite and the user is not a member of this blog change the link
$mu_profile = apply_filters( 's2_mu_profile_link', get_option( 'siteurl' ) . '/wp-admin/?s2mu_subscribe=' . $blog_id );
// Translators: Link to Profile page
$this->profile = '<p class="s2_message">' . sprintf( __( '<a href="%1$s">Subscribe</a> to email notifications when this blog posts new content.', 'subscribe2' ), $mu_profile ) . '</p>';
}
}
$this->confirmation_sent = '<p class="s2_message">' . __( 'A confirmation message is on its way!', 'subscribe2' ) . '</p>';
$this->already_subscribed = '<p class="s2_error">' . __( 'That email address is already subscribed.', 'subscribe2' ) . '</p>';
$this->not_subscribed = '<p class="s2_error">' . __( 'That email address is not subscribed.', 'subscribe2' ) . '</p>';
$this->not_an_email = '<p class="s2_error">' . __( 'Sorry, but that does not look like an email address to me.', 'subscribe2' ) . '</p>';
$this->barred_domain = '<p class="s2_error">' . __( 'Sorry, email addresses at that domain are currently barred due to spam, please use an alternative email address.', 'subscribe2' ) . '</p>';
$this->error = '<p class="s2_error">' . __( 'Sorry, there seems to be an error on the server. Please try again later.', 'subscribe2' ) . '</p>';
// confirmation messages
$this->no_such_email = '<p class="s2_error">' . __( 'No such email address is registered.', 'subscribe2' ) . '</p>';
$this->added = '<p class="s2_message">' . __( 'You have successfully subscribed!', 'subscribe2' ) . '</p>';
$this->deleted = '<p class="s2_message">' . __( 'You have successfully unsubscribed.', 'subscribe2' ) . '</p>';
$this->subscribe = __( 'subscribe', 'subscribe2' ); //ACTION replacement in subscribing confirmation email
$this->unsubscribe = __( 'unsubscribe', 'subscribe2' ); //ACTION replacement in unsubscribing in confirmation email
if ( isset( $_GET['s2_unsub'] ) && ! empty( $_GET['s2_unsub'] ) ) {
$this->unsubscribe( $_GET['s2_unsub'] );
}
}
/**
* Process unsubscribe
*
* @param $email
*/
public function unsubscribe( $email ) {
global $wpdb;
$email = base64_decode( $email );
if (! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
return;
}
$count = $wpdb->delete( $wpdb->subscribe2,
[
'email' => $email
]
);
if ( ! $count ) {
wp_safe_redirect( home_url() );
}
}
/**
* Display form when deprecated <!--subscribe2--> is used
*/
public function filter( $content = '' ) {
if ( '' === $content || ! strstr( $content, '<!--subscribe2-->' ) ) {
return $content;
}
return preg_replace( '/(<p>)?(\n)*<!--subscribe2-->(\n)*(<\/p>)?/', do_shortcode( '[subscribe2]' ), $content );
}
/**
* Overrides the default query when handling a (un)subscription confirmation
* This is basically a trick: if the s2 variable is in the query string, just grab the first
* static page and override it's contents later with title_filter()
*/
public function query_filter() {
// don't interfere if we've already done our thing
if ( 1 === $this->filtered ) {
return;
}
global $wpdb;
// brute force Simple Facebook Connect to bypass compatiblity issues
$priority = has_filter( 'wp_head', 'sfc_base_meta' );
if ( false !== $priority ) {
remove_action( 'wp_head', 'sfc_base_meta', $priority );
}
if ( 0 !== $this->subscribe2_options['s2page'] ) {
return array(
'page_id' => $this->subscribe2_options['s2page'],
);
} else {
$id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status='publish' LIMIT 1" );
if ( $id ) {
return array(
'page_id' => $id,
);
} else {
return array(
'showposts' => 1,
);
}
}
}
/**
* Overrides the page title
*/
public function title_filter( $title ) {
if ( in_the_loop() ) {
$code = $_GET['s2'];
$action = intval( substr( $code, 0, 1 ) );
if ( 1 === $action ) {
return __( 'Subscription Confirmation', 'subscribe2' );
} else {
return __( 'Unsubscription Confirmation', 'subscribe2' );
}
} else {
return $title;
}
}
/**
* Confirm request from the link emailed to the user and email the admin
*/
public function confirm( $content = '' ) {
global $wpdb;
if ( 1 === $this->filtered && '' !== $this->message ) {
return $this->message;
} elseif ( 1 === $this->filtered ) {
return $content;
}
$code = $_GET['s2'];
$action = substr( $code, 0, 1 );
$hash = substr( $code, 1, 32 );
$id = intval( substr( $code, 33 ) );
if ( $id ) {
$this->email = $this->sanitize_email( $this->get_email( $id ) );
if ( ! $this->email || wp_hash( $this->email ) !== $hash ) {
return $this->no_such_email;
}
} else {
return $this->no_such_email;
}
// get current status of email so messages are only sent once per emailed link
$current = $this->is_public( $this->email );
if ( '1' === $action ) {
// make this subscription active
$this->message = apply_filters( 's2_subscribe_confirmed', $this->added );
if ( '1' !== $this->is_public( $this->email ) ) {
$this->ip = esc_html( $this->get_remote_ip() );
$this->toggle( $this->email );
if ( 'subs' === $this->subscribe2_options['admin_email'] || 'both' === $this->subscribe2_options['admin_email'] ) {
$this->admin_email( 'subscribe' );
}
}
$this->filtered = 1;
} elseif ( '0' === $action ) {
// remove this public subscriber
$this->message = apply_filters( 's2_unsubscribe_confirmed', $this->deleted );
if ( '0' !== $this->is_public( $this->email ) ) {
$this->delete( $this->email );
if ( 'unsubs' === $this->subscribe2_options['admin_email'] || 'both' === $this->subscribe2_options['admin_email'] ) {
$this->admin_email( 'unsubscribe' );
}
}
$this->filtered = 1;
}
if ( '' !== $this->message ) {
return $this->message;
}
}
/**
* Prepare and send emails to admins on new subscriptions and unsubsriptions
*/
public function admin_email( $action ) {
if ( ! in_array( $action, array( 'subscribe', 'unsubscribe' ), true ) ) {
return false;
}
( '' === get_option( 'blogname' ) ) ? $subject = '' : $subject = '[' . stripslashes( html_entity_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . '] ';
if ( 'subscribe' === $action ) {
$subject .= __( 'New Subscription', 'subscribe2' );
$message = $this->email . ' ' . __( 'subscribed to email notifications!', 'subscribe2' );
} elseif ( 'unsubscribe' === $action ) {
$subject .= __( 'New Unsubscription', 'subscribe2' );
$message = $this->email . ' ' . __( 'unsubscribed from email notifications!', 'subscribe2' );
}
$subject = html_entity_decode( $subject, ENT_QUOTES );
$role = array(
'fields' => array(
'user_email',
),
'role' => 'administrator',
);
$wp_user_query = get_users( $role );
foreach ( $wp_user_query as $user ) {
$recipients[] = $user->user_email;
}
$recipients = apply_filters( 's2_admin_email', $recipients, $action );
$headers = $this->headers();
// send individual emails so we don't reveal admin emails to each other
foreach ( $recipients as $recipient ) {
$status = wp_mail( $recipient, $subject, $message, $headers );
}
}
/**
* Add hook for Minimeta Widget plugin
*/
public function add_minimeta() {
if ( 0 !== $this->subscribe2_options['s2page'] ) {
echo '<li><a href="' . esc_url( get_permalink( $this->subscribe2_options['s2page'] ) ) . '">' . esc_html__( '[Un]Subscribe to Posts', 'subscribe2' ) . '</a></li>' . "\r\n";
}
}
/**
* Check email is not from a barred domain
*/
public function is_barred( $email = '' ) {
if ( '' === $email ) {
return false;
}
list( $user, $domain ) = explode( '@', $email, 2 );
$domain = '@' . $domain;
foreach ( preg_split( '/[\s,]+/', $this->subscribe2_options['barred'] ) as $barred_domain ) {
if ( false !== strpos( $barred_domain, '!' ) ) {
$url = explode( '.', str_replace( '!', '', $barred_domain ) );
$count = count( $url );
// make sure our exploded domain has at least 2 components e.g. yahoo.*
if ( $count < 2 ) {
continue;
}
for ( $i = 0; $i < $count; $i++ ) {
if ( '*' === $url[ $i ] ) {
unset( $url[ $i ] );
}
}
$new_barred_domain = '@' . strtolower( trim( implode( '.', $url ) ) );
if ( false !== strpos( $barred_domain, '*' ) ) {
$new_barred_subdomain = '.' . strtolower( trim( implode( '.', $url ) ) );
if ( false !== stripos( $domain, $new_barred_domain ) || false !== stripos( $domain, $new_barred_subdomain ) ) {
return false;
}
} else {
if ( false !== stripos( $domain, $new_barred_domain ) ) {
return false;
}
}
}
if ( false === strpos( $barred_domain, '!' ) && false !== strpos( $barred_domain, '*' ) ) {
// wildcard and explictly allowed checking
$url = explode( '.', str_replace( '!', '', $barred_domain ) );
$count = count( $url );
// make sure our exploded domain has at least 2 components e.g. yahoo.*
if ( $count < 2 ) {
continue;
}
for ( $i = 0; $i < $count; $i++ ) {
if ( '*' === $url[ $i ] ) {
unset( $url[ $i ] );
}
}
$new_barred_domain = '@' . strtolower( trim( implode( '.', $url ) ) );
$new_barred_subdomain = '.' . strtolower( trim( implode( '.', $url ) ) );
if ( false !== stripos( $domain, $new_barred_domain ) || false !== stripos( $domain, $new_barred_subdomain ) ) {
return true;
}
} else {
// direct domain string comparison
$barred_domain = '@' . $barred_domain;
if ( strtolower( $domain ) === strtolower( trim( $barred_domain ) ) ) {
return true;
}
}
}
return false;
}
/**
* Enqueue javascript ip updater code
*/
public function js_ip_script() {
wp_register_script( 's2_ip_updater', S2URL . 'include/s2-ip-updater' . $this->script_debug . '.js', array(), '1.1', true );
wp_enqueue_script( 's2_ip_updater' );
}
/**
* Add ip updater library to footer
*/
public function js_ip_library_script() {
$args = array(
'format' => 'jsonp',
'callback' => 'getip',
);
wp_enqueue_script( 's2_ip_library', add_query_arg( $args, 'https://api.ipify.org' ), array(), S2VERSION, true );
}
/**
* Reformat WordPress escaped link to IPify library
*/
public function tag_replace_ampersand( $tag ) {
if ( strstr( $tag, 'ipify' ) !== false ) {
$tag = str_replace( '&#038;', '&', $tag );
}
return $tag;
}
/* ===== define some variables ===== */
public $profile = '';
/**
* Create and display a dropdown list of pages
*/
public function pages_dropdown( $s2page, $name = 's2page' ) {
//
}
}

View File

@ -1,443 +0,0 @@
<?php
/**
* List Table class used in WordPress 4.3.x and above
*/
class S2_List_Table extends WP_List_Table {
private $date_format = '';
private $time_format = '';
public function __construct() {
global $status, $page;
parent::__construct(
array(
'singular' => 'subscriber',
'plural' => 'subscribers',
'ajax' => false,
)
);
$this->date_format = get_option( 'date_format' );
$this->time_format = get_option( 'time_format' );
}
public function column_default( $item, $column_name ) {
global $current_tab;
switch ( $column_name ) {
case 'email':
case 'date':
return $item[ $column_name ];
}
}
public function column_email( $item ) {
global $current_tab;
if ( 'registered' === $current_tab ) {
$actions = array(
'edit' => sprintf( '<a href="?page=%s&amp;id=%d">%s</a>', 's2', rawurlencode( $item['id'] ), __( 'Edit', 'subscribe2' ) ),
);
return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $actions ) );
} else {
global $mysubscribe2;
if ( '0' === $mysubscribe2->is_public( $item['email'] ) ) {
return sprintf( '<span style="color:#FF0000"><abbr title="%2$s">%1$s</abbr></span>', $item['email'], $item['ip'] );
} else {
return sprintf( '<abbr title="%2$s">%1$s</abbr>', $item['email'], $item['ip'] );
}
}
}
public function column_date( $item ) {
global $current_tab;
if ( 'registered' === $current_tab ) {
$timestamp = strtotime( $item['date'] );
return sprintf( '<abbr title="%2$s">%1$s</abbr>', date_i18n( $this->date_format, $timestamp ), date_i18n( $this->time_format, $timestamp ) );
} else {
$timestamp = strtotime( $item['date'] . ' ' . $item['time'] );
return sprintf( '<abbr title="%2$s">%1$s</abbr>', date_i18n( $this->date_format, $timestamp ), date_i18n( $this->time_format, $timestamp ) );
}
}
public function column_cb( $item ) {
return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $item['email'] );
}
public function get_columns() {
global $current_tab;
$columns = array(
'cb' => '<input type="checkbox" />',
'email' => _x( 'Email', 'column name', 'subscribe2' ),
'date' => _x( 'Date', 'column name', 'subscribe2' ),
);
return $columns;
}
public function get_sortable_columns() {
global $current_tab;
$sortable_columns = array(
'email' => array( 'email', true ),
'date' => array( 'date', false ),
);
return $sortable_columns;
}
public function print_column_headers( $with_id = true ) {
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$current_url = remove_query_arg( 'paged', $current_url );
if ( isset( $_REQUEST['what'] ) ) {
$current_url = add_query_arg(
array(
'what' => $_REQUEST['what'],
),
$current_url
);
}
if ( isset( $_GET['orderby'] ) ) {
$current_orderby = $_GET['orderby'];
} else {
$current_orderby = '';
}
if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
$current_order = 'desc';
} else {
$current_order = 'asc';
}
if ( ! empty( $columns['cb'] ) ) {
static $cb_counter = 1;
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'subscribe2' ) . '</label>'
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$cb_counter++;
}
foreach ( $columns as $column_key => $column_display_name ) {
$class = array( 'manage-column', "column-$column_key" );
if ( in_array( $column_key, $hidden, true ) ) {
$class[] = 'hidden';
}
if ( 'cb' === $column_key ) {
$class[] = 'check-column';
}
if ( $column_key === $primary ) {
$class[] = 'column-primary';
}
if ( isset( $sortable[ $column_key ] ) ) {
list( $orderby, $desc_first ) = $sortable[ $column_key ];
if ( $current_orderby === $orderby ) {
$order = 'asc' === $current_order ? 'desc' : 'asc';
$class[] = 'sorted';
$class[] = $current_order;
} else {
$order = $desc_first ? 'desc' : 'asc';
$class[] = 'sortable';
$class[] = $desc_first ? 'asc' : 'desc';
}
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
}
$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
$id = $with_id ? "id='$column_key'" : '';
if ( ! empty( $class ) ) {
$class = "class='" . join( ' ', $class ) . "'";
}
echo "<$tag $scope $id $class>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput
}
}
public function get_bulk_actions() {
global $current_tab;
if ( 'registered' === $current_tab ) {
if ( is_multisite() ) {
return array();
} else {
return array(
'delete' => __( 'Delete', 'subscribe2' ),
);
}
} else {
$actions = array(
'delete' => __( 'Delete', 'subscribe2' ),
'toggle' => __( 'Toggle', 'subscribe2' ),
);
return $actions;
}
}
public function process_bulk_action() {
if ( in_array( $this->current_action(), array( 'delete', 'toggle' ), true ) ) {
if ( ! isset( $_REQUEST['subscriber'] ) ) {
echo '<div id="message" class="error"><p><strong>' . esc_html__( 'No users were selected.', 'subscribe2' ) . '</strong></p></div>';
return;
}
}
if ( 'delete' === $this->current_action() ) {
global $mysubscribe2, $current_user, $subscribers;
$message = array();
foreach ( $_REQUEST['subscriber'] as $address ) {
$address = trim( stripslashes( $address ) );
if ( false !== $mysubscribe2->is_public( $address ) ) {
$mysubscribe2->delete( $address );
$key = array_search( $address, $subscribers, true );
unset( $subscribers[ $key ] );
$message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
} else {
$user = get_user_by( 'email', $address );
if ( ! current_user_can( 'delete_user', $user->ID ) || $user->ID === $current_user->ID ) {
$message['reg_delete_error'] = __( 'Delete failed! You cannot delete some or all of these users.', 'subscribe2' );
continue;
} else {
$message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
foreach ( $subscribers as $key => $data ) {
if ( in_array( $address, $data, true ) ) {
unset( $subscribers[ $key ] );
}
}
wp_delete_user( $user->ID, $current_user->ID );
}
}
}
$final_message = implode( '<br><br>', array_filter( $message ) );
echo '<div id="message" class="updated fade"><p><strong>' . esc_html( $final_message ) . '</strong></p></div>';
}
if ( 'toggle' === $this->current_action() ) {
global $mysubscribe2, $current_user, $subscribers;
$mysubscribe2->ip = $current_user->user_login;
foreach ( $_REQUEST['subscriber'] as $address ) {
$address = trim( stripslashes( $address ) );
$mysubscribe2->toggle( $address );
if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
$key = array_search( $address, $subscribers, true );
unset( $subscribers[ $key ] );
}
}
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Status changed!', 'subscribe2' ) . '</strong></p></div>';
}
}
public function pagination( $which ) {
if ( empty( $this->_pagination_args ) ) {
return;
}
$total_items = intval( $this->_pagination_args['total_items'] );
$total_pages = intval( $this->_pagination_args['total_pages'] );
$infinite_scroll = false;
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
}
if ( 'top' === $which && $total_pages > 1 ) {
$this->screen->render_screen_reader_content( 'heading_pagination' );
}
// Translators: Pagination
$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'subscribe2' ), number_format_i18n( $total_items ) ) . '</span>';
if ( isset( $_POST['what'] ) ) {
$current = 1;
} else {
$current = intval( $this->get_pagenum() );
}
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
if ( isset( $_REQUEST['what'] ) ) {
$current_url = add_query_arg(
array(
'what' => $_REQUEST['what'],
),
$current_url
);
}
if ( isset( $_POST['s'] ) ) {
$current_url = add_query_arg(
array(
's' => $_POST['s'],
),
$current_url
);
}
$page_links = array();
$total_pages_before = '<span class="paging-input">';
$total_pages_after = '</span>';
$disable_first = false;
$disable_last = false;
$disable_prev = false;
$disable_next = false;
if ( 1 === $current ) {
$disable_first = true;
$disable_prev = true;
}
if ( 2 === $current ) {
$disable_first = true;
}
if ( $current === $total_pages ) {
$disable_last = true;
$disable_next = true;
}
if ( $current === $total_pages - 1 ) {
$disable_last = true;
}
if ( $disable_first ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
} else {
$page_links[] = sprintf(
"<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( remove_query_arg( 'paged', $current_url ) ),
__( 'First page', 'subscribe2' ),
'&laquo;'
);
}
if ( $disable_prev ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
} else {
$page_links[] = sprintf(
"<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
__( 'Previous page', 'subscribe2' ),
'&lsaquo;'
);
}
if ( 'bottom' === $which ) {
$html_current_page = $current;
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'subscribe2' ) . '</span><span id="table-paging" class="paging-input">';
} else {
$html_current_page = sprintf(
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'subscribe2' ) . '</label>',
$current,
strlen( $total_pages )
);
}
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
// Translators: Pagination
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'subscribe2' ), $html_current_page, $html_total_pages ) . $total_pages_after;
if ( $disable_next ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
} else {
$page_links[] = sprintf(
"<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
__( 'Next page', 'subscribe2' ),
'&rsaquo;'
);
}
if ( $disable_last ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
} else {
$page_links[] = sprintf(
"<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
__( 'Last page', 'subscribe2' ),
'&raquo;'
);
}
$pagination_links_class = 'pagination-links';
if ( ! empty( $infinite_scroll ) ) {
$pagination_links_class = ' hide-if-js';
}
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
if ( $total_pages ) {
$page_class = $total_pages < 2 ? ' one-page' : '';
} else {
$page_class = ' no-pages';
}
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput
}
public function prepare_items() {
global $mysubscribe2, $subscribers, $current_tab;
$user = get_current_user_id();
$screen = get_current_screen();
$screen_option = $screen->get_option( 'per_page', 'option' );
$per_page = get_user_meta( $user, $screen_option, true );
if ( empty( $per_page ) || $per_page < 1 ) {
$per_page = $screen->get_option( 'per_page', 'default' );
}
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $hidden, $sortable );
$this->process_bulk_action();
$data = array();
if ( 'public' === $current_tab ) {
foreach ( (array) $subscribers as $email ) {
$data[] = array(
'email' => $email,
'date' => $mysubscribe2->signup_date( $email ),
'time' => $mysubscribe2->signup_time( $email ),
'ip' => $mysubscribe2->signup_ip( $email ),
);
}
} else {
foreach ( (array) $subscribers as $subscriber ) {
$data[] = array(
'email' => $subscriber['user_email'],
'id' => $subscriber['ID'],
'date' => get_userdata( $subscriber['ID'] )->user_registered,
);
}
}
function usort_reorder( $a, $b ) {
$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'email';
$order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
$result = strcasecmp( $a[ $orderby ], $b[ $orderby ] );
return ( 'asc' === $order ) ? $result : -$result;
}
usort( $data, 'usort_reorder' );
if ( isset( $_POST['what'] ) ) {
$current_page = 1;
} else {
$current_page = $this->get_pagenum();
}
$total_items = count( $data );
$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
$this->items = $data;
$this->set_pagination_args(
array(
'total_items' => $total_items,
'per_page' => $per_page,
'total_pages' => ceil( $total_items / $per_page ),
)
);
}
}

View File

@ -1,174 +0,0 @@
<?php
class S2_Multisite {
/* === WP Multisite specific functions === */
/**
* Handles subscriptions and unsubscriptions for different blogs on WPMU installs
*/
public function wpmu_subscribe() {
global $mysubscribe2;
// subscribe to new blog
if ( ! empty( $_GET['s2mu_subscribe'] ) ) {
$sub_id = intval( $_GET['s2mu_subscribe'] );
if ( $sub_id >= 0 ) {
switch_to_blog( $sub_id );
$user_ID = get_current_user_id();
// if user is not a user of the current blog
if ( ! is_user_member_of_blog( $user_ID, $sub_id ) ) {
// add user to current blog as subscriber
add_user_to_blog( $sub_id, $user_ID, 'subscriber' );
// add an action hook for external manipulation of blog and user data
do_action_ref_array( 'subscribe2_wpmu_subscribe', array( $user_ID, $sub_id ) );
}
// get categories, remove excluded ones if override is off
if ( 0 === $mysubscribe2->subscribe2_options['reg_override'] ) {
$all_cats = $mysubscribe2->all_cats( true, 'ID' );
} else {
$all_cats = $mysubscribe2->all_cats( false, 'ID' );
}
$cats_string = '';
foreach ( $all_cats as $cat ) {
( '' === $cats_string ) ? $cats_string = "$cat->term_id" : $cats_string .= ",$cat->term_id";
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat->term_id, $cat->term_id );
}
if ( empty( $cats_string ) ) {
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
} else {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats_string );
}
}
} elseif ( ! empty( $_GET['s2mu_unsubscribe'] ) ) {
// unsubscribe from a blog
$unsub_id = intval( $_GET['s2mu_unsubscribe'] );
if ( $unsub_id >= 0 ) {
switch_to_blog( $unsub_id );
$user_ID = get_current_user_id();
// delete subscription to all categories on that blog
$cats = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
$cats = explode( ',', $cats );
if ( ! is_array( $cats ) ) {
$cats = array( $cats );
}
foreach ( $cats as $id ) {
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $id );
}
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
// add an action hook for external manipulation of blog and user data
do_action_ref_array( 'subscribe2_wpmu_unsubscribe', array( $user_ID, $unsub_id ) );
restore_current_blog();
}
}
if ( ! is_user_member_of_blog( $user_ID ) ) {
$user_blogs = get_active_blog_for_user( $user_ID );
if ( is_array( $user_blogs ) ) {
switch_to_blog( key( $user_blogs ) );
} else {
// no longer a member of a blog
wp_safe_redirect( get_option( 'siteurl' ) ); // redirect to front page
exit( 0 );
}
}
// redirect to profile page
$url = get_option( 'siteurl' ) . '/wp-admin/admin.php?page=s2';
wp_safe_redirect( $url );
exit( 0 );
}
/**
* Obtain a list of current WordPress multiuser blogs
* Note this may affect performance but there is no alternative
*/
public function get_mu_blog_list() {
global $wpdb;
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid ), ARRAY_A );
foreach ( $blogs as $details ) {
//reindex the array so the key is the same as the blog_id
$blog_list[ $details['blog_id'] ] = $details;
}
if ( ! is_array( $blog_list ) ) {
return array();
}
return apply_filters( 's2_mu_blog_list', $blog_list );
}
/**
* Register user details when new user is added to a multisite blog
*/
public function wpmu_add_user( $user_ID = 0 ) {
global $mysubscribe2;
if ( 0 === $user_ID ) {
return;
}
if ( 'yes' === $mysubscribe2->subscribe2_options['autosub'] ) {
$mysubscribe2->register( $user_ID, true );
} else {
$mysubscribe2->register( $user_ID, false );
}
}
/**
* Delete user details when a user is removed from a multisite blog
*/
public function wpmu_remove_user( $user_ID ) {
global $mysubscribe2;
if ( 0 === $user_ID ) {
return;
}
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ) );
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ) );
$cats = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
if ( ! empty( $cats ) ) {
$cats = explode( ',', $cats );
foreach ( $cats as $cat ) {
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $cat );
}
}
delete_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ) );
}
/**
* Rename WPMU widgets on upgrade without requiring user to re-enable
*/
public function namechange_subscribe2_widget() {
global $wpdb;
$blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
foreach ( $blogs as $blog ) {
switch_to_blog( $blog );
$sidebars = get_option( 'sidebars_widgets' );
if ( empty( $sidebars ) || ! is_array( $sidebars ) ) {
return;
}
$changed = false;
foreach ( $sidebars as $s => $sidebar ) {
if ( empty( $sidebar ) || ! is_array( $sidebar ) ) {
break;
}
foreach ( $sidebar as $w => $widget ) {
if ( 'subscribe2widget' === $widget ) {
$sidebars[ $s ][ $w ] = 'subscribe2';
$changed = true;
}
}
}
if ( $changed ) {
update_option( 'sidebar_widgets', $sidebars );
}
restore_current_blog();
}
}
}

View File

@ -1,52 +0,0 @@
<?php
class S2_Uninstall {
public function uninstall() {
global $wp_version, $wpmu_version;
// Is Subscribe2 free active
if ( is_plugin_active( 'subscribe2/subscribe2.php' ) ) {
return;
}
// Is this WordPressMU or not?
if ( isset( $wpmu_version ) || strpos( $wp_version, 'wordpress-mu' ) ) {
$s2_mu = true;
}
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
$s2_mu = true;
}
if ( isset( $s2_mu ) && true === $s2_mu ) {
global $wpdb;
$blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
foreach ( $blogs as $blog ) {
switch_to_blog( $blog );
$this->clean_database();
restore_current_blog();
}
} else {
$this->clean_database();
}
}
private function clean_database() {
global $wpdb;
// delete entry from wp_options table
delete_option( 'subscribe2_options' );
// delete legacy entry from wp-options table
delete_option( 's2_future_posts' );
// remove and scheduled events
wp_clear_scheduled_hook( 's2_digest_cron' );
// delete usermeta data for registered users
// use LIKE and % wildcard as meta_key names are prepended on WPMU
// and s2_cat is appended with category ID integer
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'" );
// delete any postmeta data that supressed notifications
$wpdb->query( "DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'" );
// drop the subscribe2 table
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe2" );
}
}

View File

@ -1,554 +0,0 @@
<?php
class S2_Upgrade {
/* ===== Install and reset ===== */
/**
* Install our table
*/
public function install() {
global $wpdb, $mysubscribe2;
// load our translations and strings
$mysubscribe2->load_translations();
// include upgrade functions
if ( ! function_exists( 'maybe_create_table' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
$charset_collate = '';
if ( ! empty( $wpdb->charset ) ) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if ( ! empty( $wpdb->collate ) ) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
$date = gmdate( 'Y-m-d' );
$sql = "CREATE TABLE $wpdb->subscribe2 (
id int(11) NOT NULL auto_increment,
email varchar(64) NOT NULL default '',
active tinyint(1) default 0,
date DATE default '$date' NOT NULL,
time TIME DEFAULT '00:00:00' NOT NULL,
ip char(64) NOT NULL default 'admin',
conf_date DATE,
conf_time TIME,
conf_ip char(64),
PRIMARY KEY (id) ) $charset_collate";
// create the table, as needed
maybe_create_table( $wpdb->subscribe2, $sql );
// safety check if options exist and if not create them
if ( ! is_array( $mysubscribe2->subscribe2_options ) ) {
$this->reset();
}
// create table entries for registered users
$users = $mysubscribe2->get_all_registered( 'ID' );
if ( ! empty( $users ) ) {
foreach ( $users as $user_ID ) {
$check_format = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true );
if ( empty( $check_format ) ) {
// no prior settings so create them
$mysubscribe2->register( $user_ID );
}
}
}
}
/**
* Reset our options
*/
public function reset() {
// load our translations and strings
global $mysubscribe2;
$mysubscribe2->load_translations();
delete_option( 'subscribe2_options' );
wp_clear_scheduled_hook( 's2_digest_cron' );
unset( $mysubscribe2->subscribe2_options );
require S2PATH . 'include/options.php';
$mysubscribe2->subscribe2_options['version'] = S2VERSION;
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
/**
* Core upgrade function for the database and settings
*/
public function upgrade() {
global $mysubscribe2;
// load our translations and strings
$mysubscribe2->load_translations();
// ensure that the options are in the database
require S2PATH . 'include/options.php';
// catch older versions that didn't use serialised options
if ( ! isset( $mysubscribe2->subscribe2_options['version'] ) ) {
$mysubscribe2->subscribe2_options['version'] = '2.0';
}
// let's take the time to ensure that database entries exist for all registered users
$this->upgrade_core();
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '2.3', '<' ) ) {
$this->upgrade2_3();
$mysubscribe2->subscribe2_options['version'] = '2.3';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.1', '<' ) ) {
$this->upgrade5_1();
$mysubscribe2->subscribe2_options['version'] = '5.1';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.6', '<' ) ) {
$this->upgrade5_6();
$mysubscribe2->subscribe2_options['version'] = '5.6';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '5.9', '<' ) ) {
$this->upgrade5_9();
$mysubscribe2->subscribe2_options['version'] = '5.9';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '6.4', '<' ) ) {
$this->upgrade6_4();
$mysubscribe2->subscribe2_options['version'] = '6.4';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '7.0', '<' ) ) {
$this->upgrade7_0();
$mysubscribe2->subscribe2_options['version'] = '7.0';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.5', '<' ) ) {
$this->upgrade8_5();
$mysubscribe2->subscribe2_options['version'] = '8.5';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.6', '<' ) ) {
$this->upgrade8_6();
$mysubscribe2->subscribe2_options['version'] = '8.6';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '8.8', '<' ) ) {
$this->upgrade8_8();
$mysubscribe2->subscribe2_options['version'] = '8.8';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '9.5', '<' ) ) {
$this->upgrade9_5();
$mysubscribe2->subscribe2_options['version'] = '9.5';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '10.14', '<' ) ) {
$this->upgrade10_14();
$mysubscribe2->subscribe2_options['version'] = '10.14';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
if ( version_compare( $mysubscribe2->subscribe2_options['version'], '10.23', '<' ) ) {
$this->upgrade10_23();
$mysubscribe2->subscribe2_options['version'] = '10.23';
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
$mysubscribe2->subscribe2_options['version'] = S2VERSION;
update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
}
private function upgrade_core() {
// let's take the time to double check data for registered users
global $mysubscribe2;
if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
global $wpdb;
$users = $wpdb->get_col( $wpdb->prepare( "SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id FROM $wpdb->usermeta WHERE meta_key=%s)", $mysubscribe2->get_usermeta_keyname( 's2_format' ) ) );
if ( ! empty( $users ) ) {
foreach ( $users as $user_ID ) {
$mysubscribe2->register( $user_ID );
}
}
} else {
$args = array(
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
'compare' => 'NOT EXISTS',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
$mysubscribe2->register( $user->ID );
}
}
}
// let's make sure that the 's2_authors' key exists on every site for all Registered Users too
$this->upgrade7_0();
}
private function upgrade2_3() {
global $mysubscribe2, $wpdb;
// include upgrade functions
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
$date = gmdate( 'Y-m-d' );
maybe_add_column( $wpdb->subscribe2, 'date', "ALTER TABLE $wpdb->subscribe2 ADD date DATE DEFAULT '$date' NOT NULL AFTER active" );
// update the options table to serialized format
$old_options = $wpdb->get_col( "SELECT option_name from $wpdb->options where option_name LIKE 's2%' AND option_name <> 's2_future_posts'" );
if ( ! empty( $old_options ) ) {
foreach ( $old_options as $option ) {
$value = get_option( $option );
$option_array = substr( $option, 3 );
$mysubscribe2->subscribe2_options[ $option_array ] = $value;
delete_option( $option );
}
}
}
private function upgrade5_1() {
global $mysubscribe2, $wpdb;
// include upgrade functions
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
maybe_add_column( $wpdb->subscribe2, 'ip', "ALTER TABLE $wpdb->subscribe2 ADD ip char(64) DEFAULT 'admin' NOT NULL AFTER date" );
}
private function upgrade5_6() {
global $mysubscribe2;
// correct autoformat to upgrade from pre 5.6
if ( 'text' === $mysubscribe2->subscribe2_options['autoformat'] ) {
$mysubscribe2->subscribe2_options['autoformat'] = 'excerpt';
}
if ( 'full' === $mysubscribe2->subscribe2_options['autoformat'] ) {
$mysubscribe2->subscribe2_options['autoformat'] = 'post';
}
}
private function upgrade5_9() {
global $mysubscribe2, $wpdb;
// ensure existing public subscriber emails are all sanitized
$confirmed = $mysubscribe2->get_public();
$unconfirmed = $mysubscribe2->get_public( 0 );
$public_subscribers = array_merge( (array) $confirmed, (array) $unconfirmed );
foreach ( $public_subscribers as $email ) {
$new_email = $mysubscribe2->sanitize_email( $email );
if ( $email !== $new_email ) {
$wpdb->get_results( $wpdb->prepare( "UPDATE $wpdb->subscribe2 SET email=%s WHERE CAST(email as binary)=%s", $new_email, $email ) );
}
}
}
private function upgrade6_4() {
global $mysubscribe2;
// change old CAPITALISED keywords to those in {PARENTHESES}; since version 6.4
$keywords = array( 'BLOGNAME', 'BLOGLINK', 'TITLE', 'POST', 'POSTTIME', 'TABLE', 'TABLELINKS', 'PERMALINK', 'TINYLINK', 'DATE', 'TIME', 'MYNAME', 'EMAIL', 'AUTHORNAME', 'LINK', 'CATS', 'TAGS', 'COUNT', 'ACTION' );
$keyword = implode( '|', $keywords );
$regex = '/(?<!\{)\b(' . $keyword . ')\b(?!\{)/xm';
$replace = '{\1}';
$mysubscribe2->subscribe2_options['mailtext'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['mailtext'] );
$mysubscribe2->subscribe2_options['notification_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['notification_subject'] );
$mysubscribe2->subscribe2_options['confirm_email'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['confirm_email'] );
$mysubscribe2->subscribe2_options['confirm_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['confirm_subject'] );
$mysubscribe2->subscribe2_options['remind_email'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['remind_email'] );
$mysubscribe2->subscribe2_options['remind_subject'] = preg_replace( $regex, $replace, $mysubscribe2->subscribe2_options['remind_subject'] );
if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
$users = $mysubscribe2->get_all_registered( 'ID' );
foreach ( $users as $user_ID ) {
$check_format = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), true );
// if user is already registered update format remove 's2_excerpt' field and update 's2_format'
if ( 'html' === $check_format ) {
delete_user_meta( $user_ID, 's2_excerpt' );
} elseif ( 'text' === $check_format ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), get_user_meta( $user_ID, 's2_excerpt' ) );
delete_user_meta( $user_ID, 's2_excerpt' );
}
$subscribed = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
if ( strstr( $subscribed, '-1' ) ) {
// make sure we remove '-1' from any settings
$old_cats = explode( ',', $subscribed );
$pos = array_search( '-1', $old_cats, true );
unset( $old_cats[ $pos ] );
$cats = implode( ',', $old_cats );
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
}
}
} else {
$args = array(
'relation' => 'AND',
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
'value' => 'html',
),
),
'meta_query' => array(
array(
'key' => 's2_excerpt',
'compare' => 'EXISTS',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
delete_user_meta( $user->ID, 's2_excerpt' );
}
}
$args = array(
'relation' => 'AND',
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_format' ),
'value' => 'text',
),
),
'meta_query' => array(
array(
'key' => 's2_excerpt',
'compare' => 'EXISTS',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), get_user_meta( $user->ID, 's2_excerpt' ) );
delete_user_meta( $user->ID, 's2_excerpt' );
}
}
$args = array(
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ),
'value' => '-1',
'compare' => 'LIKE',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
$subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
$old_cats = explode( ',', $subscribed );
$pos = array_search( '-1', $old_cats, true );
unset( $old_cats[ $pos ] );
$cats = implode( ',', $old_cats );
update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
}
}
}
// upgrade old wpmu user meta data to new
if ( true === $mysubscribe2->s2_mu ) {
global $s2class_multisite, $wpdb;
$s2class_multisite->namechange_subscribe2_widget();
// loop through all users
foreach ( $users as $user_ID ) {
// get categories which the user is subscribed to (old ones)
$categories = get_user_meta( $user_ID, 's2_subscribed', true );
$categories = explode( ',', $categories );
$format = get_user_meta( $user_ID, 's2_format', true );
$autosub = get_user_meta( $user_ID, 's2_autosub', true );
// load blogs of user (only if we need them)
$blogs = array();
if ( count( $categories ) > 0 && ! in_array( '-1', $categories, true ) ) {
$blogs = get_blogs_of_user( $user_ID, true );
}
foreach ( $blogs as $blog ) {
switch_to_blog( $blog->userblog_id );
$blog_categories = (array) $wpdb->get_col( "SELECT term_id FROM $wpdb->term_taxonomy WHERE taxonomy = 'category'" );
$subscribed_categories = array_intersect( $categories, $blog_categories );
if ( ! empty( $subscribed_categories ) ) {
foreach ( $subscribed_categories as $subscribed_category ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_cat' ) . $subscribed_category, $subscribed_category );
}
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), implode( ',', $subscribed_categories ) );
}
if ( ! empty( $format ) ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_format' ), $format );
}
if ( ! empty( $autosub ) ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_autosub' ), $autosub );
}
restore_current_blog();
}
// delete old user meta keys
delete_user_meta( $user_ID, 's2_subscribed' );
delete_user_meta( $user_ID, 's2_format' );
delete_user_meta( $user_ID, 's2_autosub' );
foreach ( $categories as $cat ) {
delete_user_meta( $user_ID, 's2_cat' . $cat );
}
}
}
}
private function upgrade7_0() {
global $mysubscribe2, $wpdb;
if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
$users = $wpdb->get_col( $wpdb->prepare( "SELECT ID from $wpdb->users WHERE ID NOT IN (SELECT user_id from $wpdb->usermeta WHERE meta_key=%s", $mysubscribe2->get_usermeta_keyname( 's2_authors' ) ) );
foreach ( $users as $user_ID ) {
$check_authors = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), true );
if ( empty( $check_authors ) ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
}
}
} else {
$args = array(
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_authors' ),
'compare' => 'NOT EXISTS',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_authors' ), '' );
}
}
}
}
private function upgrade8_5() {
global $mysubscribe2, $wpdb;
// include upgrade functions
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
maybe_add_column( $wpdb->subscribe2, 'time', "ALTER TABLE $wpdb->subscribe2 ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date" );
// update postmeta field to a protected name, from version 8.5
$wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_s2mail' WHERE meta_key = 's2mail'" );
}
private function upgrade8_6() {
global $mysubscribe2, $wpdb;
// include upgrade functions
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
maybe_add_column( $wpdb->subscribe2, 'conf_date', "ALTER TABLE $wpdb->subscribe2 ADD conf_date DATE AFTER ip" );
maybe_add_column( $wpdb->subscribe2, 'conf_time', "ALTER TABLE $wpdb->subscribe2 ADD conf_time TIME AFTER conf_date" );
maybe_add_column( $wpdb->subscribe2, 'conf_ip', "ALTER TABLE $wpdb->subscribe2 ADD conf_ip char(64) AFTER conf_time" );
// remove unnecessary table data
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 's2_cat'" );
$users = $wpdb->get_results(
$wpdb->prepare(
"SELECT ID FROM $wpdb->users INNER JOIN $wpdb->usermeta ON ( $wpdb->users.ID = $wpdb->usermeta.user_id) WHERE ( $wpdb->usermeta.meta_key = %s AND $wpdb->usermeta.meta_value LIKE %s )",
$mysubscribe2->get_usermeta_keyname( 's2_subscribed' ),
$wpdb->esc_like( ',' ) . '%'
)
);
foreach ( $users as $user ) {
// make sure we remove leading ',' from this setting
$subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
$old_cats = explode( ',', $subscribed );
unset( $old_cats[0] );
$cats = implode( ',', $old_cats );
update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
}
}
private function upgrade8_8() {
// to ensure compulsory category collects all users we need there to be s2_subscribed meta-keys for all users
global $mysubscribe2, $wpdb;
if ( version_compare( $mysubscribe2->wp_release, '3.5', '<' ) ) {
$all_registered = $mysubscribe2->get_all_registered( 'ID' );
if ( ! empty( $all_registered ) ) {
foreach ( $all_registered as $user_ID ) {
$check_subscribed = get_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
if ( empty( $check_subscribed ) ) {
update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
}
}
}
} else {
$args = array(
'meta_query' => array(
array(
'key' => $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ),
'compare' => 'NOT EXISTS',
),
),
);
$user_query = new WP_User_Query( $args );
$users = $user_query->get_results();
if ( ! empty( $users ) ) {
foreach ( $users as $user ) {
update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), '' );
}
}
}
// check the time column again as the upgrade8_6() function contained a bug
// include upgrade-functions for maybe_add_column;
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/install-helper.php';
}
maybe_add_column( $wpdb->subscribe2, 'time', "ALTER TABLE $wpdb->subscribe2 ADD time TIME DEFAULT '00:00:00' NOT NULL AFTER date" );
}
private function upgrade9_5() {
global $mysubscribe2;
if ( 'never' !== $mysubscribe2->subscribe2_options['email_freq'] ) {
$mysubscribe2->subscribe2_options['last_s2cron'] = '';
unset( $mysubscribe2->subscribe2_options['previous_s2cron'] );
}
}
private function upgrade10_14() {
global $mysubscribe2;
if ( ! isset( $mysubscribe2->subscribe2_options['frontend_form'] ) ) {
$mysubscribe2->subscribe2_options['frontend_form'] = '0';
}
if ( ! isset( $mysubscribe2->subscribe2_options['dismiss_sender_warning'] ) ) {
$mysubscribe2->subscribe2_options['dismiss_sender_warning'] = '0';
}
}
private function upgrade10_15() {
global $mysubscribe2;
if ( ! isset( $mysubscribe2->subscribe2_options['js_ip_updater'] ) ) {
$mysubscribe2->subscribe2_options['js_ip_updater'] = '0';
}
}
private function upgrade10_23() {
global $mysubscribe2;
if ( isset( $mysubscribe2->subscribe2_options['entries'] ) ) {
unset( $mysubscribe2->subscribe2_options['entries'] );
}
}
}

View File

@ -1,32 +0,0 @@
<?php
/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
/* THIS FILE EXPOSES STRINGS FROM JAVASCRIPT FILES FOR TRANSLATION */
$generated_i18n_strings = array(
__( 'Subscribe2 HTML', 'subscribe2' ),
__( 'email', 'subscribe2' ),
__( 'notification', 'subscribe2' ),
__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ),
__( 'Button Display Options', 'subscribe2' ),
__( 'Show Both Buttons', 'subscribe2' ),
__( 'Hide Subscribe Button', 'subscribe2' ),
__( 'Hide Unsubscribe Button', 'subscribe2' ),
__( 'Page ID', 'subscribe2' ),
__( 'Disable Javascript', 'subscribe2' ),
__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
__( 'Textbox size', 'subscribe2' ),
__( 'Disable wrapping of form buttons', 'subscribe2' ),
__( 'Link Text', 'subscribe2' ),
__( 'Subscribe2 HTML Shortcode', 'subscribe2' ),
__( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
__( 'Subscribe2 Resend', 'subscribe2' ),
__( 'Resend the notification email of this post to current subscribers:', 'subscribe2' ),
__( 'Resend Notification', 'subscribe2' ),
__( 'Attempt made to send email preview', 'subscribe2' ),
__( 'Attempt made to resend email notification', 'subscribe2' ),
__( 'Subscribe2 Sidebar', 'subscribe2' ),
__( 'Subscribe2 Sidebar', 'subscribe2' ),
__( 'Subscribe2 Override', 'subscribe2' ),
__( 'Subscribe2 Preview', 'subscribe2' ),
__( 'Send preview email of this post to currently logged in user:', 'subscribe2' ),
__( 'Send Preview', 'subscribe2' ),
);

View File

@ -1,401 +0,0 @@
// Version 1.0 - Initial version
// Version 1.0.1 - fix for useOnce deprecation, improve Transition from unsaved block and update 'edit' drop use of id
// Version 1.0.2 - fixed issue with transformation of text box size at default value
// Version 1.1 - eslinted and fixed bug in transformation of wrap attribute
( function( blocks, i18n, element, components, editor ) {
var el = element.createElement,
TextControl = components.TextControl,
CheckboxControl = components.CheckboxControl,
RadioControl = components.RadioControl;
function s2shortcode( props, control, newVal ) {
var attributes = props.attributes || '';
var hide = '',
id = '',
nojs = '',
antispam = '',
size = '',
wrap = '',
link = '';
// First we define the shortcode parameters from known Control values
if ( 'subscribe' === attributes.hide ) {
hide = ' hide="subscribe"';
} else if ( 'unsubscribe' === attributes.hide ) {
hide = ' hide="unsubscribe"';
}
if ( '' !== attributes.id && undefined !== attributes.id ) {
id = ' id="' + attributes.id + '"';
}
if ( true === attributes.nojs ) {
nojs = ' nojs="true"';
}
if ( true === attributes.antispam ) {
antispam = ' antispam="true"';
}
if ( '' !== attributes.size && undefined !== attributes.size && '20' !== attributes.size ) {
size = ' size="' + attributes.size + '"';
}
if ( true === attributes.wrap ) {
wrap = ' wrap="false"';
}
if ( '' !== attributes.link && undefined !== attributes.link ) {
link = ' link="' + attributes.link + '"';
}
// Second we amend parameter values based on recent input as values are asynchronous
switch ( control ) {
case 'hide':
if ( 'none' === newVal ) {
hide = '';
} else if ( 'subscribe' === newVal ) {
hide = ' hide="subscribe"';
} else if ( 'unsubscribe' === newVal ) {
hide = ' hide="unsubscribe"';
}
break;
case 'id':
if ( '' === newVal ) {
id = '';
} else {
id = ' id="' + newVal + '"';
}
break;
case 'nojs':
if ( true === newVal ) {
nojs = ' nojs="true"';
} else if ( false === newVal ) {
nojs = '';
}
break;
case 'antispam':
if ( true === newVal ) {
antispam = ' antispam="true"';
} else if ( false === newVal ) {
antispam = '';
}
break;
case 'size':
if ( '20' === newVal ) {
size = '';
} else {
size = ' size="' + newVal + '"';
}
break;
case 'wrap':
if ( true === newVal ) {
wrap = ' wrap="false"';
} else if ( false === newVal ) {
wrap = '';
}
break;
case 'link':
if ( '' === newVal ) {
link = '';
} else {
link = ' link="' + newVal + '"';
}
break;
default:
break;
}
// Now we construct and return our shortcode
props.attributes.shortcode = '[subscribe2' + hide + id + nojs + antispam + size + wrap + link + ']';
return props.attributes.shortcode;
}
blocks.registerBlockType(
'subscribe2-html/shortcode',
{
title: i18n.__( 'Subscribe2 HTML', 'subscribe2' ),
icon: 'email',
category: 'widgets',
keywords: [
i18n.__( 'email', 'subscribe2' ),
i18n.__( 'notification', 'subscribe2' )
],
supports: {
customClassName: false,
className: false,
multiple: false,
html: false
},
attributes: {
shortcode: {
type: 'text',
selector: 'p'
},
hide: {
type: 'string'
},
id: {
type: 'string'
},
nojs: {
type: 'boolean'
},
antispam: {
type: 'boolean'
},
size: {
type: 'number'
},
wrap: {
type: 'boolean'
},
link: {
type: 'string'
}
},
transforms: {
to: [
{
type: 'block',
blocks: [ 'core/shortcode' ],
transform: function( content ) {
if ( undefined === content.shortcode || '' === content.shortcode ) {
content.shortcode = '[subscribe2]';
}
return blocks.createBlock( 'core/shortcode', { text: content.shortcode } );
}
}
],
from: [
{
type: 'block',
blocks: [ 'core/shortcode' ],
transform: function( content ) {
var shortcode, params, param, hide, id, nojs, antispam, size, wrap, link, i, l;
if ( 'subscribe2' === content.text.substr( 1, 10 ) ) {
shortcode = content.text;
params = content.text.replace( /^\[subscribe2|\]$/g, '' ).replace( /^\s+|\s+$/g, '' ).split( /['"]\s/g );
l = params.length;
for ( i = 0; i < l; i++ ) {
param = params[i].split( '=' );
if ( 'hide' === param[0] ) {
hide = param[1].replace( /['"]+/g, '' );
}
if ( 'id' === param[0] ) {
id = param[1].replace( /['"]+/g, '' );
}
if ( 'nojs' === param[0] ) {
nojs = 'true' === param[1].replace( /['"]+/g, '' );
}
if ( 'antispam' === param[0] ) {
antispam = 'true' === param[1].replace( /['"]+/g, '' );
}
if ( 'size' === param[0] ) {
size = param[1].replace( /['"]+/g, '' );
}
if ( 'wrap' === param[0] ) {
wrap = 'false' === param[1].replace( /['"]+/g, '' );
}
if ( 'link' === param[0] ) {
link = param[1].replace( /^['"]|['"]$/g, '' );
}
}
return blocks.createBlock(
'subscribe2-html/shortcode',
{
shortcode: shortcode,
hide: hide,
id: id,
nojs: nojs,
antispam: antispam,
size: size,
wrap: wrap,
link: link
}
);
}
}
},
{
type: 'shortcode',
tag: 'subscribe2',
attributes: {
shortcode: {
type: 'string',
selector: 'p'
},
hide: {
type: 'string',
shortcode: function( content ) {
return content.named.hide || 'none';
}
},
id: {
type: 'string',
shortcode: function( content ) {
return content.named.id || '';
}
},
nojs: {
type: 'boolean',
shortcode: function( content ) {
return content.named.nojs || false;
}
},
antispam: {
type: 'boolean',
shortcode: function( content ) {
return content.named.antispam || false;
}
},
size: {
type: 'number',
shortcode: function( content ) {
return content.named.size || '20';
}
},
wrap: {
type: 'boolean',
shortcode: function( content ) {
return content.named.wrap || false;
}
},
link: {
type: 'string',
shortcode: function( content ) {
return content.named.link || '';
}
}
}
}
]
},
edit: function( props ) {
var hide = props.attributes.hide || 'none',
id = props.attributes.id || '',
nojs = props.attributes.nojs || false,
antispam = props.attributes.antispam || false,
size = props.attributes.size || '20',
wrap = props.attributes.wrap || false,
link = props.attributes.link || '',
isSelected = props.isSelected;
function onChangeHide( newHide ) {
props.attributes.shortcode = s2shortcode( props, 'hide', newHide );
props.setAttributes( { hide: newHide } );
}
function onChangeId( newId ) {
props.attributes.shortcode = s2shortcode( props, 'id', newId );
props.setAttributes( { id: newId } );
}
function onChangeNojs( newNojs ) {
props.attributes.shortcode = s2shortcode( props, 'nojs', newNojs );
props.setAttributes( { nojs: newNojs } );
}
function onChangeAntispam( newAntispam ) {
props.attributes.shortcode = s2shortcode( props, 'antispam', newAntispam );
props.setAttributes( { antispam: newAntispam } );
}
function onChangeSize( newSize ) {
props.attributes.shortcode = s2shortcode( props, 'size', newSize );
props.setAttributes( { size: newSize } );
}
function onChangeWrap( newWrap ) {
props.attributes.shortcode = s2shortcode( props, 'wrap', newWrap );
props.setAttributes( { wrap: newWrap } );
}
function onChangeLink( newLink ) {
props.attributes.shortcode = s2shortcode( props, 'link', newLink );
props.setAttributes( { link: newLink } );
}
return [
isSelected && el(
editor.InspectorControls,
{ key: 'subscribe2-html/inspector' },
el( 'h3', {}, i18n.__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ) ),
el(
RadioControl,
{
label: i18n.__( 'Button Display Options', 'subscribe2' ),
selected: hide,
onChange: onChangeHide,
options: [
{ value: 'none', label: i18n.__( 'Show Both Buttons', 'subscribe2' ) },
{ value: 'subscribe', label: i18n.__( 'Hide Subscribe Button', 'subscribe2' ) },
{ value: 'unsubscribe', label: i18n.__( 'Hide Unsubscribe Button', 'subscribe2' ) }
]
}
),
el(
TextControl,
{
type: 'number',
label: i18n.__( 'Page ID', 'subscribe2' ),
value: id,
onChange: onChangeId
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable Javascript', 'subscribe2' ),
checked: nojs,
onChange: onChangeNojs
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
checked: antispam,
onChange: onChangeAntispam
}
),
el(
TextControl,
{
type: 'number',
label: i18n.__( 'Textbox size', 'subscribe2' ),
value: size,
onChange: onChangeSize
}
),
el(
CheckboxControl,
{
label: i18n.__( 'Disable wrapping of form buttons', 'subscribe2' ),
checked: wrap,
onChange: onChangeWrap
}
),
el(
TextControl,
{
type: 'string',
label: i18n.__( 'Link Text', 'subscribe2' ),
value: link,
onChange: onChangeLink
}
)
),
el(
'div',
{
key: 'subscribe2-html/block',
style: { backgroundColor: '#ff0', color: '#000', padding: '2px', 'textAlign': 'center' }
},
i18n.__( 'Subscribe2 HTML Shortcode', 'subscribe2' )
)
];
},
save: function( props ) {
return el( element.RawHTML, null, '<p>' + props.attributes.shortcode + '</p>' );
}
}
);
} (
window.wp.blocks,
window.wp.i18n,
window.wp.element,
window.wp.components,
window.wp.editor
) );

File diff suppressed because one or more lines are too long

View File

@ -1,221 +0,0 @@
// Version 1.0 - Initial version
// Version 1.1 - Add Resend functionality
var privateSetting = '';
wp.apiFetch( { path: '/s2/v1/settings/private' } ).then(
function ( setting ) {
privateSetting = setting;
}
);
wp.apiFetch( { path: '/s2/v1/settings/s2meta_default' } ).then(
function ( setting ) {
var s2mail = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' )._s2mail;
if ( '' === s2mail ) {
if ( '0' === setting ) {
s2mail = 'yes';
} else if ( '1' === setting ) {
s2mail = 'no';
}
wp.data.dispatch( 'core/editor' ).editPost( { meta: { '_s2mail': s2mail } } );
wp.data.dispatch( 'core/editor' ).savePost();
}
}
);
( function( plugins, element, i18n, editPost, components, data, compose, apiFetch ) {
var registerPlugin = plugins.registerPlugin,
el = element.createElement,
__ = i18n.__,
Fragment = element.Fragment,
PluginSidebar = editPost.PluginSidebar,
PluginSidebarMoreMenuItem = editPost.PluginSidebarMoreMenuItem,
PanelBody = components.PanelBody,
PanelRow = components.PanelRow,
CheckboxControl = components.CheckboxControl,
Button = components.Button,
select = data.select,
dispatch = data.dispatch,
withSelect = data.withSelect,
withDispatch = data.withDispatch,
Compose = compose.compose;
var CheckboxControlMeta = Compose(
withSelect(
function( select, props ) {
var s2mail = select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ props.fieldName ];
return {
metaChecked: ( 'no' === s2mail ? true : false )
};
}
),
withDispatch(
function( dispatch, props ) {
return {
setMetaChecked: function( value ) {
var s2mail = ( true === value ? 'no' : 'yes' );
dispatch( 'core/editor' ).editPost( { meta: { [ props.fieldName ]: s2mail } } );
dispatch( 'core/editor' ).savePost();
}
};
}
)
)(
function( props ) {
return el(
CheckboxControl,
{
label: __( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
checked: props.metaChecked,
onChange: function( content ) {
props.setMetaChecked( content );
}
}
);
}
);
var maybeRenderResend = function() {
if ( 'publish' === select( 'core/editor' ).getEditedPostAttribute( 'status' ) ) {
return renderResendPanel();
} else if ( 'private' === select( 'core/editor' ).getEditedPostAttribute( 'status' ) && 'yes' === privateSetting ) {
return renderResendPanel();
}
};
var renderResendPanel = function() {
return el(
PanelBody,
{
title: __( 'Subscribe2 Resend', 'subscribe2' ),
initialOpen: false
},
el(
PanelRow,
{},
el(
'div',
null,
__( 'Resend the notification email of this post to current subscribers:', 'subscribe2' )
)
),
el(
PanelRow,
{},
el(
Button,
{
isDefault: true,
onClick: resendClick
},
__( 'Resend Notification', 'subscribe2' )
)
)
);
};
var previewClick = function() {
var postid = select( 'core/editor' ).getCurrentPostId();
dispatch( 'core/editor' ).savePost();
apiFetch( { path: '/s2/v1/preview/' + postid } );
dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to send email preview', 'subscribe2' ) );
};
var resendClick = function() {
var postid = select( 'core/editor' ).getCurrentPostId();
dispatch( 'core/editor' ).savePost();
apiFetch( { path: '/s2/v1/resend/' + postid } );
dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to resend email notification', 'subscribe2' ) );
};
var s2sidebar = function() {
return el(
Fragment,
{},
el(
PluginSidebarMoreMenuItem,
{
target: 's2-sidebar',
icon: 'email'
},
__( 'Subscribe2 Sidebar', 'subscribe2' )
),
el(
PluginSidebar,
{
name: 's2-sidebar',
title: __( 'Subscribe2 Sidebar', 'subscribe2' ),
icon: 'email',
isPinned: true,
isPinnable: true,
togglePin: true,
togglesidebar: false
},
el(
PanelBody,
{
title: __( 'Subscribe2 Override', 'subscribe2' ),
initialOpen: true
},
el(
PanelRow,
{},
el(
CheckboxControlMeta,
{
fieldName: '_s2mail'
}
)
)
),
el(
PanelBody,
{
title: __( 'Subscribe2 Preview', 'subscribe2' ),
initialOpen: false
},
el(
PanelRow,
{},
el(
'div',
null,
__( 'Send preview email of this post to currently logged in user:', 'subscribe2' )
)
),
el(
PanelRow,
{},
el(
Button,
{
isDefault: true,
onClick: previewClick
},
__( 'Send Preview', 'subscribe2' )
)
)
),
maybeRenderResend()
)
);
};
registerPlugin(
'subscribe2-sidebar',
{
render: s2sidebar
}
);
} (
wp.plugins,
wp.element,
wp.i18n,
wp.editPost,
wp.components,
wp.data,
wp.compose,
wp.apiFetch
) );

View File

@ -1 +0,0 @@
var privateSetting="";wp.apiFetch({path:"/s2/v1/settings/private"}).then(function(e){privateSetting=e}),wp.apiFetch({path:"/s2/v1/settings/s2meta_default"}).then(function(e){var t=wp.data.select("core/editor").getEditedPostAttribute("meta")._s2mail;""===t&&("0"===e?t="yes":"1"===e&&(t="no"),wp.data.dispatch("core/editor").editPost({meta:{_s2mail:t}}),wp.data.dispatch("core/editor").savePost())}),function(e,t,i,s,r,n,o,a){var c=e.registerPlugin,d=t.createElement,u=i.__,b=t.Fragment,l=s.PluginSidebar,p=s.PluginSidebarMoreMenuItem,m=r.PanelBody,h=r.PanelRow,f=r.CheckboxControl,v=r.Button,g=n.select,P=n.dispatch,w=n.withSelect,S=n.withDispatch,C=(0,o.compose)(w(function(e,t){return{metaChecked:"no"===e("core/editor").getEditedPostAttribute("meta")[t.fieldName]}}),S(function(e,t){return{setMetaChecked:function(i){var s=!0===i?"no":"yes";e("core/editor").editPost({meta:{[t.fieldName]:s}}),e("core/editor").savePost()}}}))(function(e){return d(f,{label:u("Check here to disable sending of an email notification for this post/page","subscribe2"),checked:e.metaChecked,onChange:function(t){e.setMetaChecked(t)}})}),k=function(){return d(m,{title:u("Subscribe2 Resend","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Resend the notification email of this post to current subscribers:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:N},u("Resend Notification","subscribe2"))))},A=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/preview/"+e}),P("core/notices").createInfoNotice(u("Attempt made to send email preview","subscribe2"))},N=function(){var e=g("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/resend/"+e}),P("core/notices").createInfoNotice(u("Attempt made to resend email notification","subscribe2"))};c("subscribe2-sidebar",{render:function(){return d(b,{},d(p,{target:"s2-sidebar",icon:"email"},u("Subscribe2 Sidebar","subscribe2")),d(l,{name:"s2-sidebar",title:u("Subscribe2 Sidebar","subscribe2"),icon:"email",isPinned:!0,isPinnable:!0,togglePin:!0,togglesidebar:!1},d(m,{title:u("Subscribe2 Override","subscribe2"),initialOpen:!0},d(h,{},d(C,{fieldName:"_s2mail"}))),d(m,{title:u("Subscribe2 Preview","subscribe2"),initialOpen:!1},d(h,{},d("div",null,u("Send preview email of this post to currently logged in user:","subscribe2"))),d(h,{},d(v,{isDefault:!0,onClick:A},u("Send Preview","subscribe2")))),"publish"===g("core/editor").getEditedPostAttribute("status")?k():"private"===g("core/editor").getEditedPostAttribute("status")&&"yes"===privateSetting?k():void 0))}})}(wp.plugins,wp.element,wp.i18n,wp.editPost,wp.components,wp.data,wp.compose,wp.apiFetch);

View File

@ -1,21 +0,0 @@
{
"name": "appsero/client",
"description": "Appsero Client",
"keywords": ["analytics", "wordpress", "plugin", "theme"],
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Tareq Hasan",
"email": "tareq@appsero.com"
}
],
"autoload": {
"psr-4": {
"Appsero\\": "src/"
}
},
"require": {
"php": ">=5.3"
}
}

View File

@ -1,206 +0,0 @@
# Appsero - Client
- [Installation](#installation)
- [Insights](#insights)
- [Dynamic Usage](#dynamic-usage)
## Installation
You can install AppSero Client in two ways, via composer and manually.
### 1. Composer Installation
Add dependency in your project (theme/plugin):
```
composer require appsero/client
```
Now add `autoload.php` in your file if you haven't done already.
```php
require __DIR__ . '/vendor/autoload.php';
```
### 2. Manual Installation
Clone the repository in your project.
```
cd /path/to/your/project/folder
git clone https://github.com/AppSero/client.git appsero
```
Now include the dependencies in your plugin/theme.
```php
require __DIR__ . '/appsero/src/Client.php';
```
## Insights
AppSero can be used in both themes and plugins.
The `Appsero\Client` class has *three* parameters:
```php
$client = new Appsero\Client( $hash, $name, $file );
```
- **hash** (*string*, *required*) - The unique identifier for a plugin or theme.
- **name** (*string*, *required*) - The name of the plugin or theme.
- **file** (*string*, *required*) - The **main file** path of the plugin. For theme, path to `functions.php`
### Usage Example
Please refer to the **installation** step before start using the class.
You can obtain the **hash** for your plugin for the [Appsero Dashboard](https://dashboard.appsero.com). The 3rd parameter **must** have to be the main file of the plugin.
```php
/**
* Initialize the tracker
*
* @return void
*/
function appsero_init_tracker_appsero_test() {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once __DIR__ . '/appsero/src/Client.php';
}
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044891', 'Akismet', __FILE__ );
// Active insights
$client->insights()->init();
// Active automatic updater
$client->updater();
// Active license page and checker
$args = array(
'type' => 'options',
'menu_title' => 'Akismet',
'page_title' => 'Akismet License Settings',
'menu_slug' => 'akismet_settings',
);
$client->license()->add_settings_page( $args );
}
appsero_init_tracker_appsero_test();
```
Make sure you call this function directly, never use any action hook to call this function.
> For plugins example code that needs to be used on your main plugin file.
> For themes example code that needs to be used on your themes `functions.php` file.
## More Usage
Sometimes you wouldn't want to show the notice, or want to customize the notice message. You can do that as well.
```php
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );
```
#### 1. Hiding the notice
```php
$client->insights()
->hide_notice()
->init();
```
#### 2. Customizing the notice message
```php
$client->insights()
->notice( 'My Custom Notice Message' )
->init();
```
#### 3. Adding extra data
You can add extra metadata from your theme or plugin. In that case, the **keys** has to be whitelisted from the Appsero dashboard.
`add_extra` method also support callback as parameter, If you need database call then callback is best for you.
```php
$metadata = array(
'key' => 'value',
'another' => 'another_value'
);
$client->insights()
->add_extra( $metadata )
->init();
```
or
```php
$metadata = function () {
return array(
'key' => 'value',
'another' => 'another_value'
);
};
$client->insights()
->add_extra( $metadata )
->init();
```
---
### Check License Validity
Check your plugin/theme is using with valid license or not, First create a global variable of `License` object then use it anywhere in your code.
If you are using it outside of same function make sure you global the variable before using the condition.
```php
$client = new Appsero\Client( 'a4a8da5b-b419-4656-98e9-4a42e9044892', 'Twenty Twelve', __FILE__ );
$args = array(
'type' => 'submenu',
'menu_title' => 'Twenty Twelve License',
'page_title' => 'Twenty Twelve License Settings',
'menu_slug' => 'twenty_twelve_settings',
'parent_slug' => 'themes.php',
);
global $twenty_twelve_license;
$twenty_twelve_license = $client->license();
$twenty_twelve_license->add_settings_page( $args );
if ( $twenty_twelve_license->is_valid() ) {
// Your special code here
}
Or check by pricing plan title
if ( $twenty_twelve_license->is_valid_by( 'title', 'Business' ) ) {
// Your special code here
}
```
### Use your own license form
You can easily manage license by creating a form using HTTP request. Call `license_form_submit` method from License object.
```php
global $twenty_twelve_license; // License object
$twenty_twelve_license->license_form_submit([
'_nonce' => wp_create_nonce( 'Twenty Twelve' ), // create a nonce with name
'_action' => 'active', // active, deactive
'license_key' => 'random-license-key', // no need to provide if you want to deactive
]);
if ( ! $twenty_twelve_license->error ) {
// license activated
$twenty_twelve_license->success; // Success message is here
} else {
$twenty_twelve_license->error; // has error message here
}
```
## Credits
Created and maintained by [Appsero](https://appsero.com).

View File

@ -1,233 +0,0 @@
<?php
namespace Appsero;
/**
* Appsero Client
*
* This class is necessary to set project data
*/
class Client {
/**
* The client version
*
* @var string
*/
public $version = '1.1.11';
/**
* Hash identifier of the plugin
*
* @var string
*/
public $hash;
/**
* Name of the plugin
*
* @var string
*/
public $name;
/**
* The plugin/theme file path
* @example .../wp-content/plugins/test-slug/test-slug.php
*
* @var string
*/
public $file;
/**
* Main plugin file
* @example test-slug/test-slug.php
*
* @var string
*/
public $basename;
/**
* Slug of the plugin
* @example test-slug
*
* @var string
*/
public $slug;
/**
* The project version
*
* @var string
*/
public $project_version;
/**
* The project type
*
* @var string
*/
public $type;
/**
* textdomain
*
* @var string
*/
public $textdomain;
/**
* Initialize the class
*
* @param string $hash hash of the plugin
* @param string $name readable name of the plugin
* @param string $file main plugin file path
*/
public function __construct( $hash, $name, $file ) {
$this->hash = $hash;
$this->name = $name;
$this->file = $file;
$this->set_basename_and_slug();
}
/**
* Initialize insights class
*
* @return Appsero\Insights
*/
public function insights() {
if ( ! class_exists( __NAMESPACE__ . '\Insights') ) {
require_once __DIR__ . '/Insights.php';
}
return new Insights( $this );
}
/**
* Initialize plugin/theme updater
*
* @return Appsero\Updater
*/
public function updater() {
if ( ! class_exists( __NAMESPACE__ . '\Updater') ) {
require_once __DIR__ . '/Updater.php';
}
return new Updater( $this );
}
/**
* Initialize license checker
*
* @return Appsero\License
*/
public function license() {
if ( ! class_exists( __NAMESPACE__ . '\License') ) {
require_once __DIR__ . '/License.php';
}
return new License( $this );
}
/**
* API Endpoint
*
* @return string
*/
public function endpoint() {
$endpoint = apply_filters( 'appsero_endpoint', 'https://api.appsero.com' );
return trailingslashit( $endpoint );
}
/**
* Set project basename, slug and version
*
* @return void
*/
protected function set_basename_and_slug() {
if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) {
$this->basename = plugin_basename( $this->file );
list( $this->slug, $mainfile) = explode( '/', $this->basename );
require_once ABSPATH . 'wp-admin/includes/plugin.php';
$plugin_data = get_plugin_data( $this->file );
$this->project_version = $plugin_data['Version'];
$this->type = 'plugin';
$this->textdomain = $this->slug;
} else {
$this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file );
list( $this->slug, $mainfile) = explode( '/', $this->basename );
$theme = wp_get_theme( $this->slug );
$this->project_version = $theme->version;
$this->type = 'theme';
}
}
/**
* Send request to remote endpoint
*
* @param array $params
* @param string $route
*
* @return array|WP_Error Array of results including HTTP headers or WP_Error if the request failed.
*/
public function send_request( $params, $route, $blocking = false ) {
$url = $this->endpoint() . $route;
$headers = array(
'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';',
'Accept' => 'application/json',
);
$response = wp_remote_post( $url, array(
'method' => 'POST',
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => $blocking,
'headers' => $headers,
'body' => array_merge( $params, array( 'client' => $this->version ) ),
'cookies' => array()
) );
return $response;
}
/**
* Check if the current server is localhost
*
* @return boolean
*/
public function is_local_server() {
return in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
}
/**
* Translate function _e()
*/
public function _etrans( $text ) {
call_user_func( '_e', $text, $this->textdomain );
}
/**
* Translate function __()
*/
public function __trans( $text ) {
return call_user_func( '__', $text, $this->textdomain );
}
}

View File

@ -1,972 +0,0 @@
<?php
namespace Appsero;
/**
* Appsero Insights
*
* This is a tracker class to track plugin usage based on if the customer has opted in.
* No personal information is being tracked by this class, only general settings, active plugins, environment details
* and admin email.
*/
class Insights {
/**
* The notice text
*
* @var string
*/
public $notice;
/**
* Wheather to the notice or not
*
* @var boolean
*/
protected $show_notice = true;
/**
* If extra data needs to be sent
*
* @var array
*/
protected $extra_data = array();
/**
* AppSero\Client
*
* @var object
*/
protected $client;
/**
* Initialize the class
*
* @param AppSero\Client
*/
public function __construct( $client, $name = null, $file = null ) {
if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) {
$client = new Client( $client, $name, $file );
}
if ( is_object( $client ) && is_a( $client, 'Appsero\Client' ) ) {
$this->client = $client;
}
}
/**
* Don't show the notice
*
* @return \self
*/
public function hide_notice() {
$this->show_notice = false;
return $this;
}
/**
* Add extra data if needed
*
* @param array $data
*
* @return \self
*/
public function add_extra( $data = array() ) {
$this->extra_data = $data;
return $this;
}
/**
* Set custom notice text
*
* @param string $text
*
* @return \self
*/
public function notice( $text ) {
$this->notice = $text;
return $this;
}
/**
* Initialize insights
*
* @return void
*/
public function init() {
if ( $this->client->type == 'plugin' ) {
$this->init_plugin();
} else if ( $this->client->type == 'theme' ) {
$this->init_theme();
}
}
/**
* Initialize theme hooks
*
* @return void
*/
public function init_theme() {
$this->init_common();
add_action( 'switch_theme', array( $this, 'deactivation_cleanup' ) );
add_action( 'switch_theme', array( $this, 'theme_deactivated' ), 12, 3 );
}
/**
* Initialize plugin hooks
*
* @return void
*/
public function init_plugin() {
// plugin deactivate popup
if ( ! $this->is_local_server() ) {
add_filter( 'plugin_action_links_' . $this->client->basename, array( $this, 'plugin_action_links' ) );
add_action( 'admin_footer', array( $this, 'deactivate_scripts' ) );
}
$this->init_common();
register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) );
register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) );
}
/**
* Initialize common hooks
*
* @return void
*/
protected function init_common() {
if ( $this->show_notice ) {
// tracking notice
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
}
add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
// uninstall reason
add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $this, 'uninstall_reason_submission' ) );
// cron events
add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) );
add_action( $this->client->slug . '_tracker_send_event', array( $this, 'send_tracking_data' ) );
// add_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test
}
/**
* Send tracking data to AppSero server
*
* @param boolean $override
*
* @return void
*/
public function send_tracking_data( $override = false ) {
// skip on AJAX Requests
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
if ( ! $this->tracking_allowed() && ! $override ) {
return;
}
// Send a maximum of once per week
$last_send = $this->get_last_send();
if ( $last_send && $last_send > strtotime( '-1 week' ) ) {
return;
}
$response = $this->client->send_request( $this->get_tracking_data(), 'track' );
update_option( $this->client->slug . '_tracking_last_send', time() );
}
/**
* Get the tracking data points
*
* @return array
*/
protected function get_tracking_data() {
$all_plugins = $this->get_all_plugins();
$users = get_users( array(
'role' => 'administrator',
'orderby' => 'ID',
'order' => 'ASC',
'number' => 1,
'paged' => 1,
) );
$admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false;
$first_name = $last_name = '';
if ( $admin_user ) {
$first_name = $admin_user->first_name ? $admin_user->first_name : $admin_user->display_name;
$last_name = $admin_user->last_name;
}
$data = array(
'version' => $this->client->project_version,
'url' => esc_url( home_url() ),
'site' => $this->get_site_name(),
'admin_email' => get_option( 'admin_email' ),
'first_name' => $first_name,
'last_name' => $last_name,
'hash' => $this->client->hash,
'server' => $this->get_server_info(),
'wp' => $this->get_wp_info(),
'users' => $this->get_user_counts(),
'active_plugins' => count( $all_plugins['active_plugins'] ),
'inactive_plugins' => count( $all_plugins['inactive_plugins'] ),
'ip_address' => $this->get_user_ip_address(),
'theme' => get_stylesheet(),
'version' => $this->client->project_version,
);
// Add metadata
if ( $extra = $this->get_extra_data() ) {
$data['extra'] = $extra;
}
return apply_filters( $this->client->slug . '_tracker_data', $data );
}
/**
* If a child class wants to send extra data
*
* @return mixed
*/
protected function get_extra_data() {
if ( is_callable( $this->extra_data ) ) {
return call_user_func( $this->extra_data );
}
if ( is_array( $this->extra_data ) ) {
return $this->extra_data;
}
return array();
}
/**
* Explain the user which data we collect
*
* @return string
*/
protected function data_we_collect() {
$data = array(
'Server environment details (php, mysql, server, WordPress versions)',
'Number of users in your site',
'Site language',
'Number of active and inactive plugins',
'Site name and url',
'Your name and email address',
);
return $data;
}
/**
* Check if the user has opted into tracking
*
* @return bool
*/
public function tracking_allowed() {
$allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' );
return $allow_tracking == 'yes';
}
/**
* Get the last time a tracking was sent
*
* @return false|string
*/
private function get_last_send() {
return get_option( $this->client->slug . '_tracking_last_send', false );
}
/**
* Check if the notice has been dismissed or enabled
*
* @return boolean
*/
private function notice_dismissed() {
$hide_notice = get_option( $this->client->slug . '_tracking_notice', null );
if ( 'hide' == $hide_notice ) {
return true;
}
return false;
}
/**
* Check if the current server is localhost
*
* @return boolean
*/
private function is_local_server() {
return false;
$is_local = in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ) );
return apply_filters( 'appsero_is_local', $is_local );
}
/**
* Schedule the event weekly
*
* @return void
*/
private function schedule_event() {
$hook_name = $this->client->slug . '_tracker_send_event';
if ( ! wp_next_scheduled( $hook_name ) ) {
wp_schedule_event( time(), 'weekly', $hook_name );
}
}
/**
* Clear any scheduled hook
*
* @return void
*/
private function clear_schedule_event() {
wp_clear_scheduled_hook( $this->client->slug . '_tracker_send_event' );
}
/**
* Display the admin notice to users that have not opted-in or out
*
* @return void
*/
public function admin_notice() {
if ( $this->notice_dismissed() ) {
return;
}
if ( $this->tracking_allowed() ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// don't show tracking if a local server
if ( ! $this->is_local_server() ) {
$optin_url = add_query_arg( $this->client->slug . '_tracker_optin', 'true' );
$optout_url = add_query_arg( $this->client->slug . '_tracker_optout', 'true' );
if ( empty( $this->notice ) ) {
$notice = sprintf( $this->client->__trans( 'Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.' ), $this->client->name );
} else {
$notice = $this->notice;
}
$policy_url = 'https://' . 'appsero.com/privacy-policy/';
$notice .= ' (<a class="' . $this->client->slug . '-insights-data-we-collect" href="#">' . $this->client->__trans( 'what we collect' ) . '</a>)';
$notice .= '<p class="description" style="display:none;">' . implode( ', ', $this->data_we_collect() ) . '. No sensitive data is tracked. ';
$notice .= 'We are using Appsero to collect your data. <a href="' . $policy_url . '">Learn more</a> about how Appsero collects and handle your data.</p>';
echo '<div class="updated"><p>';
echo $notice;
echo '</p><p class="submit">';
echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-primary button-large">' . $this->client->__trans( 'Allow' ) . '</a>';
echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary button-large">' . $this->client->__trans( 'No thanks' ) . '</a>';
echo '</p></div>';
echo "<script type='text/javascript'>jQuery('." . $this->client->slug . "-insights-data-we-collect').on('click', function(e) {
e.preventDefault();
jQuery(this).parents('.updated').find('p.description').slideToggle('fast');
});
</script>
";
}
}
/**
* handle the optin/optout
*
* @return void
*/
public function handle_optin_optout() {
if ( isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && $_GET[ $this->client->slug . '_tracker_optin' ] == 'true' ) {
$this->optin();
wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optin' ) );
exit;
}
if ( isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && $_GET[ $this->client->slug . '_tracker_optout' ] == 'true' ) {
$this->optout();
wp_redirect( remove_query_arg( $this->client->slug . '_tracker_optout' ) );
exit;
}
}
/**
* Tracking optin
*
* @return void
*/
public function optin() {
update_option( $this->client->slug . '_allow_tracking', 'yes' );
update_option( $this->client->slug . '_tracking_notice', 'hide' );
$this->clear_schedule_event();
$this->schedule_event();
$this->send_tracking_data();
}
/**
* Optout from tracking
*
* @return void
*/
public function optout() {
update_option( $this->client->slug . '_allow_tracking', 'no' );
update_option( $this->client->slug . '_tracking_notice', 'hide' );
$this->clear_schedule_event();
}
/**
* Get the number of post counts
*
* @param string $post_type
*
* @return integer
*/
public function get_post_count( $post_type ) {
global $wpdb;
return (int) $wpdb->get_var( "SELECT count(ID) FROM $wpdb->posts WHERE post_type = '$post_type' and post_status = 'publish'");
}
/**
* Get server related info.
*
* @return array
*/
private static function get_server_info() {
global $wpdb;
$server_data = array();
if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
$server_data['software'] = $_SERVER['SERVER_SOFTWARE'];
}
if ( function_exists( 'phpversion' ) ) {
$server_data['php_version'] = phpversion();
}
$server_data['mysql_version'] = $wpdb->db_version();
$server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
$server_data['php_default_timezone'] = date_default_timezone_get();
$server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
$server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
$server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
return $server_data;
}
/**
* Get WordPress related data.
*
* @return array
*/
private function get_wp_info() {
$wp_data = array();
$wp_data['memory_limit'] = WP_MEMORY_LIMIT;
$wp_data['debug_mode'] = ( defined('WP_DEBUG') && WP_DEBUG ) ? 'Yes' : 'No';
$wp_data['locale'] = get_locale();
$wp_data['version'] = get_bloginfo( 'version' );
$wp_data['multisite'] = is_multisite() ? 'Yes' : 'No';
return $wp_data;
}
/**
* Get the list of active and inactive plugins
*
* @return array
*/
private function get_all_plugins() {
// Ensure get_plugins function is loaded
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$active_plugins_keys = get_option( 'active_plugins', array() );
$active_plugins = array();
foreach ( $plugins as $k => $v ) {
// Take care of formatting the data how we want it.
$formatted = array();
$formatted['name'] = strip_tags( $v['Name'] );
if ( isset( $v['Version'] ) ) {
$formatted['version'] = strip_tags( $v['Version'] );
}
if ( isset( $v['Author'] ) ) {
$formatted['author'] = strip_tags( $v['Author'] );
}
if ( isset( $v['Network'] ) ) {
$formatted['network'] = strip_tags( $v['Network'] );
}
if ( isset( $v['PluginURI'] ) ) {
$formatted['plugin_uri'] = strip_tags( $v['PluginURI'] );
}
if ( in_array( $k, $active_plugins_keys ) ) {
// Remove active plugins from list so we can show active and inactive separately
unset( $plugins[$k] );
$active_plugins[$k] = $formatted;
} else {
$plugins[$k] = $formatted;
}
}
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
}
/**
* Get user totals based on user role.
*
* @return array
*/
public function get_user_counts() {
$user_count = array();
$user_count_data = count_users();
$user_count['total'] = $user_count_data['total_users'];
// Get user count based on user role
foreach ( $user_count_data['avail_roles'] as $role => $count ) {
$user_count[ $role ] = $count;
}
return $user_count;
}
/**
* Add weekly cron schedule
*
* @param array $schedules
*
* @return array
*/
public function add_weekly_schedule( $schedules ) {
$schedules['weekly'] = array(
'interval' => DAY_IN_SECONDS * 7,
'display' => 'Once Weekly',
);
return $schedules;
}
/**
* Plugin activation hook
*
* @return void
*/
public function activate_plugin() {
$allowed = get_option( $this->client->slug . '_allow_tracking', 'no' );
// if it wasn't allowed before, do nothing
if ( 'yes' !== $allowed ) {
return;
}
// re-schedule and delete the last sent time so we could force send again
$hook_name = $this->client->slug . '_tracker_send_event';
if ( ! wp_next_scheduled( $hook_name ) ) {
wp_schedule_event( time(), 'weekly', $hook_name );
}
delete_option( $this->client->slug . '_tracking_last_send' );
$this->send_tracking_data( true );
}
/**
* Clear our options upon deactivation
*
* @return void
*/
public function deactivation_cleanup() {
$this->clear_schedule_event();
if ( 'theme' == $this->client->type ) {
delete_option( $this->client->slug . '_tracking_last_send' );
delete_option( $this->client->slug . '_allow_tracking' );
}
delete_option( $this->client->slug . '_tracking_notice' );
}
/**
* Hook into action links and modify the deactivate link
*
* @param array $links
*
* @return array
*/
public function plugin_action_links( $links ) {
if ( array_key_exists( 'deactivate', $links ) ) {
$links['deactivate'] = str_replace( '<a', '<a class="' . $this->client->slug . '-deactivate-link"', $links['deactivate'] );
}
return $links;
}
/**
* Plugin uninstall reasons
*
* @return array
*/
private function get_uninstall_reasons() {
$reasons = array(
array(
'id' => 'could-not-understand',
'text' => "I couldn't understand how to make it work",
'type' => 'textarea',
'placeholder' => 'Would you like us to assist you?'
),
array(
'id' => 'found-better-plugin',
'text' => 'I found a better plugin',
'type' => 'text',
'placeholder' => 'Which plugin?'
),
array(
'id' => 'not-have-that-feature',
'text' => 'The plugin is great, but I need specific feature that you don\'t support',
'type' => 'textarea',
'placeholder' => 'Could you tell us more about that feature?'
),
array(
'id' => 'is-not-working',
'text' => 'The plugin is not working',
'type' => 'textarea',
'placeholder' => 'Could you tell us a bit more whats not working?'
),
array(
'id' => 'looking-for-other',
'text' => "It's not what I was looking for",
'type' => '',
'placeholder' => ''
),
array(
'id' => 'did-not-work-as-expected',
'text' => "The plugin didn't work as expected",
'type' => 'textarea',
'placeholder' => 'What did you expect?'
),
array(
'id' => 'other',
'text' => 'Other',
'type' => 'textarea',
'placeholder' => 'Could you tell us a bit more?'
),
);
return $reasons;
}
/**
* Plugin deactivation uninstall reason submission
*
* @return void
*/
public function uninstall_reason_submission() {
if ( ! isset( $_POST['reason_id'] ) ) {
wp_send_json_error();
}
$current_user = wp_get_current_user();
$data = array(
'hash' => $this->client->hash,
'reason_id' => sanitize_text_field( $_POST['reason_id'] ),
'reason_info' => isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( $_REQUEST['reason_info'] ) ) : '',
'site' => $this->get_site_name(),
'url' => esc_url( home_url() ),
'admin_email' => get_option( 'admin_email' ),
'user_email' => $current_user->user_email,
'first_name' => $current_user->first_name,
'last_name' => $current_user->last_name,
'server' => $this->get_server_info(),
'wp' => $this->get_wp_info(),
'ip_address' => $this->get_user_ip_address(),
'theme' => get_stylesheet(),
'version' => $this->client->project_version,
);
// Add metadata
if ( $extra = $this->get_extra_data() ) {
$data['extra'] = $extra;
}
$this->client->send_request( $data, 'deactivate' );
wp_send_json_success();
}
/**
* Handle the plugin deactivation feedback
*
* @return void
*/
public function deactivate_scripts() {
global $pagenow;
if ( 'plugins.php' != $pagenow ) {
return;
}
$reasons = $this->get_uninstall_reasons();
?>
<div class="wd-dr-modal" id="<?php echo $this->client->slug; ?>-wd-dr-modal">
<div class="wd-dr-modal-wrap">
<div class="wd-dr-modal-header">
<h3><?php $this->client->_etrans( 'If you have a moment, please let us know why you are deactivating:' ); ?></h3>
</div>
<div class="wd-dr-modal-body">
<ul class="reasons">
<?php foreach ($reasons as $reason) { ?>
<li data-type="<?php echo esc_attr( $reason['type'] ); ?>" data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>">
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
</li>
<?php } ?>
</ul>
<p class="wd-dr-modal-reasons-bottom">
We share your data with <a href="<?php echo 'https://appsero.com'; ?>">Appsero</a> to troubleshoot problems &amp; make product improvements.
<a href="<?php echo 'https://appsero.com/privacy-policy'; ?>">Learn more</a> about how Appsero handles your data.
</p>
</div>
<div class="wd-dr-modal-footer">
<a href="#" class="dont-bother-me"><?php $this->client->_etrans( "I rather wouldn't say" ); ?></a>
<button class="button-secondary"><?php $this->client->_etrans( 'Submit & Deactivate' ); ?></button>
<button class="button-primary"><?php $this->client->_etrans( 'Cancel' ); ?></button>
</div>
</div>
</div>
<style type="text/css">
.wd-dr-modal {
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.5);
display: none;
}
.wd-dr-modal.modal-active {
display: block;
}
.wd-dr-modal-wrap {
width: 475px;
position: relative;
margin: 10% auto;
background: #fff;
}
.wd-dr-modal-header {
border-bottom: 1px solid #eee;
padding: 8px 20px;
}
.wd-dr-modal-header h3 {
line-height: 150%;
margin: 0;
}
.wd-dr-modal-body {
padding: 5px 20px 20px 20px;
}
.wd-dr-modal-body .reason-input {
margin-top: 5px;
margin-left: 20px;
}
.wd-dr-modal-footer {
border-top: 1px solid #eee;
padding: 12px 20px;
text-align: right;
}
.wd-dr-modal-reasons-bottom {
margin: 15px 0 0 0;
}
</style>
<script type="text/javascript">
(function($) {
$(function() {
var modal = $( '#<?php echo $this->client->slug; ?>-wd-dr-modal' );
var deactivateLink = '';
$( '#the-list' ).on('click', 'a.<?php echo $this->client->slug; ?>-deactivate-link', function(e) {
e.preventDefault();
modal.addClass('modal-active');
deactivateLink = $(this).attr('href');
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
});
modal.on('click', 'button.button-primary', function(e) {
e.preventDefault();
modal.removeClass('modal-active');
});
modal.on('click', 'input[type="radio"]', function () {
var parent = $(this).parents('li:first');
modal.find('.reason-input').remove();
var inputType = parent.data('type'),
inputPlaceholder = parent.data('placeholder'),
reasonInputHtml = '<div class="reason-input">' + ( ( 'text' === inputType ) ? '<input type="text" size="40" />' : '<textarea rows="5" cols="45"></textarea>' ) + '</div>';
if ( inputType !== '' ) {
parent.append( $(reasonInputHtml) );
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
}
});
modal.on('click', 'button.button-secondary', function(e) {
e.preventDefault();
var button = $(this);
if ( button.hasClass('disabled') ) {
return;
}
var $radio = $( 'input[type="radio"]:checked', modal );
var $selected_reason = $radio.parents('li:first'),
$input = $selected_reason.find('textarea, input[type="text"]');
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action: '<?php echo $this->client->slug; ?>_submit-uninstall-reason',
reason_id: ( 0 === $radio.length ) ? 'none' : $radio.val(),
reason_info: ( 0 !== $input.length ) ? $input.val().trim() : ''
},
beforeSend: function() {
button.addClass('disabled');
button.text('Processing...');
},
complete: function() {
window.location.href = deactivateLink;
}
});
});
});
}(jQuery));
</script>
<?php
}
/**
* Run after theme deactivated
* @param string $new_name
* @param object $new_theme
* @param object $old_theme
* @return void
*/
public function theme_deactivated( $new_name, $new_theme, $old_theme ) {
// Make sure this is appsero theme
if ( $old_theme->get_template() == $this->client->slug ) {
$current_user = wp_get_current_user();
$data = array(
'hash' => $this->client->hash,
'reason_id' => 'none',
'reason_info' => '',
'site' => $this->get_site_name(),
'url' => esc_url( home_url() ),
'admin_email' => get_option( 'admin_email' ),
'user_email' => $current_user->user_email,
'first_name' => $current_user->first_name,
'last_name' => $current_user->last_name,
'server' => $this->get_server_info(),
'wp' => $this->get_wp_info(),
'ip_address' => $this->get_user_ip_address(),
'theme' => get_stylesheet(),
'version' => $this->client->project_version,
);
$this->client->send_request( $data, 'deactivate' );
}
}
/**
* Get user IP Address
*/
private function get_user_ip_address() {
$response = wp_remote_get( 'https://icanhazip.com/' );
if ( is_wp_error( $response ) ) {
return '';
}
$ip = trim( wp_remote_retrieve_body( $response ) );
if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) {
return '';
}
return $ip;
}
/**
* Get site name
*/
private function get_site_name() {
$site_name = get_bloginfo( 'name' );
if ( empty( $site_name ) ) {
$site_name = get_bloginfo( 'description' );
$site_name = wp_trim_words( $site_name, 3, '' );
}
if ( empty( $site_name ) ) {
$site_name = esc_url( home_url() );
}
return $site_name;
}
}

View File

@ -1,705 +0,0 @@
<?php
namespace Appsero;
/**
* Appsero License Checker
*
* This class will check, active and deactive license
*/
class License {
/**
* AppSero\Client
*
* @var object
*/
protected $client;
/**
* Arguments of create menu
*
* @var array
*/
protected $menu_args;
/**
* `option_name` of `wp_options` table
*
* @var string
*/
protected $option_key;
/**
* Error message of HTTP request
*
* @var string
*/
public $error;
/**
* Success message on form submit
*
* @var string
*/
public $success;
/**
* Corn schedule hook name
*
* @var string
*/
protected $schedule_hook;
/**
* Set value for valid licnese
*
* @var boolean
*/
private $is_valid_licnese = null;
/**
* Initialize the class
*
* @param Appsero\Client
*/
public function __construct( Client $client ) {
$this->client = $client;
$this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license';
$this->schedule_hook = $this->client->slug . '_license_check_event';
// Run hook to check license status daily
add_action( $this->schedule_hook, array( $this, 'check_license_status' ) );
// Active/Deactive corn schedule
$this->run_schedule();
}
/**
* Check license
*
* @return boolean
*/
public function check( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/check';
return $this->send_request( $license_key, $route );
}
/**
* Active a license
*
* @return boolean
*/
public function activate( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/activate';
return $this->send_request( $license_key, $route );
}
/**
* Deactivate a license
*
* @return boolean
*/
public function deactivate( $license_key ) {
$route = 'public/license/' . $this->client->hash . '/deactivate';
return $this->send_request( $license_key, $route );
}
/**
* Send common request
*
* @param $license_key
* @param $route
*
* @return array
*/
protected function send_request( $license_key, $route ) {
$params = array(
'license_key' => $license_key,
'url' => esc_url( home_url() ),
'is_local' => $this->client->is_local_server(),
);
$response = $this->client->send_request( $params, $route, true );
if ( is_wp_error( $response ) ) {
return array(
'success' => false,
'error' => $response->get_error_message()
);
}
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( empty( $response ) || isset( $response['exception'] )) {
return array(
'success' => false,
'error' => 'Unknown error occurred, Please try again.'
);
}
if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) {
$response = array(
'success' => false,
'error' => $response['errors']['license_key'][0]
);
}
return $response;
}
/**
* Add settings page for license
*
* @param array $args
*
* @return void
*/
public function add_settings_page( $args = array() ) {
$defaults = array(
'type' => 'menu', // Can be: menu, options, submenu
'page_title' => 'Manage License',
'menu_title' => 'Manage License',
'capability' => 'manage_options',
'menu_slug' => $this->client->slug . '-manage-license',
'icon_url' => '',
'position' => null,
'parent_slug' => '',
);
$this->menu_args = wp_parse_args( $args, $defaults );
add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 );
}
/**
* Admin Menu hook
*
* @return void
*/
public function admin_menu() {
switch ( $this->menu_args['type'] ) {
case 'menu':
$this->create_menu_page();
break;
case 'submenu':
$this->create_submenu_page();
break;
case 'options':
$this->create_options_page();
break;
}
}
/**
* License menu output
*/
public function menu_output() {
if ( isset( $_POST['submit'] ) ) {
$this->license_form_submit( $_POST );
}
$license = get_option( $this->option_key, null );
$action = ( $license && isset( $license['status'] ) && 'activate' == $license['status'] ) ? 'deactive' : 'active';
$this->licenses_style();
?>
<div class="wrap appsero-license-settings-wrapper">
<h1>License Settings</h1>
<?php
$this->show_license_page_notices();
do_action( 'before_appsero_license_section' );
?>
<div class="appsero-license-settings appsero-license-section">
<?php $this->show_license_page_card_header(); ?>
<div class="appsero-license-details">
<p>Activate <strong><?php echo $this->client->name; ?></strong> by your license key to get professional support and automatic update from your WordPress dashboard.</p>
<form method="post" action="<?php $this->formActionUrl(); ?>" novalidate="novalidate" spellcheck="false">
<input type="hidden" name="_action" value="<?php echo $action; ?>">
<input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>">
<div class="license-input-fields">
<div class="license-input-key">
<svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z"/>
</svg>
<input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>"
placeholder="Enter your license key to activate" name="license_key"
<?php echo ( 'deactive' == $action ) ? 'readonly="readonly"' : ''; ?>
/>
</div>
<button type="submit" name="submit" class="<?php echo 'deactive' == $action ? 'deactive-button' : ''; ?>">
<?php echo $action == 'active' ? 'Activate License' : 'Deactivate License' ; ?>
</button>
</div>
</form>
<?php
if ( 'deactive' == $action && isset( $license['remaining'] ) ) {
$this->show_active_license_info( $license );
}
?>
</div>
</div> <!-- /.appsero-license-settings -->
<?php do_action( 'after_appsero_license_section' ); ?>
</div>
<?php
}
/**
* License form submit
*/
public function license_form_submit( $form ) {
if ( ! isset( $form['_nonce'], $form['_action'] ) ) {
$this->error = "Please add all information";
return;
}
if ( ! wp_verify_nonce( $form['_nonce'], $this->client->name ) ) {
$this->error = "You don't have permission to manage license.";
return;
}
switch ( $form['_action'] ) {
case 'active':
$this->active_client_license( $form );
break;
case 'deactive':
$this->deactive_client_license( $form );
break;
}
}
/**
* Check license status on schedule
*/
public function check_license_status() {
$license = get_option( $this->option_key, null );
if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) {
$response = $this->check( $license['key'] );
if ( isset( $response['success'] ) && $response['success'] ) {
$license['status'] = 'activate';
$license['remaining'] = $response['remaining'];
$license['activation_limit'] = $response['activation_limit'];
$license['expiry_days'] = $response['expiry_days'];
$license['title'] = $response['title'];
$license['source_id'] = $response['source_identifier'];
$license['recurring'] = $response['recurring'];
} else {
$license['status'] = 'deactivate';
$license['expiry_days'] = 0;
}
update_option( $this->option_key, $license, false );
}
}
/**
* Check this is a valid license
*/
public function is_valid() {
if ( null !== $this->is_valid_licnese ) {
return $this->is_valid_licnese;
}
$license = get_option( $this->option_key, null );
if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) {
$this->is_valid_licnese = true;
} else {
$this->is_valid_licnese = false;
}
return $this->is_valid_licnese;
}
/**
* Check this is a valid license
*/
public function is_valid_by( $option, $value ) {
$license = get_option( $this->option_key, null );
if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] == 'activate' ) {
if ( isset( $license[ $option ] ) && $license[ $option ] == $value ) {
return true;
}
}
return false;
}
/**
* Styles for licenses page
*/
private function licenses_style() {
?>
<style type="text/css">
.appsero-license-section {
width: 100%;
max-width: 1100px;
min-height: 1px;
box-sizing: border-box;
}
.appsero-license-settings {
background-color: #fff;
box-shadow: 0px 3px 10px rgba(16, 16, 16, 0.05);
}
.appsero-license-settings * {
box-sizing: border-box;
}
.appsero-license-title {
background-color: #F8FAFB;
border-bottom: 2px solid #EAEAEA;
display: flex;
align-items: center;
padding: 10px 20px;
}
.appsero-license-title svg {
width: 30px;
height: 30px;
fill: #0082BF;
}
.appsero-license-title span {
font-size: 17px;
color: #444444;
margin-left: 10px;
}
.appsero-license-details {
padding: 20px;
}
.appsero-license-details p {
font-size: 15px;
margin: 0 0 20px 0;
}
.license-input-key {
position: relative;
flex: 0 0 72%;
max-width: 72%;
}
.license-input-key input {
background-color: #F9F9F9;
padding: 10px 15px 10px 48px;
border: 1px solid #E8E5E5;
border-radius: 3px;
height: 45px;
font-size: 16px;
color: #71777D;
width: 100%;
box-shadow: 0 0 0 transparent;
}
.license-input-key input:focus {
outline: 0 none;
border: 1px solid #E8E5E5;
box-shadow: 0 0 0 transparent;
}
.license-input-key svg {
width: 22px;
height: 22px;
fill: #0082BF;
position: absolute;
left: 14px;
top: 13px;
}
.license-input-fields {
display: flex;
justify-content: space-between;
margin-bottom: 30px;
max-width: 850px;
width: 100%;
}
.license-input-fields button {
color: #fff;
font-size: 17px;
padding: 8px;
height: 46px;
background-color: #0082BF;
border-radius: 3px;
cursor: pointer;
flex: 0 0 25%;
max-width: 25%;
border: 1px solid #0082BF;
}
.license-input-fields button.deactive-button {
background-color: #E40055;
border-color: #E40055;
}
.license-input-fields button:focus {
outline: 0 none;
}
.active-license-info {
display: flex;
}
.single-license-info {
min-width: 220px;
flex: 0 0 30%;
}
.single-license-info h3 {
font-size: 18px;
margin: 0 0 12px 0;
}
.single-license-info p {
margin: 0;
color: #00C000;
}
.single-license-info p.occupied {
color: #E40055;
}
</style>
<?php
}
/**
* Show active license information
*/
private function show_active_license_info( $license ) {
?>
<div class="active-license-info">
<div class="single-license-info">
<h3>Activation Remaining</h3>
<?php if ( empty( $license['activation_limit'] ) ): ?>
<p>Unlimited</p>
<?php else: ?>
<p class="<?php echo $license['remaining'] ? '' : 'occupied'; ?>">
<?php echo $license['remaining']; ?> out of <?php echo $license['activation_limit']; ?>
</p>
<?php endif; ?>
</div>
<div class="single-license-info">
<h3>Expires in</h3>
<?php
if ( $license['recurring'] && false !== $license['expiry_days'] ) {
$occupied = $license['expiry_days'] > 10 ? '' : 'occupied';
echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>';
} else {
echo '<p>Never</p>';
}
?>
</div>
</div>
<?php
}
/**
* Show license settings page notices
*/
private function show_license_page_notices() {
if ( ! empty( $this->error ) ) :
?>
<div class="notice notice-error is-dismissible appsero-license-section">
<p><?php echo $this->error; ?></p>
</div>
<?php
endif;
if ( ! empty( $this->success ) ) :
?>
<div class="notice notice-success is-dismissible appsero-license-section">
<p><?php echo $this->success; ?></p>
</div>
<?php
endif;
echo '<br />';
}
/**
* Card header
*/
private function show_license_page_card_header() {
?>
<div class="appsero-license-title">
<svg enable-background="new 0 0 299.995 299.995" version="1.1" viewBox="0 0 300 300" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z"/>
<path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z"/>
<path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z"/>
</svg>
<span>Activate License</span>
</div>
<?php
}
/**
* Active client license
*/
private function active_client_license( $form ) {
if ( empty( $form['license_key'] ) ) {
$this->error = 'The license key field is required.';
return;
}
$license_key = sanitize_text_field( $form['license_key'] );
$response = $this->activate( $license_key );
if ( ! $response['success'] ) {
$this->error = $response['error'] ? $response['error'] : 'Unknown error occurred.';
return;
}
$data = array(
'key' => $license_key,
'status' => 'activate',
'remaining' => $response['remaining'],
'activation_limit' => $response['activation_limit'],
'expiry_days' => $response['expiry_days'],
'title' => $response['title'],
'source_id' => $response['source_identifier'],
'recurring' => $response['recurring'],
);
update_option( $this->option_key, $data, false );
$this->success = 'License activated successfully.';
}
/**
* Deactive client license
*/
private function deactive_client_license( $form ) {
$license = get_option( $this->option_key, null );
if ( empty( $license['key'] ) ) {
$this->error = 'License key not found.';
return;
}
$response = $this->deactivate( $license['key'] );
$data = array(
'key' => '',
'status' => 'deactivate',
);
update_option( $this->option_key, $data, false );
if ( ! $response['success'] ) {
$this->error = $response['error'] ? $response['error'] : 'Unknown error occurred.';
return;
}
$this->success = 'License deactivated successfully.';
}
/**
* Add license menu page
*/
private function create_menu_page() {
call_user_func(
'add_' . 'menu' . '_page',
$this->menu_args['page_title'],
$this->menu_args['menu_title'],
$this->menu_args['capability'],
$this->menu_args['menu_slug'],
array( $this, 'menu_output' ),
$this->menu_args['icon_url'],
$this->menu_args['position']
);
}
/**
* Add submenu page
*/
private function create_submenu_page() {
call_user_func(
'add_' . 'submenu' . '_page',
$this->menu_args['parent_slug'],
$this->menu_args['page_title'],
$this->menu_args['menu_title'],
$this->menu_args['capability'],
$this->menu_args['menu_slug'],
array( $this, 'menu_output' ),
$this->menu_args['position']
);
}
/**
* Add submenu page
*/
private function create_options_page() {
call_user_func(
'add_' . 'options' . '_page',
$this->menu_args['page_title'],
$this->menu_args['menu_title'],
$this->menu_args['capability'],
$this->menu_args['menu_slug'],
array( $this, 'menu_output' ),
$this->menu_args['position']
);
}
/**
* Schedule daily sicense checker event
*/
public function schedule_cron_event() {
if ( ! wp_next_scheduled( $this->schedule_hook ) ) {
wp_schedule_event( time(), 'daily', $this->schedule_hook );
wp_schedule_single_event( time() + 20, $this->schedule_hook );
}
}
/**
* Clear any scheduled hook
*/
public function clear_scheduler() {
wp_clear_scheduled_hook( $this->schedule_hook );
}
/**
* Enable/Disable schedule
*/
private function run_schedule() {
switch ( $this->client->type ) {
case 'plugin':
register_activation_hook( $this->client->file, array( $this, 'schedule_cron_event' ) );
register_deactivation_hook( $this->client->file, array( $this, 'clear_scheduler' ) );
break;
case 'theme':
add_action( 'after_switch_theme', array( $this, 'schedule_cron_event' ) );
add_action( 'switch_theme', array( $this, 'clear_scheduler' ) );
break;
}
}
/**
* Form action URL
*/
private function formActionUrl() {
echo add_query_arg(
array( 'page' => $_GET['page'] ),
admin_url( basename( $_SERVER['SCRIPT_NAME'] ) )
);
}
/**
* Get input license key
* @param $action
* @return $license
*/
private function get_input_license_value( $action, $license ) {
if ( 'active' == $action ) {
return isset( $license['key'] ) ? $license['key'] : '';
}
if ( 'deactive' == $action ) {
$key_length = strlen( $license['key'] );
return str_pad(
substr( $license['key'], 0, $key_length / 2 ), $key_length, '*'
);
}
return '';
}
}

View File

@ -1,247 +0,0 @@
<?php
namespace Appsero;
/**
* Appsero Updater
*
* This class will show new updates project
*/
class Updater {
/**
* Appsero\Client
*
* @var object
*/
protected $client;
/**
* Initialize the class
*
* @param Appsero\Client
*/
public function __construct( Client $client ) {
$this->client = $client;
$this->cache_key = 'appsero_' . md5( $this->client->slug ) . '_version_info';
// Run hooks.
if ( $this->client->type == 'plugin' ) {
$this->run_plugin_hooks();
} elseif ( $this->client->type == 'theme' ) {
$this->run_theme_hooks();
}
}
/**
* Set up WordPress filter to hooks to get update.
*
* @return void
*/
public function run_plugin_hooks() {
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_plugin_update' ) );
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
}
/**
* Set up WordPress filter to hooks to get update.
*
* @return void
*/
public function run_theme_hooks() {
add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_theme_update' ) );
}
/**
* Check for Update for this specific project
*/
public function check_plugin_update( $transient_data ) {
global $pagenow;
if ( ! is_object( $transient_data ) ) {
$transient_data = new \stdClass;
}
if ( 'plugins.php' == $pagenow && is_multisite() ) {
return $transient_data;
}
if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->basename ] ) ) {
return $transient_data;
}
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->get_project_latest_version();
$this->set_cached_version_info( $version_info );
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) {
unset( $version_info->sections );
$transient_data->response[ $this->client->basename ] = $version_info;
}
$transient_data->last_checked = time();
$transient_data->checked[ $this->client->basename ] = $this->client->project_version;
}
return $transient_data;
}
/**
* Get version info from database
*
* @return Object or Boolean
*/
private function get_cached_version_info() {
$value = get_transient( $this->cache_key );
if( ! $value && ! isset( $value->name ) ) {
return false; // Cache is expired
}
// We need to turn the icons into an array
if ( isset( $value->icons ) ) {
$value->icons = (array) $value->icons;
}
// We need to turn the banners into an array
if ( isset( $value->banners ) ) {
$value->banners = (array) $value->banners;
}
if ( isset( $value->sections ) ) {
$value->sections = (array) $value->sections;
}
return $value;
}
/**
* Set version info to database
*/
private function set_cached_version_info( $value ) {
if ( ! $value ) {
return;
}
set_transient( $this->cache_key, $value, 3 * HOUR_IN_SECONDS );
}
/**
* Get plugin info from Appsero
*/
private function get_project_latest_version() {
$license_option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license';
$license = get_option( $license_option_key, null );
$params = array(
'version' => $this->client->project_version,
'name' => $this->client->name,
'slug' => $this->client->slug,
'basename' => $this->client->basename,
'license_key' => ! empty( $license ) && isset( $license['key'] ) ? $license['key'] : '',
);
$route = 'update/' . $this->client->hash . '/check';
$response = $this->client->send_request( $params, $route, true );
if ( is_wp_error( $response ) ) {
return false;
}
$response = json_decode( wp_remote_retrieve_body( $response ) );
if ( ! isset( $response->slug ) ) {
return false;
}
if ( isset( $response->icons ) ) {
$response->icons = (array) $response->icons;
}
if ( isset( $response->banners ) ) {
$response->banners = (array) $response->banners;
}
if ( isset( $response->sections ) ) {
$response->sections = (array) $response->sections;
}
return $response;
}
/**
* Updates information on the "View version x.x details" page with custom data.
*
* @param mixed $data
* @param string $action
* @param object $args
*
* @return object $data
*/
public function plugins_api_filter( $data, $action = '', $args = null ) {
if ( $action != 'plugin_information' ) {
return $data;
}
if ( ! isset( $args->slug ) || ( $args->slug != $this->client->slug ) ) {
return $data;
}
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->get_project_latest_version();
$this->set_cached_version_info( $version_info );
}
return $version_info;
}
/**
* Check theme upate
*/
public function check_theme_update( $transient_data ) {
global $pagenow;
if ( ! is_object( $transient_data ) ) {
$transient_data = new \stdClass;
}
if ( 'themes.php' == $pagenow && is_multisite() ) {
return $transient_data;
}
if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->slug ] ) ) {
return $transient_data;
}
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->get_project_latest_version();
$this->set_cached_version_info( $version_info );
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) {
$transient_data->response[ $this->client->slug ] = (array) $version_info;
}
$transient_data->last_checked = time();
$transient_data->checked[ $this->client->slug ] = $this->client->project_version;
}
return $transient_data;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 B

View File

@ -1,173 +0,0 @@
<?php
// Handles options for subscribe2
// DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
global $mysubscribe2;
if ( ! isset( $mysubscribe2->subscribe2_options['autosub'] ) ) {
$mysubscribe2->subscribe2_options['autosub'] = 'no';
} // option to autosubscribe registered users to new categories
if ( ! isset( $mysubscribe2->subscribe2_options['newreg_override'] ) ) {
$mysubscribe2->subscribe2_options['newreg_override'] = 'no';
} // option to autosubscribe registered users to new categories
if ( ! isset( $mysubscribe2->subscribe2_options['wpregdef'] ) ) {
$mysubscribe2->subscribe2_options['wpregdef'] = 'no';
} // option to check registration form box by default
if ( ! isset( $mysubscribe2->subscribe2_options['autoformat'] ) ) {
$mysubscribe2->subscribe2_options['autoformat'] = 'post';
} // option for default auto-subscription email format
if ( ! isset( $mysubscribe2->subscribe2_options['show_autosub'] ) ) {
$mysubscribe2->subscribe2_options['show_autosub'] = 'yes';
} // option to display auto-subscription option to registered users
if ( ! isset( $mysubscribe2->subscribe2_options['autosub_def'] ) ) {
$mysubscribe2->subscribe2_options['autosub_def'] = 'no';
} // option for user default auto-subscription to new categories
if ( ! isset( $mysubscribe2->subscribe2_options['comment_subs'] ) ) {
$mysubscribe2->subscribe2_options['comment_subs'] = 'no';
} // option for commenters to subscribe as public subscribers
if ( ! isset( $mysubscribe2->subscribe2_options['comment_def'] ) ) {
$mysubscribe2->subscribe2_options['comment_def'] = 'no';
} // option for comments box to be checked by default
if ( ! isset( $mysubscribe2->subscribe2_options['one_click_profile'] ) ) {
$mysubscribe2->subscribe2_options['one_click_profile'] = 'no';
} // option for displaying 'one-click' option on profile page
if ( ! isset( $mysubscribe2->subscribe2_options['bcclimit'] ) ) {
$mysubscribe2->subscribe2_options['bcclimit'] = 1;
} // option for default bcc limit on email notifications
if ( ! isset( $mysubscribe2->subscribe2_options['admin_email'] ) ) {
$mysubscribe2->subscribe2_options['admin_email'] = 'subs';
} // option for sending new subscriber notifications to admins
if ( ! isset( $mysubscribe2->subscribe2_options['tracking'] ) ) {
$mysubscribe2->subscribe2_options['tracking'] = '';
} // option for tracking
if ( ! isset( $mysubscribe2->subscribe2_options['s2page'] ) ) {
$mysubscribe2->subscribe2_options['s2page'] = 0;
} // option for default WordPress page for Subscribe2 to use
if ( ! isset( $mysubscribe2->subscribe2_options['s2_unsub_page'] ) ) {
$mysubscribe2->subscribe2_options['s2_unsub_page'] = 0;
} // option for default Subscribe2 unsubscribe page
if ( ! isset( $mysubscribe2->subscribe2_options['stylesheet'] ) ) {
$mysubscribe2->subscribe2_options['stylesheet'] = 'yes';
} // option to include link to theme stylesheet from HTML notifications
if ( ! isset( $mysubscribe2->subscribe2_options['embed'] ) ) {
$mysubscribe2->subscribe2_options['embed'] = 'no';
} // option to embed stylesheet and images into HTML emails
if ( ! isset( $mysubscribe2->subscribe2_options['pages'] ) ) {
$mysubscribe2->subscribe2_options['pages'] = 'no';
} // option for sending notifications for WordPress pages
if ( ! isset( $mysubscribe2->subscribe2_options['password'] ) ) {
$mysubscribe2->subscribe2_options['password'] = 'no';
} // option for sending notifications for posts that are password protected
if ( ! isset( $mysubscribe2->subscribe2_options['stickies'] ) ) {
$mysubscribe2->subscribe2_options['stickies'] = 'no';
} // option for including sticky posts in digest notifications
if ( ! isset( $mysubscribe2->subscribe2_options['private'] ) ) {
$mysubscribe2->subscribe2_options['private'] = 'no';
} // option for sending notifications for posts that are private
if ( ! isset( $mysubscribe2->subscribe2_options['email_freq'] ) ) {
$mysubscribe2->subscribe2_options['email_freq'] = 'never';
} // option for sending emails per-post or as a digest email on a cron schedule
if ( ! isset( $mysubscribe2->subscribe2_options['cron_order'] ) ) {
$mysubscribe2->subscribe2_options['cron_order'] = 'desc';
} // option for ordering of posts in digest email
if ( ! isset( $mysubscribe2->subscribe2_options['compulsory'] ) ) {
$mysubscribe2->subscribe2_options['compulsory'] = '';
} // option for compulsory categories
if ( ! isset( $mysubscribe2->subscribe2_options['exclude'] ) ) {
$mysubscribe2->subscribe2_options['exclude'] = '';
} // option for excluded categories
if ( ! isset( $mysubscribe2->subscribe2_options['sender'] ) ) {
$mysubscribe2->subscribe2_options['sender'] = 'blogname';
} // option for email notification sender
if ( ! isset( $mysubscribe2->subscribe2_options['reg_override'] ) ) {
$mysubscribe2->subscribe2_options['reg_override'] = '1';
} // option for excluded categories to be overriden for registered users
if ( ! isset( $mysubscribe2->subscribe2_options['show_meta'] ) ) {
$mysubscribe2->subscribe2_options['show_meta'] = '0';
} // option to display link to subscribe2 page from 'meta'
if ( ! isset( $mysubscribe2->subscribe2_options['show_button'] ) ) {
$mysubscribe2->subscribe2_options['show_button'] = '1';
} // option to show Subscribe2 button on Write page
if ( ! isset( $mysubscribe2->subscribe2_options['ajax'] ) ) {
$mysubscribe2->subscribe2_options['ajax'] = '0';
} // option to enable an AJAX style form
if ( ! isset( $mysubscribe2->subscribe2_options['widget'] ) ) {
$mysubscribe2->subscribe2_options['widget'] = '1';
} // option to enable Subscribe2 Widget
if ( ! isset( $mysubscribe2->subscribe2_options['counterwidget'] ) ) {
$mysubscribe2->subscribe2_options['counterwidget'] = '0';
} // option to enable Subscribe2 Counter Widget
if ( ! isset( $mysubscribe2->subscribe2_options['s2meta_default'] ) ) {
$mysubscribe2->subscribe2_options['s2meta_default'] = '0';
} // option for Subscribe2 over ride postmeta to be checked by default
if ( ! isset( $mysubscribe2->subscribe2_options['barred'] ) ) {
$mysubscribe2->subscribe2_options['barred'] = '';
} // option containing domains barred from public registration
if ( ! isset( $mysubscribe2->subscribe2_options['exclude_formats'] ) ) {
$mysubscribe2->subscribe2_options['exclude_formats'] = '';
} // option for excluding post formats as supported by the current theme
if ( ! isset( $mysubscribe2->subscribe2_options['mailtext'] ) ) {
$mysubscribe2->subscribe2_options['mailtext'] = __( "{BLOGNAME} has posted a new item, '{TITLE}'\n\n{POST}\n\nYou may view the latest post at\n{PERMALINK}\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\n{MYNAME}\n{EMAIL}", 'subscribe2' );
} // Default notification email text
if ( ! isset( $mysubscribe2->subscribe2_options['notification_subject'] ) ) {
$mysubscribe2->subscribe2_options['notification_subject'] = '[{BLOGNAME}] {TITLE}';
} // Default notification email subject
if ( ! isset( $mysubscribe2->subscribe2_options['confirm_email'] ) ) {
$mysubscribe2->subscribe2_options['confirm_email'] = __( "{BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:\n\n{LINK}\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\n{MYNAME}.", 'subscribe2' );
} // Default confirmation email text
if ( ! isset( $mysubscribe2->subscribe2_options['confirm_subject'] ) ) {
$mysubscribe2->subscribe2_options['confirm_subject'] = '[{BLOGNAME}] ' . __( 'Please confirm your request', 'subscribe2' );
} // Default confirmation email subject
if ( ! isset( $mysubscribe2->subscribe2_options['remind_email'] ) ) {
$mysubscribe2->subscribe2_options['remind_email'] = __( "This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\n{LINK}\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\n{MYNAME}", 'subscribe2' );
} // Default reminder email text
if ( ! isset( $mysubscribe2->subscribe2_options['remind_subject'] ) ) {
$mysubscribe2->subscribe2_options['remind_subject'] = '[{BLOGNAME}] ' . __( 'Subscription Reminder', 'subscribe2' );
} // Default reminder email subject
if ( ! isset( $mysubscribe2->subscribe2_options['ajax'] ) ) {
$mysubscribe2->subscribe2_options['ajax'] = '';
} // Default frontend form setting
if ( ! isset( $mysubscribe2->subscribe2_options['js_ip_updater'] ) ) {
$mysubscribe2->subscribe2_options['js_ip_updater'] = '';
} // Default setting for using javascript to update form ip address

View File

@ -1,107 +0,0 @@
/* global s2AjaxScriptStrings */
// Version 1.0 - original version
// Version 1.1 - added position and minimum width and height attributes to .dialog
// Version 1.2 - added nonce use for form submission
// Version 1.3 - eslinted
var s2jQuery = jQuery.noConflict();
s2jQuery( document ).ready(
function() {
var dialog = s2jQuery( '<div></div>' );
var ajaxurl = s2AjaxScriptStrings.ajaxurl;
s2jQuery( 'a.s2popup' ).click(
function( event ) {
var data = {
'action': 'subscribe2_form',
'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
};
event.preventDefault();
jQuery.post(
ajaxurl,
data,
function( response ) {
dialog.html( response );
}
);
dialog.dialog(
{
modal: true,
zIndex: 10000,
minWidth: 350,
minHeight: 300,
title: s2AjaxScriptStrings.title,
closeText: ""
}
);
dialog.dialog( 'open' );
}
);
s2jQuery( document ).on(
'submit',
'#s2ajaxform',
function( event ) {
var email = s2jQuery( '#s2ajaxform input[name=email]' ).val();
var ip = s2jQuery( '#s2ajaxform input[name=ip]' ).val();
var firstname = s2jQuery( '#s2ajaxform input[name=firstname]' ).val();
var lastname = s2jQuery( '#s2ajaxform input[name=lastname]' ).val();
var uri = s2jQuery( '#s2ajaxform input[name=uri]' ).val();
var btn = s2jQuery( this ).find( 'input[type=submit][clicked=true]' );
var data;
event.preventDefault();
if ( 'undefined' === typeof firstname ) {
firstname = '';
}
if ( 'undefined' === typeof lastname ) {
lastname = '';
}
if ( 'undefined' === typeof uri ) {
uri = 'http://';
}
if ( btn.length && s2jQuery( '#s2ajaxform' ).has( btn ) ) {
data = {
'action': 'subscribe2_submit',
'nonce': s2AjaxScriptStrings.nonce,
'data': {
'email': email,
'ip': ip,
'firstname': firstname,
'lastname': lastname,
'uri': uri,
'button': btn.attr( 'name' )
}
};
jQuery.post(
ajaxurl,
data,
function( response ) {
dialog.html( response );
}
);
}
}
);
// Allows detection of which button was clicked
s2jQuery( document ).on(
'click',
'#s2ajaxform input[type=submit]',
function() {
s2jQuery( '#s2ajaxform input[type=submit]' ).removeAttr( 'clicked' );
s2jQuery( this ).attr( 'clicked', 'true' );
}
);
// when form is closed return to default
s2jQuery( document ).on(
'dialogclose',
function() {
dialog.html( dialog );
}
);
}
);

View File

@ -1 +0,0 @@
var s2jQuery=jQuery.noConflict();s2jQuery(document).ready(function(){var t=s2jQuery("<div></div>"),a=s2AjaxScriptStrings.ajaxurl;s2jQuery("a.s2popup").click(function(e){var i={action:"subscribe2_form",data:s2jQuery("a.s2popup").attr("id")};e.preventDefault(),jQuery.post(a,i,function(a){t.html(a)}),t.dialog({modal:!0,zIndex:1e4,minWidth:350,minHeight:300,title:s2AjaxScriptStrings.title}),t.dialog("open")}),s2jQuery(document).on("submit","#s2ajaxform",function(e){var i,n=s2jQuery("#s2ajaxform input[name=email]").val(),r=s2jQuery("#s2ajaxform input[name=ip]").val(),u=s2jQuery("#s2ajaxform input[name=firstname]").val(),s=s2jQuery("#s2ajaxform input[name=lastname]").val(),o=s2jQuery("#s2ajaxform input[name=uri]").val(),m=s2jQuery(this).find("input[type=submit][clicked=true]");e.preventDefault(),void 0===u&&(u=""),void 0===s&&(s=""),void 0===o&&(o="http://"),m.length&&s2jQuery("#s2ajaxform").has(m)&&(i={action:"subscribe2_submit",nonce:s2AjaxScriptStrings.nonce,data:{email:n,ip:r,firstname:u,lastname:s,uri:o,button:m.attr("name")}},jQuery.post(a,i,function(a){t.html(a)}))}),s2jQuery(document).on("click","#s2ajaxform input[type=submit]",function(){s2jQuery("#s2ajaxform input[type=submit]").removeAttr("clicked"),s2jQuery(this).attr("clicked","true")}),s2jQuery(document).on("dialogclose",function(){t.html(t)})});

View File

@ -1,4 +0,0 @@
/* global QTags */
// Version 2.0 - original version for WordPress versions 3.3 and greater
QTags.addButton( 'Subscribe2', 'Subscribe2', '[subscribe2]' );

View File

@ -1 +0,0 @@
QTags.addButton("Subscribe2","Subscribe2","[subscribe2]");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 B

View File

@ -1,52 +0,0 @@
// Version 1.0 - original version
// Version 1.1 - Updated with function fixes and for WordPress 3.2 / jQuery 1.6
// Version 1.2 - Update to work when DISABLED is specified for changes in version 8.5
// Version 1.3 - Update for Subscribe2 9.0 to remove unecessary code now WordPress 3.3 is minimum requirement
// Version 1.4 - eslinted
jQuery( document ).ready(
function() {
// function to check or uncheck all when 'checkall' box it toggled
jQuery( 'input[name="checkall"]' ).click(
function() {
var checkedStatus = this.checked;
jQuery( 'input[class="' + this.value + '"]' ).each(
function() {
if ( false === jQuery( this ).prop( 'disabled' ) ) {
this.checked = checkedStatus;
}
}
);
}
);
// function to check or uncheck 'checkall' box when individual boxes are toggled
jQuery( 'input[class^="checkall"]' ).click(
function() {
var checkedStatus = true;
jQuery( 'input[class="' + this.className + '"]' ).each(
function() {
if ( ( ! this.checked ) ) {
checkedStatus = false;
}
jQuery( 'input[value="' + this.className + '"]' )
.prop( 'checked', checkedStatus );
}
);
}
);
// function to check or uncheck 'checkall' box when page is loaded
jQuery( 'input[name^="checkall"]' ).each(function(value, item) {
var checkedStatus = true;
jQuery('input[class='+item.value).each(function () {
if ( ( ! this.checked ) ) {
checkedStatus = false;
}
});
jQuery(this).prop( 'checked', checkedStatus );
}
);
}
);

View File

@ -1 +0,0 @@
jQuery(document).ready(function(){jQuery('input[name="checkall"]').click(function(){var c=this.checked;jQuery('input[class="'+this.value+'"]').each(function(){!1===jQuery(this).prop("disabled")&&(this.checked=c)})}),jQuery('input[class^="checkall"]').click(function(){var c=!0;jQuery('input[class="'+this.className+'"]').each(function(){c=!0===this.checked&&!0===c,jQuery('input[value="'+this.className+'"]').prop("checked",c)})}),jQuery('input[class^="checkall"]').each(function(){var c=!0;c=!0===this.checked&&!0===c,jQuery('input[value="'+this.className+'"]').prop("checked",c)})});

View File

@ -1,55 +0,0 @@
// Version 1.0 - original version
// Version 1.1 - Update for Subscribe2 9.0 to remove unecessary code now WordPress 3.3 is minimum requirement
// Version 1.2 - Initialise the colour fields on page load so they are the correct colour
// Version 1.3 - eslinted
jQuery( document ).ready(
function() {
jQuery( document ).on(
'focus',
'.colorpickerField',
function() {
var picker,
field = this.id.substr( 0, 20 );
if ( jQuery( this ).is( '.s2_initialised' ) || -1 !== this.id.search( '__i__' ) ) {
return; // exit early, already initialized or not activated
}
jQuery( this ).addClass( 's2_initialised' );
jQuery( '.s2_colorpicker' ).each(
function() {
if ( -1 !== this.id.search( field ) ) {
picker = this.id;
return false; // stop looping
}
}
);
jQuery( this ).on(
'focusin',
function() {
jQuery( '.s2_colorpicker' ).slideUp();
jQuery.farbtastic( '#' + picker ).linkTo( this );
jQuery( '#' + picker ).slideDown();
}
);
jQuery( this ).on(
'focusout',
function() {
jQuery( '#' + picker ).slideUp();
}
);
jQuery( this ).trigger( 'focus' );
}
);
jQuery( '.colorpickerField' ).each(
function() {
jQuery.farbtastic( '#' + this.id ).linkTo( this );
}
);
}
);

View File

@ -1 +0,0 @@
jQuery(document).ready(function(){jQuery(document).on("focus",".colorpickerField",function(){var i,e=this.id.substr(0,20);jQuery(this).is(".s2_initialised")||-1!==this.id.search("__i__")||(jQuery(this).addClass("s2_initialised"),jQuery(".s2_colorpicker").each(function(){if(-1!==this.id.search(e))return i=this.id,!1}),jQuery(this).on("focusin",function(){jQuery(".s2_colorpicker").slideUp(),jQuery.farbtastic("#"+i).linkTo(this),jQuery("#"+i).slideDown()}),jQuery(this).on("focusout",function(){jQuery("#"+i).slideUp()}),jQuery(this).trigger("focus"))}),jQuery(".colorpickerField").each(function(){jQuery.farbtastic("#"+this.id).linkTo(this)})});

View File

@ -1,12 +0,0 @@
// Version 1.0 - original version
// Version 1.1 - eslinted
jQuery( document ).ready(
function() {
jQuery( '#s2datepicker' ).datepicker(
{
dateFormat: 'MM d, yy'
}
);
}
);

View File

@ -1 +0,0 @@
jQuery(document).ready(function(){jQuery("#s2datepicker").datepicker({dateFormat:"MM d, yy"})});

View File

@ -1,17 +0,0 @@
/* global s2DismissScriptStrings */
// Version 1.0 - original version
// Version 1.1 - eslinted
jQuery( document ).on(
'click',
'#sender_message .notice-dismiss',
function() {
var ajaxurl = s2DismissScriptStrings.ajaxurl;
var data = {
'action': 's2_dismiss_notice',
'nonce': s2DismissScriptStrings.nonce
};
jQuery.post( ajaxurl, data );
}
);

View File

@ -1 +0,0 @@
jQuery(document).on("click","#sender_message .notice-dismiss",function(){var s=s2DismissScriptStrings.ajaxurl,i={action:"s2_dismiss_notice",nonce:s2DismissScriptStrings.nonce};jQuery.post(s,i)});

View File

@ -1,65 +0,0 @@
/* exported s2Show, s2Hide, s2Update, s2Revert, s2CronUpdate, s2CronRevert */
// Version 1.0 - original version
// Version 1.1 - updated for Subscribe2 8.6
// Version 1.2 - updated for Subscribe2 9.0
// Version 1.3 - eslinted
// hide our span before page loads
jQuery( document ).ready(
function() {
jQuery( '#s2bcclimit_2' ).hide();
jQuery( '#s2entries_2' ).hide();
jQuery( '#s2cron_2' ).hide();
}
);
//show span on clicking the edit link
function s2Show( id ) {
jQuery( '#s2' + id + '_2' ).show();
jQuery( '#s2' + id + '_1' ).hide();
return false;
}
// hide span on clicking the hide link
function s2Hide( id ) {
jQuery( '#s2' + id + '_1' ).show();
jQuery( '#s2' + id + '_2' ).hide();
return false;
}
function s2Update( id ) {
var input = jQuery( 'input[name="' + id + '"]' ).val();
jQuery( '#s2' + id ).html( input );
s2Hide( id );
}
function s2Revert( id ) {
var option = jQuery( '#js' + id ).val();
jQuery( 'input[name="' + id + '"]' ).val( option );
jQuery( '#s2' + id ).html( option );
s2Hide( id );
}
function s2CronUpdate( id ) {
var date, time;
date = jQuery( 'input[name="' + id + 'date"]' ).val();
jQuery( '#s2' + id + 'date' ).html( date );
time = jQuery( 'select[name="' + id + 'time"] option:selected' ).html();
jQuery( '#s2' + id + 'time' ).html( time );
s2Hide( id );
}
function s2CronRevert( id ) {
var date, time;
date = jQuery( '#js' + id + 'date' ).val();
jQuery( 'input[name="' + id + 'date"]' ).val( date );
jQuery( '#s2' + id + 'date' ).html( date );
time = jQuery( '#js' + id + 'time' ).val();
jQuery( '[name=' + id + 'time] option' ).filter(
function() {
return ( this.text === time );
}
).prop( 'selected', true ).parent().focus();
jQuery( '#s2' + id + 'time' ).html( time );
s2Hide( id );
}

View File

@ -1 +0,0 @@
function s2Show(e){return jQuery("#s2"+e+"_2").show(),jQuery("#s2"+e+"_1").hide(),!1}function s2Hide(e){return jQuery("#s2"+e+"_1").show(),jQuery("#s2"+e+"_2").hide(),!1}function s2Update(e){var t=jQuery('input[name="'+e+'"]').val();jQuery("#s2"+e).html(t),s2Hide(e)}function s2Revert(e){var t=jQuery("#js"+e).val();jQuery('input[name="'+e+'"]').val(t),jQuery("#s2"+e).html(t),s2Hide(e)}function s2CronUpdate(e){var t,r;t=jQuery('input[name="'+e+'date"]').val(),jQuery("#s2"+e+"date").html(t),r=jQuery('select[name="'+e+'time"] option:selected').html(),jQuery("#s2"+e+"time").html(r),s2Hide(e)}function s2CronRevert(e){var t,r;t=jQuery("#js"+e+"date").val(),jQuery('input[name="'+e+'date"]').val(t),jQuery("#s2"+e+"date").html(t),r=jQuery("#js"+e+"time").val(),jQuery("[name="+e+"time] option").filter(function(){return this.text===r}).prop("selected",!0).parent().focus(),jQuery("#s2"+e+"time").html(r),s2Hide(e)}jQuery(document).ready(function(){jQuery("#s2bcclimit_2").hide(),jQuery("#s2entries_2").hide(),jQuery("#s2cron_2").hide()});

View File

@ -1,16 +0,0 @@
/* exported getip */
// Version 1.0 - original version
// Version 1.1 - eslinted and fixed for Widget form name change
function getip( json ) {
var ip, i, l;
if ( true === document.body.contains( document.forms.s2form ) || true === document.body.contains( document.forms.s2formwidget ) ) {
ip = document.getElementsByName( 'ip' );
l = ip.length;
for ( i = 0; i < l; i++ ) {
if ( 's2form' === ip[i].parentElement.name ) {
ip[i].value = json.ip;
}
}
}
}

View File

@ -1 +0,0 @@
function getip(e){var n,o,t;if(!0===document.body.contains(document.forms.s2form)||!0===document.body.contains(document.forms.s2formwidget))for(t=(n=document.getElementsByName("ip")).length,o=0;o<t;o++)"s2form"===n[o].parentElement.name&&(n[o].value=e.ip)}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,58 +0,0 @@
/* global s2ScriptStrings */
/* exported s2BulkActionCheck, submitHandler, bmCheck, s2ScriptStrings */
// Version 1.0 - original version
// Version 1.1 - context specific delete warnings for registered or public subscribers
// Version 1.2 - single and plural string confirmation messages
// Version 1.3 - fix suppressed form processing for Toggle action, JavaScript binding only if elements exist & more effecient handling when no users selected
// Version 1.4 - improve Bulk Management user experience and functions
// Version 1.5 - eslinted
function s2BulkActionCheck() {
if ( null !== document.getElementById( 'doaction' ) ) {
document.getElementById( 'doaction' ).onclick = submitHandler;
document.getElementById( 'doaction2' ).onclick = submitHandler;
}
}
function submitHandler() {
var location, action1, action2, agree, selected;
location = document.getElementById( 's2_location' );
action1 = document.getElementById( 'bulk-action-selector-top' );
action2 = document.getElementById( 'bulk-action-selector-bottom' );
agree = false;
selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
if ( 0 === selected ) {
return true;
}
if ( 'delete' === action1.value || 'delete' === action2.value ) {
if ( 'registered' === location.value ) {
if ( 1 < selected ) {
agree = window.confirm( s2ScriptStrings.registered_confirm_plural );
} else {
agree = window.confirm( s2ScriptStrings.registered_confirm_single );
}
} else if ( 'public' === location.value ) {
if ( 1 < selected ) {
agree = window.confirm( s2ScriptStrings.public_confirm_plural );
} else {
agree = window.confirm( s2ScriptStrings.public_confirm_single );
}
}
} else if ( 'toggle' === action1.value || 'toggle' === action2.value ) {
agree = true;
}
return agree;
}
function bmCheck() {
var agree, selected;
agree = false;
selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
if ( 0 === selected ) {
agree = window.confirm( s2ScriptStrings.bulk_manage_all );
} else if ( 1 < selected ) {
agree = window.confirm( s2ScriptStrings.bulk_manage_single );
} else {
agree = window.confirm( s2ScriptStrings.bulk_manage_plural );
}
return agree;
}
window.onload = s2BulkActionCheck;

View File

@ -1 +0,0 @@
function s2BulkActionCheck(){null!==document.getElementById("doaction")&&(document.getElementById("doaction").onclick=submitHandler,document.getElementById("doaction2").onclick=submitHandler)}function submitHandler(){var e,n,t,i,c;return e=document.getElementById("s2_location"),n=document.getElementById("bulk-action-selector-top"),t=document.getElementById("bulk-action-selector-bottom"),i=!1,0===(c=document.querySelectorAll('input[name="subscriber[]"]:checked').length)||("delete"===n.value||"delete"===t.value?"registered"===e.value?i=1<c?window.confirm(s2ScriptStrings.registered_confirm_plural):window.confirm(s2ScriptStrings.registered_confirm_single):"public"===e.value&&(i=1<c?window.confirm(s2ScriptStrings.public_confirm_plural):window.confirm(s2ScriptStrings.public_confirm_single)):"toggle"!==n.value&&"toggle"!==t.value||(i=!0),i)}function bmCheck(){var e;return!1,0===(e=document.querySelectorAll('input[name="subscriber[]"]:checked').length)?window.confirm(s2ScriptStrings.bulk_manage_all):1<e?window.confirm(s2ScriptStrings.bulk_manage_single):window.confirm(s2ScriptStrings.bulk_manage_plural)}window.onload=s2BulkActionCheck;

View File

@ -1,92 +0,0 @@
ul.s2_blogs
{
float: left;
width: 99%;
}
ul.s2_blogs li
{
position: relative;
display: block;
float: left;
width: 47%;
margin: 3px;
padding: .5em;
white-space: nowrap;
border: 1px solid #e0e0e0;
background-color: #e3e3e3;
}
ul.s2_blogs li:hover
{
border-color: #666;
}
ul.s2_blogs li .name
{
display: block;
float: left;
}
ul.s2_blogs li .buttons
{
font-size: .8em;
display: block;
float: right;
margin-left: -6px;
white-space: nowrap;
}
ul.s2_blogs li .buttons a
{
display: block;
float: left;
margin: 0 0 0 1em;
padding: .1em .5em;
color: white;
background-color: #666;
}
ul.s2_blogs li .buttons a:hover
{
color: #666;
background-color: whitesmoke;
}
ul.s2_blogs div.additional_info
{
font-style: italic;
position: absolute;
z-index: 9;
bottom: 2.4em;
left: -2px;
display: none;
width: 75%;
margin-bottom: 2px;
padding: .5em 1em;
color: #fff;
border: 1px solid white;
border-bottom: medium none;
-moz-border-radius-topleft: .5em;
-moz-border-radius-topright: .5em;
background-color: #666;
}
ul.s2_blogs li:hover div.additional_info
{
display: block;
}

View File

@ -1 +0,0 @@
ul.s2_blogs{float:left;width:99%}ul.s2_blogs li{position:relative;display:block;float:left;width:47%;margin:3px;padding:.5em;white-space:nowrap;border:1px solid #e0e0e0;background-color:#e3e3e3}ul.s2_blogs li:hover{border-color:#666}ul.s2_blogs li .name{display:block;float:left}ul.s2_blogs li .buttons{font-size:.8em;display:block;float:right;margin-left:-6px;white-space:nowrap}ul.s2_blogs li .buttons a{display:block;float:left;margin:0 0 0 1em;padding:.1em .5em;color:#fff;background-color:#666}ul.s2_blogs li .buttons a:hover{color:#666;background-color:#f5f5f5}ul.s2_blogs div.additional_info{font-style:italic;position:absolute;z-index:9;bottom:2.4em;left:-2px;display:none;width:75%;margin-bottom:2px;padding:.5em 1em;color:#fff;border:1px solid #fff;border-bottom:medium none;-moz-border-radius-topleft:.5em;-moz-border-radius-topright:.5em;background-color:#666}ul.s2_blogs li:hover div.additional_info{display:block}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

View File

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,98 +0,0 @@
=== Subscribe2 - Form, Email Subscribers & Newsletters ===
Contributors: tareq1988, nizamuddinbabu, wemail
Donate link: https://getwemail.io
Tags: posts, subscription, email, subscribe, notify, notification, newsletter, post notification, email marketing, optin, form
Requires at least: 4.0
Tested up to: 5.8
Stable tag: 10.36
Requires PHP: 5.4
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Sends a list of subscribers an email notification when you publish new posts.
== Description ==
= Summary =
Subscribe2 provides a comprehensive subscription management and email notification system for WordPress blogs that sends email notifications to a list of subscribers when you publish new content to your blog.
A full description of features is below.
= Email =
Email notifications can be sent on a per-post basis or periodically in a Digest email. Additionally, certain categories can be excluded from inclusion in the notification and posts can be excluded on an individual basis by setting a custom field.
= Subscriptions =
Subscription requests allows users to publicly subscribe (**Public Subscribers**) by submitting their email address in an easy to use form or to register with your blog (**Registered Users**) which enables greater flexibility over the email content for per-post notifications for the subscriber. Admins are given control over the presentation of the email notifications, can bulk manage subscriptions for users and manually send email notices to subscribers.
The format of the email can also be customised for per-post notifications, Subscribe2 can generate emails for each of the following formats:
* plaintext excerpt.
* plaintext full post (Registered Users only).
* HTML excerpt (Registered Users only).
* HTML full post (Registered Users only).
If you want to grow your subscriber lists, send automated campaigns to huge subscriber lists, you should upgrade to [weMail](https://getwemail.io).
= Privacy Policy =
Subscribe2 uses [Appsero](https://appsero.com) SDK to collect some telemetry data upon user's confirmation. This helps us to troubleshoot problems faster & make product improvements. Learn more about how [Appsero collects and uses this data](https://appsero.com/privacy-policy/).
== Installation ==
= AUTOMATIC INSTALLATION =
1. Log in to your WordPress blog and visit Plugins -> Add New.
2. Search for Subscribe2, click "Install Now" and then Activate the Plugin
3. Visit the "Subscribe2 -> Settings" menu.
4. Configure the options to taste, including the email template and any categories which should be excluded from notification
5. Visit the "Subscribe2 -> Subscribers" menu.
6. Manually subscribe people as you see fit.
7. Create a [WordPress Page](http://codex.wordpress.org/Pages) to display the subscription form. When creating the page, you may click the "S2" button on the QuickBar to automatically insert the Subscribe2 token. Or, if you prefer, you may manually insert the Subscribe2 shortcode or token: [subscribe2] or the HTML invisible `<!--subscribe2-->` ***Ensure the token is on a line by itself and that it has a blank line above and below.***
This token will automatically be replaced by dynamic subscription information and will display all forms and messages as necessary.
8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
= MANUAL INSTALLATION =
1. Copy the entire /subscribe2/ directory into your /wp-content/plugins/ directory.
2. Activate the plugin.
3. Visit the "Subscribe2 -> Settings" menu.
4. Configure the options to taste, including the email template and any categories which should be excluded from notification
5. Visit the "Subscribe2 -> Subscribers" menu.
6. Manually subscribe people as you see fit.
7. Create a [WordPress Page](http://codex.wordpress.org/Pages) to display the subscription form. When creating the page, you may click the "S2" button on the QuickBar to automatically insert the Subscribe2 token. Or, if you prefer, you may manually insert the Subscribe2 shortcode or token: [subscribe2] or the HTML invisible `<!--subscribe2-->` ***Ensure the token is on a line by itself and that it has a blank line above and below.***
This token will automatically be replaced by dynamic subscription information and will display all forms and messages as necessary.
8. In the WordPress "Settings" area for Subscribe2 select the page name in the "Appearance" section that of the WordPress page created in step 7.
== Frequently Asked Questions ==
[Visit FAQ site](https://subscribe2.wordpress.com/support/faqs/)
== Changelog ==
= 10.36 (30th September, 2021) =
* WordPress 5.8 compatibility
* Fix form preview on widgets
* Fix pop up form
* Fix send schedule email options
* Fix one click subscription
* Fix some PHP warnings
= 10.35 (15th March, 2021) =
* Fix {UNSUBLINK} shortcode
* WordPress 5.7 compatibility
= 10.34 (24th August, 2020) =
* Fix gutenberg script loading issue
= 10.33 (4th June, 2020) =
* Bump tested upto version 4.4
* Minimum PHP version set to 5.4
See complete [changelog](https://github.com/weMail/Subscribe2/blob/develop/changelog.txt).

View File

@ -1,98 +0,0 @@
<?php
/*
Plugin Name: Subscribe2
Plugin URI: https://getwemail.io
Description: Notifies an email list when new entries are posted.
Version: 10.36
Author: weMail
Author URI: https://getwemail.io
Licence: GPLv3
Text Domain: subscribe2
*/
/*
Copyright (C) 2020 weDevs (info@getwemail.io)
Based on the Original Subscribe2 plugin by
Copyright (C) 2005 Scott Merrill (skippy@skippy.net)
This file is part of Subscribe2.
Subscribe2 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Subscribe2 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Subscribe2. If not, see <http://www.gnu.org/licenses/>.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.4', '<' ) || ! function_exists( 'add_action' ) ) {
if ( ! function_exists( 'add_action' ) ) {
$exit_msg = __( "I'm just a plugin, please don't call me directly", 'subscribe2' );
} else {
// Translators: Subscribe2 needs WordPress 4.4 or above, exit if not on a compatible version
$exit_msg = sprintf( __( 'This version of Subscribe2 requires WordPress 4.4 or greater. Please update %1$s or use an older version of %2$s.', 'subscribe2' ), '<a href="http://codex.wordpress.org/Updating_WordPress">WordPress</a>', '<a href="https://subscribe2.wordpress.com/subscribe2-html/">Subscribe2</a>' );
}
exit( esc_html( $exit_msg ) );
}
// stop Subscribe2 being activated site wide on Multisite installs
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
$exit_msg = __( 'Subscribe2 HTML cannot be activated as a network plugin. Please activate it on a site level', 'subscribe2' );
exit( esc_html( $exit_msg ) );
}
// our version number. Don't touch this or any line below
// unless you know exactly what you are doing
define( 'S2VERSION', '10.36' );
define( 'S2PLUGIN', __FILE__ );
define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
define( 'S2URL', plugin_dir_url( dirname( __FILE__ ) ) . S2DIR );
// Set maximum execution time to 5 minutes
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 300 );
}
global $mysubscribe2;
require_once S2PATH . 'classes/class-s2-core.php';
if ( is_admin() ) {
require_once S2PATH . 'classes/class-s2-admin.php';
$mysubscribe2 = new S2_Admin();
} else {
require_once S2PATH . 'classes/class-s2-frontend.php';
$mysubscribe2 = new S2_Frontend();
}
add_action( 'plugins_loaded', array( $mysubscribe2, 's2init' ) );
/**
* Initialize the plugin tracker
*
* @return void
*/
function subscribe2_init_appsero() {
if ( ! class_exists( 'Appsero\Client' ) ) {
require_once S2PATH . 'include/appsero/src/Client.php';
}
$client = new Appsero\Client( '6c1e710d-aab6-4d4b-b29d-aad2ff773f4c', 'Subscribe2', __FILE__ );
$client->insights()->init();
}
subscribe2_init_appsero();

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
.mceSubscribe2
{
display: block;
width: 100%;
height: 12px;
margin-top: 15px;
border: 0;
border-top: 1px;
background: url(../../include/s2-marker.png) center top no-repeat #fff;
}

View File

@ -1,108 +0,0 @@
/* global tinymce */
( function() {
tinymce.create(
'tinymce.plugins.Subscribe2Plugin',
{
init: function( ed, url ) {
var i = 0,
pb = '<p><img src="' + url + '/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',
cls = 'mceSubscribe2',
shortcode = '[subscribe2]',
pbreplaced = [],
pbreplacedcount,
pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
replacer = function( str ) {
if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
str = pbreplaced[i];
}
return str;
};
// Register commands
ed.addCommand(
'mceSubscribe2',
function() {
ed.execCommand( 'mceInsertContent', 0, pb );
}
);
// Register buttons
ed.addButton(
'subscribe2',
{
title: 'Insert Subscribe2 Token',
image: url + '/../include/s2-button.png',
cmd: cls
}
);
// load the CSS and enable it on the right class
ed.on(
'init',
function() {
ed.dom.loadCSS( url + '/css/content.css' );
if ( ed.theme.onResolveName ) {
ed.theme.onResolveName.add(
function( th, o ) {
if ( 'IMG' === o.node.nodeName && ed.dom.hasClass( o.node, cls ) ) {
o.name = 'subscribe2';
}
}
);
}
}
);
// create an array of replaced shortcodes so we have additional parameters
// then swap in the graphic
ed.on(
'BeforeSetContent',
function( ed ) {
pbreplaced = ed.content.match( pbRE );
ed.content = ed.content.replace( pbRE, pb );
}
);
// swap back the array of shortcodes to preserve parameters
// replace any other instances with the default shortcode
ed.on(
'PostProcess',
function( ed ) {
if ( ed.get ) {
if ( null !== pbreplaced ) {
pbreplacedcount = pbreplaced.length;
for ( i = 0; i < pbreplacedcount; i++ ) {
ed.content = ed.content.replace( /<img[^>]+>/, replacer );
}
}
ed.content = ed.content.replace(
/<img[^>]+>/g,
function( im ) {
if ( -1 !== im.indexOf( 'class="mceSubscribe2' ) ) {
im = shortcode;
}
return im;
}
);
}
}
);
},
getInfo: function() {
return {
longname: 'Insert Subscribe2 Token',
author: 'Matthew Robinson',
authorurl: 'http://subscribe2.wordpress.com',
infourl: 'http://subscribe2.wordpress.com',
version: tinymce.majorVersion + '.' + tinymce.minorVersion
};
}
}
);
// Register plugin
tinymce.PluginManager.add( 'subscribe2', tinymce.plugins.Subscribe2Plugin );
}() );

View File

@ -1 +0,0 @@
tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t,c=0,i='<p><img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',o="mceSubscribe2",s=[],r=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),u=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=s[c]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,i)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:o}),e.on("init",function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,o)&&(t.name="subscribe2")})}),e.on("BeforeSetContent",function(e){s=e.content.match(r),e.content=e.content.replace(r,i)}),e.on("PostProcess",function(e){if(e.get){if(null!==s)for(t=s.length,c=0;c<t;c++)e.content=e.content.replace(/<img[^>]+>/,u);e.content=e.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin);

View File

@ -1,221 +0,0 @@
<?php
trait Shortcode {
/* ===== template and filter functions ===== */
/**
* Display our form; also handles (un)subscribe requests
*/
public function widget_shortcode( $atts ) {
$args = shortcode_atts(
array(
'hide' => '',
'id' => '',
'nojs' => 'false',
'noantispam' => 'false',
'link' => '',
'size' => 20,
'wrap' => 'true',
'widget' => 'false',
),
$atts
);
// if link is true return a link to the page with the ajax class
if ( '1' === $this->subscribe2_options['ajax'] && '' !== $args['link'] && ! is_user_logged_in() ) {
$id = '';
foreach ( $args as $arg_name => $arg_value ) {
if ( ! empty( $arg_value ) && 'link' !== $arg_name && 'id' !== $arg_name ) {
if ( 'nojs' === $arg_name ) {
$arg_value = 'true';
}
( '' === $id ) ? $id .= $arg_name . '-' . $arg_value : $id .= ':' . $arg_name . '-' . $arg_value;
}
}
$this->s2form = '<a href="#" class="s2popup" id="' . esc_attr( $id ) . '">' . esc_html( $args['link'] ) . '</a>' . "\r\n";
return $this->s2form;
}
// Apply filters to button text
$unsubscribe_button_value = apply_filters( 's2_unsubscribe_button', __( 'Unsubscribe', 'subscribe2' ) );
$subscribe_button_value = apply_filters( 's2_subscribe_button', __( 'Subscribe', 'subscribe2' ) );
// if a button is hidden, show only other
$hide = strtolower( $args['hide'] );
if ( 'subscribe' === $hide ) {
$this->input_form_action = '<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
} elseif ( 'unsubscribe' === $hide ) {
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />';
} else {
// both form input actions
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />&nbsp;<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
}
// if ID is provided, get permalink
$action = '';
if ( is_numeric( $args['id'] ) ) {
$action = ' action="' . get_permalink( $args['id'] ) . '"';
} elseif ( 'home' === $args['id'] ) {
$action = ' action="' . get_site_url() . '"';
} elseif ( 'self' === $args['id'] ) {
// Correct for Static front page redirect behaviour
if ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) {
$post = get_post( get_option( 'page_on_front' ) );
$action = ' action="' . get_option( 'home' ) . '/' . $post->post_name . '/"';
} else {
$action = '';
}
} elseif ( $this->subscribe2_options['s2page'] > 0 ) {
$action = ' action="' . get_permalink( $this->subscribe2_options['s2page'] ) . '"';
}
// allow remote setting of email in form
if ( isset( $_REQUEST['email'] ) ) {
$email = $this->sanitize_email( $_REQUEST['email'] );
}
if ( isset( $_REQUEST['email'] ) && false !== $this->validate_email( $email ) ) {
$value = $email;
} elseif ( 'true' === strtolower( $args['nojs'] ) ) {
$value = '';
} else {
$value = __( 'Enter email address...', 'subscribe2' );
}
// if wrap is true add paragraph html tags
$wrap_text = '';
if ( 'true' === strtolower( $args['wrap'] ) ) {
$wrap_text = '</p><p>';
}
// deploy some anti-spam measures
$antispam_text = '';
if ( 'true' !== strtolower( $args['noantispam'] ) ) {
$antispam_text = '<span style="display:none !important">';
$antispam_text .= '<label for="firstname">Leave This Blank:</label><input type="text" id="firstname" name="firstname" />';
$antispam_text .= '<label for="lastname">Leave This Blank Too:</label><input type="text" id="lastname" name="lastname" />';
$antispam_text .= '<label for="uri">Do Not Change This:</label><input type="text" id="uri" name="uri" value="http://" />';
$antispam_text .= '</span>';
}
// get remote IP address
$remote_ip = $this->get_remote_ip();
// form name
if ( 'true' === $args['widget'] ) {
$form_name = 's2formwidget';
} else {
$form_name = 's2form';
}
// build default form
if ( 'true' === strtolower( $args['nojs'] ) ) {
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" />' . $wrap_text . $this->input_form_action . '</p></form>';
} else {
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" onfocus="if (this.value === \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value === \'\') {this.value = \'' . $value . '\';}" />' . $wrap_text . $this->input_form_action . '</p></form>' . "\r\n";
}
$this->s2form = apply_filters( 's2_form', $this->form, $args );
if ( isset( $_POST['subscribe'] ) || isset( $_POST['unsubscribe'] ) ) {
// anti spam sign up measure
if ( ( isset( $_POST['firstname'] ) && '' !== $_POST['firstname'] ) || ( isset( $_POST['lastname'] ) && '' !== $_POST['lastname'] ) || ( isset( $_POST['uri'] ) && 'http://' !== $_POST['uri'] ) ) {
// looks like some invisible-to-user fields were changed; falsely report success
return $this->confirmation_sent;
}
$validation = apply_filters( 's2_form_submission', true );
if ( true !== $validation ) {
return apply_filters( 's2_form_failed_validation', $this->s2form );
}
global $wpdb;
$this->email = $this->sanitize_email( $_POST['email'] );
if ( false === $this->validate_email( $this->email ) ) {
$this->s2form = $this->s2form . $this->not_an_email;
} elseif ( $this->is_barred( $this->email ) ) {
$this->s2form = $this->s2form . $this->barred_domain;
} else {
$this->ip = $_POST['ip'];
if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
$date = gmdate( 'H:i:s.u', $this->lockout );
$ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
if ( in_array( $this->ip, $ips, true ) ) {
return __( 'Slow down, you move too fast.', 'subscribe2' );
}
}
// does the supplied email belong to a registered user?
$check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $this->email ) );
if ( null !== $check ) {
// this is a registered email
$this->s2form = $this->please_log_in;
} else {
// this is not a registered email
// what should we do?
if ( isset( $_POST['subscribe'] ) ) {
// someone is trying to subscribe
// lets see if they've tried to subscribe previously
if ( '1' !== $this->is_public( $this->email ) ) {
// the user is unknown or inactive
$this->add( $this->email );
$status = $this->send_confirm( 'add' );
// set a variable to denote that we've already run, and shouldn't run again
$this->filtered = 1;
if ( $status ) {
$this->s2form = $this->confirmation_sent;
} else {
$this->s2form = $this->error;
}
} else {
// they're already subscribed
$this->s2form = $this->already_subscribed;
}
$this->action = 'subscribe';
} elseif ( isset( $_POST['unsubscribe'] ) ) {
// is this email a subscriber?
if ( false === $this->is_public( $this->email ) ) {
$this->s2form = $this->s2form . $this->not_subscribed;
} else {
$status = $this->send_confirm( 'del' );
// set a variable to denote that we've already run, and shouldn't run again
$this->filtered = 1;
if ( $status ) {
$this->s2form = $this->confirmation_sent;
} else {
$this->s2form = $this->error;
}
}
$this->action = 'unsubscribe';
}
}
}
}
return $this->s2form;
}
/**
* Collect and return the IP address of the remote client machine
*/
public function get_remote_ip() {
$remote_ip = false;
// In order of preference, with the best ones for this purpose first
$address_headers = array(
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'REMOTE_ADDR',
);
foreach ( $address_headers as $header ) {
if ( array_key_exists( $header, $_SERVER ) ) {
// HTTP_X_FORWARDED_FOR can contain a chain of comma-separated
// addresses. The first one is the original client. It can't be
// trusted for authenticity, but we don't need to for this purpose.
$address_chain = explode( ',', $_SERVER[ $header ] );
$remote_ip = trim( $address_chain[0] );
break;
}
}
return $remote_ip;
}
}

View File

@ -1,51 +0,0 @@
<?php
if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
// Make sure not to call this file directly
exit();
} else {
// Is Subscribe2 HTML active
if ( is_plugin_active( 'subscribe2_html/subscribe2.php' ) ) {
return;
}
// Is this WordPressMU or not?
if ( isset( $wpmu_version ) || strpos( $wp_version, 'wordpress-mu' ) ) {
$s2_mu = true;
}
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
$s2_mu = true;
}
if ( $s2_mu ) {
global $wpdb;
$blogs = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
foreach ( $blogs as $blog ) {
switch_to_blog( $blog );
s2_uninstall();
restore_current_blog();
}
} else {
s2_uninstall();
}
}
function s2_uninstall() {
global $wpdb;
// delete entry from wp_options table
delete_option( 'subscribe2_options' );
// delete legacy entry from wp-options table
delete_option( 's2_future_posts' );
// remove and scheduled events
wp_clear_scheduled_hook( 's2_digest_cron' );
// delete usermeta data for registered users
// use LIKE and % wildcard as meta_key names are prepended on WPMU
// and s2_cat is appended with category ID integer
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_cat%'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_subscribed'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_format'" );
$wpdb->query( "DELETE from $wpdb->usermeta WHERE meta_key LIKE '%s2_autosub'" );
// delete any postmeta data that supressed notifications
$wpdb->query( "DELETE from $wpdb->postmeta WHERE meta_key = 's2mail'" );
// drop the subscribe2 table
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe2" );
}