subscribe2_options['email_freq'] ) { $screen->add_help_tab( array( 'id' => 's2-user-help1', 'title' => __( 'Overview', 'subscribe2' ), 'content' => '
' . __( 'From this page you can opt in or out of receiving a periodical digest style email of blog posts.', 'subscribe2' ) . '
', ) ); } else { $screen->add_help_tab( array( 'id' => 's2-user-help1', 'title' => __( 'Overview', 'subscribe2' ), 'content' => '' . __( 'From this page you can control your subscription preferences. Choose the email format you wish to receive, which categories you would like to receive notification for and depending on the site settings which authors you would like to read.', 'subscribe2' ) . '
', ) ); } } public function subscribers_help() { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 's2-subscribers-help1', 'title' => __( 'Overview', 'subscribe2' ), 'content' => '' . __( 'From this page you can manage your subscribers.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-subscribers-help2', 'title' => __( 'Public Subscribers', 'subscribe2' ), 'content' => '' . __( 'Public Subscribers are subscribers who have used the plugin form and only provided their email address.', 'subscribe2' ) . '
' . __( 'On this page public subscribers can be viewed, searched, deleted and also toggled between Confirmed and Unconfirmed status.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-subscribers-help3', 'title' => __( 'Registered Subscribers', 'subscribe2' ), 'content' => '' . __( 'Registered Subscribers are subscribers who have registered in WordPress and have a username and password.', 'subscribe2' ) . '
' . __( 'Registered Subscribers have greater personal control over their subscription. They can change the format of the email and also select which categories and authors they want to receive notifications about.', 'subscribe2' ) . '
' . __( 'On this page registered subscribers can be viewed and searched. User accounts can be deleted from here with any posts created by those users being assigned to the currently logged in user. Bulk changes can be applied to all user settings changing their subscription email format and categories.', 'subscribe2' ) . '
', ) ); } public function subscribers_options() { $option = 'per_page'; $args = array( 'label' => __( 'Number of subscribers per page: ', 'subscribe2' ), 'default' => 25, 'option' => 'subscribers_per_page', ); add_screen_option( $option, $args ); } public function subscribers_set_screen_option( $status, $option, $value ) { if ( 'subscribers_per_page' === $option && false === $status ) { if ( $value < 1 || $value > 999 ) { return; } return $value; } } public function settings_help() { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 's2-settings-help1', 'title' => __( 'Overview', 'subscribe2' ), 'content' => '' . __( 'From this page you can adjust the Settings for Subscribe2.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-settings-help2', 'title' => __( 'Email Settings', 'subscribe2' ), 'content' => '' . __( 'This section allows you to specify settings that apply to the emails generated by the site.', 'subscribe2' ) . '
' . __( 'Emails can be sent to individual subscribers by setting the number of recipients per email to 1. A setting greater than one will group recipients together and make use of the BCC emails header. A setting of 0 sends a single email with all subscribers in one large BCC group. A setting of 1 looks less like spam email to filters but takes longer to process.', 'subscribe2' ) . '
' . __( 'This section is also where the sender of the email on this page is chosen. You can choose Post Author or your Blogname but it is recommended to create a user account with an email address that really exists and shares the same domain name as your site (the bit after the @ should be the same as your sites web address) and then use this account.', 'subscribe2' ) . '
' . __( 'This page also configures the frequency of emails. This can be at the time new posts are made (per post) or periodically with an excerpt of each post made (digest). Additionally the post types (pages, private, password protected) can also be configured here.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-settings-help3', 'title' => __( 'Templates', 'subscribe2' ), 'content' => '' . __( 'This section allows you to customise the content of your notification emails.', 'subscribe2' ) . '
' . __( 'There are special {KEYWORDS} that are used by Subscribe2 to place content into the final email. The template also accepts regular text and HTML as desired in the final emails.', 'subscribe2' ) . '
' . __( 'The {KEYWORDS} are listed on the right of the templates, note that some are for per post emails only and some are for digest emails only. Make sure the correct keywords are used based upon the Email Settings.', 'subscribe2' ) . '
' . __( 'The Notification Email template is used for sending notifications of new posts. The Subscribe / Unsubscribe confirmation template is sent when a new subscription or unsubscription request is made. The Reminder template is used to send reminder emails; this is done automatically or can be done manually.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-settings-help4', 'title' => __( 'Registered Users', 'subscribe2' ), 'content' => '' . __( 'This section allows settings that apply to Registered Subscribers to be configured.', 'subscribe2' ) . '
' . __( 'Categories can be made compulsory so emails are always sent to Public and Registered Subscribers for posts in these categories. They can also be excluded so that emails are not generated for Subscribers. Registered Subscribers can be allowed to bypass category exclusions. Excluded categories take precedence over Compulsory categories.', 'subscribe2' ) . '
' . __( 'A set of default settings for new users can also be specified using the Auto Subscribe section. Settings specified here will be applied to any newly created user accounts while Subscribe2 is activated.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-settings-help5', 'title' => __( 'Appearance', 'subscribe2' ), 'content' => '' . __( 'This section allows you to enable several aspect of the plugin such as Widgets and editor buttons.', 'subscribe2' ) . '
' . __( 'AJAX mode can be enabled that is intended to work with the shortcode link parameter so that a dialog opens in the centre of the browser rather then using the regular form.', 'subscribe2' ) . '
' . __( 'The email over ride check box can be set to be automatically checked for every new post and page from here to, this may be useful if you will only want to send very occasional notifications for specific posts. You can then uncheck this box just before you publish your content.', 'subscribe2' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 's2-settings-help7', 'title' => __( 'Miscellaneous', 'subscribe2' ), 'content' => '' . __( 'This section contains a place to bar specified domains from becoming Public Subscribers and links to help and support pages.', 'subscribe2' ) . '
', ) ); } public function mail_help() { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 's2-send-mail-help1', 'title' => __( 'Overview', 'subscribe2' ), 'content' => '' . __( 'From this page you can send emails to the recipients in the group selected in the drop down.', 'subscribe2' ) . '
' . __( 'Preview will send a preview of the email to the currently logged in user. Send will send the email to the recipient list.', 'subscribe2' ) . '
', ) ); } /** * Hook for Admin Drop Down Icons */ public function ozh_s2_icon() { return S2URL . 'include/email-edit.png'; } /** * Insert Javascript and CSS into admin_headers */ public function checkbox_form_js() { wp_register_script( 's2_checkbox', S2URL . 'include/s2-checkbox' . $this->script_debug . '.js', array( 'jquery' ), '1.4', true ); wp_enqueue_script( 's2_checkbox' ); } public function user_admin_css() { wp_register_style( 's2_user_admin', S2URL . 'include/s2-user-admin' . $this->script_debug . '.css', array(), '1.0' ); wp_enqueue_style( 's2_user_admin' ); } public function option_form_js() { wp_register_script( 's2_edit', S2URL . 'include/s2-edit' . $this->script_debug . '.js', array( 'jquery' ), '1.3', true ); wp_enqueue_script( 's2_edit' ); if ( 'never' !== $this->subscribe2_options['email_freq'] ) { wp_enqueue_script( 'jquery-ui-datepicker' ); wp_enqueue_style( 'jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css', array(), '1.12.1' ); wp_register_script( 's2_date_time', S2URL . 'include/s2-date-time' . $this->script_debug . '.js', array( 'jquery-ui-datepicker' ), '1.1', true ); wp_enqueue_script( 's2_date_time' ); } } public function dismiss_js() { wp_register_script( 's2_dismiss', S2URL . 'include/s2-dismiss' . $this->script_debug . '.js', array( 'jquery' ), '1.1', true ); $translation_array = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 's2_dismiss_nonce' ), ); wp_localize_script( 's2_dismiss', 's2DismissScriptStrings', $translation_array ); wp_enqueue_script( 's2_dismiss' ); } public function s2_dismiss_notice_handler() { if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 's2_dismiss_nonce' ) ) { return false; } $this->subscribe2_options['dismiss_sender_warning'] = '1'; update_option( 'subscribe2_options', $this->subscribe2_options ); wp_die(); } public function subscribers_form_js() { wp_register_script( 's2_subscribers', S2URL . 'include/s2-subscribers' . $this->script_debug . '.js', array(), '1.5', true ); $translation_array = array( 'registered_confirm_single' => __( 'You are about to delete a registered user account, any posts made by this user will be assigned to you. Are you sure?', 'subscribe2' ), 'registered_confirm_plural' => __( 'You are about to delete registered user accounts, any posts made by these users will be assigned to you. Are you sure?', 'subscribe2' ), 'public_confirm_single' => __( 'You are about to delete a public subscriber. Are you sure?', 'subscribe2' ), 'public_confirm_plural' => __( 'You are about to delete public subscribers. Are you sure?', 'subscribe2' ), 'bulk_manage_all' => __( 'You are about to make Bulk Management changes to all Registered Users. Are you sure?', 'subscribe2' ), 'bulk_manage_single' => __( 'You are about to make Bulk Management changes to the selected Registered User. Are you sure?', 'subscribe2' ), 'bulk_manage_plural' => __( 'You are about to make Bulk Management changes to the selected Registered Users. Are you sure?', 'subscribe2' ), ); wp_localize_script( 's2_subscribers', 's2ScriptStrings', $translation_array ); wp_enqueue_script( 's2_subscribers' ); } public function subscribers_css() { echo ''; } /** * Adds a links directly to the settings page from the plugin page */ public function plugin_links( $links, $file ) { if ( S2DIR . 'subscribe2.php' === $file ) { $links[] = '' . __( 'Settings', 'subscribe2' ) . ''; } return $links; } /* ===== Menus ===== */ /** * Our subscriber management page */ public function subscribers_menu() { require_once S2PATH . 'admin/subscribers.php'; } /** * Our settings page */ public function settings_menu() { require_once S2PATH . 'admin/settings.php'; } /** * Our profile menu */ public function user_menu() { require_once S2PATH . 'admin/your-subscriptions.php'; } /** * Display the Write sub-menu */ public function write_menu() { require_once S2PATH . 'admin/send-email.php'; } /* ===== Write Toolbar Button Functions ===== */ /** * Register our button in the QuickTags bar */ public function button_init() { global $pagenow; if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ), true ) && ! strpos( esc_url( $_SERVER['REQUEST_URI'] ), 'page=s2_posts' ) ) { return; } if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) { return; } if ( 'true' === get_user_option( 'rich_editing' ) ) { // Hook into the rich text editor add_filter( 'mce_external_plugins', array( &$this, 'mce_plugin' ) ); add_filter( 'mce_buttons', array( &$this, 'mce_button' ) ); } else { wp_enqueue_script( 'subscribe2_button', S2URL . 'include/s2-button' . $this->script_debug . '.js', array( 'quicktags' ), '2.0', true ); } } /** * Add buttons for Rich Text Editor */ public function mce_plugin( $arr ) { $arr['subscribe2'] = S2URL . 'tinymce/editor-plugin4' . $this->script_debug . '.js'; return $arr; } public function mce_button( $arr ) { $arr[] = 'subscribe2'; return $arr; } /* ===== widget functions ===== */ /** * Function to add css and js files to admin header */ public function widget_s2counter_css_and_js() { // ensure we only add colorpicker js to widgets page if ( false !== stripos( esc_url( $_SERVER['REQUEST_URI'] ), 'widgets.php' ) ) { wp_enqueue_style( 'farbtastic' ); wp_enqueue_script( 'farbtastic' ); wp_register_script( 's2_colorpicker', S2URL . 'include/s2-colorpicker' . $this->script_debug . '.js', array( 'farbtastic' ), '1.3', true ); wp_enqueue_script( 's2_colorpicker' ); } } /* ===== meta box functions to allow per-post override ===== */ /** * Create meta box on write pages */ public function s2_meta_init( $post_type, $post ) { if ( true === $this->block_editor ) { return; } if ( 'yes' === $this->subscribe2_options['pages'] ) { $s2_post_types = array( 'page', 'post' ); } else { $s2_post_types = array( 'post' ); } $s2_post_types = apply_filters( 's2_post_types', $s2_post_types ); if ( ! in_array( $post_type, $s2_post_types, true ) ) { return; } add_meta_box( 'subscribe2', __( 'Subscribe2 Notification Override', 'subscribe2' ), array( &$this, 's2_override_meta' ), $post_type, 'advanced', 'default', array( '__block_editor_compatible_meta_box' => false, '__back_compat_meta_box' => true, ) ); add_meta_box( 'subscribe2-preview', __( 'Subscribe2 Preview', 'subscribe2' ), array( &$this, 's2_preview_meta' ), $post_type, 'side', 'default', array( '__block_editor_compatible_meta_box' => false, '__back_compat_meta_box' => true, ) ); if ( 'publish' === $post->post_status || ( 'private' === $post->post_status && 'yes' === $this->subscribe2_options['private'] ) ) { add_meta_box( 'subscribe2-resend', __( 'Subscribe2 Resend', 'subscribe2' ), array( &$this, 's2_resend_meta' ), $post_type, 'side', 'default', array( '__block_editor_compatible_meta_box' => false, '__back_compat_meta_box' => true, ) ); } } /** * Meta override box code */ public function s2_override_meta() { global $post_ID; $s2mail = get_post_meta( $post_ID, '_s2mail', true ); echo ''; echo esc_html__( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ); echo ' subscribe2_options['s2meta_default'] && '' === $s2mail ) ) { echo ' checked="checked"'; } echo ' />'; } /** * Meta override box form handler */ public function s2_meta_handler( $post_id ) { if ( ! isset( $_POST['s2meta_nonce'] ) || ! wp_verify_nonce( $_POST['s2meta_nonce'], wp_hash( plugin_basename( __FILE__ ) ) ) ) { return $post_id; } if ( 'page' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; } } if ( isset( $_POST['s2_meta_field'] ) && 'no' === $_POST['s2_meta_field'] ) { update_post_meta( $post_id, '_s2mail', $_POST['s2_meta_field'] ); } else { update_post_meta( $post_id, '_s2mail', 'yes' ); } } /** * Meta preview box code */ public function s2_preview_meta() { echo '' . esc_html__( 'Send preview email of this post to currently logged in user:', 'subscribe2' ) . '
' . "\r\n"; echo '' . "\r\n"; } /** * Meta preview box handler */ public function s2_preview_handler() { if ( isset( $_POST['s2_preview'] ) ) { if ( defined( 'DOING_CRON' ) && DOING_CRON ) { return; } global $post, $current_user; if ( 'never' !== $this->subscribe2_options['email_freq'] ) { $this->subscribe2_cron( $current_user->user_email ); } else { $this->publish( $post, $current_user->user_email ); } } } /** * Meta resend box code */ public function s2_resend_meta() { echo '' . esc_html__( 'Resend the notification email of this post to current subscribers:', 'subscribe2' ) . '
' . "\r\n"; echo '' . "\r\n"; } /** * Meta resend box handler */ public function s2_resend_handler() { if ( isset( $_POST['s2_resend'] ) ) { if ( defined( 'DOING_CRON' ) && DOING_CRON ) { return; } global $post; $this->publish( $post ); } } /* ===== WordPress menu helper functions ===== */ /** * Collects the signup date for all public subscribers */ public function signup_date( $email = '' ) { if ( '' === $email ) { return false; } global $wpdb; if ( ! empty( $this->signup_dates ) ) { return $this->signup_dates[ $email ]; } else { $results = $wpdb->get_results( "SELECT email, date FROM $wpdb->subscribe2", ARRAY_N ); foreach ( $results as $result ) { $this->signup_dates[ $result[0] ] = $result[1]; } return $this->signup_dates[ $email ]; } } /** * Collects the signup time for all public subscribers */ public function signup_time( $email = '' ) { if ( '' === $email ) { return false; } global $wpdb; if ( ! empty( $this->signup_times ) ) { return $this->signup_times[ $email ]; } else { $results = $wpdb->get_results( "SELECT email, time FROM $wpdb->subscribe2", ARRAY_N ); foreach ( $results as $result ) { $this->signup_times[ $result[0] ] = $result[1]; } return $this->signup_times[ $email ]; } } /** * Collects the ip address for all public subscribers */ public function signup_ip( $email = '' ) { if ( '' === $email ) { return false; } global $wpdb; if ( ! empty( $this->signup_ips ) ) { return $this->signup_ips[ $email ]; } else { $results = $wpdb->get_results( "SELECT email, ip FROM $wpdb->subscribe2", ARRAY_N ); foreach ( $results as $result ) { $this->signup_ips[ $result[0] ] = $result[1]; } return $this->signup_ips[ $email ]; } } /** * Export subscriber emails and other details to CSV */ public function prepare_export( $subscribers ) { if ( empty( $subscribers ) ) { return; } $subscribers = explode( ",\r\n", $subscribers ); natcasesort( $subscribers ); $exportcsv = _x( 'User Email,User Type,User Name,Confirm Date,IP', 'Comma Separated Column Header names for CSV Export', 'subscribe2' ); $all_cats = $this->all_cats( false, 'ID' ); foreach ( $all_cats as $cat ) { $exportcsv .= ',' . html_entity_decode( $cat->cat_name, ENT_QUOTES ); $cat_ids[] = $cat->term_id; } $exportcsv .= "\r\n"; foreach ( $subscribers as $subscriber ) { if ( $this->is_registered( $subscriber ) ) { $user_id = $this->get_user_id( $subscriber ); $user_info = get_userdata( $user_id ); $cats = explode( ',', get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true ) ); $subscribed_cats = ''; foreach ( $cat_ids as $cat ) { ( in_array( (string) $cat, $cats, true ) ) ? $subscribed_cats .= ',Yes' : $subscribed_cats .= ',No'; } $exportcsv .= $subscriber . ','; $exportcsv .= __( 'Registered User', 'subscribe2' ); $exportcsv .= ',' . $user_info->display_name; $exportcsv .= ',,' . $subscribed_cats . "\r\n"; } else { if ( '1' === $this->is_public( $subscriber ) ) { $exportcsv .= $subscriber . ',' . __( 'Confirmed Public Subscriber', 'subscribe2' ) . ',,' . $this->signup_date( $subscriber ) . ',' . $this->signup_ip( $subscriber ) . "\r\n"; } elseif ( '0' === $this->is_public( $subscriber ) ) { $exportcsv .= $subscriber . ',' . __( 'Unconfirmed Public Subscriber', 'subscribe2' ) . ',,' . $this->signup_date( $subscriber ) . ',' . $this->signup_ip( $subscriber ) . "\r\n"; } } } return $exportcsv; } /** * Display a table of post formats supported by the currently active theme */ public function display_format_form( $formats, $selected = array() ) { $half = ( count( $formats[0] ) / 2 ); $i = 0; $j = 0; echo '' . "\r\n"; echo '' . "\r\n"; echo ' | |
' . "\r\n"; foreach ( $formats[0] as $format ) { if ( $i >= $half && 0 === $j ) { echo ' | ' . "\r\n";
$j++;
}
if ( 0 === $j ) {
echo ' ' . "\r\n"; } else { echo ' ' . "\r\n"; } $i++; } echo ' |
' . esc_html__( 'Current UTC time is', 'subscribe2' ) . ': ' . "\r\n"; echo '' . esc_html( date_i18n( $date_format . ' @ ' . $time_format, false, 'gmt' ) ) . '
' . "\r\n"; echo '' . esc_html__( 'Current blog time is', 'subscribe2' ) . ': ' . "\r\n"; echo '' . esc_html( date_i18n( $date_format . ' @ ' . $time_format ) ) . '
' . "\r\n"; echo '' . esc_html__( 'Next email notification will be sent when your blog time is after', 'subscribe2' ) . ': ' . "\r\n"; echo ''; echo ''; echo '' . esc_html( date_i18n( $date_format, $scheduled_time + $offset ) ) . ''; echo ' @ ' . esc_html( date_i18n( $time_format, $scheduled_time + $offset ) ) . ' '; echo '' . esc_html__( 'Edit', 'subscribe2' ) . '' . "\r\n"; echo '' . "\r\n"; echo '' . "\r\n"; $hours = array( '12:00 am', '1:00 am', '2:00 am', '3:00 am', '4:00 am', '5:00 am', '6:00 am', '7:00 am', '8:00 am', '9:00 am', '10:00 am', '11:00 am', '12:00 pm', '1:00 pm', '2:00 pm', '3:00 pm', '4:00 pm', '5:00 pm', '6:00 pm', '7:00 pm', '8:00 pm', '9:00 pm', '10:00 pm', '11:00 pm' ); $current_hour = intval( date_i18n( 'G', $scheduled_time + $offset ) ); echo '' . "\r\n"; echo '' . esc_html__( 'Update', 'subscribe2' ) . '' . "\r\n"; echo '' . esc_html__( 'Revert', 'subscribe2' ) . '' . "\r\n"; if ( ! empty( $this->subscribe2_options['last_s2cron'] ) ) { echo '
' . esc_html__( 'Attempt to resend the last Digest Notification email', 'subscribe2' ) . ': '; echo '
' . "\r\n"; } } else { echo '' . esc_html__( 'Subscribe / Unsubscribe', 'subscribe2' ) . ' | ' . "\r\n"; echo '' . "\r\n"; echo '' . esc_html__( 'Check if you want to receive email notification when new posts are published', 'subscribe2' ) . '' . "\r\n"; echo ' |
---|