' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '

' ); } if ( isset( $_POST['reset'] ) ) { require_once S2PATH . 'classes/class-s2-upgrade.php'; global $s2_upgrade; $s2_upgrade = new S2_Upgrade(); $s2_upgrade->reset(); echo '

' . esc_html__( 'Options reset!', 'subscribe2' ) . '

'; } 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 '

' . esc_html__( 'Preview message(s) sent to logged in user', 'subscribe2' ) . '

'; } 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 '

' . esc_html__( 'Attempt made to resend the Digest Notification email', 'subscribe2' ) . '

'; } else { echo '

' . esc_html__( 'The Digest Notification email contained no post information. No email was sent', 'subscribe2' ) . '

'; } } 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 '

' . esc_html__( 'Options saved!', 'subscribe2' ) . '

'; 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 '

' . esc_html__( 'You must create a WordPress page for this plugin to work correctly.', 'subscribe2' ) . '

'; } // 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 '

' . esc_html__( 'Your Settings may breach GDPR', 'subscribe2' ) . '

'; } } 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 = '' . __( 'Modify your template', 'subscribe2' ) . ''; if ( false !== $disallowed ) { $disallowed_keywords = __( 'Your chosen email type (per-post or digest) does not support the following keywords:', 'subscribe2' ); echo '

' . esc_html( $disallowed_keywords ) . '
' . esc_html( implode( ', ', $disallowed ) ) . '
' . wp_kses_post( $template_link ) . '

'; } // 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( '

' . 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'] ) . '

' ); } // detect or define which tab we are in $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'email'; // show our form echo '
'; echo '

' . esc_html__( 'Settings', 'subscribe2' ) . '

' . "\r\n"; $s2tabs = array( 'email' => __( 'Email Settings', 'subscribe2' ), 'templates' => __( 'Templates', 'subscribe2' ), 'registered' => __( 'Registered Users', 'subscribe2' ), 'appearance' => __( 'Appearance', 'subscribe2' ), 'misc' => __( 'Miscellaneous', 'subscribe2' ), ); echo ''; echo '
' . "\r\n"; wp_nonce_field( 'subscribe2-options_subscribers' . S2VERSION ); echo '' . "\r\n"; echo ''; switch ( $current_tab ) { case 'email': // settings for outgoing emails echo '
' . "\r\n"; echo '

' . "\r\n"; echo wp_kses_post( 'Restrict the number of recipients per email to (0 for unlimited)', 'subscribe2' ) . ': '; echo '' . esc_html( $this->subscribe2_options['bcclimit'] ) . ' '; echo '' . esc_html__( 'Edit', 'subscribe2' ) . '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; echo '' . esc_html__( 'Update', 'subscribe2' ) . '' . "\r\n"; echo '' . esc_html__( 'Revert', 'subscribe2' ) . '' . "\n"; echo '

' . esc_html__( 'Send Admins notifications for new', 'subscribe2' ) . ': '; echo '  '; echo '  '; echo '  '; echo '

' . "\r\n"; echo esc_html__( 'Include theme CSS stylesheet in HTML notifications', 'subscribe2' ) . ': '; echo '  '; echo '

' . "\r\n"; echo esc_html__( 'Send Emails for Pages', 'subscribe2' ) . ': '; echo '  '; echo '

' . "\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 '' . esc_html( implode( ', ', $s2_post_types ) ) . '

' . "\r\n"; } } echo esc_html__( 'Send Emails for Password Protected Posts', 'subscribe2' ) . ': '; echo '  '; echo '

' . "\r\n"; echo esc_html__( 'Send Emails for Private Posts', 'subscribe2' ) . ': '; echo '  '; echo '

' . "\r\n"; if ( 'never' !== $this->subscribe2_options['email_freq'] ) { echo esc_html__( 'Include Sticky Posts at the top of all Digest Notifications', 'subscribe2' ) . ': '; echo '  '; echo '

' . "\r\n"; } echo esc_html__( 'Send Email From', 'subscribe2' ) . ': '; echo '

' . "\r\n"; if ( function_exists( 'wp_schedule_event' ) ) { echo esc_html__( 'Send Emails', 'subscribe2' ) . ':
' . "\r\n"; $this->display_digest_choices(); } if ( 'never' !== $this->subscribe2_options['email_freq'] ) { echo '

' . esc_html__( 'For digest notifications, date order for posts is', 'subscribe2' ) . ': ' . "\r\n"; echo '  '; echo '

' . "\r\n"; } echo esc_html__( 'Add Tracking Parameters to the Permalink', 'subscribe2' ) . ': '; echo ' '; echo '
' . esc_html__( 'eg. utm_source=subscribe2&utm_medium=email&utm_campaign=postnotify&utm_id={ID}&utm_title={TITLE}', 'subscribe2' ) . "\r\n"; echo '

' . "\r\n"; echo '
' . "\r\n"; break; case 'templates': // email templates echo '
' . "\r\n"; echo '

