function sb_we_settings()
{
    if (sb_we_post('submit')) {
        sb_we_update_settings();
    }
    if (sb_we_post('test_send')) {
        global $current_user;
        get_currentuserinfo();
        wp_new_user_notification($current_user->ID, '[User password will appear here]');
        sb_we_display_message('Test email sent to "' . $current_user->user_email . '"');
    }
    $html = '';
    $settings = get_option('sb_we_settings');
    $page_options = array('general_settings_label' => array('title' => 'General Settings', 'type' => 'label', 'style' => 'width: 500px;', 'description' => 'These settings effect all of this plugin and, in some cases, all of your site.'), 'settings[header_from_email]' => array('title' => 'From Email Address', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Global option change the from email address for all site emails'), 'settings[header_from_name]' => array('title' => 'From Name', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Global option change the from name for all site emails'), 'settings[header_send_as]' => array('title' => 'Send Email As', 'type' => 'select', 'style' => 'width: 100px;', 'options' => array('text' => 'TEXT', 'html' => 'HTML'), 'description' => 'Send email as Text or HTML (Remember to remove html from text emails).'), 'settings[set_global_headers]' => array('title' => 'Set Global Email Headers', 'type' => 'yes_no', 'style' => 'width: 500px;', 'description' => 'This is one of those "hit it with a hammer" type functions to set to yes when you might be having issues with the from name and address setting. Or setting it to no as and when another plugin is being effected by Welcome Email Editor\'s existence.'), 'welcome_email_settings_label' => array('title' => 'Welcome Email Settings', 'type' => 'label', 'style' => 'width: 500px;', 'description' => 'These settings are for the email sent to the new user on their signup.'), 'settings[user_subject]' => array('title' => 'User Email Subject', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Subject line for the welcome email sent to the user.'), 'settings[user_body]' => array('title' => 'User Email Body', 'type' => 'textarea', 'style' => 'width: 650px; height: 500px;', 'description' => 'Body content for the welcome email sent to the user.'), 'settings[we_attachment_url]' => array('title' => 'Attachment URL', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'If you want the welcome email to have an attachment then put the URL here. The file MUST be on THIS server in a web servable directory. If you don\'t understand this then use the WordPress media uploader and paste the FULL URL into this box and it will do the rest.'), 'settings[header_additional]' => array('title' => 'Additional Email Headers', 'type' => 'textarea', 'style' => 'width: 550px; height: 200px;', 'description' => 'Optional field for advanced users to add more headers. Dont\'t forget to separate headers with \\r\\n.'), 'settings[header_reply_to]' => array('title' => 'Reply To Email Address', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Optional Header sent to change the reply to address for new user notification.'), 'welcome_email_admin_settings_label' => array('title' => 'Welcome Email Admin Notification Settings', 'type' => 'label', 'style' => 'width: 500px;', 'description' => 'These settings are for the email sent to the admin on a new user signup.'), 'settings[admin_subject]' => array('title' => 'Admin Email Subject', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Subject Line for the email sent to the admin user(s).'), 'settings[admin_body]' => array('title' => 'Admin Email Body', 'type' => 'textarea', 'style' => 'width: 650px; height: 300px;', 'description' => 'Body content for the email sent to the admin user(s).'), 'settings[admin_notify_user_id]' => array('title' => 'Send Admin Email To...', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'This allows you to type in the User IDs of the people who you want the admin notification to be sent to. 1 is admin normally but just add more separating by commas (eg: 1,2,3,4).'), 'forgot_password_settings_label' => array('title' => 'User Forgot Password Email Settings', 'type' => 'label', 'style' => 'width: 500px;', 'description' => 'These settings are for the email sent to the user when they use the inbuilt Wordpress forgot password functionality.'), 'settings[password_reminder_subject]' => array('title' => 'Forgot Password Email Subject', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Subject line for the forgot password email that a user can send to themselves using the login screen. Use [blogname] where appropriate.'), 'settings[password_reminder_body]' => array('title' => 'Forgot Password Message', 'type' => 'textarea', 'style' => 'width: 650px; height: 500px;', 'description' => 'Content for the forgot password email that the user can send to themselves via the login screen. Use [blog_name], [site_url], [reset_url] and [user_login] where appropriate. Note to use HTML in this box only if you have set the send mode to HTML. If not text will be used and any HTML ignored.'), 'submit' => array('title' => '', 'type' => 'submit', 'value' => 'Update Settings'), 'test_send' => array('title' => '', 'type' => 'submit', 'value' => 'Test Emails (Save first, will send to current user)'));
    $html .= '<div style="margin-bottom: 10px;">' . __('This page allows you to update the Wordpress welcome email and add headers to make it less likely to fall into spam. You can edit the templates for both the admin and user emails and assign admin members to receive the notifications. Use the following hooks in any of the boxes below: [site_url], [login_url], [user_email], [user_login], [plaintext_password], [blog_name], [admin_email], [user_id], [custom_fields], [first_name], [last_name], [date], [time], [bp_custom_fields] (buddypress custom fields .. admin only)', 'sb_we') . '</div>';
    $html .= sb_we_start_box('Settings');
    $html .= '<form method="POST">';
    $html .= '<table class="widefat form-table">';
    $i = 0;
    foreach ($page_options as $name => $options) {
        $options['type'] = isset($options['type']) ? $options['type'] : '';
        $options['description'] = isset($options['description']) ? $options['description'] : '';
        $options['class'] = isset($options['class']) ? $options['class'] : false;
        $options['style'] = isset($options['style']) ? $options['style'] : false;
        $options['rows'] = isset($options['rows']) ? $options['rows'] : false;
        $options['cols'] = isset($options['cols']) ? $options['cols'] : false;
        if ($options['type'] == 'submit') {
            $value = $options['value'];
        } else {
            $tmp_name = str_replace('settings[', '', $name);
            $tmp_name = str_replace(']', '', $tmp_name);
            $value = stripslashes(sb_we_post($tmp_name, isset($settings->{$tmp_name}) ? $settings->{$tmp_name} : ''));
        }
        $title = isset($options['title']) ? $options['title'] : false;
        if ($options['type'] == 'label') {
            $title = '<strong>' . $title . '</strong>';
        }
        $html .= '	<tr class="' . ($i % 2 ? 'alternate' : '') . '">
					<th style="vertical-align: top;">
						' . $title . '
						' . ($options['description'] && $options['type'] != 'label' ? '<div style="font-size: 10px; color: gray;">' . $options['description'] . '</div>' : '') . '
					</th>
					<td style="' . ($options['type'] == 'submit' ? 'text-align: right;' : '') . '">';
        switch ($options['type']) {
            case 'label':
                $html .= $options['description'];
                break;
            case 'text':
                $html .= sb_we_get_text($name, $value, $options['class'], $options['style']);
                break;
            case 'yes_no':
                $html .= sb_we_get_yes_no($name, $value, $options['class'], $options['style']);
                break;
            case 'textarea':
                $html .= sb_we_get_textarea($name, $value, $options['class'], $options['style'], $options['rows'], $options['cols']);
                break;
            case 'select':
                $html .= sb_we_get_select($name, $options['options'], $value, $options['class'], $options['style']);
                break;
            case 'submit':
                $html .= sb_we_get_submit($name, $value, $options['class'], $options['style']);
                break;
        }
        $html .= '		</td>
				</tr>';
        $i++;
    }
    $html .= '</table>';
    $html .= '</form>';
    $html .= sb_we_end_box();
    return $html;
}
function sb_we_settings()
{
    if (sb_we_post('submit')) {
        sb_we_update_settings();
    }
    $html = '';
    $settings = get_option('sb_we_settings');
    $page_options = array('user_subject' => array('title' => 'User Email Subject', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Subject line for the email sent to the user.'), 'user_body' => array('title' => 'User Email Body', 'type' => 'textarea', 'style' => 'width: 550px; height: 200px;', 'description' => 'Body content for the email sent to the user.'), 'admin_subject' => array('title' => 'Admin Email Subject', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Subject Line for the email sent to the admin user(s).'), 'admin_body' => array('title' => 'Admin Email Body', 'type' => 'textarea', 'style' => 'width: 550px; height: 200px;', 'description' => 'Body content for the email sent to the admin user(s).'), 'header_from_email' => array('title' => 'From Email Address', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Optional Header sent to change the from email address for new user notification.'), 'header_reply_to' => array('title' => 'Reply To Email Address', 'type' => 'text', 'style' => 'width: 500px;', 'description' => 'Optional Header sent to change the reply to address for new user notification.'), 'header_send_as' => array('title' => 'Send Email As', 'type' => 'select', 'style' => 'width: 100px;', 'options' => array('text' => 'TEXT', 'html' => 'HTML'), 'description' => 'Send email as Text or HTML (Rememeber to remove html from text emails).'), 'header_additional' => array('title' => 'Additional Email Headers', 'type' => 'textarea', 'style' => 'width: 550px; height: 200px;', 'description' => 'Optional field for advanced users to add more headers. Dont\'t forget to separate headers with \\r\\n.'), 'submit' => array('title' => '', 'type' => 'submit', 'value' => 'Update Settings'));
    $html .= '<div style="margin-bottom: 10px;">' . __('This page allows you to update the Wordpress welcome email and add headers to make it less likely to fall into spam. You can edit the templates for both the admin and user emails and assign admin members to receive the notifications. Use the following hooks in any of the boxes below: [site_url], [login_url], [user_email], [user_login], [plaintext_password], [blog_name], [admin_email]', 'sb_we') . '</div>';
    $html .= sb_we_start_box('Settings');
    $html .= '<form method="POST">';
    $html .= '<table class="widefat form-table">';
    $i = 0;
    foreach ($page_options as $name => $options) {
        if ($options['type'] == 'submit') {
            $value = $options['value'];
        } else {
            $value = stripslashes(sb_we_post($name, $settings->{$name}));
        }
        $title = isset($options['title']) ? $options['title'] : false;
        $html .= '	<tr class="' . ($i % 2 ? 'alternate' : '') . '">
					<th style="vertical-align: top;">
						' . $title . '
						' . ($options['description'] ? '<div style="font-size: 10px; color: gray;">' . $options['description'] . '</div>' : '') . '
					</th>
					<td style="' . ($options['type'] == 'submit' ? 'text-align: right;' : '') . '">';
        switch ($options['type']) {
            case 'text':
                $html .= sb_we_get_text($name, $value, $options['class'], $options['style']);
                break;
            case 'textarea':
                $html .= sb_we_get_textarea($name, $value, $options['class'], $options['style'], $options['rows'], $options['cols']);
                break;
            case 'select':
                $html .= sb_we_get_select($name, $options['options'], $value, $options['class'], $options['style']);
                break;
            case 'submit':
                $html .= sb_we_get_submit($name, $value, $options['class'], $options['style']);
                break;
        }
        $html .= '		</td>
				</tr>';
        $i++;
    }
    $html .= '</table>';
    $html .= '</form>';
    $html .= sb_we_end_box();
    return $html;
}
Exemplo n.º 3
0
function sb_we_settings()
{
    if (sb_we_post('submit')) {
        sb_we_update_settings();
    }
    if (sb_we_post('test_send')) {
        global $current_user;
        get_currentuserinfo();
        wp_new_user_notification($current_user->ID, false, 'both');
        sb_we_display_message(__('Test email sent to', SB_WE_DOMAIN) . ' "' . $current_user->user_email . '"');
    }
    $html = '';
    $settings = get_option('sb_we_settings');
    $page_options = array('general_settings_label' => array('title' => __('General Settings', SB_WE_DOMAIN), 'type' => 'label', 'style' => 'width: 500px;', 'description' => __('These settings effect all of this plugin and, in some cases, all of your site.', SB_WE_DOMAIN)), 'settings[header_from_email]' => array('title' => __('From Email Address', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Global option change the from email address for all site emails', SB_WE_DOMAIN)), 'settings[header_from_name]' => array('title' => __('From Name', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Global option change the from name for all site emails', SB_WE_DOMAIN)), 'settings[header_send_as]' => array('title' => __('Send Email As', SB_WE_DOMAIN), 'type' => 'select', 'style' => 'width: 100px;', 'options' => array('text' => __('TEXT', SB_WE_DOMAIN), 'html' => __('HTML', SB_WE_DOMAIN)), 'description' => __('Send email as Text or HTML (Remember to remove html from text emails).', SB_WE_DOMAIN)), 'settings[set_global_headers]' => array('title' => __('Set Global Email Headers', SB_WE_DOMAIN), 'type' => 'yes_no', 'style' => 'margin-left: 10px;', 'description' => __('This is one of those "hit it with a hammer" type functions to set to yes when you might be having issues with the from name and address setting. Or setting it to no as and when another plugin is being effected by Welcome Email Editor\'s existence.', SB_WE_DOMAIN)), 'welcome_email_settings_label' => array('title' => __('Welcome Email Settings', SB_WE_DOMAIN), 'type' => 'label', 'style' => 'width: 500px;', 'description' => __('These settings are for the email sent to the new user on their signup.', SB_WE_DOMAIN)), 'settings[user_subject]' => array('title' => __('User Email Subject', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Subject line for the welcome email sent to the user.', SB_WE_DOMAIN)), 'settings[user_body]' => array('title' => __('User Email Body', SB_WE_DOMAIN), 'type' => 'textarea', 'style' => 'width: 650px; height: 500px;', 'description' => __('Body content for the welcome email sent to the user.', SB_WE_DOMAIN)), 'settings[we_attachment_url]' => array('title' => __('Attachment URL', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('If you want the welcome email to have an attachment then put the URL here. The file MUST be on THIS server in a web servable directory. If you don\'t understand this then use the WordPress media uploader and paste the FULL URL into this box and it will do the rest.', SB_WE_DOMAIN)), 'settings[header_additional]' => array('title' => __('Additional Email Headers', SB_WE_DOMAIN), 'type' => 'textarea', 'style' => 'width: 550px; height: 200px;', 'description' => __('Optional field for advanced users to add more headers. Dont\'t forget to separate headers with \\r\\n.', SB_WE_DOMAIN)), 'settings[header_reply_to]' => array('title' => __('Reply To Email Address', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Optional Header sent to change the reply to address for new user notification.', SB_WE_DOMAIN)), 'welcome_email_admin_settings_label' => array('title' => __('Welcome Email Admin Notification Settings', SB_WE_DOMAIN), 'type' => 'label', 'style' => 'width: 500px;', 'description' => __('These settings are for the email sent to the admin on a new user signup.', SB_WE_DOMAIN)), 'settings[admin_subject]' => array('title' => __('Admin Email Subject', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Subject Line for the email sent to the admin user(s).', SB_WE_DOMAIN)), 'settings[admin_body]' => array('title' => __('Admin Email Body', SB_WE_DOMAIN), 'type' => 'textarea', 'style' => 'width: 650px; height: 300px;', 'description' => __('Body content for the email sent to the admin user(s).', SB_WE_DOMAIN)), 'settings[admin_notify_user_id]' => array('title' => __('Send Admin Email To...', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('This allows you to type in the User IDs of the people who you want the admin notification to be sent to. 1 is admin normally but just add more separating by commas (eg: 1,2,3,4).', SB_WE_DOMAIN)), 'forgot_password_settings_label' => array('title' => __('User Forgot Password Email Settings', SB_WE_DOMAIN), 'type' => 'label', 'style' => 'width: 500px;', 'description' => __('These settings are for the email sent to the user when they use the inbuilt Wordpress forgot password functionality.', SB_WE_DOMAIN)), 'settings[password_reminder_subject]' => array('title' => __('Forgot Password Email Subject', SB_WE_DOMAIN), 'type' => 'text', 'style' => 'width: 500px;', 'description' => __('Subject line for the forgot password email that a user can send to themselves using the login screen. Use [blog_name] where appropriate.', SB_WE_DOMAIN)), 'settings[password_reminder_body]' => array('title' => __('Forgot Password Message', SB_WE_DOMAIN), 'type' => 'textarea', 'style' => 'width: 650px; height: 500px;', 'description' => __('Content for the forgot password email that the user can send to themselves via the login screen. Use [blog_name], [site_url], [reset_url] and [user_login] where appropriate. Note to use HTML in this box only if you have set the send mode to HTML. If not text will be used and any HTML ignored.', SB_WE_DOMAIN)), 'submit' => array('title' => '', 'type' => 'submit', 'value' => __('Update Settings', SB_WE_DOMAIN)), 'test_send' => array('title' => '', 'type' => 'submit', 'value' => __('Test Emails (Save first, will send to current user)', SB_WE_DOMAIN)));
    $page_options = apply_filters('sb_we_settings_fields', $page_options);
    $html .= '<div style="margin-bottom: 10px;">' . __('This page allows you to update the Wordpress welcome email and add headers to make it less likely to fall into spam. You can edit the templates for both the admin and user emails and assign admin members to receive the notifications. Use the following hooks in any of the boxes below: [site_url], [login_url], [reset_pass_url], [user_email], [user_login], [blog_name], [admin_email], [user_id], [custom_fields], [first_name], [last_name], [date], [time], [bp_custom_fields] (buddypress custom fields .. admin only), [post_data] (admin only. Sends $_REQUEST)', SB_WE_DOMAIN) . '</div>';
    $html .= sb_we_start_box(__('Settings', SB_WE_DOMAIN));
    if (version_compare(get_bloginfo('version'), '4.3') >= 0) {
        //set the password hash and generate a link to go and set it rather than sending it to them in plaintext
        if (!get_option('sb_we_hide_nag')) {
            /* LS 10/11/2015 - added extra class */
            $html .= ' <div class="updated sbwe-updated"> 
					<p>' . __('IMPORTANT: As of WP 4.3, a plain text password is no longer passed to the Welcome Email functionality. If you start to receive emails with a password value of "admin" or "both" then you will need to update your message below. The new system doesn\'t include a password to give the user and, instead, asks for the user to click a link to set their password directly using the WordPress login pages. Whilst this is less convenient than it was before we do have no control over things so we need to follow the WordPress model. Provision has been made though for a password to be included where it is set on the previous and included in the page data. See the settings below for more information.', SB_WE_DOMAIN) . '<br /><a href="' . admin_url('options-general.php?page=sb_we_settings&hide_nag=1') . '">' . __('Thanks, I\'ve read this! Don\'t show again', SB_WE_DOMAIN) . '</a></p>
				</div>';
        }
    }
    $html .= '<form method="POST">';
    $html .= '<table class="widefat">';
    $i = 0;
    foreach ($page_options as $name => $options) {
        $options['type'] = isset($options['type']) ? $options['type'] : '';
        $options['description'] = isset($options['description']) ? $options['description'] : '';
        $options['class'] = isset($options['class']) ? $options['class'] : false;
        $options['style'] = isset($options['style']) ? $options['style'] : false;
        $options['rows'] = isset($options['rows']) ? $options['rows'] : false;
        $options['cols'] = isset($options['cols']) ? $options['cols'] : false;
        if ($options['type'] == 'submit') {
            $value = $options['value'];
        } else {
            $tmp_name = str_replace('settings[', '', $name);
            $tmp_name = str_replace(']', '', $tmp_name);
            $value = stripslashes(sb_we_post($tmp_name, isset($settings->{$tmp_name}) ? $settings->{$tmp_name} : ''));
        }
        $title = isset($options['title']) ? $options['title'] : false;
        if ($options['type'] == 'label') {
            $title = '<strong>' . $title . '</strong>';
        }
        $html .= '	<tr class="' . ($i % 2 ? 'alternate' : '') . '">
					<th style="vertical-align: top;">
						' . $title . '
						' . ($options['description'] && $options['type'] != 'label' ? '<div style="font-size: 10px; color: gray;">' . $options['description'] . '</div>' : '') . '
					</th>
					<td style="' . ($options['type'] == 'submit' ? 'text-align: right;' : '') . '">';
        switch ($options['type']) {
            case 'label':
                $html .= $options['description'];
                break;
            case 'text':
                $html .= sb_we_get_text($name, $value, $options['class'], $options['style']);
                break;
            case 'yes_no':
                $html .= sb_we_get_yes_no($name, $value, $options['class'], $options['style']);
                break;
            case 'textarea':
                $html .= sb_we_get_textarea($name, $value, $options['class'], $options['style'], $options['rows'], $options['cols']);
                break;
            case 'select':
                $html .= sb_we_get_select($name, $options['options'], $value, $options['class'], $options['style']);
                break;
            case 'submit':
                $html .= sb_we_get_submit($name, $value, $options['class'], $options['style']);
                break;
        }
        $html .= '		</td>
				</tr>';
        $i++;
    }
    $html .= '</table>';
    $html .= '</form>';
    $html .= sb_we_end_box();
    return $html;
}