' . "\r\n"; echo '' . "\r\n"; echo '
'; echo esc_html__( 'Notification email (must not be empty)', 'subscribe2' ) . ':
' . "\r\n"; echo esc_html__( 'Subject Line', 'subscribe2' ) . ': '; echo ''; echo '
' . "\r\n"; echo '' . "\r\n"; echo '
'; echo '

' . "\r\n"; echo '

' . esc_html__( 'Message substitutions', 'subscribe2' ) . '

' . "\r\n"; echo '
'; echo '
' . esc_html__( 'IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED', 'subscribe2' ) . '
' . "\r\n"; echo '
{BLOGNAME}
' . esc_html( get_option( 'blogname' ) ) . '
' . "\r\n"; echo '
{BLOGLINK}
' . esc_html( get_option( 'home' ) ) . '
' . "\r\n"; echo '
{TITLE}
' . wp_kses_post( __( "the post's title
(for per-post emails only)", 'subscribe2' ) ) . '
' . "\r\n"; echo '
{TITLETEXT}
' . wp_kses_post( __( "the post's unformatted title
(for per-post emails only)", 'subscribe2' ) ) . '
' . "\r\n"; echo '
{POST}
' . wp_kses_post( __( "the excerpt or the entire post
(based on the subscriber's preferences)", 'subscribe2' ) ) . '
' . "\r\n"; echo '
{POSTTIME}
' . wp_kses_post( __( 'the excerpt of the post and the time it was posted
(for digest emails only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{TABLE}
' . wp_kses_post( __( 'a list of post titles
(for digest emails only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{TABLELINKS}
' . wp_kses_post( __( 'a list of post titles followed by links to the articles
(for digest emails only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{REFERENCELINKS}
' . wp_kses_post( __( 'a reference style list of links at the end of the email with corresponding numbers in the content
(for the full content plain text per-post email only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{PERMALINK}
' . wp_kses_post( __( "the post's permalink
(for per-post emails only)", 'subscribe2' ) ) . '
' . "\r\n"; echo '
{TINYLINK}
' . esc_html__( "the post's permalink after conversion by TinyURL", 'subscribe2' ) . '
' . "\r\n"; echo '
{PERMAURL}
' . wp_kses_post( __( "the post's unformatted permalink
(for per-post emails only)", 'subscribe2' ) ) . '
' . "\r\n"; echo '
{DATE}
' . wp_kses_post( __( 'the date the post was made
(for per-post emails only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{TIME}
' . wp_kses_post( __( 'the time the post was made
(for per-post emails only)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{MYNAME}
' . esc_html__( "the admin or post author's name", 'subscribe2' ) . '
' . "\r\n"; echo '
{EMAIL}
' . esc_html__( "the admin or post author's email", 'subscribe2' ) . '
' . "\r\n"; echo '
{AUTHORNAME}
' . esc_html__( "the post author's name", 'subscribe2' ) . '
' . "\r\n"; echo '
{LINK}
' . wp_kses_post( __( 'the generated link to confirm a request
(only used in the confirmation email template)', 'subscribe2' ) ) . '
' . "\r\n"; if ( 1 === $this->subscribe2_options['bcclimit'] ) { echo '
{UNSUBLINK}
' . wp_kses_post( __( 'a generated unsubscribe link
(only used in the email notification template)', 'subscribe2' ) ) . '
' . "\r\n"; } echo '
{ACTION}
' . wp_kses_post( __( 'Action performed by LINK in confirmation email
(only used in the confirmation email template)', 'subscribe2' ) ) . '
' . "\r\n"; echo '
{CATS}
' . esc_html__( "the post's assigned categories", 'subscribe2' ) . '
' . "\r\n"; echo '
{TAGS}
' . esc_html__( "the post's assigned Tags", 'subscribe2' ) . '
' . "\r\n"; echo '
{COUNT}
' . wp_kses_post( __( 'the number of posts included in the digest email
(for digest emails only)', 'subscribe2' ) ) . '
' . "\r\n"; if ( current_theme_supports( 'post-thumbnails' ) ) { echo '
{IMAGE}
' . esc_html__( "the post's featured image", 'subscribe2' ) . '
' . "\r\n"; } echo '
'; echo esc_html__( 'Subscribe / Unsubscribe confirmation email', 'subscribe2' ) . ':
' . "\r\n"; echo esc_html__( 'Subject Line', 'subscribe2' ) . ': '; echo '
' . "\r\n"; echo '' . "\r\n"; echo '
'; echo esc_html__( 'Reminder email to Unconfirmed Subscribers', 'subscribe2' ) . ':
' . "\r\n"; echo esc_html__( 'Subject Line', 'subscribe2' ) . ': '; echo '
' . "\r\n"; echo '

' . "\r\n"; echo '
' . "\r\n"; echo '

' . "\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 '
' . "\r\n"; echo '' . "\r\n"; echo '

' . esc_html__( 'Compulsory Categories', 'subscribe2' ) . '

' . "\r\n"; echo '

' . "\r\n"; echo '' . esc_html__( 'Compulsory categories will be checked by default for Registered Subscribers', 'subscribe2' ) . '
' . "\r\n"; echo '

'; $s2_forms->display_category_form( explode( ',', $this->subscribe2_options['compulsory'] ), 1, array(), 'compulsory' ); echo "
\r\n"; // excluded categories echo '
' . "\r\n"; echo '

' . esc_html__( 'Excluded Categories', 'subscribe2' ) . '

' . "\r\n"; echo '

'; echo '' . esc_html__( 'Posts assigned to any Excluded Category do not generate notifications and are not included in digest notifications', 'subscribe2' ) . '
' . "\r\n"; echo '

'; $s2_forms->display_category_form( explode( ',', $this->subscribe2_options['exclude'] ), 1, array(), 'exclude' ); echo '

' . "\r\n"; echo '
' . "\r\n"; // excluded post formats $formats = get_theme_support( 'post-formats' ); if ( false !== $formats ) { // excluded formats echo '
' . "\r\n"; echo '

' . esc_html__( 'Excluded Formats', 'subscribe2' ) . '

' . "\r\n"; echo '

'; echo '' . esc_html__( 'Posts assigned to any Excluded Format do not generate notifications and are not included in digest notifications', 'subscribe2' ) . '
' . "\r\n"; echo '

'; $this->display_format_form( $formats, explode( ',', $this->subscribe2_options['exclude_formats'] ) ); echo '
' . "\r\n"; } //Auto Subscription for new registrations echo '
' . "\r\n"; echo '

' . esc_html__( 'Auto-Subscribe', 'subscribe2' ) . '

' . "\r\n"; echo '

' . "\r\n"; echo esc_html__( 'Subscribe new users registering with your blog', 'subscribe2' ) . ':
' . "\r\n"; if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['autosub'] ) || ( false === S2GDPR ) ) ) { echo '  '; } echo '  '; echo '

' . "\r\n"; echo esc_html__( 'Auto-subscribe includes any excluded categories', 'subscribe2' ) . ':
' . "\r\n"; echo '  '; echo '

' . "\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' ) . ':
' . "\r\n"; echo '  '; echo '

' . "\r\n"; } echo esc_html__( 'Auto-subscribe users to receive email as', 'subscribe2' ) . ':
' . "\r\n"; echo '  '; echo '  '; echo '  '; echo '

'; echo esc_html__( 'Registered Users have the option to auto-subscribe to new categories', 'subscribe2' ) . ':
' . "\r\n"; echo '  '; echo '  '; echo '

'; 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' ) . ':
' . "\r\n"; echo '  '; echo '

'; } // 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' ) . ':
' . "\r\n"; echo '  '; echo '  '; echo '

'; if ( defined( 'S2GDPR' ) && ( ( true === S2GDPR && 'yes' === $this->subscribe2_options['comment_def'] ) || ( false === S2GDPR ) ) ) { echo esc_html__( 'Comment form checkbox is checked by default', 'subscribe2' ) . ':
' . "\r\n"; echo '  '; echo '

' . "\r\n"; } } echo esc_html__( 'Show one-click subscription on profile page', 'subscribe2' ) . ':
' . "\r\n"; echo '  '; echo '' . "\r\n"; echo '

' . "\r\n"; break; case 'appearance': // Appearance options echo '
' . "\r\n"; echo '' . "\r\n"; echo '

' . "\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 "

"; 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 '



' . "\r\n"; // show QuickTag button echo '

' . "\r\n"; // enable popup style form echo '

' . "\r\n"; // show Widget echo '

' . "\r\n"; // show Counter Widget echo '

' . "\r\n"; // s2_meta checked by default echo '

' . "\r\n"; // Subscription form for Registered Users on Frontend echo '' . "\r\n"; echo '

'; echo '
' . "\r\n"; break; case 'misc': //barred domains echo '
' . "\r\n"; echo '

' . esc_html__( 'Barred Domains', 'subscribe2' ) . '

' . "\r\n"; echo '

' . "\r\n"; echo esc_html__( 'Enter domains to bar for public subscriptions, wildcards (*) and exceptions (!) are allowed', 'subscribe2' ) . '
' . "\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" . '
'; echo '

'; echo '

' . esc_html__( 'Links', 'subscribe2' ) . '

' . "\r\n"; echo '' . esc_html__( 'Plugin Site', 'subscribe2' ) . '
'; echo '' . esc_html__( 'Plugin Forum', 'subscribe2' ) . '
'; echo '' . esc_html__( 'Plugin Blog', 'subscribe2' ) . '
'; echo '
' . "\r\n"; break; } // submit echo '

'; if ( 'misc' === $current_tab ) { // reset echo '

' . esc_html__( 'Reset to Default Settings', 'subscribe2' ) . '

' . "\r\n"; echo '

' . esc_html__( 'Use this to reset all options to their defaults. This will not modify your list of subscribers.', 'subscribe2' ) . '

' . "\r\n"; echo '

'; echo '

'; } echo '
' . "\r\n"; require ABSPATH . 'wp-admin/admin-footer.php'; // just to be sure die;